mutation.go 1.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448
  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/batchmsg"
  13. "wechat-api/ent/category"
  14. "wechat-api/ent/chatrecords"
  15. "wechat-api/ent/chatsession"
  16. "wechat-api/ent/contact"
  17. "wechat-api/ent/custom_types"
  18. "wechat-api/ent/employee"
  19. "wechat-api/ent/employeeconfig"
  20. "wechat-api/ent/label"
  21. "wechat-api/ent/labelrelationship"
  22. "wechat-api/ent/labeltagging"
  23. "wechat-api/ent/message"
  24. "wechat-api/ent/messagerecords"
  25. "wechat-api/ent/msg"
  26. "wechat-api/ent/predicate"
  27. "wechat-api/ent/server"
  28. "wechat-api/ent/sopnode"
  29. "wechat-api/ent/sopstage"
  30. "wechat-api/ent/soptask"
  31. "wechat-api/ent/token"
  32. "wechat-api/ent/tutorial"
  33. "wechat-api/ent/usagedetail"
  34. "wechat-api/ent/usagetotal"
  35. "wechat-api/ent/workexperience"
  36. "wechat-api/ent/wpchatroom"
  37. "wechat-api/ent/wpchatroommember"
  38. "wechat-api/ent/wx"
  39. "wechat-api/ent/wxcard"
  40. "wechat-api/ent/wxcarduser"
  41. "wechat-api/ent/wxcardvisit"
  42. "entgo.io/ent"
  43. "entgo.io/ent/dialect/sql"
  44. )
  45. const (
  46. // Operation types.
  47. OpCreate = ent.OpCreate
  48. OpDelete = ent.OpDelete
  49. OpDeleteOne = ent.OpDeleteOne
  50. OpUpdate = ent.OpUpdate
  51. OpUpdateOne = ent.OpUpdateOne
  52. // Node types.
  53. TypeAgent = "Agent"
  54. TypeAgentBase = "AgentBase"
  55. TypeAliyunAvatar = "AliyunAvatar"
  56. TypeBatchMsg = "BatchMsg"
  57. TypeCategory = "Category"
  58. TypeChatRecords = "ChatRecords"
  59. TypeChatSession = "ChatSession"
  60. TypeContact = "Contact"
  61. TypeEmployee = "Employee"
  62. TypeEmployeeConfig = "EmployeeConfig"
  63. TypeLabel = "Label"
  64. TypeLabelRelationship = "LabelRelationship"
  65. TypeLabelTagging = "LabelTagging"
  66. TypeMessage = "Message"
  67. TypeMessageRecords = "MessageRecords"
  68. TypeMsg = "Msg"
  69. TypeServer = "Server"
  70. TypeSopNode = "SopNode"
  71. TypeSopStage = "SopStage"
  72. TypeSopTask = "SopTask"
  73. TypeToken = "Token"
  74. TypeTutorial = "Tutorial"
  75. TypeUsageDetail = "UsageDetail"
  76. TypeUsageTotal = "UsageTotal"
  77. TypeWorkExperience = "WorkExperience"
  78. TypeWpChatroom = "WpChatroom"
  79. TypeWpChatroomMember = "WpChatroomMember"
  80. TypeWx = "Wx"
  81. TypeWxCard = "WxCard"
  82. TypeWxCardUser = "WxCardUser"
  83. TypeWxCardVisit = "WxCardVisit"
  84. )
  85. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  86. type AgentMutation struct {
  87. config
  88. op Op
  89. typ string
  90. id *uint64
  91. created_at *time.Time
  92. updated_at *time.Time
  93. deleted_at *time.Time
  94. name *string
  95. role *string
  96. status *int
  97. addstatus *int
  98. background *string
  99. examples *string
  100. organization_id *uint64
  101. addorganization_id *int64
  102. dataset_id *string
  103. collection_id *string
  104. clearedFields map[string]struct{}
  105. wx_agent map[uint64]struct{}
  106. removedwx_agent map[uint64]struct{}
  107. clearedwx_agent bool
  108. token_agent map[uint64]struct{}
  109. removedtoken_agent map[uint64]struct{}
  110. clearedtoken_agent bool
  111. done bool
  112. oldValue func(context.Context) (*Agent, error)
  113. predicates []predicate.Agent
  114. }
  115. var _ ent.Mutation = (*AgentMutation)(nil)
  116. // agentOption allows management of the mutation configuration using functional options.
  117. type agentOption func(*AgentMutation)
  118. // newAgentMutation creates new mutation for the Agent entity.
  119. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  120. m := &AgentMutation{
  121. config: c,
  122. op: op,
  123. typ: TypeAgent,
  124. clearedFields: make(map[string]struct{}),
  125. }
  126. for _, opt := range opts {
  127. opt(m)
  128. }
  129. return m
  130. }
  131. // withAgentID sets the ID field of the mutation.
  132. func withAgentID(id uint64) agentOption {
  133. return func(m *AgentMutation) {
  134. var (
  135. err error
  136. once sync.Once
  137. value *Agent
  138. )
  139. m.oldValue = func(ctx context.Context) (*Agent, error) {
  140. once.Do(func() {
  141. if m.done {
  142. err = errors.New("querying old values post mutation is not allowed")
  143. } else {
  144. value, err = m.Client().Agent.Get(ctx, id)
  145. }
  146. })
  147. return value, err
  148. }
  149. m.id = &id
  150. }
  151. }
  152. // withAgent sets the old Agent of the mutation.
  153. func withAgent(node *Agent) agentOption {
  154. return func(m *AgentMutation) {
  155. m.oldValue = func(context.Context) (*Agent, error) {
  156. return node, nil
  157. }
  158. m.id = &node.ID
  159. }
  160. }
  161. // Client returns a new `ent.Client` from the mutation. If the mutation was
  162. // executed in a transaction (ent.Tx), a transactional client is returned.
  163. func (m AgentMutation) Client() *Client {
  164. client := &Client{config: m.config}
  165. client.init()
  166. return client
  167. }
  168. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  169. // it returns an error otherwise.
  170. func (m AgentMutation) Tx() (*Tx, error) {
  171. if _, ok := m.driver.(*txDriver); !ok {
  172. return nil, errors.New("ent: mutation is not running in a transaction")
  173. }
  174. tx := &Tx{config: m.config}
  175. tx.init()
  176. return tx, nil
  177. }
  178. // SetID sets the value of the id field. Note that this
  179. // operation is only accepted on creation of Agent entities.
  180. func (m *AgentMutation) SetID(id uint64) {
  181. m.id = &id
  182. }
  183. // ID returns the ID value in the mutation. Note that the ID is only available
  184. // if it was provided to the builder or after it was returned from the database.
  185. func (m *AgentMutation) ID() (id uint64, exists bool) {
  186. if m.id == nil {
  187. return
  188. }
  189. return *m.id, true
  190. }
  191. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  192. // That means, if the mutation is applied within a transaction with an isolation level such
  193. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  194. // or updated by the mutation.
  195. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  196. switch {
  197. case m.op.Is(OpUpdateOne | OpDeleteOne):
  198. id, exists := m.ID()
  199. if exists {
  200. return []uint64{id}, nil
  201. }
  202. fallthrough
  203. case m.op.Is(OpUpdate | OpDelete):
  204. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  205. default:
  206. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  207. }
  208. }
  209. // SetCreatedAt sets the "created_at" field.
  210. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  211. m.created_at = &t
  212. }
  213. // CreatedAt returns the value of the "created_at" field in the mutation.
  214. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  215. v := m.created_at
  216. if v == nil {
  217. return
  218. }
  219. return *v, true
  220. }
  221. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  222. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  224. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  225. if !m.op.Is(OpUpdateOne) {
  226. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  227. }
  228. if m.id == nil || m.oldValue == nil {
  229. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  230. }
  231. oldValue, err := m.oldValue(ctx)
  232. if err != nil {
  233. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  234. }
  235. return oldValue.CreatedAt, nil
  236. }
  237. // ResetCreatedAt resets all changes to the "created_at" field.
  238. func (m *AgentMutation) ResetCreatedAt() {
  239. m.created_at = nil
  240. }
  241. // SetUpdatedAt sets the "updated_at" field.
  242. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  243. m.updated_at = &t
  244. }
  245. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  246. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  247. v := m.updated_at
  248. if v == nil {
  249. return
  250. }
  251. return *v, true
  252. }
  253. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  254. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  256. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  257. if !m.op.Is(OpUpdateOne) {
  258. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  259. }
  260. if m.id == nil || m.oldValue == nil {
  261. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  262. }
  263. oldValue, err := m.oldValue(ctx)
  264. if err != nil {
  265. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  266. }
  267. return oldValue.UpdatedAt, nil
  268. }
  269. // ResetUpdatedAt resets all changes to the "updated_at" field.
  270. func (m *AgentMutation) ResetUpdatedAt() {
  271. m.updated_at = nil
  272. }
  273. // SetDeletedAt sets the "deleted_at" field.
  274. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  275. m.deleted_at = &t
  276. }
  277. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  278. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  279. v := m.deleted_at
  280. if v == nil {
  281. return
  282. }
  283. return *v, true
  284. }
  285. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  286. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  288. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  289. if !m.op.Is(OpUpdateOne) {
  290. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  291. }
  292. if m.id == nil || m.oldValue == nil {
  293. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  294. }
  295. oldValue, err := m.oldValue(ctx)
  296. if err != nil {
  297. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  298. }
  299. return oldValue.DeletedAt, nil
  300. }
  301. // ClearDeletedAt clears the value of the "deleted_at" field.
  302. func (m *AgentMutation) ClearDeletedAt() {
  303. m.deleted_at = nil
  304. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  305. }
  306. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  307. func (m *AgentMutation) DeletedAtCleared() bool {
  308. _, ok := m.clearedFields[agent.FieldDeletedAt]
  309. return ok
  310. }
  311. // ResetDeletedAt resets all changes to the "deleted_at" field.
  312. func (m *AgentMutation) ResetDeletedAt() {
  313. m.deleted_at = nil
  314. delete(m.clearedFields, agent.FieldDeletedAt)
  315. }
  316. // SetName sets the "name" field.
  317. func (m *AgentMutation) SetName(s string) {
  318. m.name = &s
  319. }
  320. // Name returns the value of the "name" field in the mutation.
  321. func (m *AgentMutation) Name() (r string, exists bool) {
  322. v := m.name
  323. if v == nil {
  324. return
  325. }
  326. return *v, true
  327. }
  328. // OldName returns the old "name" field's value of the Agent entity.
  329. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  331. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  332. if !m.op.Is(OpUpdateOne) {
  333. return v, errors.New("OldName is only allowed on UpdateOne operations")
  334. }
  335. if m.id == nil || m.oldValue == nil {
  336. return v, errors.New("OldName requires an ID field in the mutation")
  337. }
  338. oldValue, err := m.oldValue(ctx)
  339. if err != nil {
  340. return v, fmt.Errorf("querying old value for OldName: %w", err)
  341. }
  342. return oldValue.Name, nil
  343. }
  344. // ResetName resets all changes to the "name" field.
  345. func (m *AgentMutation) ResetName() {
  346. m.name = nil
  347. }
  348. // SetRole sets the "role" field.
  349. func (m *AgentMutation) SetRole(s string) {
  350. m.role = &s
  351. }
  352. // Role returns the value of the "role" field in the mutation.
  353. func (m *AgentMutation) Role() (r string, exists bool) {
  354. v := m.role
  355. if v == nil {
  356. return
  357. }
  358. return *v, true
  359. }
  360. // OldRole returns the old "role" field's value of the Agent entity.
  361. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  363. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  364. if !m.op.Is(OpUpdateOne) {
  365. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  366. }
  367. if m.id == nil || m.oldValue == nil {
  368. return v, errors.New("OldRole requires an ID field in the mutation")
  369. }
  370. oldValue, err := m.oldValue(ctx)
  371. if err != nil {
  372. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  373. }
  374. return oldValue.Role, nil
  375. }
  376. // ResetRole resets all changes to the "role" field.
  377. func (m *AgentMutation) ResetRole() {
  378. m.role = nil
  379. }
  380. // SetStatus sets the "status" field.
  381. func (m *AgentMutation) SetStatus(i int) {
  382. m.status = &i
  383. m.addstatus = nil
  384. }
  385. // Status returns the value of the "status" field in the mutation.
  386. func (m *AgentMutation) Status() (r int, exists bool) {
  387. v := m.status
  388. if v == nil {
  389. return
  390. }
  391. return *v, true
  392. }
  393. // OldStatus returns the old "status" field's value of the Agent entity.
  394. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  396. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  397. if !m.op.Is(OpUpdateOne) {
  398. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  399. }
  400. if m.id == nil || m.oldValue == nil {
  401. return v, errors.New("OldStatus requires an ID field in the mutation")
  402. }
  403. oldValue, err := m.oldValue(ctx)
  404. if err != nil {
  405. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  406. }
  407. return oldValue.Status, nil
  408. }
  409. // AddStatus adds i to the "status" field.
  410. func (m *AgentMutation) AddStatus(i int) {
  411. if m.addstatus != nil {
  412. *m.addstatus += i
  413. } else {
  414. m.addstatus = &i
  415. }
  416. }
  417. // AddedStatus returns the value that was added to the "status" field in this mutation.
  418. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  419. v := m.addstatus
  420. if v == nil {
  421. return
  422. }
  423. return *v, true
  424. }
  425. // ClearStatus clears the value of the "status" field.
  426. func (m *AgentMutation) ClearStatus() {
  427. m.status = nil
  428. m.addstatus = nil
  429. m.clearedFields[agent.FieldStatus] = struct{}{}
  430. }
  431. // StatusCleared returns if the "status" field was cleared in this mutation.
  432. func (m *AgentMutation) StatusCleared() bool {
  433. _, ok := m.clearedFields[agent.FieldStatus]
  434. return ok
  435. }
  436. // ResetStatus resets all changes to the "status" field.
  437. func (m *AgentMutation) ResetStatus() {
  438. m.status = nil
  439. m.addstatus = nil
  440. delete(m.clearedFields, agent.FieldStatus)
  441. }
  442. // SetBackground sets the "background" field.
  443. func (m *AgentMutation) SetBackground(s string) {
  444. m.background = &s
  445. }
  446. // Background returns the value of the "background" field in the mutation.
  447. func (m *AgentMutation) Background() (r string, exists bool) {
  448. v := m.background
  449. if v == nil {
  450. return
  451. }
  452. return *v, true
  453. }
  454. // OldBackground returns the old "background" field's value of the Agent entity.
  455. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  457. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  458. if !m.op.Is(OpUpdateOne) {
  459. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  460. }
  461. if m.id == nil || m.oldValue == nil {
  462. return v, errors.New("OldBackground requires an ID field in the mutation")
  463. }
  464. oldValue, err := m.oldValue(ctx)
  465. if err != nil {
  466. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  467. }
  468. return oldValue.Background, nil
  469. }
  470. // ClearBackground clears the value of the "background" field.
  471. func (m *AgentMutation) ClearBackground() {
  472. m.background = nil
  473. m.clearedFields[agent.FieldBackground] = struct{}{}
  474. }
  475. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  476. func (m *AgentMutation) BackgroundCleared() bool {
  477. _, ok := m.clearedFields[agent.FieldBackground]
  478. return ok
  479. }
  480. // ResetBackground resets all changes to the "background" field.
  481. func (m *AgentMutation) ResetBackground() {
  482. m.background = nil
  483. delete(m.clearedFields, agent.FieldBackground)
  484. }
  485. // SetExamples sets the "examples" field.
  486. func (m *AgentMutation) SetExamples(s string) {
  487. m.examples = &s
  488. }
  489. // Examples returns the value of the "examples" field in the mutation.
  490. func (m *AgentMutation) Examples() (r string, exists bool) {
  491. v := m.examples
  492. if v == nil {
  493. return
  494. }
  495. return *v, true
  496. }
  497. // OldExamples returns the old "examples" field's value of the Agent entity.
  498. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  500. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  501. if !m.op.Is(OpUpdateOne) {
  502. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  503. }
  504. if m.id == nil || m.oldValue == nil {
  505. return v, errors.New("OldExamples requires an ID field in the mutation")
  506. }
  507. oldValue, err := m.oldValue(ctx)
  508. if err != nil {
  509. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  510. }
  511. return oldValue.Examples, nil
  512. }
  513. // ClearExamples clears the value of the "examples" field.
  514. func (m *AgentMutation) ClearExamples() {
  515. m.examples = nil
  516. m.clearedFields[agent.FieldExamples] = struct{}{}
  517. }
  518. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  519. func (m *AgentMutation) ExamplesCleared() bool {
  520. _, ok := m.clearedFields[agent.FieldExamples]
  521. return ok
  522. }
  523. // ResetExamples resets all changes to the "examples" field.
  524. func (m *AgentMutation) ResetExamples() {
  525. m.examples = nil
  526. delete(m.clearedFields, agent.FieldExamples)
  527. }
  528. // SetOrganizationID sets the "organization_id" field.
  529. func (m *AgentMutation) SetOrganizationID(u uint64) {
  530. m.organization_id = &u
  531. m.addorganization_id = nil
  532. }
  533. // OrganizationID returns the value of the "organization_id" field in the mutation.
  534. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  535. v := m.organization_id
  536. if v == nil {
  537. return
  538. }
  539. return *v, true
  540. }
  541. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  542. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  544. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  545. if !m.op.Is(OpUpdateOne) {
  546. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  547. }
  548. if m.id == nil || m.oldValue == nil {
  549. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  550. }
  551. oldValue, err := m.oldValue(ctx)
  552. if err != nil {
  553. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  554. }
  555. return oldValue.OrganizationID, nil
  556. }
  557. // AddOrganizationID adds u to the "organization_id" field.
  558. func (m *AgentMutation) AddOrganizationID(u int64) {
  559. if m.addorganization_id != nil {
  560. *m.addorganization_id += u
  561. } else {
  562. m.addorganization_id = &u
  563. }
  564. }
  565. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  566. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  567. v := m.addorganization_id
  568. if v == nil {
  569. return
  570. }
  571. return *v, true
  572. }
  573. // ResetOrganizationID resets all changes to the "organization_id" field.
  574. func (m *AgentMutation) ResetOrganizationID() {
  575. m.organization_id = nil
  576. m.addorganization_id = nil
  577. }
  578. // SetDatasetID sets the "dataset_id" field.
  579. func (m *AgentMutation) SetDatasetID(s string) {
  580. m.dataset_id = &s
  581. }
  582. // DatasetID returns the value of the "dataset_id" field in the mutation.
  583. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  584. v := m.dataset_id
  585. if v == nil {
  586. return
  587. }
  588. return *v, true
  589. }
  590. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  591. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  593. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  594. if !m.op.Is(OpUpdateOne) {
  595. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  596. }
  597. if m.id == nil || m.oldValue == nil {
  598. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  599. }
  600. oldValue, err := m.oldValue(ctx)
  601. if err != nil {
  602. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  603. }
  604. return oldValue.DatasetID, nil
  605. }
  606. // ResetDatasetID resets all changes to the "dataset_id" field.
  607. func (m *AgentMutation) ResetDatasetID() {
  608. m.dataset_id = nil
  609. }
  610. // SetCollectionID sets the "collection_id" field.
  611. func (m *AgentMutation) SetCollectionID(s string) {
  612. m.collection_id = &s
  613. }
  614. // CollectionID returns the value of the "collection_id" field in the mutation.
  615. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  616. v := m.collection_id
  617. if v == nil {
  618. return
  619. }
  620. return *v, true
  621. }
  622. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  623. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  625. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  626. if !m.op.Is(OpUpdateOne) {
  627. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  628. }
  629. if m.id == nil || m.oldValue == nil {
  630. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  631. }
  632. oldValue, err := m.oldValue(ctx)
  633. if err != nil {
  634. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  635. }
  636. return oldValue.CollectionID, nil
  637. }
  638. // ResetCollectionID resets all changes to the "collection_id" field.
  639. func (m *AgentMutation) ResetCollectionID() {
  640. m.collection_id = nil
  641. }
  642. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  643. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  644. if m.wx_agent == nil {
  645. m.wx_agent = make(map[uint64]struct{})
  646. }
  647. for i := range ids {
  648. m.wx_agent[ids[i]] = struct{}{}
  649. }
  650. }
  651. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  652. func (m *AgentMutation) ClearWxAgent() {
  653. m.clearedwx_agent = true
  654. }
  655. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  656. func (m *AgentMutation) WxAgentCleared() bool {
  657. return m.clearedwx_agent
  658. }
  659. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  660. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  661. if m.removedwx_agent == nil {
  662. m.removedwx_agent = make(map[uint64]struct{})
  663. }
  664. for i := range ids {
  665. delete(m.wx_agent, ids[i])
  666. m.removedwx_agent[ids[i]] = struct{}{}
  667. }
  668. }
  669. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  670. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  671. for id := range m.removedwx_agent {
  672. ids = append(ids, id)
  673. }
  674. return
  675. }
  676. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  677. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  678. for id := range m.wx_agent {
  679. ids = append(ids, id)
  680. }
  681. return
  682. }
  683. // ResetWxAgent resets all changes to the "wx_agent" edge.
  684. func (m *AgentMutation) ResetWxAgent() {
  685. m.wx_agent = nil
  686. m.clearedwx_agent = false
  687. m.removedwx_agent = nil
  688. }
  689. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  690. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  691. if m.token_agent == nil {
  692. m.token_agent = make(map[uint64]struct{})
  693. }
  694. for i := range ids {
  695. m.token_agent[ids[i]] = struct{}{}
  696. }
  697. }
  698. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  699. func (m *AgentMutation) ClearTokenAgent() {
  700. m.clearedtoken_agent = true
  701. }
  702. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  703. func (m *AgentMutation) TokenAgentCleared() bool {
  704. return m.clearedtoken_agent
  705. }
  706. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  707. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  708. if m.removedtoken_agent == nil {
  709. m.removedtoken_agent = make(map[uint64]struct{})
  710. }
  711. for i := range ids {
  712. delete(m.token_agent, ids[i])
  713. m.removedtoken_agent[ids[i]] = struct{}{}
  714. }
  715. }
  716. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  717. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  718. for id := range m.removedtoken_agent {
  719. ids = append(ids, id)
  720. }
  721. return
  722. }
  723. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  724. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  725. for id := range m.token_agent {
  726. ids = append(ids, id)
  727. }
  728. return
  729. }
  730. // ResetTokenAgent resets all changes to the "token_agent" edge.
  731. func (m *AgentMutation) ResetTokenAgent() {
  732. m.token_agent = nil
  733. m.clearedtoken_agent = false
  734. m.removedtoken_agent = nil
  735. }
  736. // Where appends a list predicates to the AgentMutation builder.
  737. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  738. m.predicates = append(m.predicates, ps...)
  739. }
  740. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  741. // users can use type-assertion to append predicates that do not depend on any generated package.
  742. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  743. p := make([]predicate.Agent, len(ps))
  744. for i := range ps {
  745. p[i] = ps[i]
  746. }
  747. m.Where(p...)
  748. }
  749. // Op returns the operation name.
  750. func (m *AgentMutation) Op() Op {
  751. return m.op
  752. }
  753. // SetOp allows setting the mutation operation.
  754. func (m *AgentMutation) SetOp(op Op) {
  755. m.op = op
  756. }
  757. // Type returns the node type of this mutation (Agent).
  758. func (m *AgentMutation) Type() string {
  759. return m.typ
  760. }
  761. // Fields returns all fields that were changed during this mutation. Note that in
  762. // order to get all numeric fields that were incremented/decremented, call
  763. // AddedFields().
  764. func (m *AgentMutation) Fields() []string {
  765. fields := make([]string, 0, 11)
  766. if m.created_at != nil {
  767. fields = append(fields, agent.FieldCreatedAt)
  768. }
  769. if m.updated_at != nil {
  770. fields = append(fields, agent.FieldUpdatedAt)
  771. }
  772. if m.deleted_at != nil {
  773. fields = append(fields, agent.FieldDeletedAt)
  774. }
  775. if m.name != nil {
  776. fields = append(fields, agent.FieldName)
  777. }
  778. if m.role != nil {
  779. fields = append(fields, agent.FieldRole)
  780. }
  781. if m.status != nil {
  782. fields = append(fields, agent.FieldStatus)
  783. }
  784. if m.background != nil {
  785. fields = append(fields, agent.FieldBackground)
  786. }
  787. if m.examples != nil {
  788. fields = append(fields, agent.FieldExamples)
  789. }
  790. if m.organization_id != nil {
  791. fields = append(fields, agent.FieldOrganizationID)
  792. }
  793. if m.dataset_id != nil {
  794. fields = append(fields, agent.FieldDatasetID)
  795. }
  796. if m.collection_id != nil {
  797. fields = append(fields, agent.FieldCollectionID)
  798. }
  799. return fields
  800. }
  801. // Field returns the value of a field with the given name. The second boolean
  802. // return value indicates that this field was not set, or was not defined in the
  803. // schema.
  804. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  805. switch name {
  806. case agent.FieldCreatedAt:
  807. return m.CreatedAt()
  808. case agent.FieldUpdatedAt:
  809. return m.UpdatedAt()
  810. case agent.FieldDeletedAt:
  811. return m.DeletedAt()
  812. case agent.FieldName:
  813. return m.Name()
  814. case agent.FieldRole:
  815. return m.Role()
  816. case agent.FieldStatus:
  817. return m.Status()
  818. case agent.FieldBackground:
  819. return m.Background()
  820. case agent.FieldExamples:
  821. return m.Examples()
  822. case agent.FieldOrganizationID:
  823. return m.OrganizationID()
  824. case agent.FieldDatasetID:
  825. return m.DatasetID()
  826. case agent.FieldCollectionID:
  827. return m.CollectionID()
  828. }
  829. return nil, false
  830. }
  831. // OldField returns the old value of the field from the database. An error is
  832. // returned if the mutation operation is not UpdateOne, or the query to the
  833. // database failed.
  834. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  835. switch name {
  836. case agent.FieldCreatedAt:
  837. return m.OldCreatedAt(ctx)
  838. case agent.FieldUpdatedAt:
  839. return m.OldUpdatedAt(ctx)
  840. case agent.FieldDeletedAt:
  841. return m.OldDeletedAt(ctx)
  842. case agent.FieldName:
  843. return m.OldName(ctx)
  844. case agent.FieldRole:
  845. return m.OldRole(ctx)
  846. case agent.FieldStatus:
  847. return m.OldStatus(ctx)
  848. case agent.FieldBackground:
  849. return m.OldBackground(ctx)
  850. case agent.FieldExamples:
  851. return m.OldExamples(ctx)
  852. case agent.FieldOrganizationID:
  853. return m.OldOrganizationID(ctx)
  854. case agent.FieldDatasetID:
  855. return m.OldDatasetID(ctx)
  856. case agent.FieldCollectionID:
  857. return m.OldCollectionID(ctx)
  858. }
  859. return nil, fmt.Errorf("unknown Agent field %s", name)
  860. }
  861. // SetField sets the value of a field with the given name. It returns an error if
  862. // the field is not defined in the schema, or if the type mismatched the field
  863. // type.
  864. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  865. switch name {
  866. case agent.FieldCreatedAt:
  867. v, ok := value.(time.Time)
  868. if !ok {
  869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  870. }
  871. m.SetCreatedAt(v)
  872. return nil
  873. case agent.FieldUpdatedAt:
  874. v, ok := value.(time.Time)
  875. if !ok {
  876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  877. }
  878. m.SetUpdatedAt(v)
  879. return nil
  880. case agent.FieldDeletedAt:
  881. v, ok := value.(time.Time)
  882. if !ok {
  883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  884. }
  885. m.SetDeletedAt(v)
  886. return nil
  887. case agent.FieldName:
  888. v, ok := value.(string)
  889. if !ok {
  890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  891. }
  892. m.SetName(v)
  893. return nil
  894. case agent.FieldRole:
  895. v, ok := value.(string)
  896. if !ok {
  897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  898. }
  899. m.SetRole(v)
  900. return nil
  901. case agent.FieldStatus:
  902. v, ok := value.(int)
  903. if !ok {
  904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  905. }
  906. m.SetStatus(v)
  907. return nil
  908. case agent.FieldBackground:
  909. v, ok := value.(string)
  910. if !ok {
  911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  912. }
  913. m.SetBackground(v)
  914. return nil
  915. case agent.FieldExamples:
  916. v, ok := value.(string)
  917. if !ok {
  918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  919. }
  920. m.SetExamples(v)
  921. return nil
  922. case agent.FieldOrganizationID:
  923. v, ok := value.(uint64)
  924. if !ok {
  925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  926. }
  927. m.SetOrganizationID(v)
  928. return nil
  929. case agent.FieldDatasetID:
  930. v, ok := value.(string)
  931. if !ok {
  932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  933. }
  934. m.SetDatasetID(v)
  935. return nil
  936. case agent.FieldCollectionID:
  937. v, ok := value.(string)
  938. if !ok {
  939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  940. }
  941. m.SetCollectionID(v)
  942. return nil
  943. }
  944. return fmt.Errorf("unknown Agent field %s", name)
  945. }
  946. // AddedFields returns all numeric fields that were incremented/decremented during
  947. // this mutation.
  948. func (m *AgentMutation) AddedFields() []string {
  949. var fields []string
  950. if m.addstatus != nil {
  951. fields = append(fields, agent.FieldStatus)
  952. }
  953. if m.addorganization_id != nil {
  954. fields = append(fields, agent.FieldOrganizationID)
  955. }
  956. return fields
  957. }
  958. // AddedField returns the numeric value that was incremented/decremented on a field
  959. // with the given name. The second boolean return value indicates that this field
  960. // was not set, or was not defined in the schema.
  961. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  962. switch name {
  963. case agent.FieldStatus:
  964. return m.AddedStatus()
  965. case agent.FieldOrganizationID:
  966. return m.AddedOrganizationID()
  967. }
  968. return nil, false
  969. }
  970. // AddField adds the value to the field with the given name. It returns an error if
  971. // the field is not defined in the schema, or if the type mismatched the field
  972. // type.
  973. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  974. switch name {
  975. case agent.FieldStatus:
  976. v, ok := value.(int)
  977. if !ok {
  978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  979. }
  980. m.AddStatus(v)
  981. return nil
  982. case agent.FieldOrganizationID:
  983. v, ok := value.(int64)
  984. if !ok {
  985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  986. }
  987. m.AddOrganizationID(v)
  988. return nil
  989. }
  990. return fmt.Errorf("unknown Agent numeric field %s", name)
  991. }
  992. // ClearedFields returns all nullable fields that were cleared during this
  993. // mutation.
  994. func (m *AgentMutation) ClearedFields() []string {
  995. var fields []string
  996. if m.FieldCleared(agent.FieldDeletedAt) {
  997. fields = append(fields, agent.FieldDeletedAt)
  998. }
  999. if m.FieldCleared(agent.FieldStatus) {
  1000. fields = append(fields, agent.FieldStatus)
  1001. }
  1002. if m.FieldCleared(agent.FieldBackground) {
  1003. fields = append(fields, agent.FieldBackground)
  1004. }
  1005. if m.FieldCleared(agent.FieldExamples) {
  1006. fields = append(fields, agent.FieldExamples)
  1007. }
  1008. return fields
  1009. }
  1010. // FieldCleared returns a boolean indicating if a field with the given name was
  1011. // cleared in this mutation.
  1012. func (m *AgentMutation) FieldCleared(name string) bool {
  1013. _, ok := m.clearedFields[name]
  1014. return ok
  1015. }
  1016. // ClearField clears the value of the field with the given name. It returns an
  1017. // error if the field is not defined in the schema.
  1018. func (m *AgentMutation) ClearField(name string) error {
  1019. switch name {
  1020. case agent.FieldDeletedAt:
  1021. m.ClearDeletedAt()
  1022. return nil
  1023. case agent.FieldStatus:
  1024. m.ClearStatus()
  1025. return nil
  1026. case agent.FieldBackground:
  1027. m.ClearBackground()
  1028. return nil
  1029. case agent.FieldExamples:
  1030. m.ClearExamples()
  1031. return nil
  1032. }
  1033. return fmt.Errorf("unknown Agent nullable field %s", name)
  1034. }
  1035. // ResetField resets all changes in the mutation for the field with the given name.
  1036. // It returns an error if the field is not defined in the schema.
  1037. func (m *AgentMutation) ResetField(name string) error {
  1038. switch name {
  1039. case agent.FieldCreatedAt:
  1040. m.ResetCreatedAt()
  1041. return nil
  1042. case agent.FieldUpdatedAt:
  1043. m.ResetUpdatedAt()
  1044. return nil
  1045. case agent.FieldDeletedAt:
  1046. m.ResetDeletedAt()
  1047. return nil
  1048. case agent.FieldName:
  1049. m.ResetName()
  1050. return nil
  1051. case agent.FieldRole:
  1052. m.ResetRole()
  1053. return nil
  1054. case agent.FieldStatus:
  1055. m.ResetStatus()
  1056. return nil
  1057. case agent.FieldBackground:
  1058. m.ResetBackground()
  1059. return nil
  1060. case agent.FieldExamples:
  1061. m.ResetExamples()
  1062. return nil
  1063. case agent.FieldOrganizationID:
  1064. m.ResetOrganizationID()
  1065. return nil
  1066. case agent.FieldDatasetID:
  1067. m.ResetDatasetID()
  1068. return nil
  1069. case agent.FieldCollectionID:
  1070. m.ResetCollectionID()
  1071. return nil
  1072. }
  1073. return fmt.Errorf("unknown Agent field %s", name)
  1074. }
  1075. // AddedEdges returns all edge names that were set/added in this mutation.
  1076. func (m *AgentMutation) AddedEdges() []string {
  1077. edges := make([]string, 0, 2)
  1078. if m.wx_agent != nil {
  1079. edges = append(edges, agent.EdgeWxAgent)
  1080. }
  1081. if m.token_agent != nil {
  1082. edges = append(edges, agent.EdgeTokenAgent)
  1083. }
  1084. return edges
  1085. }
  1086. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1087. // name in this mutation.
  1088. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1089. switch name {
  1090. case agent.EdgeWxAgent:
  1091. ids := make([]ent.Value, 0, len(m.wx_agent))
  1092. for id := range m.wx_agent {
  1093. ids = append(ids, id)
  1094. }
  1095. return ids
  1096. case agent.EdgeTokenAgent:
  1097. ids := make([]ent.Value, 0, len(m.token_agent))
  1098. for id := range m.token_agent {
  1099. ids = append(ids, id)
  1100. }
  1101. return ids
  1102. }
  1103. return nil
  1104. }
  1105. // RemovedEdges returns all edge names that were removed in this mutation.
  1106. func (m *AgentMutation) RemovedEdges() []string {
  1107. edges := make([]string, 0, 2)
  1108. if m.removedwx_agent != nil {
  1109. edges = append(edges, agent.EdgeWxAgent)
  1110. }
  1111. if m.removedtoken_agent != nil {
  1112. edges = append(edges, agent.EdgeTokenAgent)
  1113. }
  1114. return edges
  1115. }
  1116. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1117. // the given name in this mutation.
  1118. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1119. switch name {
  1120. case agent.EdgeWxAgent:
  1121. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1122. for id := range m.removedwx_agent {
  1123. ids = append(ids, id)
  1124. }
  1125. return ids
  1126. case agent.EdgeTokenAgent:
  1127. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1128. for id := range m.removedtoken_agent {
  1129. ids = append(ids, id)
  1130. }
  1131. return ids
  1132. }
  1133. return nil
  1134. }
  1135. // ClearedEdges returns all edge names that were cleared in this mutation.
  1136. func (m *AgentMutation) ClearedEdges() []string {
  1137. edges := make([]string, 0, 2)
  1138. if m.clearedwx_agent {
  1139. edges = append(edges, agent.EdgeWxAgent)
  1140. }
  1141. if m.clearedtoken_agent {
  1142. edges = append(edges, agent.EdgeTokenAgent)
  1143. }
  1144. return edges
  1145. }
  1146. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1147. // was cleared in this mutation.
  1148. func (m *AgentMutation) EdgeCleared(name string) bool {
  1149. switch name {
  1150. case agent.EdgeWxAgent:
  1151. return m.clearedwx_agent
  1152. case agent.EdgeTokenAgent:
  1153. return m.clearedtoken_agent
  1154. }
  1155. return false
  1156. }
  1157. // ClearEdge clears the value of the edge with the given name. It returns an error
  1158. // if that edge is not defined in the schema.
  1159. func (m *AgentMutation) ClearEdge(name string) error {
  1160. switch name {
  1161. }
  1162. return fmt.Errorf("unknown Agent unique edge %s", name)
  1163. }
  1164. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1165. // It returns an error if the edge is not defined in the schema.
  1166. func (m *AgentMutation) ResetEdge(name string) error {
  1167. switch name {
  1168. case agent.EdgeWxAgent:
  1169. m.ResetWxAgent()
  1170. return nil
  1171. case agent.EdgeTokenAgent:
  1172. m.ResetTokenAgent()
  1173. return nil
  1174. }
  1175. return fmt.Errorf("unknown Agent edge %s", name)
  1176. }
  1177. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1178. type AgentBaseMutation struct {
  1179. config
  1180. op Op
  1181. typ string
  1182. id *string
  1183. q *string
  1184. a *string
  1185. chunk_index *uint64
  1186. addchunk_index *int64
  1187. indexes *[]string
  1188. appendindexes []string
  1189. dataset_id *string
  1190. collection_id *string
  1191. source_name *string
  1192. can_write *[]bool
  1193. appendcan_write []bool
  1194. is_owner *[]bool
  1195. appendis_owner []bool
  1196. clearedFields map[string]struct{}
  1197. wx_agent map[uint64]struct{}
  1198. removedwx_agent map[uint64]struct{}
  1199. clearedwx_agent bool
  1200. done bool
  1201. oldValue func(context.Context) (*AgentBase, error)
  1202. predicates []predicate.AgentBase
  1203. }
  1204. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1205. // agentbaseOption allows management of the mutation configuration using functional options.
  1206. type agentbaseOption func(*AgentBaseMutation)
  1207. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1208. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1209. m := &AgentBaseMutation{
  1210. config: c,
  1211. op: op,
  1212. typ: TypeAgentBase,
  1213. clearedFields: make(map[string]struct{}),
  1214. }
  1215. for _, opt := range opts {
  1216. opt(m)
  1217. }
  1218. return m
  1219. }
  1220. // withAgentBaseID sets the ID field of the mutation.
  1221. func withAgentBaseID(id string) agentbaseOption {
  1222. return func(m *AgentBaseMutation) {
  1223. var (
  1224. err error
  1225. once sync.Once
  1226. value *AgentBase
  1227. )
  1228. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1229. once.Do(func() {
  1230. if m.done {
  1231. err = errors.New("querying old values post mutation is not allowed")
  1232. } else {
  1233. value, err = m.Client().AgentBase.Get(ctx, id)
  1234. }
  1235. })
  1236. return value, err
  1237. }
  1238. m.id = &id
  1239. }
  1240. }
  1241. // withAgentBase sets the old AgentBase of the mutation.
  1242. func withAgentBase(node *AgentBase) agentbaseOption {
  1243. return func(m *AgentBaseMutation) {
  1244. m.oldValue = func(context.Context) (*AgentBase, error) {
  1245. return node, nil
  1246. }
  1247. m.id = &node.ID
  1248. }
  1249. }
  1250. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1251. // executed in a transaction (ent.Tx), a transactional client is returned.
  1252. func (m AgentBaseMutation) Client() *Client {
  1253. client := &Client{config: m.config}
  1254. client.init()
  1255. return client
  1256. }
  1257. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1258. // it returns an error otherwise.
  1259. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1260. if _, ok := m.driver.(*txDriver); !ok {
  1261. return nil, errors.New("ent: mutation is not running in a transaction")
  1262. }
  1263. tx := &Tx{config: m.config}
  1264. tx.init()
  1265. return tx, nil
  1266. }
  1267. // SetID sets the value of the id field. Note that this
  1268. // operation is only accepted on creation of AgentBase entities.
  1269. func (m *AgentBaseMutation) SetID(id string) {
  1270. m.id = &id
  1271. }
  1272. // ID returns the ID value in the mutation. Note that the ID is only available
  1273. // if it was provided to the builder or after it was returned from the database.
  1274. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1275. if m.id == nil {
  1276. return
  1277. }
  1278. return *m.id, true
  1279. }
  1280. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1281. // That means, if the mutation is applied within a transaction with an isolation level such
  1282. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1283. // or updated by the mutation.
  1284. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1285. switch {
  1286. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1287. id, exists := m.ID()
  1288. if exists {
  1289. return []string{id}, nil
  1290. }
  1291. fallthrough
  1292. case m.op.Is(OpUpdate | OpDelete):
  1293. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1294. default:
  1295. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1296. }
  1297. }
  1298. // SetQ sets the "q" field.
  1299. func (m *AgentBaseMutation) SetQ(s string) {
  1300. m.q = &s
  1301. }
  1302. // Q returns the value of the "q" field in the mutation.
  1303. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1304. v := m.q
  1305. if v == nil {
  1306. return
  1307. }
  1308. return *v, true
  1309. }
  1310. // OldQ returns the old "q" field's value of the AgentBase entity.
  1311. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1313. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1314. if !m.op.Is(OpUpdateOne) {
  1315. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1316. }
  1317. if m.id == nil || m.oldValue == nil {
  1318. return v, errors.New("OldQ requires an ID field in the mutation")
  1319. }
  1320. oldValue, err := m.oldValue(ctx)
  1321. if err != nil {
  1322. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1323. }
  1324. return oldValue.Q, nil
  1325. }
  1326. // ClearQ clears the value of the "q" field.
  1327. func (m *AgentBaseMutation) ClearQ() {
  1328. m.q = nil
  1329. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1330. }
  1331. // QCleared returns if the "q" field was cleared in this mutation.
  1332. func (m *AgentBaseMutation) QCleared() bool {
  1333. _, ok := m.clearedFields[agentbase.FieldQ]
  1334. return ok
  1335. }
  1336. // ResetQ resets all changes to the "q" field.
  1337. func (m *AgentBaseMutation) ResetQ() {
  1338. m.q = nil
  1339. delete(m.clearedFields, agentbase.FieldQ)
  1340. }
  1341. // SetA sets the "a" field.
  1342. func (m *AgentBaseMutation) SetA(s string) {
  1343. m.a = &s
  1344. }
  1345. // A returns the value of the "a" field in the mutation.
  1346. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1347. v := m.a
  1348. if v == nil {
  1349. return
  1350. }
  1351. return *v, true
  1352. }
  1353. // OldA returns the old "a" field's value of the AgentBase entity.
  1354. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1356. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1357. if !m.op.Is(OpUpdateOne) {
  1358. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1359. }
  1360. if m.id == nil || m.oldValue == nil {
  1361. return v, errors.New("OldA requires an ID field in the mutation")
  1362. }
  1363. oldValue, err := m.oldValue(ctx)
  1364. if err != nil {
  1365. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1366. }
  1367. return oldValue.A, nil
  1368. }
  1369. // ClearA clears the value of the "a" field.
  1370. func (m *AgentBaseMutation) ClearA() {
  1371. m.a = nil
  1372. m.clearedFields[agentbase.FieldA] = struct{}{}
  1373. }
  1374. // ACleared returns if the "a" field was cleared in this mutation.
  1375. func (m *AgentBaseMutation) ACleared() bool {
  1376. _, ok := m.clearedFields[agentbase.FieldA]
  1377. return ok
  1378. }
  1379. // ResetA resets all changes to the "a" field.
  1380. func (m *AgentBaseMutation) ResetA() {
  1381. m.a = nil
  1382. delete(m.clearedFields, agentbase.FieldA)
  1383. }
  1384. // SetChunkIndex sets the "chunk_index" field.
  1385. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1386. m.chunk_index = &u
  1387. m.addchunk_index = nil
  1388. }
  1389. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1390. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1391. v := m.chunk_index
  1392. if v == nil {
  1393. return
  1394. }
  1395. return *v, true
  1396. }
  1397. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1398. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1400. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1401. if !m.op.Is(OpUpdateOne) {
  1402. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1403. }
  1404. if m.id == nil || m.oldValue == nil {
  1405. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1406. }
  1407. oldValue, err := m.oldValue(ctx)
  1408. if err != nil {
  1409. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1410. }
  1411. return oldValue.ChunkIndex, nil
  1412. }
  1413. // AddChunkIndex adds u to the "chunk_index" field.
  1414. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1415. if m.addchunk_index != nil {
  1416. *m.addchunk_index += u
  1417. } else {
  1418. m.addchunk_index = &u
  1419. }
  1420. }
  1421. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1422. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1423. v := m.addchunk_index
  1424. if v == nil {
  1425. return
  1426. }
  1427. return *v, true
  1428. }
  1429. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1430. func (m *AgentBaseMutation) ResetChunkIndex() {
  1431. m.chunk_index = nil
  1432. m.addchunk_index = nil
  1433. }
  1434. // SetIndexes sets the "indexes" field.
  1435. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1436. m.indexes = &s
  1437. m.appendindexes = nil
  1438. }
  1439. // Indexes returns the value of the "indexes" field in the mutation.
  1440. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1441. v := m.indexes
  1442. if v == nil {
  1443. return
  1444. }
  1445. return *v, true
  1446. }
  1447. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1448. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1450. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1451. if !m.op.Is(OpUpdateOne) {
  1452. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1453. }
  1454. if m.id == nil || m.oldValue == nil {
  1455. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1456. }
  1457. oldValue, err := m.oldValue(ctx)
  1458. if err != nil {
  1459. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1460. }
  1461. return oldValue.Indexes, nil
  1462. }
  1463. // AppendIndexes adds s to the "indexes" field.
  1464. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1465. m.appendindexes = append(m.appendindexes, s...)
  1466. }
  1467. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1468. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1469. if len(m.appendindexes) == 0 {
  1470. return nil, false
  1471. }
  1472. return m.appendindexes, true
  1473. }
  1474. // ClearIndexes clears the value of the "indexes" field.
  1475. func (m *AgentBaseMutation) ClearIndexes() {
  1476. m.indexes = nil
  1477. m.appendindexes = nil
  1478. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1479. }
  1480. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1481. func (m *AgentBaseMutation) IndexesCleared() bool {
  1482. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1483. return ok
  1484. }
  1485. // ResetIndexes resets all changes to the "indexes" field.
  1486. func (m *AgentBaseMutation) ResetIndexes() {
  1487. m.indexes = nil
  1488. m.appendindexes = nil
  1489. delete(m.clearedFields, agentbase.FieldIndexes)
  1490. }
  1491. // SetDatasetID sets the "dataset_id" field.
  1492. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1493. m.dataset_id = &s
  1494. }
  1495. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1496. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1497. v := m.dataset_id
  1498. if v == nil {
  1499. return
  1500. }
  1501. return *v, true
  1502. }
  1503. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1504. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1506. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1507. if !m.op.Is(OpUpdateOne) {
  1508. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1509. }
  1510. if m.id == nil || m.oldValue == nil {
  1511. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1512. }
  1513. oldValue, err := m.oldValue(ctx)
  1514. if err != nil {
  1515. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1516. }
  1517. return oldValue.DatasetID, nil
  1518. }
  1519. // ClearDatasetID clears the value of the "dataset_id" field.
  1520. func (m *AgentBaseMutation) ClearDatasetID() {
  1521. m.dataset_id = nil
  1522. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1523. }
  1524. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1525. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1526. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1527. return ok
  1528. }
  1529. // ResetDatasetID resets all changes to the "dataset_id" field.
  1530. func (m *AgentBaseMutation) ResetDatasetID() {
  1531. m.dataset_id = nil
  1532. delete(m.clearedFields, agentbase.FieldDatasetID)
  1533. }
  1534. // SetCollectionID sets the "collection_id" field.
  1535. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1536. m.collection_id = &s
  1537. }
  1538. // CollectionID returns the value of the "collection_id" field in the mutation.
  1539. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1540. v := m.collection_id
  1541. if v == nil {
  1542. return
  1543. }
  1544. return *v, true
  1545. }
  1546. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1547. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1549. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1550. if !m.op.Is(OpUpdateOne) {
  1551. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1552. }
  1553. if m.id == nil || m.oldValue == nil {
  1554. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1555. }
  1556. oldValue, err := m.oldValue(ctx)
  1557. if err != nil {
  1558. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1559. }
  1560. return oldValue.CollectionID, nil
  1561. }
  1562. // ClearCollectionID clears the value of the "collection_id" field.
  1563. func (m *AgentBaseMutation) ClearCollectionID() {
  1564. m.collection_id = nil
  1565. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1566. }
  1567. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1568. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1569. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1570. return ok
  1571. }
  1572. // ResetCollectionID resets all changes to the "collection_id" field.
  1573. func (m *AgentBaseMutation) ResetCollectionID() {
  1574. m.collection_id = nil
  1575. delete(m.clearedFields, agentbase.FieldCollectionID)
  1576. }
  1577. // SetSourceName sets the "source_name" field.
  1578. func (m *AgentBaseMutation) SetSourceName(s string) {
  1579. m.source_name = &s
  1580. }
  1581. // SourceName returns the value of the "source_name" field in the mutation.
  1582. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1583. v := m.source_name
  1584. if v == nil {
  1585. return
  1586. }
  1587. return *v, true
  1588. }
  1589. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1590. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1592. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1593. if !m.op.Is(OpUpdateOne) {
  1594. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1595. }
  1596. if m.id == nil || m.oldValue == nil {
  1597. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1598. }
  1599. oldValue, err := m.oldValue(ctx)
  1600. if err != nil {
  1601. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1602. }
  1603. return oldValue.SourceName, nil
  1604. }
  1605. // ClearSourceName clears the value of the "source_name" field.
  1606. func (m *AgentBaseMutation) ClearSourceName() {
  1607. m.source_name = nil
  1608. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1609. }
  1610. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1611. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1612. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1613. return ok
  1614. }
  1615. // ResetSourceName resets all changes to the "source_name" field.
  1616. func (m *AgentBaseMutation) ResetSourceName() {
  1617. m.source_name = nil
  1618. delete(m.clearedFields, agentbase.FieldSourceName)
  1619. }
  1620. // SetCanWrite sets the "can_write" field.
  1621. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1622. m.can_write = &b
  1623. m.appendcan_write = nil
  1624. }
  1625. // CanWrite returns the value of the "can_write" field in the mutation.
  1626. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1627. v := m.can_write
  1628. if v == nil {
  1629. return
  1630. }
  1631. return *v, true
  1632. }
  1633. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1634. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1636. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1637. if !m.op.Is(OpUpdateOne) {
  1638. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1639. }
  1640. if m.id == nil || m.oldValue == nil {
  1641. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1642. }
  1643. oldValue, err := m.oldValue(ctx)
  1644. if err != nil {
  1645. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1646. }
  1647. return oldValue.CanWrite, nil
  1648. }
  1649. // AppendCanWrite adds b to the "can_write" field.
  1650. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1651. m.appendcan_write = append(m.appendcan_write, b...)
  1652. }
  1653. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1654. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1655. if len(m.appendcan_write) == 0 {
  1656. return nil, false
  1657. }
  1658. return m.appendcan_write, true
  1659. }
  1660. // ClearCanWrite clears the value of the "can_write" field.
  1661. func (m *AgentBaseMutation) ClearCanWrite() {
  1662. m.can_write = nil
  1663. m.appendcan_write = nil
  1664. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1665. }
  1666. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1667. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1668. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1669. return ok
  1670. }
  1671. // ResetCanWrite resets all changes to the "can_write" field.
  1672. func (m *AgentBaseMutation) ResetCanWrite() {
  1673. m.can_write = nil
  1674. m.appendcan_write = nil
  1675. delete(m.clearedFields, agentbase.FieldCanWrite)
  1676. }
  1677. // SetIsOwner sets the "is_owner" field.
  1678. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1679. m.is_owner = &b
  1680. m.appendis_owner = nil
  1681. }
  1682. // IsOwner returns the value of the "is_owner" field in the mutation.
  1683. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1684. v := m.is_owner
  1685. if v == nil {
  1686. return
  1687. }
  1688. return *v, true
  1689. }
  1690. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1691. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1693. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1694. if !m.op.Is(OpUpdateOne) {
  1695. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1696. }
  1697. if m.id == nil || m.oldValue == nil {
  1698. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1699. }
  1700. oldValue, err := m.oldValue(ctx)
  1701. if err != nil {
  1702. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1703. }
  1704. return oldValue.IsOwner, nil
  1705. }
  1706. // AppendIsOwner adds b to the "is_owner" field.
  1707. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1708. m.appendis_owner = append(m.appendis_owner, b...)
  1709. }
  1710. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1711. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1712. if len(m.appendis_owner) == 0 {
  1713. return nil, false
  1714. }
  1715. return m.appendis_owner, true
  1716. }
  1717. // ClearIsOwner clears the value of the "is_owner" field.
  1718. func (m *AgentBaseMutation) ClearIsOwner() {
  1719. m.is_owner = nil
  1720. m.appendis_owner = nil
  1721. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1722. }
  1723. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1724. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1725. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1726. return ok
  1727. }
  1728. // ResetIsOwner resets all changes to the "is_owner" field.
  1729. func (m *AgentBaseMutation) ResetIsOwner() {
  1730. m.is_owner = nil
  1731. m.appendis_owner = nil
  1732. delete(m.clearedFields, agentbase.FieldIsOwner)
  1733. }
  1734. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1735. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1736. if m.wx_agent == nil {
  1737. m.wx_agent = make(map[uint64]struct{})
  1738. }
  1739. for i := range ids {
  1740. m.wx_agent[ids[i]] = struct{}{}
  1741. }
  1742. }
  1743. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1744. func (m *AgentBaseMutation) ClearWxAgent() {
  1745. m.clearedwx_agent = true
  1746. }
  1747. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1748. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1749. return m.clearedwx_agent
  1750. }
  1751. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1752. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1753. if m.removedwx_agent == nil {
  1754. m.removedwx_agent = make(map[uint64]struct{})
  1755. }
  1756. for i := range ids {
  1757. delete(m.wx_agent, ids[i])
  1758. m.removedwx_agent[ids[i]] = struct{}{}
  1759. }
  1760. }
  1761. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1762. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1763. for id := range m.removedwx_agent {
  1764. ids = append(ids, id)
  1765. }
  1766. return
  1767. }
  1768. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1769. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1770. for id := range m.wx_agent {
  1771. ids = append(ids, id)
  1772. }
  1773. return
  1774. }
  1775. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1776. func (m *AgentBaseMutation) ResetWxAgent() {
  1777. m.wx_agent = nil
  1778. m.clearedwx_agent = false
  1779. m.removedwx_agent = nil
  1780. }
  1781. // Where appends a list predicates to the AgentBaseMutation builder.
  1782. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1783. m.predicates = append(m.predicates, ps...)
  1784. }
  1785. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1786. // users can use type-assertion to append predicates that do not depend on any generated package.
  1787. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1788. p := make([]predicate.AgentBase, len(ps))
  1789. for i := range ps {
  1790. p[i] = ps[i]
  1791. }
  1792. m.Where(p...)
  1793. }
  1794. // Op returns the operation name.
  1795. func (m *AgentBaseMutation) Op() Op {
  1796. return m.op
  1797. }
  1798. // SetOp allows setting the mutation operation.
  1799. func (m *AgentBaseMutation) SetOp(op Op) {
  1800. m.op = op
  1801. }
  1802. // Type returns the node type of this mutation (AgentBase).
  1803. func (m *AgentBaseMutation) Type() string {
  1804. return m.typ
  1805. }
  1806. // Fields returns all fields that were changed during this mutation. Note that in
  1807. // order to get all numeric fields that were incremented/decremented, call
  1808. // AddedFields().
  1809. func (m *AgentBaseMutation) Fields() []string {
  1810. fields := make([]string, 0, 9)
  1811. if m.q != nil {
  1812. fields = append(fields, agentbase.FieldQ)
  1813. }
  1814. if m.a != nil {
  1815. fields = append(fields, agentbase.FieldA)
  1816. }
  1817. if m.chunk_index != nil {
  1818. fields = append(fields, agentbase.FieldChunkIndex)
  1819. }
  1820. if m.indexes != nil {
  1821. fields = append(fields, agentbase.FieldIndexes)
  1822. }
  1823. if m.dataset_id != nil {
  1824. fields = append(fields, agentbase.FieldDatasetID)
  1825. }
  1826. if m.collection_id != nil {
  1827. fields = append(fields, agentbase.FieldCollectionID)
  1828. }
  1829. if m.source_name != nil {
  1830. fields = append(fields, agentbase.FieldSourceName)
  1831. }
  1832. if m.can_write != nil {
  1833. fields = append(fields, agentbase.FieldCanWrite)
  1834. }
  1835. if m.is_owner != nil {
  1836. fields = append(fields, agentbase.FieldIsOwner)
  1837. }
  1838. return fields
  1839. }
  1840. // Field returns the value of a field with the given name. The second boolean
  1841. // return value indicates that this field was not set, or was not defined in the
  1842. // schema.
  1843. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1844. switch name {
  1845. case agentbase.FieldQ:
  1846. return m.Q()
  1847. case agentbase.FieldA:
  1848. return m.A()
  1849. case agentbase.FieldChunkIndex:
  1850. return m.ChunkIndex()
  1851. case agentbase.FieldIndexes:
  1852. return m.Indexes()
  1853. case agentbase.FieldDatasetID:
  1854. return m.DatasetID()
  1855. case agentbase.FieldCollectionID:
  1856. return m.CollectionID()
  1857. case agentbase.FieldSourceName:
  1858. return m.SourceName()
  1859. case agentbase.FieldCanWrite:
  1860. return m.CanWrite()
  1861. case agentbase.FieldIsOwner:
  1862. return m.IsOwner()
  1863. }
  1864. return nil, false
  1865. }
  1866. // OldField returns the old value of the field from the database. An error is
  1867. // returned if the mutation operation is not UpdateOne, or the query to the
  1868. // database failed.
  1869. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1870. switch name {
  1871. case agentbase.FieldQ:
  1872. return m.OldQ(ctx)
  1873. case agentbase.FieldA:
  1874. return m.OldA(ctx)
  1875. case agentbase.FieldChunkIndex:
  1876. return m.OldChunkIndex(ctx)
  1877. case agentbase.FieldIndexes:
  1878. return m.OldIndexes(ctx)
  1879. case agentbase.FieldDatasetID:
  1880. return m.OldDatasetID(ctx)
  1881. case agentbase.FieldCollectionID:
  1882. return m.OldCollectionID(ctx)
  1883. case agentbase.FieldSourceName:
  1884. return m.OldSourceName(ctx)
  1885. case agentbase.FieldCanWrite:
  1886. return m.OldCanWrite(ctx)
  1887. case agentbase.FieldIsOwner:
  1888. return m.OldIsOwner(ctx)
  1889. }
  1890. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1891. }
  1892. // SetField sets the value of a field with the given name. It returns an error if
  1893. // the field is not defined in the schema, or if the type mismatched the field
  1894. // type.
  1895. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1896. switch name {
  1897. case agentbase.FieldQ:
  1898. v, ok := value.(string)
  1899. if !ok {
  1900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1901. }
  1902. m.SetQ(v)
  1903. return nil
  1904. case agentbase.FieldA:
  1905. v, ok := value.(string)
  1906. if !ok {
  1907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1908. }
  1909. m.SetA(v)
  1910. return nil
  1911. case agentbase.FieldChunkIndex:
  1912. v, ok := value.(uint64)
  1913. if !ok {
  1914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1915. }
  1916. m.SetChunkIndex(v)
  1917. return nil
  1918. case agentbase.FieldIndexes:
  1919. v, ok := value.([]string)
  1920. if !ok {
  1921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1922. }
  1923. m.SetIndexes(v)
  1924. return nil
  1925. case agentbase.FieldDatasetID:
  1926. v, ok := value.(string)
  1927. if !ok {
  1928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1929. }
  1930. m.SetDatasetID(v)
  1931. return nil
  1932. case agentbase.FieldCollectionID:
  1933. v, ok := value.(string)
  1934. if !ok {
  1935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1936. }
  1937. m.SetCollectionID(v)
  1938. return nil
  1939. case agentbase.FieldSourceName:
  1940. v, ok := value.(string)
  1941. if !ok {
  1942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1943. }
  1944. m.SetSourceName(v)
  1945. return nil
  1946. case agentbase.FieldCanWrite:
  1947. v, ok := value.([]bool)
  1948. if !ok {
  1949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1950. }
  1951. m.SetCanWrite(v)
  1952. return nil
  1953. case agentbase.FieldIsOwner:
  1954. v, ok := value.([]bool)
  1955. if !ok {
  1956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1957. }
  1958. m.SetIsOwner(v)
  1959. return nil
  1960. }
  1961. return fmt.Errorf("unknown AgentBase field %s", name)
  1962. }
  1963. // AddedFields returns all numeric fields that were incremented/decremented during
  1964. // this mutation.
  1965. func (m *AgentBaseMutation) AddedFields() []string {
  1966. var fields []string
  1967. if m.addchunk_index != nil {
  1968. fields = append(fields, agentbase.FieldChunkIndex)
  1969. }
  1970. return fields
  1971. }
  1972. // AddedField returns the numeric value that was incremented/decremented on a field
  1973. // with the given name. The second boolean return value indicates that this field
  1974. // was not set, or was not defined in the schema.
  1975. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1976. switch name {
  1977. case agentbase.FieldChunkIndex:
  1978. return m.AddedChunkIndex()
  1979. }
  1980. return nil, false
  1981. }
  1982. // AddField adds the value to the field with the given name. It returns an error if
  1983. // the field is not defined in the schema, or if the type mismatched the field
  1984. // type.
  1985. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1986. switch name {
  1987. case agentbase.FieldChunkIndex:
  1988. v, ok := value.(int64)
  1989. if !ok {
  1990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1991. }
  1992. m.AddChunkIndex(v)
  1993. return nil
  1994. }
  1995. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  1996. }
  1997. // ClearedFields returns all nullable fields that were cleared during this
  1998. // mutation.
  1999. func (m *AgentBaseMutation) ClearedFields() []string {
  2000. var fields []string
  2001. if m.FieldCleared(agentbase.FieldQ) {
  2002. fields = append(fields, agentbase.FieldQ)
  2003. }
  2004. if m.FieldCleared(agentbase.FieldA) {
  2005. fields = append(fields, agentbase.FieldA)
  2006. }
  2007. if m.FieldCleared(agentbase.FieldIndexes) {
  2008. fields = append(fields, agentbase.FieldIndexes)
  2009. }
  2010. if m.FieldCleared(agentbase.FieldDatasetID) {
  2011. fields = append(fields, agentbase.FieldDatasetID)
  2012. }
  2013. if m.FieldCleared(agentbase.FieldCollectionID) {
  2014. fields = append(fields, agentbase.FieldCollectionID)
  2015. }
  2016. if m.FieldCleared(agentbase.FieldSourceName) {
  2017. fields = append(fields, agentbase.FieldSourceName)
  2018. }
  2019. if m.FieldCleared(agentbase.FieldCanWrite) {
  2020. fields = append(fields, agentbase.FieldCanWrite)
  2021. }
  2022. if m.FieldCleared(agentbase.FieldIsOwner) {
  2023. fields = append(fields, agentbase.FieldIsOwner)
  2024. }
  2025. return fields
  2026. }
  2027. // FieldCleared returns a boolean indicating if a field with the given name was
  2028. // cleared in this mutation.
  2029. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2030. _, ok := m.clearedFields[name]
  2031. return ok
  2032. }
  2033. // ClearField clears the value of the field with the given name. It returns an
  2034. // error if the field is not defined in the schema.
  2035. func (m *AgentBaseMutation) ClearField(name string) error {
  2036. switch name {
  2037. case agentbase.FieldQ:
  2038. m.ClearQ()
  2039. return nil
  2040. case agentbase.FieldA:
  2041. m.ClearA()
  2042. return nil
  2043. case agentbase.FieldIndexes:
  2044. m.ClearIndexes()
  2045. return nil
  2046. case agentbase.FieldDatasetID:
  2047. m.ClearDatasetID()
  2048. return nil
  2049. case agentbase.FieldCollectionID:
  2050. m.ClearCollectionID()
  2051. return nil
  2052. case agentbase.FieldSourceName:
  2053. m.ClearSourceName()
  2054. return nil
  2055. case agentbase.FieldCanWrite:
  2056. m.ClearCanWrite()
  2057. return nil
  2058. case agentbase.FieldIsOwner:
  2059. m.ClearIsOwner()
  2060. return nil
  2061. }
  2062. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2063. }
  2064. // ResetField resets all changes in the mutation for the field with the given name.
  2065. // It returns an error if the field is not defined in the schema.
  2066. func (m *AgentBaseMutation) ResetField(name string) error {
  2067. switch name {
  2068. case agentbase.FieldQ:
  2069. m.ResetQ()
  2070. return nil
  2071. case agentbase.FieldA:
  2072. m.ResetA()
  2073. return nil
  2074. case agentbase.FieldChunkIndex:
  2075. m.ResetChunkIndex()
  2076. return nil
  2077. case agentbase.FieldIndexes:
  2078. m.ResetIndexes()
  2079. return nil
  2080. case agentbase.FieldDatasetID:
  2081. m.ResetDatasetID()
  2082. return nil
  2083. case agentbase.FieldCollectionID:
  2084. m.ResetCollectionID()
  2085. return nil
  2086. case agentbase.FieldSourceName:
  2087. m.ResetSourceName()
  2088. return nil
  2089. case agentbase.FieldCanWrite:
  2090. m.ResetCanWrite()
  2091. return nil
  2092. case agentbase.FieldIsOwner:
  2093. m.ResetIsOwner()
  2094. return nil
  2095. }
  2096. return fmt.Errorf("unknown AgentBase field %s", name)
  2097. }
  2098. // AddedEdges returns all edge names that were set/added in this mutation.
  2099. func (m *AgentBaseMutation) AddedEdges() []string {
  2100. edges := make([]string, 0, 1)
  2101. if m.wx_agent != nil {
  2102. edges = append(edges, agentbase.EdgeWxAgent)
  2103. }
  2104. return edges
  2105. }
  2106. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2107. // name in this mutation.
  2108. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2109. switch name {
  2110. case agentbase.EdgeWxAgent:
  2111. ids := make([]ent.Value, 0, len(m.wx_agent))
  2112. for id := range m.wx_agent {
  2113. ids = append(ids, id)
  2114. }
  2115. return ids
  2116. }
  2117. return nil
  2118. }
  2119. // RemovedEdges returns all edge names that were removed in this mutation.
  2120. func (m *AgentBaseMutation) RemovedEdges() []string {
  2121. edges := make([]string, 0, 1)
  2122. if m.removedwx_agent != nil {
  2123. edges = append(edges, agentbase.EdgeWxAgent)
  2124. }
  2125. return edges
  2126. }
  2127. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2128. // the given name in this mutation.
  2129. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2130. switch name {
  2131. case agentbase.EdgeWxAgent:
  2132. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2133. for id := range m.removedwx_agent {
  2134. ids = append(ids, id)
  2135. }
  2136. return ids
  2137. }
  2138. return nil
  2139. }
  2140. // ClearedEdges returns all edge names that were cleared in this mutation.
  2141. func (m *AgentBaseMutation) ClearedEdges() []string {
  2142. edges := make([]string, 0, 1)
  2143. if m.clearedwx_agent {
  2144. edges = append(edges, agentbase.EdgeWxAgent)
  2145. }
  2146. return edges
  2147. }
  2148. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2149. // was cleared in this mutation.
  2150. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2151. switch name {
  2152. case agentbase.EdgeWxAgent:
  2153. return m.clearedwx_agent
  2154. }
  2155. return false
  2156. }
  2157. // ClearEdge clears the value of the edge with the given name. It returns an error
  2158. // if that edge is not defined in the schema.
  2159. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2160. switch name {
  2161. }
  2162. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2163. }
  2164. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2165. // It returns an error if the edge is not defined in the schema.
  2166. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2167. switch name {
  2168. case agentbase.EdgeWxAgent:
  2169. m.ResetWxAgent()
  2170. return nil
  2171. }
  2172. return fmt.Errorf("unknown AgentBase edge %s", name)
  2173. }
  2174. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2175. type AliyunAvatarMutation struct {
  2176. config
  2177. op Op
  2178. typ string
  2179. id *uint64
  2180. created_at *time.Time
  2181. updated_at *time.Time
  2182. deleted_at *time.Time
  2183. user_id *uint64
  2184. adduser_id *int64
  2185. biz_id *string
  2186. access_key_id *string
  2187. access_key_secret *string
  2188. app_id *string
  2189. tenant_id *uint64
  2190. addtenant_id *int64
  2191. response *string
  2192. token *string
  2193. session_id *string
  2194. clearedFields map[string]struct{}
  2195. done bool
  2196. oldValue func(context.Context) (*AliyunAvatar, error)
  2197. predicates []predicate.AliyunAvatar
  2198. }
  2199. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2200. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2201. type aliyunavatarOption func(*AliyunAvatarMutation)
  2202. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2203. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2204. m := &AliyunAvatarMutation{
  2205. config: c,
  2206. op: op,
  2207. typ: TypeAliyunAvatar,
  2208. clearedFields: make(map[string]struct{}),
  2209. }
  2210. for _, opt := range opts {
  2211. opt(m)
  2212. }
  2213. return m
  2214. }
  2215. // withAliyunAvatarID sets the ID field of the mutation.
  2216. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2217. return func(m *AliyunAvatarMutation) {
  2218. var (
  2219. err error
  2220. once sync.Once
  2221. value *AliyunAvatar
  2222. )
  2223. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2224. once.Do(func() {
  2225. if m.done {
  2226. err = errors.New("querying old values post mutation is not allowed")
  2227. } else {
  2228. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2229. }
  2230. })
  2231. return value, err
  2232. }
  2233. m.id = &id
  2234. }
  2235. }
  2236. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2237. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2238. return func(m *AliyunAvatarMutation) {
  2239. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2240. return node, nil
  2241. }
  2242. m.id = &node.ID
  2243. }
  2244. }
  2245. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2246. // executed in a transaction (ent.Tx), a transactional client is returned.
  2247. func (m AliyunAvatarMutation) Client() *Client {
  2248. client := &Client{config: m.config}
  2249. client.init()
  2250. return client
  2251. }
  2252. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2253. // it returns an error otherwise.
  2254. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2255. if _, ok := m.driver.(*txDriver); !ok {
  2256. return nil, errors.New("ent: mutation is not running in a transaction")
  2257. }
  2258. tx := &Tx{config: m.config}
  2259. tx.init()
  2260. return tx, nil
  2261. }
  2262. // SetID sets the value of the id field. Note that this
  2263. // operation is only accepted on creation of AliyunAvatar entities.
  2264. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2265. m.id = &id
  2266. }
  2267. // ID returns the ID value in the mutation. Note that the ID is only available
  2268. // if it was provided to the builder or after it was returned from the database.
  2269. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2270. if m.id == nil {
  2271. return
  2272. }
  2273. return *m.id, true
  2274. }
  2275. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2276. // That means, if the mutation is applied within a transaction with an isolation level such
  2277. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2278. // or updated by the mutation.
  2279. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2280. switch {
  2281. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2282. id, exists := m.ID()
  2283. if exists {
  2284. return []uint64{id}, nil
  2285. }
  2286. fallthrough
  2287. case m.op.Is(OpUpdate | OpDelete):
  2288. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2289. default:
  2290. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2291. }
  2292. }
  2293. // SetCreatedAt sets the "created_at" field.
  2294. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2295. m.created_at = &t
  2296. }
  2297. // CreatedAt returns the value of the "created_at" field in the mutation.
  2298. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2299. v := m.created_at
  2300. if v == nil {
  2301. return
  2302. }
  2303. return *v, true
  2304. }
  2305. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2306. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2308. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2309. if !m.op.Is(OpUpdateOne) {
  2310. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2311. }
  2312. if m.id == nil || m.oldValue == nil {
  2313. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2314. }
  2315. oldValue, err := m.oldValue(ctx)
  2316. if err != nil {
  2317. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2318. }
  2319. return oldValue.CreatedAt, nil
  2320. }
  2321. // ResetCreatedAt resets all changes to the "created_at" field.
  2322. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2323. m.created_at = nil
  2324. }
  2325. // SetUpdatedAt sets the "updated_at" field.
  2326. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2327. m.updated_at = &t
  2328. }
  2329. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2330. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2331. v := m.updated_at
  2332. if v == nil {
  2333. return
  2334. }
  2335. return *v, true
  2336. }
  2337. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2338. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2340. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2341. if !m.op.Is(OpUpdateOne) {
  2342. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2343. }
  2344. if m.id == nil || m.oldValue == nil {
  2345. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2346. }
  2347. oldValue, err := m.oldValue(ctx)
  2348. if err != nil {
  2349. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2350. }
  2351. return oldValue.UpdatedAt, nil
  2352. }
  2353. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2354. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2355. m.updated_at = nil
  2356. }
  2357. // SetDeletedAt sets the "deleted_at" field.
  2358. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2359. m.deleted_at = &t
  2360. }
  2361. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2362. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2363. v := m.deleted_at
  2364. if v == nil {
  2365. return
  2366. }
  2367. return *v, true
  2368. }
  2369. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2370. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2372. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2373. if !m.op.Is(OpUpdateOne) {
  2374. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2375. }
  2376. if m.id == nil || m.oldValue == nil {
  2377. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2378. }
  2379. oldValue, err := m.oldValue(ctx)
  2380. if err != nil {
  2381. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2382. }
  2383. return oldValue.DeletedAt, nil
  2384. }
  2385. // ClearDeletedAt clears the value of the "deleted_at" field.
  2386. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2387. m.deleted_at = nil
  2388. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2389. }
  2390. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2391. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2392. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2393. return ok
  2394. }
  2395. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2396. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2397. m.deleted_at = nil
  2398. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2399. }
  2400. // SetUserID sets the "user_id" field.
  2401. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2402. m.user_id = &u
  2403. m.adduser_id = nil
  2404. }
  2405. // UserID returns the value of the "user_id" field in the mutation.
  2406. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2407. v := m.user_id
  2408. if v == nil {
  2409. return
  2410. }
  2411. return *v, true
  2412. }
  2413. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2414. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2416. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2417. if !m.op.Is(OpUpdateOne) {
  2418. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2419. }
  2420. if m.id == nil || m.oldValue == nil {
  2421. return v, errors.New("OldUserID requires an ID field in the mutation")
  2422. }
  2423. oldValue, err := m.oldValue(ctx)
  2424. if err != nil {
  2425. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2426. }
  2427. return oldValue.UserID, nil
  2428. }
  2429. // AddUserID adds u to the "user_id" field.
  2430. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2431. if m.adduser_id != nil {
  2432. *m.adduser_id += u
  2433. } else {
  2434. m.adduser_id = &u
  2435. }
  2436. }
  2437. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2438. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2439. v := m.adduser_id
  2440. if v == nil {
  2441. return
  2442. }
  2443. return *v, true
  2444. }
  2445. // ResetUserID resets all changes to the "user_id" field.
  2446. func (m *AliyunAvatarMutation) ResetUserID() {
  2447. m.user_id = nil
  2448. m.adduser_id = nil
  2449. }
  2450. // SetBizID sets the "biz_id" field.
  2451. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2452. m.biz_id = &s
  2453. }
  2454. // BizID returns the value of the "biz_id" field in the mutation.
  2455. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2456. v := m.biz_id
  2457. if v == nil {
  2458. return
  2459. }
  2460. return *v, true
  2461. }
  2462. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2463. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2465. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2466. if !m.op.Is(OpUpdateOne) {
  2467. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2468. }
  2469. if m.id == nil || m.oldValue == nil {
  2470. return v, errors.New("OldBizID requires an ID field in the mutation")
  2471. }
  2472. oldValue, err := m.oldValue(ctx)
  2473. if err != nil {
  2474. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2475. }
  2476. return oldValue.BizID, nil
  2477. }
  2478. // ResetBizID resets all changes to the "biz_id" field.
  2479. func (m *AliyunAvatarMutation) ResetBizID() {
  2480. m.biz_id = nil
  2481. }
  2482. // SetAccessKeyID sets the "access_key_id" field.
  2483. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2484. m.access_key_id = &s
  2485. }
  2486. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2487. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2488. v := m.access_key_id
  2489. if v == nil {
  2490. return
  2491. }
  2492. return *v, true
  2493. }
  2494. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2495. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2497. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2498. if !m.op.Is(OpUpdateOne) {
  2499. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2500. }
  2501. if m.id == nil || m.oldValue == nil {
  2502. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2503. }
  2504. oldValue, err := m.oldValue(ctx)
  2505. if err != nil {
  2506. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2507. }
  2508. return oldValue.AccessKeyID, nil
  2509. }
  2510. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2511. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2512. m.access_key_id = nil
  2513. }
  2514. // SetAccessKeySecret sets the "access_key_secret" field.
  2515. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2516. m.access_key_secret = &s
  2517. }
  2518. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2519. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2520. v := m.access_key_secret
  2521. if v == nil {
  2522. return
  2523. }
  2524. return *v, true
  2525. }
  2526. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2527. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2529. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2530. if !m.op.Is(OpUpdateOne) {
  2531. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2532. }
  2533. if m.id == nil || m.oldValue == nil {
  2534. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2535. }
  2536. oldValue, err := m.oldValue(ctx)
  2537. if err != nil {
  2538. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2539. }
  2540. return oldValue.AccessKeySecret, nil
  2541. }
  2542. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2543. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2544. m.access_key_secret = nil
  2545. }
  2546. // SetAppID sets the "app_id" field.
  2547. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2548. m.app_id = &s
  2549. }
  2550. // AppID returns the value of the "app_id" field in the mutation.
  2551. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2552. v := m.app_id
  2553. if v == nil {
  2554. return
  2555. }
  2556. return *v, true
  2557. }
  2558. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2559. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2561. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2562. if !m.op.Is(OpUpdateOne) {
  2563. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2564. }
  2565. if m.id == nil || m.oldValue == nil {
  2566. return v, errors.New("OldAppID requires an ID field in the mutation")
  2567. }
  2568. oldValue, err := m.oldValue(ctx)
  2569. if err != nil {
  2570. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2571. }
  2572. return oldValue.AppID, nil
  2573. }
  2574. // ClearAppID clears the value of the "app_id" field.
  2575. func (m *AliyunAvatarMutation) ClearAppID() {
  2576. m.app_id = nil
  2577. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2578. }
  2579. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2580. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2581. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2582. return ok
  2583. }
  2584. // ResetAppID resets all changes to the "app_id" field.
  2585. func (m *AliyunAvatarMutation) ResetAppID() {
  2586. m.app_id = nil
  2587. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2588. }
  2589. // SetTenantID sets the "tenant_id" field.
  2590. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2591. m.tenant_id = &u
  2592. m.addtenant_id = nil
  2593. }
  2594. // TenantID returns the value of the "tenant_id" field in the mutation.
  2595. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2596. v := m.tenant_id
  2597. if v == nil {
  2598. return
  2599. }
  2600. return *v, true
  2601. }
  2602. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2603. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2605. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2606. if !m.op.Is(OpUpdateOne) {
  2607. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2608. }
  2609. if m.id == nil || m.oldValue == nil {
  2610. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2611. }
  2612. oldValue, err := m.oldValue(ctx)
  2613. if err != nil {
  2614. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2615. }
  2616. return oldValue.TenantID, nil
  2617. }
  2618. // AddTenantID adds u to the "tenant_id" field.
  2619. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2620. if m.addtenant_id != nil {
  2621. *m.addtenant_id += u
  2622. } else {
  2623. m.addtenant_id = &u
  2624. }
  2625. }
  2626. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2627. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2628. v := m.addtenant_id
  2629. if v == nil {
  2630. return
  2631. }
  2632. return *v, true
  2633. }
  2634. // ResetTenantID resets all changes to the "tenant_id" field.
  2635. func (m *AliyunAvatarMutation) ResetTenantID() {
  2636. m.tenant_id = nil
  2637. m.addtenant_id = nil
  2638. }
  2639. // SetResponse sets the "response" field.
  2640. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2641. m.response = &s
  2642. }
  2643. // Response returns the value of the "response" field in the mutation.
  2644. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2645. v := m.response
  2646. if v == nil {
  2647. return
  2648. }
  2649. return *v, true
  2650. }
  2651. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2652. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2654. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2655. if !m.op.Is(OpUpdateOne) {
  2656. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2657. }
  2658. if m.id == nil || m.oldValue == nil {
  2659. return v, errors.New("OldResponse requires an ID field in the mutation")
  2660. }
  2661. oldValue, err := m.oldValue(ctx)
  2662. if err != nil {
  2663. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2664. }
  2665. return oldValue.Response, nil
  2666. }
  2667. // ResetResponse resets all changes to the "response" field.
  2668. func (m *AliyunAvatarMutation) ResetResponse() {
  2669. m.response = nil
  2670. }
  2671. // SetToken sets the "token" field.
  2672. func (m *AliyunAvatarMutation) SetToken(s string) {
  2673. m.token = &s
  2674. }
  2675. // Token returns the value of the "token" field in the mutation.
  2676. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2677. v := m.token
  2678. if v == nil {
  2679. return
  2680. }
  2681. return *v, true
  2682. }
  2683. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2684. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2686. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2687. if !m.op.Is(OpUpdateOne) {
  2688. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2689. }
  2690. if m.id == nil || m.oldValue == nil {
  2691. return v, errors.New("OldToken requires an ID field in the mutation")
  2692. }
  2693. oldValue, err := m.oldValue(ctx)
  2694. if err != nil {
  2695. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2696. }
  2697. return oldValue.Token, nil
  2698. }
  2699. // ResetToken resets all changes to the "token" field.
  2700. func (m *AliyunAvatarMutation) ResetToken() {
  2701. m.token = nil
  2702. }
  2703. // SetSessionID sets the "session_id" field.
  2704. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2705. m.session_id = &s
  2706. }
  2707. // SessionID returns the value of the "session_id" field in the mutation.
  2708. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2709. v := m.session_id
  2710. if v == nil {
  2711. return
  2712. }
  2713. return *v, true
  2714. }
  2715. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2716. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2718. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2719. if !m.op.Is(OpUpdateOne) {
  2720. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2721. }
  2722. if m.id == nil || m.oldValue == nil {
  2723. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2724. }
  2725. oldValue, err := m.oldValue(ctx)
  2726. if err != nil {
  2727. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2728. }
  2729. return oldValue.SessionID, nil
  2730. }
  2731. // ResetSessionID resets all changes to the "session_id" field.
  2732. func (m *AliyunAvatarMutation) ResetSessionID() {
  2733. m.session_id = nil
  2734. }
  2735. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2736. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2737. m.predicates = append(m.predicates, ps...)
  2738. }
  2739. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2740. // users can use type-assertion to append predicates that do not depend on any generated package.
  2741. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2742. p := make([]predicate.AliyunAvatar, len(ps))
  2743. for i := range ps {
  2744. p[i] = ps[i]
  2745. }
  2746. m.Where(p...)
  2747. }
  2748. // Op returns the operation name.
  2749. func (m *AliyunAvatarMutation) Op() Op {
  2750. return m.op
  2751. }
  2752. // SetOp allows setting the mutation operation.
  2753. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2754. m.op = op
  2755. }
  2756. // Type returns the node type of this mutation (AliyunAvatar).
  2757. func (m *AliyunAvatarMutation) Type() string {
  2758. return m.typ
  2759. }
  2760. // Fields returns all fields that were changed during this mutation. Note that in
  2761. // order to get all numeric fields that were incremented/decremented, call
  2762. // AddedFields().
  2763. func (m *AliyunAvatarMutation) Fields() []string {
  2764. fields := make([]string, 0, 12)
  2765. if m.created_at != nil {
  2766. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2767. }
  2768. if m.updated_at != nil {
  2769. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2770. }
  2771. if m.deleted_at != nil {
  2772. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2773. }
  2774. if m.user_id != nil {
  2775. fields = append(fields, aliyunavatar.FieldUserID)
  2776. }
  2777. if m.biz_id != nil {
  2778. fields = append(fields, aliyunavatar.FieldBizID)
  2779. }
  2780. if m.access_key_id != nil {
  2781. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2782. }
  2783. if m.access_key_secret != nil {
  2784. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2785. }
  2786. if m.app_id != nil {
  2787. fields = append(fields, aliyunavatar.FieldAppID)
  2788. }
  2789. if m.tenant_id != nil {
  2790. fields = append(fields, aliyunavatar.FieldTenantID)
  2791. }
  2792. if m.response != nil {
  2793. fields = append(fields, aliyunavatar.FieldResponse)
  2794. }
  2795. if m.token != nil {
  2796. fields = append(fields, aliyunavatar.FieldToken)
  2797. }
  2798. if m.session_id != nil {
  2799. fields = append(fields, aliyunavatar.FieldSessionID)
  2800. }
  2801. return fields
  2802. }
  2803. // Field returns the value of a field with the given name. The second boolean
  2804. // return value indicates that this field was not set, or was not defined in the
  2805. // schema.
  2806. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2807. switch name {
  2808. case aliyunavatar.FieldCreatedAt:
  2809. return m.CreatedAt()
  2810. case aliyunavatar.FieldUpdatedAt:
  2811. return m.UpdatedAt()
  2812. case aliyunavatar.FieldDeletedAt:
  2813. return m.DeletedAt()
  2814. case aliyunavatar.FieldUserID:
  2815. return m.UserID()
  2816. case aliyunavatar.FieldBizID:
  2817. return m.BizID()
  2818. case aliyunavatar.FieldAccessKeyID:
  2819. return m.AccessKeyID()
  2820. case aliyunavatar.FieldAccessKeySecret:
  2821. return m.AccessKeySecret()
  2822. case aliyunavatar.FieldAppID:
  2823. return m.AppID()
  2824. case aliyunavatar.FieldTenantID:
  2825. return m.TenantID()
  2826. case aliyunavatar.FieldResponse:
  2827. return m.Response()
  2828. case aliyunavatar.FieldToken:
  2829. return m.Token()
  2830. case aliyunavatar.FieldSessionID:
  2831. return m.SessionID()
  2832. }
  2833. return nil, false
  2834. }
  2835. // OldField returns the old value of the field from the database. An error is
  2836. // returned if the mutation operation is not UpdateOne, or the query to the
  2837. // database failed.
  2838. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2839. switch name {
  2840. case aliyunavatar.FieldCreatedAt:
  2841. return m.OldCreatedAt(ctx)
  2842. case aliyunavatar.FieldUpdatedAt:
  2843. return m.OldUpdatedAt(ctx)
  2844. case aliyunavatar.FieldDeletedAt:
  2845. return m.OldDeletedAt(ctx)
  2846. case aliyunavatar.FieldUserID:
  2847. return m.OldUserID(ctx)
  2848. case aliyunavatar.FieldBizID:
  2849. return m.OldBizID(ctx)
  2850. case aliyunavatar.FieldAccessKeyID:
  2851. return m.OldAccessKeyID(ctx)
  2852. case aliyunavatar.FieldAccessKeySecret:
  2853. return m.OldAccessKeySecret(ctx)
  2854. case aliyunavatar.FieldAppID:
  2855. return m.OldAppID(ctx)
  2856. case aliyunavatar.FieldTenantID:
  2857. return m.OldTenantID(ctx)
  2858. case aliyunavatar.FieldResponse:
  2859. return m.OldResponse(ctx)
  2860. case aliyunavatar.FieldToken:
  2861. return m.OldToken(ctx)
  2862. case aliyunavatar.FieldSessionID:
  2863. return m.OldSessionID(ctx)
  2864. }
  2865. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2866. }
  2867. // SetField sets the value of a field with the given name. It returns an error if
  2868. // the field is not defined in the schema, or if the type mismatched the field
  2869. // type.
  2870. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2871. switch name {
  2872. case aliyunavatar.FieldCreatedAt:
  2873. v, ok := value.(time.Time)
  2874. if !ok {
  2875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2876. }
  2877. m.SetCreatedAt(v)
  2878. return nil
  2879. case aliyunavatar.FieldUpdatedAt:
  2880. v, ok := value.(time.Time)
  2881. if !ok {
  2882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2883. }
  2884. m.SetUpdatedAt(v)
  2885. return nil
  2886. case aliyunavatar.FieldDeletedAt:
  2887. v, ok := value.(time.Time)
  2888. if !ok {
  2889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2890. }
  2891. m.SetDeletedAt(v)
  2892. return nil
  2893. case aliyunavatar.FieldUserID:
  2894. v, ok := value.(uint64)
  2895. if !ok {
  2896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2897. }
  2898. m.SetUserID(v)
  2899. return nil
  2900. case aliyunavatar.FieldBizID:
  2901. v, ok := value.(string)
  2902. if !ok {
  2903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2904. }
  2905. m.SetBizID(v)
  2906. return nil
  2907. case aliyunavatar.FieldAccessKeyID:
  2908. v, ok := value.(string)
  2909. if !ok {
  2910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2911. }
  2912. m.SetAccessKeyID(v)
  2913. return nil
  2914. case aliyunavatar.FieldAccessKeySecret:
  2915. v, ok := value.(string)
  2916. if !ok {
  2917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2918. }
  2919. m.SetAccessKeySecret(v)
  2920. return nil
  2921. case aliyunavatar.FieldAppID:
  2922. v, ok := value.(string)
  2923. if !ok {
  2924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2925. }
  2926. m.SetAppID(v)
  2927. return nil
  2928. case aliyunavatar.FieldTenantID:
  2929. v, ok := value.(uint64)
  2930. if !ok {
  2931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2932. }
  2933. m.SetTenantID(v)
  2934. return nil
  2935. case aliyunavatar.FieldResponse:
  2936. v, ok := value.(string)
  2937. if !ok {
  2938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2939. }
  2940. m.SetResponse(v)
  2941. return nil
  2942. case aliyunavatar.FieldToken:
  2943. v, ok := value.(string)
  2944. if !ok {
  2945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2946. }
  2947. m.SetToken(v)
  2948. return nil
  2949. case aliyunavatar.FieldSessionID:
  2950. v, ok := value.(string)
  2951. if !ok {
  2952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2953. }
  2954. m.SetSessionID(v)
  2955. return nil
  2956. }
  2957. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2958. }
  2959. // AddedFields returns all numeric fields that were incremented/decremented during
  2960. // this mutation.
  2961. func (m *AliyunAvatarMutation) AddedFields() []string {
  2962. var fields []string
  2963. if m.adduser_id != nil {
  2964. fields = append(fields, aliyunavatar.FieldUserID)
  2965. }
  2966. if m.addtenant_id != nil {
  2967. fields = append(fields, aliyunavatar.FieldTenantID)
  2968. }
  2969. return fields
  2970. }
  2971. // AddedField returns the numeric value that was incremented/decremented on a field
  2972. // with the given name. The second boolean return value indicates that this field
  2973. // was not set, or was not defined in the schema.
  2974. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2975. switch name {
  2976. case aliyunavatar.FieldUserID:
  2977. return m.AddedUserID()
  2978. case aliyunavatar.FieldTenantID:
  2979. return m.AddedTenantID()
  2980. }
  2981. return nil, false
  2982. }
  2983. // AddField adds the value to the field with the given name. It returns an error if
  2984. // the field is not defined in the schema, or if the type mismatched the field
  2985. // type.
  2986. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  2987. switch name {
  2988. case aliyunavatar.FieldUserID:
  2989. v, ok := value.(int64)
  2990. if !ok {
  2991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2992. }
  2993. m.AddUserID(v)
  2994. return nil
  2995. case aliyunavatar.FieldTenantID:
  2996. v, ok := value.(int64)
  2997. if !ok {
  2998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2999. }
  3000. m.AddTenantID(v)
  3001. return nil
  3002. }
  3003. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3004. }
  3005. // ClearedFields returns all nullable fields that were cleared during this
  3006. // mutation.
  3007. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3008. var fields []string
  3009. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3010. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3011. }
  3012. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3013. fields = append(fields, aliyunavatar.FieldAppID)
  3014. }
  3015. return fields
  3016. }
  3017. // FieldCleared returns a boolean indicating if a field with the given name was
  3018. // cleared in this mutation.
  3019. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3020. _, ok := m.clearedFields[name]
  3021. return ok
  3022. }
  3023. // ClearField clears the value of the field with the given name. It returns an
  3024. // error if the field is not defined in the schema.
  3025. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3026. switch name {
  3027. case aliyunavatar.FieldDeletedAt:
  3028. m.ClearDeletedAt()
  3029. return nil
  3030. case aliyunavatar.FieldAppID:
  3031. m.ClearAppID()
  3032. return nil
  3033. }
  3034. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3035. }
  3036. // ResetField resets all changes in the mutation for the field with the given name.
  3037. // It returns an error if the field is not defined in the schema.
  3038. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3039. switch name {
  3040. case aliyunavatar.FieldCreatedAt:
  3041. m.ResetCreatedAt()
  3042. return nil
  3043. case aliyunavatar.FieldUpdatedAt:
  3044. m.ResetUpdatedAt()
  3045. return nil
  3046. case aliyunavatar.FieldDeletedAt:
  3047. m.ResetDeletedAt()
  3048. return nil
  3049. case aliyunavatar.FieldUserID:
  3050. m.ResetUserID()
  3051. return nil
  3052. case aliyunavatar.FieldBizID:
  3053. m.ResetBizID()
  3054. return nil
  3055. case aliyunavatar.FieldAccessKeyID:
  3056. m.ResetAccessKeyID()
  3057. return nil
  3058. case aliyunavatar.FieldAccessKeySecret:
  3059. m.ResetAccessKeySecret()
  3060. return nil
  3061. case aliyunavatar.FieldAppID:
  3062. m.ResetAppID()
  3063. return nil
  3064. case aliyunavatar.FieldTenantID:
  3065. m.ResetTenantID()
  3066. return nil
  3067. case aliyunavatar.FieldResponse:
  3068. m.ResetResponse()
  3069. return nil
  3070. case aliyunavatar.FieldToken:
  3071. m.ResetToken()
  3072. return nil
  3073. case aliyunavatar.FieldSessionID:
  3074. m.ResetSessionID()
  3075. return nil
  3076. }
  3077. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3078. }
  3079. // AddedEdges returns all edge names that were set/added in this mutation.
  3080. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3081. edges := make([]string, 0, 0)
  3082. return edges
  3083. }
  3084. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3085. // name in this mutation.
  3086. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3087. return nil
  3088. }
  3089. // RemovedEdges returns all edge names that were removed in this mutation.
  3090. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3091. edges := make([]string, 0, 0)
  3092. return edges
  3093. }
  3094. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3095. // the given name in this mutation.
  3096. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3097. return nil
  3098. }
  3099. // ClearedEdges returns all edge names that were cleared in this mutation.
  3100. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3101. edges := make([]string, 0, 0)
  3102. return edges
  3103. }
  3104. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3105. // was cleared in this mutation.
  3106. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3107. return false
  3108. }
  3109. // ClearEdge clears the value of the edge with the given name. It returns an error
  3110. // if that edge is not defined in the schema.
  3111. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3112. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3113. }
  3114. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3115. // It returns an error if the edge is not defined in the schema.
  3116. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3117. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3118. }
  3119. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3120. type BatchMsgMutation struct {
  3121. config
  3122. op Op
  3123. typ string
  3124. id *uint64
  3125. created_at *time.Time
  3126. updated_at *time.Time
  3127. deleted_at *time.Time
  3128. status *uint8
  3129. addstatus *int8
  3130. batch_no *string
  3131. task_name *string
  3132. fromwxid *string
  3133. msg *string
  3134. tag *string
  3135. tagids *string
  3136. total *int32
  3137. addtotal *int32
  3138. success *int32
  3139. addsuccess *int32
  3140. fail *int32
  3141. addfail *int32
  3142. start_time *time.Time
  3143. stop_time *time.Time
  3144. send_time *time.Time
  3145. _type *int32
  3146. add_type *int32
  3147. organization_id *uint64
  3148. addorganization_id *int64
  3149. clearedFields map[string]struct{}
  3150. done bool
  3151. oldValue func(context.Context) (*BatchMsg, error)
  3152. predicates []predicate.BatchMsg
  3153. }
  3154. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3155. // batchmsgOption allows management of the mutation configuration using functional options.
  3156. type batchmsgOption func(*BatchMsgMutation)
  3157. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3158. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3159. m := &BatchMsgMutation{
  3160. config: c,
  3161. op: op,
  3162. typ: TypeBatchMsg,
  3163. clearedFields: make(map[string]struct{}),
  3164. }
  3165. for _, opt := range opts {
  3166. opt(m)
  3167. }
  3168. return m
  3169. }
  3170. // withBatchMsgID sets the ID field of the mutation.
  3171. func withBatchMsgID(id uint64) batchmsgOption {
  3172. return func(m *BatchMsgMutation) {
  3173. var (
  3174. err error
  3175. once sync.Once
  3176. value *BatchMsg
  3177. )
  3178. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3179. once.Do(func() {
  3180. if m.done {
  3181. err = errors.New("querying old values post mutation is not allowed")
  3182. } else {
  3183. value, err = m.Client().BatchMsg.Get(ctx, id)
  3184. }
  3185. })
  3186. return value, err
  3187. }
  3188. m.id = &id
  3189. }
  3190. }
  3191. // withBatchMsg sets the old BatchMsg of the mutation.
  3192. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3193. return func(m *BatchMsgMutation) {
  3194. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3195. return node, nil
  3196. }
  3197. m.id = &node.ID
  3198. }
  3199. }
  3200. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3201. // executed in a transaction (ent.Tx), a transactional client is returned.
  3202. func (m BatchMsgMutation) Client() *Client {
  3203. client := &Client{config: m.config}
  3204. client.init()
  3205. return client
  3206. }
  3207. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3208. // it returns an error otherwise.
  3209. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3210. if _, ok := m.driver.(*txDriver); !ok {
  3211. return nil, errors.New("ent: mutation is not running in a transaction")
  3212. }
  3213. tx := &Tx{config: m.config}
  3214. tx.init()
  3215. return tx, nil
  3216. }
  3217. // SetID sets the value of the id field. Note that this
  3218. // operation is only accepted on creation of BatchMsg entities.
  3219. func (m *BatchMsgMutation) SetID(id uint64) {
  3220. m.id = &id
  3221. }
  3222. // ID returns the ID value in the mutation. Note that the ID is only available
  3223. // if it was provided to the builder or after it was returned from the database.
  3224. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3225. if m.id == nil {
  3226. return
  3227. }
  3228. return *m.id, true
  3229. }
  3230. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3231. // That means, if the mutation is applied within a transaction with an isolation level such
  3232. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3233. // or updated by the mutation.
  3234. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3235. switch {
  3236. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3237. id, exists := m.ID()
  3238. if exists {
  3239. return []uint64{id}, nil
  3240. }
  3241. fallthrough
  3242. case m.op.Is(OpUpdate | OpDelete):
  3243. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  3244. default:
  3245. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3246. }
  3247. }
  3248. // SetCreatedAt sets the "created_at" field.
  3249. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  3250. m.created_at = &t
  3251. }
  3252. // CreatedAt returns the value of the "created_at" field in the mutation.
  3253. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  3254. v := m.created_at
  3255. if v == nil {
  3256. return
  3257. }
  3258. return *v, true
  3259. }
  3260. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  3261. // If the BatchMsg 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 *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3264. if !m.op.Is(OpUpdateOne) {
  3265. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3266. }
  3267. if m.id == nil || m.oldValue == nil {
  3268. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  3273. }
  3274. return oldValue.CreatedAt, nil
  3275. }
  3276. // ResetCreatedAt resets all changes to the "created_at" field.
  3277. func (m *BatchMsgMutation) ResetCreatedAt() {
  3278. m.created_at = nil
  3279. }
  3280. // SetUpdatedAt sets the "updated_at" field.
  3281. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  3282. m.updated_at = &t
  3283. }
  3284. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3285. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  3286. v := m.updated_at
  3287. if v == nil {
  3288. return
  3289. }
  3290. return *v, true
  3291. }
  3292. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  3293. // If the BatchMsg 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 *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3296. if !m.op.Is(OpUpdateOne) {
  3297. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3298. }
  3299. if m.id == nil || m.oldValue == nil {
  3300. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  3305. }
  3306. return oldValue.UpdatedAt, nil
  3307. }
  3308. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3309. func (m *BatchMsgMutation) ResetUpdatedAt() {
  3310. m.updated_at = nil
  3311. }
  3312. // SetDeletedAt sets the "deleted_at" field.
  3313. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  3314. m.deleted_at = &t
  3315. }
  3316. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3317. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  3318. v := m.deleted_at
  3319. if v == nil {
  3320. return
  3321. }
  3322. return *v, true
  3323. }
  3324. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  3325. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3327. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3328. if !m.op.Is(OpUpdateOne) {
  3329. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3330. }
  3331. if m.id == nil || m.oldValue == nil {
  3332. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3333. }
  3334. oldValue, err := m.oldValue(ctx)
  3335. if err != nil {
  3336. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3337. }
  3338. return oldValue.DeletedAt, nil
  3339. }
  3340. // ClearDeletedAt clears the value of the "deleted_at" field.
  3341. func (m *BatchMsgMutation) ClearDeletedAt() {
  3342. m.deleted_at = nil
  3343. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  3344. }
  3345. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3346. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  3347. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  3348. return ok
  3349. }
  3350. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3351. func (m *BatchMsgMutation) ResetDeletedAt() {
  3352. m.deleted_at = nil
  3353. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  3354. }
  3355. // SetStatus sets the "status" field.
  3356. func (m *BatchMsgMutation) SetStatus(u uint8) {
  3357. m.status = &u
  3358. m.addstatus = nil
  3359. }
  3360. // Status returns the value of the "status" field in the mutation.
  3361. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  3362. v := m.status
  3363. if v == nil {
  3364. return
  3365. }
  3366. return *v, true
  3367. }
  3368. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  3369. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3371. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3372. if !m.op.Is(OpUpdateOne) {
  3373. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3374. }
  3375. if m.id == nil || m.oldValue == nil {
  3376. return v, errors.New("OldStatus requires an ID field in the mutation")
  3377. }
  3378. oldValue, err := m.oldValue(ctx)
  3379. if err != nil {
  3380. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3381. }
  3382. return oldValue.Status, nil
  3383. }
  3384. // AddStatus adds u to the "status" field.
  3385. func (m *BatchMsgMutation) AddStatus(u int8) {
  3386. if m.addstatus != nil {
  3387. *m.addstatus += u
  3388. } else {
  3389. m.addstatus = &u
  3390. }
  3391. }
  3392. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3393. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  3394. v := m.addstatus
  3395. if v == nil {
  3396. return
  3397. }
  3398. return *v, true
  3399. }
  3400. // ClearStatus clears the value of the "status" field.
  3401. func (m *BatchMsgMutation) ClearStatus() {
  3402. m.status = nil
  3403. m.addstatus = nil
  3404. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  3405. }
  3406. // StatusCleared returns if the "status" field was cleared in this mutation.
  3407. func (m *BatchMsgMutation) StatusCleared() bool {
  3408. _, ok := m.clearedFields[batchmsg.FieldStatus]
  3409. return ok
  3410. }
  3411. // ResetStatus resets all changes to the "status" field.
  3412. func (m *BatchMsgMutation) ResetStatus() {
  3413. m.status = nil
  3414. m.addstatus = nil
  3415. delete(m.clearedFields, batchmsg.FieldStatus)
  3416. }
  3417. // SetBatchNo sets the "batch_no" field.
  3418. func (m *BatchMsgMutation) SetBatchNo(s string) {
  3419. m.batch_no = &s
  3420. }
  3421. // BatchNo returns the value of the "batch_no" field in the mutation.
  3422. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  3423. v := m.batch_no
  3424. if v == nil {
  3425. return
  3426. }
  3427. return *v, true
  3428. }
  3429. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  3430. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3432. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  3433. if !m.op.Is(OpUpdateOne) {
  3434. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  3435. }
  3436. if m.id == nil || m.oldValue == nil {
  3437. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  3438. }
  3439. oldValue, err := m.oldValue(ctx)
  3440. if err != nil {
  3441. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  3442. }
  3443. return oldValue.BatchNo, nil
  3444. }
  3445. // ClearBatchNo clears the value of the "batch_no" field.
  3446. func (m *BatchMsgMutation) ClearBatchNo() {
  3447. m.batch_no = nil
  3448. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  3449. }
  3450. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  3451. func (m *BatchMsgMutation) BatchNoCleared() bool {
  3452. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  3453. return ok
  3454. }
  3455. // ResetBatchNo resets all changes to the "batch_no" field.
  3456. func (m *BatchMsgMutation) ResetBatchNo() {
  3457. m.batch_no = nil
  3458. delete(m.clearedFields, batchmsg.FieldBatchNo)
  3459. }
  3460. // SetTaskName sets the "task_name" field.
  3461. func (m *BatchMsgMutation) SetTaskName(s string) {
  3462. m.task_name = &s
  3463. }
  3464. // TaskName returns the value of the "task_name" field in the mutation.
  3465. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  3466. v := m.task_name
  3467. if v == nil {
  3468. return
  3469. }
  3470. return *v, true
  3471. }
  3472. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  3473. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3475. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  3476. if !m.op.Is(OpUpdateOne) {
  3477. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  3478. }
  3479. if m.id == nil || m.oldValue == nil {
  3480. return v, errors.New("OldTaskName requires an ID field in the mutation")
  3481. }
  3482. oldValue, err := m.oldValue(ctx)
  3483. if err != nil {
  3484. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  3485. }
  3486. return oldValue.TaskName, nil
  3487. }
  3488. // ClearTaskName clears the value of the "task_name" field.
  3489. func (m *BatchMsgMutation) ClearTaskName() {
  3490. m.task_name = nil
  3491. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  3492. }
  3493. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  3494. func (m *BatchMsgMutation) TaskNameCleared() bool {
  3495. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  3496. return ok
  3497. }
  3498. // ResetTaskName resets all changes to the "task_name" field.
  3499. func (m *BatchMsgMutation) ResetTaskName() {
  3500. m.task_name = nil
  3501. delete(m.clearedFields, batchmsg.FieldTaskName)
  3502. }
  3503. // SetFromwxid sets the "fromwxid" field.
  3504. func (m *BatchMsgMutation) SetFromwxid(s string) {
  3505. m.fromwxid = &s
  3506. }
  3507. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  3508. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  3509. v := m.fromwxid
  3510. if v == nil {
  3511. return
  3512. }
  3513. return *v, true
  3514. }
  3515. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  3516. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3518. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  3519. if !m.op.Is(OpUpdateOne) {
  3520. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  3521. }
  3522. if m.id == nil || m.oldValue == nil {
  3523. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  3524. }
  3525. oldValue, err := m.oldValue(ctx)
  3526. if err != nil {
  3527. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  3528. }
  3529. return oldValue.Fromwxid, nil
  3530. }
  3531. // ClearFromwxid clears the value of the "fromwxid" field.
  3532. func (m *BatchMsgMutation) ClearFromwxid() {
  3533. m.fromwxid = nil
  3534. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  3535. }
  3536. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  3537. func (m *BatchMsgMutation) FromwxidCleared() bool {
  3538. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  3539. return ok
  3540. }
  3541. // ResetFromwxid resets all changes to the "fromwxid" field.
  3542. func (m *BatchMsgMutation) ResetFromwxid() {
  3543. m.fromwxid = nil
  3544. delete(m.clearedFields, batchmsg.FieldFromwxid)
  3545. }
  3546. // SetMsg sets the "msg" field.
  3547. func (m *BatchMsgMutation) SetMsg(s string) {
  3548. m.msg = &s
  3549. }
  3550. // Msg returns the value of the "msg" field in the mutation.
  3551. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  3552. v := m.msg
  3553. if v == nil {
  3554. return
  3555. }
  3556. return *v, true
  3557. }
  3558. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  3559. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3561. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  3562. if !m.op.Is(OpUpdateOne) {
  3563. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  3564. }
  3565. if m.id == nil || m.oldValue == nil {
  3566. return v, errors.New("OldMsg requires an ID field in the mutation")
  3567. }
  3568. oldValue, err := m.oldValue(ctx)
  3569. if err != nil {
  3570. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  3571. }
  3572. return oldValue.Msg, nil
  3573. }
  3574. // ClearMsg clears the value of the "msg" field.
  3575. func (m *BatchMsgMutation) ClearMsg() {
  3576. m.msg = nil
  3577. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  3578. }
  3579. // MsgCleared returns if the "msg" field was cleared in this mutation.
  3580. func (m *BatchMsgMutation) MsgCleared() bool {
  3581. _, ok := m.clearedFields[batchmsg.FieldMsg]
  3582. return ok
  3583. }
  3584. // ResetMsg resets all changes to the "msg" field.
  3585. func (m *BatchMsgMutation) ResetMsg() {
  3586. m.msg = nil
  3587. delete(m.clearedFields, batchmsg.FieldMsg)
  3588. }
  3589. // SetTag sets the "tag" field.
  3590. func (m *BatchMsgMutation) SetTag(s string) {
  3591. m.tag = &s
  3592. }
  3593. // Tag returns the value of the "tag" field in the mutation.
  3594. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  3595. v := m.tag
  3596. if v == nil {
  3597. return
  3598. }
  3599. return *v, true
  3600. }
  3601. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  3602. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3604. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  3605. if !m.op.Is(OpUpdateOne) {
  3606. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  3607. }
  3608. if m.id == nil || m.oldValue == nil {
  3609. return v, errors.New("OldTag requires an ID field in the mutation")
  3610. }
  3611. oldValue, err := m.oldValue(ctx)
  3612. if err != nil {
  3613. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  3614. }
  3615. return oldValue.Tag, nil
  3616. }
  3617. // ClearTag clears the value of the "tag" field.
  3618. func (m *BatchMsgMutation) ClearTag() {
  3619. m.tag = nil
  3620. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  3621. }
  3622. // TagCleared returns if the "tag" field was cleared in this mutation.
  3623. func (m *BatchMsgMutation) TagCleared() bool {
  3624. _, ok := m.clearedFields[batchmsg.FieldTag]
  3625. return ok
  3626. }
  3627. // ResetTag resets all changes to the "tag" field.
  3628. func (m *BatchMsgMutation) ResetTag() {
  3629. m.tag = nil
  3630. delete(m.clearedFields, batchmsg.FieldTag)
  3631. }
  3632. // SetTagids sets the "tagids" field.
  3633. func (m *BatchMsgMutation) SetTagids(s string) {
  3634. m.tagids = &s
  3635. }
  3636. // Tagids returns the value of the "tagids" field in the mutation.
  3637. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  3638. v := m.tagids
  3639. if v == nil {
  3640. return
  3641. }
  3642. return *v, true
  3643. }
  3644. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  3645. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3647. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  3648. if !m.op.Is(OpUpdateOne) {
  3649. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  3650. }
  3651. if m.id == nil || m.oldValue == nil {
  3652. return v, errors.New("OldTagids requires an ID field in the mutation")
  3653. }
  3654. oldValue, err := m.oldValue(ctx)
  3655. if err != nil {
  3656. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  3657. }
  3658. return oldValue.Tagids, nil
  3659. }
  3660. // ClearTagids clears the value of the "tagids" field.
  3661. func (m *BatchMsgMutation) ClearTagids() {
  3662. m.tagids = nil
  3663. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  3664. }
  3665. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  3666. func (m *BatchMsgMutation) TagidsCleared() bool {
  3667. _, ok := m.clearedFields[batchmsg.FieldTagids]
  3668. return ok
  3669. }
  3670. // ResetTagids resets all changes to the "tagids" field.
  3671. func (m *BatchMsgMutation) ResetTagids() {
  3672. m.tagids = nil
  3673. delete(m.clearedFields, batchmsg.FieldTagids)
  3674. }
  3675. // SetTotal sets the "total" field.
  3676. func (m *BatchMsgMutation) SetTotal(i int32) {
  3677. m.total = &i
  3678. m.addtotal = nil
  3679. }
  3680. // Total returns the value of the "total" field in the mutation.
  3681. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  3682. v := m.total
  3683. if v == nil {
  3684. return
  3685. }
  3686. return *v, true
  3687. }
  3688. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  3689. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3691. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  3692. if !m.op.Is(OpUpdateOne) {
  3693. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  3694. }
  3695. if m.id == nil || m.oldValue == nil {
  3696. return v, errors.New("OldTotal requires an ID field in the mutation")
  3697. }
  3698. oldValue, err := m.oldValue(ctx)
  3699. if err != nil {
  3700. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  3701. }
  3702. return oldValue.Total, nil
  3703. }
  3704. // AddTotal adds i to the "total" field.
  3705. func (m *BatchMsgMutation) AddTotal(i int32) {
  3706. if m.addtotal != nil {
  3707. *m.addtotal += i
  3708. } else {
  3709. m.addtotal = &i
  3710. }
  3711. }
  3712. // AddedTotal returns the value that was added to the "total" field in this mutation.
  3713. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  3714. v := m.addtotal
  3715. if v == nil {
  3716. return
  3717. }
  3718. return *v, true
  3719. }
  3720. // ClearTotal clears the value of the "total" field.
  3721. func (m *BatchMsgMutation) ClearTotal() {
  3722. m.total = nil
  3723. m.addtotal = nil
  3724. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  3725. }
  3726. // TotalCleared returns if the "total" field was cleared in this mutation.
  3727. func (m *BatchMsgMutation) TotalCleared() bool {
  3728. _, ok := m.clearedFields[batchmsg.FieldTotal]
  3729. return ok
  3730. }
  3731. // ResetTotal resets all changes to the "total" field.
  3732. func (m *BatchMsgMutation) ResetTotal() {
  3733. m.total = nil
  3734. m.addtotal = nil
  3735. delete(m.clearedFields, batchmsg.FieldTotal)
  3736. }
  3737. // SetSuccess sets the "success" field.
  3738. func (m *BatchMsgMutation) SetSuccess(i int32) {
  3739. m.success = &i
  3740. m.addsuccess = nil
  3741. }
  3742. // Success returns the value of the "success" field in the mutation.
  3743. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  3744. v := m.success
  3745. if v == nil {
  3746. return
  3747. }
  3748. return *v, true
  3749. }
  3750. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  3751. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3753. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  3754. if !m.op.Is(OpUpdateOne) {
  3755. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  3756. }
  3757. if m.id == nil || m.oldValue == nil {
  3758. return v, errors.New("OldSuccess requires an ID field in the mutation")
  3759. }
  3760. oldValue, err := m.oldValue(ctx)
  3761. if err != nil {
  3762. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  3763. }
  3764. return oldValue.Success, nil
  3765. }
  3766. // AddSuccess adds i to the "success" field.
  3767. func (m *BatchMsgMutation) AddSuccess(i int32) {
  3768. if m.addsuccess != nil {
  3769. *m.addsuccess += i
  3770. } else {
  3771. m.addsuccess = &i
  3772. }
  3773. }
  3774. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  3775. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  3776. v := m.addsuccess
  3777. if v == nil {
  3778. return
  3779. }
  3780. return *v, true
  3781. }
  3782. // ClearSuccess clears the value of the "success" field.
  3783. func (m *BatchMsgMutation) ClearSuccess() {
  3784. m.success = nil
  3785. m.addsuccess = nil
  3786. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  3787. }
  3788. // SuccessCleared returns if the "success" field was cleared in this mutation.
  3789. func (m *BatchMsgMutation) SuccessCleared() bool {
  3790. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  3791. return ok
  3792. }
  3793. // ResetSuccess resets all changes to the "success" field.
  3794. func (m *BatchMsgMutation) ResetSuccess() {
  3795. m.success = nil
  3796. m.addsuccess = nil
  3797. delete(m.clearedFields, batchmsg.FieldSuccess)
  3798. }
  3799. // SetFail sets the "fail" field.
  3800. func (m *BatchMsgMutation) SetFail(i int32) {
  3801. m.fail = &i
  3802. m.addfail = nil
  3803. }
  3804. // Fail returns the value of the "fail" field in the mutation.
  3805. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  3806. v := m.fail
  3807. if v == nil {
  3808. return
  3809. }
  3810. return *v, true
  3811. }
  3812. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  3813. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3815. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  3816. if !m.op.Is(OpUpdateOne) {
  3817. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  3818. }
  3819. if m.id == nil || m.oldValue == nil {
  3820. return v, errors.New("OldFail requires an ID field in the mutation")
  3821. }
  3822. oldValue, err := m.oldValue(ctx)
  3823. if err != nil {
  3824. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  3825. }
  3826. return oldValue.Fail, nil
  3827. }
  3828. // AddFail adds i to the "fail" field.
  3829. func (m *BatchMsgMutation) AddFail(i int32) {
  3830. if m.addfail != nil {
  3831. *m.addfail += i
  3832. } else {
  3833. m.addfail = &i
  3834. }
  3835. }
  3836. // AddedFail returns the value that was added to the "fail" field in this mutation.
  3837. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  3838. v := m.addfail
  3839. if v == nil {
  3840. return
  3841. }
  3842. return *v, true
  3843. }
  3844. // ClearFail clears the value of the "fail" field.
  3845. func (m *BatchMsgMutation) ClearFail() {
  3846. m.fail = nil
  3847. m.addfail = nil
  3848. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  3849. }
  3850. // FailCleared returns if the "fail" field was cleared in this mutation.
  3851. func (m *BatchMsgMutation) FailCleared() bool {
  3852. _, ok := m.clearedFields[batchmsg.FieldFail]
  3853. return ok
  3854. }
  3855. // ResetFail resets all changes to the "fail" field.
  3856. func (m *BatchMsgMutation) ResetFail() {
  3857. m.fail = nil
  3858. m.addfail = nil
  3859. delete(m.clearedFields, batchmsg.FieldFail)
  3860. }
  3861. // SetStartTime sets the "start_time" field.
  3862. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  3863. m.start_time = &t
  3864. }
  3865. // StartTime returns the value of the "start_time" field in the mutation.
  3866. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  3867. v := m.start_time
  3868. if v == nil {
  3869. return
  3870. }
  3871. return *v, true
  3872. }
  3873. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  3874. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3876. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  3877. if !m.op.Is(OpUpdateOne) {
  3878. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  3879. }
  3880. if m.id == nil || m.oldValue == nil {
  3881. return v, errors.New("OldStartTime requires an ID field in the mutation")
  3882. }
  3883. oldValue, err := m.oldValue(ctx)
  3884. if err != nil {
  3885. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  3886. }
  3887. return oldValue.StartTime, nil
  3888. }
  3889. // ClearStartTime clears the value of the "start_time" field.
  3890. func (m *BatchMsgMutation) ClearStartTime() {
  3891. m.start_time = nil
  3892. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  3893. }
  3894. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  3895. func (m *BatchMsgMutation) StartTimeCleared() bool {
  3896. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  3897. return ok
  3898. }
  3899. // ResetStartTime resets all changes to the "start_time" field.
  3900. func (m *BatchMsgMutation) ResetStartTime() {
  3901. m.start_time = nil
  3902. delete(m.clearedFields, batchmsg.FieldStartTime)
  3903. }
  3904. // SetStopTime sets the "stop_time" field.
  3905. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  3906. m.stop_time = &t
  3907. }
  3908. // StopTime returns the value of the "stop_time" field in the mutation.
  3909. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  3910. v := m.stop_time
  3911. if v == nil {
  3912. return
  3913. }
  3914. return *v, true
  3915. }
  3916. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  3917. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3919. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  3920. if !m.op.Is(OpUpdateOne) {
  3921. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  3922. }
  3923. if m.id == nil || m.oldValue == nil {
  3924. return v, errors.New("OldStopTime requires an ID field in the mutation")
  3925. }
  3926. oldValue, err := m.oldValue(ctx)
  3927. if err != nil {
  3928. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  3929. }
  3930. return oldValue.StopTime, nil
  3931. }
  3932. // ClearStopTime clears the value of the "stop_time" field.
  3933. func (m *BatchMsgMutation) ClearStopTime() {
  3934. m.stop_time = nil
  3935. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  3936. }
  3937. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  3938. func (m *BatchMsgMutation) StopTimeCleared() bool {
  3939. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  3940. return ok
  3941. }
  3942. // ResetStopTime resets all changes to the "stop_time" field.
  3943. func (m *BatchMsgMutation) ResetStopTime() {
  3944. m.stop_time = nil
  3945. delete(m.clearedFields, batchmsg.FieldStopTime)
  3946. }
  3947. // SetSendTime sets the "send_time" field.
  3948. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  3949. m.send_time = &t
  3950. }
  3951. // SendTime returns the value of the "send_time" field in the mutation.
  3952. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  3953. v := m.send_time
  3954. if v == nil {
  3955. return
  3956. }
  3957. return *v, true
  3958. }
  3959. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  3960. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3962. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  3963. if !m.op.Is(OpUpdateOne) {
  3964. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  3965. }
  3966. if m.id == nil || m.oldValue == nil {
  3967. return v, errors.New("OldSendTime requires an ID field in the mutation")
  3968. }
  3969. oldValue, err := m.oldValue(ctx)
  3970. if err != nil {
  3971. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  3972. }
  3973. return oldValue.SendTime, nil
  3974. }
  3975. // ClearSendTime clears the value of the "send_time" field.
  3976. func (m *BatchMsgMutation) ClearSendTime() {
  3977. m.send_time = nil
  3978. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  3979. }
  3980. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  3981. func (m *BatchMsgMutation) SendTimeCleared() bool {
  3982. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  3983. return ok
  3984. }
  3985. // ResetSendTime resets all changes to the "send_time" field.
  3986. func (m *BatchMsgMutation) ResetSendTime() {
  3987. m.send_time = nil
  3988. delete(m.clearedFields, batchmsg.FieldSendTime)
  3989. }
  3990. // SetType sets the "type" field.
  3991. func (m *BatchMsgMutation) SetType(i int32) {
  3992. m._type = &i
  3993. m.add_type = nil
  3994. }
  3995. // GetType returns the value of the "type" field in the mutation.
  3996. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  3997. v := m._type
  3998. if v == nil {
  3999. return
  4000. }
  4001. return *v, true
  4002. }
  4003. // OldType returns the old "type" field's value of the BatchMsg entity.
  4004. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4006. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4007. if !m.op.Is(OpUpdateOne) {
  4008. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4009. }
  4010. if m.id == nil || m.oldValue == nil {
  4011. return v, errors.New("OldType requires an ID field in the mutation")
  4012. }
  4013. oldValue, err := m.oldValue(ctx)
  4014. if err != nil {
  4015. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4016. }
  4017. return oldValue.Type, nil
  4018. }
  4019. // AddType adds i to the "type" field.
  4020. func (m *BatchMsgMutation) AddType(i int32) {
  4021. if m.add_type != nil {
  4022. *m.add_type += i
  4023. } else {
  4024. m.add_type = &i
  4025. }
  4026. }
  4027. // AddedType returns the value that was added to the "type" field in this mutation.
  4028. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4029. v := m.add_type
  4030. if v == nil {
  4031. return
  4032. }
  4033. return *v, true
  4034. }
  4035. // ClearType clears the value of the "type" field.
  4036. func (m *BatchMsgMutation) ClearType() {
  4037. m._type = nil
  4038. m.add_type = nil
  4039. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4040. }
  4041. // TypeCleared returns if the "type" field was cleared in this mutation.
  4042. func (m *BatchMsgMutation) TypeCleared() bool {
  4043. _, ok := m.clearedFields[batchmsg.FieldType]
  4044. return ok
  4045. }
  4046. // ResetType resets all changes to the "type" field.
  4047. func (m *BatchMsgMutation) ResetType() {
  4048. m._type = nil
  4049. m.add_type = nil
  4050. delete(m.clearedFields, batchmsg.FieldType)
  4051. }
  4052. // SetOrganizationID sets the "organization_id" field.
  4053. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4054. m.organization_id = &u
  4055. m.addorganization_id = nil
  4056. }
  4057. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4058. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4059. v := m.organization_id
  4060. if v == nil {
  4061. return
  4062. }
  4063. return *v, true
  4064. }
  4065. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4066. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4068. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4069. if !m.op.Is(OpUpdateOne) {
  4070. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4071. }
  4072. if m.id == nil || m.oldValue == nil {
  4073. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4074. }
  4075. oldValue, err := m.oldValue(ctx)
  4076. if err != nil {
  4077. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4078. }
  4079. return oldValue.OrganizationID, nil
  4080. }
  4081. // AddOrganizationID adds u to the "organization_id" field.
  4082. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4083. if m.addorganization_id != nil {
  4084. *m.addorganization_id += u
  4085. } else {
  4086. m.addorganization_id = &u
  4087. }
  4088. }
  4089. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4090. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4091. v := m.addorganization_id
  4092. if v == nil {
  4093. return
  4094. }
  4095. return *v, true
  4096. }
  4097. // ResetOrganizationID resets all changes to the "organization_id" field.
  4098. func (m *BatchMsgMutation) ResetOrganizationID() {
  4099. m.organization_id = nil
  4100. m.addorganization_id = nil
  4101. }
  4102. // Where appends a list predicates to the BatchMsgMutation builder.
  4103. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4104. m.predicates = append(m.predicates, ps...)
  4105. }
  4106. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4107. // users can use type-assertion to append predicates that do not depend on any generated package.
  4108. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4109. p := make([]predicate.BatchMsg, len(ps))
  4110. for i := range ps {
  4111. p[i] = ps[i]
  4112. }
  4113. m.Where(p...)
  4114. }
  4115. // Op returns the operation name.
  4116. func (m *BatchMsgMutation) Op() Op {
  4117. return m.op
  4118. }
  4119. // SetOp allows setting the mutation operation.
  4120. func (m *BatchMsgMutation) SetOp(op Op) {
  4121. m.op = op
  4122. }
  4123. // Type returns the node type of this mutation (BatchMsg).
  4124. func (m *BatchMsgMutation) Type() string {
  4125. return m.typ
  4126. }
  4127. // Fields returns all fields that were changed during this mutation. Note that in
  4128. // order to get all numeric fields that were incremented/decremented, call
  4129. // AddedFields().
  4130. func (m *BatchMsgMutation) Fields() []string {
  4131. fields := make([]string, 0, 18)
  4132. if m.created_at != nil {
  4133. fields = append(fields, batchmsg.FieldCreatedAt)
  4134. }
  4135. if m.updated_at != nil {
  4136. fields = append(fields, batchmsg.FieldUpdatedAt)
  4137. }
  4138. if m.deleted_at != nil {
  4139. fields = append(fields, batchmsg.FieldDeletedAt)
  4140. }
  4141. if m.status != nil {
  4142. fields = append(fields, batchmsg.FieldStatus)
  4143. }
  4144. if m.batch_no != nil {
  4145. fields = append(fields, batchmsg.FieldBatchNo)
  4146. }
  4147. if m.task_name != nil {
  4148. fields = append(fields, batchmsg.FieldTaskName)
  4149. }
  4150. if m.fromwxid != nil {
  4151. fields = append(fields, batchmsg.FieldFromwxid)
  4152. }
  4153. if m.msg != nil {
  4154. fields = append(fields, batchmsg.FieldMsg)
  4155. }
  4156. if m.tag != nil {
  4157. fields = append(fields, batchmsg.FieldTag)
  4158. }
  4159. if m.tagids != nil {
  4160. fields = append(fields, batchmsg.FieldTagids)
  4161. }
  4162. if m.total != nil {
  4163. fields = append(fields, batchmsg.FieldTotal)
  4164. }
  4165. if m.success != nil {
  4166. fields = append(fields, batchmsg.FieldSuccess)
  4167. }
  4168. if m.fail != nil {
  4169. fields = append(fields, batchmsg.FieldFail)
  4170. }
  4171. if m.start_time != nil {
  4172. fields = append(fields, batchmsg.FieldStartTime)
  4173. }
  4174. if m.stop_time != nil {
  4175. fields = append(fields, batchmsg.FieldStopTime)
  4176. }
  4177. if m.send_time != nil {
  4178. fields = append(fields, batchmsg.FieldSendTime)
  4179. }
  4180. if m._type != nil {
  4181. fields = append(fields, batchmsg.FieldType)
  4182. }
  4183. if m.organization_id != nil {
  4184. fields = append(fields, batchmsg.FieldOrganizationID)
  4185. }
  4186. return fields
  4187. }
  4188. // Field returns the value of a field with the given name. The second boolean
  4189. // return value indicates that this field was not set, or was not defined in the
  4190. // schema.
  4191. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4192. switch name {
  4193. case batchmsg.FieldCreatedAt:
  4194. return m.CreatedAt()
  4195. case batchmsg.FieldUpdatedAt:
  4196. return m.UpdatedAt()
  4197. case batchmsg.FieldDeletedAt:
  4198. return m.DeletedAt()
  4199. case batchmsg.FieldStatus:
  4200. return m.Status()
  4201. case batchmsg.FieldBatchNo:
  4202. return m.BatchNo()
  4203. case batchmsg.FieldTaskName:
  4204. return m.TaskName()
  4205. case batchmsg.FieldFromwxid:
  4206. return m.Fromwxid()
  4207. case batchmsg.FieldMsg:
  4208. return m.Msg()
  4209. case batchmsg.FieldTag:
  4210. return m.Tag()
  4211. case batchmsg.FieldTagids:
  4212. return m.Tagids()
  4213. case batchmsg.FieldTotal:
  4214. return m.Total()
  4215. case batchmsg.FieldSuccess:
  4216. return m.Success()
  4217. case batchmsg.FieldFail:
  4218. return m.Fail()
  4219. case batchmsg.FieldStartTime:
  4220. return m.StartTime()
  4221. case batchmsg.FieldStopTime:
  4222. return m.StopTime()
  4223. case batchmsg.FieldSendTime:
  4224. return m.SendTime()
  4225. case batchmsg.FieldType:
  4226. return m.GetType()
  4227. case batchmsg.FieldOrganizationID:
  4228. return m.OrganizationID()
  4229. }
  4230. return nil, false
  4231. }
  4232. // OldField returns the old value of the field from the database. An error is
  4233. // returned if the mutation operation is not UpdateOne, or the query to the
  4234. // database failed.
  4235. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4236. switch name {
  4237. case batchmsg.FieldCreatedAt:
  4238. return m.OldCreatedAt(ctx)
  4239. case batchmsg.FieldUpdatedAt:
  4240. return m.OldUpdatedAt(ctx)
  4241. case batchmsg.FieldDeletedAt:
  4242. return m.OldDeletedAt(ctx)
  4243. case batchmsg.FieldStatus:
  4244. return m.OldStatus(ctx)
  4245. case batchmsg.FieldBatchNo:
  4246. return m.OldBatchNo(ctx)
  4247. case batchmsg.FieldTaskName:
  4248. return m.OldTaskName(ctx)
  4249. case batchmsg.FieldFromwxid:
  4250. return m.OldFromwxid(ctx)
  4251. case batchmsg.FieldMsg:
  4252. return m.OldMsg(ctx)
  4253. case batchmsg.FieldTag:
  4254. return m.OldTag(ctx)
  4255. case batchmsg.FieldTagids:
  4256. return m.OldTagids(ctx)
  4257. case batchmsg.FieldTotal:
  4258. return m.OldTotal(ctx)
  4259. case batchmsg.FieldSuccess:
  4260. return m.OldSuccess(ctx)
  4261. case batchmsg.FieldFail:
  4262. return m.OldFail(ctx)
  4263. case batchmsg.FieldStartTime:
  4264. return m.OldStartTime(ctx)
  4265. case batchmsg.FieldStopTime:
  4266. return m.OldStopTime(ctx)
  4267. case batchmsg.FieldSendTime:
  4268. return m.OldSendTime(ctx)
  4269. case batchmsg.FieldType:
  4270. return m.OldType(ctx)
  4271. case batchmsg.FieldOrganizationID:
  4272. return m.OldOrganizationID(ctx)
  4273. }
  4274. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  4275. }
  4276. // SetField sets the value of a field with the given name. It returns an error if
  4277. // the field is not defined in the schema, or if the type mismatched the field
  4278. // type.
  4279. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  4280. switch name {
  4281. case batchmsg.FieldCreatedAt:
  4282. v, ok := value.(time.Time)
  4283. if !ok {
  4284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4285. }
  4286. m.SetCreatedAt(v)
  4287. return nil
  4288. case batchmsg.FieldUpdatedAt:
  4289. v, ok := value.(time.Time)
  4290. if !ok {
  4291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4292. }
  4293. m.SetUpdatedAt(v)
  4294. return nil
  4295. case batchmsg.FieldDeletedAt:
  4296. v, ok := value.(time.Time)
  4297. if !ok {
  4298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4299. }
  4300. m.SetDeletedAt(v)
  4301. return nil
  4302. case batchmsg.FieldStatus:
  4303. v, ok := value.(uint8)
  4304. if !ok {
  4305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4306. }
  4307. m.SetStatus(v)
  4308. return nil
  4309. case batchmsg.FieldBatchNo:
  4310. v, ok := value.(string)
  4311. if !ok {
  4312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4313. }
  4314. m.SetBatchNo(v)
  4315. return nil
  4316. case batchmsg.FieldTaskName:
  4317. v, ok := value.(string)
  4318. if !ok {
  4319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4320. }
  4321. m.SetTaskName(v)
  4322. return nil
  4323. case batchmsg.FieldFromwxid:
  4324. v, ok := value.(string)
  4325. if !ok {
  4326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4327. }
  4328. m.SetFromwxid(v)
  4329. return nil
  4330. case batchmsg.FieldMsg:
  4331. v, ok := value.(string)
  4332. if !ok {
  4333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4334. }
  4335. m.SetMsg(v)
  4336. return nil
  4337. case batchmsg.FieldTag:
  4338. v, ok := value.(string)
  4339. if !ok {
  4340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4341. }
  4342. m.SetTag(v)
  4343. return nil
  4344. case batchmsg.FieldTagids:
  4345. v, ok := value.(string)
  4346. if !ok {
  4347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4348. }
  4349. m.SetTagids(v)
  4350. return nil
  4351. case batchmsg.FieldTotal:
  4352. v, ok := value.(int32)
  4353. if !ok {
  4354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4355. }
  4356. m.SetTotal(v)
  4357. return nil
  4358. case batchmsg.FieldSuccess:
  4359. v, ok := value.(int32)
  4360. if !ok {
  4361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4362. }
  4363. m.SetSuccess(v)
  4364. return nil
  4365. case batchmsg.FieldFail:
  4366. v, ok := value.(int32)
  4367. if !ok {
  4368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4369. }
  4370. m.SetFail(v)
  4371. return nil
  4372. case batchmsg.FieldStartTime:
  4373. v, ok := value.(time.Time)
  4374. if !ok {
  4375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4376. }
  4377. m.SetStartTime(v)
  4378. return nil
  4379. case batchmsg.FieldStopTime:
  4380. v, ok := value.(time.Time)
  4381. if !ok {
  4382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4383. }
  4384. m.SetStopTime(v)
  4385. return nil
  4386. case batchmsg.FieldSendTime:
  4387. v, ok := value.(time.Time)
  4388. if !ok {
  4389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4390. }
  4391. m.SetSendTime(v)
  4392. return nil
  4393. case batchmsg.FieldType:
  4394. v, ok := value.(int32)
  4395. if !ok {
  4396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4397. }
  4398. m.SetType(v)
  4399. return nil
  4400. case batchmsg.FieldOrganizationID:
  4401. v, ok := value.(uint64)
  4402. if !ok {
  4403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4404. }
  4405. m.SetOrganizationID(v)
  4406. return nil
  4407. }
  4408. return fmt.Errorf("unknown BatchMsg field %s", name)
  4409. }
  4410. // AddedFields returns all numeric fields that were incremented/decremented during
  4411. // this mutation.
  4412. func (m *BatchMsgMutation) AddedFields() []string {
  4413. var fields []string
  4414. if m.addstatus != nil {
  4415. fields = append(fields, batchmsg.FieldStatus)
  4416. }
  4417. if m.addtotal != nil {
  4418. fields = append(fields, batchmsg.FieldTotal)
  4419. }
  4420. if m.addsuccess != nil {
  4421. fields = append(fields, batchmsg.FieldSuccess)
  4422. }
  4423. if m.addfail != nil {
  4424. fields = append(fields, batchmsg.FieldFail)
  4425. }
  4426. if m.add_type != nil {
  4427. fields = append(fields, batchmsg.FieldType)
  4428. }
  4429. if m.addorganization_id != nil {
  4430. fields = append(fields, batchmsg.FieldOrganizationID)
  4431. }
  4432. return fields
  4433. }
  4434. // AddedField returns the numeric value that was incremented/decremented on a field
  4435. // with the given name. The second boolean return value indicates that this field
  4436. // was not set, or was not defined in the schema.
  4437. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  4438. switch name {
  4439. case batchmsg.FieldStatus:
  4440. return m.AddedStatus()
  4441. case batchmsg.FieldTotal:
  4442. return m.AddedTotal()
  4443. case batchmsg.FieldSuccess:
  4444. return m.AddedSuccess()
  4445. case batchmsg.FieldFail:
  4446. return m.AddedFail()
  4447. case batchmsg.FieldType:
  4448. return m.AddedType()
  4449. case batchmsg.FieldOrganizationID:
  4450. return m.AddedOrganizationID()
  4451. }
  4452. return nil, false
  4453. }
  4454. // AddField adds the value to the field with the given name. It returns an error if
  4455. // the field is not defined in the schema, or if the type mismatched the field
  4456. // type.
  4457. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  4458. switch name {
  4459. case batchmsg.FieldStatus:
  4460. v, ok := value.(int8)
  4461. if !ok {
  4462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4463. }
  4464. m.AddStatus(v)
  4465. return nil
  4466. case batchmsg.FieldTotal:
  4467. v, ok := value.(int32)
  4468. if !ok {
  4469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4470. }
  4471. m.AddTotal(v)
  4472. return nil
  4473. case batchmsg.FieldSuccess:
  4474. v, ok := value.(int32)
  4475. if !ok {
  4476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4477. }
  4478. m.AddSuccess(v)
  4479. return nil
  4480. case batchmsg.FieldFail:
  4481. v, ok := value.(int32)
  4482. if !ok {
  4483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4484. }
  4485. m.AddFail(v)
  4486. return nil
  4487. case batchmsg.FieldType:
  4488. v, ok := value.(int32)
  4489. if !ok {
  4490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4491. }
  4492. m.AddType(v)
  4493. return nil
  4494. case batchmsg.FieldOrganizationID:
  4495. v, ok := value.(int64)
  4496. if !ok {
  4497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4498. }
  4499. m.AddOrganizationID(v)
  4500. return nil
  4501. }
  4502. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  4503. }
  4504. // ClearedFields returns all nullable fields that were cleared during this
  4505. // mutation.
  4506. func (m *BatchMsgMutation) ClearedFields() []string {
  4507. var fields []string
  4508. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  4509. fields = append(fields, batchmsg.FieldDeletedAt)
  4510. }
  4511. if m.FieldCleared(batchmsg.FieldStatus) {
  4512. fields = append(fields, batchmsg.FieldStatus)
  4513. }
  4514. if m.FieldCleared(batchmsg.FieldBatchNo) {
  4515. fields = append(fields, batchmsg.FieldBatchNo)
  4516. }
  4517. if m.FieldCleared(batchmsg.FieldTaskName) {
  4518. fields = append(fields, batchmsg.FieldTaskName)
  4519. }
  4520. if m.FieldCleared(batchmsg.FieldFromwxid) {
  4521. fields = append(fields, batchmsg.FieldFromwxid)
  4522. }
  4523. if m.FieldCleared(batchmsg.FieldMsg) {
  4524. fields = append(fields, batchmsg.FieldMsg)
  4525. }
  4526. if m.FieldCleared(batchmsg.FieldTag) {
  4527. fields = append(fields, batchmsg.FieldTag)
  4528. }
  4529. if m.FieldCleared(batchmsg.FieldTagids) {
  4530. fields = append(fields, batchmsg.FieldTagids)
  4531. }
  4532. if m.FieldCleared(batchmsg.FieldTotal) {
  4533. fields = append(fields, batchmsg.FieldTotal)
  4534. }
  4535. if m.FieldCleared(batchmsg.FieldSuccess) {
  4536. fields = append(fields, batchmsg.FieldSuccess)
  4537. }
  4538. if m.FieldCleared(batchmsg.FieldFail) {
  4539. fields = append(fields, batchmsg.FieldFail)
  4540. }
  4541. if m.FieldCleared(batchmsg.FieldStartTime) {
  4542. fields = append(fields, batchmsg.FieldStartTime)
  4543. }
  4544. if m.FieldCleared(batchmsg.FieldStopTime) {
  4545. fields = append(fields, batchmsg.FieldStopTime)
  4546. }
  4547. if m.FieldCleared(batchmsg.FieldSendTime) {
  4548. fields = append(fields, batchmsg.FieldSendTime)
  4549. }
  4550. if m.FieldCleared(batchmsg.FieldType) {
  4551. fields = append(fields, batchmsg.FieldType)
  4552. }
  4553. return fields
  4554. }
  4555. // FieldCleared returns a boolean indicating if a field with the given name was
  4556. // cleared in this mutation.
  4557. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  4558. _, ok := m.clearedFields[name]
  4559. return ok
  4560. }
  4561. // ClearField clears the value of the field with the given name. It returns an
  4562. // error if the field is not defined in the schema.
  4563. func (m *BatchMsgMutation) ClearField(name string) error {
  4564. switch name {
  4565. case batchmsg.FieldDeletedAt:
  4566. m.ClearDeletedAt()
  4567. return nil
  4568. case batchmsg.FieldStatus:
  4569. m.ClearStatus()
  4570. return nil
  4571. case batchmsg.FieldBatchNo:
  4572. m.ClearBatchNo()
  4573. return nil
  4574. case batchmsg.FieldTaskName:
  4575. m.ClearTaskName()
  4576. return nil
  4577. case batchmsg.FieldFromwxid:
  4578. m.ClearFromwxid()
  4579. return nil
  4580. case batchmsg.FieldMsg:
  4581. m.ClearMsg()
  4582. return nil
  4583. case batchmsg.FieldTag:
  4584. m.ClearTag()
  4585. return nil
  4586. case batchmsg.FieldTagids:
  4587. m.ClearTagids()
  4588. return nil
  4589. case batchmsg.FieldTotal:
  4590. m.ClearTotal()
  4591. return nil
  4592. case batchmsg.FieldSuccess:
  4593. m.ClearSuccess()
  4594. return nil
  4595. case batchmsg.FieldFail:
  4596. m.ClearFail()
  4597. return nil
  4598. case batchmsg.FieldStartTime:
  4599. m.ClearStartTime()
  4600. return nil
  4601. case batchmsg.FieldStopTime:
  4602. m.ClearStopTime()
  4603. return nil
  4604. case batchmsg.FieldSendTime:
  4605. m.ClearSendTime()
  4606. return nil
  4607. case batchmsg.FieldType:
  4608. m.ClearType()
  4609. return nil
  4610. }
  4611. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  4612. }
  4613. // ResetField resets all changes in the mutation for the field with the given name.
  4614. // It returns an error if the field is not defined in the schema.
  4615. func (m *BatchMsgMutation) ResetField(name string) error {
  4616. switch name {
  4617. case batchmsg.FieldCreatedAt:
  4618. m.ResetCreatedAt()
  4619. return nil
  4620. case batchmsg.FieldUpdatedAt:
  4621. m.ResetUpdatedAt()
  4622. return nil
  4623. case batchmsg.FieldDeletedAt:
  4624. m.ResetDeletedAt()
  4625. return nil
  4626. case batchmsg.FieldStatus:
  4627. m.ResetStatus()
  4628. return nil
  4629. case batchmsg.FieldBatchNo:
  4630. m.ResetBatchNo()
  4631. return nil
  4632. case batchmsg.FieldTaskName:
  4633. m.ResetTaskName()
  4634. return nil
  4635. case batchmsg.FieldFromwxid:
  4636. m.ResetFromwxid()
  4637. return nil
  4638. case batchmsg.FieldMsg:
  4639. m.ResetMsg()
  4640. return nil
  4641. case batchmsg.FieldTag:
  4642. m.ResetTag()
  4643. return nil
  4644. case batchmsg.FieldTagids:
  4645. m.ResetTagids()
  4646. return nil
  4647. case batchmsg.FieldTotal:
  4648. m.ResetTotal()
  4649. return nil
  4650. case batchmsg.FieldSuccess:
  4651. m.ResetSuccess()
  4652. return nil
  4653. case batchmsg.FieldFail:
  4654. m.ResetFail()
  4655. return nil
  4656. case batchmsg.FieldStartTime:
  4657. m.ResetStartTime()
  4658. return nil
  4659. case batchmsg.FieldStopTime:
  4660. m.ResetStopTime()
  4661. return nil
  4662. case batchmsg.FieldSendTime:
  4663. m.ResetSendTime()
  4664. return nil
  4665. case batchmsg.FieldType:
  4666. m.ResetType()
  4667. return nil
  4668. case batchmsg.FieldOrganizationID:
  4669. m.ResetOrganizationID()
  4670. return nil
  4671. }
  4672. return fmt.Errorf("unknown BatchMsg field %s", name)
  4673. }
  4674. // AddedEdges returns all edge names that were set/added in this mutation.
  4675. func (m *BatchMsgMutation) AddedEdges() []string {
  4676. edges := make([]string, 0, 0)
  4677. return edges
  4678. }
  4679. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4680. // name in this mutation.
  4681. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  4682. return nil
  4683. }
  4684. // RemovedEdges returns all edge names that were removed in this mutation.
  4685. func (m *BatchMsgMutation) RemovedEdges() []string {
  4686. edges := make([]string, 0, 0)
  4687. return edges
  4688. }
  4689. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4690. // the given name in this mutation.
  4691. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  4692. return nil
  4693. }
  4694. // ClearedEdges returns all edge names that were cleared in this mutation.
  4695. func (m *BatchMsgMutation) ClearedEdges() []string {
  4696. edges := make([]string, 0, 0)
  4697. return edges
  4698. }
  4699. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4700. // was cleared in this mutation.
  4701. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  4702. return false
  4703. }
  4704. // ClearEdge clears the value of the edge with the given name. It returns an error
  4705. // if that edge is not defined in the schema.
  4706. func (m *BatchMsgMutation) ClearEdge(name string) error {
  4707. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  4708. }
  4709. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4710. // It returns an error if the edge is not defined in the schema.
  4711. func (m *BatchMsgMutation) ResetEdge(name string) error {
  4712. return fmt.Errorf("unknown BatchMsg edge %s", name)
  4713. }
  4714. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  4715. type CategoryMutation struct {
  4716. config
  4717. op Op
  4718. typ string
  4719. id *uint64
  4720. created_at *time.Time
  4721. updated_at *time.Time
  4722. deleted_at *time.Time
  4723. name *string
  4724. organization_id *uint64
  4725. addorganization_id *int64
  4726. clearedFields map[string]struct{}
  4727. done bool
  4728. oldValue func(context.Context) (*Category, error)
  4729. predicates []predicate.Category
  4730. }
  4731. var _ ent.Mutation = (*CategoryMutation)(nil)
  4732. // categoryOption allows management of the mutation configuration using functional options.
  4733. type categoryOption func(*CategoryMutation)
  4734. // newCategoryMutation creates new mutation for the Category entity.
  4735. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  4736. m := &CategoryMutation{
  4737. config: c,
  4738. op: op,
  4739. typ: TypeCategory,
  4740. clearedFields: make(map[string]struct{}),
  4741. }
  4742. for _, opt := range opts {
  4743. opt(m)
  4744. }
  4745. return m
  4746. }
  4747. // withCategoryID sets the ID field of the mutation.
  4748. func withCategoryID(id uint64) categoryOption {
  4749. return func(m *CategoryMutation) {
  4750. var (
  4751. err error
  4752. once sync.Once
  4753. value *Category
  4754. )
  4755. m.oldValue = func(ctx context.Context) (*Category, error) {
  4756. once.Do(func() {
  4757. if m.done {
  4758. err = errors.New("querying old values post mutation is not allowed")
  4759. } else {
  4760. value, err = m.Client().Category.Get(ctx, id)
  4761. }
  4762. })
  4763. return value, err
  4764. }
  4765. m.id = &id
  4766. }
  4767. }
  4768. // withCategory sets the old Category of the mutation.
  4769. func withCategory(node *Category) categoryOption {
  4770. return func(m *CategoryMutation) {
  4771. m.oldValue = func(context.Context) (*Category, error) {
  4772. return node, nil
  4773. }
  4774. m.id = &node.ID
  4775. }
  4776. }
  4777. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4778. // executed in a transaction (ent.Tx), a transactional client is returned.
  4779. func (m CategoryMutation) Client() *Client {
  4780. client := &Client{config: m.config}
  4781. client.init()
  4782. return client
  4783. }
  4784. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4785. // it returns an error otherwise.
  4786. func (m CategoryMutation) Tx() (*Tx, error) {
  4787. if _, ok := m.driver.(*txDriver); !ok {
  4788. return nil, errors.New("ent: mutation is not running in a transaction")
  4789. }
  4790. tx := &Tx{config: m.config}
  4791. tx.init()
  4792. return tx, nil
  4793. }
  4794. // SetID sets the value of the id field. Note that this
  4795. // operation is only accepted on creation of Category entities.
  4796. func (m *CategoryMutation) SetID(id uint64) {
  4797. m.id = &id
  4798. }
  4799. // ID returns the ID value in the mutation. Note that the ID is only available
  4800. // if it was provided to the builder or after it was returned from the database.
  4801. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  4802. if m.id == nil {
  4803. return
  4804. }
  4805. return *m.id, true
  4806. }
  4807. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4808. // That means, if the mutation is applied within a transaction with an isolation level such
  4809. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4810. // or updated by the mutation.
  4811. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  4812. switch {
  4813. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4814. id, exists := m.ID()
  4815. if exists {
  4816. return []uint64{id}, nil
  4817. }
  4818. fallthrough
  4819. case m.op.Is(OpUpdate | OpDelete):
  4820. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  4821. default:
  4822. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4823. }
  4824. }
  4825. // SetCreatedAt sets the "created_at" field.
  4826. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  4827. m.created_at = &t
  4828. }
  4829. // CreatedAt returns the value of the "created_at" field in the mutation.
  4830. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  4831. v := m.created_at
  4832. if v == nil {
  4833. return
  4834. }
  4835. return *v, true
  4836. }
  4837. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  4838. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4840. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4841. if !m.op.Is(OpUpdateOne) {
  4842. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4843. }
  4844. if m.id == nil || m.oldValue == nil {
  4845. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4846. }
  4847. oldValue, err := m.oldValue(ctx)
  4848. if err != nil {
  4849. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4850. }
  4851. return oldValue.CreatedAt, nil
  4852. }
  4853. // ResetCreatedAt resets all changes to the "created_at" field.
  4854. func (m *CategoryMutation) ResetCreatedAt() {
  4855. m.created_at = nil
  4856. }
  4857. // SetUpdatedAt sets the "updated_at" field.
  4858. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  4859. m.updated_at = &t
  4860. }
  4861. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4862. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  4863. v := m.updated_at
  4864. if v == nil {
  4865. return
  4866. }
  4867. return *v, true
  4868. }
  4869. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  4870. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4872. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4873. if !m.op.Is(OpUpdateOne) {
  4874. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4875. }
  4876. if m.id == nil || m.oldValue == nil {
  4877. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4878. }
  4879. oldValue, err := m.oldValue(ctx)
  4880. if err != nil {
  4881. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4882. }
  4883. return oldValue.UpdatedAt, nil
  4884. }
  4885. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4886. func (m *CategoryMutation) ResetUpdatedAt() {
  4887. m.updated_at = nil
  4888. }
  4889. // SetDeletedAt sets the "deleted_at" field.
  4890. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  4891. m.deleted_at = &t
  4892. }
  4893. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4894. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  4895. v := m.deleted_at
  4896. if v == nil {
  4897. return
  4898. }
  4899. return *v, true
  4900. }
  4901. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  4902. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4904. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4905. if !m.op.Is(OpUpdateOne) {
  4906. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4907. }
  4908. if m.id == nil || m.oldValue == nil {
  4909. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4910. }
  4911. oldValue, err := m.oldValue(ctx)
  4912. if err != nil {
  4913. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4914. }
  4915. return oldValue.DeletedAt, nil
  4916. }
  4917. // ClearDeletedAt clears the value of the "deleted_at" field.
  4918. func (m *CategoryMutation) ClearDeletedAt() {
  4919. m.deleted_at = nil
  4920. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  4921. }
  4922. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4923. func (m *CategoryMutation) DeletedAtCleared() bool {
  4924. _, ok := m.clearedFields[category.FieldDeletedAt]
  4925. return ok
  4926. }
  4927. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4928. func (m *CategoryMutation) ResetDeletedAt() {
  4929. m.deleted_at = nil
  4930. delete(m.clearedFields, category.FieldDeletedAt)
  4931. }
  4932. // SetName sets the "name" field.
  4933. func (m *CategoryMutation) SetName(s string) {
  4934. m.name = &s
  4935. }
  4936. // Name returns the value of the "name" field in the mutation.
  4937. func (m *CategoryMutation) Name() (r string, exists bool) {
  4938. v := m.name
  4939. if v == nil {
  4940. return
  4941. }
  4942. return *v, true
  4943. }
  4944. // OldName returns the old "name" field's value of the Category entity.
  4945. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4947. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  4948. if !m.op.Is(OpUpdateOne) {
  4949. return v, errors.New("OldName is only allowed on UpdateOne operations")
  4950. }
  4951. if m.id == nil || m.oldValue == nil {
  4952. return v, errors.New("OldName requires an ID field in the mutation")
  4953. }
  4954. oldValue, err := m.oldValue(ctx)
  4955. if err != nil {
  4956. return v, fmt.Errorf("querying old value for OldName: %w", err)
  4957. }
  4958. return oldValue.Name, nil
  4959. }
  4960. // ResetName resets all changes to the "name" field.
  4961. func (m *CategoryMutation) ResetName() {
  4962. m.name = nil
  4963. }
  4964. // SetOrganizationID sets the "organization_id" field.
  4965. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  4966. m.organization_id = &u
  4967. m.addorganization_id = nil
  4968. }
  4969. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4970. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  4971. v := m.organization_id
  4972. if v == nil {
  4973. return
  4974. }
  4975. return *v, true
  4976. }
  4977. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  4978. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4980. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4981. if !m.op.Is(OpUpdateOne) {
  4982. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4983. }
  4984. if m.id == nil || m.oldValue == nil {
  4985. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4986. }
  4987. oldValue, err := m.oldValue(ctx)
  4988. if err != nil {
  4989. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4990. }
  4991. return oldValue.OrganizationID, nil
  4992. }
  4993. // AddOrganizationID adds u to the "organization_id" field.
  4994. func (m *CategoryMutation) AddOrganizationID(u int64) {
  4995. if m.addorganization_id != nil {
  4996. *m.addorganization_id += u
  4997. } else {
  4998. m.addorganization_id = &u
  4999. }
  5000. }
  5001. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5002. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5003. v := m.addorganization_id
  5004. if v == nil {
  5005. return
  5006. }
  5007. return *v, true
  5008. }
  5009. // ResetOrganizationID resets all changes to the "organization_id" field.
  5010. func (m *CategoryMutation) ResetOrganizationID() {
  5011. m.organization_id = nil
  5012. m.addorganization_id = nil
  5013. }
  5014. // Where appends a list predicates to the CategoryMutation builder.
  5015. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5016. m.predicates = append(m.predicates, ps...)
  5017. }
  5018. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5019. // users can use type-assertion to append predicates that do not depend on any generated package.
  5020. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5021. p := make([]predicate.Category, len(ps))
  5022. for i := range ps {
  5023. p[i] = ps[i]
  5024. }
  5025. m.Where(p...)
  5026. }
  5027. // Op returns the operation name.
  5028. func (m *CategoryMutation) Op() Op {
  5029. return m.op
  5030. }
  5031. // SetOp allows setting the mutation operation.
  5032. func (m *CategoryMutation) SetOp(op Op) {
  5033. m.op = op
  5034. }
  5035. // Type returns the node type of this mutation (Category).
  5036. func (m *CategoryMutation) Type() string {
  5037. return m.typ
  5038. }
  5039. // Fields returns all fields that were changed during this mutation. Note that in
  5040. // order to get all numeric fields that were incremented/decremented, call
  5041. // AddedFields().
  5042. func (m *CategoryMutation) Fields() []string {
  5043. fields := make([]string, 0, 5)
  5044. if m.created_at != nil {
  5045. fields = append(fields, category.FieldCreatedAt)
  5046. }
  5047. if m.updated_at != nil {
  5048. fields = append(fields, category.FieldUpdatedAt)
  5049. }
  5050. if m.deleted_at != nil {
  5051. fields = append(fields, category.FieldDeletedAt)
  5052. }
  5053. if m.name != nil {
  5054. fields = append(fields, category.FieldName)
  5055. }
  5056. if m.organization_id != nil {
  5057. fields = append(fields, category.FieldOrganizationID)
  5058. }
  5059. return fields
  5060. }
  5061. // Field returns the value of a field with the given name. The second boolean
  5062. // return value indicates that this field was not set, or was not defined in the
  5063. // schema.
  5064. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5065. switch name {
  5066. case category.FieldCreatedAt:
  5067. return m.CreatedAt()
  5068. case category.FieldUpdatedAt:
  5069. return m.UpdatedAt()
  5070. case category.FieldDeletedAt:
  5071. return m.DeletedAt()
  5072. case category.FieldName:
  5073. return m.Name()
  5074. case category.FieldOrganizationID:
  5075. return m.OrganizationID()
  5076. }
  5077. return nil, false
  5078. }
  5079. // OldField returns the old value of the field from the database. An error is
  5080. // returned if the mutation operation is not UpdateOne, or the query to the
  5081. // database failed.
  5082. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5083. switch name {
  5084. case category.FieldCreatedAt:
  5085. return m.OldCreatedAt(ctx)
  5086. case category.FieldUpdatedAt:
  5087. return m.OldUpdatedAt(ctx)
  5088. case category.FieldDeletedAt:
  5089. return m.OldDeletedAt(ctx)
  5090. case category.FieldName:
  5091. return m.OldName(ctx)
  5092. case category.FieldOrganizationID:
  5093. return m.OldOrganizationID(ctx)
  5094. }
  5095. return nil, fmt.Errorf("unknown Category field %s", name)
  5096. }
  5097. // SetField sets the value of a field with the given name. It returns an error if
  5098. // the field is not defined in the schema, or if the type mismatched the field
  5099. // type.
  5100. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5101. switch name {
  5102. case category.FieldCreatedAt:
  5103. v, ok := value.(time.Time)
  5104. if !ok {
  5105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5106. }
  5107. m.SetCreatedAt(v)
  5108. return nil
  5109. case category.FieldUpdatedAt:
  5110. v, ok := value.(time.Time)
  5111. if !ok {
  5112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5113. }
  5114. m.SetUpdatedAt(v)
  5115. return nil
  5116. case category.FieldDeletedAt:
  5117. v, ok := value.(time.Time)
  5118. if !ok {
  5119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5120. }
  5121. m.SetDeletedAt(v)
  5122. return nil
  5123. case category.FieldName:
  5124. v, ok := value.(string)
  5125. if !ok {
  5126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5127. }
  5128. m.SetName(v)
  5129. return nil
  5130. case category.FieldOrganizationID:
  5131. v, ok := value.(uint64)
  5132. if !ok {
  5133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5134. }
  5135. m.SetOrganizationID(v)
  5136. return nil
  5137. }
  5138. return fmt.Errorf("unknown Category field %s", name)
  5139. }
  5140. // AddedFields returns all numeric fields that were incremented/decremented during
  5141. // this mutation.
  5142. func (m *CategoryMutation) AddedFields() []string {
  5143. var fields []string
  5144. if m.addorganization_id != nil {
  5145. fields = append(fields, category.FieldOrganizationID)
  5146. }
  5147. return fields
  5148. }
  5149. // AddedField returns the numeric value that was incremented/decremented on a field
  5150. // with the given name. The second boolean return value indicates that this field
  5151. // was not set, or was not defined in the schema.
  5152. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5153. switch name {
  5154. case category.FieldOrganizationID:
  5155. return m.AddedOrganizationID()
  5156. }
  5157. return nil, false
  5158. }
  5159. // AddField adds the value to the field with the given name. It returns an error if
  5160. // the field is not defined in the schema, or if the type mismatched the field
  5161. // type.
  5162. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5163. switch name {
  5164. case category.FieldOrganizationID:
  5165. v, ok := value.(int64)
  5166. if !ok {
  5167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5168. }
  5169. m.AddOrganizationID(v)
  5170. return nil
  5171. }
  5172. return fmt.Errorf("unknown Category numeric field %s", name)
  5173. }
  5174. // ClearedFields returns all nullable fields that were cleared during this
  5175. // mutation.
  5176. func (m *CategoryMutation) ClearedFields() []string {
  5177. var fields []string
  5178. if m.FieldCleared(category.FieldDeletedAt) {
  5179. fields = append(fields, category.FieldDeletedAt)
  5180. }
  5181. return fields
  5182. }
  5183. // FieldCleared returns a boolean indicating if a field with the given name was
  5184. // cleared in this mutation.
  5185. func (m *CategoryMutation) FieldCleared(name string) bool {
  5186. _, ok := m.clearedFields[name]
  5187. return ok
  5188. }
  5189. // ClearField clears the value of the field with the given name. It returns an
  5190. // error if the field is not defined in the schema.
  5191. func (m *CategoryMutation) ClearField(name string) error {
  5192. switch name {
  5193. case category.FieldDeletedAt:
  5194. m.ClearDeletedAt()
  5195. return nil
  5196. }
  5197. return fmt.Errorf("unknown Category nullable field %s", name)
  5198. }
  5199. // ResetField resets all changes in the mutation for the field with the given name.
  5200. // It returns an error if the field is not defined in the schema.
  5201. func (m *CategoryMutation) ResetField(name string) error {
  5202. switch name {
  5203. case category.FieldCreatedAt:
  5204. m.ResetCreatedAt()
  5205. return nil
  5206. case category.FieldUpdatedAt:
  5207. m.ResetUpdatedAt()
  5208. return nil
  5209. case category.FieldDeletedAt:
  5210. m.ResetDeletedAt()
  5211. return nil
  5212. case category.FieldName:
  5213. m.ResetName()
  5214. return nil
  5215. case category.FieldOrganizationID:
  5216. m.ResetOrganizationID()
  5217. return nil
  5218. }
  5219. return fmt.Errorf("unknown Category field %s", name)
  5220. }
  5221. // AddedEdges returns all edge names that were set/added in this mutation.
  5222. func (m *CategoryMutation) AddedEdges() []string {
  5223. edges := make([]string, 0, 0)
  5224. return edges
  5225. }
  5226. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5227. // name in this mutation.
  5228. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5229. return nil
  5230. }
  5231. // RemovedEdges returns all edge names that were removed in this mutation.
  5232. func (m *CategoryMutation) RemovedEdges() []string {
  5233. edges := make([]string, 0, 0)
  5234. return edges
  5235. }
  5236. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5237. // the given name in this mutation.
  5238. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  5239. return nil
  5240. }
  5241. // ClearedEdges returns all edge names that were cleared in this mutation.
  5242. func (m *CategoryMutation) ClearedEdges() []string {
  5243. edges := make([]string, 0, 0)
  5244. return edges
  5245. }
  5246. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5247. // was cleared in this mutation.
  5248. func (m *CategoryMutation) EdgeCleared(name string) bool {
  5249. return false
  5250. }
  5251. // ClearEdge clears the value of the edge with the given name. It returns an error
  5252. // if that edge is not defined in the schema.
  5253. func (m *CategoryMutation) ClearEdge(name string) error {
  5254. return fmt.Errorf("unknown Category unique edge %s", name)
  5255. }
  5256. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5257. // It returns an error if the edge is not defined in the schema.
  5258. func (m *CategoryMutation) ResetEdge(name string) error {
  5259. return fmt.Errorf("unknown Category edge %s", name)
  5260. }
  5261. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  5262. type ChatRecordsMutation struct {
  5263. config
  5264. op Op
  5265. typ string
  5266. id *uint64
  5267. created_at *time.Time
  5268. updated_at *time.Time
  5269. deleted_at *time.Time
  5270. content *string
  5271. content_type *uint8
  5272. addcontent_type *int8
  5273. session_id *uint64
  5274. addsession_id *int64
  5275. user_id *uint64
  5276. adduser_id *int64
  5277. bot_id *uint64
  5278. addbot_id *int64
  5279. bot_type *uint8
  5280. addbot_type *int8
  5281. clearedFields map[string]struct{}
  5282. done bool
  5283. oldValue func(context.Context) (*ChatRecords, error)
  5284. predicates []predicate.ChatRecords
  5285. }
  5286. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  5287. // chatrecordsOption allows management of the mutation configuration using functional options.
  5288. type chatrecordsOption func(*ChatRecordsMutation)
  5289. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  5290. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  5291. m := &ChatRecordsMutation{
  5292. config: c,
  5293. op: op,
  5294. typ: TypeChatRecords,
  5295. clearedFields: make(map[string]struct{}),
  5296. }
  5297. for _, opt := range opts {
  5298. opt(m)
  5299. }
  5300. return m
  5301. }
  5302. // withChatRecordsID sets the ID field of the mutation.
  5303. func withChatRecordsID(id uint64) chatrecordsOption {
  5304. return func(m *ChatRecordsMutation) {
  5305. var (
  5306. err error
  5307. once sync.Once
  5308. value *ChatRecords
  5309. )
  5310. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  5311. once.Do(func() {
  5312. if m.done {
  5313. err = errors.New("querying old values post mutation is not allowed")
  5314. } else {
  5315. value, err = m.Client().ChatRecords.Get(ctx, id)
  5316. }
  5317. })
  5318. return value, err
  5319. }
  5320. m.id = &id
  5321. }
  5322. }
  5323. // withChatRecords sets the old ChatRecords of the mutation.
  5324. func withChatRecords(node *ChatRecords) chatrecordsOption {
  5325. return func(m *ChatRecordsMutation) {
  5326. m.oldValue = func(context.Context) (*ChatRecords, error) {
  5327. return node, nil
  5328. }
  5329. m.id = &node.ID
  5330. }
  5331. }
  5332. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5333. // executed in a transaction (ent.Tx), a transactional client is returned.
  5334. func (m ChatRecordsMutation) Client() *Client {
  5335. client := &Client{config: m.config}
  5336. client.init()
  5337. return client
  5338. }
  5339. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5340. // it returns an error otherwise.
  5341. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  5342. if _, ok := m.driver.(*txDriver); !ok {
  5343. return nil, errors.New("ent: mutation is not running in a transaction")
  5344. }
  5345. tx := &Tx{config: m.config}
  5346. tx.init()
  5347. return tx, nil
  5348. }
  5349. // SetID sets the value of the id field. Note that this
  5350. // operation is only accepted on creation of ChatRecords entities.
  5351. func (m *ChatRecordsMutation) SetID(id uint64) {
  5352. m.id = &id
  5353. }
  5354. // ID returns the ID value in the mutation. Note that the ID is only available
  5355. // if it was provided to the builder or after it was returned from the database.
  5356. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  5357. if m.id == nil {
  5358. return
  5359. }
  5360. return *m.id, true
  5361. }
  5362. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5363. // That means, if the mutation is applied within a transaction with an isolation level such
  5364. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5365. // or updated by the mutation.
  5366. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  5367. switch {
  5368. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5369. id, exists := m.ID()
  5370. if exists {
  5371. return []uint64{id}, nil
  5372. }
  5373. fallthrough
  5374. case m.op.Is(OpUpdate | OpDelete):
  5375. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  5376. default:
  5377. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5378. }
  5379. }
  5380. // SetCreatedAt sets the "created_at" field.
  5381. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  5382. m.created_at = &t
  5383. }
  5384. // CreatedAt returns the value of the "created_at" field in the mutation.
  5385. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  5386. v := m.created_at
  5387. if v == nil {
  5388. return
  5389. }
  5390. return *v, true
  5391. }
  5392. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  5393. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5395. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5396. if !m.op.Is(OpUpdateOne) {
  5397. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5398. }
  5399. if m.id == nil || m.oldValue == nil {
  5400. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5401. }
  5402. oldValue, err := m.oldValue(ctx)
  5403. if err != nil {
  5404. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5405. }
  5406. return oldValue.CreatedAt, nil
  5407. }
  5408. // ResetCreatedAt resets all changes to the "created_at" field.
  5409. func (m *ChatRecordsMutation) ResetCreatedAt() {
  5410. m.created_at = nil
  5411. }
  5412. // SetUpdatedAt sets the "updated_at" field.
  5413. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  5414. m.updated_at = &t
  5415. }
  5416. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5417. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  5418. v := m.updated_at
  5419. if v == nil {
  5420. return
  5421. }
  5422. return *v, true
  5423. }
  5424. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  5425. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5427. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5428. if !m.op.Is(OpUpdateOne) {
  5429. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5430. }
  5431. if m.id == nil || m.oldValue == nil {
  5432. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5433. }
  5434. oldValue, err := m.oldValue(ctx)
  5435. if err != nil {
  5436. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5437. }
  5438. return oldValue.UpdatedAt, nil
  5439. }
  5440. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5441. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  5442. m.updated_at = nil
  5443. }
  5444. // SetDeletedAt sets the "deleted_at" field.
  5445. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  5446. m.deleted_at = &t
  5447. }
  5448. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5449. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  5450. v := m.deleted_at
  5451. if v == nil {
  5452. return
  5453. }
  5454. return *v, true
  5455. }
  5456. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  5457. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5459. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5460. if !m.op.Is(OpUpdateOne) {
  5461. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5462. }
  5463. if m.id == nil || m.oldValue == nil {
  5464. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5465. }
  5466. oldValue, err := m.oldValue(ctx)
  5467. if err != nil {
  5468. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5469. }
  5470. return oldValue.DeletedAt, nil
  5471. }
  5472. // ClearDeletedAt clears the value of the "deleted_at" field.
  5473. func (m *ChatRecordsMutation) ClearDeletedAt() {
  5474. m.deleted_at = nil
  5475. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  5476. }
  5477. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5478. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  5479. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  5480. return ok
  5481. }
  5482. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5483. func (m *ChatRecordsMutation) ResetDeletedAt() {
  5484. m.deleted_at = nil
  5485. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  5486. }
  5487. // SetContent sets the "content" field.
  5488. func (m *ChatRecordsMutation) SetContent(s string) {
  5489. m.content = &s
  5490. }
  5491. // Content returns the value of the "content" field in the mutation.
  5492. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  5493. v := m.content
  5494. if v == nil {
  5495. return
  5496. }
  5497. return *v, true
  5498. }
  5499. // OldContent returns the old "content" field's value of the ChatRecords entity.
  5500. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5502. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  5503. if !m.op.Is(OpUpdateOne) {
  5504. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  5505. }
  5506. if m.id == nil || m.oldValue == nil {
  5507. return v, errors.New("OldContent requires an ID field in the mutation")
  5508. }
  5509. oldValue, err := m.oldValue(ctx)
  5510. if err != nil {
  5511. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  5512. }
  5513. return oldValue.Content, nil
  5514. }
  5515. // ResetContent resets all changes to the "content" field.
  5516. func (m *ChatRecordsMutation) ResetContent() {
  5517. m.content = nil
  5518. }
  5519. // SetContentType sets the "content_type" field.
  5520. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  5521. m.content_type = &u
  5522. m.addcontent_type = nil
  5523. }
  5524. // ContentType returns the value of the "content_type" field in the mutation.
  5525. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  5526. v := m.content_type
  5527. if v == nil {
  5528. return
  5529. }
  5530. return *v, true
  5531. }
  5532. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  5533. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5535. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  5536. if !m.op.Is(OpUpdateOne) {
  5537. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  5538. }
  5539. if m.id == nil || m.oldValue == nil {
  5540. return v, errors.New("OldContentType requires an ID field in the mutation")
  5541. }
  5542. oldValue, err := m.oldValue(ctx)
  5543. if err != nil {
  5544. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  5545. }
  5546. return oldValue.ContentType, nil
  5547. }
  5548. // AddContentType adds u to the "content_type" field.
  5549. func (m *ChatRecordsMutation) AddContentType(u int8) {
  5550. if m.addcontent_type != nil {
  5551. *m.addcontent_type += u
  5552. } else {
  5553. m.addcontent_type = &u
  5554. }
  5555. }
  5556. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  5557. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  5558. v := m.addcontent_type
  5559. if v == nil {
  5560. return
  5561. }
  5562. return *v, true
  5563. }
  5564. // ResetContentType resets all changes to the "content_type" field.
  5565. func (m *ChatRecordsMutation) ResetContentType() {
  5566. m.content_type = nil
  5567. m.addcontent_type = nil
  5568. }
  5569. // SetSessionID sets the "session_id" field.
  5570. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  5571. m.session_id = &u
  5572. m.addsession_id = nil
  5573. }
  5574. // SessionID returns the value of the "session_id" field in the mutation.
  5575. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  5576. v := m.session_id
  5577. if v == nil {
  5578. return
  5579. }
  5580. return *v, true
  5581. }
  5582. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  5583. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5585. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  5586. if !m.op.Is(OpUpdateOne) {
  5587. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  5588. }
  5589. if m.id == nil || m.oldValue == nil {
  5590. return v, errors.New("OldSessionID requires an ID field in the mutation")
  5591. }
  5592. oldValue, err := m.oldValue(ctx)
  5593. if err != nil {
  5594. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  5595. }
  5596. return oldValue.SessionID, nil
  5597. }
  5598. // AddSessionID adds u to the "session_id" field.
  5599. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  5600. if m.addsession_id != nil {
  5601. *m.addsession_id += u
  5602. } else {
  5603. m.addsession_id = &u
  5604. }
  5605. }
  5606. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  5607. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  5608. v := m.addsession_id
  5609. if v == nil {
  5610. return
  5611. }
  5612. return *v, true
  5613. }
  5614. // ResetSessionID resets all changes to the "session_id" field.
  5615. func (m *ChatRecordsMutation) ResetSessionID() {
  5616. m.session_id = nil
  5617. m.addsession_id = nil
  5618. }
  5619. // SetUserID sets the "user_id" field.
  5620. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  5621. m.user_id = &u
  5622. m.adduser_id = nil
  5623. }
  5624. // UserID returns the value of the "user_id" field in the mutation.
  5625. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  5626. v := m.user_id
  5627. if v == nil {
  5628. return
  5629. }
  5630. return *v, true
  5631. }
  5632. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  5633. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5635. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  5636. if !m.op.Is(OpUpdateOne) {
  5637. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  5638. }
  5639. if m.id == nil || m.oldValue == nil {
  5640. return v, errors.New("OldUserID requires an ID field in the mutation")
  5641. }
  5642. oldValue, err := m.oldValue(ctx)
  5643. if err != nil {
  5644. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  5645. }
  5646. return oldValue.UserID, nil
  5647. }
  5648. // AddUserID adds u to the "user_id" field.
  5649. func (m *ChatRecordsMutation) AddUserID(u int64) {
  5650. if m.adduser_id != nil {
  5651. *m.adduser_id += u
  5652. } else {
  5653. m.adduser_id = &u
  5654. }
  5655. }
  5656. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  5657. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  5658. v := m.adduser_id
  5659. if v == nil {
  5660. return
  5661. }
  5662. return *v, true
  5663. }
  5664. // ResetUserID resets all changes to the "user_id" field.
  5665. func (m *ChatRecordsMutation) ResetUserID() {
  5666. m.user_id = nil
  5667. m.adduser_id = nil
  5668. }
  5669. // SetBotID sets the "bot_id" field.
  5670. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  5671. m.bot_id = &u
  5672. m.addbot_id = nil
  5673. }
  5674. // BotID returns the value of the "bot_id" field in the mutation.
  5675. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  5676. v := m.bot_id
  5677. if v == nil {
  5678. return
  5679. }
  5680. return *v, true
  5681. }
  5682. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  5683. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5685. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  5686. if !m.op.Is(OpUpdateOne) {
  5687. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  5688. }
  5689. if m.id == nil || m.oldValue == nil {
  5690. return v, errors.New("OldBotID requires an ID field in the mutation")
  5691. }
  5692. oldValue, err := m.oldValue(ctx)
  5693. if err != nil {
  5694. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  5695. }
  5696. return oldValue.BotID, nil
  5697. }
  5698. // AddBotID adds u to the "bot_id" field.
  5699. func (m *ChatRecordsMutation) AddBotID(u int64) {
  5700. if m.addbot_id != nil {
  5701. *m.addbot_id += u
  5702. } else {
  5703. m.addbot_id = &u
  5704. }
  5705. }
  5706. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  5707. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  5708. v := m.addbot_id
  5709. if v == nil {
  5710. return
  5711. }
  5712. return *v, true
  5713. }
  5714. // ResetBotID resets all changes to the "bot_id" field.
  5715. func (m *ChatRecordsMutation) ResetBotID() {
  5716. m.bot_id = nil
  5717. m.addbot_id = nil
  5718. }
  5719. // SetBotType sets the "bot_type" field.
  5720. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  5721. m.bot_type = &u
  5722. m.addbot_type = nil
  5723. }
  5724. // BotType returns the value of the "bot_type" field in the mutation.
  5725. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  5726. v := m.bot_type
  5727. if v == nil {
  5728. return
  5729. }
  5730. return *v, true
  5731. }
  5732. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  5733. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5735. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  5736. if !m.op.Is(OpUpdateOne) {
  5737. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  5738. }
  5739. if m.id == nil || m.oldValue == nil {
  5740. return v, errors.New("OldBotType requires an ID field in the mutation")
  5741. }
  5742. oldValue, err := m.oldValue(ctx)
  5743. if err != nil {
  5744. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  5745. }
  5746. return oldValue.BotType, nil
  5747. }
  5748. // AddBotType adds u to the "bot_type" field.
  5749. func (m *ChatRecordsMutation) AddBotType(u int8) {
  5750. if m.addbot_type != nil {
  5751. *m.addbot_type += u
  5752. } else {
  5753. m.addbot_type = &u
  5754. }
  5755. }
  5756. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  5757. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  5758. v := m.addbot_type
  5759. if v == nil {
  5760. return
  5761. }
  5762. return *v, true
  5763. }
  5764. // ResetBotType resets all changes to the "bot_type" field.
  5765. func (m *ChatRecordsMutation) ResetBotType() {
  5766. m.bot_type = nil
  5767. m.addbot_type = nil
  5768. }
  5769. // Where appends a list predicates to the ChatRecordsMutation builder.
  5770. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  5771. m.predicates = append(m.predicates, ps...)
  5772. }
  5773. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  5774. // users can use type-assertion to append predicates that do not depend on any generated package.
  5775. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  5776. p := make([]predicate.ChatRecords, len(ps))
  5777. for i := range ps {
  5778. p[i] = ps[i]
  5779. }
  5780. m.Where(p...)
  5781. }
  5782. // Op returns the operation name.
  5783. func (m *ChatRecordsMutation) Op() Op {
  5784. return m.op
  5785. }
  5786. // SetOp allows setting the mutation operation.
  5787. func (m *ChatRecordsMutation) SetOp(op Op) {
  5788. m.op = op
  5789. }
  5790. // Type returns the node type of this mutation (ChatRecords).
  5791. func (m *ChatRecordsMutation) Type() string {
  5792. return m.typ
  5793. }
  5794. // Fields returns all fields that were changed during this mutation. Note that in
  5795. // order to get all numeric fields that were incremented/decremented, call
  5796. // AddedFields().
  5797. func (m *ChatRecordsMutation) Fields() []string {
  5798. fields := make([]string, 0, 9)
  5799. if m.created_at != nil {
  5800. fields = append(fields, chatrecords.FieldCreatedAt)
  5801. }
  5802. if m.updated_at != nil {
  5803. fields = append(fields, chatrecords.FieldUpdatedAt)
  5804. }
  5805. if m.deleted_at != nil {
  5806. fields = append(fields, chatrecords.FieldDeletedAt)
  5807. }
  5808. if m.content != nil {
  5809. fields = append(fields, chatrecords.FieldContent)
  5810. }
  5811. if m.content_type != nil {
  5812. fields = append(fields, chatrecords.FieldContentType)
  5813. }
  5814. if m.session_id != nil {
  5815. fields = append(fields, chatrecords.FieldSessionID)
  5816. }
  5817. if m.user_id != nil {
  5818. fields = append(fields, chatrecords.FieldUserID)
  5819. }
  5820. if m.bot_id != nil {
  5821. fields = append(fields, chatrecords.FieldBotID)
  5822. }
  5823. if m.bot_type != nil {
  5824. fields = append(fields, chatrecords.FieldBotType)
  5825. }
  5826. return fields
  5827. }
  5828. // Field returns the value of a field with the given name. The second boolean
  5829. // return value indicates that this field was not set, or was not defined in the
  5830. // schema.
  5831. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  5832. switch name {
  5833. case chatrecords.FieldCreatedAt:
  5834. return m.CreatedAt()
  5835. case chatrecords.FieldUpdatedAt:
  5836. return m.UpdatedAt()
  5837. case chatrecords.FieldDeletedAt:
  5838. return m.DeletedAt()
  5839. case chatrecords.FieldContent:
  5840. return m.Content()
  5841. case chatrecords.FieldContentType:
  5842. return m.ContentType()
  5843. case chatrecords.FieldSessionID:
  5844. return m.SessionID()
  5845. case chatrecords.FieldUserID:
  5846. return m.UserID()
  5847. case chatrecords.FieldBotID:
  5848. return m.BotID()
  5849. case chatrecords.FieldBotType:
  5850. return m.BotType()
  5851. }
  5852. return nil, false
  5853. }
  5854. // OldField returns the old value of the field from the database. An error is
  5855. // returned if the mutation operation is not UpdateOne, or the query to the
  5856. // database failed.
  5857. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5858. switch name {
  5859. case chatrecords.FieldCreatedAt:
  5860. return m.OldCreatedAt(ctx)
  5861. case chatrecords.FieldUpdatedAt:
  5862. return m.OldUpdatedAt(ctx)
  5863. case chatrecords.FieldDeletedAt:
  5864. return m.OldDeletedAt(ctx)
  5865. case chatrecords.FieldContent:
  5866. return m.OldContent(ctx)
  5867. case chatrecords.FieldContentType:
  5868. return m.OldContentType(ctx)
  5869. case chatrecords.FieldSessionID:
  5870. return m.OldSessionID(ctx)
  5871. case chatrecords.FieldUserID:
  5872. return m.OldUserID(ctx)
  5873. case chatrecords.FieldBotID:
  5874. return m.OldBotID(ctx)
  5875. case chatrecords.FieldBotType:
  5876. return m.OldBotType(ctx)
  5877. }
  5878. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  5879. }
  5880. // SetField sets the value of a field with the given name. It returns an error if
  5881. // the field is not defined in the schema, or if the type mismatched the field
  5882. // type.
  5883. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  5884. switch name {
  5885. case chatrecords.FieldCreatedAt:
  5886. v, ok := value.(time.Time)
  5887. if !ok {
  5888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5889. }
  5890. m.SetCreatedAt(v)
  5891. return nil
  5892. case chatrecords.FieldUpdatedAt:
  5893. v, ok := value.(time.Time)
  5894. if !ok {
  5895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5896. }
  5897. m.SetUpdatedAt(v)
  5898. return nil
  5899. case chatrecords.FieldDeletedAt:
  5900. v, ok := value.(time.Time)
  5901. if !ok {
  5902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5903. }
  5904. m.SetDeletedAt(v)
  5905. return nil
  5906. case chatrecords.FieldContent:
  5907. v, ok := value.(string)
  5908. if !ok {
  5909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5910. }
  5911. m.SetContent(v)
  5912. return nil
  5913. case chatrecords.FieldContentType:
  5914. v, ok := value.(uint8)
  5915. if !ok {
  5916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5917. }
  5918. m.SetContentType(v)
  5919. return nil
  5920. case chatrecords.FieldSessionID:
  5921. v, ok := value.(uint64)
  5922. if !ok {
  5923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5924. }
  5925. m.SetSessionID(v)
  5926. return nil
  5927. case chatrecords.FieldUserID:
  5928. v, ok := value.(uint64)
  5929. if !ok {
  5930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5931. }
  5932. m.SetUserID(v)
  5933. return nil
  5934. case chatrecords.FieldBotID:
  5935. v, ok := value.(uint64)
  5936. if !ok {
  5937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5938. }
  5939. m.SetBotID(v)
  5940. return nil
  5941. case chatrecords.FieldBotType:
  5942. v, ok := value.(uint8)
  5943. if !ok {
  5944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5945. }
  5946. m.SetBotType(v)
  5947. return nil
  5948. }
  5949. return fmt.Errorf("unknown ChatRecords field %s", name)
  5950. }
  5951. // AddedFields returns all numeric fields that were incremented/decremented during
  5952. // this mutation.
  5953. func (m *ChatRecordsMutation) AddedFields() []string {
  5954. var fields []string
  5955. if m.addcontent_type != nil {
  5956. fields = append(fields, chatrecords.FieldContentType)
  5957. }
  5958. if m.addsession_id != nil {
  5959. fields = append(fields, chatrecords.FieldSessionID)
  5960. }
  5961. if m.adduser_id != nil {
  5962. fields = append(fields, chatrecords.FieldUserID)
  5963. }
  5964. if m.addbot_id != nil {
  5965. fields = append(fields, chatrecords.FieldBotID)
  5966. }
  5967. if m.addbot_type != nil {
  5968. fields = append(fields, chatrecords.FieldBotType)
  5969. }
  5970. return fields
  5971. }
  5972. // AddedField returns the numeric value that was incremented/decremented on a field
  5973. // with the given name. The second boolean return value indicates that this field
  5974. // was not set, or was not defined in the schema.
  5975. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  5976. switch name {
  5977. case chatrecords.FieldContentType:
  5978. return m.AddedContentType()
  5979. case chatrecords.FieldSessionID:
  5980. return m.AddedSessionID()
  5981. case chatrecords.FieldUserID:
  5982. return m.AddedUserID()
  5983. case chatrecords.FieldBotID:
  5984. return m.AddedBotID()
  5985. case chatrecords.FieldBotType:
  5986. return m.AddedBotType()
  5987. }
  5988. return nil, false
  5989. }
  5990. // AddField adds the value to the field with the given name. It returns an error if
  5991. // the field is not defined in the schema, or if the type mismatched the field
  5992. // type.
  5993. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  5994. switch name {
  5995. case chatrecords.FieldContentType:
  5996. v, ok := value.(int8)
  5997. if !ok {
  5998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5999. }
  6000. m.AddContentType(v)
  6001. return nil
  6002. case chatrecords.FieldSessionID:
  6003. v, ok := value.(int64)
  6004. if !ok {
  6005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6006. }
  6007. m.AddSessionID(v)
  6008. return nil
  6009. case chatrecords.FieldUserID:
  6010. v, ok := value.(int64)
  6011. if !ok {
  6012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6013. }
  6014. m.AddUserID(v)
  6015. return nil
  6016. case chatrecords.FieldBotID:
  6017. v, ok := value.(int64)
  6018. if !ok {
  6019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6020. }
  6021. m.AddBotID(v)
  6022. return nil
  6023. case chatrecords.FieldBotType:
  6024. v, ok := value.(int8)
  6025. if !ok {
  6026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6027. }
  6028. m.AddBotType(v)
  6029. return nil
  6030. }
  6031. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6032. }
  6033. // ClearedFields returns all nullable fields that were cleared during this
  6034. // mutation.
  6035. func (m *ChatRecordsMutation) ClearedFields() []string {
  6036. var fields []string
  6037. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6038. fields = append(fields, chatrecords.FieldDeletedAt)
  6039. }
  6040. return fields
  6041. }
  6042. // FieldCleared returns a boolean indicating if a field with the given name was
  6043. // cleared in this mutation.
  6044. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6045. _, ok := m.clearedFields[name]
  6046. return ok
  6047. }
  6048. // ClearField clears the value of the field with the given name. It returns an
  6049. // error if the field is not defined in the schema.
  6050. func (m *ChatRecordsMutation) ClearField(name string) error {
  6051. switch name {
  6052. case chatrecords.FieldDeletedAt:
  6053. m.ClearDeletedAt()
  6054. return nil
  6055. }
  6056. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6057. }
  6058. // ResetField resets all changes in the mutation for the field with the given name.
  6059. // It returns an error if the field is not defined in the schema.
  6060. func (m *ChatRecordsMutation) ResetField(name string) error {
  6061. switch name {
  6062. case chatrecords.FieldCreatedAt:
  6063. m.ResetCreatedAt()
  6064. return nil
  6065. case chatrecords.FieldUpdatedAt:
  6066. m.ResetUpdatedAt()
  6067. return nil
  6068. case chatrecords.FieldDeletedAt:
  6069. m.ResetDeletedAt()
  6070. return nil
  6071. case chatrecords.FieldContent:
  6072. m.ResetContent()
  6073. return nil
  6074. case chatrecords.FieldContentType:
  6075. m.ResetContentType()
  6076. return nil
  6077. case chatrecords.FieldSessionID:
  6078. m.ResetSessionID()
  6079. return nil
  6080. case chatrecords.FieldUserID:
  6081. m.ResetUserID()
  6082. return nil
  6083. case chatrecords.FieldBotID:
  6084. m.ResetBotID()
  6085. return nil
  6086. case chatrecords.FieldBotType:
  6087. m.ResetBotType()
  6088. return nil
  6089. }
  6090. return fmt.Errorf("unknown ChatRecords field %s", name)
  6091. }
  6092. // AddedEdges returns all edge names that were set/added in this mutation.
  6093. func (m *ChatRecordsMutation) AddedEdges() []string {
  6094. edges := make([]string, 0, 0)
  6095. return edges
  6096. }
  6097. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6098. // name in this mutation.
  6099. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6100. return nil
  6101. }
  6102. // RemovedEdges returns all edge names that were removed in this mutation.
  6103. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6104. edges := make([]string, 0, 0)
  6105. return edges
  6106. }
  6107. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6108. // the given name in this mutation.
  6109. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6110. return nil
  6111. }
  6112. // ClearedEdges returns all edge names that were cleared in this mutation.
  6113. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6114. edges := make([]string, 0, 0)
  6115. return edges
  6116. }
  6117. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6118. // was cleared in this mutation.
  6119. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6120. return false
  6121. }
  6122. // ClearEdge clears the value of the edge with the given name. It returns an error
  6123. // if that edge is not defined in the schema.
  6124. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6125. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6126. }
  6127. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6128. // It returns an error if the edge is not defined in the schema.
  6129. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6130. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6131. }
  6132. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6133. type ChatSessionMutation struct {
  6134. config
  6135. op Op
  6136. typ string
  6137. id *uint64
  6138. created_at *time.Time
  6139. updated_at *time.Time
  6140. deleted_at *time.Time
  6141. name *string
  6142. user_id *uint64
  6143. adduser_id *int64
  6144. bot_id *uint64
  6145. addbot_id *int64
  6146. bot_type *uint8
  6147. addbot_type *int8
  6148. clearedFields map[string]struct{}
  6149. done bool
  6150. oldValue func(context.Context) (*ChatSession, error)
  6151. predicates []predicate.ChatSession
  6152. }
  6153. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6154. // chatsessionOption allows management of the mutation configuration using functional options.
  6155. type chatsessionOption func(*ChatSessionMutation)
  6156. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6157. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6158. m := &ChatSessionMutation{
  6159. config: c,
  6160. op: op,
  6161. typ: TypeChatSession,
  6162. clearedFields: make(map[string]struct{}),
  6163. }
  6164. for _, opt := range opts {
  6165. opt(m)
  6166. }
  6167. return m
  6168. }
  6169. // withChatSessionID sets the ID field of the mutation.
  6170. func withChatSessionID(id uint64) chatsessionOption {
  6171. return func(m *ChatSessionMutation) {
  6172. var (
  6173. err error
  6174. once sync.Once
  6175. value *ChatSession
  6176. )
  6177. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6178. once.Do(func() {
  6179. if m.done {
  6180. err = errors.New("querying old values post mutation is not allowed")
  6181. } else {
  6182. value, err = m.Client().ChatSession.Get(ctx, id)
  6183. }
  6184. })
  6185. return value, err
  6186. }
  6187. m.id = &id
  6188. }
  6189. }
  6190. // withChatSession sets the old ChatSession of the mutation.
  6191. func withChatSession(node *ChatSession) chatsessionOption {
  6192. return func(m *ChatSessionMutation) {
  6193. m.oldValue = func(context.Context) (*ChatSession, error) {
  6194. return node, nil
  6195. }
  6196. m.id = &node.ID
  6197. }
  6198. }
  6199. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6200. // executed in a transaction (ent.Tx), a transactional client is returned.
  6201. func (m ChatSessionMutation) Client() *Client {
  6202. client := &Client{config: m.config}
  6203. client.init()
  6204. return client
  6205. }
  6206. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6207. // it returns an error otherwise.
  6208. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6209. if _, ok := m.driver.(*txDriver); !ok {
  6210. return nil, errors.New("ent: mutation is not running in a transaction")
  6211. }
  6212. tx := &Tx{config: m.config}
  6213. tx.init()
  6214. return tx, nil
  6215. }
  6216. // SetID sets the value of the id field. Note that this
  6217. // operation is only accepted on creation of ChatSession entities.
  6218. func (m *ChatSessionMutation) SetID(id uint64) {
  6219. m.id = &id
  6220. }
  6221. // ID returns the ID value in the mutation. Note that the ID is only available
  6222. // if it was provided to the builder or after it was returned from the database.
  6223. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6224. if m.id == nil {
  6225. return
  6226. }
  6227. return *m.id, true
  6228. }
  6229. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6230. // That means, if the mutation is applied within a transaction with an isolation level such
  6231. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6232. // or updated by the mutation.
  6233. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6234. switch {
  6235. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6236. id, exists := m.ID()
  6237. if exists {
  6238. return []uint64{id}, nil
  6239. }
  6240. fallthrough
  6241. case m.op.Is(OpUpdate | OpDelete):
  6242. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  6243. default:
  6244. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6245. }
  6246. }
  6247. // SetCreatedAt sets the "created_at" field.
  6248. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  6249. m.created_at = &t
  6250. }
  6251. // CreatedAt returns the value of the "created_at" field in the mutation.
  6252. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  6253. v := m.created_at
  6254. if v == nil {
  6255. return
  6256. }
  6257. return *v, true
  6258. }
  6259. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  6260. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6262. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6263. if !m.op.Is(OpUpdateOne) {
  6264. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6265. }
  6266. if m.id == nil || m.oldValue == nil {
  6267. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6268. }
  6269. oldValue, err := m.oldValue(ctx)
  6270. if err != nil {
  6271. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6272. }
  6273. return oldValue.CreatedAt, nil
  6274. }
  6275. // ResetCreatedAt resets all changes to the "created_at" field.
  6276. func (m *ChatSessionMutation) ResetCreatedAt() {
  6277. m.created_at = nil
  6278. }
  6279. // SetUpdatedAt sets the "updated_at" field.
  6280. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  6281. m.updated_at = &t
  6282. }
  6283. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6284. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  6285. v := m.updated_at
  6286. if v == nil {
  6287. return
  6288. }
  6289. return *v, true
  6290. }
  6291. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  6292. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6294. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6295. if !m.op.Is(OpUpdateOne) {
  6296. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6297. }
  6298. if m.id == nil || m.oldValue == nil {
  6299. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6300. }
  6301. oldValue, err := m.oldValue(ctx)
  6302. if err != nil {
  6303. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6304. }
  6305. return oldValue.UpdatedAt, nil
  6306. }
  6307. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6308. func (m *ChatSessionMutation) ResetUpdatedAt() {
  6309. m.updated_at = nil
  6310. }
  6311. // SetDeletedAt sets the "deleted_at" field.
  6312. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  6313. m.deleted_at = &t
  6314. }
  6315. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6316. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  6317. v := m.deleted_at
  6318. if v == nil {
  6319. return
  6320. }
  6321. return *v, true
  6322. }
  6323. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  6324. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6326. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6327. if !m.op.Is(OpUpdateOne) {
  6328. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6329. }
  6330. if m.id == nil || m.oldValue == nil {
  6331. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6332. }
  6333. oldValue, err := m.oldValue(ctx)
  6334. if err != nil {
  6335. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6336. }
  6337. return oldValue.DeletedAt, nil
  6338. }
  6339. // ClearDeletedAt clears the value of the "deleted_at" field.
  6340. func (m *ChatSessionMutation) ClearDeletedAt() {
  6341. m.deleted_at = nil
  6342. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  6343. }
  6344. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6345. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  6346. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  6347. return ok
  6348. }
  6349. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6350. func (m *ChatSessionMutation) ResetDeletedAt() {
  6351. m.deleted_at = nil
  6352. delete(m.clearedFields, chatsession.FieldDeletedAt)
  6353. }
  6354. // SetName sets the "name" field.
  6355. func (m *ChatSessionMutation) SetName(s string) {
  6356. m.name = &s
  6357. }
  6358. // Name returns the value of the "name" field in the mutation.
  6359. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  6360. v := m.name
  6361. if v == nil {
  6362. return
  6363. }
  6364. return *v, true
  6365. }
  6366. // OldName returns the old "name" field's value of the ChatSession entity.
  6367. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6369. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  6370. if !m.op.Is(OpUpdateOne) {
  6371. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6372. }
  6373. if m.id == nil || m.oldValue == nil {
  6374. return v, errors.New("OldName requires an ID field in the mutation")
  6375. }
  6376. oldValue, err := m.oldValue(ctx)
  6377. if err != nil {
  6378. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6379. }
  6380. return oldValue.Name, nil
  6381. }
  6382. // ResetName resets all changes to the "name" field.
  6383. func (m *ChatSessionMutation) ResetName() {
  6384. m.name = nil
  6385. }
  6386. // SetUserID sets the "user_id" field.
  6387. func (m *ChatSessionMutation) SetUserID(u uint64) {
  6388. m.user_id = &u
  6389. m.adduser_id = nil
  6390. }
  6391. // UserID returns the value of the "user_id" field in the mutation.
  6392. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  6393. v := m.user_id
  6394. if v == nil {
  6395. return
  6396. }
  6397. return *v, true
  6398. }
  6399. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  6400. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6402. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6403. if !m.op.Is(OpUpdateOne) {
  6404. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6405. }
  6406. if m.id == nil || m.oldValue == nil {
  6407. return v, errors.New("OldUserID requires an ID field in the mutation")
  6408. }
  6409. oldValue, err := m.oldValue(ctx)
  6410. if err != nil {
  6411. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6412. }
  6413. return oldValue.UserID, nil
  6414. }
  6415. // AddUserID adds u to the "user_id" field.
  6416. func (m *ChatSessionMutation) AddUserID(u int64) {
  6417. if m.adduser_id != nil {
  6418. *m.adduser_id += u
  6419. } else {
  6420. m.adduser_id = &u
  6421. }
  6422. }
  6423. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6424. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  6425. v := m.adduser_id
  6426. if v == nil {
  6427. return
  6428. }
  6429. return *v, true
  6430. }
  6431. // ResetUserID resets all changes to the "user_id" field.
  6432. func (m *ChatSessionMutation) ResetUserID() {
  6433. m.user_id = nil
  6434. m.adduser_id = nil
  6435. }
  6436. // SetBotID sets the "bot_id" field.
  6437. func (m *ChatSessionMutation) SetBotID(u uint64) {
  6438. m.bot_id = &u
  6439. m.addbot_id = nil
  6440. }
  6441. // BotID returns the value of the "bot_id" field in the mutation.
  6442. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  6443. v := m.bot_id
  6444. if v == nil {
  6445. return
  6446. }
  6447. return *v, true
  6448. }
  6449. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  6450. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6452. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6453. if !m.op.Is(OpUpdateOne) {
  6454. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6455. }
  6456. if m.id == nil || m.oldValue == nil {
  6457. return v, errors.New("OldBotID requires an ID field in the mutation")
  6458. }
  6459. oldValue, err := m.oldValue(ctx)
  6460. if err != nil {
  6461. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6462. }
  6463. return oldValue.BotID, nil
  6464. }
  6465. // AddBotID adds u to the "bot_id" field.
  6466. func (m *ChatSessionMutation) AddBotID(u int64) {
  6467. if m.addbot_id != nil {
  6468. *m.addbot_id += u
  6469. } else {
  6470. m.addbot_id = &u
  6471. }
  6472. }
  6473. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6474. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  6475. v := m.addbot_id
  6476. if v == nil {
  6477. return
  6478. }
  6479. return *v, true
  6480. }
  6481. // ResetBotID resets all changes to the "bot_id" field.
  6482. func (m *ChatSessionMutation) ResetBotID() {
  6483. m.bot_id = nil
  6484. m.addbot_id = nil
  6485. }
  6486. // SetBotType sets the "bot_type" field.
  6487. func (m *ChatSessionMutation) SetBotType(u uint8) {
  6488. m.bot_type = &u
  6489. m.addbot_type = nil
  6490. }
  6491. // BotType returns the value of the "bot_type" field in the mutation.
  6492. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  6493. v := m.bot_type
  6494. if v == nil {
  6495. return
  6496. }
  6497. return *v, true
  6498. }
  6499. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  6500. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6502. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6503. if !m.op.Is(OpUpdateOne) {
  6504. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6505. }
  6506. if m.id == nil || m.oldValue == nil {
  6507. return v, errors.New("OldBotType requires an ID field in the mutation")
  6508. }
  6509. oldValue, err := m.oldValue(ctx)
  6510. if err != nil {
  6511. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6512. }
  6513. return oldValue.BotType, nil
  6514. }
  6515. // AddBotType adds u to the "bot_type" field.
  6516. func (m *ChatSessionMutation) AddBotType(u int8) {
  6517. if m.addbot_type != nil {
  6518. *m.addbot_type += u
  6519. } else {
  6520. m.addbot_type = &u
  6521. }
  6522. }
  6523. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6524. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  6525. v := m.addbot_type
  6526. if v == nil {
  6527. return
  6528. }
  6529. return *v, true
  6530. }
  6531. // ResetBotType resets all changes to the "bot_type" field.
  6532. func (m *ChatSessionMutation) ResetBotType() {
  6533. m.bot_type = nil
  6534. m.addbot_type = nil
  6535. }
  6536. // Where appends a list predicates to the ChatSessionMutation builder.
  6537. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  6538. m.predicates = append(m.predicates, ps...)
  6539. }
  6540. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  6541. // users can use type-assertion to append predicates that do not depend on any generated package.
  6542. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  6543. p := make([]predicate.ChatSession, len(ps))
  6544. for i := range ps {
  6545. p[i] = ps[i]
  6546. }
  6547. m.Where(p...)
  6548. }
  6549. // Op returns the operation name.
  6550. func (m *ChatSessionMutation) Op() Op {
  6551. return m.op
  6552. }
  6553. // SetOp allows setting the mutation operation.
  6554. func (m *ChatSessionMutation) SetOp(op Op) {
  6555. m.op = op
  6556. }
  6557. // Type returns the node type of this mutation (ChatSession).
  6558. func (m *ChatSessionMutation) Type() string {
  6559. return m.typ
  6560. }
  6561. // Fields returns all fields that were changed during this mutation. Note that in
  6562. // order to get all numeric fields that were incremented/decremented, call
  6563. // AddedFields().
  6564. func (m *ChatSessionMutation) Fields() []string {
  6565. fields := make([]string, 0, 7)
  6566. if m.created_at != nil {
  6567. fields = append(fields, chatsession.FieldCreatedAt)
  6568. }
  6569. if m.updated_at != nil {
  6570. fields = append(fields, chatsession.FieldUpdatedAt)
  6571. }
  6572. if m.deleted_at != nil {
  6573. fields = append(fields, chatsession.FieldDeletedAt)
  6574. }
  6575. if m.name != nil {
  6576. fields = append(fields, chatsession.FieldName)
  6577. }
  6578. if m.user_id != nil {
  6579. fields = append(fields, chatsession.FieldUserID)
  6580. }
  6581. if m.bot_id != nil {
  6582. fields = append(fields, chatsession.FieldBotID)
  6583. }
  6584. if m.bot_type != nil {
  6585. fields = append(fields, chatsession.FieldBotType)
  6586. }
  6587. return fields
  6588. }
  6589. // Field returns the value of a field with the given name. The second boolean
  6590. // return value indicates that this field was not set, or was not defined in the
  6591. // schema.
  6592. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  6593. switch name {
  6594. case chatsession.FieldCreatedAt:
  6595. return m.CreatedAt()
  6596. case chatsession.FieldUpdatedAt:
  6597. return m.UpdatedAt()
  6598. case chatsession.FieldDeletedAt:
  6599. return m.DeletedAt()
  6600. case chatsession.FieldName:
  6601. return m.Name()
  6602. case chatsession.FieldUserID:
  6603. return m.UserID()
  6604. case chatsession.FieldBotID:
  6605. return m.BotID()
  6606. case chatsession.FieldBotType:
  6607. return m.BotType()
  6608. }
  6609. return nil, false
  6610. }
  6611. // OldField returns the old value of the field from the database. An error is
  6612. // returned if the mutation operation is not UpdateOne, or the query to the
  6613. // database failed.
  6614. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6615. switch name {
  6616. case chatsession.FieldCreatedAt:
  6617. return m.OldCreatedAt(ctx)
  6618. case chatsession.FieldUpdatedAt:
  6619. return m.OldUpdatedAt(ctx)
  6620. case chatsession.FieldDeletedAt:
  6621. return m.OldDeletedAt(ctx)
  6622. case chatsession.FieldName:
  6623. return m.OldName(ctx)
  6624. case chatsession.FieldUserID:
  6625. return m.OldUserID(ctx)
  6626. case chatsession.FieldBotID:
  6627. return m.OldBotID(ctx)
  6628. case chatsession.FieldBotType:
  6629. return m.OldBotType(ctx)
  6630. }
  6631. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  6632. }
  6633. // SetField sets the value of a field with the given name. It returns an error if
  6634. // the field is not defined in the schema, or if the type mismatched the field
  6635. // type.
  6636. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  6637. switch name {
  6638. case chatsession.FieldCreatedAt:
  6639. v, ok := value.(time.Time)
  6640. if !ok {
  6641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6642. }
  6643. m.SetCreatedAt(v)
  6644. return nil
  6645. case chatsession.FieldUpdatedAt:
  6646. v, ok := value.(time.Time)
  6647. if !ok {
  6648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6649. }
  6650. m.SetUpdatedAt(v)
  6651. return nil
  6652. case chatsession.FieldDeletedAt:
  6653. v, ok := value.(time.Time)
  6654. if !ok {
  6655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6656. }
  6657. m.SetDeletedAt(v)
  6658. return nil
  6659. case chatsession.FieldName:
  6660. v, ok := value.(string)
  6661. if !ok {
  6662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6663. }
  6664. m.SetName(v)
  6665. return nil
  6666. case chatsession.FieldUserID:
  6667. v, ok := value.(uint64)
  6668. if !ok {
  6669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6670. }
  6671. m.SetUserID(v)
  6672. return nil
  6673. case chatsession.FieldBotID:
  6674. v, ok := value.(uint64)
  6675. if !ok {
  6676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6677. }
  6678. m.SetBotID(v)
  6679. return nil
  6680. case chatsession.FieldBotType:
  6681. v, ok := value.(uint8)
  6682. if !ok {
  6683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6684. }
  6685. m.SetBotType(v)
  6686. return nil
  6687. }
  6688. return fmt.Errorf("unknown ChatSession field %s", name)
  6689. }
  6690. // AddedFields returns all numeric fields that were incremented/decremented during
  6691. // this mutation.
  6692. func (m *ChatSessionMutation) AddedFields() []string {
  6693. var fields []string
  6694. if m.adduser_id != nil {
  6695. fields = append(fields, chatsession.FieldUserID)
  6696. }
  6697. if m.addbot_id != nil {
  6698. fields = append(fields, chatsession.FieldBotID)
  6699. }
  6700. if m.addbot_type != nil {
  6701. fields = append(fields, chatsession.FieldBotType)
  6702. }
  6703. return fields
  6704. }
  6705. // AddedField returns the numeric value that was incremented/decremented on a field
  6706. // with the given name. The second boolean return value indicates that this field
  6707. // was not set, or was not defined in the schema.
  6708. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  6709. switch name {
  6710. case chatsession.FieldUserID:
  6711. return m.AddedUserID()
  6712. case chatsession.FieldBotID:
  6713. return m.AddedBotID()
  6714. case chatsession.FieldBotType:
  6715. return m.AddedBotType()
  6716. }
  6717. return nil, false
  6718. }
  6719. // AddField adds the value to the field with the given name. It returns an error if
  6720. // the field is not defined in the schema, or if the type mismatched the field
  6721. // type.
  6722. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  6723. switch name {
  6724. case chatsession.FieldUserID:
  6725. v, ok := value.(int64)
  6726. if !ok {
  6727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6728. }
  6729. m.AddUserID(v)
  6730. return nil
  6731. case chatsession.FieldBotID:
  6732. v, ok := value.(int64)
  6733. if !ok {
  6734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6735. }
  6736. m.AddBotID(v)
  6737. return nil
  6738. case chatsession.FieldBotType:
  6739. v, ok := value.(int8)
  6740. if !ok {
  6741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6742. }
  6743. m.AddBotType(v)
  6744. return nil
  6745. }
  6746. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  6747. }
  6748. // ClearedFields returns all nullable fields that were cleared during this
  6749. // mutation.
  6750. func (m *ChatSessionMutation) ClearedFields() []string {
  6751. var fields []string
  6752. if m.FieldCleared(chatsession.FieldDeletedAt) {
  6753. fields = append(fields, chatsession.FieldDeletedAt)
  6754. }
  6755. return fields
  6756. }
  6757. // FieldCleared returns a boolean indicating if a field with the given name was
  6758. // cleared in this mutation.
  6759. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  6760. _, ok := m.clearedFields[name]
  6761. return ok
  6762. }
  6763. // ClearField clears the value of the field with the given name. It returns an
  6764. // error if the field is not defined in the schema.
  6765. func (m *ChatSessionMutation) ClearField(name string) error {
  6766. switch name {
  6767. case chatsession.FieldDeletedAt:
  6768. m.ClearDeletedAt()
  6769. return nil
  6770. }
  6771. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  6772. }
  6773. // ResetField resets all changes in the mutation for the field with the given name.
  6774. // It returns an error if the field is not defined in the schema.
  6775. func (m *ChatSessionMutation) ResetField(name string) error {
  6776. switch name {
  6777. case chatsession.FieldCreatedAt:
  6778. m.ResetCreatedAt()
  6779. return nil
  6780. case chatsession.FieldUpdatedAt:
  6781. m.ResetUpdatedAt()
  6782. return nil
  6783. case chatsession.FieldDeletedAt:
  6784. m.ResetDeletedAt()
  6785. return nil
  6786. case chatsession.FieldName:
  6787. m.ResetName()
  6788. return nil
  6789. case chatsession.FieldUserID:
  6790. m.ResetUserID()
  6791. return nil
  6792. case chatsession.FieldBotID:
  6793. m.ResetBotID()
  6794. return nil
  6795. case chatsession.FieldBotType:
  6796. m.ResetBotType()
  6797. return nil
  6798. }
  6799. return fmt.Errorf("unknown ChatSession field %s", name)
  6800. }
  6801. // AddedEdges returns all edge names that were set/added in this mutation.
  6802. func (m *ChatSessionMutation) AddedEdges() []string {
  6803. edges := make([]string, 0, 0)
  6804. return edges
  6805. }
  6806. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6807. // name in this mutation.
  6808. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  6809. return nil
  6810. }
  6811. // RemovedEdges returns all edge names that were removed in this mutation.
  6812. func (m *ChatSessionMutation) RemovedEdges() []string {
  6813. edges := make([]string, 0, 0)
  6814. return edges
  6815. }
  6816. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6817. // the given name in this mutation.
  6818. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  6819. return nil
  6820. }
  6821. // ClearedEdges returns all edge names that were cleared in this mutation.
  6822. func (m *ChatSessionMutation) ClearedEdges() []string {
  6823. edges := make([]string, 0, 0)
  6824. return edges
  6825. }
  6826. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6827. // was cleared in this mutation.
  6828. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  6829. return false
  6830. }
  6831. // ClearEdge clears the value of the edge with the given name. It returns an error
  6832. // if that edge is not defined in the schema.
  6833. func (m *ChatSessionMutation) ClearEdge(name string) error {
  6834. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  6835. }
  6836. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6837. // It returns an error if the edge is not defined in the schema.
  6838. func (m *ChatSessionMutation) ResetEdge(name string) error {
  6839. return fmt.Errorf("unknown ChatSession edge %s", name)
  6840. }
  6841. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  6842. type ContactMutation struct {
  6843. config
  6844. op Op
  6845. typ string
  6846. id *uint64
  6847. created_at *time.Time
  6848. updated_at *time.Time
  6849. status *uint8
  6850. addstatus *int8
  6851. deleted_at *time.Time
  6852. wx_wxid *string
  6853. _type *int
  6854. add_type *int
  6855. wxid *string
  6856. account *string
  6857. nickname *string
  6858. markname *string
  6859. headimg *string
  6860. sex *int
  6861. addsex *int
  6862. starrole *string
  6863. dontseeit *int
  6864. adddontseeit *int
  6865. dontseeme *int
  6866. adddontseeme *int
  6867. lag *string
  6868. gid *string
  6869. gname *string
  6870. v3 *string
  6871. organization_id *uint64
  6872. addorganization_id *int64
  6873. clearedFields map[string]struct{}
  6874. contact_relationships map[uint64]struct{}
  6875. removedcontact_relationships map[uint64]struct{}
  6876. clearedcontact_relationships bool
  6877. contact_messages map[uint64]struct{}
  6878. removedcontact_messages map[uint64]struct{}
  6879. clearedcontact_messages bool
  6880. done bool
  6881. oldValue func(context.Context) (*Contact, error)
  6882. predicates []predicate.Contact
  6883. }
  6884. var _ ent.Mutation = (*ContactMutation)(nil)
  6885. // contactOption allows management of the mutation configuration using functional options.
  6886. type contactOption func(*ContactMutation)
  6887. // newContactMutation creates new mutation for the Contact entity.
  6888. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  6889. m := &ContactMutation{
  6890. config: c,
  6891. op: op,
  6892. typ: TypeContact,
  6893. clearedFields: make(map[string]struct{}),
  6894. }
  6895. for _, opt := range opts {
  6896. opt(m)
  6897. }
  6898. return m
  6899. }
  6900. // withContactID sets the ID field of the mutation.
  6901. func withContactID(id uint64) contactOption {
  6902. return func(m *ContactMutation) {
  6903. var (
  6904. err error
  6905. once sync.Once
  6906. value *Contact
  6907. )
  6908. m.oldValue = func(ctx context.Context) (*Contact, error) {
  6909. once.Do(func() {
  6910. if m.done {
  6911. err = errors.New("querying old values post mutation is not allowed")
  6912. } else {
  6913. value, err = m.Client().Contact.Get(ctx, id)
  6914. }
  6915. })
  6916. return value, err
  6917. }
  6918. m.id = &id
  6919. }
  6920. }
  6921. // withContact sets the old Contact of the mutation.
  6922. func withContact(node *Contact) contactOption {
  6923. return func(m *ContactMutation) {
  6924. m.oldValue = func(context.Context) (*Contact, error) {
  6925. return node, nil
  6926. }
  6927. m.id = &node.ID
  6928. }
  6929. }
  6930. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6931. // executed in a transaction (ent.Tx), a transactional client is returned.
  6932. func (m ContactMutation) Client() *Client {
  6933. client := &Client{config: m.config}
  6934. client.init()
  6935. return client
  6936. }
  6937. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6938. // it returns an error otherwise.
  6939. func (m ContactMutation) Tx() (*Tx, error) {
  6940. if _, ok := m.driver.(*txDriver); !ok {
  6941. return nil, errors.New("ent: mutation is not running in a transaction")
  6942. }
  6943. tx := &Tx{config: m.config}
  6944. tx.init()
  6945. return tx, nil
  6946. }
  6947. // SetID sets the value of the id field. Note that this
  6948. // operation is only accepted on creation of Contact entities.
  6949. func (m *ContactMutation) SetID(id uint64) {
  6950. m.id = &id
  6951. }
  6952. // ID returns the ID value in the mutation. Note that the ID is only available
  6953. // if it was provided to the builder or after it was returned from the database.
  6954. func (m *ContactMutation) ID() (id uint64, exists bool) {
  6955. if m.id == nil {
  6956. return
  6957. }
  6958. return *m.id, true
  6959. }
  6960. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6961. // That means, if the mutation is applied within a transaction with an isolation level such
  6962. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6963. // or updated by the mutation.
  6964. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  6965. switch {
  6966. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6967. id, exists := m.ID()
  6968. if exists {
  6969. return []uint64{id}, nil
  6970. }
  6971. fallthrough
  6972. case m.op.Is(OpUpdate | OpDelete):
  6973. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  6974. default:
  6975. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6976. }
  6977. }
  6978. // SetCreatedAt sets the "created_at" field.
  6979. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  6980. m.created_at = &t
  6981. }
  6982. // CreatedAt returns the value of the "created_at" field in the mutation.
  6983. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  6984. v := m.created_at
  6985. if v == nil {
  6986. return
  6987. }
  6988. return *v, true
  6989. }
  6990. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  6991. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6993. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6994. if !m.op.Is(OpUpdateOne) {
  6995. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6996. }
  6997. if m.id == nil || m.oldValue == nil {
  6998. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6999. }
  7000. oldValue, err := m.oldValue(ctx)
  7001. if err != nil {
  7002. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7003. }
  7004. return oldValue.CreatedAt, nil
  7005. }
  7006. // ResetCreatedAt resets all changes to the "created_at" field.
  7007. func (m *ContactMutation) ResetCreatedAt() {
  7008. m.created_at = nil
  7009. }
  7010. // SetUpdatedAt sets the "updated_at" field.
  7011. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7012. m.updated_at = &t
  7013. }
  7014. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7015. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7016. v := m.updated_at
  7017. if v == nil {
  7018. return
  7019. }
  7020. return *v, true
  7021. }
  7022. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7023. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7025. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7026. if !m.op.Is(OpUpdateOne) {
  7027. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7028. }
  7029. if m.id == nil || m.oldValue == nil {
  7030. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7031. }
  7032. oldValue, err := m.oldValue(ctx)
  7033. if err != nil {
  7034. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7035. }
  7036. return oldValue.UpdatedAt, nil
  7037. }
  7038. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7039. func (m *ContactMutation) ResetUpdatedAt() {
  7040. m.updated_at = nil
  7041. }
  7042. // SetStatus sets the "status" field.
  7043. func (m *ContactMutation) SetStatus(u uint8) {
  7044. m.status = &u
  7045. m.addstatus = nil
  7046. }
  7047. // Status returns the value of the "status" field in the mutation.
  7048. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7049. v := m.status
  7050. if v == nil {
  7051. return
  7052. }
  7053. return *v, true
  7054. }
  7055. // OldStatus returns the old "status" field's value of the Contact entity.
  7056. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7058. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7059. if !m.op.Is(OpUpdateOne) {
  7060. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7061. }
  7062. if m.id == nil || m.oldValue == nil {
  7063. return v, errors.New("OldStatus requires an ID field in the mutation")
  7064. }
  7065. oldValue, err := m.oldValue(ctx)
  7066. if err != nil {
  7067. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7068. }
  7069. return oldValue.Status, nil
  7070. }
  7071. // AddStatus adds u to the "status" field.
  7072. func (m *ContactMutation) AddStatus(u int8) {
  7073. if m.addstatus != nil {
  7074. *m.addstatus += u
  7075. } else {
  7076. m.addstatus = &u
  7077. }
  7078. }
  7079. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7080. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7081. v := m.addstatus
  7082. if v == nil {
  7083. return
  7084. }
  7085. return *v, true
  7086. }
  7087. // ClearStatus clears the value of the "status" field.
  7088. func (m *ContactMutation) ClearStatus() {
  7089. m.status = nil
  7090. m.addstatus = nil
  7091. m.clearedFields[contact.FieldStatus] = struct{}{}
  7092. }
  7093. // StatusCleared returns if the "status" field was cleared in this mutation.
  7094. func (m *ContactMutation) StatusCleared() bool {
  7095. _, ok := m.clearedFields[contact.FieldStatus]
  7096. return ok
  7097. }
  7098. // ResetStatus resets all changes to the "status" field.
  7099. func (m *ContactMutation) ResetStatus() {
  7100. m.status = nil
  7101. m.addstatus = nil
  7102. delete(m.clearedFields, contact.FieldStatus)
  7103. }
  7104. // SetDeletedAt sets the "deleted_at" field.
  7105. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7106. m.deleted_at = &t
  7107. }
  7108. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7109. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7110. v := m.deleted_at
  7111. if v == nil {
  7112. return
  7113. }
  7114. return *v, true
  7115. }
  7116. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7117. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7119. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7120. if !m.op.Is(OpUpdateOne) {
  7121. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7122. }
  7123. if m.id == nil || m.oldValue == nil {
  7124. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7125. }
  7126. oldValue, err := m.oldValue(ctx)
  7127. if err != nil {
  7128. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7129. }
  7130. return oldValue.DeletedAt, nil
  7131. }
  7132. // ClearDeletedAt clears the value of the "deleted_at" field.
  7133. func (m *ContactMutation) ClearDeletedAt() {
  7134. m.deleted_at = nil
  7135. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7136. }
  7137. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7138. func (m *ContactMutation) DeletedAtCleared() bool {
  7139. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7140. return ok
  7141. }
  7142. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7143. func (m *ContactMutation) ResetDeletedAt() {
  7144. m.deleted_at = nil
  7145. delete(m.clearedFields, contact.FieldDeletedAt)
  7146. }
  7147. // SetWxWxid sets the "wx_wxid" field.
  7148. func (m *ContactMutation) SetWxWxid(s string) {
  7149. m.wx_wxid = &s
  7150. }
  7151. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7152. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7153. v := m.wx_wxid
  7154. if v == nil {
  7155. return
  7156. }
  7157. return *v, true
  7158. }
  7159. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7160. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7162. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7163. if !m.op.Is(OpUpdateOne) {
  7164. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7165. }
  7166. if m.id == nil || m.oldValue == nil {
  7167. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7168. }
  7169. oldValue, err := m.oldValue(ctx)
  7170. if err != nil {
  7171. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7172. }
  7173. return oldValue.WxWxid, nil
  7174. }
  7175. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7176. func (m *ContactMutation) ResetWxWxid() {
  7177. m.wx_wxid = nil
  7178. }
  7179. // SetType sets the "type" field.
  7180. func (m *ContactMutation) SetType(i int) {
  7181. m._type = &i
  7182. m.add_type = nil
  7183. }
  7184. // GetType returns the value of the "type" field in the mutation.
  7185. func (m *ContactMutation) GetType() (r int, exists bool) {
  7186. v := m._type
  7187. if v == nil {
  7188. return
  7189. }
  7190. return *v, true
  7191. }
  7192. // OldType returns the old "type" field's value of the Contact entity.
  7193. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7195. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7196. if !m.op.Is(OpUpdateOne) {
  7197. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7198. }
  7199. if m.id == nil || m.oldValue == nil {
  7200. return v, errors.New("OldType requires an ID field in the mutation")
  7201. }
  7202. oldValue, err := m.oldValue(ctx)
  7203. if err != nil {
  7204. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7205. }
  7206. return oldValue.Type, nil
  7207. }
  7208. // AddType adds i to the "type" field.
  7209. func (m *ContactMutation) AddType(i int) {
  7210. if m.add_type != nil {
  7211. *m.add_type += i
  7212. } else {
  7213. m.add_type = &i
  7214. }
  7215. }
  7216. // AddedType returns the value that was added to the "type" field in this mutation.
  7217. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7218. v := m.add_type
  7219. if v == nil {
  7220. return
  7221. }
  7222. return *v, true
  7223. }
  7224. // ClearType clears the value of the "type" field.
  7225. func (m *ContactMutation) ClearType() {
  7226. m._type = nil
  7227. m.add_type = nil
  7228. m.clearedFields[contact.FieldType] = struct{}{}
  7229. }
  7230. // TypeCleared returns if the "type" field was cleared in this mutation.
  7231. func (m *ContactMutation) TypeCleared() bool {
  7232. _, ok := m.clearedFields[contact.FieldType]
  7233. return ok
  7234. }
  7235. // ResetType resets all changes to the "type" field.
  7236. func (m *ContactMutation) ResetType() {
  7237. m._type = nil
  7238. m.add_type = nil
  7239. delete(m.clearedFields, contact.FieldType)
  7240. }
  7241. // SetWxid sets the "wxid" field.
  7242. func (m *ContactMutation) SetWxid(s string) {
  7243. m.wxid = &s
  7244. }
  7245. // Wxid returns the value of the "wxid" field in the mutation.
  7246. func (m *ContactMutation) Wxid() (r string, exists bool) {
  7247. v := m.wxid
  7248. if v == nil {
  7249. return
  7250. }
  7251. return *v, true
  7252. }
  7253. // OldWxid returns the old "wxid" field's value of the Contact entity.
  7254. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7256. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  7257. if !m.op.Is(OpUpdateOne) {
  7258. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  7259. }
  7260. if m.id == nil || m.oldValue == nil {
  7261. return v, errors.New("OldWxid requires an ID field in the mutation")
  7262. }
  7263. oldValue, err := m.oldValue(ctx)
  7264. if err != nil {
  7265. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  7266. }
  7267. return oldValue.Wxid, nil
  7268. }
  7269. // ResetWxid resets all changes to the "wxid" field.
  7270. func (m *ContactMutation) ResetWxid() {
  7271. m.wxid = nil
  7272. }
  7273. // SetAccount sets the "account" field.
  7274. func (m *ContactMutation) SetAccount(s string) {
  7275. m.account = &s
  7276. }
  7277. // Account returns the value of the "account" field in the mutation.
  7278. func (m *ContactMutation) Account() (r string, exists bool) {
  7279. v := m.account
  7280. if v == nil {
  7281. return
  7282. }
  7283. return *v, true
  7284. }
  7285. // OldAccount returns the old "account" field's value of the Contact entity.
  7286. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7288. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  7289. if !m.op.Is(OpUpdateOne) {
  7290. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  7291. }
  7292. if m.id == nil || m.oldValue == nil {
  7293. return v, errors.New("OldAccount requires an ID field in the mutation")
  7294. }
  7295. oldValue, err := m.oldValue(ctx)
  7296. if err != nil {
  7297. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  7298. }
  7299. return oldValue.Account, nil
  7300. }
  7301. // ResetAccount resets all changes to the "account" field.
  7302. func (m *ContactMutation) ResetAccount() {
  7303. m.account = nil
  7304. }
  7305. // SetNickname sets the "nickname" field.
  7306. func (m *ContactMutation) SetNickname(s string) {
  7307. m.nickname = &s
  7308. }
  7309. // Nickname returns the value of the "nickname" field in the mutation.
  7310. func (m *ContactMutation) Nickname() (r string, exists bool) {
  7311. v := m.nickname
  7312. if v == nil {
  7313. return
  7314. }
  7315. return *v, true
  7316. }
  7317. // OldNickname returns the old "nickname" field's value of the Contact entity.
  7318. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7320. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  7321. if !m.op.Is(OpUpdateOne) {
  7322. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  7323. }
  7324. if m.id == nil || m.oldValue == nil {
  7325. return v, errors.New("OldNickname requires an ID field in the mutation")
  7326. }
  7327. oldValue, err := m.oldValue(ctx)
  7328. if err != nil {
  7329. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  7330. }
  7331. return oldValue.Nickname, nil
  7332. }
  7333. // ResetNickname resets all changes to the "nickname" field.
  7334. func (m *ContactMutation) ResetNickname() {
  7335. m.nickname = nil
  7336. }
  7337. // SetMarkname sets the "markname" field.
  7338. func (m *ContactMutation) SetMarkname(s string) {
  7339. m.markname = &s
  7340. }
  7341. // Markname returns the value of the "markname" field in the mutation.
  7342. func (m *ContactMutation) Markname() (r string, exists bool) {
  7343. v := m.markname
  7344. if v == nil {
  7345. return
  7346. }
  7347. return *v, true
  7348. }
  7349. // OldMarkname returns the old "markname" field's value of the Contact entity.
  7350. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7352. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  7353. if !m.op.Is(OpUpdateOne) {
  7354. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  7355. }
  7356. if m.id == nil || m.oldValue == nil {
  7357. return v, errors.New("OldMarkname requires an ID field in the mutation")
  7358. }
  7359. oldValue, err := m.oldValue(ctx)
  7360. if err != nil {
  7361. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  7362. }
  7363. return oldValue.Markname, nil
  7364. }
  7365. // ResetMarkname resets all changes to the "markname" field.
  7366. func (m *ContactMutation) ResetMarkname() {
  7367. m.markname = nil
  7368. }
  7369. // SetHeadimg sets the "headimg" field.
  7370. func (m *ContactMutation) SetHeadimg(s string) {
  7371. m.headimg = &s
  7372. }
  7373. // Headimg returns the value of the "headimg" field in the mutation.
  7374. func (m *ContactMutation) Headimg() (r string, exists bool) {
  7375. v := m.headimg
  7376. if v == nil {
  7377. return
  7378. }
  7379. return *v, true
  7380. }
  7381. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  7382. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7384. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  7385. if !m.op.Is(OpUpdateOne) {
  7386. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  7387. }
  7388. if m.id == nil || m.oldValue == nil {
  7389. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  7390. }
  7391. oldValue, err := m.oldValue(ctx)
  7392. if err != nil {
  7393. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  7394. }
  7395. return oldValue.Headimg, nil
  7396. }
  7397. // ResetHeadimg resets all changes to the "headimg" field.
  7398. func (m *ContactMutation) ResetHeadimg() {
  7399. m.headimg = nil
  7400. }
  7401. // SetSex sets the "sex" field.
  7402. func (m *ContactMutation) SetSex(i int) {
  7403. m.sex = &i
  7404. m.addsex = nil
  7405. }
  7406. // Sex returns the value of the "sex" field in the mutation.
  7407. func (m *ContactMutation) Sex() (r int, exists bool) {
  7408. v := m.sex
  7409. if v == nil {
  7410. return
  7411. }
  7412. return *v, true
  7413. }
  7414. // OldSex returns the old "sex" field's value of the Contact entity.
  7415. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7417. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  7418. if !m.op.Is(OpUpdateOne) {
  7419. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  7420. }
  7421. if m.id == nil || m.oldValue == nil {
  7422. return v, errors.New("OldSex requires an ID field in the mutation")
  7423. }
  7424. oldValue, err := m.oldValue(ctx)
  7425. if err != nil {
  7426. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  7427. }
  7428. return oldValue.Sex, nil
  7429. }
  7430. // AddSex adds i to the "sex" field.
  7431. func (m *ContactMutation) AddSex(i int) {
  7432. if m.addsex != nil {
  7433. *m.addsex += i
  7434. } else {
  7435. m.addsex = &i
  7436. }
  7437. }
  7438. // AddedSex returns the value that was added to the "sex" field in this mutation.
  7439. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  7440. v := m.addsex
  7441. if v == nil {
  7442. return
  7443. }
  7444. return *v, true
  7445. }
  7446. // ResetSex resets all changes to the "sex" field.
  7447. func (m *ContactMutation) ResetSex() {
  7448. m.sex = nil
  7449. m.addsex = nil
  7450. }
  7451. // SetStarrole sets the "starrole" field.
  7452. func (m *ContactMutation) SetStarrole(s string) {
  7453. m.starrole = &s
  7454. }
  7455. // Starrole returns the value of the "starrole" field in the mutation.
  7456. func (m *ContactMutation) Starrole() (r string, exists bool) {
  7457. v := m.starrole
  7458. if v == nil {
  7459. return
  7460. }
  7461. return *v, true
  7462. }
  7463. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  7464. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7466. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  7467. if !m.op.Is(OpUpdateOne) {
  7468. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  7469. }
  7470. if m.id == nil || m.oldValue == nil {
  7471. return v, errors.New("OldStarrole requires an ID field in the mutation")
  7472. }
  7473. oldValue, err := m.oldValue(ctx)
  7474. if err != nil {
  7475. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  7476. }
  7477. return oldValue.Starrole, nil
  7478. }
  7479. // ResetStarrole resets all changes to the "starrole" field.
  7480. func (m *ContactMutation) ResetStarrole() {
  7481. m.starrole = nil
  7482. }
  7483. // SetDontseeit sets the "dontseeit" field.
  7484. func (m *ContactMutation) SetDontseeit(i int) {
  7485. m.dontseeit = &i
  7486. m.adddontseeit = nil
  7487. }
  7488. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  7489. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  7490. v := m.dontseeit
  7491. if v == nil {
  7492. return
  7493. }
  7494. return *v, true
  7495. }
  7496. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  7497. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7499. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  7500. if !m.op.Is(OpUpdateOne) {
  7501. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  7502. }
  7503. if m.id == nil || m.oldValue == nil {
  7504. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  7505. }
  7506. oldValue, err := m.oldValue(ctx)
  7507. if err != nil {
  7508. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  7509. }
  7510. return oldValue.Dontseeit, nil
  7511. }
  7512. // AddDontseeit adds i to the "dontseeit" field.
  7513. func (m *ContactMutation) AddDontseeit(i int) {
  7514. if m.adddontseeit != nil {
  7515. *m.adddontseeit += i
  7516. } else {
  7517. m.adddontseeit = &i
  7518. }
  7519. }
  7520. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  7521. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  7522. v := m.adddontseeit
  7523. if v == nil {
  7524. return
  7525. }
  7526. return *v, true
  7527. }
  7528. // ResetDontseeit resets all changes to the "dontseeit" field.
  7529. func (m *ContactMutation) ResetDontseeit() {
  7530. m.dontseeit = nil
  7531. m.adddontseeit = nil
  7532. }
  7533. // SetDontseeme sets the "dontseeme" field.
  7534. func (m *ContactMutation) SetDontseeme(i int) {
  7535. m.dontseeme = &i
  7536. m.adddontseeme = nil
  7537. }
  7538. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  7539. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  7540. v := m.dontseeme
  7541. if v == nil {
  7542. return
  7543. }
  7544. return *v, true
  7545. }
  7546. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  7547. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7549. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  7550. if !m.op.Is(OpUpdateOne) {
  7551. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  7552. }
  7553. if m.id == nil || m.oldValue == nil {
  7554. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  7555. }
  7556. oldValue, err := m.oldValue(ctx)
  7557. if err != nil {
  7558. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  7559. }
  7560. return oldValue.Dontseeme, nil
  7561. }
  7562. // AddDontseeme adds i to the "dontseeme" field.
  7563. func (m *ContactMutation) AddDontseeme(i int) {
  7564. if m.adddontseeme != nil {
  7565. *m.adddontseeme += i
  7566. } else {
  7567. m.adddontseeme = &i
  7568. }
  7569. }
  7570. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  7571. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  7572. v := m.adddontseeme
  7573. if v == nil {
  7574. return
  7575. }
  7576. return *v, true
  7577. }
  7578. // ResetDontseeme resets all changes to the "dontseeme" field.
  7579. func (m *ContactMutation) ResetDontseeme() {
  7580. m.dontseeme = nil
  7581. m.adddontseeme = nil
  7582. }
  7583. // SetLag sets the "lag" field.
  7584. func (m *ContactMutation) SetLag(s string) {
  7585. m.lag = &s
  7586. }
  7587. // Lag returns the value of the "lag" field in the mutation.
  7588. func (m *ContactMutation) Lag() (r string, exists bool) {
  7589. v := m.lag
  7590. if v == nil {
  7591. return
  7592. }
  7593. return *v, true
  7594. }
  7595. // OldLag returns the old "lag" field's value of the Contact entity.
  7596. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7598. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  7599. if !m.op.Is(OpUpdateOne) {
  7600. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  7601. }
  7602. if m.id == nil || m.oldValue == nil {
  7603. return v, errors.New("OldLag requires an ID field in the mutation")
  7604. }
  7605. oldValue, err := m.oldValue(ctx)
  7606. if err != nil {
  7607. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  7608. }
  7609. return oldValue.Lag, nil
  7610. }
  7611. // ResetLag resets all changes to the "lag" field.
  7612. func (m *ContactMutation) ResetLag() {
  7613. m.lag = nil
  7614. }
  7615. // SetGid sets the "gid" field.
  7616. func (m *ContactMutation) SetGid(s string) {
  7617. m.gid = &s
  7618. }
  7619. // Gid returns the value of the "gid" field in the mutation.
  7620. func (m *ContactMutation) Gid() (r string, exists bool) {
  7621. v := m.gid
  7622. if v == nil {
  7623. return
  7624. }
  7625. return *v, true
  7626. }
  7627. // OldGid returns the old "gid" field's value of the Contact entity.
  7628. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7630. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  7631. if !m.op.Is(OpUpdateOne) {
  7632. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  7633. }
  7634. if m.id == nil || m.oldValue == nil {
  7635. return v, errors.New("OldGid requires an ID field in the mutation")
  7636. }
  7637. oldValue, err := m.oldValue(ctx)
  7638. if err != nil {
  7639. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  7640. }
  7641. return oldValue.Gid, nil
  7642. }
  7643. // ResetGid resets all changes to the "gid" field.
  7644. func (m *ContactMutation) ResetGid() {
  7645. m.gid = nil
  7646. }
  7647. // SetGname sets the "gname" field.
  7648. func (m *ContactMutation) SetGname(s string) {
  7649. m.gname = &s
  7650. }
  7651. // Gname returns the value of the "gname" field in the mutation.
  7652. func (m *ContactMutation) Gname() (r string, exists bool) {
  7653. v := m.gname
  7654. if v == nil {
  7655. return
  7656. }
  7657. return *v, true
  7658. }
  7659. // OldGname returns the old "gname" field's value of the Contact entity.
  7660. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7662. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  7663. if !m.op.Is(OpUpdateOne) {
  7664. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  7665. }
  7666. if m.id == nil || m.oldValue == nil {
  7667. return v, errors.New("OldGname requires an ID field in the mutation")
  7668. }
  7669. oldValue, err := m.oldValue(ctx)
  7670. if err != nil {
  7671. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  7672. }
  7673. return oldValue.Gname, nil
  7674. }
  7675. // ResetGname resets all changes to the "gname" field.
  7676. func (m *ContactMutation) ResetGname() {
  7677. m.gname = nil
  7678. }
  7679. // SetV3 sets the "v3" field.
  7680. func (m *ContactMutation) SetV3(s string) {
  7681. m.v3 = &s
  7682. }
  7683. // V3 returns the value of the "v3" field in the mutation.
  7684. func (m *ContactMutation) V3() (r string, exists bool) {
  7685. v := m.v3
  7686. if v == nil {
  7687. return
  7688. }
  7689. return *v, true
  7690. }
  7691. // OldV3 returns the old "v3" field's value of the Contact entity.
  7692. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7694. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  7695. if !m.op.Is(OpUpdateOne) {
  7696. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  7697. }
  7698. if m.id == nil || m.oldValue == nil {
  7699. return v, errors.New("OldV3 requires an ID field in the mutation")
  7700. }
  7701. oldValue, err := m.oldValue(ctx)
  7702. if err != nil {
  7703. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  7704. }
  7705. return oldValue.V3, nil
  7706. }
  7707. // ResetV3 resets all changes to the "v3" field.
  7708. func (m *ContactMutation) ResetV3() {
  7709. m.v3 = nil
  7710. }
  7711. // SetOrganizationID sets the "organization_id" field.
  7712. func (m *ContactMutation) SetOrganizationID(u uint64) {
  7713. m.organization_id = &u
  7714. m.addorganization_id = nil
  7715. }
  7716. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7717. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  7718. v := m.organization_id
  7719. if v == nil {
  7720. return
  7721. }
  7722. return *v, true
  7723. }
  7724. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  7725. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7727. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7728. if !m.op.Is(OpUpdateOne) {
  7729. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7730. }
  7731. if m.id == nil || m.oldValue == nil {
  7732. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7733. }
  7734. oldValue, err := m.oldValue(ctx)
  7735. if err != nil {
  7736. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7737. }
  7738. return oldValue.OrganizationID, nil
  7739. }
  7740. // AddOrganizationID adds u to the "organization_id" field.
  7741. func (m *ContactMutation) AddOrganizationID(u int64) {
  7742. if m.addorganization_id != nil {
  7743. *m.addorganization_id += u
  7744. } else {
  7745. m.addorganization_id = &u
  7746. }
  7747. }
  7748. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7749. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  7750. v := m.addorganization_id
  7751. if v == nil {
  7752. return
  7753. }
  7754. return *v, true
  7755. }
  7756. // ClearOrganizationID clears the value of the "organization_id" field.
  7757. func (m *ContactMutation) ClearOrganizationID() {
  7758. m.organization_id = nil
  7759. m.addorganization_id = nil
  7760. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  7761. }
  7762. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7763. func (m *ContactMutation) OrganizationIDCleared() bool {
  7764. _, ok := m.clearedFields[contact.FieldOrganizationID]
  7765. return ok
  7766. }
  7767. // ResetOrganizationID resets all changes to the "organization_id" field.
  7768. func (m *ContactMutation) ResetOrganizationID() {
  7769. m.organization_id = nil
  7770. m.addorganization_id = nil
  7771. delete(m.clearedFields, contact.FieldOrganizationID)
  7772. }
  7773. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  7774. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  7775. if m.contact_relationships == nil {
  7776. m.contact_relationships = make(map[uint64]struct{})
  7777. }
  7778. for i := range ids {
  7779. m.contact_relationships[ids[i]] = struct{}{}
  7780. }
  7781. }
  7782. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  7783. func (m *ContactMutation) ClearContactRelationships() {
  7784. m.clearedcontact_relationships = true
  7785. }
  7786. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  7787. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  7788. return m.clearedcontact_relationships
  7789. }
  7790. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  7791. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  7792. if m.removedcontact_relationships == nil {
  7793. m.removedcontact_relationships = make(map[uint64]struct{})
  7794. }
  7795. for i := range ids {
  7796. delete(m.contact_relationships, ids[i])
  7797. m.removedcontact_relationships[ids[i]] = struct{}{}
  7798. }
  7799. }
  7800. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  7801. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  7802. for id := range m.removedcontact_relationships {
  7803. ids = append(ids, id)
  7804. }
  7805. return
  7806. }
  7807. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  7808. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  7809. for id := range m.contact_relationships {
  7810. ids = append(ids, id)
  7811. }
  7812. return
  7813. }
  7814. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  7815. func (m *ContactMutation) ResetContactRelationships() {
  7816. m.contact_relationships = nil
  7817. m.clearedcontact_relationships = false
  7818. m.removedcontact_relationships = nil
  7819. }
  7820. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  7821. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  7822. if m.contact_messages == nil {
  7823. m.contact_messages = make(map[uint64]struct{})
  7824. }
  7825. for i := range ids {
  7826. m.contact_messages[ids[i]] = struct{}{}
  7827. }
  7828. }
  7829. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  7830. func (m *ContactMutation) ClearContactMessages() {
  7831. m.clearedcontact_messages = true
  7832. }
  7833. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  7834. func (m *ContactMutation) ContactMessagesCleared() bool {
  7835. return m.clearedcontact_messages
  7836. }
  7837. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  7838. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  7839. if m.removedcontact_messages == nil {
  7840. m.removedcontact_messages = make(map[uint64]struct{})
  7841. }
  7842. for i := range ids {
  7843. delete(m.contact_messages, ids[i])
  7844. m.removedcontact_messages[ids[i]] = struct{}{}
  7845. }
  7846. }
  7847. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  7848. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  7849. for id := range m.removedcontact_messages {
  7850. ids = append(ids, id)
  7851. }
  7852. return
  7853. }
  7854. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  7855. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  7856. for id := range m.contact_messages {
  7857. ids = append(ids, id)
  7858. }
  7859. return
  7860. }
  7861. // ResetContactMessages resets all changes to the "contact_messages" edge.
  7862. func (m *ContactMutation) ResetContactMessages() {
  7863. m.contact_messages = nil
  7864. m.clearedcontact_messages = false
  7865. m.removedcontact_messages = nil
  7866. }
  7867. // Where appends a list predicates to the ContactMutation builder.
  7868. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  7869. m.predicates = append(m.predicates, ps...)
  7870. }
  7871. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  7872. // users can use type-assertion to append predicates that do not depend on any generated package.
  7873. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  7874. p := make([]predicate.Contact, len(ps))
  7875. for i := range ps {
  7876. p[i] = ps[i]
  7877. }
  7878. m.Where(p...)
  7879. }
  7880. // Op returns the operation name.
  7881. func (m *ContactMutation) Op() Op {
  7882. return m.op
  7883. }
  7884. // SetOp allows setting the mutation operation.
  7885. func (m *ContactMutation) SetOp(op Op) {
  7886. m.op = op
  7887. }
  7888. // Type returns the node type of this mutation (Contact).
  7889. func (m *ContactMutation) Type() string {
  7890. return m.typ
  7891. }
  7892. // Fields returns all fields that were changed during this mutation. Note that in
  7893. // order to get all numeric fields that were incremented/decremented, call
  7894. // AddedFields().
  7895. func (m *ContactMutation) Fields() []string {
  7896. fields := make([]string, 0, 20)
  7897. if m.created_at != nil {
  7898. fields = append(fields, contact.FieldCreatedAt)
  7899. }
  7900. if m.updated_at != nil {
  7901. fields = append(fields, contact.FieldUpdatedAt)
  7902. }
  7903. if m.status != nil {
  7904. fields = append(fields, contact.FieldStatus)
  7905. }
  7906. if m.deleted_at != nil {
  7907. fields = append(fields, contact.FieldDeletedAt)
  7908. }
  7909. if m.wx_wxid != nil {
  7910. fields = append(fields, contact.FieldWxWxid)
  7911. }
  7912. if m._type != nil {
  7913. fields = append(fields, contact.FieldType)
  7914. }
  7915. if m.wxid != nil {
  7916. fields = append(fields, contact.FieldWxid)
  7917. }
  7918. if m.account != nil {
  7919. fields = append(fields, contact.FieldAccount)
  7920. }
  7921. if m.nickname != nil {
  7922. fields = append(fields, contact.FieldNickname)
  7923. }
  7924. if m.markname != nil {
  7925. fields = append(fields, contact.FieldMarkname)
  7926. }
  7927. if m.headimg != nil {
  7928. fields = append(fields, contact.FieldHeadimg)
  7929. }
  7930. if m.sex != nil {
  7931. fields = append(fields, contact.FieldSex)
  7932. }
  7933. if m.starrole != nil {
  7934. fields = append(fields, contact.FieldStarrole)
  7935. }
  7936. if m.dontseeit != nil {
  7937. fields = append(fields, contact.FieldDontseeit)
  7938. }
  7939. if m.dontseeme != nil {
  7940. fields = append(fields, contact.FieldDontseeme)
  7941. }
  7942. if m.lag != nil {
  7943. fields = append(fields, contact.FieldLag)
  7944. }
  7945. if m.gid != nil {
  7946. fields = append(fields, contact.FieldGid)
  7947. }
  7948. if m.gname != nil {
  7949. fields = append(fields, contact.FieldGname)
  7950. }
  7951. if m.v3 != nil {
  7952. fields = append(fields, contact.FieldV3)
  7953. }
  7954. if m.organization_id != nil {
  7955. fields = append(fields, contact.FieldOrganizationID)
  7956. }
  7957. return fields
  7958. }
  7959. // Field returns the value of a field with the given name. The second boolean
  7960. // return value indicates that this field was not set, or was not defined in the
  7961. // schema.
  7962. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  7963. switch name {
  7964. case contact.FieldCreatedAt:
  7965. return m.CreatedAt()
  7966. case contact.FieldUpdatedAt:
  7967. return m.UpdatedAt()
  7968. case contact.FieldStatus:
  7969. return m.Status()
  7970. case contact.FieldDeletedAt:
  7971. return m.DeletedAt()
  7972. case contact.FieldWxWxid:
  7973. return m.WxWxid()
  7974. case contact.FieldType:
  7975. return m.GetType()
  7976. case contact.FieldWxid:
  7977. return m.Wxid()
  7978. case contact.FieldAccount:
  7979. return m.Account()
  7980. case contact.FieldNickname:
  7981. return m.Nickname()
  7982. case contact.FieldMarkname:
  7983. return m.Markname()
  7984. case contact.FieldHeadimg:
  7985. return m.Headimg()
  7986. case contact.FieldSex:
  7987. return m.Sex()
  7988. case contact.FieldStarrole:
  7989. return m.Starrole()
  7990. case contact.FieldDontseeit:
  7991. return m.Dontseeit()
  7992. case contact.FieldDontseeme:
  7993. return m.Dontseeme()
  7994. case contact.FieldLag:
  7995. return m.Lag()
  7996. case contact.FieldGid:
  7997. return m.Gid()
  7998. case contact.FieldGname:
  7999. return m.Gname()
  8000. case contact.FieldV3:
  8001. return m.V3()
  8002. case contact.FieldOrganizationID:
  8003. return m.OrganizationID()
  8004. }
  8005. return nil, false
  8006. }
  8007. // OldField returns the old value of the field from the database. An error is
  8008. // returned if the mutation operation is not UpdateOne, or the query to the
  8009. // database failed.
  8010. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8011. switch name {
  8012. case contact.FieldCreatedAt:
  8013. return m.OldCreatedAt(ctx)
  8014. case contact.FieldUpdatedAt:
  8015. return m.OldUpdatedAt(ctx)
  8016. case contact.FieldStatus:
  8017. return m.OldStatus(ctx)
  8018. case contact.FieldDeletedAt:
  8019. return m.OldDeletedAt(ctx)
  8020. case contact.FieldWxWxid:
  8021. return m.OldWxWxid(ctx)
  8022. case contact.FieldType:
  8023. return m.OldType(ctx)
  8024. case contact.FieldWxid:
  8025. return m.OldWxid(ctx)
  8026. case contact.FieldAccount:
  8027. return m.OldAccount(ctx)
  8028. case contact.FieldNickname:
  8029. return m.OldNickname(ctx)
  8030. case contact.FieldMarkname:
  8031. return m.OldMarkname(ctx)
  8032. case contact.FieldHeadimg:
  8033. return m.OldHeadimg(ctx)
  8034. case contact.FieldSex:
  8035. return m.OldSex(ctx)
  8036. case contact.FieldStarrole:
  8037. return m.OldStarrole(ctx)
  8038. case contact.FieldDontseeit:
  8039. return m.OldDontseeit(ctx)
  8040. case contact.FieldDontseeme:
  8041. return m.OldDontseeme(ctx)
  8042. case contact.FieldLag:
  8043. return m.OldLag(ctx)
  8044. case contact.FieldGid:
  8045. return m.OldGid(ctx)
  8046. case contact.FieldGname:
  8047. return m.OldGname(ctx)
  8048. case contact.FieldV3:
  8049. return m.OldV3(ctx)
  8050. case contact.FieldOrganizationID:
  8051. return m.OldOrganizationID(ctx)
  8052. }
  8053. return nil, fmt.Errorf("unknown Contact field %s", name)
  8054. }
  8055. // SetField sets the value of a field with the given name. It returns an error if
  8056. // the field is not defined in the schema, or if the type mismatched the field
  8057. // type.
  8058. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8059. switch name {
  8060. case contact.FieldCreatedAt:
  8061. v, ok := value.(time.Time)
  8062. if !ok {
  8063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8064. }
  8065. m.SetCreatedAt(v)
  8066. return nil
  8067. case contact.FieldUpdatedAt:
  8068. v, ok := value.(time.Time)
  8069. if !ok {
  8070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8071. }
  8072. m.SetUpdatedAt(v)
  8073. return nil
  8074. case contact.FieldStatus:
  8075. v, ok := value.(uint8)
  8076. if !ok {
  8077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8078. }
  8079. m.SetStatus(v)
  8080. return nil
  8081. case contact.FieldDeletedAt:
  8082. v, ok := value.(time.Time)
  8083. if !ok {
  8084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8085. }
  8086. m.SetDeletedAt(v)
  8087. return nil
  8088. case contact.FieldWxWxid:
  8089. v, ok := value.(string)
  8090. if !ok {
  8091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8092. }
  8093. m.SetWxWxid(v)
  8094. return nil
  8095. case contact.FieldType:
  8096. v, ok := value.(int)
  8097. if !ok {
  8098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8099. }
  8100. m.SetType(v)
  8101. return nil
  8102. case contact.FieldWxid:
  8103. v, ok := value.(string)
  8104. if !ok {
  8105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8106. }
  8107. m.SetWxid(v)
  8108. return nil
  8109. case contact.FieldAccount:
  8110. v, ok := value.(string)
  8111. if !ok {
  8112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8113. }
  8114. m.SetAccount(v)
  8115. return nil
  8116. case contact.FieldNickname:
  8117. v, ok := value.(string)
  8118. if !ok {
  8119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8120. }
  8121. m.SetNickname(v)
  8122. return nil
  8123. case contact.FieldMarkname:
  8124. v, ok := value.(string)
  8125. if !ok {
  8126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8127. }
  8128. m.SetMarkname(v)
  8129. return nil
  8130. case contact.FieldHeadimg:
  8131. v, ok := value.(string)
  8132. if !ok {
  8133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8134. }
  8135. m.SetHeadimg(v)
  8136. return nil
  8137. case contact.FieldSex:
  8138. v, ok := value.(int)
  8139. if !ok {
  8140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8141. }
  8142. m.SetSex(v)
  8143. return nil
  8144. case contact.FieldStarrole:
  8145. v, ok := value.(string)
  8146. if !ok {
  8147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8148. }
  8149. m.SetStarrole(v)
  8150. return nil
  8151. case contact.FieldDontseeit:
  8152. v, ok := value.(int)
  8153. if !ok {
  8154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8155. }
  8156. m.SetDontseeit(v)
  8157. return nil
  8158. case contact.FieldDontseeme:
  8159. v, ok := value.(int)
  8160. if !ok {
  8161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8162. }
  8163. m.SetDontseeme(v)
  8164. return nil
  8165. case contact.FieldLag:
  8166. v, ok := value.(string)
  8167. if !ok {
  8168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8169. }
  8170. m.SetLag(v)
  8171. return nil
  8172. case contact.FieldGid:
  8173. v, ok := value.(string)
  8174. if !ok {
  8175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8176. }
  8177. m.SetGid(v)
  8178. return nil
  8179. case contact.FieldGname:
  8180. v, ok := value.(string)
  8181. if !ok {
  8182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8183. }
  8184. m.SetGname(v)
  8185. return nil
  8186. case contact.FieldV3:
  8187. v, ok := value.(string)
  8188. if !ok {
  8189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8190. }
  8191. m.SetV3(v)
  8192. return nil
  8193. case contact.FieldOrganizationID:
  8194. v, ok := value.(uint64)
  8195. if !ok {
  8196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8197. }
  8198. m.SetOrganizationID(v)
  8199. return nil
  8200. }
  8201. return fmt.Errorf("unknown Contact field %s", name)
  8202. }
  8203. // AddedFields returns all numeric fields that were incremented/decremented during
  8204. // this mutation.
  8205. func (m *ContactMutation) AddedFields() []string {
  8206. var fields []string
  8207. if m.addstatus != nil {
  8208. fields = append(fields, contact.FieldStatus)
  8209. }
  8210. if m.add_type != nil {
  8211. fields = append(fields, contact.FieldType)
  8212. }
  8213. if m.addsex != nil {
  8214. fields = append(fields, contact.FieldSex)
  8215. }
  8216. if m.adddontseeit != nil {
  8217. fields = append(fields, contact.FieldDontseeit)
  8218. }
  8219. if m.adddontseeme != nil {
  8220. fields = append(fields, contact.FieldDontseeme)
  8221. }
  8222. if m.addorganization_id != nil {
  8223. fields = append(fields, contact.FieldOrganizationID)
  8224. }
  8225. return fields
  8226. }
  8227. // AddedField returns the numeric value that was incremented/decremented on a field
  8228. // with the given name. The second boolean return value indicates that this field
  8229. // was not set, or was not defined in the schema.
  8230. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8231. switch name {
  8232. case contact.FieldStatus:
  8233. return m.AddedStatus()
  8234. case contact.FieldType:
  8235. return m.AddedType()
  8236. case contact.FieldSex:
  8237. return m.AddedSex()
  8238. case contact.FieldDontseeit:
  8239. return m.AddedDontseeit()
  8240. case contact.FieldDontseeme:
  8241. return m.AddedDontseeme()
  8242. case contact.FieldOrganizationID:
  8243. return m.AddedOrganizationID()
  8244. }
  8245. return nil, false
  8246. }
  8247. // AddField adds the value to the field with the given name. It returns an error if
  8248. // the field is not defined in the schema, or if the type mismatched the field
  8249. // type.
  8250. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  8251. switch name {
  8252. case contact.FieldStatus:
  8253. v, ok := value.(int8)
  8254. if !ok {
  8255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8256. }
  8257. m.AddStatus(v)
  8258. return nil
  8259. case contact.FieldType:
  8260. v, ok := value.(int)
  8261. if !ok {
  8262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8263. }
  8264. m.AddType(v)
  8265. return nil
  8266. case contact.FieldSex:
  8267. v, ok := value.(int)
  8268. if !ok {
  8269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8270. }
  8271. m.AddSex(v)
  8272. return nil
  8273. case contact.FieldDontseeit:
  8274. v, ok := value.(int)
  8275. if !ok {
  8276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8277. }
  8278. m.AddDontseeit(v)
  8279. return nil
  8280. case contact.FieldDontseeme:
  8281. v, ok := value.(int)
  8282. if !ok {
  8283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8284. }
  8285. m.AddDontseeme(v)
  8286. return nil
  8287. case contact.FieldOrganizationID:
  8288. v, ok := value.(int64)
  8289. if !ok {
  8290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8291. }
  8292. m.AddOrganizationID(v)
  8293. return nil
  8294. }
  8295. return fmt.Errorf("unknown Contact numeric field %s", name)
  8296. }
  8297. // ClearedFields returns all nullable fields that were cleared during this
  8298. // mutation.
  8299. func (m *ContactMutation) ClearedFields() []string {
  8300. var fields []string
  8301. if m.FieldCleared(contact.FieldStatus) {
  8302. fields = append(fields, contact.FieldStatus)
  8303. }
  8304. if m.FieldCleared(contact.FieldDeletedAt) {
  8305. fields = append(fields, contact.FieldDeletedAt)
  8306. }
  8307. if m.FieldCleared(contact.FieldType) {
  8308. fields = append(fields, contact.FieldType)
  8309. }
  8310. if m.FieldCleared(contact.FieldOrganizationID) {
  8311. fields = append(fields, contact.FieldOrganizationID)
  8312. }
  8313. return fields
  8314. }
  8315. // FieldCleared returns a boolean indicating if a field with the given name was
  8316. // cleared in this mutation.
  8317. func (m *ContactMutation) FieldCleared(name string) bool {
  8318. _, ok := m.clearedFields[name]
  8319. return ok
  8320. }
  8321. // ClearField clears the value of the field with the given name. It returns an
  8322. // error if the field is not defined in the schema.
  8323. func (m *ContactMutation) ClearField(name string) error {
  8324. switch name {
  8325. case contact.FieldStatus:
  8326. m.ClearStatus()
  8327. return nil
  8328. case contact.FieldDeletedAt:
  8329. m.ClearDeletedAt()
  8330. return nil
  8331. case contact.FieldType:
  8332. m.ClearType()
  8333. return nil
  8334. case contact.FieldOrganizationID:
  8335. m.ClearOrganizationID()
  8336. return nil
  8337. }
  8338. return fmt.Errorf("unknown Contact nullable field %s", name)
  8339. }
  8340. // ResetField resets all changes in the mutation for the field with the given name.
  8341. // It returns an error if the field is not defined in the schema.
  8342. func (m *ContactMutation) ResetField(name string) error {
  8343. switch name {
  8344. case contact.FieldCreatedAt:
  8345. m.ResetCreatedAt()
  8346. return nil
  8347. case contact.FieldUpdatedAt:
  8348. m.ResetUpdatedAt()
  8349. return nil
  8350. case contact.FieldStatus:
  8351. m.ResetStatus()
  8352. return nil
  8353. case contact.FieldDeletedAt:
  8354. m.ResetDeletedAt()
  8355. return nil
  8356. case contact.FieldWxWxid:
  8357. m.ResetWxWxid()
  8358. return nil
  8359. case contact.FieldType:
  8360. m.ResetType()
  8361. return nil
  8362. case contact.FieldWxid:
  8363. m.ResetWxid()
  8364. return nil
  8365. case contact.FieldAccount:
  8366. m.ResetAccount()
  8367. return nil
  8368. case contact.FieldNickname:
  8369. m.ResetNickname()
  8370. return nil
  8371. case contact.FieldMarkname:
  8372. m.ResetMarkname()
  8373. return nil
  8374. case contact.FieldHeadimg:
  8375. m.ResetHeadimg()
  8376. return nil
  8377. case contact.FieldSex:
  8378. m.ResetSex()
  8379. return nil
  8380. case contact.FieldStarrole:
  8381. m.ResetStarrole()
  8382. return nil
  8383. case contact.FieldDontseeit:
  8384. m.ResetDontseeit()
  8385. return nil
  8386. case contact.FieldDontseeme:
  8387. m.ResetDontseeme()
  8388. return nil
  8389. case contact.FieldLag:
  8390. m.ResetLag()
  8391. return nil
  8392. case contact.FieldGid:
  8393. m.ResetGid()
  8394. return nil
  8395. case contact.FieldGname:
  8396. m.ResetGname()
  8397. return nil
  8398. case contact.FieldV3:
  8399. m.ResetV3()
  8400. return nil
  8401. case contact.FieldOrganizationID:
  8402. m.ResetOrganizationID()
  8403. return nil
  8404. }
  8405. return fmt.Errorf("unknown Contact field %s", name)
  8406. }
  8407. // AddedEdges returns all edge names that were set/added in this mutation.
  8408. func (m *ContactMutation) AddedEdges() []string {
  8409. edges := make([]string, 0, 2)
  8410. if m.contact_relationships != nil {
  8411. edges = append(edges, contact.EdgeContactRelationships)
  8412. }
  8413. if m.contact_messages != nil {
  8414. edges = append(edges, contact.EdgeContactMessages)
  8415. }
  8416. return edges
  8417. }
  8418. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8419. // name in this mutation.
  8420. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  8421. switch name {
  8422. case contact.EdgeContactRelationships:
  8423. ids := make([]ent.Value, 0, len(m.contact_relationships))
  8424. for id := range m.contact_relationships {
  8425. ids = append(ids, id)
  8426. }
  8427. return ids
  8428. case contact.EdgeContactMessages:
  8429. ids := make([]ent.Value, 0, len(m.contact_messages))
  8430. for id := range m.contact_messages {
  8431. ids = append(ids, id)
  8432. }
  8433. return ids
  8434. }
  8435. return nil
  8436. }
  8437. // RemovedEdges returns all edge names that were removed in this mutation.
  8438. func (m *ContactMutation) RemovedEdges() []string {
  8439. edges := make([]string, 0, 2)
  8440. if m.removedcontact_relationships != nil {
  8441. edges = append(edges, contact.EdgeContactRelationships)
  8442. }
  8443. if m.removedcontact_messages != nil {
  8444. edges = append(edges, contact.EdgeContactMessages)
  8445. }
  8446. return edges
  8447. }
  8448. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8449. // the given name in this mutation.
  8450. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  8451. switch name {
  8452. case contact.EdgeContactRelationships:
  8453. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  8454. for id := range m.removedcontact_relationships {
  8455. ids = append(ids, id)
  8456. }
  8457. return ids
  8458. case contact.EdgeContactMessages:
  8459. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  8460. for id := range m.removedcontact_messages {
  8461. ids = append(ids, id)
  8462. }
  8463. return ids
  8464. }
  8465. return nil
  8466. }
  8467. // ClearedEdges returns all edge names that were cleared in this mutation.
  8468. func (m *ContactMutation) ClearedEdges() []string {
  8469. edges := make([]string, 0, 2)
  8470. if m.clearedcontact_relationships {
  8471. edges = append(edges, contact.EdgeContactRelationships)
  8472. }
  8473. if m.clearedcontact_messages {
  8474. edges = append(edges, contact.EdgeContactMessages)
  8475. }
  8476. return edges
  8477. }
  8478. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8479. // was cleared in this mutation.
  8480. func (m *ContactMutation) EdgeCleared(name string) bool {
  8481. switch name {
  8482. case contact.EdgeContactRelationships:
  8483. return m.clearedcontact_relationships
  8484. case contact.EdgeContactMessages:
  8485. return m.clearedcontact_messages
  8486. }
  8487. return false
  8488. }
  8489. // ClearEdge clears the value of the edge with the given name. It returns an error
  8490. // if that edge is not defined in the schema.
  8491. func (m *ContactMutation) ClearEdge(name string) error {
  8492. switch name {
  8493. }
  8494. return fmt.Errorf("unknown Contact unique edge %s", name)
  8495. }
  8496. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8497. // It returns an error if the edge is not defined in the schema.
  8498. func (m *ContactMutation) ResetEdge(name string) error {
  8499. switch name {
  8500. case contact.EdgeContactRelationships:
  8501. m.ResetContactRelationships()
  8502. return nil
  8503. case contact.EdgeContactMessages:
  8504. m.ResetContactMessages()
  8505. return nil
  8506. }
  8507. return fmt.Errorf("unknown Contact edge %s", name)
  8508. }
  8509. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  8510. type EmployeeMutation struct {
  8511. config
  8512. op Op
  8513. typ string
  8514. id *uint64
  8515. created_at *time.Time
  8516. updated_at *time.Time
  8517. deleted_at *time.Time
  8518. title *string
  8519. avatar *string
  8520. tags *string
  8521. hire_count *int
  8522. addhire_count *int
  8523. service_count *int
  8524. addservice_count *int
  8525. achievement_count *int
  8526. addachievement_count *int
  8527. intro *string
  8528. estimate *string
  8529. skill *string
  8530. ability_type *string
  8531. scene *string
  8532. switch_in *string
  8533. video_url *string
  8534. organization_id *uint64
  8535. addorganization_id *int64
  8536. category_id *uint64
  8537. addcategory_id *int64
  8538. api_base *string
  8539. api_key *string
  8540. ai_info *string
  8541. is_vip *int
  8542. addis_vip *int
  8543. chat_url *string
  8544. clearedFields map[string]struct{}
  8545. em_work_experiences map[uint64]struct{}
  8546. removedem_work_experiences map[uint64]struct{}
  8547. clearedem_work_experiences bool
  8548. em_tutorial map[uint64]struct{}
  8549. removedem_tutorial map[uint64]struct{}
  8550. clearedem_tutorial bool
  8551. done bool
  8552. oldValue func(context.Context) (*Employee, error)
  8553. predicates []predicate.Employee
  8554. }
  8555. var _ ent.Mutation = (*EmployeeMutation)(nil)
  8556. // employeeOption allows management of the mutation configuration using functional options.
  8557. type employeeOption func(*EmployeeMutation)
  8558. // newEmployeeMutation creates new mutation for the Employee entity.
  8559. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  8560. m := &EmployeeMutation{
  8561. config: c,
  8562. op: op,
  8563. typ: TypeEmployee,
  8564. clearedFields: make(map[string]struct{}),
  8565. }
  8566. for _, opt := range opts {
  8567. opt(m)
  8568. }
  8569. return m
  8570. }
  8571. // withEmployeeID sets the ID field of the mutation.
  8572. func withEmployeeID(id uint64) employeeOption {
  8573. return func(m *EmployeeMutation) {
  8574. var (
  8575. err error
  8576. once sync.Once
  8577. value *Employee
  8578. )
  8579. m.oldValue = func(ctx context.Context) (*Employee, error) {
  8580. once.Do(func() {
  8581. if m.done {
  8582. err = errors.New("querying old values post mutation is not allowed")
  8583. } else {
  8584. value, err = m.Client().Employee.Get(ctx, id)
  8585. }
  8586. })
  8587. return value, err
  8588. }
  8589. m.id = &id
  8590. }
  8591. }
  8592. // withEmployee sets the old Employee of the mutation.
  8593. func withEmployee(node *Employee) employeeOption {
  8594. return func(m *EmployeeMutation) {
  8595. m.oldValue = func(context.Context) (*Employee, error) {
  8596. return node, nil
  8597. }
  8598. m.id = &node.ID
  8599. }
  8600. }
  8601. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8602. // executed in a transaction (ent.Tx), a transactional client is returned.
  8603. func (m EmployeeMutation) Client() *Client {
  8604. client := &Client{config: m.config}
  8605. client.init()
  8606. return client
  8607. }
  8608. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8609. // it returns an error otherwise.
  8610. func (m EmployeeMutation) Tx() (*Tx, error) {
  8611. if _, ok := m.driver.(*txDriver); !ok {
  8612. return nil, errors.New("ent: mutation is not running in a transaction")
  8613. }
  8614. tx := &Tx{config: m.config}
  8615. tx.init()
  8616. return tx, nil
  8617. }
  8618. // SetID sets the value of the id field. Note that this
  8619. // operation is only accepted on creation of Employee entities.
  8620. func (m *EmployeeMutation) SetID(id uint64) {
  8621. m.id = &id
  8622. }
  8623. // ID returns the ID value in the mutation. Note that the ID is only available
  8624. // if it was provided to the builder or after it was returned from the database.
  8625. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  8626. if m.id == nil {
  8627. return
  8628. }
  8629. return *m.id, true
  8630. }
  8631. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8632. // That means, if the mutation is applied within a transaction with an isolation level such
  8633. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8634. // or updated by the mutation.
  8635. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  8636. switch {
  8637. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8638. id, exists := m.ID()
  8639. if exists {
  8640. return []uint64{id}, nil
  8641. }
  8642. fallthrough
  8643. case m.op.Is(OpUpdate | OpDelete):
  8644. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  8645. default:
  8646. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8647. }
  8648. }
  8649. // SetCreatedAt sets the "created_at" field.
  8650. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  8651. m.created_at = &t
  8652. }
  8653. // CreatedAt returns the value of the "created_at" field in the mutation.
  8654. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  8655. v := m.created_at
  8656. if v == nil {
  8657. return
  8658. }
  8659. return *v, true
  8660. }
  8661. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  8662. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8664. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8665. if !m.op.Is(OpUpdateOne) {
  8666. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8667. }
  8668. if m.id == nil || m.oldValue == nil {
  8669. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8670. }
  8671. oldValue, err := m.oldValue(ctx)
  8672. if err != nil {
  8673. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8674. }
  8675. return oldValue.CreatedAt, nil
  8676. }
  8677. // ResetCreatedAt resets all changes to the "created_at" field.
  8678. func (m *EmployeeMutation) ResetCreatedAt() {
  8679. m.created_at = nil
  8680. }
  8681. // SetUpdatedAt sets the "updated_at" field.
  8682. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  8683. m.updated_at = &t
  8684. }
  8685. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8686. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  8687. v := m.updated_at
  8688. if v == nil {
  8689. return
  8690. }
  8691. return *v, true
  8692. }
  8693. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  8694. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8696. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8697. if !m.op.Is(OpUpdateOne) {
  8698. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8699. }
  8700. if m.id == nil || m.oldValue == nil {
  8701. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8702. }
  8703. oldValue, err := m.oldValue(ctx)
  8704. if err != nil {
  8705. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8706. }
  8707. return oldValue.UpdatedAt, nil
  8708. }
  8709. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8710. func (m *EmployeeMutation) ResetUpdatedAt() {
  8711. m.updated_at = nil
  8712. }
  8713. // SetDeletedAt sets the "deleted_at" field.
  8714. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  8715. m.deleted_at = &t
  8716. }
  8717. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8718. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  8719. v := m.deleted_at
  8720. if v == nil {
  8721. return
  8722. }
  8723. return *v, true
  8724. }
  8725. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  8726. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8728. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8729. if !m.op.Is(OpUpdateOne) {
  8730. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8731. }
  8732. if m.id == nil || m.oldValue == nil {
  8733. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8734. }
  8735. oldValue, err := m.oldValue(ctx)
  8736. if err != nil {
  8737. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8738. }
  8739. return oldValue.DeletedAt, nil
  8740. }
  8741. // ClearDeletedAt clears the value of the "deleted_at" field.
  8742. func (m *EmployeeMutation) ClearDeletedAt() {
  8743. m.deleted_at = nil
  8744. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  8745. }
  8746. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8747. func (m *EmployeeMutation) DeletedAtCleared() bool {
  8748. _, ok := m.clearedFields[employee.FieldDeletedAt]
  8749. return ok
  8750. }
  8751. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8752. func (m *EmployeeMutation) ResetDeletedAt() {
  8753. m.deleted_at = nil
  8754. delete(m.clearedFields, employee.FieldDeletedAt)
  8755. }
  8756. // SetTitle sets the "title" field.
  8757. func (m *EmployeeMutation) SetTitle(s string) {
  8758. m.title = &s
  8759. }
  8760. // Title returns the value of the "title" field in the mutation.
  8761. func (m *EmployeeMutation) Title() (r string, exists bool) {
  8762. v := m.title
  8763. if v == nil {
  8764. return
  8765. }
  8766. return *v, true
  8767. }
  8768. // OldTitle returns the old "title" field's value of the Employee entity.
  8769. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8771. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  8772. if !m.op.Is(OpUpdateOne) {
  8773. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  8774. }
  8775. if m.id == nil || m.oldValue == nil {
  8776. return v, errors.New("OldTitle requires an ID field in the mutation")
  8777. }
  8778. oldValue, err := m.oldValue(ctx)
  8779. if err != nil {
  8780. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  8781. }
  8782. return oldValue.Title, nil
  8783. }
  8784. // ResetTitle resets all changes to the "title" field.
  8785. func (m *EmployeeMutation) ResetTitle() {
  8786. m.title = nil
  8787. }
  8788. // SetAvatar sets the "avatar" field.
  8789. func (m *EmployeeMutation) SetAvatar(s string) {
  8790. m.avatar = &s
  8791. }
  8792. // Avatar returns the value of the "avatar" field in the mutation.
  8793. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  8794. v := m.avatar
  8795. if v == nil {
  8796. return
  8797. }
  8798. return *v, true
  8799. }
  8800. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  8801. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8803. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  8804. if !m.op.Is(OpUpdateOne) {
  8805. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  8806. }
  8807. if m.id == nil || m.oldValue == nil {
  8808. return v, errors.New("OldAvatar requires an ID field in the mutation")
  8809. }
  8810. oldValue, err := m.oldValue(ctx)
  8811. if err != nil {
  8812. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  8813. }
  8814. return oldValue.Avatar, nil
  8815. }
  8816. // ResetAvatar resets all changes to the "avatar" field.
  8817. func (m *EmployeeMutation) ResetAvatar() {
  8818. m.avatar = nil
  8819. }
  8820. // SetTags sets the "tags" field.
  8821. func (m *EmployeeMutation) SetTags(s string) {
  8822. m.tags = &s
  8823. }
  8824. // Tags returns the value of the "tags" field in the mutation.
  8825. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  8826. v := m.tags
  8827. if v == nil {
  8828. return
  8829. }
  8830. return *v, true
  8831. }
  8832. // OldTags returns the old "tags" field's value of the Employee entity.
  8833. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8835. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  8836. if !m.op.Is(OpUpdateOne) {
  8837. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  8838. }
  8839. if m.id == nil || m.oldValue == nil {
  8840. return v, errors.New("OldTags requires an ID field in the mutation")
  8841. }
  8842. oldValue, err := m.oldValue(ctx)
  8843. if err != nil {
  8844. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  8845. }
  8846. return oldValue.Tags, nil
  8847. }
  8848. // ResetTags resets all changes to the "tags" field.
  8849. func (m *EmployeeMutation) ResetTags() {
  8850. m.tags = nil
  8851. }
  8852. // SetHireCount sets the "hire_count" field.
  8853. func (m *EmployeeMutation) SetHireCount(i int) {
  8854. m.hire_count = &i
  8855. m.addhire_count = nil
  8856. }
  8857. // HireCount returns the value of the "hire_count" field in the mutation.
  8858. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  8859. v := m.hire_count
  8860. if v == nil {
  8861. return
  8862. }
  8863. return *v, true
  8864. }
  8865. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  8866. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8868. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  8869. if !m.op.Is(OpUpdateOne) {
  8870. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  8871. }
  8872. if m.id == nil || m.oldValue == nil {
  8873. return v, errors.New("OldHireCount requires an ID field in the mutation")
  8874. }
  8875. oldValue, err := m.oldValue(ctx)
  8876. if err != nil {
  8877. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  8878. }
  8879. return oldValue.HireCount, nil
  8880. }
  8881. // AddHireCount adds i to the "hire_count" field.
  8882. func (m *EmployeeMutation) AddHireCount(i int) {
  8883. if m.addhire_count != nil {
  8884. *m.addhire_count += i
  8885. } else {
  8886. m.addhire_count = &i
  8887. }
  8888. }
  8889. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  8890. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  8891. v := m.addhire_count
  8892. if v == nil {
  8893. return
  8894. }
  8895. return *v, true
  8896. }
  8897. // ResetHireCount resets all changes to the "hire_count" field.
  8898. func (m *EmployeeMutation) ResetHireCount() {
  8899. m.hire_count = nil
  8900. m.addhire_count = nil
  8901. }
  8902. // SetServiceCount sets the "service_count" field.
  8903. func (m *EmployeeMutation) SetServiceCount(i int) {
  8904. m.service_count = &i
  8905. m.addservice_count = nil
  8906. }
  8907. // ServiceCount returns the value of the "service_count" field in the mutation.
  8908. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  8909. v := m.service_count
  8910. if v == nil {
  8911. return
  8912. }
  8913. return *v, true
  8914. }
  8915. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  8916. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8918. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  8919. if !m.op.Is(OpUpdateOne) {
  8920. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  8921. }
  8922. if m.id == nil || m.oldValue == nil {
  8923. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  8924. }
  8925. oldValue, err := m.oldValue(ctx)
  8926. if err != nil {
  8927. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  8928. }
  8929. return oldValue.ServiceCount, nil
  8930. }
  8931. // AddServiceCount adds i to the "service_count" field.
  8932. func (m *EmployeeMutation) AddServiceCount(i int) {
  8933. if m.addservice_count != nil {
  8934. *m.addservice_count += i
  8935. } else {
  8936. m.addservice_count = &i
  8937. }
  8938. }
  8939. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  8940. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  8941. v := m.addservice_count
  8942. if v == nil {
  8943. return
  8944. }
  8945. return *v, true
  8946. }
  8947. // ResetServiceCount resets all changes to the "service_count" field.
  8948. func (m *EmployeeMutation) ResetServiceCount() {
  8949. m.service_count = nil
  8950. m.addservice_count = nil
  8951. }
  8952. // SetAchievementCount sets the "achievement_count" field.
  8953. func (m *EmployeeMutation) SetAchievementCount(i int) {
  8954. m.achievement_count = &i
  8955. m.addachievement_count = nil
  8956. }
  8957. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  8958. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  8959. v := m.achievement_count
  8960. if v == nil {
  8961. return
  8962. }
  8963. return *v, true
  8964. }
  8965. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  8966. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8968. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  8969. if !m.op.Is(OpUpdateOne) {
  8970. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  8971. }
  8972. if m.id == nil || m.oldValue == nil {
  8973. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  8974. }
  8975. oldValue, err := m.oldValue(ctx)
  8976. if err != nil {
  8977. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  8978. }
  8979. return oldValue.AchievementCount, nil
  8980. }
  8981. // AddAchievementCount adds i to the "achievement_count" field.
  8982. func (m *EmployeeMutation) AddAchievementCount(i int) {
  8983. if m.addachievement_count != nil {
  8984. *m.addachievement_count += i
  8985. } else {
  8986. m.addachievement_count = &i
  8987. }
  8988. }
  8989. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  8990. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  8991. v := m.addachievement_count
  8992. if v == nil {
  8993. return
  8994. }
  8995. return *v, true
  8996. }
  8997. // ResetAchievementCount resets all changes to the "achievement_count" field.
  8998. func (m *EmployeeMutation) ResetAchievementCount() {
  8999. m.achievement_count = nil
  9000. m.addachievement_count = nil
  9001. }
  9002. // SetIntro sets the "intro" field.
  9003. func (m *EmployeeMutation) SetIntro(s string) {
  9004. m.intro = &s
  9005. }
  9006. // Intro returns the value of the "intro" field in the mutation.
  9007. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  9008. v := m.intro
  9009. if v == nil {
  9010. return
  9011. }
  9012. return *v, true
  9013. }
  9014. // OldIntro returns the old "intro" field's value of the Employee entity.
  9015. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9017. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  9018. if !m.op.Is(OpUpdateOne) {
  9019. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  9020. }
  9021. if m.id == nil || m.oldValue == nil {
  9022. return v, errors.New("OldIntro requires an ID field in the mutation")
  9023. }
  9024. oldValue, err := m.oldValue(ctx)
  9025. if err != nil {
  9026. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  9027. }
  9028. return oldValue.Intro, nil
  9029. }
  9030. // ResetIntro resets all changes to the "intro" field.
  9031. func (m *EmployeeMutation) ResetIntro() {
  9032. m.intro = nil
  9033. }
  9034. // SetEstimate sets the "estimate" field.
  9035. func (m *EmployeeMutation) SetEstimate(s string) {
  9036. m.estimate = &s
  9037. }
  9038. // Estimate returns the value of the "estimate" field in the mutation.
  9039. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  9040. v := m.estimate
  9041. if v == nil {
  9042. return
  9043. }
  9044. return *v, true
  9045. }
  9046. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  9047. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9049. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  9050. if !m.op.Is(OpUpdateOne) {
  9051. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  9052. }
  9053. if m.id == nil || m.oldValue == nil {
  9054. return v, errors.New("OldEstimate requires an ID field in the mutation")
  9055. }
  9056. oldValue, err := m.oldValue(ctx)
  9057. if err != nil {
  9058. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  9059. }
  9060. return oldValue.Estimate, nil
  9061. }
  9062. // ResetEstimate resets all changes to the "estimate" field.
  9063. func (m *EmployeeMutation) ResetEstimate() {
  9064. m.estimate = nil
  9065. }
  9066. // SetSkill sets the "skill" field.
  9067. func (m *EmployeeMutation) SetSkill(s string) {
  9068. m.skill = &s
  9069. }
  9070. // Skill returns the value of the "skill" field in the mutation.
  9071. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  9072. v := m.skill
  9073. if v == nil {
  9074. return
  9075. }
  9076. return *v, true
  9077. }
  9078. // OldSkill returns the old "skill" field's value of the Employee entity.
  9079. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9081. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  9082. if !m.op.Is(OpUpdateOne) {
  9083. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  9084. }
  9085. if m.id == nil || m.oldValue == nil {
  9086. return v, errors.New("OldSkill requires an ID field in the mutation")
  9087. }
  9088. oldValue, err := m.oldValue(ctx)
  9089. if err != nil {
  9090. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  9091. }
  9092. return oldValue.Skill, nil
  9093. }
  9094. // ResetSkill resets all changes to the "skill" field.
  9095. func (m *EmployeeMutation) ResetSkill() {
  9096. m.skill = nil
  9097. }
  9098. // SetAbilityType sets the "ability_type" field.
  9099. func (m *EmployeeMutation) SetAbilityType(s string) {
  9100. m.ability_type = &s
  9101. }
  9102. // AbilityType returns the value of the "ability_type" field in the mutation.
  9103. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  9104. v := m.ability_type
  9105. if v == nil {
  9106. return
  9107. }
  9108. return *v, true
  9109. }
  9110. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  9111. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9113. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  9114. if !m.op.Is(OpUpdateOne) {
  9115. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  9116. }
  9117. if m.id == nil || m.oldValue == nil {
  9118. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  9119. }
  9120. oldValue, err := m.oldValue(ctx)
  9121. if err != nil {
  9122. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  9123. }
  9124. return oldValue.AbilityType, nil
  9125. }
  9126. // ResetAbilityType resets all changes to the "ability_type" field.
  9127. func (m *EmployeeMutation) ResetAbilityType() {
  9128. m.ability_type = nil
  9129. }
  9130. // SetScene sets the "scene" field.
  9131. func (m *EmployeeMutation) SetScene(s string) {
  9132. m.scene = &s
  9133. }
  9134. // Scene returns the value of the "scene" field in the mutation.
  9135. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  9136. v := m.scene
  9137. if v == nil {
  9138. return
  9139. }
  9140. return *v, true
  9141. }
  9142. // OldScene returns the old "scene" field's value of the Employee entity.
  9143. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9145. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  9146. if !m.op.Is(OpUpdateOne) {
  9147. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  9148. }
  9149. if m.id == nil || m.oldValue == nil {
  9150. return v, errors.New("OldScene requires an ID field in the mutation")
  9151. }
  9152. oldValue, err := m.oldValue(ctx)
  9153. if err != nil {
  9154. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  9155. }
  9156. return oldValue.Scene, nil
  9157. }
  9158. // ResetScene resets all changes to the "scene" field.
  9159. func (m *EmployeeMutation) ResetScene() {
  9160. m.scene = nil
  9161. }
  9162. // SetSwitchIn sets the "switch_in" field.
  9163. func (m *EmployeeMutation) SetSwitchIn(s string) {
  9164. m.switch_in = &s
  9165. }
  9166. // SwitchIn returns the value of the "switch_in" field in the mutation.
  9167. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  9168. v := m.switch_in
  9169. if v == nil {
  9170. return
  9171. }
  9172. return *v, true
  9173. }
  9174. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  9175. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9177. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  9178. if !m.op.Is(OpUpdateOne) {
  9179. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  9180. }
  9181. if m.id == nil || m.oldValue == nil {
  9182. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  9183. }
  9184. oldValue, err := m.oldValue(ctx)
  9185. if err != nil {
  9186. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  9187. }
  9188. return oldValue.SwitchIn, nil
  9189. }
  9190. // ResetSwitchIn resets all changes to the "switch_in" field.
  9191. func (m *EmployeeMutation) ResetSwitchIn() {
  9192. m.switch_in = nil
  9193. }
  9194. // SetVideoURL sets the "video_url" field.
  9195. func (m *EmployeeMutation) SetVideoURL(s string) {
  9196. m.video_url = &s
  9197. }
  9198. // VideoURL returns the value of the "video_url" field in the mutation.
  9199. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  9200. v := m.video_url
  9201. if v == nil {
  9202. return
  9203. }
  9204. return *v, true
  9205. }
  9206. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  9207. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9209. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  9210. if !m.op.Is(OpUpdateOne) {
  9211. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  9212. }
  9213. if m.id == nil || m.oldValue == nil {
  9214. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  9215. }
  9216. oldValue, err := m.oldValue(ctx)
  9217. if err != nil {
  9218. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  9219. }
  9220. return oldValue.VideoURL, nil
  9221. }
  9222. // ResetVideoURL resets all changes to the "video_url" field.
  9223. func (m *EmployeeMutation) ResetVideoURL() {
  9224. m.video_url = nil
  9225. }
  9226. // SetOrganizationID sets the "organization_id" field.
  9227. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  9228. m.organization_id = &u
  9229. m.addorganization_id = nil
  9230. }
  9231. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9232. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  9233. v := m.organization_id
  9234. if v == nil {
  9235. return
  9236. }
  9237. return *v, true
  9238. }
  9239. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  9240. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9242. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9243. if !m.op.Is(OpUpdateOne) {
  9244. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9245. }
  9246. if m.id == nil || m.oldValue == nil {
  9247. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9248. }
  9249. oldValue, err := m.oldValue(ctx)
  9250. if err != nil {
  9251. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9252. }
  9253. return oldValue.OrganizationID, nil
  9254. }
  9255. // AddOrganizationID adds u to the "organization_id" field.
  9256. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  9257. if m.addorganization_id != nil {
  9258. *m.addorganization_id += u
  9259. } else {
  9260. m.addorganization_id = &u
  9261. }
  9262. }
  9263. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9264. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  9265. v := m.addorganization_id
  9266. if v == nil {
  9267. return
  9268. }
  9269. return *v, true
  9270. }
  9271. // ResetOrganizationID resets all changes to the "organization_id" field.
  9272. func (m *EmployeeMutation) ResetOrganizationID() {
  9273. m.organization_id = nil
  9274. m.addorganization_id = nil
  9275. }
  9276. // SetCategoryID sets the "category_id" field.
  9277. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  9278. m.category_id = &u
  9279. m.addcategory_id = nil
  9280. }
  9281. // CategoryID returns the value of the "category_id" field in the mutation.
  9282. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  9283. v := m.category_id
  9284. if v == nil {
  9285. return
  9286. }
  9287. return *v, true
  9288. }
  9289. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  9290. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9292. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  9293. if !m.op.Is(OpUpdateOne) {
  9294. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  9295. }
  9296. if m.id == nil || m.oldValue == nil {
  9297. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  9298. }
  9299. oldValue, err := m.oldValue(ctx)
  9300. if err != nil {
  9301. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  9302. }
  9303. return oldValue.CategoryID, nil
  9304. }
  9305. // AddCategoryID adds u to the "category_id" field.
  9306. func (m *EmployeeMutation) AddCategoryID(u int64) {
  9307. if m.addcategory_id != nil {
  9308. *m.addcategory_id += u
  9309. } else {
  9310. m.addcategory_id = &u
  9311. }
  9312. }
  9313. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  9314. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  9315. v := m.addcategory_id
  9316. if v == nil {
  9317. return
  9318. }
  9319. return *v, true
  9320. }
  9321. // ResetCategoryID resets all changes to the "category_id" field.
  9322. func (m *EmployeeMutation) ResetCategoryID() {
  9323. m.category_id = nil
  9324. m.addcategory_id = nil
  9325. }
  9326. // SetAPIBase sets the "api_base" field.
  9327. func (m *EmployeeMutation) SetAPIBase(s string) {
  9328. m.api_base = &s
  9329. }
  9330. // APIBase returns the value of the "api_base" field in the mutation.
  9331. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  9332. v := m.api_base
  9333. if v == nil {
  9334. return
  9335. }
  9336. return *v, true
  9337. }
  9338. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  9339. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9341. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  9342. if !m.op.Is(OpUpdateOne) {
  9343. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  9344. }
  9345. if m.id == nil || m.oldValue == nil {
  9346. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  9347. }
  9348. oldValue, err := m.oldValue(ctx)
  9349. if err != nil {
  9350. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  9351. }
  9352. return oldValue.APIBase, nil
  9353. }
  9354. // ResetAPIBase resets all changes to the "api_base" field.
  9355. func (m *EmployeeMutation) ResetAPIBase() {
  9356. m.api_base = nil
  9357. }
  9358. // SetAPIKey sets the "api_key" field.
  9359. func (m *EmployeeMutation) SetAPIKey(s string) {
  9360. m.api_key = &s
  9361. }
  9362. // APIKey returns the value of the "api_key" field in the mutation.
  9363. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  9364. v := m.api_key
  9365. if v == nil {
  9366. return
  9367. }
  9368. return *v, true
  9369. }
  9370. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  9371. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9373. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  9374. if !m.op.Is(OpUpdateOne) {
  9375. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  9376. }
  9377. if m.id == nil || m.oldValue == nil {
  9378. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  9379. }
  9380. oldValue, err := m.oldValue(ctx)
  9381. if err != nil {
  9382. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  9383. }
  9384. return oldValue.APIKey, nil
  9385. }
  9386. // ResetAPIKey resets all changes to the "api_key" field.
  9387. func (m *EmployeeMutation) ResetAPIKey() {
  9388. m.api_key = nil
  9389. }
  9390. // SetAiInfo sets the "ai_info" field.
  9391. func (m *EmployeeMutation) SetAiInfo(s string) {
  9392. m.ai_info = &s
  9393. }
  9394. // AiInfo returns the value of the "ai_info" field in the mutation.
  9395. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  9396. v := m.ai_info
  9397. if v == nil {
  9398. return
  9399. }
  9400. return *v, true
  9401. }
  9402. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  9403. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9405. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  9406. if !m.op.Is(OpUpdateOne) {
  9407. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  9408. }
  9409. if m.id == nil || m.oldValue == nil {
  9410. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  9411. }
  9412. oldValue, err := m.oldValue(ctx)
  9413. if err != nil {
  9414. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  9415. }
  9416. return oldValue.AiInfo, nil
  9417. }
  9418. // ClearAiInfo clears the value of the "ai_info" field.
  9419. func (m *EmployeeMutation) ClearAiInfo() {
  9420. m.ai_info = nil
  9421. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  9422. }
  9423. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  9424. func (m *EmployeeMutation) AiInfoCleared() bool {
  9425. _, ok := m.clearedFields[employee.FieldAiInfo]
  9426. return ok
  9427. }
  9428. // ResetAiInfo resets all changes to the "ai_info" field.
  9429. func (m *EmployeeMutation) ResetAiInfo() {
  9430. m.ai_info = nil
  9431. delete(m.clearedFields, employee.FieldAiInfo)
  9432. }
  9433. // SetIsVip sets the "is_vip" field.
  9434. func (m *EmployeeMutation) SetIsVip(i int) {
  9435. m.is_vip = &i
  9436. m.addis_vip = nil
  9437. }
  9438. // IsVip returns the value of the "is_vip" field in the mutation.
  9439. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  9440. v := m.is_vip
  9441. if v == nil {
  9442. return
  9443. }
  9444. return *v, true
  9445. }
  9446. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  9447. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9449. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  9450. if !m.op.Is(OpUpdateOne) {
  9451. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  9452. }
  9453. if m.id == nil || m.oldValue == nil {
  9454. return v, errors.New("OldIsVip requires an ID field in the mutation")
  9455. }
  9456. oldValue, err := m.oldValue(ctx)
  9457. if err != nil {
  9458. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  9459. }
  9460. return oldValue.IsVip, nil
  9461. }
  9462. // AddIsVip adds i to the "is_vip" field.
  9463. func (m *EmployeeMutation) AddIsVip(i int) {
  9464. if m.addis_vip != nil {
  9465. *m.addis_vip += i
  9466. } else {
  9467. m.addis_vip = &i
  9468. }
  9469. }
  9470. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  9471. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  9472. v := m.addis_vip
  9473. if v == nil {
  9474. return
  9475. }
  9476. return *v, true
  9477. }
  9478. // ResetIsVip resets all changes to the "is_vip" field.
  9479. func (m *EmployeeMutation) ResetIsVip() {
  9480. m.is_vip = nil
  9481. m.addis_vip = nil
  9482. }
  9483. // SetChatURL sets the "chat_url" field.
  9484. func (m *EmployeeMutation) SetChatURL(s string) {
  9485. m.chat_url = &s
  9486. }
  9487. // ChatURL returns the value of the "chat_url" field in the mutation.
  9488. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  9489. v := m.chat_url
  9490. if v == nil {
  9491. return
  9492. }
  9493. return *v, true
  9494. }
  9495. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  9496. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9498. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  9499. if !m.op.Is(OpUpdateOne) {
  9500. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  9501. }
  9502. if m.id == nil || m.oldValue == nil {
  9503. return v, errors.New("OldChatURL requires an ID field in the mutation")
  9504. }
  9505. oldValue, err := m.oldValue(ctx)
  9506. if err != nil {
  9507. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  9508. }
  9509. return oldValue.ChatURL, nil
  9510. }
  9511. // ResetChatURL resets all changes to the "chat_url" field.
  9512. func (m *EmployeeMutation) ResetChatURL() {
  9513. m.chat_url = nil
  9514. }
  9515. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  9516. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  9517. if m.em_work_experiences == nil {
  9518. m.em_work_experiences = make(map[uint64]struct{})
  9519. }
  9520. for i := range ids {
  9521. m.em_work_experiences[ids[i]] = struct{}{}
  9522. }
  9523. }
  9524. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  9525. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  9526. m.clearedem_work_experiences = true
  9527. }
  9528. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  9529. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  9530. return m.clearedem_work_experiences
  9531. }
  9532. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  9533. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  9534. if m.removedem_work_experiences == nil {
  9535. m.removedem_work_experiences = make(map[uint64]struct{})
  9536. }
  9537. for i := range ids {
  9538. delete(m.em_work_experiences, ids[i])
  9539. m.removedem_work_experiences[ids[i]] = struct{}{}
  9540. }
  9541. }
  9542. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  9543. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  9544. for id := range m.removedem_work_experiences {
  9545. ids = append(ids, id)
  9546. }
  9547. return
  9548. }
  9549. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  9550. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  9551. for id := range m.em_work_experiences {
  9552. ids = append(ids, id)
  9553. }
  9554. return
  9555. }
  9556. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  9557. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  9558. m.em_work_experiences = nil
  9559. m.clearedem_work_experiences = false
  9560. m.removedem_work_experiences = nil
  9561. }
  9562. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  9563. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  9564. if m.em_tutorial == nil {
  9565. m.em_tutorial = make(map[uint64]struct{})
  9566. }
  9567. for i := range ids {
  9568. m.em_tutorial[ids[i]] = struct{}{}
  9569. }
  9570. }
  9571. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  9572. func (m *EmployeeMutation) ClearEmTutorial() {
  9573. m.clearedem_tutorial = true
  9574. }
  9575. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  9576. func (m *EmployeeMutation) EmTutorialCleared() bool {
  9577. return m.clearedem_tutorial
  9578. }
  9579. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  9580. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  9581. if m.removedem_tutorial == nil {
  9582. m.removedem_tutorial = make(map[uint64]struct{})
  9583. }
  9584. for i := range ids {
  9585. delete(m.em_tutorial, ids[i])
  9586. m.removedem_tutorial[ids[i]] = struct{}{}
  9587. }
  9588. }
  9589. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  9590. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  9591. for id := range m.removedem_tutorial {
  9592. ids = append(ids, id)
  9593. }
  9594. return
  9595. }
  9596. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  9597. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  9598. for id := range m.em_tutorial {
  9599. ids = append(ids, id)
  9600. }
  9601. return
  9602. }
  9603. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  9604. func (m *EmployeeMutation) ResetEmTutorial() {
  9605. m.em_tutorial = nil
  9606. m.clearedem_tutorial = false
  9607. m.removedem_tutorial = nil
  9608. }
  9609. // Where appends a list predicates to the EmployeeMutation builder.
  9610. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  9611. m.predicates = append(m.predicates, ps...)
  9612. }
  9613. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  9614. // users can use type-assertion to append predicates that do not depend on any generated package.
  9615. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  9616. p := make([]predicate.Employee, len(ps))
  9617. for i := range ps {
  9618. p[i] = ps[i]
  9619. }
  9620. m.Where(p...)
  9621. }
  9622. // Op returns the operation name.
  9623. func (m *EmployeeMutation) Op() Op {
  9624. return m.op
  9625. }
  9626. // SetOp allows setting the mutation operation.
  9627. func (m *EmployeeMutation) SetOp(op Op) {
  9628. m.op = op
  9629. }
  9630. // Type returns the node type of this mutation (Employee).
  9631. func (m *EmployeeMutation) Type() string {
  9632. return m.typ
  9633. }
  9634. // Fields returns all fields that were changed during this mutation. Note that in
  9635. // order to get all numeric fields that were incremented/decremented, call
  9636. // AddedFields().
  9637. func (m *EmployeeMutation) Fields() []string {
  9638. fields := make([]string, 0, 23)
  9639. if m.created_at != nil {
  9640. fields = append(fields, employee.FieldCreatedAt)
  9641. }
  9642. if m.updated_at != nil {
  9643. fields = append(fields, employee.FieldUpdatedAt)
  9644. }
  9645. if m.deleted_at != nil {
  9646. fields = append(fields, employee.FieldDeletedAt)
  9647. }
  9648. if m.title != nil {
  9649. fields = append(fields, employee.FieldTitle)
  9650. }
  9651. if m.avatar != nil {
  9652. fields = append(fields, employee.FieldAvatar)
  9653. }
  9654. if m.tags != nil {
  9655. fields = append(fields, employee.FieldTags)
  9656. }
  9657. if m.hire_count != nil {
  9658. fields = append(fields, employee.FieldHireCount)
  9659. }
  9660. if m.service_count != nil {
  9661. fields = append(fields, employee.FieldServiceCount)
  9662. }
  9663. if m.achievement_count != nil {
  9664. fields = append(fields, employee.FieldAchievementCount)
  9665. }
  9666. if m.intro != nil {
  9667. fields = append(fields, employee.FieldIntro)
  9668. }
  9669. if m.estimate != nil {
  9670. fields = append(fields, employee.FieldEstimate)
  9671. }
  9672. if m.skill != nil {
  9673. fields = append(fields, employee.FieldSkill)
  9674. }
  9675. if m.ability_type != nil {
  9676. fields = append(fields, employee.FieldAbilityType)
  9677. }
  9678. if m.scene != nil {
  9679. fields = append(fields, employee.FieldScene)
  9680. }
  9681. if m.switch_in != nil {
  9682. fields = append(fields, employee.FieldSwitchIn)
  9683. }
  9684. if m.video_url != nil {
  9685. fields = append(fields, employee.FieldVideoURL)
  9686. }
  9687. if m.organization_id != nil {
  9688. fields = append(fields, employee.FieldOrganizationID)
  9689. }
  9690. if m.category_id != nil {
  9691. fields = append(fields, employee.FieldCategoryID)
  9692. }
  9693. if m.api_base != nil {
  9694. fields = append(fields, employee.FieldAPIBase)
  9695. }
  9696. if m.api_key != nil {
  9697. fields = append(fields, employee.FieldAPIKey)
  9698. }
  9699. if m.ai_info != nil {
  9700. fields = append(fields, employee.FieldAiInfo)
  9701. }
  9702. if m.is_vip != nil {
  9703. fields = append(fields, employee.FieldIsVip)
  9704. }
  9705. if m.chat_url != nil {
  9706. fields = append(fields, employee.FieldChatURL)
  9707. }
  9708. return fields
  9709. }
  9710. // Field returns the value of a field with the given name. The second boolean
  9711. // return value indicates that this field was not set, or was not defined in the
  9712. // schema.
  9713. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  9714. switch name {
  9715. case employee.FieldCreatedAt:
  9716. return m.CreatedAt()
  9717. case employee.FieldUpdatedAt:
  9718. return m.UpdatedAt()
  9719. case employee.FieldDeletedAt:
  9720. return m.DeletedAt()
  9721. case employee.FieldTitle:
  9722. return m.Title()
  9723. case employee.FieldAvatar:
  9724. return m.Avatar()
  9725. case employee.FieldTags:
  9726. return m.Tags()
  9727. case employee.FieldHireCount:
  9728. return m.HireCount()
  9729. case employee.FieldServiceCount:
  9730. return m.ServiceCount()
  9731. case employee.FieldAchievementCount:
  9732. return m.AchievementCount()
  9733. case employee.FieldIntro:
  9734. return m.Intro()
  9735. case employee.FieldEstimate:
  9736. return m.Estimate()
  9737. case employee.FieldSkill:
  9738. return m.Skill()
  9739. case employee.FieldAbilityType:
  9740. return m.AbilityType()
  9741. case employee.FieldScene:
  9742. return m.Scene()
  9743. case employee.FieldSwitchIn:
  9744. return m.SwitchIn()
  9745. case employee.FieldVideoURL:
  9746. return m.VideoURL()
  9747. case employee.FieldOrganizationID:
  9748. return m.OrganizationID()
  9749. case employee.FieldCategoryID:
  9750. return m.CategoryID()
  9751. case employee.FieldAPIBase:
  9752. return m.APIBase()
  9753. case employee.FieldAPIKey:
  9754. return m.APIKey()
  9755. case employee.FieldAiInfo:
  9756. return m.AiInfo()
  9757. case employee.FieldIsVip:
  9758. return m.IsVip()
  9759. case employee.FieldChatURL:
  9760. return m.ChatURL()
  9761. }
  9762. return nil, false
  9763. }
  9764. // OldField returns the old value of the field from the database. An error is
  9765. // returned if the mutation operation is not UpdateOne, or the query to the
  9766. // database failed.
  9767. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9768. switch name {
  9769. case employee.FieldCreatedAt:
  9770. return m.OldCreatedAt(ctx)
  9771. case employee.FieldUpdatedAt:
  9772. return m.OldUpdatedAt(ctx)
  9773. case employee.FieldDeletedAt:
  9774. return m.OldDeletedAt(ctx)
  9775. case employee.FieldTitle:
  9776. return m.OldTitle(ctx)
  9777. case employee.FieldAvatar:
  9778. return m.OldAvatar(ctx)
  9779. case employee.FieldTags:
  9780. return m.OldTags(ctx)
  9781. case employee.FieldHireCount:
  9782. return m.OldHireCount(ctx)
  9783. case employee.FieldServiceCount:
  9784. return m.OldServiceCount(ctx)
  9785. case employee.FieldAchievementCount:
  9786. return m.OldAchievementCount(ctx)
  9787. case employee.FieldIntro:
  9788. return m.OldIntro(ctx)
  9789. case employee.FieldEstimate:
  9790. return m.OldEstimate(ctx)
  9791. case employee.FieldSkill:
  9792. return m.OldSkill(ctx)
  9793. case employee.FieldAbilityType:
  9794. return m.OldAbilityType(ctx)
  9795. case employee.FieldScene:
  9796. return m.OldScene(ctx)
  9797. case employee.FieldSwitchIn:
  9798. return m.OldSwitchIn(ctx)
  9799. case employee.FieldVideoURL:
  9800. return m.OldVideoURL(ctx)
  9801. case employee.FieldOrganizationID:
  9802. return m.OldOrganizationID(ctx)
  9803. case employee.FieldCategoryID:
  9804. return m.OldCategoryID(ctx)
  9805. case employee.FieldAPIBase:
  9806. return m.OldAPIBase(ctx)
  9807. case employee.FieldAPIKey:
  9808. return m.OldAPIKey(ctx)
  9809. case employee.FieldAiInfo:
  9810. return m.OldAiInfo(ctx)
  9811. case employee.FieldIsVip:
  9812. return m.OldIsVip(ctx)
  9813. case employee.FieldChatURL:
  9814. return m.OldChatURL(ctx)
  9815. }
  9816. return nil, fmt.Errorf("unknown Employee field %s", name)
  9817. }
  9818. // SetField sets the value of a field with the given name. It returns an error if
  9819. // the field is not defined in the schema, or if the type mismatched the field
  9820. // type.
  9821. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  9822. switch name {
  9823. case employee.FieldCreatedAt:
  9824. v, ok := value.(time.Time)
  9825. if !ok {
  9826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9827. }
  9828. m.SetCreatedAt(v)
  9829. return nil
  9830. case employee.FieldUpdatedAt:
  9831. v, ok := value.(time.Time)
  9832. if !ok {
  9833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9834. }
  9835. m.SetUpdatedAt(v)
  9836. return nil
  9837. case employee.FieldDeletedAt:
  9838. v, ok := value.(time.Time)
  9839. if !ok {
  9840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9841. }
  9842. m.SetDeletedAt(v)
  9843. return nil
  9844. case employee.FieldTitle:
  9845. v, ok := value.(string)
  9846. if !ok {
  9847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9848. }
  9849. m.SetTitle(v)
  9850. return nil
  9851. case employee.FieldAvatar:
  9852. v, ok := value.(string)
  9853. if !ok {
  9854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9855. }
  9856. m.SetAvatar(v)
  9857. return nil
  9858. case employee.FieldTags:
  9859. v, ok := value.(string)
  9860. if !ok {
  9861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9862. }
  9863. m.SetTags(v)
  9864. return nil
  9865. case employee.FieldHireCount:
  9866. v, ok := value.(int)
  9867. if !ok {
  9868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9869. }
  9870. m.SetHireCount(v)
  9871. return nil
  9872. case employee.FieldServiceCount:
  9873. v, ok := value.(int)
  9874. if !ok {
  9875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9876. }
  9877. m.SetServiceCount(v)
  9878. return nil
  9879. case employee.FieldAchievementCount:
  9880. v, ok := value.(int)
  9881. if !ok {
  9882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9883. }
  9884. m.SetAchievementCount(v)
  9885. return nil
  9886. case employee.FieldIntro:
  9887. v, ok := value.(string)
  9888. if !ok {
  9889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9890. }
  9891. m.SetIntro(v)
  9892. return nil
  9893. case employee.FieldEstimate:
  9894. v, ok := value.(string)
  9895. if !ok {
  9896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9897. }
  9898. m.SetEstimate(v)
  9899. return nil
  9900. case employee.FieldSkill:
  9901. v, ok := value.(string)
  9902. if !ok {
  9903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9904. }
  9905. m.SetSkill(v)
  9906. return nil
  9907. case employee.FieldAbilityType:
  9908. v, ok := value.(string)
  9909. if !ok {
  9910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9911. }
  9912. m.SetAbilityType(v)
  9913. return nil
  9914. case employee.FieldScene:
  9915. v, ok := value.(string)
  9916. if !ok {
  9917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9918. }
  9919. m.SetScene(v)
  9920. return nil
  9921. case employee.FieldSwitchIn:
  9922. v, ok := value.(string)
  9923. if !ok {
  9924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9925. }
  9926. m.SetSwitchIn(v)
  9927. return nil
  9928. case employee.FieldVideoURL:
  9929. v, ok := value.(string)
  9930. if !ok {
  9931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9932. }
  9933. m.SetVideoURL(v)
  9934. return nil
  9935. case employee.FieldOrganizationID:
  9936. v, ok := value.(uint64)
  9937. if !ok {
  9938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9939. }
  9940. m.SetOrganizationID(v)
  9941. return nil
  9942. case employee.FieldCategoryID:
  9943. v, ok := value.(uint64)
  9944. if !ok {
  9945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9946. }
  9947. m.SetCategoryID(v)
  9948. return nil
  9949. case employee.FieldAPIBase:
  9950. v, ok := value.(string)
  9951. if !ok {
  9952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9953. }
  9954. m.SetAPIBase(v)
  9955. return nil
  9956. case employee.FieldAPIKey:
  9957. v, ok := value.(string)
  9958. if !ok {
  9959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9960. }
  9961. m.SetAPIKey(v)
  9962. return nil
  9963. case employee.FieldAiInfo:
  9964. v, ok := value.(string)
  9965. if !ok {
  9966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9967. }
  9968. m.SetAiInfo(v)
  9969. return nil
  9970. case employee.FieldIsVip:
  9971. v, ok := value.(int)
  9972. if !ok {
  9973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9974. }
  9975. m.SetIsVip(v)
  9976. return nil
  9977. case employee.FieldChatURL:
  9978. v, ok := value.(string)
  9979. if !ok {
  9980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9981. }
  9982. m.SetChatURL(v)
  9983. return nil
  9984. }
  9985. return fmt.Errorf("unknown Employee field %s", name)
  9986. }
  9987. // AddedFields returns all numeric fields that were incremented/decremented during
  9988. // this mutation.
  9989. func (m *EmployeeMutation) AddedFields() []string {
  9990. var fields []string
  9991. if m.addhire_count != nil {
  9992. fields = append(fields, employee.FieldHireCount)
  9993. }
  9994. if m.addservice_count != nil {
  9995. fields = append(fields, employee.FieldServiceCount)
  9996. }
  9997. if m.addachievement_count != nil {
  9998. fields = append(fields, employee.FieldAchievementCount)
  9999. }
  10000. if m.addorganization_id != nil {
  10001. fields = append(fields, employee.FieldOrganizationID)
  10002. }
  10003. if m.addcategory_id != nil {
  10004. fields = append(fields, employee.FieldCategoryID)
  10005. }
  10006. if m.addis_vip != nil {
  10007. fields = append(fields, employee.FieldIsVip)
  10008. }
  10009. return fields
  10010. }
  10011. // AddedField returns the numeric value that was incremented/decremented on a field
  10012. // with the given name. The second boolean return value indicates that this field
  10013. // was not set, or was not defined in the schema.
  10014. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  10015. switch name {
  10016. case employee.FieldHireCount:
  10017. return m.AddedHireCount()
  10018. case employee.FieldServiceCount:
  10019. return m.AddedServiceCount()
  10020. case employee.FieldAchievementCount:
  10021. return m.AddedAchievementCount()
  10022. case employee.FieldOrganizationID:
  10023. return m.AddedOrganizationID()
  10024. case employee.FieldCategoryID:
  10025. return m.AddedCategoryID()
  10026. case employee.FieldIsVip:
  10027. return m.AddedIsVip()
  10028. }
  10029. return nil, false
  10030. }
  10031. // AddField adds the value to the field with the given name. It returns an error if
  10032. // the field is not defined in the schema, or if the type mismatched the field
  10033. // type.
  10034. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  10035. switch name {
  10036. case employee.FieldHireCount:
  10037. v, ok := value.(int)
  10038. if !ok {
  10039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10040. }
  10041. m.AddHireCount(v)
  10042. return nil
  10043. case employee.FieldServiceCount:
  10044. v, ok := value.(int)
  10045. if !ok {
  10046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10047. }
  10048. m.AddServiceCount(v)
  10049. return nil
  10050. case employee.FieldAchievementCount:
  10051. v, ok := value.(int)
  10052. if !ok {
  10053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10054. }
  10055. m.AddAchievementCount(v)
  10056. return nil
  10057. case employee.FieldOrganizationID:
  10058. v, ok := value.(int64)
  10059. if !ok {
  10060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10061. }
  10062. m.AddOrganizationID(v)
  10063. return nil
  10064. case employee.FieldCategoryID:
  10065. v, ok := value.(int64)
  10066. if !ok {
  10067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10068. }
  10069. m.AddCategoryID(v)
  10070. return nil
  10071. case employee.FieldIsVip:
  10072. v, ok := value.(int)
  10073. if !ok {
  10074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10075. }
  10076. m.AddIsVip(v)
  10077. return nil
  10078. }
  10079. return fmt.Errorf("unknown Employee numeric field %s", name)
  10080. }
  10081. // ClearedFields returns all nullable fields that were cleared during this
  10082. // mutation.
  10083. func (m *EmployeeMutation) ClearedFields() []string {
  10084. var fields []string
  10085. if m.FieldCleared(employee.FieldDeletedAt) {
  10086. fields = append(fields, employee.FieldDeletedAt)
  10087. }
  10088. if m.FieldCleared(employee.FieldAiInfo) {
  10089. fields = append(fields, employee.FieldAiInfo)
  10090. }
  10091. return fields
  10092. }
  10093. // FieldCleared returns a boolean indicating if a field with the given name was
  10094. // cleared in this mutation.
  10095. func (m *EmployeeMutation) FieldCleared(name string) bool {
  10096. _, ok := m.clearedFields[name]
  10097. return ok
  10098. }
  10099. // ClearField clears the value of the field with the given name. It returns an
  10100. // error if the field is not defined in the schema.
  10101. func (m *EmployeeMutation) ClearField(name string) error {
  10102. switch name {
  10103. case employee.FieldDeletedAt:
  10104. m.ClearDeletedAt()
  10105. return nil
  10106. case employee.FieldAiInfo:
  10107. m.ClearAiInfo()
  10108. return nil
  10109. }
  10110. return fmt.Errorf("unknown Employee nullable field %s", name)
  10111. }
  10112. // ResetField resets all changes in the mutation for the field with the given name.
  10113. // It returns an error if the field is not defined in the schema.
  10114. func (m *EmployeeMutation) ResetField(name string) error {
  10115. switch name {
  10116. case employee.FieldCreatedAt:
  10117. m.ResetCreatedAt()
  10118. return nil
  10119. case employee.FieldUpdatedAt:
  10120. m.ResetUpdatedAt()
  10121. return nil
  10122. case employee.FieldDeletedAt:
  10123. m.ResetDeletedAt()
  10124. return nil
  10125. case employee.FieldTitle:
  10126. m.ResetTitle()
  10127. return nil
  10128. case employee.FieldAvatar:
  10129. m.ResetAvatar()
  10130. return nil
  10131. case employee.FieldTags:
  10132. m.ResetTags()
  10133. return nil
  10134. case employee.FieldHireCount:
  10135. m.ResetHireCount()
  10136. return nil
  10137. case employee.FieldServiceCount:
  10138. m.ResetServiceCount()
  10139. return nil
  10140. case employee.FieldAchievementCount:
  10141. m.ResetAchievementCount()
  10142. return nil
  10143. case employee.FieldIntro:
  10144. m.ResetIntro()
  10145. return nil
  10146. case employee.FieldEstimate:
  10147. m.ResetEstimate()
  10148. return nil
  10149. case employee.FieldSkill:
  10150. m.ResetSkill()
  10151. return nil
  10152. case employee.FieldAbilityType:
  10153. m.ResetAbilityType()
  10154. return nil
  10155. case employee.FieldScene:
  10156. m.ResetScene()
  10157. return nil
  10158. case employee.FieldSwitchIn:
  10159. m.ResetSwitchIn()
  10160. return nil
  10161. case employee.FieldVideoURL:
  10162. m.ResetVideoURL()
  10163. return nil
  10164. case employee.FieldOrganizationID:
  10165. m.ResetOrganizationID()
  10166. return nil
  10167. case employee.FieldCategoryID:
  10168. m.ResetCategoryID()
  10169. return nil
  10170. case employee.FieldAPIBase:
  10171. m.ResetAPIBase()
  10172. return nil
  10173. case employee.FieldAPIKey:
  10174. m.ResetAPIKey()
  10175. return nil
  10176. case employee.FieldAiInfo:
  10177. m.ResetAiInfo()
  10178. return nil
  10179. case employee.FieldIsVip:
  10180. m.ResetIsVip()
  10181. return nil
  10182. case employee.FieldChatURL:
  10183. m.ResetChatURL()
  10184. return nil
  10185. }
  10186. return fmt.Errorf("unknown Employee field %s", name)
  10187. }
  10188. // AddedEdges returns all edge names that were set/added in this mutation.
  10189. func (m *EmployeeMutation) AddedEdges() []string {
  10190. edges := make([]string, 0, 2)
  10191. if m.em_work_experiences != nil {
  10192. edges = append(edges, employee.EdgeEmWorkExperiences)
  10193. }
  10194. if m.em_tutorial != nil {
  10195. edges = append(edges, employee.EdgeEmTutorial)
  10196. }
  10197. return edges
  10198. }
  10199. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10200. // name in this mutation.
  10201. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  10202. switch name {
  10203. case employee.EdgeEmWorkExperiences:
  10204. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  10205. for id := range m.em_work_experiences {
  10206. ids = append(ids, id)
  10207. }
  10208. return ids
  10209. case employee.EdgeEmTutorial:
  10210. ids := make([]ent.Value, 0, len(m.em_tutorial))
  10211. for id := range m.em_tutorial {
  10212. ids = append(ids, id)
  10213. }
  10214. return ids
  10215. }
  10216. return nil
  10217. }
  10218. // RemovedEdges returns all edge names that were removed in this mutation.
  10219. func (m *EmployeeMutation) RemovedEdges() []string {
  10220. edges := make([]string, 0, 2)
  10221. if m.removedem_work_experiences != nil {
  10222. edges = append(edges, employee.EdgeEmWorkExperiences)
  10223. }
  10224. if m.removedem_tutorial != nil {
  10225. edges = append(edges, employee.EdgeEmTutorial)
  10226. }
  10227. return edges
  10228. }
  10229. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10230. // the given name in this mutation.
  10231. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  10232. switch name {
  10233. case employee.EdgeEmWorkExperiences:
  10234. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  10235. for id := range m.removedem_work_experiences {
  10236. ids = append(ids, id)
  10237. }
  10238. return ids
  10239. case employee.EdgeEmTutorial:
  10240. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  10241. for id := range m.removedem_tutorial {
  10242. ids = append(ids, id)
  10243. }
  10244. return ids
  10245. }
  10246. return nil
  10247. }
  10248. // ClearedEdges returns all edge names that were cleared in this mutation.
  10249. func (m *EmployeeMutation) ClearedEdges() []string {
  10250. edges := make([]string, 0, 2)
  10251. if m.clearedem_work_experiences {
  10252. edges = append(edges, employee.EdgeEmWorkExperiences)
  10253. }
  10254. if m.clearedem_tutorial {
  10255. edges = append(edges, employee.EdgeEmTutorial)
  10256. }
  10257. return edges
  10258. }
  10259. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10260. // was cleared in this mutation.
  10261. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  10262. switch name {
  10263. case employee.EdgeEmWorkExperiences:
  10264. return m.clearedem_work_experiences
  10265. case employee.EdgeEmTutorial:
  10266. return m.clearedem_tutorial
  10267. }
  10268. return false
  10269. }
  10270. // ClearEdge clears the value of the edge with the given name. It returns an error
  10271. // if that edge is not defined in the schema.
  10272. func (m *EmployeeMutation) ClearEdge(name string) error {
  10273. switch name {
  10274. }
  10275. return fmt.Errorf("unknown Employee unique edge %s", name)
  10276. }
  10277. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10278. // It returns an error if the edge is not defined in the schema.
  10279. func (m *EmployeeMutation) ResetEdge(name string) error {
  10280. switch name {
  10281. case employee.EdgeEmWorkExperiences:
  10282. m.ResetEmWorkExperiences()
  10283. return nil
  10284. case employee.EdgeEmTutorial:
  10285. m.ResetEmTutorial()
  10286. return nil
  10287. }
  10288. return fmt.Errorf("unknown Employee edge %s", name)
  10289. }
  10290. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  10291. type EmployeeConfigMutation struct {
  10292. config
  10293. op Op
  10294. typ string
  10295. id *uint64
  10296. created_at *time.Time
  10297. updated_at *time.Time
  10298. deleted_at *time.Time
  10299. stype *string
  10300. title *string
  10301. photo *string
  10302. organization_id *uint64
  10303. addorganization_id *int64
  10304. clearedFields map[string]struct{}
  10305. done bool
  10306. oldValue func(context.Context) (*EmployeeConfig, error)
  10307. predicates []predicate.EmployeeConfig
  10308. }
  10309. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  10310. // employeeconfigOption allows management of the mutation configuration using functional options.
  10311. type employeeconfigOption func(*EmployeeConfigMutation)
  10312. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  10313. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  10314. m := &EmployeeConfigMutation{
  10315. config: c,
  10316. op: op,
  10317. typ: TypeEmployeeConfig,
  10318. clearedFields: make(map[string]struct{}),
  10319. }
  10320. for _, opt := range opts {
  10321. opt(m)
  10322. }
  10323. return m
  10324. }
  10325. // withEmployeeConfigID sets the ID field of the mutation.
  10326. func withEmployeeConfigID(id uint64) employeeconfigOption {
  10327. return func(m *EmployeeConfigMutation) {
  10328. var (
  10329. err error
  10330. once sync.Once
  10331. value *EmployeeConfig
  10332. )
  10333. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  10334. once.Do(func() {
  10335. if m.done {
  10336. err = errors.New("querying old values post mutation is not allowed")
  10337. } else {
  10338. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  10339. }
  10340. })
  10341. return value, err
  10342. }
  10343. m.id = &id
  10344. }
  10345. }
  10346. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  10347. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  10348. return func(m *EmployeeConfigMutation) {
  10349. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  10350. return node, nil
  10351. }
  10352. m.id = &node.ID
  10353. }
  10354. }
  10355. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10356. // executed in a transaction (ent.Tx), a transactional client is returned.
  10357. func (m EmployeeConfigMutation) Client() *Client {
  10358. client := &Client{config: m.config}
  10359. client.init()
  10360. return client
  10361. }
  10362. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10363. // it returns an error otherwise.
  10364. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  10365. if _, ok := m.driver.(*txDriver); !ok {
  10366. return nil, errors.New("ent: mutation is not running in a transaction")
  10367. }
  10368. tx := &Tx{config: m.config}
  10369. tx.init()
  10370. return tx, nil
  10371. }
  10372. // SetID sets the value of the id field. Note that this
  10373. // operation is only accepted on creation of EmployeeConfig entities.
  10374. func (m *EmployeeConfigMutation) SetID(id uint64) {
  10375. m.id = &id
  10376. }
  10377. // ID returns the ID value in the mutation. Note that the ID is only available
  10378. // if it was provided to the builder or after it was returned from the database.
  10379. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  10380. if m.id == nil {
  10381. return
  10382. }
  10383. return *m.id, true
  10384. }
  10385. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10386. // That means, if the mutation is applied within a transaction with an isolation level such
  10387. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10388. // or updated by the mutation.
  10389. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  10390. switch {
  10391. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10392. id, exists := m.ID()
  10393. if exists {
  10394. return []uint64{id}, nil
  10395. }
  10396. fallthrough
  10397. case m.op.Is(OpUpdate | OpDelete):
  10398. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  10399. default:
  10400. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10401. }
  10402. }
  10403. // SetCreatedAt sets the "created_at" field.
  10404. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  10405. m.created_at = &t
  10406. }
  10407. // CreatedAt returns the value of the "created_at" field in the mutation.
  10408. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  10409. v := m.created_at
  10410. if v == nil {
  10411. return
  10412. }
  10413. return *v, true
  10414. }
  10415. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  10416. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10418. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10419. if !m.op.Is(OpUpdateOne) {
  10420. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10421. }
  10422. if m.id == nil || m.oldValue == nil {
  10423. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10424. }
  10425. oldValue, err := m.oldValue(ctx)
  10426. if err != nil {
  10427. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10428. }
  10429. return oldValue.CreatedAt, nil
  10430. }
  10431. // ResetCreatedAt resets all changes to the "created_at" field.
  10432. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  10433. m.created_at = nil
  10434. }
  10435. // SetUpdatedAt sets the "updated_at" field.
  10436. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  10437. m.updated_at = &t
  10438. }
  10439. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10440. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  10441. v := m.updated_at
  10442. if v == nil {
  10443. return
  10444. }
  10445. return *v, true
  10446. }
  10447. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  10448. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10450. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10451. if !m.op.Is(OpUpdateOne) {
  10452. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10453. }
  10454. if m.id == nil || m.oldValue == nil {
  10455. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10456. }
  10457. oldValue, err := m.oldValue(ctx)
  10458. if err != nil {
  10459. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10460. }
  10461. return oldValue.UpdatedAt, nil
  10462. }
  10463. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10464. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  10465. m.updated_at = nil
  10466. }
  10467. // SetDeletedAt sets the "deleted_at" field.
  10468. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  10469. m.deleted_at = &t
  10470. }
  10471. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10472. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  10473. v := m.deleted_at
  10474. if v == nil {
  10475. return
  10476. }
  10477. return *v, true
  10478. }
  10479. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  10480. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10482. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10483. if !m.op.Is(OpUpdateOne) {
  10484. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10485. }
  10486. if m.id == nil || m.oldValue == nil {
  10487. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10488. }
  10489. oldValue, err := m.oldValue(ctx)
  10490. if err != nil {
  10491. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10492. }
  10493. return oldValue.DeletedAt, nil
  10494. }
  10495. // ClearDeletedAt clears the value of the "deleted_at" field.
  10496. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  10497. m.deleted_at = nil
  10498. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  10499. }
  10500. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10501. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  10502. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  10503. return ok
  10504. }
  10505. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10506. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  10507. m.deleted_at = nil
  10508. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  10509. }
  10510. // SetStype sets the "stype" field.
  10511. func (m *EmployeeConfigMutation) SetStype(s string) {
  10512. m.stype = &s
  10513. }
  10514. // Stype returns the value of the "stype" field in the mutation.
  10515. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  10516. v := m.stype
  10517. if v == nil {
  10518. return
  10519. }
  10520. return *v, true
  10521. }
  10522. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  10523. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10525. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  10526. if !m.op.Is(OpUpdateOne) {
  10527. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  10528. }
  10529. if m.id == nil || m.oldValue == nil {
  10530. return v, errors.New("OldStype requires an ID field in the mutation")
  10531. }
  10532. oldValue, err := m.oldValue(ctx)
  10533. if err != nil {
  10534. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  10535. }
  10536. return oldValue.Stype, nil
  10537. }
  10538. // ResetStype resets all changes to the "stype" field.
  10539. func (m *EmployeeConfigMutation) ResetStype() {
  10540. m.stype = nil
  10541. }
  10542. // SetTitle sets the "title" field.
  10543. func (m *EmployeeConfigMutation) SetTitle(s string) {
  10544. m.title = &s
  10545. }
  10546. // Title returns the value of the "title" field in the mutation.
  10547. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  10548. v := m.title
  10549. if v == nil {
  10550. return
  10551. }
  10552. return *v, true
  10553. }
  10554. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  10555. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10557. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  10558. if !m.op.Is(OpUpdateOne) {
  10559. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  10560. }
  10561. if m.id == nil || m.oldValue == nil {
  10562. return v, errors.New("OldTitle requires an ID field in the mutation")
  10563. }
  10564. oldValue, err := m.oldValue(ctx)
  10565. if err != nil {
  10566. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  10567. }
  10568. return oldValue.Title, nil
  10569. }
  10570. // ResetTitle resets all changes to the "title" field.
  10571. func (m *EmployeeConfigMutation) ResetTitle() {
  10572. m.title = nil
  10573. }
  10574. // SetPhoto sets the "photo" field.
  10575. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  10576. m.photo = &s
  10577. }
  10578. // Photo returns the value of the "photo" field in the mutation.
  10579. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  10580. v := m.photo
  10581. if v == nil {
  10582. return
  10583. }
  10584. return *v, true
  10585. }
  10586. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  10587. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10589. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  10590. if !m.op.Is(OpUpdateOne) {
  10591. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  10592. }
  10593. if m.id == nil || m.oldValue == nil {
  10594. return v, errors.New("OldPhoto requires an ID field in the mutation")
  10595. }
  10596. oldValue, err := m.oldValue(ctx)
  10597. if err != nil {
  10598. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  10599. }
  10600. return oldValue.Photo, nil
  10601. }
  10602. // ResetPhoto resets all changes to the "photo" field.
  10603. func (m *EmployeeConfigMutation) ResetPhoto() {
  10604. m.photo = nil
  10605. }
  10606. // SetOrganizationID sets the "organization_id" field.
  10607. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  10608. m.organization_id = &u
  10609. m.addorganization_id = nil
  10610. }
  10611. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10612. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  10613. v := m.organization_id
  10614. if v == nil {
  10615. return
  10616. }
  10617. return *v, true
  10618. }
  10619. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  10620. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10622. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10623. if !m.op.Is(OpUpdateOne) {
  10624. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10625. }
  10626. if m.id == nil || m.oldValue == nil {
  10627. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10628. }
  10629. oldValue, err := m.oldValue(ctx)
  10630. if err != nil {
  10631. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10632. }
  10633. return oldValue.OrganizationID, nil
  10634. }
  10635. // AddOrganizationID adds u to the "organization_id" field.
  10636. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  10637. if m.addorganization_id != nil {
  10638. *m.addorganization_id += u
  10639. } else {
  10640. m.addorganization_id = &u
  10641. }
  10642. }
  10643. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10644. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  10645. v := m.addorganization_id
  10646. if v == nil {
  10647. return
  10648. }
  10649. return *v, true
  10650. }
  10651. // ClearOrganizationID clears the value of the "organization_id" field.
  10652. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  10653. m.organization_id = nil
  10654. m.addorganization_id = nil
  10655. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  10656. }
  10657. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10658. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  10659. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  10660. return ok
  10661. }
  10662. // ResetOrganizationID resets all changes to the "organization_id" field.
  10663. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  10664. m.organization_id = nil
  10665. m.addorganization_id = nil
  10666. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  10667. }
  10668. // Where appends a list predicates to the EmployeeConfigMutation builder.
  10669. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  10670. m.predicates = append(m.predicates, ps...)
  10671. }
  10672. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  10673. // users can use type-assertion to append predicates that do not depend on any generated package.
  10674. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  10675. p := make([]predicate.EmployeeConfig, len(ps))
  10676. for i := range ps {
  10677. p[i] = ps[i]
  10678. }
  10679. m.Where(p...)
  10680. }
  10681. // Op returns the operation name.
  10682. func (m *EmployeeConfigMutation) Op() Op {
  10683. return m.op
  10684. }
  10685. // SetOp allows setting the mutation operation.
  10686. func (m *EmployeeConfigMutation) SetOp(op Op) {
  10687. m.op = op
  10688. }
  10689. // Type returns the node type of this mutation (EmployeeConfig).
  10690. func (m *EmployeeConfigMutation) Type() string {
  10691. return m.typ
  10692. }
  10693. // Fields returns all fields that were changed during this mutation. Note that in
  10694. // order to get all numeric fields that were incremented/decremented, call
  10695. // AddedFields().
  10696. func (m *EmployeeConfigMutation) Fields() []string {
  10697. fields := make([]string, 0, 7)
  10698. if m.created_at != nil {
  10699. fields = append(fields, employeeconfig.FieldCreatedAt)
  10700. }
  10701. if m.updated_at != nil {
  10702. fields = append(fields, employeeconfig.FieldUpdatedAt)
  10703. }
  10704. if m.deleted_at != nil {
  10705. fields = append(fields, employeeconfig.FieldDeletedAt)
  10706. }
  10707. if m.stype != nil {
  10708. fields = append(fields, employeeconfig.FieldStype)
  10709. }
  10710. if m.title != nil {
  10711. fields = append(fields, employeeconfig.FieldTitle)
  10712. }
  10713. if m.photo != nil {
  10714. fields = append(fields, employeeconfig.FieldPhoto)
  10715. }
  10716. if m.organization_id != nil {
  10717. fields = append(fields, employeeconfig.FieldOrganizationID)
  10718. }
  10719. return fields
  10720. }
  10721. // Field returns the value of a field with the given name. The second boolean
  10722. // return value indicates that this field was not set, or was not defined in the
  10723. // schema.
  10724. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  10725. switch name {
  10726. case employeeconfig.FieldCreatedAt:
  10727. return m.CreatedAt()
  10728. case employeeconfig.FieldUpdatedAt:
  10729. return m.UpdatedAt()
  10730. case employeeconfig.FieldDeletedAt:
  10731. return m.DeletedAt()
  10732. case employeeconfig.FieldStype:
  10733. return m.Stype()
  10734. case employeeconfig.FieldTitle:
  10735. return m.Title()
  10736. case employeeconfig.FieldPhoto:
  10737. return m.Photo()
  10738. case employeeconfig.FieldOrganizationID:
  10739. return m.OrganizationID()
  10740. }
  10741. return nil, false
  10742. }
  10743. // OldField returns the old value of the field from the database. An error is
  10744. // returned if the mutation operation is not UpdateOne, or the query to the
  10745. // database failed.
  10746. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10747. switch name {
  10748. case employeeconfig.FieldCreatedAt:
  10749. return m.OldCreatedAt(ctx)
  10750. case employeeconfig.FieldUpdatedAt:
  10751. return m.OldUpdatedAt(ctx)
  10752. case employeeconfig.FieldDeletedAt:
  10753. return m.OldDeletedAt(ctx)
  10754. case employeeconfig.FieldStype:
  10755. return m.OldStype(ctx)
  10756. case employeeconfig.FieldTitle:
  10757. return m.OldTitle(ctx)
  10758. case employeeconfig.FieldPhoto:
  10759. return m.OldPhoto(ctx)
  10760. case employeeconfig.FieldOrganizationID:
  10761. return m.OldOrganizationID(ctx)
  10762. }
  10763. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  10764. }
  10765. // SetField sets the value of a field with the given name. It returns an error if
  10766. // the field is not defined in the schema, or if the type mismatched the field
  10767. // type.
  10768. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  10769. switch name {
  10770. case employeeconfig.FieldCreatedAt:
  10771. v, ok := value.(time.Time)
  10772. if !ok {
  10773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10774. }
  10775. m.SetCreatedAt(v)
  10776. return nil
  10777. case employeeconfig.FieldUpdatedAt:
  10778. v, ok := value.(time.Time)
  10779. if !ok {
  10780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10781. }
  10782. m.SetUpdatedAt(v)
  10783. return nil
  10784. case employeeconfig.FieldDeletedAt:
  10785. v, ok := value.(time.Time)
  10786. if !ok {
  10787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10788. }
  10789. m.SetDeletedAt(v)
  10790. return nil
  10791. case employeeconfig.FieldStype:
  10792. v, ok := value.(string)
  10793. if !ok {
  10794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10795. }
  10796. m.SetStype(v)
  10797. return nil
  10798. case employeeconfig.FieldTitle:
  10799. v, ok := value.(string)
  10800. if !ok {
  10801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10802. }
  10803. m.SetTitle(v)
  10804. return nil
  10805. case employeeconfig.FieldPhoto:
  10806. v, ok := value.(string)
  10807. if !ok {
  10808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10809. }
  10810. m.SetPhoto(v)
  10811. return nil
  10812. case employeeconfig.FieldOrganizationID:
  10813. v, ok := value.(uint64)
  10814. if !ok {
  10815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10816. }
  10817. m.SetOrganizationID(v)
  10818. return nil
  10819. }
  10820. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10821. }
  10822. // AddedFields returns all numeric fields that were incremented/decremented during
  10823. // this mutation.
  10824. func (m *EmployeeConfigMutation) AddedFields() []string {
  10825. var fields []string
  10826. if m.addorganization_id != nil {
  10827. fields = append(fields, employeeconfig.FieldOrganizationID)
  10828. }
  10829. return fields
  10830. }
  10831. // AddedField returns the numeric value that was incremented/decremented on a field
  10832. // with the given name. The second boolean return value indicates that this field
  10833. // was not set, or was not defined in the schema.
  10834. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  10835. switch name {
  10836. case employeeconfig.FieldOrganizationID:
  10837. return m.AddedOrganizationID()
  10838. }
  10839. return nil, false
  10840. }
  10841. // AddField adds the value to the field with the given name. It returns an error if
  10842. // the field is not defined in the schema, or if the type mismatched the field
  10843. // type.
  10844. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  10845. switch name {
  10846. case employeeconfig.FieldOrganizationID:
  10847. v, ok := value.(int64)
  10848. if !ok {
  10849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10850. }
  10851. m.AddOrganizationID(v)
  10852. return nil
  10853. }
  10854. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  10855. }
  10856. // ClearedFields returns all nullable fields that were cleared during this
  10857. // mutation.
  10858. func (m *EmployeeConfigMutation) ClearedFields() []string {
  10859. var fields []string
  10860. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  10861. fields = append(fields, employeeconfig.FieldDeletedAt)
  10862. }
  10863. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  10864. fields = append(fields, employeeconfig.FieldOrganizationID)
  10865. }
  10866. return fields
  10867. }
  10868. // FieldCleared returns a boolean indicating if a field with the given name was
  10869. // cleared in this mutation.
  10870. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  10871. _, ok := m.clearedFields[name]
  10872. return ok
  10873. }
  10874. // ClearField clears the value of the field with the given name. It returns an
  10875. // error if the field is not defined in the schema.
  10876. func (m *EmployeeConfigMutation) ClearField(name string) error {
  10877. switch name {
  10878. case employeeconfig.FieldDeletedAt:
  10879. m.ClearDeletedAt()
  10880. return nil
  10881. case employeeconfig.FieldOrganizationID:
  10882. m.ClearOrganizationID()
  10883. return nil
  10884. }
  10885. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  10886. }
  10887. // ResetField resets all changes in the mutation for the field with the given name.
  10888. // It returns an error if the field is not defined in the schema.
  10889. func (m *EmployeeConfigMutation) ResetField(name string) error {
  10890. switch name {
  10891. case employeeconfig.FieldCreatedAt:
  10892. m.ResetCreatedAt()
  10893. return nil
  10894. case employeeconfig.FieldUpdatedAt:
  10895. m.ResetUpdatedAt()
  10896. return nil
  10897. case employeeconfig.FieldDeletedAt:
  10898. m.ResetDeletedAt()
  10899. return nil
  10900. case employeeconfig.FieldStype:
  10901. m.ResetStype()
  10902. return nil
  10903. case employeeconfig.FieldTitle:
  10904. m.ResetTitle()
  10905. return nil
  10906. case employeeconfig.FieldPhoto:
  10907. m.ResetPhoto()
  10908. return nil
  10909. case employeeconfig.FieldOrganizationID:
  10910. m.ResetOrganizationID()
  10911. return nil
  10912. }
  10913. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10914. }
  10915. // AddedEdges returns all edge names that were set/added in this mutation.
  10916. func (m *EmployeeConfigMutation) AddedEdges() []string {
  10917. edges := make([]string, 0, 0)
  10918. return edges
  10919. }
  10920. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10921. // name in this mutation.
  10922. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  10923. return nil
  10924. }
  10925. // RemovedEdges returns all edge names that were removed in this mutation.
  10926. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  10927. edges := make([]string, 0, 0)
  10928. return edges
  10929. }
  10930. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10931. // the given name in this mutation.
  10932. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  10933. return nil
  10934. }
  10935. // ClearedEdges returns all edge names that were cleared in this mutation.
  10936. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  10937. edges := make([]string, 0, 0)
  10938. return edges
  10939. }
  10940. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10941. // was cleared in this mutation.
  10942. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  10943. return false
  10944. }
  10945. // ClearEdge clears the value of the edge with the given name. It returns an error
  10946. // if that edge is not defined in the schema.
  10947. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  10948. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  10949. }
  10950. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10951. // It returns an error if the edge is not defined in the schema.
  10952. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  10953. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  10954. }
  10955. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  10956. type LabelMutation struct {
  10957. config
  10958. op Op
  10959. typ string
  10960. id *uint64
  10961. created_at *time.Time
  10962. updated_at *time.Time
  10963. status *uint8
  10964. addstatus *int8
  10965. _type *int
  10966. add_type *int
  10967. name *string
  10968. from *int
  10969. addfrom *int
  10970. mode *int
  10971. addmode *int
  10972. conditions *string
  10973. organization_id *uint64
  10974. addorganization_id *int64
  10975. clearedFields map[string]struct{}
  10976. label_relationships map[uint64]struct{}
  10977. removedlabel_relationships map[uint64]struct{}
  10978. clearedlabel_relationships bool
  10979. done bool
  10980. oldValue func(context.Context) (*Label, error)
  10981. predicates []predicate.Label
  10982. }
  10983. var _ ent.Mutation = (*LabelMutation)(nil)
  10984. // labelOption allows management of the mutation configuration using functional options.
  10985. type labelOption func(*LabelMutation)
  10986. // newLabelMutation creates new mutation for the Label entity.
  10987. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  10988. m := &LabelMutation{
  10989. config: c,
  10990. op: op,
  10991. typ: TypeLabel,
  10992. clearedFields: make(map[string]struct{}),
  10993. }
  10994. for _, opt := range opts {
  10995. opt(m)
  10996. }
  10997. return m
  10998. }
  10999. // withLabelID sets the ID field of the mutation.
  11000. func withLabelID(id uint64) labelOption {
  11001. return func(m *LabelMutation) {
  11002. var (
  11003. err error
  11004. once sync.Once
  11005. value *Label
  11006. )
  11007. m.oldValue = func(ctx context.Context) (*Label, error) {
  11008. once.Do(func() {
  11009. if m.done {
  11010. err = errors.New("querying old values post mutation is not allowed")
  11011. } else {
  11012. value, err = m.Client().Label.Get(ctx, id)
  11013. }
  11014. })
  11015. return value, err
  11016. }
  11017. m.id = &id
  11018. }
  11019. }
  11020. // withLabel sets the old Label of the mutation.
  11021. func withLabel(node *Label) labelOption {
  11022. return func(m *LabelMutation) {
  11023. m.oldValue = func(context.Context) (*Label, error) {
  11024. return node, nil
  11025. }
  11026. m.id = &node.ID
  11027. }
  11028. }
  11029. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11030. // executed in a transaction (ent.Tx), a transactional client is returned.
  11031. func (m LabelMutation) Client() *Client {
  11032. client := &Client{config: m.config}
  11033. client.init()
  11034. return client
  11035. }
  11036. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11037. // it returns an error otherwise.
  11038. func (m LabelMutation) Tx() (*Tx, error) {
  11039. if _, ok := m.driver.(*txDriver); !ok {
  11040. return nil, errors.New("ent: mutation is not running in a transaction")
  11041. }
  11042. tx := &Tx{config: m.config}
  11043. tx.init()
  11044. return tx, nil
  11045. }
  11046. // SetID sets the value of the id field. Note that this
  11047. // operation is only accepted on creation of Label entities.
  11048. func (m *LabelMutation) SetID(id uint64) {
  11049. m.id = &id
  11050. }
  11051. // ID returns the ID value in the mutation. Note that the ID is only available
  11052. // if it was provided to the builder or after it was returned from the database.
  11053. func (m *LabelMutation) ID() (id uint64, exists bool) {
  11054. if m.id == nil {
  11055. return
  11056. }
  11057. return *m.id, true
  11058. }
  11059. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11060. // That means, if the mutation is applied within a transaction with an isolation level such
  11061. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11062. // or updated by the mutation.
  11063. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  11064. switch {
  11065. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11066. id, exists := m.ID()
  11067. if exists {
  11068. return []uint64{id}, nil
  11069. }
  11070. fallthrough
  11071. case m.op.Is(OpUpdate | OpDelete):
  11072. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  11073. default:
  11074. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11075. }
  11076. }
  11077. // SetCreatedAt sets the "created_at" field.
  11078. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  11079. m.created_at = &t
  11080. }
  11081. // CreatedAt returns the value of the "created_at" field in the mutation.
  11082. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  11083. v := m.created_at
  11084. if v == nil {
  11085. return
  11086. }
  11087. return *v, true
  11088. }
  11089. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  11090. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11092. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11093. if !m.op.Is(OpUpdateOne) {
  11094. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11095. }
  11096. if m.id == nil || m.oldValue == nil {
  11097. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11098. }
  11099. oldValue, err := m.oldValue(ctx)
  11100. if err != nil {
  11101. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11102. }
  11103. return oldValue.CreatedAt, nil
  11104. }
  11105. // ResetCreatedAt resets all changes to the "created_at" field.
  11106. func (m *LabelMutation) ResetCreatedAt() {
  11107. m.created_at = nil
  11108. }
  11109. // SetUpdatedAt sets the "updated_at" field.
  11110. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  11111. m.updated_at = &t
  11112. }
  11113. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11114. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  11115. v := m.updated_at
  11116. if v == nil {
  11117. return
  11118. }
  11119. return *v, true
  11120. }
  11121. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  11122. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11124. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11125. if !m.op.Is(OpUpdateOne) {
  11126. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11127. }
  11128. if m.id == nil || m.oldValue == nil {
  11129. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11130. }
  11131. oldValue, err := m.oldValue(ctx)
  11132. if err != nil {
  11133. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11134. }
  11135. return oldValue.UpdatedAt, nil
  11136. }
  11137. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11138. func (m *LabelMutation) ResetUpdatedAt() {
  11139. m.updated_at = nil
  11140. }
  11141. // SetStatus sets the "status" field.
  11142. func (m *LabelMutation) SetStatus(u uint8) {
  11143. m.status = &u
  11144. m.addstatus = nil
  11145. }
  11146. // Status returns the value of the "status" field in the mutation.
  11147. func (m *LabelMutation) Status() (r uint8, exists bool) {
  11148. v := m.status
  11149. if v == nil {
  11150. return
  11151. }
  11152. return *v, true
  11153. }
  11154. // OldStatus returns the old "status" field's value of the Label entity.
  11155. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11157. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11158. if !m.op.Is(OpUpdateOne) {
  11159. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11160. }
  11161. if m.id == nil || m.oldValue == nil {
  11162. return v, errors.New("OldStatus requires an ID field in the mutation")
  11163. }
  11164. oldValue, err := m.oldValue(ctx)
  11165. if err != nil {
  11166. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11167. }
  11168. return oldValue.Status, nil
  11169. }
  11170. // AddStatus adds u to the "status" field.
  11171. func (m *LabelMutation) AddStatus(u int8) {
  11172. if m.addstatus != nil {
  11173. *m.addstatus += u
  11174. } else {
  11175. m.addstatus = &u
  11176. }
  11177. }
  11178. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11179. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  11180. v := m.addstatus
  11181. if v == nil {
  11182. return
  11183. }
  11184. return *v, true
  11185. }
  11186. // ClearStatus clears the value of the "status" field.
  11187. func (m *LabelMutation) ClearStatus() {
  11188. m.status = nil
  11189. m.addstatus = nil
  11190. m.clearedFields[label.FieldStatus] = struct{}{}
  11191. }
  11192. // StatusCleared returns if the "status" field was cleared in this mutation.
  11193. func (m *LabelMutation) StatusCleared() bool {
  11194. _, ok := m.clearedFields[label.FieldStatus]
  11195. return ok
  11196. }
  11197. // ResetStatus resets all changes to the "status" field.
  11198. func (m *LabelMutation) ResetStatus() {
  11199. m.status = nil
  11200. m.addstatus = nil
  11201. delete(m.clearedFields, label.FieldStatus)
  11202. }
  11203. // SetType sets the "type" field.
  11204. func (m *LabelMutation) SetType(i int) {
  11205. m._type = &i
  11206. m.add_type = nil
  11207. }
  11208. // GetType returns the value of the "type" field in the mutation.
  11209. func (m *LabelMutation) GetType() (r int, exists bool) {
  11210. v := m._type
  11211. if v == nil {
  11212. return
  11213. }
  11214. return *v, true
  11215. }
  11216. // OldType returns the old "type" field's value of the Label entity.
  11217. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11219. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  11220. if !m.op.Is(OpUpdateOne) {
  11221. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11222. }
  11223. if m.id == nil || m.oldValue == nil {
  11224. return v, errors.New("OldType requires an ID field in the mutation")
  11225. }
  11226. oldValue, err := m.oldValue(ctx)
  11227. if err != nil {
  11228. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11229. }
  11230. return oldValue.Type, nil
  11231. }
  11232. // AddType adds i to the "type" field.
  11233. func (m *LabelMutation) AddType(i int) {
  11234. if m.add_type != nil {
  11235. *m.add_type += i
  11236. } else {
  11237. m.add_type = &i
  11238. }
  11239. }
  11240. // AddedType returns the value that was added to the "type" field in this mutation.
  11241. func (m *LabelMutation) AddedType() (r int, exists bool) {
  11242. v := m.add_type
  11243. if v == nil {
  11244. return
  11245. }
  11246. return *v, true
  11247. }
  11248. // ResetType resets all changes to the "type" field.
  11249. func (m *LabelMutation) ResetType() {
  11250. m._type = nil
  11251. m.add_type = nil
  11252. }
  11253. // SetName sets the "name" field.
  11254. func (m *LabelMutation) SetName(s string) {
  11255. m.name = &s
  11256. }
  11257. // Name returns the value of the "name" field in the mutation.
  11258. func (m *LabelMutation) Name() (r string, exists bool) {
  11259. v := m.name
  11260. if v == nil {
  11261. return
  11262. }
  11263. return *v, true
  11264. }
  11265. // OldName returns the old "name" field's value of the Label entity.
  11266. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11268. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  11269. if !m.op.Is(OpUpdateOne) {
  11270. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11271. }
  11272. if m.id == nil || m.oldValue == nil {
  11273. return v, errors.New("OldName requires an ID field in the mutation")
  11274. }
  11275. oldValue, err := m.oldValue(ctx)
  11276. if err != nil {
  11277. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11278. }
  11279. return oldValue.Name, nil
  11280. }
  11281. // ResetName resets all changes to the "name" field.
  11282. func (m *LabelMutation) ResetName() {
  11283. m.name = nil
  11284. }
  11285. // SetFrom sets the "from" field.
  11286. func (m *LabelMutation) SetFrom(i int) {
  11287. m.from = &i
  11288. m.addfrom = nil
  11289. }
  11290. // From returns the value of the "from" field in the mutation.
  11291. func (m *LabelMutation) From() (r int, exists bool) {
  11292. v := m.from
  11293. if v == nil {
  11294. return
  11295. }
  11296. return *v, true
  11297. }
  11298. // OldFrom returns the old "from" field's value of the Label entity.
  11299. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11301. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  11302. if !m.op.Is(OpUpdateOne) {
  11303. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  11304. }
  11305. if m.id == nil || m.oldValue == nil {
  11306. return v, errors.New("OldFrom requires an ID field in the mutation")
  11307. }
  11308. oldValue, err := m.oldValue(ctx)
  11309. if err != nil {
  11310. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  11311. }
  11312. return oldValue.From, nil
  11313. }
  11314. // AddFrom adds i to the "from" field.
  11315. func (m *LabelMutation) AddFrom(i int) {
  11316. if m.addfrom != nil {
  11317. *m.addfrom += i
  11318. } else {
  11319. m.addfrom = &i
  11320. }
  11321. }
  11322. // AddedFrom returns the value that was added to the "from" field in this mutation.
  11323. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  11324. v := m.addfrom
  11325. if v == nil {
  11326. return
  11327. }
  11328. return *v, true
  11329. }
  11330. // ResetFrom resets all changes to the "from" field.
  11331. func (m *LabelMutation) ResetFrom() {
  11332. m.from = nil
  11333. m.addfrom = nil
  11334. }
  11335. // SetMode sets the "mode" field.
  11336. func (m *LabelMutation) SetMode(i int) {
  11337. m.mode = &i
  11338. m.addmode = nil
  11339. }
  11340. // Mode returns the value of the "mode" field in the mutation.
  11341. func (m *LabelMutation) Mode() (r int, exists bool) {
  11342. v := m.mode
  11343. if v == nil {
  11344. return
  11345. }
  11346. return *v, true
  11347. }
  11348. // OldMode returns the old "mode" field's value of the Label entity.
  11349. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11351. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  11352. if !m.op.Is(OpUpdateOne) {
  11353. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  11354. }
  11355. if m.id == nil || m.oldValue == nil {
  11356. return v, errors.New("OldMode requires an ID field in the mutation")
  11357. }
  11358. oldValue, err := m.oldValue(ctx)
  11359. if err != nil {
  11360. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  11361. }
  11362. return oldValue.Mode, nil
  11363. }
  11364. // AddMode adds i to the "mode" field.
  11365. func (m *LabelMutation) AddMode(i int) {
  11366. if m.addmode != nil {
  11367. *m.addmode += i
  11368. } else {
  11369. m.addmode = &i
  11370. }
  11371. }
  11372. // AddedMode returns the value that was added to the "mode" field in this mutation.
  11373. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  11374. v := m.addmode
  11375. if v == nil {
  11376. return
  11377. }
  11378. return *v, true
  11379. }
  11380. // ResetMode resets all changes to the "mode" field.
  11381. func (m *LabelMutation) ResetMode() {
  11382. m.mode = nil
  11383. m.addmode = nil
  11384. }
  11385. // SetConditions sets the "conditions" field.
  11386. func (m *LabelMutation) SetConditions(s string) {
  11387. m.conditions = &s
  11388. }
  11389. // Conditions returns the value of the "conditions" field in the mutation.
  11390. func (m *LabelMutation) Conditions() (r string, exists bool) {
  11391. v := m.conditions
  11392. if v == nil {
  11393. return
  11394. }
  11395. return *v, true
  11396. }
  11397. // OldConditions returns the old "conditions" field's value of the Label entity.
  11398. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11400. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  11401. if !m.op.Is(OpUpdateOne) {
  11402. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  11403. }
  11404. if m.id == nil || m.oldValue == nil {
  11405. return v, errors.New("OldConditions requires an ID field in the mutation")
  11406. }
  11407. oldValue, err := m.oldValue(ctx)
  11408. if err != nil {
  11409. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  11410. }
  11411. return oldValue.Conditions, nil
  11412. }
  11413. // ClearConditions clears the value of the "conditions" field.
  11414. func (m *LabelMutation) ClearConditions() {
  11415. m.conditions = nil
  11416. m.clearedFields[label.FieldConditions] = struct{}{}
  11417. }
  11418. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  11419. func (m *LabelMutation) ConditionsCleared() bool {
  11420. _, ok := m.clearedFields[label.FieldConditions]
  11421. return ok
  11422. }
  11423. // ResetConditions resets all changes to the "conditions" field.
  11424. func (m *LabelMutation) ResetConditions() {
  11425. m.conditions = nil
  11426. delete(m.clearedFields, label.FieldConditions)
  11427. }
  11428. // SetOrganizationID sets the "organization_id" field.
  11429. func (m *LabelMutation) SetOrganizationID(u uint64) {
  11430. m.organization_id = &u
  11431. m.addorganization_id = nil
  11432. }
  11433. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11434. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  11435. v := m.organization_id
  11436. if v == nil {
  11437. return
  11438. }
  11439. return *v, true
  11440. }
  11441. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  11442. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11444. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11445. if !m.op.Is(OpUpdateOne) {
  11446. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11447. }
  11448. if m.id == nil || m.oldValue == nil {
  11449. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11450. }
  11451. oldValue, err := m.oldValue(ctx)
  11452. if err != nil {
  11453. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11454. }
  11455. return oldValue.OrganizationID, nil
  11456. }
  11457. // AddOrganizationID adds u to the "organization_id" field.
  11458. func (m *LabelMutation) AddOrganizationID(u int64) {
  11459. if m.addorganization_id != nil {
  11460. *m.addorganization_id += u
  11461. } else {
  11462. m.addorganization_id = &u
  11463. }
  11464. }
  11465. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11466. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  11467. v := m.addorganization_id
  11468. if v == nil {
  11469. return
  11470. }
  11471. return *v, true
  11472. }
  11473. // ClearOrganizationID clears the value of the "organization_id" field.
  11474. func (m *LabelMutation) ClearOrganizationID() {
  11475. m.organization_id = nil
  11476. m.addorganization_id = nil
  11477. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  11478. }
  11479. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11480. func (m *LabelMutation) OrganizationIDCleared() bool {
  11481. _, ok := m.clearedFields[label.FieldOrganizationID]
  11482. return ok
  11483. }
  11484. // ResetOrganizationID resets all changes to the "organization_id" field.
  11485. func (m *LabelMutation) ResetOrganizationID() {
  11486. m.organization_id = nil
  11487. m.addorganization_id = nil
  11488. delete(m.clearedFields, label.FieldOrganizationID)
  11489. }
  11490. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  11491. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  11492. if m.label_relationships == nil {
  11493. m.label_relationships = make(map[uint64]struct{})
  11494. }
  11495. for i := range ids {
  11496. m.label_relationships[ids[i]] = struct{}{}
  11497. }
  11498. }
  11499. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  11500. func (m *LabelMutation) ClearLabelRelationships() {
  11501. m.clearedlabel_relationships = true
  11502. }
  11503. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  11504. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  11505. return m.clearedlabel_relationships
  11506. }
  11507. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  11508. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  11509. if m.removedlabel_relationships == nil {
  11510. m.removedlabel_relationships = make(map[uint64]struct{})
  11511. }
  11512. for i := range ids {
  11513. delete(m.label_relationships, ids[i])
  11514. m.removedlabel_relationships[ids[i]] = struct{}{}
  11515. }
  11516. }
  11517. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  11518. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  11519. for id := range m.removedlabel_relationships {
  11520. ids = append(ids, id)
  11521. }
  11522. return
  11523. }
  11524. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  11525. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  11526. for id := range m.label_relationships {
  11527. ids = append(ids, id)
  11528. }
  11529. return
  11530. }
  11531. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  11532. func (m *LabelMutation) ResetLabelRelationships() {
  11533. m.label_relationships = nil
  11534. m.clearedlabel_relationships = false
  11535. m.removedlabel_relationships = nil
  11536. }
  11537. // Where appends a list predicates to the LabelMutation builder.
  11538. func (m *LabelMutation) Where(ps ...predicate.Label) {
  11539. m.predicates = append(m.predicates, ps...)
  11540. }
  11541. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  11542. // users can use type-assertion to append predicates that do not depend on any generated package.
  11543. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  11544. p := make([]predicate.Label, len(ps))
  11545. for i := range ps {
  11546. p[i] = ps[i]
  11547. }
  11548. m.Where(p...)
  11549. }
  11550. // Op returns the operation name.
  11551. func (m *LabelMutation) Op() Op {
  11552. return m.op
  11553. }
  11554. // SetOp allows setting the mutation operation.
  11555. func (m *LabelMutation) SetOp(op Op) {
  11556. m.op = op
  11557. }
  11558. // Type returns the node type of this mutation (Label).
  11559. func (m *LabelMutation) Type() string {
  11560. return m.typ
  11561. }
  11562. // Fields returns all fields that were changed during this mutation. Note that in
  11563. // order to get all numeric fields that were incremented/decremented, call
  11564. // AddedFields().
  11565. func (m *LabelMutation) Fields() []string {
  11566. fields := make([]string, 0, 9)
  11567. if m.created_at != nil {
  11568. fields = append(fields, label.FieldCreatedAt)
  11569. }
  11570. if m.updated_at != nil {
  11571. fields = append(fields, label.FieldUpdatedAt)
  11572. }
  11573. if m.status != nil {
  11574. fields = append(fields, label.FieldStatus)
  11575. }
  11576. if m._type != nil {
  11577. fields = append(fields, label.FieldType)
  11578. }
  11579. if m.name != nil {
  11580. fields = append(fields, label.FieldName)
  11581. }
  11582. if m.from != nil {
  11583. fields = append(fields, label.FieldFrom)
  11584. }
  11585. if m.mode != nil {
  11586. fields = append(fields, label.FieldMode)
  11587. }
  11588. if m.conditions != nil {
  11589. fields = append(fields, label.FieldConditions)
  11590. }
  11591. if m.organization_id != nil {
  11592. fields = append(fields, label.FieldOrganizationID)
  11593. }
  11594. return fields
  11595. }
  11596. // Field returns the value of a field with the given name. The second boolean
  11597. // return value indicates that this field was not set, or was not defined in the
  11598. // schema.
  11599. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  11600. switch name {
  11601. case label.FieldCreatedAt:
  11602. return m.CreatedAt()
  11603. case label.FieldUpdatedAt:
  11604. return m.UpdatedAt()
  11605. case label.FieldStatus:
  11606. return m.Status()
  11607. case label.FieldType:
  11608. return m.GetType()
  11609. case label.FieldName:
  11610. return m.Name()
  11611. case label.FieldFrom:
  11612. return m.From()
  11613. case label.FieldMode:
  11614. return m.Mode()
  11615. case label.FieldConditions:
  11616. return m.Conditions()
  11617. case label.FieldOrganizationID:
  11618. return m.OrganizationID()
  11619. }
  11620. return nil, false
  11621. }
  11622. // OldField returns the old value of the field from the database. An error is
  11623. // returned if the mutation operation is not UpdateOne, or the query to the
  11624. // database failed.
  11625. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11626. switch name {
  11627. case label.FieldCreatedAt:
  11628. return m.OldCreatedAt(ctx)
  11629. case label.FieldUpdatedAt:
  11630. return m.OldUpdatedAt(ctx)
  11631. case label.FieldStatus:
  11632. return m.OldStatus(ctx)
  11633. case label.FieldType:
  11634. return m.OldType(ctx)
  11635. case label.FieldName:
  11636. return m.OldName(ctx)
  11637. case label.FieldFrom:
  11638. return m.OldFrom(ctx)
  11639. case label.FieldMode:
  11640. return m.OldMode(ctx)
  11641. case label.FieldConditions:
  11642. return m.OldConditions(ctx)
  11643. case label.FieldOrganizationID:
  11644. return m.OldOrganizationID(ctx)
  11645. }
  11646. return nil, fmt.Errorf("unknown Label field %s", name)
  11647. }
  11648. // SetField sets the value of a field with the given name. It returns an error if
  11649. // the field is not defined in the schema, or if the type mismatched the field
  11650. // type.
  11651. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  11652. switch name {
  11653. case label.FieldCreatedAt:
  11654. v, ok := value.(time.Time)
  11655. if !ok {
  11656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11657. }
  11658. m.SetCreatedAt(v)
  11659. return nil
  11660. case label.FieldUpdatedAt:
  11661. v, ok := value.(time.Time)
  11662. if !ok {
  11663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11664. }
  11665. m.SetUpdatedAt(v)
  11666. return nil
  11667. case label.FieldStatus:
  11668. v, ok := value.(uint8)
  11669. if !ok {
  11670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11671. }
  11672. m.SetStatus(v)
  11673. return nil
  11674. case label.FieldType:
  11675. v, ok := value.(int)
  11676. if !ok {
  11677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11678. }
  11679. m.SetType(v)
  11680. return nil
  11681. case label.FieldName:
  11682. v, ok := value.(string)
  11683. if !ok {
  11684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11685. }
  11686. m.SetName(v)
  11687. return nil
  11688. case label.FieldFrom:
  11689. v, ok := value.(int)
  11690. if !ok {
  11691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11692. }
  11693. m.SetFrom(v)
  11694. return nil
  11695. case label.FieldMode:
  11696. v, ok := value.(int)
  11697. if !ok {
  11698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11699. }
  11700. m.SetMode(v)
  11701. return nil
  11702. case label.FieldConditions:
  11703. v, ok := value.(string)
  11704. if !ok {
  11705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11706. }
  11707. m.SetConditions(v)
  11708. return nil
  11709. case label.FieldOrganizationID:
  11710. v, ok := value.(uint64)
  11711. if !ok {
  11712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11713. }
  11714. m.SetOrganizationID(v)
  11715. return nil
  11716. }
  11717. return fmt.Errorf("unknown Label field %s", name)
  11718. }
  11719. // AddedFields returns all numeric fields that were incremented/decremented during
  11720. // this mutation.
  11721. func (m *LabelMutation) AddedFields() []string {
  11722. var fields []string
  11723. if m.addstatus != nil {
  11724. fields = append(fields, label.FieldStatus)
  11725. }
  11726. if m.add_type != nil {
  11727. fields = append(fields, label.FieldType)
  11728. }
  11729. if m.addfrom != nil {
  11730. fields = append(fields, label.FieldFrom)
  11731. }
  11732. if m.addmode != nil {
  11733. fields = append(fields, label.FieldMode)
  11734. }
  11735. if m.addorganization_id != nil {
  11736. fields = append(fields, label.FieldOrganizationID)
  11737. }
  11738. return fields
  11739. }
  11740. // AddedField returns the numeric value that was incremented/decremented on a field
  11741. // with the given name. The second boolean return value indicates that this field
  11742. // was not set, or was not defined in the schema.
  11743. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  11744. switch name {
  11745. case label.FieldStatus:
  11746. return m.AddedStatus()
  11747. case label.FieldType:
  11748. return m.AddedType()
  11749. case label.FieldFrom:
  11750. return m.AddedFrom()
  11751. case label.FieldMode:
  11752. return m.AddedMode()
  11753. case label.FieldOrganizationID:
  11754. return m.AddedOrganizationID()
  11755. }
  11756. return nil, false
  11757. }
  11758. // AddField adds the value to the field with the given name. It returns an error if
  11759. // the field is not defined in the schema, or if the type mismatched the field
  11760. // type.
  11761. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  11762. switch name {
  11763. case label.FieldStatus:
  11764. v, ok := value.(int8)
  11765. if !ok {
  11766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11767. }
  11768. m.AddStatus(v)
  11769. return nil
  11770. case label.FieldType:
  11771. v, ok := value.(int)
  11772. if !ok {
  11773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11774. }
  11775. m.AddType(v)
  11776. return nil
  11777. case label.FieldFrom:
  11778. v, ok := value.(int)
  11779. if !ok {
  11780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11781. }
  11782. m.AddFrom(v)
  11783. return nil
  11784. case label.FieldMode:
  11785. v, ok := value.(int)
  11786. if !ok {
  11787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11788. }
  11789. m.AddMode(v)
  11790. return nil
  11791. case label.FieldOrganizationID:
  11792. v, ok := value.(int64)
  11793. if !ok {
  11794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11795. }
  11796. m.AddOrganizationID(v)
  11797. return nil
  11798. }
  11799. return fmt.Errorf("unknown Label numeric field %s", name)
  11800. }
  11801. // ClearedFields returns all nullable fields that were cleared during this
  11802. // mutation.
  11803. func (m *LabelMutation) ClearedFields() []string {
  11804. var fields []string
  11805. if m.FieldCleared(label.FieldStatus) {
  11806. fields = append(fields, label.FieldStatus)
  11807. }
  11808. if m.FieldCleared(label.FieldConditions) {
  11809. fields = append(fields, label.FieldConditions)
  11810. }
  11811. if m.FieldCleared(label.FieldOrganizationID) {
  11812. fields = append(fields, label.FieldOrganizationID)
  11813. }
  11814. return fields
  11815. }
  11816. // FieldCleared returns a boolean indicating if a field with the given name was
  11817. // cleared in this mutation.
  11818. func (m *LabelMutation) FieldCleared(name string) bool {
  11819. _, ok := m.clearedFields[name]
  11820. return ok
  11821. }
  11822. // ClearField clears the value of the field with the given name. It returns an
  11823. // error if the field is not defined in the schema.
  11824. func (m *LabelMutation) ClearField(name string) error {
  11825. switch name {
  11826. case label.FieldStatus:
  11827. m.ClearStatus()
  11828. return nil
  11829. case label.FieldConditions:
  11830. m.ClearConditions()
  11831. return nil
  11832. case label.FieldOrganizationID:
  11833. m.ClearOrganizationID()
  11834. return nil
  11835. }
  11836. return fmt.Errorf("unknown Label nullable field %s", name)
  11837. }
  11838. // ResetField resets all changes in the mutation for the field with the given name.
  11839. // It returns an error if the field is not defined in the schema.
  11840. func (m *LabelMutation) ResetField(name string) error {
  11841. switch name {
  11842. case label.FieldCreatedAt:
  11843. m.ResetCreatedAt()
  11844. return nil
  11845. case label.FieldUpdatedAt:
  11846. m.ResetUpdatedAt()
  11847. return nil
  11848. case label.FieldStatus:
  11849. m.ResetStatus()
  11850. return nil
  11851. case label.FieldType:
  11852. m.ResetType()
  11853. return nil
  11854. case label.FieldName:
  11855. m.ResetName()
  11856. return nil
  11857. case label.FieldFrom:
  11858. m.ResetFrom()
  11859. return nil
  11860. case label.FieldMode:
  11861. m.ResetMode()
  11862. return nil
  11863. case label.FieldConditions:
  11864. m.ResetConditions()
  11865. return nil
  11866. case label.FieldOrganizationID:
  11867. m.ResetOrganizationID()
  11868. return nil
  11869. }
  11870. return fmt.Errorf("unknown Label field %s", name)
  11871. }
  11872. // AddedEdges returns all edge names that were set/added in this mutation.
  11873. func (m *LabelMutation) AddedEdges() []string {
  11874. edges := make([]string, 0, 1)
  11875. if m.label_relationships != nil {
  11876. edges = append(edges, label.EdgeLabelRelationships)
  11877. }
  11878. return edges
  11879. }
  11880. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11881. // name in this mutation.
  11882. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  11883. switch name {
  11884. case label.EdgeLabelRelationships:
  11885. ids := make([]ent.Value, 0, len(m.label_relationships))
  11886. for id := range m.label_relationships {
  11887. ids = append(ids, id)
  11888. }
  11889. return ids
  11890. }
  11891. return nil
  11892. }
  11893. // RemovedEdges returns all edge names that were removed in this mutation.
  11894. func (m *LabelMutation) RemovedEdges() []string {
  11895. edges := make([]string, 0, 1)
  11896. if m.removedlabel_relationships != nil {
  11897. edges = append(edges, label.EdgeLabelRelationships)
  11898. }
  11899. return edges
  11900. }
  11901. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11902. // the given name in this mutation.
  11903. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  11904. switch name {
  11905. case label.EdgeLabelRelationships:
  11906. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  11907. for id := range m.removedlabel_relationships {
  11908. ids = append(ids, id)
  11909. }
  11910. return ids
  11911. }
  11912. return nil
  11913. }
  11914. // ClearedEdges returns all edge names that were cleared in this mutation.
  11915. func (m *LabelMutation) ClearedEdges() []string {
  11916. edges := make([]string, 0, 1)
  11917. if m.clearedlabel_relationships {
  11918. edges = append(edges, label.EdgeLabelRelationships)
  11919. }
  11920. return edges
  11921. }
  11922. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11923. // was cleared in this mutation.
  11924. func (m *LabelMutation) EdgeCleared(name string) bool {
  11925. switch name {
  11926. case label.EdgeLabelRelationships:
  11927. return m.clearedlabel_relationships
  11928. }
  11929. return false
  11930. }
  11931. // ClearEdge clears the value of the edge with the given name. It returns an error
  11932. // if that edge is not defined in the schema.
  11933. func (m *LabelMutation) ClearEdge(name string) error {
  11934. switch name {
  11935. }
  11936. return fmt.Errorf("unknown Label unique edge %s", name)
  11937. }
  11938. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11939. // It returns an error if the edge is not defined in the schema.
  11940. func (m *LabelMutation) ResetEdge(name string) error {
  11941. switch name {
  11942. case label.EdgeLabelRelationships:
  11943. m.ResetLabelRelationships()
  11944. return nil
  11945. }
  11946. return fmt.Errorf("unknown Label edge %s", name)
  11947. }
  11948. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  11949. type LabelRelationshipMutation struct {
  11950. config
  11951. op Op
  11952. typ string
  11953. id *uint64
  11954. created_at *time.Time
  11955. updated_at *time.Time
  11956. status *uint8
  11957. addstatus *int8
  11958. deleted_at *time.Time
  11959. organization_id *uint64
  11960. addorganization_id *int64
  11961. clearedFields map[string]struct{}
  11962. contacts *uint64
  11963. clearedcontacts bool
  11964. labels *uint64
  11965. clearedlabels bool
  11966. done bool
  11967. oldValue func(context.Context) (*LabelRelationship, error)
  11968. predicates []predicate.LabelRelationship
  11969. }
  11970. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  11971. // labelrelationshipOption allows management of the mutation configuration using functional options.
  11972. type labelrelationshipOption func(*LabelRelationshipMutation)
  11973. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  11974. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  11975. m := &LabelRelationshipMutation{
  11976. config: c,
  11977. op: op,
  11978. typ: TypeLabelRelationship,
  11979. clearedFields: make(map[string]struct{}),
  11980. }
  11981. for _, opt := range opts {
  11982. opt(m)
  11983. }
  11984. return m
  11985. }
  11986. // withLabelRelationshipID sets the ID field of the mutation.
  11987. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  11988. return func(m *LabelRelationshipMutation) {
  11989. var (
  11990. err error
  11991. once sync.Once
  11992. value *LabelRelationship
  11993. )
  11994. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  11995. once.Do(func() {
  11996. if m.done {
  11997. err = errors.New("querying old values post mutation is not allowed")
  11998. } else {
  11999. value, err = m.Client().LabelRelationship.Get(ctx, id)
  12000. }
  12001. })
  12002. return value, err
  12003. }
  12004. m.id = &id
  12005. }
  12006. }
  12007. // withLabelRelationship sets the old LabelRelationship of the mutation.
  12008. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  12009. return func(m *LabelRelationshipMutation) {
  12010. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  12011. return node, nil
  12012. }
  12013. m.id = &node.ID
  12014. }
  12015. }
  12016. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12017. // executed in a transaction (ent.Tx), a transactional client is returned.
  12018. func (m LabelRelationshipMutation) Client() *Client {
  12019. client := &Client{config: m.config}
  12020. client.init()
  12021. return client
  12022. }
  12023. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12024. // it returns an error otherwise.
  12025. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  12026. if _, ok := m.driver.(*txDriver); !ok {
  12027. return nil, errors.New("ent: mutation is not running in a transaction")
  12028. }
  12029. tx := &Tx{config: m.config}
  12030. tx.init()
  12031. return tx, nil
  12032. }
  12033. // SetID sets the value of the id field. Note that this
  12034. // operation is only accepted on creation of LabelRelationship entities.
  12035. func (m *LabelRelationshipMutation) SetID(id uint64) {
  12036. m.id = &id
  12037. }
  12038. // ID returns the ID value in the mutation. Note that the ID is only available
  12039. // if it was provided to the builder or after it was returned from the database.
  12040. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  12041. if m.id == nil {
  12042. return
  12043. }
  12044. return *m.id, true
  12045. }
  12046. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12047. // That means, if the mutation is applied within a transaction with an isolation level such
  12048. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12049. // or updated by the mutation.
  12050. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  12051. switch {
  12052. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12053. id, exists := m.ID()
  12054. if exists {
  12055. return []uint64{id}, nil
  12056. }
  12057. fallthrough
  12058. case m.op.Is(OpUpdate | OpDelete):
  12059. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  12060. default:
  12061. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12062. }
  12063. }
  12064. // SetCreatedAt sets the "created_at" field.
  12065. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  12066. m.created_at = &t
  12067. }
  12068. // CreatedAt returns the value of the "created_at" field in the mutation.
  12069. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  12070. v := m.created_at
  12071. if v == nil {
  12072. return
  12073. }
  12074. return *v, true
  12075. }
  12076. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  12077. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12079. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12080. if !m.op.Is(OpUpdateOne) {
  12081. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12082. }
  12083. if m.id == nil || m.oldValue == nil {
  12084. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12085. }
  12086. oldValue, err := m.oldValue(ctx)
  12087. if err != nil {
  12088. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12089. }
  12090. return oldValue.CreatedAt, nil
  12091. }
  12092. // ResetCreatedAt resets all changes to the "created_at" field.
  12093. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  12094. m.created_at = nil
  12095. }
  12096. // SetUpdatedAt sets the "updated_at" field.
  12097. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  12098. m.updated_at = &t
  12099. }
  12100. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12101. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  12102. v := m.updated_at
  12103. if v == nil {
  12104. return
  12105. }
  12106. return *v, true
  12107. }
  12108. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  12109. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12111. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12112. if !m.op.Is(OpUpdateOne) {
  12113. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12114. }
  12115. if m.id == nil || m.oldValue == nil {
  12116. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12117. }
  12118. oldValue, err := m.oldValue(ctx)
  12119. if err != nil {
  12120. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12121. }
  12122. return oldValue.UpdatedAt, nil
  12123. }
  12124. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12125. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  12126. m.updated_at = nil
  12127. }
  12128. // SetStatus sets the "status" field.
  12129. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  12130. m.status = &u
  12131. m.addstatus = nil
  12132. }
  12133. // Status returns the value of the "status" field in the mutation.
  12134. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  12135. v := m.status
  12136. if v == nil {
  12137. return
  12138. }
  12139. return *v, true
  12140. }
  12141. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  12142. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12144. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12145. if !m.op.Is(OpUpdateOne) {
  12146. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12147. }
  12148. if m.id == nil || m.oldValue == nil {
  12149. return v, errors.New("OldStatus requires an ID field in the mutation")
  12150. }
  12151. oldValue, err := m.oldValue(ctx)
  12152. if err != nil {
  12153. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12154. }
  12155. return oldValue.Status, nil
  12156. }
  12157. // AddStatus adds u to the "status" field.
  12158. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  12159. if m.addstatus != nil {
  12160. *m.addstatus += u
  12161. } else {
  12162. m.addstatus = &u
  12163. }
  12164. }
  12165. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12166. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  12167. v := m.addstatus
  12168. if v == nil {
  12169. return
  12170. }
  12171. return *v, true
  12172. }
  12173. // ClearStatus clears the value of the "status" field.
  12174. func (m *LabelRelationshipMutation) ClearStatus() {
  12175. m.status = nil
  12176. m.addstatus = nil
  12177. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  12178. }
  12179. // StatusCleared returns if the "status" field was cleared in this mutation.
  12180. func (m *LabelRelationshipMutation) StatusCleared() bool {
  12181. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  12182. return ok
  12183. }
  12184. // ResetStatus resets all changes to the "status" field.
  12185. func (m *LabelRelationshipMutation) ResetStatus() {
  12186. m.status = nil
  12187. m.addstatus = nil
  12188. delete(m.clearedFields, labelrelationship.FieldStatus)
  12189. }
  12190. // SetDeletedAt sets the "deleted_at" field.
  12191. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  12192. m.deleted_at = &t
  12193. }
  12194. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12195. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  12196. v := m.deleted_at
  12197. if v == nil {
  12198. return
  12199. }
  12200. return *v, true
  12201. }
  12202. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  12203. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12205. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12206. if !m.op.Is(OpUpdateOne) {
  12207. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12208. }
  12209. if m.id == nil || m.oldValue == nil {
  12210. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12211. }
  12212. oldValue, err := m.oldValue(ctx)
  12213. if err != nil {
  12214. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12215. }
  12216. return oldValue.DeletedAt, nil
  12217. }
  12218. // ClearDeletedAt clears the value of the "deleted_at" field.
  12219. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  12220. m.deleted_at = nil
  12221. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  12222. }
  12223. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12224. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  12225. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  12226. return ok
  12227. }
  12228. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12229. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  12230. m.deleted_at = nil
  12231. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  12232. }
  12233. // SetLabelID sets the "label_id" field.
  12234. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  12235. m.labels = &u
  12236. }
  12237. // LabelID returns the value of the "label_id" field in the mutation.
  12238. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  12239. v := m.labels
  12240. if v == nil {
  12241. return
  12242. }
  12243. return *v, true
  12244. }
  12245. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  12246. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12248. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  12249. if !m.op.Is(OpUpdateOne) {
  12250. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  12251. }
  12252. if m.id == nil || m.oldValue == nil {
  12253. return v, errors.New("OldLabelID requires an ID field in the mutation")
  12254. }
  12255. oldValue, err := m.oldValue(ctx)
  12256. if err != nil {
  12257. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  12258. }
  12259. return oldValue.LabelID, nil
  12260. }
  12261. // ResetLabelID resets all changes to the "label_id" field.
  12262. func (m *LabelRelationshipMutation) ResetLabelID() {
  12263. m.labels = nil
  12264. }
  12265. // SetContactID sets the "contact_id" field.
  12266. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  12267. m.contacts = &u
  12268. }
  12269. // ContactID returns the value of the "contact_id" field in the mutation.
  12270. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  12271. v := m.contacts
  12272. if v == nil {
  12273. return
  12274. }
  12275. return *v, true
  12276. }
  12277. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  12278. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12280. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  12281. if !m.op.Is(OpUpdateOne) {
  12282. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  12283. }
  12284. if m.id == nil || m.oldValue == nil {
  12285. return v, errors.New("OldContactID requires an ID field in the mutation")
  12286. }
  12287. oldValue, err := m.oldValue(ctx)
  12288. if err != nil {
  12289. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  12290. }
  12291. return oldValue.ContactID, nil
  12292. }
  12293. // ResetContactID resets all changes to the "contact_id" field.
  12294. func (m *LabelRelationshipMutation) ResetContactID() {
  12295. m.contacts = nil
  12296. }
  12297. // SetOrganizationID sets the "organization_id" field.
  12298. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  12299. m.organization_id = &u
  12300. m.addorganization_id = nil
  12301. }
  12302. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12303. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  12304. v := m.organization_id
  12305. if v == nil {
  12306. return
  12307. }
  12308. return *v, true
  12309. }
  12310. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  12311. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12313. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12314. if !m.op.Is(OpUpdateOne) {
  12315. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12316. }
  12317. if m.id == nil || m.oldValue == nil {
  12318. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12319. }
  12320. oldValue, err := m.oldValue(ctx)
  12321. if err != nil {
  12322. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12323. }
  12324. return oldValue.OrganizationID, nil
  12325. }
  12326. // AddOrganizationID adds u to the "organization_id" field.
  12327. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  12328. if m.addorganization_id != nil {
  12329. *m.addorganization_id += u
  12330. } else {
  12331. m.addorganization_id = &u
  12332. }
  12333. }
  12334. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12335. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  12336. v := m.addorganization_id
  12337. if v == nil {
  12338. return
  12339. }
  12340. return *v, true
  12341. }
  12342. // ClearOrganizationID clears the value of the "organization_id" field.
  12343. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  12344. m.organization_id = nil
  12345. m.addorganization_id = nil
  12346. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  12347. }
  12348. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12349. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  12350. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  12351. return ok
  12352. }
  12353. // ResetOrganizationID resets all changes to the "organization_id" field.
  12354. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  12355. m.organization_id = nil
  12356. m.addorganization_id = nil
  12357. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  12358. }
  12359. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  12360. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  12361. m.contacts = &id
  12362. }
  12363. // ClearContacts clears the "contacts" edge to the Contact entity.
  12364. func (m *LabelRelationshipMutation) ClearContacts() {
  12365. m.clearedcontacts = true
  12366. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  12367. }
  12368. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  12369. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  12370. return m.clearedcontacts
  12371. }
  12372. // ContactsID returns the "contacts" edge ID in the mutation.
  12373. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  12374. if m.contacts != nil {
  12375. return *m.contacts, true
  12376. }
  12377. return
  12378. }
  12379. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  12380. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12381. // ContactsID instead. It exists only for internal usage by the builders.
  12382. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  12383. if id := m.contacts; id != nil {
  12384. ids = append(ids, *id)
  12385. }
  12386. return
  12387. }
  12388. // ResetContacts resets all changes to the "contacts" edge.
  12389. func (m *LabelRelationshipMutation) ResetContacts() {
  12390. m.contacts = nil
  12391. m.clearedcontacts = false
  12392. }
  12393. // SetLabelsID sets the "labels" edge to the Label entity by id.
  12394. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  12395. m.labels = &id
  12396. }
  12397. // ClearLabels clears the "labels" edge to the Label entity.
  12398. func (m *LabelRelationshipMutation) ClearLabels() {
  12399. m.clearedlabels = true
  12400. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  12401. }
  12402. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  12403. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  12404. return m.clearedlabels
  12405. }
  12406. // LabelsID returns the "labels" edge ID in the mutation.
  12407. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  12408. if m.labels != nil {
  12409. return *m.labels, true
  12410. }
  12411. return
  12412. }
  12413. // LabelsIDs returns the "labels" edge IDs in the mutation.
  12414. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12415. // LabelsID instead. It exists only for internal usage by the builders.
  12416. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  12417. if id := m.labels; id != nil {
  12418. ids = append(ids, *id)
  12419. }
  12420. return
  12421. }
  12422. // ResetLabels resets all changes to the "labels" edge.
  12423. func (m *LabelRelationshipMutation) ResetLabels() {
  12424. m.labels = nil
  12425. m.clearedlabels = false
  12426. }
  12427. // Where appends a list predicates to the LabelRelationshipMutation builder.
  12428. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  12429. m.predicates = append(m.predicates, ps...)
  12430. }
  12431. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  12432. // users can use type-assertion to append predicates that do not depend on any generated package.
  12433. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  12434. p := make([]predicate.LabelRelationship, len(ps))
  12435. for i := range ps {
  12436. p[i] = ps[i]
  12437. }
  12438. m.Where(p...)
  12439. }
  12440. // Op returns the operation name.
  12441. func (m *LabelRelationshipMutation) Op() Op {
  12442. return m.op
  12443. }
  12444. // SetOp allows setting the mutation operation.
  12445. func (m *LabelRelationshipMutation) SetOp(op Op) {
  12446. m.op = op
  12447. }
  12448. // Type returns the node type of this mutation (LabelRelationship).
  12449. func (m *LabelRelationshipMutation) Type() string {
  12450. return m.typ
  12451. }
  12452. // Fields returns all fields that were changed during this mutation. Note that in
  12453. // order to get all numeric fields that were incremented/decremented, call
  12454. // AddedFields().
  12455. func (m *LabelRelationshipMutation) Fields() []string {
  12456. fields := make([]string, 0, 7)
  12457. if m.created_at != nil {
  12458. fields = append(fields, labelrelationship.FieldCreatedAt)
  12459. }
  12460. if m.updated_at != nil {
  12461. fields = append(fields, labelrelationship.FieldUpdatedAt)
  12462. }
  12463. if m.status != nil {
  12464. fields = append(fields, labelrelationship.FieldStatus)
  12465. }
  12466. if m.deleted_at != nil {
  12467. fields = append(fields, labelrelationship.FieldDeletedAt)
  12468. }
  12469. if m.labels != nil {
  12470. fields = append(fields, labelrelationship.FieldLabelID)
  12471. }
  12472. if m.contacts != nil {
  12473. fields = append(fields, labelrelationship.FieldContactID)
  12474. }
  12475. if m.organization_id != nil {
  12476. fields = append(fields, labelrelationship.FieldOrganizationID)
  12477. }
  12478. return fields
  12479. }
  12480. // Field returns the value of a field with the given name. The second boolean
  12481. // return value indicates that this field was not set, or was not defined in the
  12482. // schema.
  12483. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  12484. switch name {
  12485. case labelrelationship.FieldCreatedAt:
  12486. return m.CreatedAt()
  12487. case labelrelationship.FieldUpdatedAt:
  12488. return m.UpdatedAt()
  12489. case labelrelationship.FieldStatus:
  12490. return m.Status()
  12491. case labelrelationship.FieldDeletedAt:
  12492. return m.DeletedAt()
  12493. case labelrelationship.FieldLabelID:
  12494. return m.LabelID()
  12495. case labelrelationship.FieldContactID:
  12496. return m.ContactID()
  12497. case labelrelationship.FieldOrganizationID:
  12498. return m.OrganizationID()
  12499. }
  12500. return nil, false
  12501. }
  12502. // OldField returns the old value of the field from the database. An error is
  12503. // returned if the mutation operation is not UpdateOne, or the query to the
  12504. // database failed.
  12505. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12506. switch name {
  12507. case labelrelationship.FieldCreatedAt:
  12508. return m.OldCreatedAt(ctx)
  12509. case labelrelationship.FieldUpdatedAt:
  12510. return m.OldUpdatedAt(ctx)
  12511. case labelrelationship.FieldStatus:
  12512. return m.OldStatus(ctx)
  12513. case labelrelationship.FieldDeletedAt:
  12514. return m.OldDeletedAt(ctx)
  12515. case labelrelationship.FieldLabelID:
  12516. return m.OldLabelID(ctx)
  12517. case labelrelationship.FieldContactID:
  12518. return m.OldContactID(ctx)
  12519. case labelrelationship.FieldOrganizationID:
  12520. return m.OldOrganizationID(ctx)
  12521. }
  12522. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  12523. }
  12524. // SetField sets the value of a field with the given name. It returns an error if
  12525. // the field is not defined in the schema, or if the type mismatched the field
  12526. // type.
  12527. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  12528. switch name {
  12529. case labelrelationship.FieldCreatedAt:
  12530. v, ok := value.(time.Time)
  12531. if !ok {
  12532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12533. }
  12534. m.SetCreatedAt(v)
  12535. return nil
  12536. case labelrelationship.FieldUpdatedAt:
  12537. v, ok := value.(time.Time)
  12538. if !ok {
  12539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12540. }
  12541. m.SetUpdatedAt(v)
  12542. return nil
  12543. case labelrelationship.FieldStatus:
  12544. v, ok := value.(uint8)
  12545. if !ok {
  12546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12547. }
  12548. m.SetStatus(v)
  12549. return nil
  12550. case labelrelationship.FieldDeletedAt:
  12551. v, ok := value.(time.Time)
  12552. if !ok {
  12553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12554. }
  12555. m.SetDeletedAt(v)
  12556. return nil
  12557. case labelrelationship.FieldLabelID:
  12558. v, ok := value.(uint64)
  12559. if !ok {
  12560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12561. }
  12562. m.SetLabelID(v)
  12563. return nil
  12564. case labelrelationship.FieldContactID:
  12565. v, ok := value.(uint64)
  12566. if !ok {
  12567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12568. }
  12569. m.SetContactID(v)
  12570. return nil
  12571. case labelrelationship.FieldOrganizationID:
  12572. v, ok := value.(uint64)
  12573. if !ok {
  12574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12575. }
  12576. m.SetOrganizationID(v)
  12577. return nil
  12578. }
  12579. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12580. }
  12581. // AddedFields returns all numeric fields that were incremented/decremented during
  12582. // this mutation.
  12583. func (m *LabelRelationshipMutation) AddedFields() []string {
  12584. var fields []string
  12585. if m.addstatus != nil {
  12586. fields = append(fields, labelrelationship.FieldStatus)
  12587. }
  12588. if m.addorganization_id != nil {
  12589. fields = append(fields, labelrelationship.FieldOrganizationID)
  12590. }
  12591. return fields
  12592. }
  12593. // AddedField returns the numeric value that was incremented/decremented on a field
  12594. // with the given name. The second boolean return value indicates that this field
  12595. // was not set, or was not defined in the schema.
  12596. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  12597. switch name {
  12598. case labelrelationship.FieldStatus:
  12599. return m.AddedStatus()
  12600. case labelrelationship.FieldOrganizationID:
  12601. return m.AddedOrganizationID()
  12602. }
  12603. return nil, false
  12604. }
  12605. // AddField adds the value to the field with the given name. It returns an error if
  12606. // the field is not defined in the schema, or if the type mismatched the field
  12607. // type.
  12608. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  12609. switch name {
  12610. case labelrelationship.FieldStatus:
  12611. v, ok := value.(int8)
  12612. if !ok {
  12613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12614. }
  12615. m.AddStatus(v)
  12616. return nil
  12617. case labelrelationship.FieldOrganizationID:
  12618. v, ok := value.(int64)
  12619. if !ok {
  12620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12621. }
  12622. m.AddOrganizationID(v)
  12623. return nil
  12624. }
  12625. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  12626. }
  12627. // ClearedFields returns all nullable fields that were cleared during this
  12628. // mutation.
  12629. func (m *LabelRelationshipMutation) ClearedFields() []string {
  12630. var fields []string
  12631. if m.FieldCleared(labelrelationship.FieldStatus) {
  12632. fields = append(fields, labelrelationship.FieldStatus)
  12633. }
  12634. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  12635. fields = append(fields, labelrelationship.FieldDeletedAt)
  12636. }
  12637. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  12638. fields = append(fields, labelrelationship.FieldOrganizationID)
  12639. }
  12640. return fields
  12641. }
  12642. // FieldCleared returns a boolean indicating if a field with the given name was
  12643. // cleared in this mutation.
  12644. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  12645. _, ok := m.clearedFields[name]
  12646. return ok
  12647. }
  12648. // ClearField clears the value of the field with the given name. It returns an
  12649. // error if the field is not defined in the schema.
  12650. func (m *LabelRelationshipMutation) ClearField(name string) error {
  12651. switch name {
  12652. case labelrelationship.FieldStatus:
  12653. m.ClearStatus()
  12654. return nil
  12655. case labelrelationship.FieldDeletedAt:
  12656. m.ClearDeletedAt()
  12657. return nil
  12658. case labelrelationship.FieldOrganizationID:
  12659. m.ClearOrganizationID()
  12660. return nil
  12661. }
  12662. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  12663. }
  12664. // ResetField resets all changes in the mutation for the field with the given name.
  12665. // It returns an error if the field is not defined in the schema.
  12666. func (m *LabelRelationshipMutation) ResetField(name string) error {
  12667. switch name {
  12668. case labelrelationship.FieldCreatedAt:
  12669. m.ResetCreatedAt()
  12670. return nil
  12671. case labelrelationship.FieldUpdatedAt:
  12672. m.ResetUpdatedAt()
  12673. return nil
  12674. case labelrelationship.FieldStatus:
  12675. m.ResetStatus()
  12676. return nil
  12677. case labelrelationship.FieldDeletedAt:
  12678. m.ResetDeletedAt()
  12679. return nil
  12680. case labelrelationship.FieldLabelID:
  12681. m.ResetLabelID()
  12682. return nil
  12683. case labelrelationship.FieldContactID:
  12684. m.ResetContactID()
  12685. return nil
  12686. case labelrelationship.FieldOrganizationID:
  12687. m.ResetOrganizationID()
  12688. return nil
  12689. }
  12690. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12691. }
  12692. // AddedEdges returns all edge names that were set/added in this mutation.
  12693. func (m *LabelRelationshipMutation) AddedEdges() []string {
  12694. edges := make([]string, 0, 2)
  12695. if m.contacts != nil {
  12696. edges = append(edges, labelrelationship.EdgeContacts)
  12697. }
  12698. if m.labels != nil {
  12699. edges = append(edges, labelrelationship.EdgeLabels)
  12700. }
  12701. return edges
  12702. }
  12703. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12704. // name in this mutation.
  12705. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  12706. switch name {
  12707. case labelrelationship.EdgeContacts:
  12708. if id := m.contacts; id != nil {
  12709. return []ent.Value{*id}
  12710. }
  12711. case labelrelationship.EdgeLabels:
  12712. if id := m.labels; id != nil {
  12713. return []ent.Value{*id}
  12714. }
  12715. }
  12716. return nil
  12717. }
  12718. // RemovedEdges returns all edge names that were removed in this mutation.
  12719. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  12720. edges := make([]string, 0, 2)
  12721. return edges
  12722. }
  12723. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12724. // the given name in this mutation.
  12725. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  12726. return nil
  12727. }
  12728. // ClearedEdges returns all edge names that were cleared in this mutation.
  12729. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  12730. edges := make([]string, 0, 2)
  12731. if m.clearedcontacts {
  12732. edges = append(edges, labelrelationship.EdgeContacts)
  12733. }
  12734. if m.clearedlabels {
  12735. edges = append(edges, labelrelationship.EdgeLabels)
  12736. }
  12737. return edges
  12738. }
  12739. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12740. // was cleared in this mutation.
  12741. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  12742. switch name {
  12743. case labelrelationship.EdgeContacts:
  12744. return m.clearedcontacts
  12745. case labelrelationship.EdgeLabels:
  12746. return m.clearedlabels
  12747. }
  12748. return false
  12749. }
  12750. // ClearEdge clears the value of the edge with the given name. It returns an error
  12751. // if that edge is not defined in the schema.
  12752. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  12753. switch name {
  12754. case labelrelationship.EdgeContacts:
  12755. m.ClearContacts()
  12756. return nil
  12757. case labelrelationship.EdgeLabels:
  12758. m.ClearLabels()
  12759. return nil
  12760. }
  12761. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  12762. }
  12763. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12764. // It returns an error if the edge is not defined in the schema.
  12765. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  12766. switch name {
  12767. case labelrelationship.EdgeContacts:
  12768. m.ResetContacts()
  12769. return nil
  12770. case labelrelationship.EdgeLabels:
  12771. m.ResetLabels()
  12772. return nil
  12773. }
  12774. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  12775. }
  12776. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  12777. type LabelTaggingMutation struct {
  12778. config
  12779. op Op
  12780. typ string
  12781. id *uint64
  12782. created_at *time.Time
  12783. updated_at *time.Time
  12784. status *uint8
  12785. addstatus *int8
  12786. deleted_at *time.Time
  12787. organization_id *uint64
  12788. addorganization_id *int64
  12789. _type *int
  12790. add_type *int
  12791. conditions *string
  12792. action_label_add *[]uint64
  12793. appendaction_label_add []uint64
  12794. action_label_del *[]uint64
  12795. appendaction_label_del []uint64
  12796. clearedFields map[string]struct{}
  12797. done bool
  12798. oldValue func(context.Context) (*LabelTagging, error)
  12799. predicates []predicate.LabelTagging
  12800. }
  12801. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  12802. // labeltaggingOption allows management of the mutation configuration using functional options.
  12803. type labeltaggingOption func(*LabelTaggingMutation)
  12804. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  12805. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  12806. m := &LabelTaggingMutation{
  12807. config: c,
  12808. op: op,
  12809. typ: TypeLabelTagging,
  12810. clearedFields: make(map[string]struct{}),
  12811. }
  12812. for _, opt := range opts {
  12813. opt(m)
  12814. }
  12815. return m
  12816. }
  12817. // withLabelTaggingID sets the ID field of the mutation.
  12818. func withLabelTaggingID(id uint64) labeltaggingOption {
  12819. return func(m *LabelTaggingMutation) {
  12820. var (
  12821. err error
  12822. once sync.Once
  12823. value *LabelTagging
  12824. )
  12825. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  12826. once.Do(func() {
  12827. if m.done {
  12828. err = errors.New("querying old values post mutation is not allowed")
  12829. } else {
  12830. value, err = m.Client().LabelTagging.Get(ctx, id)
  12831. }
  12832. })
  12833. return value, err
  12834. }
  12835. m.id = &id
  12836. }
  12837. }
  12838. // withLabelTagging sets the old LabelTagging of the mutation.
  12839. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  12840. return func(m *LabelTaggingMutation) {
  12841. m.oldValue = func(context.Context) (*LabelTagging, error) {
  12842. return node, nil
  12843. }
  12844. m.id = &node.ID
  12845. }
  12846. }
  12847. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12848. // executed in a transaction (ent.Tx), a transactional client is returned.
  12849. func (m LabelTaggingMutation) Client() *Client {
  12850. client := &Client{config: m.config}
  12851. client.init()
  12852. return client
  12853. }
  12854. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12855. // it returns an error otherwise.
  12856. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  12857. if _, ok := m.driver.(*txDriver); !ok {
  12858. return nil, errors.New("ent: mutation is not running in a transaction")
  12859. }
  12860. tx := &Tx{config: m.config}
  12861. tx.init()
  12862. return tx, nil
  12863. }
  12864. // SetID sets the value of the id field. Note that this
  12865. // operation is only accepted on creation of LabelTagging entities.
  12866. func (m *LabelTaggingMutation) SetID(id uint64) {
  12867. m.id = &id
  12868. }
  12869. // ID returns the ID value in the mutation. Note that the ID is only available
  12870. // if it was provided to the builder or after it was returned from the database.
  12871. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  12872. if m.id == nil {
  12873. return
  12874. }
  12875. return *m.id, true
  12876. }
  12877. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12878. // That means, if the mutation is applied within a transaction with an isolation level such
  12879. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12880. // or updated by the mutation.
  12881. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  12882. switch {
  12883. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12884. id, exists := m.ID()
  12885. if exists {
  12886. return []uint64{id}, nil
  12887. }
  12888. fallthrough
  12889. case m.op.Is(OpUpdate | OpDelete):
  12890. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  12891. default:
  12892. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12893. }
  12894. }
  12895. // SetCreatedAt sets the "created_at" field.
  12896. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  12897. m.created_at = &t
  12898. }
  12899. // CreatedAt returns the value of the "created_at" field in the mutation.
  12900. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  12901. v := m.created_at
  12902. if v == nil {
  12903. return
  12904. }
  12905. return *v, true
  12906. }
  12907. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  12908. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  12909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12910. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12911. if !m.op.Is(OpUpdateOne) {
  12912. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12913. }
  12914. if m.id == nil || m.oldValue == nil {
  12915. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12916. }
  12917. oldValue, err := m.oldValue(ctx)
  12918. if err != nil {
  12919. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12920. }
  12921. return oldValue.CreatedAt, nil
  12922. }
  12923. // ResetCreatedAt resets all changes to the "created_at" field.
  12924. func (m *LabelTaggingMutation) ResetCreatedAt() {
  12925. m.created_at = nil
  12926. }
  12927. // SetUpdatedAt sets the "updated_at" field.
  12928. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  12929. m.updated_at = &t
  12930. }
  12931. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12932. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  12933. v := m.updated_at
  12934. if v == nil {
  12935. return
  12936. }
  12937. return *v, true
  12938. }
  12939. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  12940. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  12941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12942. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12943. if !m.op.Is(OpUpdateOne) {
  12944. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12945. }
  12946. if m.id == nil || m.oldValue == nil {
  12947. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12948. }
  12949. oldValue, err := m.oldValue(ctx)
  12950. if err != nil {
  12951. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12952. }
  12953. return oldValue.UpdatedAt, nil
  12954. }
  12955. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12956. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  12957. m.updated_at = nil
  12958. }
  12959. // SetStatus sets the "status" field.
  12960. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  12961. m.status = &u
  12962. m.addstatus = nil
  12963. }
  12964. // Status returns the value of the "status" field in the mutation.
  12965. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  12966. v := m.status
  12967. if v == nil {
  12968. return
  12969. }
  12970. return *v, true
  12971. }
  12972. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  12973. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  12974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12975. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12976. if !m.op.Is(OpUpdateOne) {
  12977. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12978. }
  12979. if m.id == nil || m.oldValue == nil {
  12980. return v, errors.New("OldStatus requires an ID field in the mutation")
  12981. }
  12982. oldValue, err := m.oldValue(ctx)
  12983. if err != nil {
  12984. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12985. }
  12986. return oldValue.Status, nil
  12987. }
  12988. // AddStatus adds u to the "status" field.
  12989. func (m *LabelTaggingMutation) AddStatus(u int8) {
  12990. if m.addstatus != nil {
  12991. *m.addstatus += u
  12992. } else {
  12993. m.addstatus = &u
  12994. }
  12995. }
  12996. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12997. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  12998. v := m.addstatus
  12999. if v == nil {
  13000. return
  13001. }
  13002. return *v, true
  13003. }
  13004. // ClearStatus clears the value of the "status" field.
  13005. func (m *LabelTaggingMutation) ClearStatus() {
  13006. m.status = nil
  13007. m.addstatus = nil
  13008. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  13009. }
  13010. // StatusCleared returns if the "status" field was cleared in this mutation.
  13011. func (m *LabelTaggingMutation) StatusCleared() bool {
  13012. _, ok := m.clearedFields[labeltagging.FieldStatus]
  13013. return ok
  13014. }
  13015. // ResetStatus resets all changes to the "status" field.
  13016. func (m *LabelTaggingMutation) ResetStatus() {
  13017. m.status = nil
  13018. m.addstatus = nil
  13019. delete(m.clearedFields, labeltagging.FieldStatus)
  13020. }
  13021. // SetDeletedAt sets the "deleted_at" field.
  13022. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  13023. m.deleted_at = &t
  13024. }
  13025. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13026. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  13027. v := m.deleted_at
  13028. if v == nil {
  13029. return
  13030. }
  13031. return *v, true
  13032. }
  13033. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  13034. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13036. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13037. if !m.op.Is(OpUpdateOne) {
  13038. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13039. }
  13040. if m.id == nil || m.oldValue == nil {
  13041. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13042. }
  13043. oldValue, err := m.oldValue(ctx)
  13044. if err != nil {
  13045. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13046. }
  13047. return oldValue.DeletedAt, nil
  13048. }
  13049. // ClearDeletedAt clears the value of the "deleted_at" field.
  13050. func (m *LabelTaggingMutation) ClearDeletedAt() {
  13051. m.deleted_at = nil
  13052. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  13053. }
  13054. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13055. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  13056. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  13057. return ok
  13058. }
  13059. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13060. func (m *LabelTaggingMutation) ResetDeletedAt() {
  13061. m.deleted_at = nil
  13062. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  13063. }
  13064. // SetOrganizationID sets the "organization_id" field.
  13065. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  13066. m.organization_id = &u
  13067. m.addorganization_id = nil
  13068. }
  13069. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13070. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  13071. v := m.organization_id
  13072. if v == nil {
  13073. return
  13074. }
  13075. return *v, true
  13076. }
  13077. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  13078. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13080. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13081. if !m.op.Is(OpUpdateOne) {
  13082. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13083. }
  13084. if m.id == nil || m.oldValue == nil {
  13085. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13086. }
  13087. oldValue, err := m.oldValue(ctx)
  13088. if err != nil {
  13089. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13090. }
  13091. return oldValue.OrganizationID, nil
  13092. }
  13093. // AddOrganizationID adds u to the "organization_id" field.
  13094. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  13095. if m.addorganization_id != nil {
  13096. *m.addorganization_id += u
  13097. } else {
  13098. m.addorganization_id = &u
  13099. }
  13100. }
  13101. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13102. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  13103. v := m.addorganization_id
  13104. if v == nil {
  13105. return
  13106. }
  13107. return *v, true
  13108. }
  13109. // ResetOrganizationID resets all changes to the "organization_id" field.
  13110. func (m *LabelTaggingMutation) ResetOrganizationID() {
  13111. m.organization_id = nil
  13112. m.addorganization_id = nil
  13113. }
  13114. // SetType sets the "type" field.
  13115. func (m *LabelTaggingMutation) SetType(i int) {
  13116. m._type = &i
  13117. m.add_type = nil
  13118. }
  13119. // GetType returns the value of the "type" field in the mutation.
  13120. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  13121. v := m._type
  13122. if v == nil {
  13123. return
  13124. }
  13125. return *v, true
  13126. }
  13127. // OldType returns the old "type" field's value of the LabelTagging entity.
  13128. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13130. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  13131. if !m.op.Is(OpUpdateOne) {
  13132. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13133. }
  13134. if m.id == nil || m.oldValue == nil {
  13135. return v, errors.New("OldType requires an ID field in the mutation")
  13136. }
  13137. oldValue, err := m.oldValue(ctx)
  13138. if err != nil {
  13139. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13140. }
  13141. return oldValue.Type, nil
  13142. }
  13143. // AddType adds i to the "type" field.
  13144. func (m *LabelTaggingMutation) AddType(i int) {
  13145. if m.add_type != nil {
  13146. *m.add_type += i
  13147. } else {
  13148. m.add_type = &i
  13149. }
  13150. }
  13151. // AddedType returns the value that was added to the "type" field in this mutation.
  13152. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  13153. v := m.add_type
  13154. if v == nil {
  13155. return
  13156. }
  13157. return *v, true
  13158. }
  13159. // ResetType resets all changes to the "type" field.
  13160. func (m *LabelTaggingMutation) ResetType() {
  13161. m._type = nil
  13162. m.add_type = nil
  13163. }
  13164. // SetConditions sets the "conditions" field.
  13165. func (m *LabelTaggingMutation) SetConditions(s string) {
  13166. m.conditions = &s
  13167. }
  13168. // Conditions returns the value of the "conditions" field in the mutation.
  13169. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  13170. v := m.conditions
  13171. if v == nil {
  13172. return
  13173. }
  13174. return *v, true
  13175. }
  13176. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  13177. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13179. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  13180. if !m.op.Is(OpUpdateOne) {
  13181. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  13182. }
  13183. if m.id == nil || m.oldValue == nil {
  13184. return v, errors.New("OldConditions requires an ID field in the mutation")
  13185. }
  13186. oldValue, err := m.oldValue(ctx)
  13187. if err != nil {
  13188. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  13189. }
  13190. return oldValue.Conditions, nil
  13191. }
  13192. // ResetConditions resets all changes to the "conditions" field.
  13193. func (m *LabelTaggingMutation) ResetConditions() {
  13194. m.conditions = nil
  13195. }
  13196. // SetActionLabelAdd sets the "action_label_add" field.
  13197. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  13198. m.action_label_add = &u
  13199. m.appendaction_label_add = nil
  13200. }
  13201. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  13202. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  13203. v := m.action_label_add
  13204. if v == nil {
  13205. return
  13206. }
  13207. return *v, true
  13208. }
  13209. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  13210. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13212. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  13213. if !m.op.Is(OpUpdateOne) {
  13214. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  13215. }
  13216. if m.id == nil || m.oldValue == nil {
  13217. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  13218. }
  13219. oldValue, err := m.oldValue(ctx)
  13220. if err != nil {
  13221. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  13222. }
  13223. return oldValue.ActionLabelAdd, nil
  13224. }
  13225. // AppendActionLabelAdd adds u to the "action_label_add" field.
  13226. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  13227. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  13228. }
  13229. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  13230. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  13231. if len(m.appendaction_label_add) == 0 {
  13232. return nil, false
  13233. }
  13234. return m.appendaction_label_add, true
  13235. }
  13236. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  13237. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  13238. m.action_label_add = nil
  13239. m.appendaction_label_add = nil
  13240. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  13241. }
  13242. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  13243. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  13244. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  13245. return ok
  13246. }
  13247. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  13248. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  13249. m.action_label_add = nil
  13250. m.appendaction_label_add = nil
  13251. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  13252. }
  13253. // SetActionLabelDel sets the "action_label_del" field.
  13254. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  13255. m.action_label_del = &u
  13256. m.appendaction_label_del = nil
  13257. }
  13258. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  13259. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  13260. v := m.action_label_del
  13261. if v == nil {
  13262. return
  13263. }
  13264. return *v, true
  13265. }
  13266. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  13267. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13269. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  13270. if !m.op.Is(OpUpdateOne) {
  13271. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  13272. }
  13273. if m.id == nil || m.oldValue == nil {
  13274. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  13275. }
  13276. oldValue, err := m.oldValue(ctx)
  13277. if err != nil {
  13278. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  13279. }
  13280. return oldValue.ActionLabelDel, nil
  13281. }
  13282. // AppendActionLabelDel adds u to the "action_label_del" field.
  13283. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  13284. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  13285. }
  13286. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  13287. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  13288. if len(m.appendaction_label_del) == 0 {
  13289. return nil, false
  13290. }
  13291. return m.appendaction_label_del, true
  13292. }
  13293. // ClearActionLabelDel clears the value of the "action_label_del" field.
  13294. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  13295. m.action_label_del = nil
  13296. m.appendaction_label_del = nil
  13297. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  13298. }
  13299. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  13300. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  13301. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  13302. return ok
  13303. }
  13304. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  13305. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  13306. m.action_label_del = nil
  13307. m.appendaction_label_del = nil
  13308. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  13309. }
  13310. // Where appends a list predicates to the LabelTaggingMutation builder.
  13311. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  13312. m.predicates = append(m.predicates, ps...)
  13313. }
  13314. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  13315. // users can use type-assertion to append predicates that do not depend on any generated package.
  13316. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  13317. p := make([]predicate.LabelTagging, len(ps))
  13318. for i := range ps {
  13319. p[i] = ps[i]
  13320. }
  13321. m.Where(p...)
  13322. }
  13323. // Op returns the operation name.
  13324. func (m *LabelTaggingMutation) Op() Op {
  13325. return m.op
  13326. }
  13327. // SetOp allows setting the mutation operation.
  13328. func (m *LabelTaggingMutation) SetOp(op Op) {
  13329. m.op = op
  13330. }
  13331. // Type returns the node type of this mutation (LabelTagging).
  13332. func (m *LabelTaggingMutation) Type() string {
  13333. return m.typ
  13334. }
  13335. // Fields returns all fields that were changed during this mutation. Note that in
  13336. // order to get all numeric fields that were incremented/decremented, call
  13337. // AddedFields().
  13338. func (m *LabelTaggingMutation) Fields() []string {
  13339. fields := make([]string, 0, 9)
  13340. if m.created_at != nil {
  13341. fields = append(fields, labeltagging.FieldCreatedAt)
  13342. }
  13343. if m.updated_at != nil {
  13344. fields = append(fields, labeltagging.FieldUpdatedAt)
  13345. }
  13346. if m.status != nil {
  13347. fields = append(fields, labeltagging.FieldStatus)
  13348. }
  13349. if m.deleted_at != nil {
  13350. fields = append(fields, labeltagging.FieldDeletedAt)
  13351. }
  13352. if m.organization_id != nil {
  13353. fields = append(fields, labeltagging.FieldOrganizationID)
  13354. }
  13355. if m._type != nil {
  13356. fields = append(fields, labeltagging.FieldType)
  13357. }
  13358. if m.conditions != nil {
  13359. fields = append(fields, labeltagging.FieldConditions)
  13360. }
  13361. if m.action_label_add != nil {
  13362. fields = append(fields, labeltagging.FieldActionLabelAdd)
  13363. }
  13364. if m.action_label_del != nil {
  13365. fields = append(fields, labeltagging.FieldActionLabelDel)
  13366. }
  13367. return fields
  13368. }
  13369. // Field returns the value of a field with the given name. The second boolean
  13370. // return value indicates that this field was not set, or was not defined in the
  13371. // schema.
  13372. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  13373. switch name {
  13374. case labeltagging.FieldCreatedAt:
  13375. return m.CreatedAt()
  13376. case labeltagging.FieldUpdatedAt:
  13377. return m.UpdatedAt()
  13378. case labeltagging.FieldStatus:
  13379. return m.Status()
  13380. case labeltagging.FieldDeletedAt:
  13381. return m.DeletedAt()
  13382. case labeltagging.FieldOrganizationID:
  13383. return m.OrganizationID()
  13384. case labeltagging.FieldType:
  13385. return m.GetType()
  13386. case labeltagging.FieldConditions:
  13387. return m.Conditions()
  13388. case labeltagging.FieldActionLabelAdd:
  13389. return m.ActionLabelAdd()
  13390. case labeltagging.FieldActionLabelDel:
  13391. return m.ActionLabelDel()
  13392. }
  13393. return nil, false
  13394. }
  13395. // OldField returns the old value of the field from the database. An error is
  13396. // returned if the mutation operation is not UpdateOne, or the query to the
  13397. // database failed.
  13398. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13399. switch name {
  13400. case labeltagging.FieldCreatedAt:
  13401. return m.OldCreatedAt(ctx)
  13402. case labeltagging.FieldUpdatedAt:
  13403. return m.OldUpdatedAt(ctx)
  13404. case labeltagging.FieldStatus:
  13405. return m.OldStatus(ctx)
  13406. case labeltagging.FieldDeletedAt:
  13407. return m.OldDeletedAt(ctx)
  13408. case labeltagging.FieldOrganizationID:
  13409. return m.OldOrganizationID(ctx)
  13410. case labeltagging.FieldType:
  13411. return m.OldType(ctx)
  13412. case labeltagging.FieldConditions:
  13413. return m.OldConditions(ctx)
  13414. case labeltagging.FieldActionLabelAdd:
  13415. return m.OldActionLabelAdd(ctx)
  13416. case labeltagging.FieldActionLabelDel:
  13417. return m.OldActionLabelDel(ctx)
  13418. }
  13419. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  13420. }
  13421. // SetField sets the value of a field with the given name. It returns an error if
  13422. // the field is not defined in the schema, or if the type mismatched the field
  13423. // type.
  13424. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  13425. switch name {
  13426. case labeltagging.FieldCreatedAt:
  13427. v, ok := value.(time.Time)
  13428. if !ok {
  13429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13430. }
  13431. m.SetCreatedAt(v)
  13432. return nil
  13433. case labeltagging.FieldUpdatedAt:
  13434. v, ok := value.(time.Time)
  13435. if !ok {
  13436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13437. }
  13438. m.SetUpdatedAt(v)
  13439. return nil
  13440. case labeltagging.FieldStatus:
  13441. v, ok := value.(uint8)
  13442. if !ok {
  13443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13444. }
  13445. m.SetStatus(v)
  13446. return nil
  13447. case labeltagging.FieldDeletedAt:
  13448. v, ok := value.(time.Time)
  13449. if !ok {
  13450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13451. }
  13452. m.SetDeletedAt(v)
  13453. return nil
  13454. case labeltagging.FieldOrganizationID:
  13455. v, ok := value.(uint64)
  13456. if !ok {
  13457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13458. }
  13459. m.SetOrganizationID(v)
  13460. return nil
  13461. case labeltagging.FieldType:
  13462. v, ok := value.(int)
  13463. if !ok {
  13464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13465. }
  13466. m.SetType(v)
  13467. return nil
  13468. case labeltagging.FieldConditions:
  13469. v, ok := value.(string)
  13470. if !ok {
  13471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13472. }
  13473. m.SetConditions(v)
  13474. return nil
  13475. case labeltagging.FieldActionLabelAdd:
  13476. v, ok := value.([]uint64)
  13477. if !ok {
  13478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13479. }
  13480. m.SetActionLabelAdd(v)
  13481. return nil
  13482. case labeltagging.FieldActionLabelDel:
  13483. v, ok := value.([]uint64)
  13484. if !ok {
  13485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13486. }
  13487. m.SetActionLabelDel(v)
  13488. return nil
  13489. }
  13490. return fmt.Errorf("unknown LabelTagging field %s", name)
  13491. }
  13492. // AddedFields returns all numeric fields that were incremented/decremented during
  13493. // this mutation.
  13494. func (m *LabelTaggingMutation) AddedFields() []string {
  13495. var fields []string
  13496. if m.addstatus != nil {
  13497. fields = append(fields, labeltagging.FieldStatus)
  13498. }
  13499. if m.addorganization_id != nil {
  13500. fields = append(fields, labeltagging.FieldOrganizationID)
  13501. }
  13502. if m.add_type != nil {
  13503. fields = append(fields, labeltagging.FieldType)
  13504. }
  13505. return fields
  13506. }
  13507. // AddedField returns the numeric value that was incremented/decremented on a field
  13508. // with the given name. The second boolean return value indicates that this field
  13509. // was not set, or was not defined in the schema.
  13510. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  13511. switch name {
  13512. case labeltagging.FieldStatus:
  13513. return m.AddedStatus()
  13514. case labeltagging.FieldOrganizationID:
  13515. return m.AddedOrganizationID()
  13516. case labeltagging.FieldType:
  13517. return m.AddedType()
  13518. }
  13519. return nil, false
  13520. }
  13521. // AddField adds the value to the field with the given name. It returns an error if
  13522. // the field is not defined in the schema, or if the type mismatched the field
  13523. // type.
  13524. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  13525. switch name {
  13526. case labeltagging.FieldStatus:
  13527. v, ok := value.(int8)
  13528. if !ok {
  13529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13530. }
  13531. m.AddStatus(v)
  13532. return nil
  13533. case labeltagging.FieldOrganizationID:
  13534. v, ok := value.(int64)
  13535. if !ok {
  13536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13537. }
  13538. m.AddOrganizationID(v)
  13539. return nil
  13540. case labeltagging.FieldType:
  13541. v, ok := value.(int)
  13542. if !ok {
  13543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13544. }
  13545. m.AddType(v)
  13546. return nil
  13547. }
  13548. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  13549. }
  13550. // ClearedFields returns all nullable fields that were cleared during this
  13551. // mutation.
  13552. func (m *LabelTaggingMutation) ClearedFields() []string {
  13553. var fields []string
  13554. if m.FieldCleared(labeltagging.FieldStatus) {
  13555. fields = append(fields, labeltagging.FieldStatus)
  13556. }
  13557. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  13558. fields = append(fields, labeltagging.FieldDeletedAt)
  13559. }
  13560. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  13561. fields = append(fields, labeltagging.FieldActionLabelAdd)
  13562. }
  13563. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  13564. fields = append(fields, labeltagging.FieldActionLabelDel)
  13565. }
  13566. return fields
  13567. }
  13568. // FieldCleared returns a boolean indicating if a field with the given name was
  13569. // cleared in this mutation.
  13570. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  13571. _, ok := m.clearedFields[name]
  13572. return ok
  13573. }
  13574. // ClearField clears the value of the field with the given name. It returns an
  13575. // error if the field is not defined in the schema.
  13576. func (m *LabelTaggingMutation) ClearField(name string) error {
  13577. switch name {
  13578. case labeltagging.FieldStatus:
  13579. m.ClearStatus()
  13580. return nil
  13581. case labeltagging.FieldDeletedAt:
  13582. m.ClearDeletedAt()
  13583. return nil
  13584. case labeltagging.FieldActionLabelAdd:
  13585. m.ClearActionLabelAdd()
  13586. return nil
  13587. case labeltagging.FieldActionLabelDel:
  13588. m.ClearActionLabelDel()
  13589. return nil
  13590. }
  13591. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  13592. }
  13593. // ResetField resets all changes in the mutation for the field with the given name.
  13594. // It returns an error if the field is not defined in the schema.
  13595. func (m *LabelTaggingMutation) ResetField(name string) error {
  13596. switch name {
  13597. case labeltagging.FieldCreatedAt:
  13598. m.ResetCreatedAt()
  13599. return nil
  13600. case labeltagging.FieldUpdatedAt:
  13601. m.ResetUpdatedAt()
  13602. return nil
  13603. case labeltagging.FieldStatus:
  13604. m.ResetStatus()
  13605. return nil
  13606. case labeltagging.FieldDeletedAt:
  13607. m.ResetDeletedAt()
  13608. return nil
  13609. case labeltagging.FieldOrganizationID:
  13610. m.ResetOrganizationID()
  13611. return nil
  13612. case labeltagging.FieldType:
  13613. m.ResetType()
  13614. return nil
  13615. case labeltagging.FieldConditions:
  13616. m.ResetConditions()
  13617. return nil
  13618. case labeltagging.FieldActionLabelAdd:
  13619. m.ResetActionLabelAdd()
  13620. return nil
  13621. case labeltagging.FieldActionLabelDel:
  13622. m.ResetActionLabelDel()
  13623. return nil
  13624. }
  13625. return fmt.Errorf("unknown LabelTagging field %s", name)
  13626. }
  13627. // AddedEdges returns all edge names that were set/added in this mutation.
  13628. func (m *LabelTaggingMutation) AddedEdges() []string {
  13629. edges := make([]string, 0, 0)
  13630. return edges
  13631. }
  13632. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13633. // name in this mutation.
  13634. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  13635. return nil
  13636. }
  13637. // RemovedEdges returns all edge names that were removed in this mutation.
  13638. func (m *LabelTaggingMutation) RemovedEdges() []string {
  13639. edges := make([]string, 0, 0)
  13640. return edges
  13641. }
  13642. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13643. // the given name in this mutation.
  13644. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  13645. return nil
  13646. }
  13647. // ClearedEdges returns all edge names that were cleared in this mutation.
  13648. func (m *LabelTaggingMutation) ClearedEdges() []string {
  13649. edges := make([]string, 0, 0)
  13650. return edges
  13651. }
  13652. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13653. // was cleared in this mutation.
  13654. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  13655. return false
  13656. }
  13657. // ClearEdge clears the value of the edge with the given name. It returns an error
  13658. // if that edge is not defined in the schema.
  13659. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  13660. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  13661. }
  13662. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13663. // It returns an error if the edge is not defined in the schema.
  13664. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  13665. return fmt.Errorf("unknown LabelTagging edge %s", name)
  13666. }
  13667. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  13668. type MessageMutation struct {
  13669. config
  13670. op Op
  13671. typ string
  13672. id *int
  13673. wx_wxid *string
  13674. wxid *string
  13675. content *string
  13676. clearedFields map[string]struct{}
  13677. done bool
  13678. oldValue func(context.Context) (*Message, error)
  13679. predicates []predicate.Message
  13680. }
  13681. var _ ent.Mutation = (*MessageMutation)(nil)
  13682. // messageOption allows management of the mutation configuration using functional options.
  13683. type messageOption func(*MessageMutation)
  13684. // newMessageMutation creates new mutation for the Message entity.
  13685. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  13686. m := &MessageMutation{
  13687. config: c,
  13688. op: op,
  13689. typ: TypeMessage,
  13690. clearedFields: make(map[string]struct{}),
  13691. }
  13692. for _, opt := range opts {
  13693. opt(m)
  13694. }
  13695. return m
  13696. }
  13697. // withMessageID sets the ID field of the mutation.
  13698. func withMessageID(id int) messageOption {
  13699. return func(m *MessageMutation) {
  13700. var (
  13701. err error
  13702. once sync.Once
  13703. value *Message
  13704. )
  13705. m.oldValue = func(ctx context.Context) (*Message, error) {
  13706. once.Do(func() {
  13707. if m.done {
  13708. err = errors.New("querying old values post mutation is not allowed")
  13709. } else {
  13710. value, err = m.Client().Message.Get(ctx, id)
  13711. }
  13712. })
  13713. return value, err
  13714. }
  13715. m.id = &id
  13716. }
  13717. }
  13718. // withMessage sets the old Message of the mutation.
  13719. func withMessage(node *Message) messageOption {
  13720. return func(m *MessageMutation) {
  13721. m.oldValue = func(context.Context) (*Message, error) {
  13722. return node, nil
  13723. }
  13724. m.id = &node.ID
  13725. }
  13726. }
  13727. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13728. // executed in a transaction (ent.Tx), a transactional client is returned.
  13729. func (m MessageMutation) Client() *Client {
  13730. client := &Client{config: m.config}
  13731. client.init()
  13732. return client
  13733. }
  13734. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13735. // it returns an error otherwise.
  13736. func (m MessageMutation) Tx() (*Tx, error) {
  13737. if _, ok := m.driver.(*txDriver); !ok {
  13738. return nil, errors.New("ent: mutation is not running in a transaction")
  13739. }
  13740. tx := &Tx{config: m.config}
  13741. tx.init()
  13742. return tx, nil
  13743. }
  13744. // ID returns the ID value in the mutation. Note that the ID is only available
  13745. // if it was provided to the builder or after it was returned from the database.
  13746. func (m *MessageMutation) ID() (id int, exists bool) {
  13747. if m.id == nil {
  13748. return
  13749. }
  13750. return *m.id, true
  13751. }
  13752. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13753. // That means, if the mutation is applied within a transaction with an isolation level such
  13754. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13755. // or updated by the mutation.
  13756. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  13757. switch {
  13758. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13759. id, exists := m.ID()
  13760. if exists {
  13761. return []int{id}, nil
  13762. }
  13763. fallthrough
  13764. case m.op.Is(OpUpdate | OpDelete):
  13765. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  13766. default:
  13767. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13768. }
  13769. }
  13770. // SetWxWxid sets the "wx_wxid" field.
  13771. func (m *MessageMutation) SetWxWxid(s string) {
  13772. m.wx_wxid = &s
  13773. }
  13774. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  13775. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  13776. v := m.wx_wxid
  13777. if v == nil {
  13778. return
  13779. }
  13780. return *v, true
  13781. }
  13782. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  13783. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13785. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  13786. if !m.op.Is(OpUpdateOne) {
  13787. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  13788. }
  13789. if m.id == nil || m.oldValue == nil {
  13790. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  13791. }
  13792. oldValue, err := m.oldValue(ctx)
  13793. if err != nil {
  13794. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  13795. }
  13796. return oldValue.WxWxid, nil
  13797. }
  13798. // ClearWxWxid clears the value of the "wx_wxid" field.
  13799. func (m *MessageMutation) ClearWxWxid() {
  13800. m.wx_wxid = nil
  13801. m.clearedFields[message.FieldWxWxid] = struct{}{}
  13802. }
  13803. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  13804. func (m *MessageMutation) WxWxidCleared() bool {
  13805. _, ok := m.clearedFields[message.FieldWxWxid]
  13806. return ok
  13807. }
  13808. // ResetWxWxid resets all changes to the "wx_wxid" field.
  13809. func (m *MessageMutation) ResetWxWxid() {
  13810. m.wx_wxid = nil
  13811. delete(m.clearedFields, message.FieldWxWxid)
  13812. }
  13813. // SetWxid sets the "wxid" field.
  13814. func (m *MessageMutation) SetWxid(s string) {
  13815. m.wxid = &s
  13816. }
  13817. // Wxid returns the value of the "wxid" field in the mutation.
  13818. func (m *MessageMutation) Wxid() (r string, exists bool) {
  13819. v := m.wxid
  13820. if v == nil {
  13821. return
  13822. }
  13823. return *v, true
  13824. }
  13825. // OldWxid returns the old "wxid" field's value of the Message entity.
  13826. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13828. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  13829. if !m.op.Is(OpUpdateOne) {
  13830. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  13831. }
  13832. if m.id == nil || m.oldValue == nil {
  13833. return v, errors.New("OldWxid requires an ID field in the mutation")
  13834. }
  13835. oldValue, err := m.oldValue(ctx)
  13836. if err != nil {
  13837. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  13838. }
  13839. return oldValue.Wxid, nil
  13840. }
  13841. // ResetWxid resets all changes to the "wxid" field.
  13842. func (m *MessageMutation) ResetWxid() {
  13843. m.wxid = nil
  13844. }
  13845. // SetContent sets the "content" field.
  13846. func (m *MessageMutation) SetContent(s string) {
  13847. m.content = &s
  13848. }
  13849. // Content returns the value of the "content" field in the mutation.
  13850. func (m *MessageMutation) Content() (r string, exists bool) {
  13851. v := m.content
  13852. if v == nil {
  13853. return
  13854. }
  13855. return *v, true
  13856. }
  13857. // OldContent returns the old "content" field's value of the Message entity.
  13858. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13860. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  13861. if !m.op.Is(OpUpdateOne) {
  13862. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  13863. }
  13864. if m.id == nil || m.oldValue == nil {
  13865. return v, errors.New("OldContent requires an ID field in the mutation")
  13866. }
  13867. oldValue, err := m.oldValue(ctx)
  13868. if err != nil {
  13869. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  13870. }
  13871. return oldValue.Content, nil
  13872. }
  13873. // ResetContent resets all changes to the "content" field.
  13874. func (m *MessageMutation) ResetContent() {
  13875. m.content = nil
  13876. }
  13877. // Where appends a list predicates to the MessageMutation builder.
  13878. func (m *MessageMutation) Where(ps ...predicate.Message) {
  13879. m.predicates = append(m.predicates, ps...)
  13880. }
  13881. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  13882. // users can use type-assertion to append predicates that do not depend on any generated package.
  13883. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  13884. p := make([]predicate.Message, len(ps))
  13885. for i := range ps {
  13886. p[i] = ps[i]
  13887. }
  13888. m.Where(p...)
  13889. }
  13890. // Op returns the operation name.
  13891. func (m *MessageMutation) Op() Op {
  13892. return m.op
  13893. }
  13894. // SetOp allows setting the mutation operation.
  13895. func (m *MessageMutation) SetOp(op Op) {
  13896. m.op = op
  13897. }
  13898. // Type returns the node type of this mutation (Message).
  13899. func (m *MessageMutation) Type() string {
  13900. return m.typ
  13901. }
  13902. // Fields returns all fields that were changed during this mutation. Note that in
  13903. // order to get all numeric fields that were incremented/decremented, call
  13904. // AddedFields().
  13905. func (m *MessageMutation) Fields() []string {
  13906. fields := make([]string, 0, 3)
  13907. if m.wx_wxid != nil {
  13908. fields = append(fields, message.FieldWxWxid)
  13909. }
  13910. if m.wxid != nil {
  13911. fields = append(fields, message.FieldWxid)
  13912. }
  13913. if m.content != nil {
  13914. fields = append(fields, message.FieldContent)
  13915. }
  13916. return fields
  13917. }
  13918. // Field returns the value of a field with the given name. The second boolean
  13919. // return value indicates that this field was not set, or was not defined in the
  13920. // schema.
  13921. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  13922. switch name {
  13923. case message.FieldWxWxid:
  13924. return m.WxWxid()
  13925. case message.FieldWxid:
  13926. return m.Wxid()
  13927. case message.FieldContent:
  13928. return m.Content()
  13929. }
  13930. return nil, false
  13931. }
  13932. // OldField returns the old value of the field from the database. An error is
  13933. // returned if the mutation operation is not UpdateOne, or the query to the
  13934. // database failed.
  13935. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13936. switch name {
  13937. case message.FieldWxWxid:
  13938. return m.OldWxWxid(ctx)
  13939. case message.FieldWxid:
  13940. return m.OldWxid(ctx)
  13941. case message.FieldContent:
  13942. return m.OldContent(ctx)
  13943. }
  13944. return nil, fmt.Errorf("unknown Message field %s", name)
  13945. }
  13946. // SetField sets the value of a field with the given name. It returns an error if
  13947. // the field is not defined in the schema, or if the type mismatched the field
  13948. // type.
  13949. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  13950. switch name {
  13951. case message.FieldWxWxid:
  13952. v, ok := value.(string)
  13953. if !ok {
  13954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13955. }
  13956. m.SetWxWxid(v)
  13957. return nil
  13958. case message.FieldWxid:
  13959. v, ok := value.(string)
  13960. if !ok {
  13961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13962. }
  13963. m.SetWxid(v)
  13964. return nil
  13965. case message.FieldContent:
  13966. v, ok := value.(string)
  13967. if !ok {
  13968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13969. }
  13970. m.SetContent(v)
  13971. return nil
  13972. }
  13973. return fmt.Errorf("unknown Message field %s", name)
  13974. }
  13975. // AddedFields returns all numeric fields that were incremented/decremented during
  13976. // this mutation.
  13977. func (m *MessageMutation) AddedFields() []string {
  13978. return nil
  13979. }
  13980. // AddedField returns the numeric value that was incremented/decremented on a field
  13981. // with the given name. The second boolean return value indicates that this field
  13982. // was not set, or was not defined in the schema.
  13983. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  13984. return nil, false
  13985. }
  13986. // AddField adds the value to the field with the given name. It returns an error if
  13987. // the field is not defined in the schema, or if the type mismatched the field
  13988. // type.
  13989. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  13990. switch name {
  13991. }
  13992. return fmt.Errorf("unknown Message numeric field %s", name)
  13993. }
  13994. // ClearedFields returns all nullable fields that were cleared during this
  13995. // mutation.
  13996. func (m *MessageMutation) ClearedFields() []string {
  13997. var fields []string
  13998. if m.FieldCleared(message.FieldWxWxid) {
  13999. fields = append(fields, message.FieldWxWxid)
  14000. }
  14001. return fields
  14002. }
  14003. // FieldCleared returns a boolean indicating if a field with the given name was
  14004. // cleared in this mutation.
  14005. func (m *MessageMutation) FieldCleared(name string) bool {
  14006. _, ok := m.clearedFields[name]
  14007. return ok
  14008. }
  14009. // ClearField clears the value of the field with the given name. It returns an
  14010. // error if the field is not defined in the schema.
  14011. func (m *MessageMutation) ClearField(name string) error {
  14012. switch name {
  14013. case message.FieldWxWxid:
  14014. m.ClearWxWxid()
  14015. return nil
  14016. }
  14017. return fmt.Errorf("unknown Message nullable field %s", name)
  14018. }
  14019. // ResetField resets all changes in the mutation for the field with the given name.
  14020. // It returns an error if the field is not defined in the schema.
  14021. func (m *MessageMutation) ResetField(name string) error {
  14022. switch name {
  14023. case message.FieldWxWxid:
  14024. m.ResetWxWxid()
  14025. return nil
  14026. case message.FieldWxid:
  14027. m.ResetWxid()
  14028. return nil
  14029. case message.FieldContent:
  14030. m.ResetContent()
  14031. return nil
  14032. }
  14033. return fmt.Errorf("unknown Message field %s", name)
  14034. }
  14035. // AddedEdges returns all edge names that were set/added in this mutation.
  14036. func (m *MessageMutation) AddedEdges() []string {
  14037. edges := make([]string, 0, 0)
  14038. return edges
  14039. }
  14040. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14041. // name in this mutation.
  14042. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  14043. return nil
  14044. }
  14045. // RemovedEdges returns all edge names that were removed in this mutation.
  14046. func (m *MessageMutation) RemovedEdges() []string {
  14047. edges := make([]string, 0, 0)
  14048. return edges
  14049. }
  14050. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14051. // the given name in this mutation.
  14052. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  14053. return nil
  14054. }
  14055. // ClearedEdges returns all edge names that were cleared in this mutation.
  14056. func (m *MessageMutation) ClearedEdges() []string {
  14057. edges := make([]string, 0, 0)
  14058. return edges
  14059. }
  14060. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14061. // was cleared in this mutation.
  14062. func (m *MessageMutation) EdgeCleared(name string) bool {
  14063. return false
  14064. }
  14065. // ClearEdge clears the value of the edge with the given name. It returns an error
  14066. // if that edge is not defined in the schema.
  14067. func (m *MessageMutation) ClearEdge(name string) error {
  14068. return fmt.Errorf("unknown Message unique edge %s", name)
  14069. }
  14070. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14071. // It returns an error if the edge is not defined in the schema.
  14072. func (m *MessageMutation) ResetEdge(name string) error {
  14073. return fmt.Errorf("unknown Message edge %s", name)
  14074. }
  14075. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  14076. type MessageRecordsMutation struct {
  14077. config
  14078. op Op
  14079. typ string
  14080. id *uint64
  14081. created_at *time.Time
  14082. updated_at *time.Time
  14083. status *uint8
  14084. addstatus *int8
  14085. bot_wxid *string
  14086. contact_type *int
  14087. addcontact_type *int
  14088. contact_wxid *string
  14089. content_type *int
  14090. addcontent_type *int
  14091. content *string
  14092. meta *custom_types.Meta
  14093. error_detail *string
  14094. send_time *time.Time
  14095. source_type *int
  14096. addsource_type *int
  14097. organization_id *uint64
  14098. addorganization_id *int64
  14099. clearedFields map[string]struct{}
  14100. sop_stage *uint64
  14101. clearedsop_stage bool
  14102. sop_node *uint64
  14103. clearedsop_node bool
  14104. message_contact *uint64
  14105. clearedmessage_contact bool
  14106. done bool
  14107. oldValue func(context.Context) (*MessageRecords, error)
  14108. predicates []predicate.MessageRecords
  14109. }
  14110. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  14111. // messagerecordsOption allows management of the mutation configuration using functional options.
  14112. type messagerecordsOption func(*MessageRecordsMutation)
  14113. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  14114. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  14115. m := &MessageRecordsMutation{
  14116. config: c,
  14117. op: op,
  14118. typ: TypeMessageRecords,
  14119. clearedFields: make(map[string]struct{}),
  14120. }
  14121. for _, opt := range opts {
  14122. opt(m)
  14123. }
  14124. return m
  14125. }
  14126. // withMessageRecordsID sets the ID field of the mutation.
  14127. func withMessageRecordsID(id uint64) messagerecordsOption {
  14128. return func(m *MessageRecordsMutation) {
  14129. var (
  14130. err error
  14131. once sync.Once
  14132. value *MessageRecords
  14133. )
  14134. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  14135. once.Do(func() {
  14136. if m.done {
  14137. err = errors.New("querying old values post mutation is not allowed")
  14138. } else {
  14139. value, err = m.Client().MessageRecords.Get(ctx, id)
  14140. }
  14141. })
  14142. return value, err
  14143. }
  14144. m.id = &id
  14145. }
  14146. }
  14147. // withMessageRecords sets the old MessageRecords of the mutation.
  14148. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  14149. return func(m *MessageRecordsMutation) {
  14150. m.oldValue = func(context.Context) (*MessageRecords, error) {
  14151. return node, nil
  14152. }
  14153. m.id = &node.ID
  14154. }
  14155. }
  14156. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14157. // executed in a transaction (ent.Tx), a transactional client is returned.
  14158. func (m MessageRecordsMutation) Client() *Client {
  14159. client := &Client{config: m.config}
  14160. client.init()
  14161. return client
  14162. }
  14163. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14164. // it returns an error otherwise.
  14165. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  14166. if _, ok := m.driver.(*txDriver); !ok {
  14167. return nil, errors.New("ent: mutation is not running in a transaction")
  14168. }
  14169. tx := &Tx{config: m.config}
  14170. tx.init()
  14171. return tx, nil
  14172. }
  14173. // SetID sets the value of the id field. Note that this
  14174. // operation is only accepted on creation of MessageRecords entities.
  14175. func (m *MessageRecordsMutation) SetID(id uint64) {
  14176. m.id = &id
  14177. }
  14178. // ID returns the ID value in the mutation. Note that the ID is only available
  14179. // if it was provided to the builder or after it was returned from the database.
  14180. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  14181. if m.id == nil {
  14182. return
  14183. }
  14184. return *m.id, true
  14185. }
  14186. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14187. // That means, if the mutation is applied within a transaction with an isolation level such
  14188. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14189. // or updated by the mutation.
  14190. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  14191. switch {
  14192. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14193. id, exists := m.ID()
  14194. if exists {
  14195. return []uint64{id}, nil
  14196. }
  14197. fallthrough
  14198. case m.op.Is(OpUpdate | OpDelete):
  14199. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  14200. default:
  14201. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14202. }
  14203. }
  14204. // SetCreatedAt sets the "created_at" field.
  14205. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  14206. m.created_at = &t
  14207. }
  14208. // CreatedAt returns the value of the "created_at" field in the mutation.
  14209. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  14210. v := m.created_at
  14211. if v == nil {
  14212. return
  14213. }
  14214. return *v, true
  14215. }
  14216. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  14217. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14219. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14220. if !m.op.Is(OpUpdateOne) {
  14221. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14222. }
  14223. if m.id == nil || m.oldValue == nil {
  14224. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14225. }
  14226. oldValue, err := m.oldValue(ctx)
  14227. if err != nil {
  14228. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14229. }
  14230. return oldValue.CreatedAt, nil
  14231. }
  14232. // ResetCreatedAt resets all changes to the "created_at" field.
  14233. func (m *MessageRecordsMutation) ResetCreatedAt() {
  14234. m.created_at = nil
  14235. }
  14236. // SetUpdatedAt sets the "updated_at" field.
  14237. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  14238. m.updated_at = &t
  14239. }
  14240. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14241. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  14242. v := m.updated_at
  14243. if v == nil {
  14244. return
  14245. }
  14246. return *v, true
  14247. }
  14248. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  14249. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14251. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14252. if !m.op.Is(OpUpdateOne) {
  14253. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14254. }
  14255. if m.id == nil || m.oldValue == nil {
  14256. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14257. }
  14258. oldValue, err := m.oldValue(ctx)
  14259. if err != nil {
  14260. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14261. }
  14262. return oldValue.UpdatedAt, nil
  14263. }
  14264. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14265. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  14266. m.updated_at = nil
  14267. }
  14268. // SetStatus sets the "status" field.
  14269. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  14270. m.status = &u
  14271. m.addstatus = nil
  14272. }
  14273. // Status returns the value of the "status" field in the mutation.
  14274. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  14275. v := m.status
  14276. if v == nil {
  14277. return
  14278. }
  14279. return *v, true
  14280. }
  14281. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  14282. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14284. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14285. if !m.op.Is(OpUpdateOne) {
  14286. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14287. }
  14288. if m.id == nil || m.oldValue == nil {
  14289. return v, errors.New("OldStatus requires an ID field in the mutation")
  14290. }
  14291. oldValue, err := m.oldValue(ctx)
  14292. if err != nil {
  14293. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14294. }
  14295. return oldValue.Status, nil
  14296. }
  14297. // AddStatus adds u to the "status" field.
  14298. func (m *MessageRecordsMutation) AddStatus(u int8) {
  14299. if m.addstatus != nil {
  14300. *m.addstatus += u
  14301. } else {
  14302. m.addstatus = &u
  14303. }
  14304. }
  14305. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14306. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  14307. v := m.addstatus
  14308. if v == nil {
  14309. return
  14310. }
  14311. return *v, true
  14312. }
  14313. // ClearStatus clears the value of the "status" field.
  14314. func (m *MessageRecordsMutation) ClearStatus() {
  14315. m.status = nil
  14316. m.addstatus = nil
  14317. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  14318. }
  14319. // StatusCleared returns if the "status" field was cleared in this mutation.
  14320. func (m *MessageRecordsMutation) StatusCleared() bool {
  14321. _, ok := m.clearedFields[messagerecords.FieldStatus]
  14322. return ok
  14323. }
  14324. // ResetStatus resets all changes to the "status" field.
  14325. func (m *MessageRecordsMutation) ResetStatus() {
  14326. m.status = nil
  14327. m.addstatus = nil
  14328. delete(m.clearedFields, messagerecords.FieldStatus)
  14329. }
  14330. // SetBotWxid sets the "bot_wxid" field.
  14331. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  14332. m.bot_wxid = &s
  14333. }
  14334. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  14335. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  14336. v := m.bot_wxid
  14337. if v == nil {
  14338. return
  14339. }
  14340. return *v, true
  14341. }
  14342. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  14343. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14345. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  14346. if !m.op.Is(OpUpdateOne) {
  14347. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  14348. }
  14349. if m.id == nil || m.oldValue == nil {
  14350. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  14351. }
  14352. oldValue, err := m.oldValue(ctx)
  14353. if err != nil {
  14354. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  14355. }
  14356. return oldValue.BotWxid, nil
  14357. }
  14358. // ResetBotWxid resets all changes to the "bot_wxid" field.
  14359. func (m *MessageRecordsMutation) ResetBotWxid() {
  14360. m.bot_wxid = nil
  14361. }
  14362. // SetContactID sets the "contact_id" field.
  14363. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  14364. m.message_contact = &u
  14365. }
  14366. // ContactID returns the value of the "contact_id" field in the mutation.
  14367. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  14368. v := m.message_contact
  14369. if v == nil {
  14370. return
  14371. }
  14372. return *v, true
  14373. }
  14374. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  14375. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14377. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14378. if !m.op.Is(OpUpdateOne) {
  14379. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14380. }
  14381. if m.id == nil || m.oldValue == nil {
  14382. return v, errors.New("OldContactID requires an ID field in the mutation")
  14383. }
  14384. oldValue, err := m.oldValue(ctx)
  14385. if err != nil {
  14386. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14387. }
  14388. return oldValue.ContactID, nil
  14389. }
  14390. // ClearContactID clears the value of the "contact_id" field.
  14391. func (m *MessageRecordsMutation) ClearContactID() {
  14392. m.message_contact = nil
  14393. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  14394. }
  14395. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  14396. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  14397. _, ok := m.clearedFields[messagerecords.FieldContactID]
  14398. return ok
  14399. }
  14400. // ResetContactID resets all changes to the "contact_id" field.
  14401. func (m *MessageRecordsMutation) ResetContactID() {
  14402. m.message_contact = nil
  14403. delete(m.clearedFields, messagerecords.FieldContactID)
  14404. }
  14405. // SetContactType sets the "contact_type" field.
  14406. func (m *MessageRecordsMutation) SetContactType(i int) {
  14407. m.contact_type = &i
  14408. m.addcontact_type = nil
  14409. }
  14410. // ContactType returns the value of the "contact_type" field in the mutation.
  14411. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  14412. v := m.contact_type
  14413. if v == nil {
  14414. return
  14415. }
  14416. return *v, true
  14417. }
  14418. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  14419. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14421. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  14422. if !m.op.Is(OpUpdateOne) {
  14423. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  14424. }
  14425. if m.id == nil || m.oldValue == nil {
  14426. return v, errors.New("OldContactType requires an ID field in the mutation")
  14427. }
  14428. oldValue, err := m.oldValue(ctx)
  14429. if err != nil {
  14430. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  14431. }
  14432. return oldValue.ContactType, nil
  14433. }
  14434. // AddContactType adds i to the "contact_type" field.
  14435. func (m *MessageRecordsMutation) AddContactType(i int) {
  14436. if m.addcontact_type != nil {
  14437. *m.addcontact_type += i
  14438. } else {
  14439. m.addcontact_type = &i
  14440. }
  14441. }
  14442. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  14443. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  14444. v := m.addcontact_type
  14445. if v == nil {
  14446. return
  14447. }
  14448. return *v, true
  14449. }
  14450. // ResetContactType resets all changes to the "contact_type" field.
  14451. func (m *MessageRecordsMutation) ResetContactType() {
  14452. m.contact_type = nil
  14453. m.addcontact_type = nil
  14454. }
  14455. // SetContactWxid sets the "contact_wxid" field.
  14456. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  14457. m.contact_wxid = &s
  14458. }
  14459. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  14460. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  14461. v := m.contact_wxid
  14462. if v == nil {
  14463. return
  14464. }
  14465. return *v, true
  14466. }
  14467. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  14468. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14470. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  14471. if !m.op.Is(OpUpdateOne) {
  14472. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  14473. }
  14474. if m.id == nil || m.oldValue == nil {
  14475. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  14476. }
  14477. oldValue, err := m.oldValue(ctx)
  14478. if err != nil {
  14479. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  14480. }
  14481. return oldValue.ContactWxid, nil
  14482. }
  14483. // ResetContactWxid resets all changes to the "contact_wxid" field.
  14484. func (m *MessageRecordsMutation) ResetContactWxid() {
  14485. m.contact_wxid = nil
  14486. }
  14487. // SetContentType sets the "content_type" field.
  14488. func (m *MessageRecordsMutation) SetContentType(i int) {
  14489. m.content_type = &i
  14490. m.addcontent_type = nil
  14491. }
  14492. // ContentType returns the value of the "content_type" field in the mutation.
  14493. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  14494. v := m.content_type
  14495. if v == nil {
  14496. return
  14497. }
  14498. return *v, true
  14499. }
  14500. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  14501. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14503. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  14504. if !m.op.Is(OpUpdateOne) {
  14505. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  14506. }
  14507. if m.id == nil || m.oldValue == nil {
  14508. return v, errors.New("OldContentType requires an ID field in the mutation")
  14509. }
  14510. oldValue, err := m.oldValue(ctx)
  14511. if err != nil {
  14512. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  14513. }
  14514. return oldValue.ContentType, nil
  14515. }
  14516. // AddContentType adds i to the "content_type" field.
  14517. func (m *MessageRecordsMutation) AddContentType(i int) {
  14518. if m.addcontent_type != nil {
  14519. *m.addcontent_type += i
  14520. } else {
  14521. m.addcontent_type = &i
  14522. }
  14523. }
  14524. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  14525. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  14526. v := m.addcontent_type
  14527. if v == nil {
  14528. return
  14529. }
  14530. return *v, true
  14531. }
  14532. // ResetContentType resets all changes to the "content_type" field.
  14533. func (m *MessageRecordsMutation) ResetContentType() {
  14534. m.content_type = nil
  14535. m.addcontent_type = nil
  14536. }
  14537. // SetContent sets the "content" field.
  14538. func (m *MessageRecordsMutation) SetContent(s string) {
  14539. m.content = &s
  14540. }
  14541. // Content returns the value of the "content" field in the mutation.
  14542. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  14543. v := m.content
  14544. if v == nil {
  14545. return
  14546. }
  14547. return *v, true
  14548. }
  14549. // OldContent returns the old "content" field's value of the MessageRecords entity.
  14550. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14552. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  14553. if !m.op.Is(OpUpdateOne) {
  14554. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  14555. }
  14556. if m.id == nil || m.oldValue == nil {
  14557. return v, errors.New("OldContent requires an ID field in the mutation")
  14558. }
  14559. oldValue, err := m.oldValue(ctx)
  14560. if err != nil {
  14561. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  14562. }
  14563. return oldValue.Content, nil
  14564. }
  14565. // ResetContent resets all changes to the "content" field.
  14566. func (m *MessageRecordsMutation) ResetContent() {
  14567. m.content = nil
  14568. }
  14569. // SetMeta sets the "meta" field.
  14570. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  14571. m.meta = &ct
  14572. }
  14573. // Meta returns the value of the "meta" field in the mutation.
  14574. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  14575. v := m.meta
  14576. if v == nil {
  14577. return
  14578. }
  14579. return *v, true
  14580. }
  14581. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  14582. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14584. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  14585. if !m.op.Is(OpUpdateOne) {
  14586. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  14587. }
  14588. if m.id == nil || m.oldValue == nil {
  14589. return v, errors.New("OldMeta requires an ID field in the mutation")
  14590. }
  14591. oldValue, err := m.oldValue(ctx)
  14592. if err != nil {
  14593. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  14594. }
  14595. return oldValue.Meta, nil
  14596. }
  14597. // ClearMeta clears the value of the "meta" field.
  14598. func (m *MessageRecordsMutation) ClearMeta() {
  14599. m.meta = nil
  14600. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  14601. }
  14602. // MetaCleared returns if the "meta" field was cleared in this mutation.
  14603. func (m *MessageRecordsMutation) MetaCleared() bool {
  14604. _, ok := m.clearedFields[messagerecords.FieldMeta]
  14605. return ok
  14606. }
  14607. // ResetMeta resets all changes to the "meta" field.
  14608. func (m *MessageRecordsMutation) ResetMeta() {
  14609. m.meta = nil
  14610. delete(m.clearedFields, messagerecords.FieldMeta)
  14611. }
  14612. // SetErrorDetail sets the "error_detail" field.
  14613. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  14614. m.error_detail = &s
  14615. }
  14616. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  14617. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  14618. v := m.error_detail
  14619. if v == nil {
  14620. return
  14621. }
  14622. return *v, true
  14623. }
  14624. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  14625. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14627. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  14628. if !m.op.Is(OpUpdateOne) {
  14629. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  14630. }
  14631. if m.id == nil || m.oldValue == nil {
  14632. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  14633. }
  14634. oldValue, err := m.oldValue(ctx)
  14635. if err != nil {
  14636. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  14637. }
  14638. return oldValue.ErrorDetail, nil
  14639. }
  14640. // ResetErrorDetail resets all changes to the "error_detail" field.
  14641. func (m *MessageRecordsMutation) ResetErrorDetail() {
  14642. m.error_detail = nil
  14643. }
  14644. // SetSendTime sets the "send_time" field.
  14645. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  14646. m.send_time = &t
  14647. }
  14648. // SendTime returns the value of the "send_time" field in the mutation.
  14649. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  14650. v := m.send_time
  14651. if v == nil {
  14652. return
  14653. }
  14654. return *v, true
  14655. }
  14656. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  14657. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14659. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  14660. if !m.op.Is(OpUpdateOne) {
  14661. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  14662. }
  14663. if m.id == nil || m.oldValue == nil {
  14664. return v, errors.New("OldSendTime requires an ID field in the mutation")
  14665. }
  14666. oldValue, err := m.oldValue(ctx)
  14667. if err != nil {
  14668. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  14669. }
  14670. return oldValue.SendTime, nil
  14671. }
  14672. // ClearSendTime clears the value of the "send_time" field.
  14673. func (m *MessageRecordsMutation) ClearSendTime() {
  14674. m.send_time = nil
  14675. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  14676. }
  14677. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  14678. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  14679. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  14680. return ok
  14681. }
  14682. // ResetSendTime resets all changes to the "send_time" field.
  14683. func (m *MessageRecordsMutation) ResetSendTime() {
  14684. m.send_time = nil
  14685. delete(m.clearedFields, messagerecords.FieldSendTime)
  14686. }
  14687. // SetSourceType sets the "source_type" field.
  14688. func (m *MessageRecordsMutation) SetSourceType(i int) {
  14689. m.source_type = &i
  14690. m.addsource_type = nil
  14691. }
  14692. // SourceType returns the value of the "source_type" field in the mutation.
  14693. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  14694. v := m.source_type
  14695. if v == nil {
  14696. return
  14697. }
  14698. return *v, true
  14699. }
  14700. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  14701. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14703. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  14704. if !m.op.Is(OpUpdateOne) {
  14705. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  14706. }
  14707. if m.id == nil || m.oldValue == nil {
  14708. return v, errors.New("OldSourceType requires an ID field in the mutation")
  14709. }
  14710. oldValue, err := m.oldValue(ctx)
  14711. if err != nil {
  14712. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  14713. }
  14714. return oldValue.SourceType, nil
  14715. }
  14716. // AddSourceType adds i to the "source_type" field.
  14717. func (m *MessageRecordsMutation) AddSourceType(i int) {
  14718. if m.addsource_type != nil {
  14719. *m.addsource_type += i
  14720. } else {
  14721. m.addsource_type = &i
  14722. }
  14723. }
  14724. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  14725. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  14726. v := m.addsource_type
  14727. if v == nil {
  14728. return
  14729. }
  14730. return *v, true
  14731. }
  14732. // ResetSourceType resets all changes to the "source_type" field.
  14733. func (m *MessageRecordsMutation) ResetSourceType() {
  14734. m.source_type = nil
  14735. m.addsource_type = nil
  14736. }
  14737. // SetSourceID sets the "source_id" field.
  14738. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  14739. m.sop_stage = &u
  14740. }
  14741. // SourceID returns the value of the "source_id" field in the mutation.
  14742. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  14743. v := m.sop_stage
  14744. if v == nil {
  14745. return
  14746. }
  14747. return *v, true
  14748. }
  14749. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  14750. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14752. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  14753. if !m.op.Is(OpUpdateOne) {
  14754. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  14755. }
  14756. if m.id == nil || m.oldValue == nil {
  14757. return v, errors.New("OldSourceID requires an ID field in the mutation")
  14758. }
  14759. oldValue, err := m.oldValue(ctx)
  14760. if err != nil {
  14761. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  14762. }
  14763. return oldValue.SourceID, nil
  14764. }
  14765. // ClearSourceID clears the value of the "source_id" field.
  14766. func (m *MessageRecordsMutation) ClearSourceID() {
  14767. m.sop_stage = nil
  14768. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  14769. }
  14770. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  14771. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  14772. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  14773. return ok
  14774. }
  14775. // ResetSourceID resets all changes to the "source_id" field.
  14776. func (m *MessageRecordsMutation) ResetSourceID() {
  14777. m.sop_stage = nil
  14778. delete(m.clearedFields, messagerecords.FieldSourceID)
  14779. }
  14780. // SetSubSourceID sets the "sub_source_id" field.
  14781. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  14782. m.sop_node = &u
  14783. }
  14784. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  14785. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  14786. v := m.sop_node
  14787. if v == nil {
  14788. return
  14789. }
  14790. return *v, true
  14791. }
  14792. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  14793. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14795. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  14796. if !m.op.Is(OpUpdateOne) {
  14797. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  14798. }
  14799. if m.id == nil || m.oldValue == nil {
  14800. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  14801. }
  14802. oldValue, err := m.oldValue(ctx)
  14803. if err != nil {
  14804. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  14805. }
  14806. return oldValue.SubSourceID, nil
  14807. }
  14808. // ClearSubSourceID clears the value of the "sub_source_id" field.
  14809. func (m *MessageRecordsMutation) ClearSubSourceID() {
  14810. m.sop_node = nil
  14811. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  14812. }
  14813. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  14814. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  14815. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  14816. return ok
  14817. }
  14818. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  14819. func (m *MessageRecordsMutation) ResetSubSourceID() {
  14820. m.sop_node = nil
  14821. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  14822. }
  14823. // SetOrganizationID sets the "organization_id" field.
  14824. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  14825. m.organization_id = &u
  14826. m.addorganization_id = nil
  14827. }
  14828. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14829. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  14830. v := m.organization_id
  14831. if v == nil {
  14832. return
  14833. }
  14834. return *v, true
  14835. }
  14836. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  14837. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14839. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14840. if !m.op.Is(OpUpdateOne) {
  14841. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14842. }
  14843. if m.id == nil || m.oldValue == nil {
  14844. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14845. }
  14846. oldValue, err := m.oldValue(ctx)
  14847. if err != nil {
  14848. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14849. }
  14850. return oldValue.OrganizationID, nil
  14851. }
  14852. // AddOrganizationID adds u to the "organization_id" field.
  14853. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  14854. if m.addorganization_id != nil {
  14855. *m.addorganization_id += u
  14856. } else {
  14857. m.addorganization_id = &u
  14858. }
  14859. }
  14860. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14861. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  14862. v := m.addorganization_id
  14863. if v == nil {
  14864. return
  14865. }
  14866. return *v, true
  14867. }
  14868. // ClearOrganizationID clears the value of the "organization_id" field.
  14869. func (m *MessageRecordsMutation) ClearOrganizationID() {
  14870. m.organization_id = nil
  14871. m.addorganization_id = nil
  14872. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  14873. }
  14874. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14875. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  14876. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  14877. return ok
  14878. }
  14879. // ResetOrganizationID resets all changes to the "organization_id" field.
  14880. func (m *MessageRecordsMutation) ResetOrganizationID() {
  14881. m.organization_id = nil
  14882. m.addorganization_id = nil
  14883. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  14884. }
  14885. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  14886. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  14887. m.sop_stage = &id
  14888. }
  14889. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  14890. func (m *MessageRecordsMutation) ClearSopStage() {
  14891. m.clearedsop_stage = true
  14892. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  14893. }
  14894. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  14895. func (m *MessageRecordsMutation) SopStageCleared() bool {
  14896. return m.SourceIDCleared() || m.clearedsop_stage
  14897. }
  14898. // SopStageID returns the "sop_stage" edge ID in the mutation.
  14899. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  14900. if m.sop_stage != nil {
  14901. return *m.sop_stage, true
  14902. }
  14903. return
  14904. }
  14905. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  14906. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14907. // SopStageID instead. It exists only for internal usage by the builders.
  14908. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  14909. if id := m.sop_stage; id != nil {
  14910. ids = append(ids, *id)
  14911. }
  14912. return
  14913. }
  14914. // ResetSopStage resets all changes to the "sop_stage" edge.
  14915. func (m *MessageRecordsMutation) ResetSopStage() {
  14916. m.sop_stage = nil
  14917. m.clearedsop_stage = false
  14918. }
  14919. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  14920. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  14921. m.sop_node = &id
  14922. }
  14923. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  14924. func (m *MessageRecordsMutation) ClearSopNode() {
  14925. m.clearedsop_node = true
  14926. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  14927. }
  14928. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  14929. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  14930. return m.SubSourceIDCleared() || m.clearedsop_node
  14931. }
  14932. // SopNodeID returns the "sop_node" edge ID in the mutation.
  14933. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  14934. if m.sop_node != nil {
  14935. return *m.sop_node, true
  14936. }
  14937. return
  14938. }
  14939. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  14940. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14941. // SopNodeID instead. It exists only for internal usage by the builders.
  14942. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  14943. if id := m.sop_node; id != nil {
  14944. ids = append(ids, *id)
  14945. }
  14946. return
  14947. }
  14948. // ResetSopNode resets all changes to the "sop_node" edge.
  14949. func (m *MessageRecordsMutation) ResetSopNode() {
  14950. m.sop_node = nil
  14951. m.clearedsop_node = false
  14952. }
  14953. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  14954. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  14955. m.message_contact = &id
  14956. }
  14957. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  14958. func (m *MessageRecordsMutation) ClearMessageContact() {
  14959. m.clearedmessage_contact = true
  14960. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  14961. }
  14962. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  14963. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  14964. return m.ContactIDCleared() || m.clearedmessage_contact
  14965. }
  14966. // MessageContactID returns the "message_contact" edge ID in the mutation.
  14967. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  14968. if m.message_contact != nil {
  14969. return *m.message_contact, true
  14970. }
  14971. return
  14972. }
  14973. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  14974. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14975. // MessageContactID instead. It exists only for internal usage by the builders.
  14976. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  14977. if id := m.message_contact; id != nil {
  14978. ids = append(ids, *id)
  14979. }
  14980. return
  14981. }
  14982. // ResetMessageContact resets all changes to the "message_contact" edge.
  14983. func (m *MessageRecordsMutation) ResetMessageContact() {
  14984. m.message_contact = nil
  14985. m.clearedmessage_contact = false
  14986. }
  14987. // Where appends a list predicates to the MessageRecordsMutation builder.
  14988. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  14989. m.predicates = append(m.predicates, ps...)
  14990. }
  14991. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  14992. // users can use type-assertion to append predicates that do not depend on any generated package.
  14993. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  14994. p := make([]predicate.MessageRecords, len(ps))
  14995. for i := range ps {
  14996. p[i] = ps[i]
  14997. }
  14998. m.Where(p...)
  14999. }
  15000. // Op returns the operation name.
  15001. func (m *MessageRecordsMutation) Op() Op {
  15002. return m.op
  15003. }
  15004. // SetOp allows setting the mutation operation.
  15005. func (m *MessageRecordsMutation) SetOp(op Op) {
  15006. m.op = op
  15007. }
  15008. // Type returns the node type of this mutation (MessageRecords).
  15009. func (m *MessageRecordsMutation) Type() string {
  15010. return m.typ
  15011. }
  15012. // Fields returns all fields that were changed during this mutation. Note that in
  15013. // order to get all numeric fields that were incremented/decremented, call
  15014. // AddedFields().
  15015. func (m *MessageRecordsMutation) Fields() []string {
  15016. fields := make([]string, 0, 16)
  15017. if m.created_at != nil {
  15018. fields = append(fields, messagerecords.FieldCreatedAt)
  15019. }
  15020. if m.updated_at != nil {
  15021. fields = append(fields, messagerecords.FieldUpdatedAt)
  15022. }
  15023. if m.status != nil {
  15024. fields = append(fields, messagerecords.FieldStatus)
  15025. }
  15026. if m.bot_wxid != nil {
  15027. fields = append(fields, messagerecords.FieldBotWxid)
  15028. }
  15029. if m.message_contact != nil {
  15030. fields = append(fields, messagerecords.FieldContactID)
  15031. }
  15032. if m.contact_type != nil {
  15033. fields = append(fields, messagerecords.FieldContactType)
  15034. }
  15035. if m.contact_wxid != nil {
  15036. fields = append(fields, messagerecords.FieldContactWxid)
  15037. }
  15038. if m.content_type != nil {
  15039. fields = append(fields, messagerecords.FieldContentType)
  15040. }
  15041. if m.content != nil {
  15042. fields = append(fields, messagerecords.FieldContent)
  15043. }
  15044. if m.meta != nil {
  15045. fields = append(fields, messagerecords.FieldMeta)
  15046. }
  15047. if m.error_detail != nil {
  15048. fields = append(fields, messagerecords.FieldErrorDetail)
  15049. }
  15050. if m.send_time != nil {
  15051. fields = append(fields, messagerecords.FieldSendTime)
  15052. }
  15053. if m.source_type != nil {
  15054. fields = append(fields, messagerecords.FieldSourceType)
  15055. }
  15056. if m.sop_stage != nil {
  15057. fields = append(fields, messagerecords.FieldSourceID)
  15058. }
  15059. if m.sop_node != nil {
  15060. fields = append(fields, messagerecords.FieldSubSourceID)
  15061. }
  15062. if m.organization_id != nil {
  15063. fields = append(fields, messagerecords.FieldOrganizationID)
  15064. }
  15065. return fields
  15066. }
  15067. // Field returns the value of a field with the given name. The second boolean
  15068. // return value indicates that this field was not set, or was not defined in the
  15069. // schema.
  15070. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  15071. switch name {
  15072. case messagerecords.FieldCreatedAt:
  15073. return m.CreatedAt()
  15074. case messagerecords.FieldUpdatedAt:
  15075. return m.UpdatedAt()
  15076. case messagerecords.FieldStatus:
  15077. return m.Status()
  15078. case messagerecords.FieldBotWxid:
  15079. return m.BotWxid()
  15080. case messagerecords.FieldContactID:
  15081. return m.ContactID()
  15082. case messagerecords.FieldContactType:
  15083. return m.ContactType()
  15084. case messagerecords.FieldContactWxid:
  15085. return m.ContactWxid()
  15086. case messagerecords.FieldContentType:
  15087. return m.ContentType()
  15088. case messagerecords.FieldContent:
  15089. return m.Content()
  15090. case messagerecords.FieldMeta:
  15091. return m.Meta()
  15092. case messagerecords.FieldErrorDetail:
  15093. return m.ErrorDetail()
  15094. case messagerecords.FieldSendTime:
  15095. return m.SendTime()
  15096. case messagerecords.FieldSourceType:
  15097. return m.SourceType()
  15098. case messagerecords.FieldSourceID:
  15099. return m.SourceID()
  15100. case messagerecords.FieldSubSourceID:
  15101. return m.SubSourceID()
  15102. case messagerecords.FieldOrganizationID:
  15103. return m.OrganizationID()
  15104. }
  15105. return nil, false
  15106. }
  15107. // OldField returns the old value of the field from the database. An error is
  15108. // returned if the mutation operation is not UpdateOne, or the query to the
  15109. // database failed.
  15110. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15111. switch name {
  15112. case messagerecords.FieldCreatedAt:
  15113. return m.OldCreatedAt(ctx)
  15114. case messagerecords.FieldUpdatedAt:
  15115. return m.OldUpdatedAt(ctx)
  15116. case messagerecords.FieldStatus:
  15117. return m.OldStatus(ctx)
  15118. case messagerecords.FieldBotWxid:
  15119. return m.OldBotWxid(ctx)
  15120. case messagerecords.FieldContactID:
  15121. return m.OldContactID(ctx)
  15122. case messagerecords.FieldContactType:
  15123. return m.OldContactType(ctx)
  15124. case messagerecords.FieldContactWxid:
  15125. return m.OldContactWxid(ctx)
  15126. case messagerecords.FieldContentType:
  15127. return m.OldContentType(ctx)
  15128. case messagerecords.FieldContent:
  15129. return m.OldContent(ctx)
  15130. case messagerecords.FieldMeta:
  15131. return m.OldMeta(ctx)
  15132. case messagerecords.FieldErrorDetail:
  15133. return m.OldErrorDetail(ctx)
  15134. case messagerecords.FieldSendTime:
  15135. return m.OldSendTime(ctx)
  15136. case messagerecords.FieldSourceType:
  15137. return m.OldSourceType(ctx)
  15138. case messagerecords.FieldSourceID:
  15139. return m.OldSourceID(ctx)
  15140. case messagerecords.FieldSubSourceID:
  15141. return m.OldSubSourceID(ctx)
  15142. case messagerecords.FieldOrganizationID:
  15143. return m.OldOrganizationID(ctx)
  15144. }
  15145. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  15146. }
  15147. // SetField sets the value of a field with the given name. It returns an error if
  15148. // the field is not defined in the schema, or if the type mismatched the field
  15149. // type.
  15150. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  15151. switch name {
  15152. case messagerecords.FieldCreatedAt:
  15153. v, ok := value.(time.Time)
  15154. if !ok {
  15155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15156. }
  15157. m.SetCreatedAt(v)
  15158. return nil
  15159. case messagerecords.FieldUpdatedAt:
  15160. v, ok := value.(time.Time)
  15161. if !ok {
  15162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15163. }
  15164. m.SetUpdatedAt(v)
  15165. return nil
  15166. case messagerecords.FieldStatus:
  15167. v, ok := value.(uint8)
  15168. if !ok {
  15169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15170. }
  15171. m.SetStatus(v)
  15172. return nil
  15173. case messagerecords.FieldBotWxid:
  15174. v, ok := value.(string)
  15175. if !ok {
  15176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15177. }
  15178. m.SetBotWxid(v)
  15179. return nil
  15180. case messagerecords.FieldContactID:
  15181. v, ok := value.(uint64)
  15182. if !ok {
  15183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15184. }
  15185. m.SetContactID(v)
  15186. return nil
  15187. case messagerecords.FieldContactType:
  15188. v, ok := value.(int)
  15189. if !ok {
  15190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15191. }
  15192. m.SetContactType(v)
  15193. return nil
  15194. case messagerecords.FieldContactWxid:
  15195. v, ok := value.(string)
  15196. if !ok {
  15197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15198. }
  15199. m.SetContactWxid(v)
  15200. return nil
  15201. case messagerecords.FieldContentType:
  15202. v, ok := value.(int)
  15203. if !ok {
  15204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15205. }
  15206. m.SetContentType(v)
  15207. return nil
  15208. case messagerecords.FieldContent:
  15209. v, ok := value.(string)
  15210. if !ok {
  15211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15212. }
  15213. m.SetContent(v)
  15214. return nil
  15215. case messagerecords.FieldMeta:
  15216. v, ok := value.(custom_types.Meta)
  15217. if !ok {
  15218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15219. }
  15220. m.SetMeta(v)
  15221. return nil
  15222. case messagerecords.FieldErrorDetail:
  15223. v, ok := value.(string)
  15224. if !ok {
  15225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15226. }
  15227. m.SetErrorDetail(v)
  15228. return nil
  15229. case messagerecords.FieldSendTime:
  15230. v, ok := value.(time.Time)
  15231. if !ok {
  15232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15233. }
  15234. m.SetSendTime(v)
  15235. return nil
  15236. case messagerecords.FieldSourceType:
  15237. v, ok := value.(int)
  15238. if !ok {
  15239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15240. }
  15241. m.SetSourceType(v)
  15242. return nil
  15243. case messagerecords.FieldSourceID:
  15244. v, ok := value.(uint64)
  15245. if !ok {
  15246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15247. }
  15248. m.SetSourceID(v)
  15249. return nil
  15250. case messagerecords.FieldSubSourceID:
  15251. v, ok := value.(uint64)
  15252. if !ok {
  15253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15254. }
  15255. m.SetSubSourceID(v)
  15256. return nil
  15257. case messagerecords.FieldOrganizationID:
  15258. v, ok := value.(uint64)
  15259. if !ok {
  15260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15261. }
  15262. m.SetOrganizationID(v)
  15263. return nil
  15264. }
  15265. return fmt.Errorf("unknown MessageRecords field %s", name)
  15266. }
  15267. // AddedFields returns all numeric fields that were incremented/decremented during
  15268. // this mutation.
  15269. func (m *MessageRecordsMutation) AddedFields() []string {
  15270. var fields []string
  15271. if m.addstatus != nil {
  15272. fields = append(fields, messagerecords.FieldStatus)
  15273. }
  15274. if m.addcontact_type != nil {
  15275. fields = append(fields, messagerecords.FieldContactType)
  15276. }
  15277. if m.addcontent_type != nil {
  15278. fields = append(fields, messagerecords.FieldContentType)
  15279. }
  15280. if m.addsource_type != nil {
  15281. fields = append(fields, messagerecords.FieldSourceType)
  15282. }
  15283. if m.addorganization_id != nil {
  15284. fields = append(fields, messagerecords.FieldOrganizationID)
  15285. }
  15286. return fields
  15287. }
  15288. // AddedField returns the numeric value that was incremented/decremented on a field
  15289. // with the given name. The second boolean return value indicates that this field
  15290. // was not set, or was not defined in the schema.
  15291. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  15292. switch name {
  15293. case messagerecords.FieldStatus:
  15294. return m.AddedStatus()
  15295. case messagerecords.FieldContactType:
  15296. return m.AddedContactType()
  15297. case messagerecords.FieldContentType:
  15298. return m.AddedContentType()
  15299. case messagerecords.FieldSourceType:
  15300. return m.AddedSourceType()
  15301. case messagerecords.FieldOrganizationID:
  15302. return m.AddedOrganizationID()
  15303. }
  15304. return nil, false
  15305. }
  15306. // AddField adds the value to the field with the given name. It returns an error if
  15307. // the field is not defined in the schema, or if the type mismatched the field
  15308. // type.
  15309. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  15310. switch name {
  15311. case messagerecords.FieldStatus:
  15312. v, ok := value.(int8)
  15313. if !ok {
  15314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15315. }
  15316. m.AddStatus(v)
  15317. return nil
  15318. case messagerecords.FieldContactType:
  15319. v, ok := value.(int)
  15320. if !ok {
  15321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15322. }
  15323. m.AddContactType(v)
  15324. return nil
  15325. case messagerecords.FieldContentType:
  15326. v, ok := value.(int)
  15327. if !ok {
  15328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15329. }
  15330. m.AddContentType(v)
  15331. return nil
  15332. case messagerecords.FieldSourceType:
  15333. v, ok := value.(int)
  15334. if !ok {
  15335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15336. }
  15337. m.AddSourceType(v)
  15338. return nil
  15339. case messagerecords.FieldOrganizationID:
  15340. v, ok := value.(int64)
  15341. if !ok {
  15342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15343. }
  15344. m.AddOrganizationID(v)
  15345. return nil
  15346. }
  15347. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  15348. }
  15349. // ClearedFields returns all nullable fields that were cleared during this
  15350. // mutation.
  15351. func (m *MessageRecordsMutation) ClearedFields() []string {
  15352. var fields []string
  15353. if m.FieldCleared(messagerecords.FieldStatus) {
  15354. fields = append(fields, messagerecords.FieldStatus)
  15355. }
  15356. if m.FieldCleared(messagerecords.FieldContactID) {
  15357. fields = append(fields, messagerecords.FieldContactID)
  15358. }
  15359. if m.FieldCleared(messagerecords.FieldMeta) {
  15360. fields = append(fields, messagerecords.FieldMeta)
  15361. }
  15362. if m.FieldCleared(messagerecords.FieldSendTime) {
  15363. fields = append(fields, messagerecords.FieldSendTime)
  15364. }
  15365. if m.FieldCleared(messagerecords.FieldSourceID) {
  15366. fields = append(fields, messagerecords.FieldSourceID)
  15367. }
  15368. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  15369. fields = append(fields, messagerecords.FieldSubSourceID)
  15370. }
  15371. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  15372. fields = append(fields, messagerecords.FieldOrganizationID)
  15373. }
  15374. return fields
  15375. }
  15376. // FieldCleared returns a boolean indicating if a field with the given name was
  15377. // cleared in this mutation.
  15378. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  15379. _, ok := m.clearedFields[name]
  15380. return ok
  15381. }
  15382. // ClearField clears the value of the field with the given name. It returns an
  15383. // error if the field is not defined in the schema.
  15384. func (m *MessageRecordsMutation) ClearField(name string) error {
  15385. switch name {
  15386. case messagerecords.FieldStatus:
  15387. m.ClearStatus()
  15388. return nil
  15389. case messagerecords.FieldContactID:
  15390. m.ClearContactID()
  15391. return nil
  15392. case messagerecords.FieldMeta:
  15393. m.ClearMeta()
  15394. return nil
  15395. case messagerecords.FieldSendTime:
  15396. m.ClearSendTime()
  15397. return nil
  15398. case messagerecords.FieldSourceID:
  15399. m.ClearSourceID()
  15400. return nil
  15401. case messagerecords.FieldSubSourceID:
  15402. m.ClearSubSourceID()
  15403. return nil
  15404. case messagerecords.FieldOrganizationID:
  15405. m.ClearOrganizationID()
  15406. return nil
  15407. }
  15408. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  15409. }
  15410. // ResetField resets all changes in the mutation for the field with the given name.
  15411. // It returns an error if the field is not defined in the schema.
  15412. func (m *MessageRecordsMutation) ResetField(name string) error {
  15413. switch name {
  15414. case messagerecords.FieldCreatedAt:
  15415. m.ResetCreatedAt()
  15416. return nil
  15417. case messagerecords.FieldUpdatedAt:
  15418. m.ResetUpdatedAt()
  15419. return nil
  15420. case messagerecords.FieldStatus:
  15421. m.ResetStatus()
  15422. return nil
  15423. case messagerecords.FieldBotWxid:
  15424. m.ResetBotWxid()
  15425. return nil
  15426. case messagerecords.FieldContactID:
  15427. m.ResetContactID()
  15428. return nil
  15429. case messagerecords.FieldContactType:
  15430. m.ResetContactType()
  15431. return nil
  15432. case messagerecords.FieldContactWxid:
  15433. m.ResetContactWxid()
  15434. return nil
  15435. case messagerecords.FieldContentType:
  15436. m.ResetContentType()
  15437. return nil
  15438. case messagerecords.FieldContent:
  15439. m.ResetContent()
  15440. return nil
  15441. case messagerecords.FieldMeta:
  15442. m.ResetMeta()
  15443. return nil
  15444. case messagerecords.FieldErrorDetail:
  15445. m.ResetErrorDetail()
  15446. return nil
  15447. case messagerecords.FieldSendTime:
  15448. m.ResetSendTime()
  15449. return nil
  15450. case messagerecords.FieldSourceType:
  15451. m.ResetSourceType()
  15452. return nil
  15453. case messagerecords.FieldSourceID:
  15454. m.ResetSourceID()
  15455. return nil
  15456. case messagerecords.FieldSubSourceID:
  15457. m.ResetSubSourceID()
  15458. return nil
  15459. case messagerecords.FieldOrganizationID:
  15460. m.ResetOrganizationID()
  15461. return nil
  15462. }
  15463. return fmt.Errorf("unknown MessageRecords field %s", name)
  15464. }
  15465. // AddedEdges returns all edge names that were set/added in this mutation.
  15466. func (m *MessageRecordsMutation) AddedEdges() []string {
  15467. edges := make([]string, 0, 3)
  15468. if m.sop_stage != nil {
  15469. edges = append(edges, messagerecords.EdgeSopStage)
  15470. }
  15471. if m.sop_node != nil {
  15472. edges = append(edges, messagerecords.EdgeSopNode)
  15473. }
  15474. if m.message_contact != nil {
  15475. edges = append(edges, messagerecords.EdgeMessageContact)
  15476. }
  15477. return edges
  15478. }
  15479. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15480. // name in this mutation.
  15481. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  15482. switch name {
  15483. case messagerecords.EdgeSopStage:
  15484. if id := m.sop_stage; id != nil {
  15485. return []ent.Value{*id}
  15486. }
  15487. case messagerecords.EdgeSopNode:
  15488. if id := m.sop_node; id != nil {
  15489. return []ent.Value{*id}
  15490. }
  15491. case messagerecords.EdgeMessageContact:
  15492. if id := m.message_contact; id != nil {
  15493. return []ent.Value{*id}
  15494. }
  15495. }
  15496. return nil
  15497. }
  15498. // RemovedEdges returns all edge names that were removed in this mutation.
  15499. func (m *MessageRecordsMutation) RemovedEdges() []string {
  15500. edges := make([]string, 0, 3)
  15501. return edges
  15502. }
  15503. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15504. // the given name in this mutation.
  15505. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  15506. return nil
  15507. }
  15508. // ClearedEdges returns all edge names that were cleared in this mutation.
  15509. func (m *MessageRecordsMutation) ClearedEdges() []string {
  15510. edges := make([]string, 0, 3)
  15511. if m.clearedsop_stage {
  15512. edges = append(edges, messagerecords.EdgeSopStage)
  15513. }
  15514. if m.clearedsop_node {
  15515. edges = append(edges, messagerecords.EdgeSopNode)
  15516. }
  15517. if m.clearedmessage_contact {
  15518. edges = append(edges, messagerecords.EdgeMessageContact)
  15519. }
  15520. return edges
  15521. }
  15522. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15523. // was cleared in this mutation.
  15524. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  15525. switch name {
  15526. case messagerecords.EdgeSopStage:
  15527. return m.clearedsop_stage
  15528. case messagerecords.EdgeSopNode:
  15529. return m.clearedsop_node
  15530. case messagerecords.EdgeMessageContact:
  15531. return m.clearedmessage_contact
  15532. }
  15533. return false
  15534. }
  15535. // ClearEdge clears the value of the edge with the given name. It returns an error
  15536. // if that edge is not defined in the schema.
  15537. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  15538. switch name {
  15539. case messagerecords.EdgeSopStage:
  15540. m.ClearSopStage()
  15541. return nil
  15542. case messagerecords.EdgeSopNode:
  15543. m.ClearSopNode()
  15544. return nil
  15545. case messagerecords.EdgeMessageContact:
  15546. m.ClearMessageContact()
  15547. return nil
  15548. }
  15549. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  15550. }
  15551. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15552. // It returns an error if the edge is not defined in the schema.
  15553. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  15554. switch name {
  15555. case messagerecords.EdgeSopStage:
  15556. m.ResetSopStage()
  15557. return nil
  15558. case messagerecords.EdgeSopNode:
  15559. m.ResetSopNode()
  15560. return nil
  15561. case messagerecords.EdgeMessageContact:
  15562. m.ResetMessageContact()
  15563. return nil
  15564. }
  15565. return fmt.Errorf("unknown MessageRecords edge %s", name)
  15566. }
  15567. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  15568. type MsgMutation struct {
  15569. config
  15570. op Op
  15571. typ string
  15572. id *uint64
  15573. created_at *time.Time
  15574. updated_at *time.Time
  15575. deleted_at *time.Time
  15576. status *uint8
  15577. addstatus *int8
  15578. fromwxid *string
  15579. toid *string
  15580. msgtype *int32
  15581. addmsgtype *int32
  15582. msg *string
  15583. batch_no *string
  15584. clearedFields map[string]struct{}
  15585. done bool
  15586. oldValue func(context.Context) (*Msg, error)
  15587. predicates []predicate.Msg
  15588. }
  15589. var _ ent.Mutation = (*MsgMutation)(nil)
  15590. // msgOption allows management of the mutation configuration using functional options.
  15591. type msgOption func(*MsgMutation)
  15592. // newMsgMutation creates new mutation for the Msg entity.
  15593. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  15594. m := &MsgMutation{
  15595. config: c,
  15596. op: op,
  15597. typ: TypeMsg,
  15598. clearedFields: make(map[string]struct{}),
  15599. }
  15600. for _, opt := range opts {
  15601. opt(m)
  15602. }
  15603. return m
  15604. }
  15605. // withMsgID sets the ID field of the mutation.
  15606. func withMsgID(id uint64) msgOption {
  15607. return func(m *MsgMutation) {
  15608. var (
  15609. err error
  15610. once sync.Once
  15611. value *Msg
  15612. )
  15613. m.oldValue = func(ctx context.Context) (*Msg, error) {
  15614. once.Do(func() {
  15615. if m.done {
  15616. err = errors.New("querying old values post mutation is not allowed")
  15617. } else {
  15618. value, err = m.Client().Msg.Get(ctx, id)
  15619. }
  15620. })
  15621. return value, err
  15622. }
  15623. m.id = &id
  15624. }
  15625. }
  15626. // withMsg sets the old Msg of the mutation.
  15627. func withMsg(node *Msg) msgOption {
  15628. return func(m *MsgMutation) {
  15629. m.oldValue = func(context.Context) (*Msg, error) {
  15630. return node, nil
  15631. }
  15632. m.id = &node.ID
  15633. }
  15634. }
  15635. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15636. // executed in a transaction (ent.Tx), a transactional client is returned.
  15637. func (m MsgMutation) Client() *Client {
  15638. client := &Client{config: m.config}
  15639. client.init()
  15640. return client
  15641. }
  15642. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15643. // it returns an error otherwise.
  15644. func (m MsgMutation) Tx() (*Tx, error) {
  15645. if _, ok := m.driver.(*txDriver); !ok {
  15646. return nil, errors.New("ent: mutation is not running in a transaction")
  15647. }
  15648. tx := &Tx{config: m.config}
  15649. tx.init()
  15650. return tx, nil
  15651. }
  15652. // SetID sets the value of the id field. Note that this
  15653. // operation is only accepted on creation of Msg entities.
  15654. func (m *MsgMutation) SetID(id uint64) {
  15655. m.id = &id
  15656. }
  15657. // ID returns the ID value in the mutation. Note that the ID is only available
  15658. // if it was provided to the builder or after it was returned from the database.
  15659. func (m *MsgMutation) ID() (id uint64, exists bool) {
  15660. if m.id == nil {
  15661. return
  15662. }
  15663. return *m.id, true
  15664. }
  15665. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15666. // That means, if the mutation is applied within a transaction with an isolation level such
  15667. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15668. // or updated by the mutation.
  15669. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  15670. switch {
  15671. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15672. id, exists := m.ID()
  15673. if exists {
  15674. return []uint64{id}, nil
  15675. }
  15676. fallthrough
  15677. case m.op.Is(OpUpdate | OpDelete):
  15678. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  15679. default:
  15680. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15681. }
  15682. }
  15683. // SetCreatedAt sets the "created_at" field.
  15684. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  15685. m.created_at = &t
  15686. }
  15687. // CreatedAt returns the value of the "created_at" field in the mutation.
  15688. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  15689. v := m.created_at
  15690. if v == nil {
  15691. return
  15692. }
  15693. return *v, true
  15694. }
  15695. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  15696. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15698. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15699. if !m.op.Is(OpUpdateOne) {
  15700. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15701. }
  15702. if m.id == nil || m.oldValue == nil {
  15703. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15704. }
  15705. oldValue, err := m.oldValue(ctx)
  15706. if err != nil {
  15707. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15708. }
  15709. return oldValue.CreatedAt, nil
  15710. }
  15711. // ResetCreatedAt resets all changes to the "created_at" field.
  15712. func (m *MsgMutation) ResetCreatedAt() {
  15713. m.created_at = nil
  15714. }
  15715. // SetUpdatedAt sets the "updated_at" field.
  15716. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  15717. m.updated_at = &t
  15718. }
  15719. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15720. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  15721. v := m.updated_at
  15722. if v == nil {
  15723. return
  15724. }
  15725. return *v, true
  15726. }
  15727. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  15728. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15730. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15731. if !m.op.Is(OpUpdateOne) {
  15732. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15733. }
  15734. if m.id == nil || m.oldValue == nil {
  15735. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15736. }
  15737. oldValue, err := m.oldValue(ctx)
  15738. if err != nil {
  15739. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15740. }
  15741. return oldValue.UpdatedAt, nil
  15742. }
  15743. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15744. func (m *MsgMutation) ResetUpdatedAt() {
  15745. m.updated_at = nil
  15746. }
  15747. // SetDeletedAt sets the "deleted_at" field.
  15748. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  15749. m.deleted_at = &t
  15750. }
  15751. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15752. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  15753. v := m.deleted_at
  15754. if v == nil {
  15755. return
  15756. }
  15757. return *v, true
  15758. }
  15759. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  15760. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15762. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15763. if !m.op.Is(OpUpdateOne) {
  15764. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15765. }
  15766. if m.id == nil || m.oldValue == nil {
  15767. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15768. }
  15769. oldValue, err := m.oldValue(ctx)
  15770. if err != nil {
  15771. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15772. }
  15773. return oldValue.DeletedAt, nil
  15774. }
  15775. // ClearDeletedAt clears the value of the "deleted_at" field.
  15776. func (m *MsgMutation) ClearDeletedAt() {
  15777. m.deleted_at = nil
  15778. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  15779. }
  15780. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15781. func (m *MsgMutation) DeletedAtCleared() bool {
  15782. _, ok := m.clearedFields[msg.FieldDeletedAt]
  15783. return ok
  15784. }
  15785. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15786. func (m *MsgMutation) ResetDeletedAt() {
  15787. m.deleted_at = nil
  15788. delete(m.clearedFields, msg.FieldDeletedAt)
  15789. }
  15790. // SetStatus sets the "status" field.
  15791. func (m *MsgMutation) SetStatus(u uint8) {
  15792. m.status = &u
  15793. m.addstatus = nil
  15794. }
  15795. // Status returns the value of the "status" field in the mutation.
  15796. func (m *MsgMutation) Status() (r uint8, exists bool) {
  15797. v := m.status
  15798. if v == nil {
  15799. return
  15800. }
  15801. return *v, true
  15802. }
  15803. // OldStatus returns the old "status" field's value of the Msg entity.
  15804. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15806. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15807. if !m.op.Is(OpUpdateOne) {
  15808. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15809. }
  15810. if m.id == nil || m.oldValue == nil {
  15811. return v, errors.New("OldStatus requires an ID field in the mutation")
  15812. }
  15813. oldValue, err := m.oldValue(ctx)
  15814. if err != nil {
  15815. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15816. }
  15817. return oldValue.Status, nil
  15818. }
  15819. // AddStatus adds u to the "status" field.
  15820. func (m *MsgMutation) AddStatus(u int8) {
  15821. if m.addstatus != nil {
  15822. *m.addstatus += u
  15823. } else {
  15824. m.addstatus = &u
  15825. }
  15826. }
  15827. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15828. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  15829. v := m.addstatus
  15830. if v == nil {
  15831. return
  15832. }
  15833. return *v, true
  15834. }
  15835. // ClearStatus clears the value of the "status" field.
  15836. func (m *MsgMutation) ClearStatus() {
  15837. m.status = nil
  15838. m.addstatus = nil
  15839. m.clearedFields[msg.FieldStatus] = struct{}{}
  15840. }
  15841. // StatusCleared returns if the "status" field was cleared in this mutation.
  15842. func (m *MsgMutation) StatusCleared() bool {
  15843. _, ok := m.clearedFields[msg.FieldStatus]
  15844. return ok
  15845. }
  15846. // ResetStatus resets all changes to the "status" field.
  15847. func (m *MsgMutation) ResetStatus() {
  15848. m.status = nil
  15849. m.addstatus = nil
  15850. delete(m.clearedFields, msg.FieldStatus)
  15851. }
  15852. // SetFromwxid sets the "fromwxid" field.
  15853. func (m *MsgMutation) SetFromwxid(s string) {
  15854. m.fromwxid = &s
  15855. }
  15856. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  15857. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  15858. v := m.fromwxid
  15859. if v == nil {
  15860. return
  15861. }
  15862. return *v, true
  15863. }
  15864. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  15865. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15867. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  15868. if !m.op.Is(OpUpdateOne) {
  15869. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  15870. }
  15871. if m.id == nil || m.oldValue == nil {
  15872. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  15873. }
  15874. oldValue, err := m.oldValue(ctx)
  15875. if err != nil {
  15876. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  15877. }
  15878. return oldValue.Fromwxid, nil
  15879. }
  15880. // ClearFromwxid clears the value of the "fromwxid" field.
  15881. func (m *MsgMutation) ClearFromwxid() {
  15882. m.fromwxid = nil
  15883. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  15884. }
  15885. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  15886. func (m *MsgMutation) FromwxidCleared() bool {
  15887. _, ok := m.clearedFields[msg.FieldFromwxid]
  15888. return ok
  15889. }
  15890. // ResetFromwxid resets all changes to the "fromwxid" field.
  15891. func (m *MsgMutation) ResetFromwxid() {
  15892. m.fromwxid = nil
  15893. delete(m.clearedFields, msg.FieldFromwxid)
  15894. }
  15895. // SetToid sets the "toid" field.
  15896. func (m *MsgMutation) SetToid(s string) {
  15897. m.toid = &s
  15898. }
  15899. // Toid returns the value of the "toid" field in the mutation.
  15900. func (m *MsgMutation) Toid() (r string, exists bool) {
  15901. v := m.toid
  15902. if v == nil {
  15903. return
  15904. }
  15905. return *v, true
  15906. }
  15907. // OldToid returns the old "toid" field's value of the Msg entity.
  15908. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15910. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  15911. if !m.op.Is(OpUpdateOne) {
  15912. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  15913. }
  15914. if m.id == nil || m.oldValue == nil {
  15915. return v, errors.New("OldToid requires an ID field in the mutation")
  15916. }
  15917. oldValue, err := m.oldValue(ctx)
  15918. if err != nil {
  15919. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  15920. }
  15921. return oldValue.Toid, nil
  15922. }
  15923. // ClearToid clears the value of the "toid" field.
  15924. func (m *MsgMutation) ClearToid() {
  15925. m.toid = nil
  15926. m.clearedFields[msg.FieldToid] = struct{}{}
  15927. }
  15928. // ToidCleared returns if the "toid" field was cleared in this mutation.
  15929. func (m *MsgMutation) ToidCleared() bool {
  15930. _, ok := m.clearedFields[msg.FieldToid]
  15931. return ok
  15932. }
  15933. // ResetToid resets all changes to the "toid" field.
  15934. func (m *MsgMutation) ResetToid() {
  15935. m.toid = nil
  15936. delete(m.clearedFields, msg.FieldToid)
  15937. }
  15938. // SetMsgtype sets the "msgtype" field.
  15939. func (m *MsgMutation) SetMsgtype(i int32) {
  15940. m.msgtype = &i
  15941. m.addmsgtype = nil
  15942. }
  15943. // Msgtype returns the value of the "msgtype" field in the mutation.
  15944. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  15945. v := m.msgtype
  15946. if v == nil {
  15947. return
  15948. }
  15949. return *v, true
  15950. }
  15951. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  15952. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15954. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  15955. if !m.op.Is(OpUpdateOne) {
  15956. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  15957. }
  15958. if m.id == nil || m.oldValue == nil {
  15959. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  15960. }
  15961. oldValue, err := m.oldValue(ctx)
  15962. if err != nil {
  15963. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  15964. }
  15965. return oldValue.Msgtype, nil
  15966. }
  15967. // AddMsgtype adds i to the "msgtype" field.
  15968. func (m *MsgMutation) AddMsgtype(i int32) {
  15969. if m.addmsgtype != nil {
  15970. *m.addmsgtype += i
  15971. } else {
  15972. m.addmsgtype = &i
  15973. }
  15974. }
  15975. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  15976. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  15977. v := m.addmsgtype
  15978. if v == nil {
  15979. return
  15980. }
  15981. return *v, true
  15982. }
  15983. // ClearMsgtype clears the value of the "msgtype" field.
  15984. func (m *MsgMutation) ClearMsgtype() {
  15985. m.msgtype = nil
  15986. m.addmsgtype = nil
  15987. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  15988. }
  15989. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  15990. func (m *MsgMutation) MsgtypeCleared() bool {
  15991. _, ok := m.clearedFields[msg.FieldMsgtype]
  15992. return ok
  15993. }
  15994. // ResetMsgtype resets all changes to the "msgtype" field.
  15995. func (m *MsgMutation) ResetMsgtype() {
  15996. m.msgtype = nil
  15997. m.addmsgtype = nil
  15998. delete(m.clearedFields, msg.FieldMsgtype)
  15999. }
  16000. // SetMsg sets the "msg" field.
  16001. func (m *MsgMutation) SetMsg(s string) {
  16002. m.msg = &s
  16003. }
  16004. // Msg returns the value of the "msg" field in the mutation.
  16005. func (m *MsgMutation) Msg() (r string, exists bool) {
  16006. v := m.msg
  16007. if v == nil {
  16008. return
  16009. }
  16010. return *v, true
  16011. }
  16012. // OldMsg returns the old "msg" field's value of the Msg entity.
  16013. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16015. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  16016. if !m.op.Is(OpUpdateOne) {
  16017. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  16018. }
  16019. if m.id == nil || m.oldValue == nil {
  16020. return v, errors.New("OldMsg requires an ID field in the mutation")
  16021. }
  16022. oldValue, err := m.oldValue(ctx)
  16023. if err != nil {
  16024. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  16025. }
  16026. return oldValue.Msg, nil
  16027. }
  16028. // ClearMsg clears the value of the "msg" field.
  16029. func (m *MsgMutation) ClearMsg() {
  16030. m.msg = nil
  16031. m.clearedFields[msg.FieldMsg] = struct{}{}
  16032. }
  16033. // MsgCleared returns if the "msg" field was cleared in this mutation.
  16034. func (m *MsgMutation) MsgCleared() bool {
  16035. _, ok := m.clearedFields[msg.FieldMsg]
  16036. return ok
  16037. }
  16038. // ResetMsg resets all changes to the "msg" field.
  16039. func (m *MsgMutation) ResetMsg() {
  16040. m.msg = nil
  16041. delete(m.clearedFields, msg.FieldMsg)
  16042. }
  16043. // SetBatchNo sets the "batch_no" field.
  16044. func (m *MsgMutation) SetBatchNo(s string) {
  16045. m.batch_no = &s
  16046. }
  16047. // BatchNo returns the value of the "batch_no" field in the mutation.
  16048. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  16049. v := m.batch_no
  16050. if v == nil {
  16051. return
  16052. }
  16053. return *v, true
  16054. }
  16055. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  16056. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16058. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  16059. if !m.op.Is(OpUpdateOne) {
  16060. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  16061. }
  16062. if m.id == nil || m.oldValue == nil {
  16063. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  16064. }
  16065. oldValue, err := m.oldValue(ctx)
  16066. if err != nil {
  16067. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  16068. }
  16069. return oldValue.BatchNo, nil
  16070. }
  16071. // ClearBatchNo clears the value of the "batch_no" field.
  16072. func (m *MsgMutation) ClearBatchNo() {
  16073. m.batch_no = nil
  16074. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  16075. }
  16076. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  16077. func (m *MsgMutation) BatchNoCleared() bool {
  16078. _, ok := m.clearedFields[msg.FieldBatchNo]
  16079. return ok
  16080. }
  16081. // ResetBatchNo resets all changes to the "batch_no" field.
  16082. func (m *MsgMutation) ResetBatchNo() {
  16083. m.batch_no = nil
  16084. delete(m.clearedFields, msg.FieldBatchNo)
  16085. }
  16086. // Where appends a list predicates to the MsgMutation builder.
  16087. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  16088. m.predicates = append(m.predicates, ps...)
  16089. }
  16090. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  16091. // users can use type-assertion to append predicates that do not depend on any generated package.
  16092. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  16093. p := make([]predicate.Msg, len(ps))
  16094. for i := range ps {
  16095. p[i] = ps[i]
  16096. }
  16097. m.Where(p...)
  16098. }
  16099. // Op returns the operation name.
  16100. func (m *MsgMutation) Op() Op {
  16101. return m.op
  16102. }
  16103. // SetOp allows setting the mutation operation.
  16104. func (m *MsgMutation) SetOp(op Op) {
  16105. m.op = op
  16106. }
  16107. // Type returns the node type of this mutation (Msg).
  16108. func (m *MsgMutation) Type() string {
  16109. return m.typ
  16110. }
  16111. // Fields returns all fields that were changed during this mutation. Note that in
  16112. // order to get all numeric fields that were incremented/decremented, call
  16113. // AddedFields().
  16114. func (m *MsgMutation) Fields() []string {
  16115. fields := make([]string, 0, 9)
  16116. if m.created_at != nil {
  16117. fields = append(fields, msg.FieldCreatedAt)
  16118. }
  16119. if m.updated_at != nil {
  16120. fields = append(fields, msg.FieldUpdatedAt)
  16121. }
  16122. if m.deleted_at != nil {
  16123. fields = append(fields, msg.FieldDeletedAt)
  16124. }
  16125. if m.status != nil {
  16126. fields = append(fields, msg.FieldStatus)
  16127. }
  16128. if m.fromwxid != nil {
  16129. fields = append(fields, msg.FieldFromwxid)
  16130. }
  16131. if m.toid != nil {
  16132. fields = append(fields, msg.FieldToid)
  16133. }
  16134. if m.msgtype != nil {
  16135. fields = append(fields, msg.FieldMsgtype)
  16136. }
  16137. if m.msg != nil {
  16138. fields = append(fields, msg.FieldMsg)
  16139. }
  16140. if m.batch_no != nil {
  16141. fields = append(fields, msg.FieldBatchNo)
  16142. }
  16143. return fields
  16144. }
  16145. // Field returns the value of a field with the given name. The second boolean
  16146. // return value indicates that this field was not set, or was not defined in the
  16147. // schema.
  16148. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  16149. switch name {
  16150. case msg.FieldCreatedAt:
  16151. return m.CreatedAt()
  16152. case msg.FieldUpdatedAt:
  16153. return m.UpdatedAt()
  16154. case msg.FieldDeletedAt:
  16155. return m.DeletedAt()
  16156. case msg.FieldStatus:
  16157. return m.Status()
  16158. case msg.FieldFromwxid:
  16159. return m.Fromwxid()
  16160. case msg.FieldToid:
  16161. return m.Toid()
  16162. case msg.FieldMsgtype:
  16163. return m.Msgtype()
  16164. case msg.FieldMsg:
  16165. return m.Msg()
  16166. case msg.FieldBatchNo:
  16167. return m.BatchNo()
  16168. }
  16169. return nil, false
  16170. }
  16171. // OldField returns the old value of the field from the database. An error is
  16172. // returned if the mutation operation is not UpdateOne, or the query to the
  16173. // database failed.
  16174. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16175. switch name {
  16176. case msg.FieldCreatedAt:
  16177. return m.OldCreatedAt(ctx)
  16178. case msg.FieldUpdatedAt:
  16179. return m.OldUpdatedAt(ctx)
  16180. case msg.FieldDeletedAt:
  16181. return m.OldDeletedAt(ctx)
  16182. case msg.FieldStatus:
  16183. return m.OldStatus(ctx)
  16184. case msg.FieldFromwxid:
  16185. return m.OldFromwxid(ctx)
  16186. case msg.FieldToid:
  16187. return m.OldToid(ctx)
  16188. case msg.FieldMsgtype:
  16189. return m.OldMsgtype(ctx)
  16190. case msg.FieldMsg:
  16191. return m.OldMsg(ctx)
  16192. case msg.FieldBatchNo:
  16193. return m.OldBatchNo(ctx)
  16194. }
  16195. return nil, fmt.Errorf("unknown Msg field %s", name)
  16196. }
  16197. // SetField sets the value of a field with the given name. It returns an error if
  16198. // the field is not defined in the schema, or if the type mismatched the field
  16199. // type.
  16200. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  16201. switch name {
  16202. case msg.FieldCreatedAt:
  16203. v, ok := value.(time.Time)
  16204. if !ok {
  16205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16206. }
  16207. m.SetCreatedAt(v)
  16208. return nil
  16209. case msg.FieldUpdatedAt:
  16210. v, ok := value.(time.Time)
  16211. if !ok {
  16212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16213. }
  16214. m.SetUpdatedAt(v)
  16215. return nil
  16216. case msg.FieldDeletedAt:
  16217. v, ok := value.(time.Time)
  16218. if !ok {
  16219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16220. }
  16221. m.SetDeletedAt(v)
  16222. return nil
  16223. case msg.FieldStatus:
  16224. v, ok := value.(uint8)
  16225. if !ok {
  16226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16227. }
  16228. m.SetStatus(v)
  16229. return nil
  16230. case msg.FieldFromwxid:
  16231. v, ok := value.(string)
  16232. if !ok {
  16233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16234. }
  16235. m.SetFromwxid(v)
  16236. return nil
  16237. case msg.FieldToid:
  16238. v, ok := value.(string)
  16239. if !ok {
  16240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16241. }
  16242. m.SetToid(v)
  16243. return nil
  16244. case msg.FieldMsgtype:
  16245. v, ok := value.(int32)
  16246. if !ok {
  16247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16248. }
  16249. m.SetMsgtype(v)
  16250. return nil
  16251. case msg.FieldMsg:
  16252. v, ok := value.(string)
  16253. if !ok {
  16254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16255. }
  16256. m.SetMsg(v)
  16257. return nil
  16258. case msg.FieldBatchNo:
  16259. v, ok := value.(string)
  16260. if !ok {
  16261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16262. }
  16263. m.SetBatchNo(v)
  16264. return nil
  16265. }
  16266. return fmt.Errorf("unknown Msg field %s", name)
  16267. }
  16268. // AddedFields returns all numeric fields that were incremented/decremented during
  16269. // this mutation.
  16270. func (m *MsgMutation) AddedFields() []string {
  16271. var fields []string
  16272. if m.addstatus != nil {
  16273. fields = append(fields, msg.FieldStatus)
  16274. }
  16275. if m.addmsgtype != nil {
  16276. fields = append(fields, msg.FieldMsgtype)
  16277. }
  16278. return fields
  16279. }
  16280. // AddedField returns the numeric value that was incremented/decremented on a field
  16281. // with the given name. The second boolean return value indicates that this field
  16282. // was not set, or was not defined in the schema.
  16283. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  16284. switch name {
  16285. case msg.FieldStatus:
  16286. return m.AddedStatus()
  16287. case msg.FieldMsgtype:
  16288. return m.AddedMsgtype()
  16289. }
  16290. return nil, false
  16291. }
  16292. // AddField adds the value to the field with the given name. It returns an error if
  16293. // the field is not defined in the schema, or if the type mismatched the field
  16294. // type.
  16295. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  16296. switch name {
  16297. case msg.FieldStatus:
  16298. v, ok := value.(int8)
  16299. if !ok {
  16300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16301. }
  16302. m.AddStatus(v)
  16303. return nil
  16304. case msg.FieldMsgtype:
  16305. v, ok := value.(int32)
  16306. if !ok {
  16307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16308. }
  16309. m.AddMsgtype(v)
  16310. return nil
  16311. }
  16312. return fmt.Errorf("unknown Msg numeric field %s", name)
  16313. }
  16314. // ClearedFields returns all nullable fields that were cleared during this
  16315. // mutation.
  16316. func (m *MsgMutation) ClearedFields() []string {
  16317. var fields []string
  16318. if m.FieldCleared(msg.FieldDeletedAt) {
  16319. fields = append(fields, msg.FieldDeletedAt)
  16320. }
  16321. if m.FieldCleared(msg.FieldStatus) {
  16322. fields = append(fields, msg.FieldStatus)
  16323. }
  16324. if m.FieldCleared(msg.FieldFromwxid) {
  16325. fields = append(fields, msg.FieldFromwxid)
  16326. }
  16327. if m.FieldCleared(msg.FieldToid) {
  16328. fields = append(fields, msg.FieldToid)
  16329. }
  16330. if m.FieldCleared(msg.FieldMsgtype) {
  16331. fields = append(fields, msg.FieldMsgtype)
  16332. }
  16333. if m.FieldCleared(msg.FieldMsg) {
  16334. fields = append(fields, msg.FieldMsg)
  16335. }
  16336. if m.FieldCleared(msg.FieldBatchNo) {
  16337. fields = append(fields, msg.FieldBatchNo)
  16338. }
  16339. return fields
  16340. }
  16341. // FieldCleared returns a boolean indicating if a field with the given name was
  16342. // cleared in this mutation.
  16343. func (m *MsgMutation) FieldCleared(name string) bool {
  16344. _, ok := m.clearedFields[name]
  16345. return ok
  16346. }
  16347. // ClearField clears the value of the field with the given name. It returns an
  16348. // error if the field is not defined in the schema.
  16349. func (m *MsgMutation) ClearField(name string) error {
  16350. switch name {
  16351. case msg.FieldDeletedAt:
  16352. m.ClearDeletedAt()
  16353. return nil
  16354. case msg.FieldStatus:
  16355. m.ClearStatus()
  16356. return nil
  16357. case msg.FieldFromwxid:
  16358. m.ClearFromwxid()
  16359. return nil
  16360. case msg.FieldToid:
  16361. m.ClearToid()
  16362. return nil
  16363. case msg.FieldMsgtype:
  16364. m.ClearMsgtype()
  16365. return nil
  16366. case msg.FieldMsg:
  16367. m.ClearMsg()
  16368. return nil
  16369. case msg.FieldBatchNo:
  16370. m.ClearBatchNo()
  16371. return nil
  16372. }
  16373. return fmt.Errorf("unknown Msg nullable field %s", name)
  16374. }
  16375. // ResetField resets all changes in the mutation for the field with the given name.
  16376. // It returns an error if the field is not defined in the schema.
  16377. func (m *MsgMutation) ResetField(name string) error {
  16378. switch name {
  16379. case msg.FieldCreatedAt:
  16380. m.ResetCreatedAt()
  16381. return nil
  16382. case msg.FieldUpdatedAt:
  16383. m.ResetUpdatedAt()
  16384. return nil
  16385. case msg.FieldDeletedAt:
  16386. m.ResetDeletedAt()
  16387. return nil
  16388. case msg.FieldStatus:
  16389. m.ResetStatus()
  16390. return nil
  16391. case msg.FieldFromwxid:
  16392. m.ResetFromwxid()
  16393. return nil
  16394. case msg.FieldToid:
  16395. m.ResetToid()
  16396. return nil
  16397. case msg.FieldMsgtype:
  16398. m.ResetMsgtype()
  16399. return nil
  16400. case msg.FieldMsg:
  16401. m.ResetMsg()
  16402. return nil
  16403. case msg.FieldBatchNo:
  16404. m.ResetBatchNo()
  16405. return nil
  16406. }
  16407. return fmt.Errorf("unknown Msg field %s", name)
  16408. }
  16409. // AddedEdges returns all edge names that were set/added in this mutation.
  16410. func (m *MsgMutation) AddedEdges() []string {
  16411. edges := make([]string, 0, 0)
  16412. return edges
  16413. }
  16414. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16415. // name in this mutation.
  16416. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  16417. return nil
  16418. }
  16419. // RemovedEdges returns all edge names that were removed in this mutation.
  16420. func (m *MsgMutation) RemovedEdges() []string {
  16421. edges := make([]string, 0, 0)
  16422. return edges
  16423. }
  16424. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16425. // the given name in this mutation.
  16426. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  16427. return nil
  16428. }
  16429. // ClearedEdges returns all edge names that were cleared in this mutation.
  16430. func (m *MsgMutation) ClearedEdges() []string {
  16431. edges := make([]string, 0, 0)
  16432. return edges
  16433. }
  16434. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16435. // was cleared in this mutation.
  16436. func (m *MsgMutation) EdgeCleared(name string) bool {
  16437. return false
  16438. }
  16439. // ClearEdge clears the value of the edge with the given name. It returns an error
  16440. // if that edge is not defined in the schema.
  16441. func (m *MsgMutation) ClearEdge(name string) error {
  16442. return fmt.Errorf("unknown Msg unique edge %s", name)
  16443. }
  16444. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16445. // It returns an error if the edge is not defined in the schema.
  16446. func (m *MsgMutation) ResetEdge(name string) error {
  16447. return fmt.Errorf("unknown Msg edge %s", name)
  16448. }
  16449. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  16450. type ServerMutation struct {
  16451. config
  16452. op Op
  16453. typ string
  16454. id *uint64
  16455. created_at *time.Time
  16456. updated_at *time.Time
  16457. status *uint8
  16458. addstatus *int8
  16459. deleted_at *time.Time
  16460. name *string
  16461. public_ip *string
  16462. private_ip *string
  16463. admin_port *string
  16464. clearedFields map[string]struct{}
  16465. wxs map[uint64]struct{}
  16466. removedwxs map[uint64]struct{}
  16467. clearedwxs bool
  16468. done bool
  16469. oldValue func(context.Context) (*Server, error)
  16470. predicates []predicate.Server
  16471. }
  16472. var _ ent.Mutation = (*ServerMutation)(nil)
  16473. // serverOption allows management of the mutation configuration using functional options.
  16474. type serverOption func(*ServerMutation)
  16475. // newServerMutation creates new mutation for the Server entity.
  16476. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  16477. m := &ServerMutation{
  16478. config: c,
  16479. op: op,
  16480. typ: TypeServer,
  16481. clearedFields: make(map[string]struct{}),
  16482. }
  16483. for _, opt := range opts {
  16484. opt(m)
  16485. }
  16486. return m
  16487. }
  16488. // withServerID sets the ID field of the mutation.
  16489. func withServerID(id uint64) serverOption {
  16490. return func(m *ServerMutation) {
  16491. var (
  16492. err error
  16493. once sync.Once
  16494. value *Server
  16495. )
  16496. m.oldValue = func(ctx context.Context) (*Server, error) {
  16497. once.Do(func() {
  16498. if m.done {
  16499. err = errors.New("querying old values post mutation is not allowed")
  16500. } else {
  16501. value, err = m.Client().Server.Get(ctx, id)
  16502. }
  16503. })
  16504. return value, err
  16505. }
  16506. m.id = &id
  16507. }
  16508. }
  16509. // withServer sets the old Server of the mutation.
  16510. func withServer(node *Server) serverOption {
  16511. return func(m *ServerMutation) {
  16512. m.oldValue = func(context.Context) (*Server, error) {
  16513. return node, nil
  16514. }
  16515. m.id = &node.ID
  16516. }
  16517. }
  16518. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16519. // executed in a transaction (ent.Tx), a transactional client is returned.
  16520. func (m ServerMutation) Client() *Client {
  16521. client := &Client{config: m.config}
  16522. client.init()
  16523. return client
  16524. }
  16525. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16526. // it returns an error otherwise.
  16527. func (m ServerMutation) Tx() (*Tx, error) {
  16528. if _, ok := m.driver.(*txDriver); !ok {
  16529. return nil, errors.New("ent: mutation is not running in a transaction")
  16530. }
  16531. tx := &Tx{config: m.config}
  16532. tx.init()
  16533. return tx, nil
  16534. }
  16535. // SetID sets the value of the id field. Note that this
  16536. // operation is only accepted on creation of Server entities.
  16537. func (m *ServerMutation) SetID(id uint64) {
  16538. m.id = &id
  16539. }
  16540. // ID returns the ID value in the mutation. Note that the ID is only available
  16541. // if it was provided to the builder or after it was returned from the database.
  16542. func (m *ServerMutation) ID() (id uint64, exists bool) {
  16543. if m.id == nil {
  16544. return
  16545. }
  16546. return *m.id, true
  16547. }
  16548. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16549. // That means, if the mutation is applied within a transaction with an isolation level such
  16550. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16551. // or updated by the mutation.
  16552. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  16553. switch {
  16554. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16555. id, exists := m.ID()
  16556. if exists {
  16557. return []uint64{id}, nil
  16558. }
  16559. fallthrough
  16560. case m.op.Is(OpUpdate | OpDelete):
  16561. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  16562. default:
  16563. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16564. }
  16565. }
  16566. // SetCreatedAt sets the "created_at" field.
  16567. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  16568. m.created_at = &t
  16569. }
  16570. // CreatedAt returns the value of the "created_at" field in the mutation.
  16571. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  16572. v := m.created_at
  16573. if v == nil {
  16574. return
  16575. }
  16576. return *v, true
  16577. }
  16578. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  16579. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16581. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16582. if !m.op.Is(OpUpdateOne) {
  16583. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16584. }
  16585. if m.id == nil || m.oldValue == nil {
  16586. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16587. }
  16588. oldValue, err := m.oldValue(ctx)
  16589. if err != nil {
  16590. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16591. }
  16592. return oldValue.CreatedAt, nil
  16593. }
  16594. // ResetCreatedAt resets all changes to the "created_at" field.
  16595. func (m *ServerMutation) ResetCreatedAt() {
  16596. m.created_at = nil
  16597. }
  16598. // SetUpdatedAt sets the "updated_at" field.
  16599. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  16600. m.updated_at = &t
  16601. }
  16602. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16603. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  16604. v := m.updated_at
  16605. if v == nil {
  16606. return
  16607. }
  16608. return *v, true
  16609. }
  16610. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  16611. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16613. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16614. if !m.op.Is(OpUpdateOne) {
  16615. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16616. }
  16617. if m.id == nil || m.oldValue == nil {
  16618. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16619. }
  16620. oldValue, err := m.oldValue(ctx)
  16621. if err != nil {
  16622. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16623. }
  16624. return oldValue.UpdatedAt, nil
  16625. }
  16626. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16627. func (m *ServerMutation) ResetUpdatedAt() {
  16628. m.updated_at = nil
  16629. }
  16630. // SetStatus sets the "status" field.
  16631. func (m *ServerMutation) SetStatus(u uint8) {
  16632. m.status = &u
  16633. m.addstatus = nil
  16634. }
  16635. // Status returns the value of the "status" field in the mutation.
  16636. func (m *ServerMutation) Status() (r uint8, exists bool) {
  16637. v := m.status
  16638. if v == nil {
  16639. return
  16640. }
  16641. return *v, true
  16642. }
  16643. // OldStatus returns the old "status" field's value of the Server entity.
  16644. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16646. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16647. if !m.op.Is(OpUpdateOne) {
  16648. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16649. }
  16650. if m.id == nil || m.oldValue == nil {
  16651. return v, errors.New("OldStatus requires an ID field in the mutation")
  16652. }
  16653. oldValue, err := m.oldValue(ctx)
  16654. if err != nil {
  16655. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16656. }
  16657. return oldValue.Status, nil
  16658. }
  16659. // AddStatus adds u to the "status" field.
  16660. func (m *ServerMutation) AddStatus(u int8) {
  16661. if m.addstatus != nil {
  16662. *m.addstatus += u
  16663. } else {
  16664. m.addstatus = &u
  16665. }
  16666. }
  16667. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16668. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  16669. v := m.addstatus
  16670. if v == nil {
  16671. return
  16672. }
  16673. return *v, true
  16674. }
  16675. // ClearStatus clears the value of the "status" field.
  16676. func (m *ServerMutation) ClearStatus() {
  16677. m.status = nil
  16678. m.addstatus = nil
  16679. m.clearedFields[server.FieldStatus] = struct{}{}
  16680. }
  16681. // StatusCleared returns if the "status" field was cleared in this mutation.
  16682. func (m *ServerMutation) StatusCleared() bool {
  16683. _, ok := m.clearedFields[server.FieldStatus]
  16684. return ok
  16685. }
  16686. // ResetStatus resets all changes to the "status" field.
  16687. func (m *ServerMutation) ResetStatus() {
  16688. m.status = nil
  16689. m.addstatus = nil
  16690. delete(m.clearedFields, server.FieldStatus)
  16691. }
  16692. // SetDeletedAt sets the "deleted_at" field.
  16693. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  16694. m.deleted_at = &t
  16695. }
  16696. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16697. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  16698. v := m.deleted_at
  16699. if v == nil {
  16700. return
  16701. }
  16702. return *v, true
  16703. }
  16704. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  16705. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16707. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16708. if !m.op.Is(OpUpdateOne) {
  16709. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16710. }
  16711. if m.id == nil || m.oldValue == nil {
  16712. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16713. }
  16714. oldValue, err := m.oldValue(ctx)
  16715. if err != nil {
  16716. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16717. }
  16718. return oldValue.DeletedAt, nil
  16719. }
  16720. // ClearDeletedAt clears the value of the "deleted_at" field.
  16721. func (m *ServerMutation) ClearDeletedAt() {
  16722. m.deleted_at = nil
  16723. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  16724. }
  16725. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16726. func (m *ServerMutation) DeletedAtCleared() bool {
  16727. _, ok := m.clearedFields[server.FieldDeletedAt]
  16728. return ok
  16729. }
  16730. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16731. func (m *ServerMutation) ResetDeletedAt() {
  16732. m.deleted_at = nil
  16733. delete(m.clearedFields, server.FieldDeletedAt)
  16734. }
  16735. // SetName sets the "name" field.
  16736. func (m *ServerMutation) SetName(s string) {
  16737. m.name = &s
  16738. }
  16739. // Name returns the value of the "name" field in the mutation.
  16740. func (m *ServerMutation) Name() (r string, exists bool) {
  16741. v := m.name
  16742. if v == nil {
  16743. return
  16744. }
  16745. return *v, true
  16746. }
  16747. // OldName returns the old "name" field's value of the Server entity.
  16748. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16750. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  16751. if !m.op.Is(OpUpdateOne) {
  16752. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16753. }
  16754. if m.id == nil || m.oldValue == nil {
  16755. return v, errors.New("OldName requires an ID field in the mutation")
  16756. }
  16757. oldValue, err := m.oldValue(ctx)
  16758. if err != nil {
  16759. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16760. }
  16761. return oldValue.Name, nil
  16762. }
  16763. // ResetName resets all changes to the "name" field.
  16764. func (m *ServerMutation) ResetName() {
  16765. m.name = nil
  16766. }
  16767. // SetPublicIP sets the "public_ip" field.
  16768. func (m *ServerMutation) SetPublicIP(s string) {
  16769. m.public_ip = &s
  16770. }
  16771. // PublicIP returns the value of the "public_ip" field in the mutation.
  16772. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  16773. v := m.public_ip
  16774. if v == nil {
  16775. return
  16776. }
  16777. return *v, true
  16778. }
  16779. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  16780. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16782. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  16783. if !m.op.Is(OpUpdateOne) {
  16784. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  16785. }
  16786. if m.id == nil || m.oldValue == nil {
  16787. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  16788. }
  16789. oldValue, err := m.oldValue(ctx)
  16790. if err != nil {
  16791. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  16792. }
  16793. return oldValue.PublicIP, nil
  16794. }
  16795. // ResetPublicIP resets all changes to the "public_ip" field.
  16796. func (m *ServerMutation) ResetPublicIP() {
  16797. m.public_ip = nil
  16798. }
  16799. // SetPrivateIP sets the "private_ip" field.
  16800. func (m *ServerMutation) SetPrivateIP(s string) {
  16801. m.private_ip = &s
  16802. }
  16803. // PrivateIP returns the value of the "private_ip" field in the mutation.
  16804. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  16805. v := m.private_ip
  16806. if v == nil {
  16807. return
  16808. }
  16809. return *v, true
  16810. }
  16811. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  16812. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16814. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  16815. if !m.op.Is(OpUpdateOne) {
  16816. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  16817. }
  16818. if m.id == nil || m.oldValue == nil {
  16819. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  16820. }
  16821. oldValue, err := m.oldValue(ctx)
  16822. if err != nil {
  16823. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  16824. }
  16825. return oldValue.PrivateIP, nil
  16826. }
  16827. // ResetPrivateIP resets all changes to the "private_ip" field.
  16828. func (m *ServerMutation) ResetPrivateIP() {
  16829. m.private_ip = nil
  16830. }
  16831. // SetAdminPort sets the "admin_port" field.
  16832. func (m *ServerMutation) SetAdminPort(s string) {
  16833. m.admin_port = &s
  16834. }
  16835. // AdminPort returns the value of the "admin_port" field in the mutation.
  16836. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  16837. v := m.admin_port
  16838. if v == nil {
  16839. return
  16840. }
  16841. return *v, true
  16842. }
  16843. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  16844. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16846. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  16847. if !m.op.Is(OpUpdateOne) {
  16848. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  16849. }
  16850. if m.id == nil || m.oldValue == nil {
  16851. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  16852. }
  16853. oldValue, err := m.oldValue(ctx)
  16854. if err != nil {
  16855. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  16856. }
  16857. return oldValue.AdminPort, nil
  16858. }
  16859. // ResetAdminPort resets all changes to the "admin_port" field.
  16860. func (m *ServerMutation) ResetAdminPort() {
  16861. m.admin_port = nil
  16862. }
  16863. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  16864. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  16865. if m.wxs == nil {
  16866. m.wxs = make(map[uint64]struct{})
  16867. }
  16868. for i := range ids {
  16869. m.wxs[ids[i]] = struct{}{}
  16870. }
  16871. }
  16872. // ClearWxs clears the "wxs" edge to the Wx entity.
  16873. func (m *ServerMutation) ClearWxs() {
  16874. m.clearedwxs = true
  16875. }
  16876. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  16877. func (m *ServerMutation) WxsCleared() bool {
  16878. return m.clearedwxs
  16879. }
  16880. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  16881. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  16882. if m.removedwxs == nil {
  16883. m.removedwxs = make(map[uint64]struct{})
  16884. }
  16885. for i := range ids {
  16886. delete(m.wxs, ids[i])
  16887. m.removedwxs[ids[i]] = struct{}{}
  16888. }
  16889. }
  16890. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  16891. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  16892. for id := range m.removedwxs {
  16893. ids = append(ids, id)
  16894. }
  16895. return
  16896. }
  16897. // WxsIDs returns the "wxs" edge IDs in the mutation.
  16898. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  16899. for id := range m.wxs {
  16900. ids = append(ids, id)
  16901. }
  16902. return
  16903. }
  16904. // ResetWxs resets all changes to the "wxs" edge.
  16905. func (m *ServerMutation) ResetWxs() {
  16906. m.wxs = nil
  16907. m.clearedwxs = false
  16908. m.removedwxs = nil
  16909. }
  16910. // Where appends a list predicates to the ServerMutation builder.
  16911. func (m *ServerMutation) Where(ps ...predicate.Server) {
  16912. m.predicates = append(m.predicates, ps...)
  16913. }
  16914. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  16915. // users can use type-assertion to append predicates that do not depend on any generated package.
  16916. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  16917. p := make([]predicate.Server, len(ps))
  16918. for i := range ps {
  16919. p[i] = ps[i]
  16920. }
  16921. m.Where(p...)
  16922. }
  16923. // Op returns the operation name.
  16924. func (m *ServerMutation) Op() Op {
  16925. return m.op
  16926. }
  16927. // SetOp allows setting the mutation operation.
  16928. func (m *ServerMutation) SetOp(op Op) {
  16929. m.op = op
  16930. }
  16931. // Type returns the node type of this mutation (Server).
  16932. func (m *ServerMutation) Type() string {
  16933. return m.typ
  16934. }
  16935. // Fields returns all fields that were changed during this mutation. Note that in
  16936. // order to get all numeric fields that were incremented/decremented, call
  16937. // AddedFields().
  16938. func (m *ServerMutation) Fields() []string {
  16939. fields := make([]string, 0, 8)
  16940. if m.created_at != nil {
  16941. fields = append(fields, server.FieldCreatedAt)
  16942. }
  16943. if m.updated_at != nil {
  16944. fields = append(fields, server.FieldUpdatedAt)
  16945. }
  16946. if m.status != nil {
  16947. fields = append(fields, server.FieldStatus)
  16948. }
  16949. if m.deleted_at != nil {
  16950. fields = append(fields, server.FieldDeletedAt)
  16951. }
  16952. if m.name != nil {
  16953. fields = append(fields, server.FieldName)
  16954. }
  16955. if m.public_ip != nil {
  16956. fields = append(fields, server.FieldPublicIP)
  16957. }
  16958. if m.private_ip != nil {
  16959. fields = append(fields, server.FieldPrivateIP)
  16960. }
  16961. if m.admin_port != nil {
  16962. fields = append(fields, server.FieldAdminPort)
  16963. }
  16964. return fields
  16965. }
  16966. // Field returns the value of a field with the given name. The second boolean
  16967. // return value indicates that this field was not set, or was not defined in the
  16968. // schema.
  16969. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  16970. switch name {
  16971. case server.FieldCreatedAt:
  16972. return m.CreatedAt()
  16973. case server.FieldUpdatedAt:
  16974. return m.UpdatedAt()
  16975. case server.FieldStatus:
  16976. return m.Status()
  16977. case server.FieldDeletedAt:
  16978. return m.DeletedAt()
  16979. case server.FieldName:
  16980. return m.Name()
  16981. case server.FieldPublicIP:
  16982. return m.PublicIP()
  16983. case server.FieldPrivateIP:
  16984. return m.PrivateIP()
  16985. case server.FieldAdminPort:
  16986. return m.AdminPort()
  16987. }
  16988. return nil, false
  16989. }
  16990. // OldField returns the old value of the field from the database. An error is
  16991. // returned if the mutation operation is not UpdateOne, or the query to the
  16992. // database failed.
  16993. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16994. switch name {
  16995. case server.FieldCreatedAt:
  16996. return m.OldCreatedAt(ctx)
  16997. case server.FieldUpdatedAt:
  16998. return m.OldUpdatedAt(ctx)
  16999. case server.FieldStatus:
  17000. return m.OldStatus(ctx)
  17001. case server.FieldDeletedAt:
  17002. return m.OldDeletedAt(ctx)
  17003. case server.FieldName:
  17004. return m.OldName(ctx)
  17005. case server.FieldPublicIP:
  17006. return m.OldPublicIP(ctx)
  17007. case server.FieldPrivateIP:
  17008. return m.OldPrivateIP(ctx)
  17009. case server.FieldAdminPort:
  17010. return m.OldAdminPort(ctx)
  17011. }
  17012. return nil, fmt.Errorf("unknown Server field %s", name)
  17013. }
  17014. // SetField sets the value of a field with the given name. It returns an error if
  17015. // the field is not defined in the schema, or if the type mismatched the field
  17016. // type.
  17017. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  17018. switch name {
  17019. case server.FieldCreatedAt:
  17020. v, ok := value.(time.Time)
  17021. if !ok {
  17022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17023. }
  17024. m.SetCreatedAt(v)
  17025. return nil
  17026. case server.FieldUpdatedAt:
  17027. v, ok := value.(time.Time)
  17028. if !ok {
  17029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17030. }
  17031. m.SetUpdatedAt(v)
  17032. return nil
  17033. case server.FieldStatus:
  17034. v, ok := value.(uint8)
  17035. if !ok {
  17036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17037. }
  17038. m.SetStatus(v)
  17039. return nil
  17040. case server.FieldDeletedAt:
  17041. v, ok := value.(time.Time)
  17042. if !ok {
  17043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17044. }
  17045. m.SetDeletedAt(v)
  17046. return nil
  17047. case server.FieldName:
  17048. v, ok := value.(string)
  17049. if !ok {
  17050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17051. }
  17052. m.SetName(v)
  17053. return nil
  17054. case server.FieldPublicIP:
  17055. v, ok := value.(string)
  17056. if !ok {
  17057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17058. }
  17059. m.SetPublicIP(v)
  17060. return nil
  17061. case server.FieldPrivateIP:
  17062. v, ok := value.(string)
  17063. if !ok {
  17064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17065. }
  17066. m.SetPrivateIP(v)
  17067. return nil
  17068. case server.FieldAdminPort:
  17069. v, ok := value.(string)
  17070. if !ok {
  17071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17072. }
  17073. m.SetAdminPort(v)
  17074. return nil
  17075. }
  17076. return fmt.Errorf("unknown Server field %s", name)
  17077. }
  17078. // AddedFields returns all numeric fields that were incremented/decremented during
  17079. // this mutation.
  17080. func (m *ServerMutation) AddedFields() []string {
  17081. var fields []string
  17082. if m.addstatus != nil {
  17083. fields = append(fields, server.FieldStatus)
  17084. }
  17085. return fields
  17086. }
  17087. // AddedField returns the numeric value that was incremented/decremented on a field
  17088. // with the given name. The second boolean return value indicates that this field
  17089. // was not set, or was not defined in the schema.
  17090. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  17091. switch name {
  17092. case server.FieldStatus:
  17093. return m.AddedStatus()
  17094. }
  17095. return nil, false
  17096. }
  17097. // AddField adds the value to the field with the given name. It returns an error if
  17098. // the field is not defined in the schema, or if the type mismatched the field
  17099. // type.
  17100. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  17101. switch name {
  17102. case server.FieldStatus:
  17103. v, ok := value.(int8)
  17104. if !ok {
  17105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17106. }
  17107. m.AddStatus(v)
  17108. return nil
  17109. }
  17110. return fmt.Errorf("unknown Server numeric field %s", name)
  17111. }
  17112. // ClearedFields returns all nullable fields that were cleared during this
  17113. // mutation.
  17114. func (m *ServerMutation) ClearedFields() []string {
  17115. var fields []string
  17116. if m.FieldCleared(server.FieldStatus) {
  17117. fields = append(fields, server.FieldStatus)
  17118. }
  17119. if m.FieldCleared(server.FieldDeletedAt) {
  17120. fields = append(fields, server.FieldDeletedAt)
  17121. }
  17122. return fields
  17123. }
  17124. // FieldCleared returns a boolean indicating if a field with the given name was
  17125. // cleared in this mutation.
  17126. func (m *ServerMutation) FieldCleared(name string) bool {
  17127. _, ok := m.clearedFields[name]
  17128. return ok
  17129. }
  17130. // ClearField clears the value of the field with the given name. It returns an
  17131. // error if the field is not defined in the schema.
  17132. func (m *ServerMutation) ClearField(name string) error {
  17133. switch name {
  17134. case server.FieldStatus:
  17135. m.ClearStatus()
  17136. return nil
  17137. case server.FieldDeletedAt:
  17138. m.ClearDeletedAt()
  17139. return nil
  17140. }
  17141. return fmt.Errorf("unknown Server nullable field %s", name)
  17142. }
  17143. // ResetField resets all changes in the mutation for the field with the given name.
  17144. // It returns an error if the field is not defined in the schema.
  17145. func (m *ServerMutation) ResetField(name string) error {
  17146. switch name {
  17147. case server.FieldCreatedAt:
  17148. m.ResetCreatedAt()
  17149. return nil
  17150. case server.FieldUpdatedAt:
  17151. m.ResetUpdatedAt()
  17152. return nil
  17153. case server.FieldStatus:
  17154. m.ResetStatus()
  17155. return nil
  17156. case server.FieldDeletedAt:
  17157. m.ResetDeletedAt()
  17158. return nil
  17159. case server.FieldName:
  17160. m.ResetName()
  17161. return nil
  17162. case server.FieldPublicIP:
  17163. m.ResetPublicIP()
  17164. return nil
  17165. case server.FieldPrivateIP:
  17166. m.ResetPrivateIP()
  17167. return nil
  17168. case server.FieldAdminPort:
  17169. m.ResetAdminPort()
  17170. return nil
  17171. }
  17172. return fmt.Errorf("unknown Server field %s", name)
  17173. }
  17174. // AddedEdges returns all edge names that were set/added in this mutation.
  17175. func (m *ServerMutation) AddedEdges() []string {
  17176. edges := make([]string, 0, 1)
  17177. if m.wxs != nil {
  17178. edges = append(edges, server.EdgeWxs)
  17179. }
  17180. return edges
  17181. }
  17182. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17183. // name in this mutation.
  17184. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  17185. switch name {
  17186. case server.EdgeWxs:
  17187. ids := make([]ent.Value, 0, len(m.wxs))
  17188. for id := range m.wxs {
  17189. ids = append(ids, id)
  17190. }
  17191. return ids
  17192. }
  17193. return nil
  17194. }
  17195. // RemovedEdges returns all edge names that were removed in this mutation.
  17196. func (m *ServerMutation) RemovedEdges() []string {
  17197. edges := make([]string, 0, 1)
  17198. if m.removedwxs != nil {
  17199. edges = append(edges, server.EdgeWxs)
  17200. }
  17201. return edges
  17202. }
  17203. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17204. // the given name in this mutation.
  17205. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  17206. switch name {
  17207. case server.EdgeWxs:
  17208. ids := make([]ent.Value, 0, len(m.removedwxs))
  17209. for id := range m.removedwxs {
  17210. ids = append(ids, id)
  17211. }
  17212. return ids
  17213. }
  17214. return nil
  17215. }
  17216. // ClearedEdges returns all edge names that were cleared in this mutation.
  17217. func (m *ServerMutation) ClearedEdges() []string {
  17218. edges := make([]string, 0, 1)
  17219. if m.clearedwxs {
  17220. edges = append(edges, server.EdgeWxs)
  17221. }
  17222. return edges
  17223. }
  17224. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17225. // was cleared in this mutation.
  17226. func (m *ServerMutation) EdgeCleared(name string) bool {
  17227. switch name {
  17228. case server.EdgeWxs:
  17229. return m.clearedwxs
  17230. }
  17231. return false
  17232. }
  17233. // ClearEdge clears the value of the edge with the given name. It returns an error
  17234. // if that edge is not defined in the schema.
  17235. func (m *ServerMutation) ClearEdge(name string) error {
  17236. switch name {
  17237. }
  17238. return fmt.Errorf("unknown Server unique edge %s", name)
  17239. }
  17240. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17241. // It returns an error if the edge is not defined in the schema.
  17242. func (m *ServerMutation) ResetEdge(name string) error {
  17243. switch name {
  17244. case server.EdgeWxs:
  17245. m.ResetWxs()
  17246. return nil
  17247. }
  17248. return fmt.Errorf("unknown Server edge %s", name)
  17249. }
  17250. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  17251. type SopNodeMutation struct {
  17252. config
  17253. op Op
  17254. typ string
  17255. id *uint64
  17256. created_at *time.Time
  17257. updated_at *time.Time
  17258. status *uint8
  17259. addstatus *int8
  17260. deleted_at *time.Time
  17261. parent_id *uint64
  17262. addparent_id *int64
  17263. name *string
  17264. condition_type *int
  17265. addcondition_type *int
  17266. condition_list *[]string
  17267. appendcondition_list []string
  17268. no_reply_condition *uint64
  17269. addno_reply_condition *int64
  17270. no_reply_unit *string
  17271. action_message *[]custom_types.Action
  17272. appendaction_message []custom_types.Action
  17273. action_label_add *[]uint64
  17274. appendaction_label_add []uint64
  17275. action_label_del *[]uint64
  17276. appendaction_label_del []uint64
  17277. action_forward **custom_types.ActionForward
  17278. clearedFields map[string]struct{}
  17279. sop_stage *uint64
  17280. clearedsop_stage bool
  17281. node_messages map[uint64]struct{}
  17282. removednode_messages map[uint64]struct{}
  17283. clearednode_messages bool
  17284. done bool
  17285. oldValue func(context.Context) (*SopNode, error)
  17286. predicates []predicate.SopNode
  17287. }
  17288. var _ ent.Mutation = (*SopNodeMutation)(nil)
  17289. // sopnodeOption allows management of the mutation configuration using functional options.
  17290. type sopnodeOption func(*SopNodeMutation)
  17291. // newSopNodeMutation creates new mutation for the SopNode entity.
  17292. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  17293. m := &SopNodeMutation{
  17294. config: c,
  17295. op: op,
  17296. typ: TypeSopNode,
  17297. clearedFields: make(map[string]struct{}),
  17298. }
  17299. for _, opt := range opts {
  17300. opt(m)
  17301. }
  17302. return m
  17303. }
  17304. // withSopNodeID sets the ID field of the mutation.
  17305. func withSopNodeID(id uint64) sopnodeOption {
  17306. return func(m *SopNodeMutation) {
  17307. var (
  17308. err error
  17309. once sync.Once
  17310. value *SopNode
  17311. )
  17312. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  17313. once.Do(func() {
  17314. if m.done {
  17315. err = errors.New("querying old values post mutation is not allowed")
  17316. } else {
  17317. value, err = m.Client().SopNode.Get(ctx, id)
  17318. }
  17319. })
  17320. return value, err
  17321. }
  17322. m.id = &id
  17323. }
  17324. }
  17325. // withSopNode sets the old SopNode of the mutation.
  17326. func withSopNode(node *SopNode) sopnodeOption {
  17327. return func(m *SopNodeMutation) {
  17328. m.oldValue = func(context.Context) (*SopNode, error) {
  17329. return node, nil
  17330. }
  17331. m.id = &node.ID
  17332. }
  17333. }
  17334. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17335. // executed in a transaction (ent.Tx), a transactional client is returned.
  17336. func (m SopNodeMutation) Client() *Client {
  17337. client := &Client{config: m.config}
  17338. client.init()
  17339. return client
  17340. }
  17341. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17342. // it returns an error otherwise.
  17343. func (m SopNodeMutation) Tx() (*Tx, error) {
  17344. if _, ok := m.driver.(*txDriver); !ok {
  17345. return nil, errors.New("ent: mutation is not running in a transaction")
  17346. }
  17347. tx := &Tx{config: m.config}
  17348. tx.init()
  17349. return tx, nil
  17350. }
  17351. // SetID sets the value of the id field. Note that this
  17352. // operation is only accepted on creation of SopNode entities.
  17353. func (m *SopNodeMutation) SetID(id uint64) {
  17354. m.id = &id
  17355. }
  17356. // ID returns the ID value in the mutation. Note that the ID is only available
  17357. // if it was provided to the builder or after it was returned from the database.
  17358. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  17359. if m.id == nil {
  17360. return
  17361. }
  17362. return *m.id, true
  17363. }
  17364. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17365. // That means, if the mutation is applied within a transaction with an isolation level such
  17366. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17367. // or updated by the mutation.
  17368. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  17369. switch {
  17370. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17371. id, exists := m.ID()
  17372. if exists {
  17373. return []uint64{id}, nil
  17374. }
  17375. fallthrough
  17376. case m.op.Is(OpUpdate | OpDelete):
  17377. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  17378. default:
  17379. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17380. }
  17381. }
  17382. // SetCreatedAt sets the "created_at" field.
  17383. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  17384. m.created_at = &t
  17385. }
  17386. // CreatedAt returns the value of the "created_at" field in the mutation.
  17387. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  17388. v := m.created_at
  17389. if v == nil {
  17390. return
  17391. }
  17392. return *v, true
  17393. }
  17394. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  17395. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17397. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17398. if !m.op.Is(OpUpdateOne) {
  17399. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17400. }
  17401. if m.id == nil || m.oldValue == nil {
  17402. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17403. }
  17404. oldValue, err := m.oldValue(ctx)
  17405. if err != nil {
  17406. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17407. }
  17408. return oldValue.CreatedAt, nil
  17409. }
  17410. // ResetCreatedAt resets all changes to the "created_at" field.
  17411. func (m *SopNodeMutation) ResetCreatedAt() {
  17412. m.created_at = nil
  17413. }
  17414. // SetUpdatedAt sets the "updated_at" field.
  17415. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  17416. m.updated_at = &t
  17417. }
  17418. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17419. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  17420. v := m.updated_at
  17421. if v == nil {
  17422. return
  17423. }
  17424. return *v, true
  17425. }
  17426. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  17427. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17429. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17430. if !m.op.Is(OpUpdateOne) {
  17431. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17432. }
  17433. if m.id == nil || m.oldValue == nil {
  17434. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17435. }
  17436. oldValue, err := m.oldValue(ctx)
  17437. if err != nil {
  17438. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17439. }
  17440. return oldValue.UpdatedAt, nil
  17441. }
  17442. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17443. func (m *SopNodeMutation) ResetUpdatedAt() {
  17444. m.updated_at = nil
  17445. }
  17446. // SetStatus sets the "status" field.
  17447. func (m *SopNodeMutation) SetStatus(u uint8) {
  17448. m.status = &u
  17449. m.addstatus = nil
  17450. }
  17451. // Status returns the value of the "status" field in the mutation.
  17452. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  17453. v := m.status
  17454. if v == nil {
  17455. return
  17456. }
  17457. return *v, true
  17458. }
  17459. // OldStatus returns the old "status" field's value of the SopNode entity.
  17460. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17462. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17463. if !m.op.Is(OpUpdateOne) {
  17464. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17465. }
  17466. if m.id == nil || m.oldValue == nil {
  17467. return v, errors.New("OldStatus requires an ID field in the mutation")
  17468. }
  17469. oldValue, err := m.oldValue(ctx)
  17470. if err != nil {
  17471. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17472. }
  17473. return oldValue.Status, nil
  17474. }
  17475. // AddStatus adds u to the "status" field.
  17476. func (m *SopNodeMutation) AddStatus(u int8) {
  17477. if m.addstatus != nil {
  17478. *m.addstatus += u
  17479. } else {
  17480. m.addstatus = &u
  17481. }
  17482. }
  17483. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17484. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  17485. v := m.addstatus
  17486. if v == nil {
  17487. return
  17488. }
  17489. return *v, true
  17490. }
  17491. // ClearStatus clears the value of the "status" field.
  17492. func (m *SopNodeMutation) ClearStatus() {
  17493. m.status = nil
  17494. m.addstatus = nil
  17495. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  17496. }
  17497. // StatusCleared returns if the "status" field was cleared in this mutation.
  17498. func (m *SopNodeMutation) StatusCleared() bool {
  17499. _, ok := m.clearedFields[sopnode.FieldStatus]
  17500. return ok
  17501. }
  17502. // ResetStatus resets all changes to the "status" field.
  17503. func (m *SopNodeMutation) ResetStatus() {
  17504. m.status = nil
  17505. m.addstatus = nil
  17506. delete(m.clearedFields, sopnode.FieldStatus)
  17507. }
  17508. // SetDeletedAt sets the "deleted_at" field.
  17509. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  17510. m.deleted_at = &t
  17511. }
  17512. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17513. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  17514. v := m.deleted_at
  17515. if v == nil {
  17516. return
  17517. }
  17518. return *v, true
  17519. }
  17520. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  17521. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17523. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17524. if !m.op.Is(OpUpdateOne) {
  17525. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17526. }
  17527. if m.id == nil || m.oldValue == nil {
  17528. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17529. }
  17530. oldValue, err := m.oldValue(ctx)
  17531. if err != nil {
  17532. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17533. }
  17534. return oldValue.DeletedAt, nil
  17535. }
  17536. // ClearDeletedAt clears the value of the "deleted_at" field.
  17537. func (m *SopNodeMutation) ClearDeletedAt() {
  17538. m.deleted_at = nil
  17539. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  17540. }
  17541. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17542. func (m *SopNodeMutation) DeletedAtCleared() bool {
  17543. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  17544. return ok
  17545. }
  17546. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17547. func (m *SopNodeMutation) ResetDeletedAt() {
  17548. m.deleted_at = nil
  17549. delete(m.clearedFields, sopnode.FieldDeletedAt)
  17550. }
  17551. // SetStageID sets the "stage_id" field.
  17552. func (m *SopNodeMutation) SetStageID(u uint64) {
  17553. m.sop_stage = &u
  17554. }
  17555. // StageID returns the value of the "stage_id" field in the mutation.
  17556. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  17557. v := m.sop_stage
  17558. if v == nil {
  17559. return
  17560. }
  17561. return *v, true
  17562. }
  17563. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  17564. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17566. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  17567. if !m.op.Is(OpUpdateOne) {
  17568. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  17569. }
  17570. if m.id == nil || m.oldValue == nil {
  17571. return v, errors.New("OldStageID requires an ID field in the mutation")
  17572. }
  17573. oldValue, err := m.oldValue(ctx)
  17574. if err != nil {
  17575. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  17576. }
  17577. return oldValue.StageID, nil
  17578. }
  17579. // ResetStageID resets all changes to the "stage_id" field.
  17580. func (m *SopNodeMutation) ResetStageID() {
  17581. m.sop_stage = nil
  17582. }
  17583. // SetParentID sets the "parent_id" field.
  17584. func (m *SopNodeMutation) SetParentID(u uint64) {
  17585. m.parent_id = &u
  17586. m.addparent_id = nil
  17587. }
  17588. // ParentID returns the value of the "parent_id" field in the mutation.
  17589. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  17590. v := m.parent_id
  17591. if v == nil {
  17592. return
  17593. }
  17594. return *v, true
  17595. }
  17596. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  17597. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17599. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  17600. if !m.op.Is(OpUpdateOne) {
  17601. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  17602. }
  17603. if m.id == nil || m.oldValue == nil {
  17604. return v, errors.New("OldParentID requires an ID field in the mutation")
  17605. }
  17606. oldValue, err := m.oldValue(ctx)
  17607. if err != nil {
  17608. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  17609. }
  17610. return oldValue.ParentID, nil
  17611. }
  17612. // AddParentID adds u to the "parent_id" field.
  17613. func (m *SopNodeMutation) AddParentID(u int64) {
  17614. if m.addparent_id != nil {
  17615. *m.addparent_id += u
  17616. } else {
  17617. m.addparent_id = &u
  17618. }
  17619. }
  17620. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  17621. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  17622. v := m.addparent_id
  17623. if v == nil {
  17624. return
  17625. }
  17626. return *v, true
  17627. }
  17628. // ResetParentID resets all changes to the "parent_id" field.
  17629. func (m *SopNodeMutation) ResetParentID() {
  17630. m.parent_id = nil
  17631. m.addparent_id = nil
  17632. }
  17633. // SetName sets the "name" field.
  17634. func (m *SopNodeMutation) SetName(s string) {
  17635. m.name = &s
  17636. }
  17637. // Name returns the value of the "name" field in the mutation.
  17638. func (m *SopNodeMutation) Name() (r string, exists bool) {
  17639. v := m.name
  17640. if v == nil {
  17641. return
  17642. }
  17643. return *v, true
  17644. }
  17645. // OldName returns the old "name" field's value of the SopNode entity.
  17646. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17648. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  17649. if !m.op.Is(OpUpdateOne) {
  17650. return v, errors.New("OldName is only allowed on UpdateOne operations")
  17651. }
  17652. if m.id == nil || m.oldValue == nil {
  17653. return v, errors.New("OldName requires an ID field in the mutation")
  17654. }
  17655. oldValue, err := m.oldValue(ctx)
  17656. if err != nil {
  17657. return v, fmt.Errorf("querying old value for OldName: %w", err)
  17658. }
  17659. return oldValue.Name, nil
  17660. }
  17661. // ResetName resets all changes to the "name" field.
  17662. func (m *SopNodeMutation) ResetName() {
  17663. m.name = nil
  17664. }
  17665. // SetConditionType sets the "condition_type" field.
  17666. func (m *SopNodeMutation) SetConditionType(i int) {
  17667. m.condition_type = &i
  17668. m.addcondition_type = nil
  17669. }
  17670. // ConditionType returns the value of the "condition_type" field in the mutation.
  17671. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  17672. v := m.condition_type
  17673. if v == nil {
  17674. return
  17675. }
  17676. return *v, true
  17677. }
  17678. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  17679. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17681. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  17682. if !m.op.Is(OpUpdateOne) {
  17683. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  17684. }
  17685. if m.id == nil || m.oldValue == nil {
  17686. return v, errors.New("OldConditionType requires an ID field in the mutation")
  17687. }
  17688. oldValue, err := m.oldValue(ctx)
  17689. if err != nil {
  17690. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  17691. }
  17692. return oldValue.ConditionType, nil
  17693. }
  17694. // AddConditionType adds i to the "condition_type" field.
  17695. func (m *SopNodeMutation) AddConditionType(i int) {
  17696. if m.addcondition_type != nil {
  17697. *m.addcondition_type += i
  17698. } else {
  17699. m.addcondition_type = &i
  17700. }
  17701. }
  17702. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  17703. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  17704. v := m.addcondition_type
  17705. if v == nil {
  17706. return
  17707. }
  17708. return *v, true
  17709. }
  17710. // ResetConditionType resets all changes to the "condition_type" field.
  17711. func (m *SopNodeMutation) ResetConditionType() {
  17712. m.condition_type = nil
  17713. m.addcondition_type = nil
  17714. }
  17715. // SetConditionList sets the "condition_list" field.
  17716. func (m *SopNodeMutation) SetConditionList(s []string) {
  17717. m.condition_list = &s
  17718. m.appendcondition_list = nil
  17719. }
  17720. // ConditionList returns the value of the "condition_list" field in the mutation.
  17721. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  17722. v := m.condition_list
  17723. if v == nil {
  17724. return
  17725. }
  17726. return *v, true
  17727. }
  17728. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  17729. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17731. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  17732. if !m.op.Is(OpUpdateOne) {
  17733. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  17734. }
  17735. if m.id == nil || m.oldValue == nil {
  17736. return v, errors.New("OldConditionList requires an ID field in the mutation")
  17737. }
  17738. oldValue, err := m.oldValue(ctx)
  17739. if err != nil {
  17740. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  17741. }
  17742. return oldValue.ConditionList, nil
  17743. }
  17744. // AppendConditionList adds s to the "condition_list" field.
  17745. func (m *SopNodeMutation) AppendConditionList(s []string) {
  17746. m.appendcondition_list = append(m.appendcondition_list, s...)
  17747. }
  17748. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  17749. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  17750. if len(m.appendcondition_list) == 0 {
  17751. return nil, false
  17752. }
  17753. return m.appendcondition_list, true
  17754. }
  17755. // ClearConditionList clears the value of the "condition_list" field.
  17756. func (m *SopNodeMutation) ClearConditionList() {
  17757. m.condition_list = nil
  17758. m.appendcondition_list = nil
  17759. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  17760. }
  17761. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  17762. func (m *SopNodeMutation) ConditionListCleared() bool {
  17763. _, ok := m.clearedFields[sopnode.FieldConditionList]
  17764. return ok
  17765. }
  17766. // ResetConditionList resets all changes to the "condition_list" field.
  17767. func (m *SopNodeMutation) ResetConditionList() {
  17768. m.condition_list = nil
  17769. m.appendcondition_list = nil
  17770. delete(m.clearedFields, sopnode.FieldConditionList)
  17771. }
  17772. // SetNoReplyCondition sets the "no_reply_condition" field.
  17773. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  17774. m.no_reply_condition = &u
  17775. m.addno_reply_condition = nil
  17776. }
  17777. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  17778. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  17779. v := m.no_reply_condition
  17780. if v == nil {
  17781. return
  17782. }
  17783. return *v, true
  17784. }
  17785. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  17786. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17788. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  17789. if !m.op.Is(OpUpdateOne) {
  17790. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  17791. }
  17792. if m.id == nil || m.oldValue == nil {
  17793. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  17794. }
  17795. oldValue, err := m.oldValue(ctx)
  17796. if err != nil {
  17797. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  17798. }
  17799. return oldValue.NoReplyCondition, nil
  17800. }
  17801. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  17802. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  17803. if m.addno_reply_condition != nil {
  17804. *m.addno_reply_condition += u
  17805. } else {
  17806. m.addno_reply_condition = &u
  17807. }
  17808. }
  17809. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  17810. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  17811. v := m.addno_reply_condition
  17812. if v == nil {
  17813. return
  17814. }
  17815. return *v, true
  17816. }
  17817. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  17818. func (m *SopNodeMutation) ResetNoReplyCondition() {
  17819. m.no_reply_condition = nil
  17820. m.addno_reply_condition = nil
  17821. }
  17822. // SetNoReplyUnit sets the "no_reply_unit" field.
  17823. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  17824. m.no_reply_unit = &s
  17825. }
  17826. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  17827. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  17828. v := m.no_reply_unit
  17829. if v == nil {
  17830. return
  17831. }
  17832. return *v, true
  17833. }
  17834. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  17835. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17837. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  17838. if !m.op.Is(OpUpdateOne) {
  17839. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  17840. }
  17841. if m.id == nil || m.oldValue == nil {
  17842. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  17843. }
  17844. oldValue, err := m.oldValue(ctx)
  17845. if err != nil {
  17846. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  17847. }
  17848. return oldValue.NoReplyUnit, nil
  17849. }
  17850. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  17851. func (m *SopNodeMutation) ResetNoReplyUnit() {
  17852. m.no_reply_unit = nil
  17853. }
  17854. // SetActionMessage sets the "action_message" field.
  17855. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  17856. m.action_message = &ct
  17857. m.appendaction_message = nil
  17858. }
  17859. // ActionMessage returns the value of the "action_message" field in the mutation.
  17860. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  17861. v := m.action_message
  17862. if v == nil {
  17863. return
  17864. }
  17865. return *v, true
  17866. }
  17867. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  17868. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17870. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  17871. if !m.op.Is(OpUpdateOne) {
  17872. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  17873. }
  17874. if m.id == nil || m.oldValue == nil {
  17875. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  17876. }
  17877. oldValue, err := m.oldValue(ctx)
  17878. if err != nil {
  17879. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  17880. }
  17881. return oldValue.ActionMessage, nil
  17882. }
  17883. // AppendActionMessage adds ct to the "action_message" field.
  17884. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  17885. m.appendaction_message = append(m.appendaction_message, ct...)
  17886. }
  17887. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  17888. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  17889. if len(m.appendaction_message) == 0 {
  17890. return nil, false
  17891. }
  17892. return m.appendaction_message, true
  17893. }
  17894. // ClearActionMessage clears the value of the "action_message" field.
  17895. func (m *SopNodeMutation) ClearActionMessage() {
  17896. m.action_message = nil
  17897. m.appendaction_message = nil
  17898. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  17899. }
  17900. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  17901. func (m *SopNodeMutation) ActionMessageCleared() bool {
  17902. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  17903. return ok
  17904. }
  17905. // ResetActionMessage resets all changes to the "action_message" field.
  17906. func (m *SopNodeMutation) ResetActionMessage() {
  17907. m.action_message = nil
  17908. m.appendaction_message = nil
  17909. delete(m.clearedFields, sopnode.FieldActionMessage)
  17910. }
  17911. // SetActionLabelAdd sets the "action_label_add" field.
  17912. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  17913. m.action_label_add = &u
  17914. m.appendaction_label_add = nil
  17915. }
  17916. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17917. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17918. v := m.action_label_add
  17919. if v == nil {
  17920. return
  17921. }
  17922. return *v, true
  17923. }
  17924. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  17925. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17927. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17928. if !m.op.Is(OpUpdateOne) {
  17929. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17930. }
  17931. if m.id == nil || m.oldValue == nil {
  17932. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17933. }
  17934. oldValue, err := m.oldValue(ctx)
  17935. if err != nil {
  17936. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17937. }
  17938. return oldValue.ActionLabelAdd, nil
  17939. }
  17940. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17941. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  17942. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17943. }
  17944. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17945. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17946. if len(m.appendaction_label_add) == 0 {
  17947. return nil, false
  17948. }
  17949. return m.appendaction_label_add, true
  17950. }
  17951. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17952. func (m *SopNodeMutation) ClearActionLabelAdd() {
  17953. m.action_label_add = nil
  17954. m.appendaction_label_add = nil
  17955. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  17956. }
  17957. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17958. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  17959. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  17960. return ok
  17961. }
  17962. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17963. func (m *SopNodeMutation) ResetActionLabelAdd() {
  17964. m.action_label_add = nil
  17965. m.appendaction_label_add = nil
  17966. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  17967. }
  17968. // SetActionLabelDel sets the "action_label_del" field.
  17969. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  17970. m.action_label_del = &u
  17971. m.appendaction_label_del = nil
  17972. }
  17973. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  17974. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  17975. v := m.action_label_del
  17976. if v == nil {
  17977. return
  17978. }
  17979. return *v, true
  17980. }
  17981. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  17982. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17984. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  17985. if !m.op.Is(OpUpdateOne) {
  17986. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  17987. }
  17988. if m.id == nil || m.oldValue == nil {
  17989. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  17990. }
  17991. oldValue, err := m.oldValue(ctx)
  17992. if err != nil {
  17993. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  17994. }
  17995. return oldValue.ActionLabelDel, nil
  17996. }
  17997. // AppendActionLabelDel adds u to the "action_label_del" field.
  17998. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  17999. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18000. }
  18001. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18002. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18003. if len(m.appendaction_label_del) == 0 {
  18004. return nil, false
  18005. }
  18006. return m.appendaction_label_del, true
  18007. }
  18008. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18009. func (m *SopNodeMutation) ClearActionLabelDel() {
  18010. m.action_label_del = nil
  18011. m.appendaction_label_del = nil
  18012. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  18013. }
  18014. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18015. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  18016. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  18017. return ok
  18018. }
  18019. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18020. func (m *SopNodeMutation) ResetActionLabelDel() {
  18021. m.action_label_del = nil
  18022. m.appendaction_label_del = nil
  18023. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  18024. }
  18025. // SetActionForward sets the "action_forward" field.
  18026. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  18027. m.action_forward = &ctf
  18028. }
  18029. // ActionForward returns the value of the "action_forward" field in the mutation.
  18030. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  18031. v := m.action_forward
  18032. if v == nil {
  18033. return
  18034. }
  18035. return *v, true
  18036. }
  18037. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  18038. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18040. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  18041. if !m.op.Is(OpUpdateOne) {
  18042. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  18043. }
  18044. if m.id == nil || m.oldValue == nil {
  18045. return v, errors.New("OldActionForward requires an ID field in the mutation")
  18046. }
  18047. oldValue, err := m.oldValue(ctx)
  18048. if err != nil {
  18049. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  18050. }
  18051. return oldValue.ActionForward, nil
  18052. }
  18053. // ClearActionForward clears the value of the "action_forward" field.
  18054. func (m *SopNodeMutation) ClearActionForward() {
  18055. m.action_forward = nil
  18056. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  18057. }
  18058. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  18059. func (m *SopNodeMutation) ActionForwardCleared() bool {
  18060. _, ok := m.clearedFields[sopnode.FieldActionForward]
  18061. return ok
  18062. }
  18063. // ResetActionForward resets all changes to the "action_forward" field.
  18064. func (m *SopNodeMutation) ResetActionForward() {
  18065. m.action_forward = nil
  18066. delete(m.clearedFields, sopnode.FieldActionForward)
  18067. }
  18068. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  18069. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  18070. m.sop_stage = &id
  18071. }
  18072. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  18073. func (m *SopNodeMutation) ClearSopStage() {
  18074. m.clearedsop_stage = true
  18075. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  18076. }
  18077. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  18078. func (m *SopNodeMutation) SopStageCleared() bool {
  18079. return m.clearedsop_stage
  18080. }
  18081. // SopStageID returns the "sop_stage" edge ID in the mutation.
  18082. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  18083. if m.sop_stage != nil {
  18084. return *m.sop_stage, true
  18085. }
  18086. return
  18087. }
  18088. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  18089. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18090. // SopStageID instead. It exists only for internal usage by the builders.
  18091. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  18092. if id := m.sop_stage; id != nil {
  18093. ids = append(ids, *id)
  18094. }
  18095. return
  18096. }
  18097. // ResetSopStage resets all changes to the "sop_stage" edge.
  18098. func (m *SopNodeMutation) ResetSopStage() {
  18099. m.sop_stage = nil
  18100. m.clearedsop_stage = false
  18101. }
  18102. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  18103. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  18104. if m.node_messages == nil {
  18105. m.node_messages = make(map[uint64]struct{})
  18106. }
  18107. for i := range ids {
  18108. m.node_messages[ids[i]] = struct{}{}
  18109. }
  18110. }
  18111. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  18112. func (m *SopNodeMutation) ClearNodeMessages() {
  18113. m.clearednode_messages = true
  18114. }
  18115. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  18116. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  18117. return m.clearednode_messages
  18118. }
  18119. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  18120. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  18121. if m.removednode_messages == nil {
  18122. m.removednode_messages = make(map[uint64]struct{})
  18123. }
  18124. for i := range ids {
  18125. delete(m.node_messages, ids[i])
  18126. m.removednode_messages[ids[i]] = struct{}{}
  18127. }
  18128. }
  18129. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  18130. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  18131. for id := range m.removednode_messages {
  18132. ids = append(ids, id)
  18133. }
  18134. return
  18135. }
  18136. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  18137. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  18138. for id := range m.node_messages {
  18139. ids = append(ids, id)
  18140. }
  18141. return
  18142. }
  18143. // ResetNodeMessages resets all changes to the "node_messages" edge.
  18144. func (m *SopNodeMutation) ResetNodeMessages() {
  18145. m.node_messages = nil
  18146. m.clearednode_messages = false
  18147. m.removednode_messages = nil
  18148. }
  18149. // Where appends a list predicates to the SopNodeMutation builder.
  18150. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  18151. m.predicates = append(m.predicates, ps...)
  18152. }
  18153. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  18154. // users can use type-assertion to append predicates that do not depend on any generated package.
  18155. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  18156. p := make([]predicate.SopNode, len(ps))
  18157. for i := range ps {
  18158. p[i] = ps[i]
  18159. }
  18160. m.Where(p...)
  18161. }
  18162. // Op returns the operation name.
  18163. func (m *SopNodeMutation) Op() Op {
  18164. return m.op
  18165. }
  18166. // SetOp allows setting the mutation operation.
  18167. func (m *SopNodeMutation) SetOp(op Op) {
  18168. m.op = op
  18169. }
  18170. // Type returns the node type of this mutation (SopNode).
  18171. func (m *SopNodeMutation) Type() string {
  18172. return m.typ
  18173. }
  18174. // Fields returns all fields that were changed during this mutation. Note that in
  18175. // order to get all numeric fields that were incremented/decremented, call
  18176. // AddedFields().
  18177. func (m *SopNodeMutation) Fields() []string {
  18178. fields := make([]string, 0, 15)
  18179. if m.created_at != nil {
  18180. fields = append(fields, sopnode.FieldCreatedAt)
  18181. }
  18182. if m.updated_at != nil {
  18183. fields = append(fields, sopnode.FieldUpdatedAt)
  18184. }
  18185. if m.status != nil {
  18186. fields = append(fields, sopnode.FieldStatus)
  18187. }
  18188. if m.deleted_at != nil {
  18189. fields = append(fields, sopnode.FieldDeletedAt)
  18190. }
  18191. if m.sop_stage != nil {
  18192. fields = append(fields, sopnode.FieldStageID)
  18193. }
  18194. if m.parent_id != nil {
  18195. fields = append(fields, sopnode.FieldParentID)
  18196. }
  18197. if m.name != nil {
  18198. fields = append(fields, sopnode.FieldName)
  18199. }
  18200. if m.condition_type != nil {
  18201. fields = append(fields, sopnode.FieldConditionType)
  18202. }
  18203. if m.condition_list != nil {
  18204. fields = append(fields, sopnode.FieldConditionList)
  18205. }
  18206. if m.no_reply_condition != nil {
  18207. fields = append(fields, sopnode.FieldNoReplyCondition)
  18208. }
  18209. if m.no_reply_unit != nil {
  18210. fields = append(fields, sopnode.FieldNoReplyUnit)
  18211. }
  18212. if m.action_message != nil {
  18213. fields = append(fields, sopnode.FieldActionMessage)
  18214. }
  18215. if m.action_label_add != nil {
  18216. fields = append(fields, sopnode.FieldActionLabelAdd)
  18217. }
  18218. if m.action_label_del != nil {
  18219. fields = append(fields, sopnode.FieldActionLabelDel)
  18220. }
  18221. if m.action_forward != nil {
  18222. fields = append(fields, sopnode.FieldActionForward)
  18223. }
  18224. return fields
  18225. }
  18226. // Field returns the value of a field with the given name. The second boolean
  18227. // return value indicates that this field was not set, or was not defined in the
  18228. // schema.
  18229. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  18230. switch name {
  18231. case sopnode.FieldCreatedAt:
  18232. return m.CreatedAt()
  18233. case sopnode.FieldUpdatedAt:
  18234. return m.UpdatedAt()
  18235. case sopnode.FieldStatus:
  18236. return m.Status()
  18237. case sopnode.FieldDeletedAt:
  18238. return m.DeletedAt()
  18239. case sopnode.FieldStageID:
  18240. return m.StageID()
  18241. case sopnode.FieldParentID:
  18242. return m.ParentID()
  18243. case sopnode.FieldName:
  18244. return m.Name()
  18245. case sopnode.FieldConditionType:
  18246. return m.ConditionType()
  18247. case sopnode.FieldConditionList:
  18248. return m.ConditionList()
  18249. case sopnode.FieldNoReplyCondition:
  18250. return m.NoReplyCondition()
  18251. case sopnode.FieldNoReplyUnit:
  18252. return m.NoReplyUnit()
  18253. case sopnode.FieldActionMessage:
  18254. return m.ActionMessage()
  18255. case sopnode.FieldActionLabelAdd:
  18256. return m.ActionLabelAdd()
  18257. case sopnode.FieldActionLabelDel:
  18258. return m.ActionLabelDel()
  18259. case sopnode.FieldActionForward:
  18260. return m.ActionForward()
  18261. }
  18262. return nil, false
  18263. }
  18264. // OldField returns the old value of the field from the database. An error is
  18265. // returned if the mutation operation is not UpdateOne, or the query to the
  18266. // database failed.
  18267. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18268. switch name {
  18269. case sopnode.FieldCreatedAt:
  18270. return m.OldCreatedAt(ctx)
  18271. case sopnode.FieldUpdatedAt:
  18272. return m.OldUpdatedAt(ctx)
  18273. case sopnode.FieldStatus:
  18274. return m.OldStatus(ctx)
  18275. case sopnode.FieldDeletedAt:
  18276. return m.OldDeletedAt(ctx)
  18277. case sopnode.FieldStageID:
  18278. return m.OldStageID(ctx)
  18279. case sopnode.FieldParentID:
  18280. return m.OldParentID(ctx)
  18281. case sopnode.FieldName:
  18282. return m.OldName(ctx)
  18283. case sopnode.FieldConditionType:
  18284. return m.OldConditionType(ctx)
  18285. case sopnode.FieldConditionList:
  18286. return m.OldConditionList(ctx)
  18287. case sopnode.FieldNoReplyCondition:
  18288. return m.OldNoReplyCondition(ctx)
  18289. case sopnode.FieldNoReplyUnit:
  18290. return m.OldNoReplyUnit(ctx)
  18291. case sopnode.FieldActionMessage:
  18292. return m.OldActionMessage(ctx)
  18293. case sopnode.FieldActionLabelAdd:
  18294. return m.OldActionLabelAdd(ctx)
  18295. case sopnode.FieldActionLabelDel:
  18296. return m.OldActionLabelDel(ctx)
  18297. case sopnode.FieldActionForward:
  18298. return m.OldActionForward(ctx)
  18299. }
  18300. return nil, fmt.Errorf("unknown SopNode field %s", name)
  18301. }
  18302. // SetField sets the value of a field with the given name. It returns an error if
  18303. // the field is not defined in the schema, or if the type mismatched the field
  18304. // type.
  18305. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  18306. switch name {
  18307. case sopnode.FieldCreatedAt:
  18308. v, ok := value.(time.Time)
  18309. if !ok {
  18310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18311. }
  18312. m.SetCreatedAt(v)
  18313. return nil
  18314. case sopnode.FieldUpdatedAt:
  18315. v, ok := value.(time.Time)
  18316. if !ok {
  18317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18318. }
  18319. m.SetUpdatedAt(v)
  18320. return nil
  18321. case sopnode.FieldStatus:
  18322. v, ok := value.(uint8)
  18323. if !ok {
  18324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18325. }
  18326. m.SetStatus(v)
  18327. return nil
  18328. case sopnode.FieldDeletedAt:
  18329. v, ok := value.(time.Time)
  18330. if !ok {
  18331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18332. }
  18333. m.SetDeletedAt(v)
  18334. return nil
  18335. case sopnode.FieldStageID:
  18336. v, ok := value.(uint64)
  18337. if !ok {
  18338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18339. }
  18340. m.SetStageID(v)
  18341. return nil
  18342. case sopnode.FieldParentID:
  18343. v, ok := value.(uint64)
  18344. if !ok {
  18345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18346. }
  18347. m.SetParentID(v)
  18348. return nil
  18349. case sopnode.FieldName:
  18350. v, ok := value.(string)
  18351. if !ok {
  18352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18353. }
  18354. m.SetName(v)
  18355. return nil
  18356. case sopnode.FieldConditionType:
  18357. v, ok := value.(int)
  18358. if !ok {
  18359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18360. }
  18361. m.SetConditionType(v)
  18362. return nil
  18363. case sopnode.FieldConditionList:
  18364. v, ok := value.([]string)
  18365. if !ok {
  18366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18367. }
  18368. m.SetConditionList(v)
  18369. return nil
  18370. case sopnode.FieldNoReplyCondition:
  18371. v, ok := value.(uint64)
  18372. if !ok {
  18373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18374. }
  18375. m.SetNoReplyCondition(v)
  18376. return nil
  18377. case sopnode.FieldNoReplyUnit:
  18378. v, ok := value.(string)
  18379. if !ok {
  18380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18381. }
  18382. m.SetNoReplyUnit(v)
  18383. return nil
  18384. case sopnode.FieldActionMessage:
  18385. v, ok := value.([]custom_types.Action)
  18386. if !ok {
  18387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18388. }
  18389. m.SetActionMessage(v)
  18390. return nil
  18391. case sopnode.FieldActionLabelAdd:
  18392. v, ok := value.([]uint64)
  18393. if !ok {
  18394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18395. }
  18396. m.SetActionLabelAdd(v)
  18397. return nil
  18398. case sopnode.FieldActionLabelDel:
  18399. v, ok := value.([]uint64)
  18400. if !ok {
  18401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18402. }
  18403. m.SetActionLabelDel(v)
  18404. return nil
  18405. case sopnode.FieldActionForward:
  18406. v, ok := value.(*custom_types.ActionForward)
  18407. if !ok {
  18408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18409. }
  18410. m.SetActionForward(v)
  18411. return nil
  18412. }
  18413. return fmt.Errorf("unknown SopNode field %s", name)
  18414. }
  18415. // AddedFields returns all numeric fields that were incremented/decremented during
  18416. // this mutation.
  18417. func (m *SopNodeMutation) AddedFields() []string {
  18418. var fields []string
  18419. if m.addstatus != nil {
  18420. fields = append(fields, sopnode.FieldStatus)
  18421. }
  18422. if m.addparent_id != nil {
  18423. fields = append(fields, sopnode.FieldParentID)
  18424. }
  18425. if m.addcondition_type != nil {
  18426. fields = append(fields, sopnode.FieldConditionType)
  18427. }
  18428. if m.addno_reply_condition != nil {
  18429. fields = append(fields, sopnode.FieldNoReplyCondition)
  18430. }
  18431. return fields
  18432. }
  18433. // AddedField returns the numeric value that was incremented/decremented on a field
  18434. // with the given name. The second boolean return value indicates that this field
  18435. // was not set, or was not defined in the schema.
  18436. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  18437. switch name {
  18438. case sopnode.FieldStatus:
  18439. return m.AddedStatus()
  18440. case sopnode.FieldParentID:
  18441. return m.AddedParentID()
  18442. case sopnode.FieldConditionType:
  18443. return m.AddedConditionType()
  18444. case sopnode.FieldNoReplyCondition:
  18445. return m.AddedNoReplyCondition()
  18446. }
  18447. return nil, false
  18448. }
  18449. // AddField adds the value to the field with the given name. It returns an error if
  18450. // the field is not defined in the schema, or if the type mismatched the field
  18451. // type.
  18452. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  18453. switch name {
  18454. case sopnode.FieldStatus:
  18455. v, ok := value.(int8)
  18456. if !ok {
  18457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18458. }
  18459. m.AddStatus(v)
  18460. return nil
  18461. case sopnode.FieldParentID:
  18462. v, ok := value.(int64)
  18463. if !ok {
  18464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18465. }
  18466. m.AddParentID(v)
  18467. return nil
  18468. case sopnode.FieldConditionType:
  18469. v, ok := value.(int)
  18470. if !ok {
  18471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18472. }
  18473. m.AddConditionType(v)
  18474. return nil
  18475. case sopnode.FieldNoReplyCondition:
  18476. v, ok := value.(int64)
  18477. if !ok {
  18478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18479. }
  18480. m.AddNoReplyCondition(v)
  18481. return nil
  18482. }
  18483. return fmt.Errorf("unknown SopNode numeric field %s", name)
  18484. }
  18485. // ClearedFields returns all nullable fields that were cleared during this
  18486. // mutation.
  18487. func (m *SopNodeMutation) ClearedFields() []string {
  18488. var fields []string
  18489. if m.FieldCleared(sopnode.FieldStatus) {
  18490. fields = append(fields, sopnode.FieldStatus)
  18491. }
  18492. if m.FieldCleared(sopnode.FieldDeletedAt) {
  18493. fields = append(fields, sopnode.FieldDeletedAt)
  18494. }
  18495. if m.FieldCleared(sopnode.FieldConditionList) {
  18496. fields = append(fields, sopnode.FieldConditionList)
  18497. }
  18498. if m.FieldCleared(sopnode.FieldActionMessage) {
  18499. fields = append(fields, sopnode.FieldActionMessage)
  18500. }
  18501. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  18502. fields = append(fields, sopnode.FieldActionLabelAdd)
  18503. }
  18504. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  18505. fields = append(fields, sopnode.FieldActionLabelDel)
  18506. }
  18507. if m.FieldCleared(sopnode.FieldActionForward) {
  18508. fields = append(fields, sopnode.FieldActionForward)
  18509. }
  18510. return fields
  18511. }
  18512. // FieldCleared returns a boolean indicating if a field with the given name was
  18513. // cleared in this mutation.
  18514. func (m *SopNodeMutation) FieldCleared(name string) bool {
  18515. _, ok := m.clearedFields[name]
  18516. return ok
  18517. }
  18518. // ClearField clears the value of the field with the given name. It returns an
  18519. // error if the field is not defined in the schema.
  18520. func (m *SopNodeMutation) ClearField(name string) error {
  18521. switch name {
  18522. case sopnode.FieldStatus:
  18523. m.ClearStatus()
  18524. return nil
  18525. case sopnode.FieldDeletedAt:
  18526. m.ClearDeletedAt()
  18527. return nil
  18528. case sopnode.FieldConditionList:
  18529. m.ClearConditionList()
  18530. return nil
  18531. case sopnode.FieldActionMessage:
  18532. m.ClearActionMessage()
  18533. return nil
  18534. case sopnode.FieldActionLabelAdd:
  18535. m.ClearActionLabelAdd()
  18536. return nil
  18537. case sopnode.FieldActionLabelDel:
  18538. m.ClearActionLabelDel()
  18539. return nil
  18540. case sopnode.FieldActionForward:
  18541. m.ClearActionForward()
  18542. return nil
  18543. }
  18544. return fmt.Errorf("unknown SopNode nullable field %s", name)
  18545. }
  18546. // ResetField resets all changes in the mutation for the field with the given name.
  18547. // It returns an error if the field is not defined in the schema.
  18548. func (m *SopNodeMutation) ResetField(name string) error {
  18549. switch name {
  18550. case sopnode.FieldCreatedAt:
  18551. m.ResetCreatedAt()
  18552. return nil
  18553. case sopnode.FieldUpdatedAt:
  18554. m.ResetUpdatedAt()
  18555. return nil
  18556. case sopnode.FieldStatus:
  18557. m.ResetStatus()
  18558. return nil
  18559. case sopnode.FieldDeletedAt:
  18560. m.ResetDeletedAt()
  18561. return nil
  18562. case sopnode.FieldStageID:
  18563. m.ResetStageID()
  18564. return nil
  18565. case sopnode.FieldParentID:
  18566. m.ResetParentID()
  18567. return nil
  18568. case sopnode.FieldName:
  18569. m.ResetName()
  18570. return nil
  18571. case sopnode.FieldConditionType:
  18572. m.ResetConditionType()
  18573. return nil
  18574. case sopnode.FieldConditionList:
  18575. m.ResetConditionList()
  18576. return nil
  18577. case sopnode.FieldNoReplyCondition:
  18578. m.ResetNoReplyCondition()
  18579. return nil
  18580. case sopnode.FieldNoReplyUnit:
  18581. m.ResetNoReplyUnit()
  18582. return nil
  18583. case sopnode.FieldActionMessage:
  18584. m.ResetActionMessage()
  18585. return nil
  18586. case sopnode.FieldActionLabelAdd:
  18587. m.ResetActionLabelAdd()
  18588. return nil
  18589. case sopnode.FieldActionLabelDel:
  18590. m.ResetActionLabelDel()
  18591. return nil
  18592. case sopnode.FieldActionForward:
  18593. m.ResetActionForward()
  18594. return nil
  18595. }
  18596. return fmt.Errorf("unknown SopNode field %s", name)
  18597. }
  18598. // AddedEdges returns all edge names that were set/added in this mutation.
  18599. func (m *SopNodeMutation) AddedEdges() []string {
  18600. edges := make([]string, 0, 2)
  18601. if m.sop_stage != nil {
  18602. edges = append(edges, sopnode.EdgeSopStage)
  18603. }
  18604. if m.node_messages != nil {
  18605. edges = append(edges, sopnode.EdgeNodeMessages)
  18606. }
  18607. return edges
  18608. }
  18609. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18610. // name in this mutation.
  18611. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  18612. switch name {
  18613. case sopnode.EdgeSopStage:
  18614. if id := m.sop_stage; id != nil {
  18615. return []ent.Value{*id}
  18616. }
  18617. case sopnode.EdgeNodeMessages:
  18618. ids := make([]ent.Value, 0, len(m.node_messages))
  18619. for id := range m.node_messages {
  18620. ids = append(ids, id)
  18621. }
  18622. return ids
  18623. }
  18624. return nil
  18625. }
  18626. // RemovedEdges returns all edge names that were removed in this mutation.
  18627. func (m *SopNodeMutation) RemovedEdges() []string {
  18628. edges := make([]string, 0, 2)
  18629. if m.removednode_messages != nil {
  18630. edges = append(edges, sopnode.EdgeNodeMessages)
  18631. }
  18632. return edges
  18633. }
  18634. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18635. // the given name in this mutation.
  18636. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  18637. switch name {
  18638. case sopnode.EdgeNodeMessages:
  18639. ids := make([]ent.Value, 0, len(m.removednode_messages))
  18640. for id := range m.removednode_messages {
  18641. ids = append(ids, id)
  18642. }
  18643. return ids
  18644. }
  18645. return nil
  18646. }
  18647. // ClearedEdges returns all edge names that were cleared in this mutation.
  18648. func (m *SopNodeMutation) ClearedEdges() []string {
  18649. edges := make([]string, 0, 2)
  18650. if m.clearedsop_stage {
  18651. edges = append(edges, sopnode.EdgeSopStage)
  18652. }
  18653. if m.clearednode_messages {
  18654. edges = append(edges, sopnode.EdgeNodeMessages)
  18655. }
  18656. return edges
  18657. }
  18658. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18659. // was cleared in this mutation.
  18660. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  18661. switch name {
  18662. case sopnode.EdgeSopStage:
  18663. return m.clearedsop_stage
  18664. case sopnode.EdgeNodeMessages:
  18665. return m.clearednode_messages
  18666. }
  18667. return false
  18668. }
  18669. // ClearEdge clears the value of the edge with the given name. It returns an error
  18670. // if that edge is not defined in the schema.
  18671. func (m *SopNodeMutation) ClearEdge(name string) error {
  18672. switch name {
  18673. case sopnode.EdgeSopStage:
  18674. m.ClearSopStage()
  18675. return nil
  18676. }
  18677. return fmt.Errorf("unknown SopNode unique edge %s", name)
  18678. }
  18679. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18680. // It returns an error if the edge is not defined in the schema.
  18681. func (m *SopNodeMutation) ResetEdge(name string) error {
  18682. switch name {
  18683. case sopnode.EdgeSopStage:
  18684. m.ResetSopStage()
  18685. return nil
  18686. case sopnode.EdgeNodeMessages:
  18687. m.ResetNodeMessages()
  18688. return nil
  18689. }
  18690. return fmt.Errorf("unknown SopNode edge %s", name)
  18691. }
  18692. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  18693. type SopStageMutation struct {
  18694. config
  18695. op Op
  18696. typ string
  18697. id *uint64
  18698. created_at *time.Time
  18699. updated_at *time.Time
  18700. status *uint8
  18701. addstatus *int8
  18702. deleted_at *time.Time
  18703. name *string
  18704. condition_type *int
  18705. addcondition_type *int
  18706. condition_operator *int
  18707. addcondition_operator *int
  18708. condition_list *[]custom_types.Condition
  18709. appendcondition_list []custom_types.Condition
  18710. action_message *[]custom_types.Action
  18711. appendaction_message []custom_types.Action
  18712. action_label_add *[]uint64
  18713. appendaction_label_add []uint64
  18714. action_label_del *[]uint64
  18715. appendaction_label_del []uint64
  18716. action_forward **custom_types.ActionForward
  18717. index_sort *int
  18718. addindex_sort *int
  18719. clearedFields map[string]struct{}
  18720. sop_task *uint64
  18721. clearedsop_task bool
  18722. stage_nodes map[uint64]struct{}
  18723. removedstage_nodes map[uint64]struct{}
  18724. clearedstage_nodes bool
  18725. stage_messages map[uint64]struct{}
  18726. removedstage_messages map[uint64]struct{}
  18727. clearedstage_messages bool
  18728. done bool
  18729. oldValue func(context.Context) (*SopStage, error)
  18730. predicates []predicate.SopStage
  18731. }
  18732. var _ ent.Mutation = (*SopStageMutation)(nil)
  18733. // sopstageOption allows management of the mutation configuration using functional options.
  18734. type sopstageOption func(*SopStageMutation)
  18735. // newSopStageMutation creates new mutation for the SopStage entity.
  18736. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  18737. m := &SopStageMutation{
  18738. config: c,
  18739. op: op,
  18740. typ: TypeSopStage,
  18741. clearedFields: make(map[string]struct{}),
  18742. }
  18743. for _, opt := range opts {
  18744. opt(m)
  18745. }
  18746. return m
  18747. }
  18748. // withSopStageID sets the ID field of the mutation.
  18749. func withSopStageID(id uint64) sopstageOption {
  18750. return func(m *SopStageMutation) {
  18751. var (
  18752. err error
  18753. once sync.Once
  18754. value *SopStage
  18755. )
  18756. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  18757. once.Do(func() {
  18758. if m.done {
  18759. err = errors.New("querying old values post mutation is not allowed")
  18760. } else {
  18761. value, err = m.Client().SopStage.Get(ctx, id)
  18762. }
  18763. })
  18764. return value, err
  18765. }
  18766. m.id = &id
  18767. }
  18768. }
  18769. // withSopStage sets the old SopStage of the mutation.
  18770. func withSopStage(node *SopStage) sopstageOption {
  18771. return func(m *SopStageMutation) {
  18772. m.oldValue = func(context.Context) (*SopStage, error) {
  18773. return node, nil
  18774. }
  18775. m.id = &node.ID
  18776. }
  18777. }
  18778. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18779. // executed in a transaction (ent.Tx), a transactional client is returned.
  18780. func (m SopStageMutation) Client() *Client {
  18781. client := &Client{config: m.config}
  18782. client.init()
  18783. return client
  18784. }
  18785. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18786. // it returns an error otherwise.
  18787. func (m SopStageMutation) Tx() (*Tx, error) {
  18788. if _, ok := m.driver.(*txDriver); !ok {
  18789. return nil, errors.New("ent: mutation is not running in a transaction")
  18790. }
  18791. tx := &Tx{config: m.config}
  18792. tx.init()
  18793. return tx, nil
  18794. }
  18795. // SetID sets the value of the id field. Note that this
  18796. // operation is only accepted on creation of SopStage entities.
  18797. func (m *SopStageMutation) SetID(id uint64) {
  18798. m.id = &id
  18799. }
  18800. // ID returns the ID value in the mutation. Note that the ID is only available
  18801. // if it was provided to the builder or after it was returned from the database.
  18802. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  18803. if m.id == nil {
  18804. return
  18805. }
  18806. return *m.id, true
  18807. }
  18808. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18809. // That means, if the mutation is applied within a transaction with an isolation level such
  18810. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18811. // or updated by the mutation.
  18812. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  18813. switch {
  18814. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18815. id, exists := m.ID()
  18816. if exists {
  18817. return []uint64{id}, nil
  18818. }
  18819. fallthrough
  18820. case m.op.Is(OpUpdate | OpDelete):
  18821. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  18822. default:
  18823. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18824. }
  18825. }
  18826. // SetCreatedAt sets the "created_at" field.
  18827. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  18828. m.created_at = &t
  18829. }
  18830. // CreatedAt returns the value of the "created_at" field in the mutation.
  18831. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  18832. v := m.created_at
  18833. if v == nil {
  18834. return
  18835. }
  18836. return *v, true
  18837. }
  18838. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  18839. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18841. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18842. if !m.op.Is(OpUpdateOne) {
  18843. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18844. }
  18845. if m.id == nil || m.oldValue == nil {
  18846. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18847. }
  18848. oldValue, err := m.oldValue(ctx)
  18849. if err != nil {
  18850. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18851. }
  18852. return oldValue.CreatedAt, nil
  18853. }
  18854. // ResetCreatedAt resets all changes to the "created_at" field.
  18855. func (m *SopStageMutation) ResetCreatedAt() {
  18856. m.created_at = nil
  18857. }
  18858. // SetUpdatedAt sets the "updated_at" field.
  18859. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  18860. m.updated_at = &t
  18861. }
  18862. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18863. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  18864. v := m.updated_at
  18865. if v == nil {
  18866. return
  18867. }
  18868. return *v, true
  18869. }
  18870. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  18871. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18873. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18874. if !m.op.Is(OpUpdateOne) {
  18875. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18876. }
  18877. if m.id == nil || m.oldValue == nil {
  18878. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18879. }
  18880. oldValue, err := m.oldValue(ctx)
  18881. if err != nil {
  18882. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18883. }
  18884. return oldValue.UpdatedAt, nil
  18885. }
  18886. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18887. func (m *SopStageMutation) ResetUpdatedAt() {
  18888. m.updated_at = nil
  18889. }
  18890. // SetStatus sets the "status" field.
  18891. func (m *SopStageMutation) SetStatus(u uint8) {
  18892. m.status = &u
  18893. m.addstatus = nil
  18894. }
  18895. // Status returns the value of the "status" field in the mutation.
  18896. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  18897. v := m.status
  18898. if v == nil {
  18899. return
  18900. }
  18901. return *v, true
  18902. }
  18903. // OldStatus returns the old "status" field's value of the SopStage entity.
  18904. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18906. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18907. if !m.op.Is(OpUpdateOne) {
  18908. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18909. }
  18910. if m.id == nil || m.oldValue == nil {
  18911. return v, errors.New("OldStatus requires an ID field in the mutation")
  18912. }
  18913. oldValue, err := m.oldValue(ctx)
  18914. if err != nil {
  18915. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18916. }
  18917. return oldValue.Status, nil
  18918. }
  18919. // AddStatus adds u to the "status" field.
  18920. func (m *SopStageMutation) AddStatus(u int8) {
  18921. if m.addstatus != nil {
  18922. *m.addstatus += u
  18923. } else {
  18924. m.addstatus = &u
  18925. }
  18926. }
  18927. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18928. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  18929. v := m.addstatus
  18930. if v == nil {
  18931. return
  18932. }
  18933. return *v, true
  18934. }
  18935. // ClearStatus clears the value of the "status" field.
  18936. func (m *SopStageMutation) ClearStatus() {
  18937. m.status = nil
  18938. m.addstatus = nil
  18939. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  18940. }
  18941. // StatusCleared returns if the "status" field was cleared in this mutation.
  18942. func (m *SopStageMutation) StatusCleared() bool {
  18943. _, ok := m.clearedFields[sopstage.FieldStatus]
  18944. return ok
  18945. }
  18946. // ResetStatus resets all changes to the "status" field.
  18947. func (m *SopStageMutation) ResetStatus() {
  18948. m.status = nil
  18949. m.addstatus = nil
  18950. delete(m.clearedFields, sopstage.FieldStatus)
  18951. }
  18952. // SetDeletedAt sets the "deleted_at" field.
  18953. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  18954. m.deleted_at = &t
  18955. }
  18956. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18957. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  18958. v := m.deleted_at
  18959. if v == nil {
  18960. return
  18961. }
  18962. return *v, true
  18963. }
  18964. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  18965. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18967. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18968. if !m.op.Is(OpUpdateOne) {
  18969. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18970. }
  18971. if m.id == nil || m.oldValue == nil {
  18972. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18973. }
  18974. oldValue, err := m.oldValue(ctx)
  18975. if err != nil {
  18976. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18977. }
  18978. return oldValue.DeletedAt, nil
  18979. }
  18980. // ClearDeletedAt clears the value of the "deleted_at" field.
  18981. func (m *SopStageMutation) ClearDeletedAt() {
  18982. m.deleted_at = nil
  18983. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  18984. }
  18985. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18986. func (m *SopStageMutation) DeletedAtCleared() bool {
  18987. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  18988. return ok
  18989. }
  18990. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18991. func (m *SopStageMutation) ResetDeletedAt() {
  18992. m.deleted_at = nil
  18993. delete(m.clearedFields, sopstage.FieldDeletedAt)
  18994. }
  18995. // SetTaskID sets the "task_id" field.
  18996. func (m *SopStageMutation) SetTaskID(u uint64) {
  18997. m.sop_task = &u
  18998. }
  18999. // TaskID returns the value of the "task_id" field in the mutation.
  19000. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  19001. v := m.sop_task
  19002. if v == nil {
  19003. return
  19004. }
  19005. return *v, true
  19006. }
  19007. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  19008. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19010. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  19011. if !m.op.Is(OpUpdateOne) {
  19012. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  19013. }
  19014. if m.id == nil || m.oldValue == nil {
  19015. return v, errors.New("OldTaskID requires an ID field in the mutation")
  19016. }
  19017. oldValue, err := m.oldValue(ctx)
  19018. if err != nil {
  19019. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  19020. }
  19021. return oldValue.TaskID, nil
  19022. }
  19023. // ResetTaskID resets all changes to the "task_id" field.
  19024. func (m *SopStageMutation) ResetTaskID() {
  19025. m.sop_task = nil
  19026. }
  19027. // SetName sets the "name" field.
  19028. func (m *SopStageMutation) SetName(s string) {
  19029. m.name = &s
  19030. }
  19031. // Name returns the value of the "name" field in the mutation.
  19032. func (m *SopStageMutation) Name() (r string, exists bool) {
  19033. v := m.name
  19034. if v == nil {
  19035. return
  19036. }
  19037. return *v, true
  19038. }
  19039. // OldName returns the old "name" field's value of the SopStage entity.
  19040. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19042. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  19043. if !m.op.Is(OpUpdateOne) {
  19044. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19045. }
  19046. if m.id == nil || m.oldValue == nil {
  19047. return v, errors.New("OldName requires an ID field in the mutation")
  19048. }
  19049. oldValue, err := m.oldValue(ctx)
  19050. if err != nil {
  19051. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19052. }
  19053. return oldValue.Name, nil
  19054. }
  19055. // ResetName resets all changes to the "name" field.
  19056. func (m *SopStageMutation) ResetName() {
  19057. m.name = nil
  19058. }
  19059. // SetConditionType sets the "condition_type" field.
  19060. func (m *SopStageMutation) SetConditionType(i int) {
  19061. m.condition_type = &i
  19062. m.addcondition_type = nil
  19063. }
  19064. // ConditionType returns the value of the "condition_type" field in the mutation.
  19065. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  19066. v := m.condition_type
  19067. if v == nil {
  19068. return
  19069. }
  19070. return *v, true
  19071. }
  19072. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  19073. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19075. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  19076. if !m.op.Is(OpUpdateOne) {
  19077. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  19078. }
  19079. if m.id == nil || m.oldValue == nil {
  19080. return v, errors.New("OldConditionType requires an ID field in the mutation")
  19081. }
  19082. oldValue, err := m.oldValue(ctx)
  19083. if err != nil {
  19084. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  19085. }
  19086. return oldValue.ConditionType, nil
  19087. }
  19088. // AddConditionType adds i to the "condition_type" field.
  19089. func (m *SopStageMutation) AddConditionType(i int) {
  19090. if m.addcondition_type != nil {
  19091. *m.addcondition_type += i
  19092. } else {
  19093. m.addcondition_type = &i
  19094. }
  19095. }
  19096. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  19097. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  19098. v := m.addcondition_type
  19099. if v == nil {
  19100. return
  19101. }
  19102. return *v, true
  19103. }
  19104. // ResetConditionType resets all changes to the "condition_type" field.
  19105. func (m *SopStageMutation) ResetConditionType() {
  19106. m.condition_type = nil
  19107. m.addcondition_type = nil
  19108. }
  19109. // SetConditionOperator sets the "condition_operator" field.
  19110. func (m *SopStageMutation) SetConditionOperator(i int) {
  19111. m.condition_operator = &i
  19112. m.addcondition_operator = nil
  19113. }
  19114. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  19115. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  19116. v := m.condition_operator
  19117. if v == nil {
  19118. return
  19119. }
  19120. return *v, true
  19121. }
  19122. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  19123. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19125. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  19126. if !m.op.Is(OpUpdateOne) {
  19127. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  19128. }
  19129. if m.id == nil || m.oldValue == nil {
  19130. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  19131. }
  19132. oldValue, err := m.oldValue(ctx)
  19133. if err != nil {
  19134. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  19135. }
  19136. return oldValue.ConditionOperator, nil
  19137. }
  19138. // AddConditionOperator adds i to the "condition_operator" field.
  19139. func (m *SopStageMutation) AddConditionOperator(i int) {
  19140. if m.addcondition_operator != nil {
  19141. *m.addcondition_operator += i
  19142. } else {
  19143. m.addcondition_operator = &i
  19144. }
  19145. }
  19146. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  19147. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  19148. v := m.addcondition_operator
  19149. if v == nil {
  19150. return
  19151. }
  19152. return *v, true
  19153. }
  19154. // ResetConditionOperator resets all changes to the "condition_operator" field.
  19155. func (m *SopStageMutation) ResetConditionOperator() {
  19156. m.condition_operator = nil
  19157. m.addcondition_operator = nil
  19158. }
  19159. // SetConditionList sets the "condition_list" field.
  19160. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  19161. m.condition_list = &ct
  19162. m.appendcondition_list = nil
  19163. }
  19164. // ConditionList returns the value of the "condition_list" field in the mutation.
  19165. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  19166. v := m.condition_list
  19167. if v == nil {
  19168. return
  19169. }
  19170. return *v, true
  19171. }
  19172. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  19173. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19175. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  19176. if !m.op.Is(OpUpdateOne) {
  19177. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  19178. }
  19179. if m.id == nil || m.oldValue == nil {
  19180. return v, errors.New("OldConditionList requires an ID field in the mutation")
  19181. }
  19182. oldValue, err := m.oldValue(ctx)
  19183. if err != nil {
  19184. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  19185. }
  19186. return oldValue.ConditionList, nil
  19187. }
  19188. // AppendConditionList adds ct to the "condition_list" field.
  19189. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  19190. m.appendcondition_list = append(m.appendcondition_list, ct...)
  19191. }
  19192. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  19193. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  19194. if len(m.appendcondition_list) == 0 {
  19195. return nil, false
  19196. }
  19197. return m.appendcondition_list, true
  19198. }
  19199. // ResetConditionList resets all changes to the "condition_list" field.
  19200. func (m *SopStageMutation) ResetConditionList() {
  19201. m.condition_list = nil
  19202. m.appendcondition_list = nil
  19203. }
  19204. // SetActionMessage sets the "action_message" field.
  19205. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  19206. m.action_message = &ct
  19207. m.appendaction_message = nil
  19208. }
  19209. // ActionMessage returns the value of the "action_message" field in the mutation.
  19210. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  19211. v := m.action_message
  19212. if v == nil {
  19213. return
  19214. }
  19215. return *v, true
  19216. }
  19217. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  19218. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19220. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  19221. if !m.op.Is(OpUpdateOne) {
  19222. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  19223. }
  19224. if m.id == nil || m.oldValue == nil {
  19225. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  19226. }
  19227. oldValue, err := m.oldValue(ctx)
  19228. if err != nil {
  19229. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  19230. }
  19231. return oldValue.ActionMessage, nil
  19232. }
  19233. // AppendActionMessage adds ct to the "action_message" field.
  19234. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  19235. m.appendaction_message = append(m.appendaction_message, ct...)
  19236. }
  19237. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  19238. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  19239. if len(m.appendaction_message) == 0 {
  19240. return nil, false
  19241. }
  19242. return m.appendaction_message, true
  19243. }
  19244. // ClearActionMessage clears the value of the "action_message" field.
  19245. func (m *SopStageMutation) ClearActionMessage() {
  19246. m.action_message = nil
  19247. m.appendaction_message = nil
  19248. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  19249. }
  19250. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  19251. func (m *SopStageMutation) ActionMessageCleared() bool {
  19252. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  19253. return ok
  19254. }
  19255. // ResetActionMessage resets all changes to the "action_message" field.
  19256. func (m *SopStageMutation) ResetActionMessage() {
  19257. m.action_message = nil
  19258. m.appendaction_message = nil
  19259. delete(m.clearedFields, sopstage.FieldActionMessage)
  19260. }
  19261. // SetActionLabelAdd sets the "action_label_add" field.
  19262. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  19263. m.action_label_add = &u
  19264. m.appendaction_label_add = nil
  19265. }
  19266. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  19267. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  19268. v := m.action_label_add
  19269. if v == nil {
  19270. return
  19271. }
  19272. return *v, true
  19273. }
  19274. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  19275. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19277. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  19278. if !m.op.Is(OpUpdateOne) {
  19279. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  19280. }
  19281. if m.id == nil || m.oldValue == nil {
  19282. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  19283. }
  19284. oldValue, err := m.oldValue(ctx)
  19285. if err != nil {
  19286. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  19287. }
  19288. return oldValue.ActionLabelAdd, nil
  19289. }
  19290. // AppendActionLabelAdd adds u to the "action_label_add" field.
  19291. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  19292. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  19293. }
  19294. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  19295. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  19296. if len(m.appendaction_label_add) == 0 {
  19297. return nil, false
  19298. }
  19299. return m.appendaction_label_add, true
  19300. }
  19301. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  19302. func (m *SopStageMutation) ClearActionLabelAdd() {
  19303. m.action_label_add = nil
  19304. m.appendaction_label_add = nil
  19305. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  19306. }
  19307. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  19308. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  19309. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  19310. return ok
  19311. }
  19312. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  19313. func (m *SopStageMutation) ResetActionLabelAdd() {
  19314. m.action_label_add = nil
  19315. m.appendaction_label_add = nil
  19316. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  19317. }
  19318. // SetActionLabelDel sets the "action_label_del" field.
  19319. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  19320. m.action_label_del = &u
  19321. m.appendaction_label_del = nil
  19322. }
  19323. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  19324. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  19325. v := m.action_label_del
  19326. if v == nil {
  19327. return
  19328. }
  19329. return *v, true
  19330. }
  19331. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  19332. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19334. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  19335. if !m.op.Is(OpUpdateOne) {
  19336. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  19337. }
  19338. if m.id == nil || m.oldValue == nil {
  19339. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  19340. }
  19341. oldValue, err := m.oldValue(ctx)
  19342. if err != nil {
  19343. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  19344. }
  19345. return oldValue.ActionLabelDel, nil
  19346. }
  19347. // AppendActionLabelDel adds u to the "action_label_del" field.
  19348. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  19349. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  19350. }
  19351. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  19352. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  19353. if len(m.appendaction_label_del) == 0 {
  19354. return nil, false
  19355. }
  19356. return m.appendaction_label_del, true
  19357. }
  19358. // ClearActionLabelDel clears the value of the "action_label_del" field.
  19359. func (m *SopStageMutation) ClearActionLabelDel() {
  19360. m.action_label_del = nil
  19361. m.appendaction_label_del = nil
  19362. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  19363. }
  19364. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  19365. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  19366. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  19367. return ok
  19368. }
  19369. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  19370. func (m *SopStageMutation) ResetActionLabelDel() {
  19371. m.action_label_del = nil
  19372. m.appendaction_label_del = nil
  19373. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  19374. }
  19375. // SetActionForward sets the "action_forward" field.
  19376. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  19377. m.action_forward = &ctf
  19378. }
  19379. // ActionForward returns the value of the "action_forward" field in the mutation.
  19380. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  19381. v := m.action_forward
  19382. if v == nil {
  19383. return
  19384. }
  19385. return *v, true
  19386. }
  19387. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  19388. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19390. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  19391. if !m.op.Is(OpUpdateOne) {
  19392. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  19393. }
  19394. if m.id == nil || m.oldValue == nil {
  19395. return v, errors.New("OldActionForward requires an ID field in the mutation")
  19396. }
  19397. oldValue, err := m.oldValue(ctx)
  19398. if err != nil {
  19399. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  19400. }
  19401. return oldValue.ActionForward, nil
  19402. }
  19403. // ClearActionForward clears the value of the "action_forward" field.
  19404. func (m *SopStageMutation) ClearActionForward() {
  19405. m.action_forward = nil
  19406. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  19407. }
  19408. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  19409. func (m *SopStageMutation) ActionForwardCleared() bool {
  19410. _, ok := m.clearedFields[sopstage.FieldActionForward]
  19411. return ok
  19412. }
  19413. // ResetActionForward resets all changes to the "action_forward" field.
  19414. func (m *SopStageMutation) ResetActionForward() {
  19415. m.action_forward = nil
  19416. delete(m.clearedFields, sopstage.FieldActionForward)
  19417. }
  19418. // SetIndexSort sets the "index_sort" field.
  19419. func (m *SopStageMutation) SetIndexSort(i int) {
  19420. m.index_sort = &i
  19421. m.addindex_sort = nil
  19422. }
  19423. // IndexSort returns the value of the "index_sort" field in the mutation.
  19424. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  19425. v := m.index_sort
  19426. if v == nil {
  19427. return
  19428. }
  19429. return *v, true
  19430. }
  19431. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  19432. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19434. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  19435. if !m.op.Is(OpUpdateOne) {
  19436. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  19437. }
  19438. if m.id == nil || m.oldValue == nil {
  19439. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  19440. }
  19441. oldValue, err := m.oldValue(ctx)
  19442. if err != nil {
  19443. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  19444. }
  19445. return oldValue.IndexSort, nil
  19446. }
  19447. // AddIndexSort adds i to the "index_sort" field.
  19448. func (m *SopStageMutation) AddIndexSort(i int) {
  19449. if m.addindex_sort != nil {
  19450. *m.addindex_sort += i
  19451. } else {
  19452. m.addindex_sort = &i
  19453. }
  19454. }
  19455. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  19456. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  19457. v := m.addindex_sort
  19458. if v == nil {
  19459. return
  19460. }
  19461. return *v, true
  19462. }
  19463. // ClearIndexSort clears the value of the "index_sort" field.
  19464. func (m *SopStageMutation) ClearIndexSort() {
  19465. m.index_sort = nil
  19466. m.addindex_sort = nil
  19467. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  19468. }
  19469. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  19470. func (m *SopStageMutation) IndexSortCleared() bool {
  19471. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  19472. return ok
  19473. }
  19474. // ResetIndexSort resets all changes to the "index_sort" field.
  19475. func (m *SopStageMutation) ResetIndexSort() {
  19476. m.index_sort = nil
  19477. m.addindex_sort = nil
  19478. delete(m.clearedFields, sopstage.FieldIndexSort)
  19479. }
  19480. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  19481. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  19482. m.sop_task = &id
  19483. }
  19484. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  19485. func (m *SopStageMutation) ClearSopTask() {
  19486. m.clearedsop_task = true
  19487. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  19488. }
  19489. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  19490. func (m *SopStageMutation) SopTaskCleared() bool {
  19491. return m.clearedsop_task
  19492. }
  19493. // SopTaskID returns the "sop_task" edge ID in the mutation.
  19494. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  19495. if m.sop_task != nil {
  19496. return *m.sop_task, true
  19497. }
  19498. return
  19499. }
  19500. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  19501. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19502. // SopTaskID instead. It exists only for internal usage by the builders.
  19503. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  19504. if id := m.sop_task; id != nil {
  19505. ids = append(ids, *id)
  19506. }
  19507. return
  19508. }
  19509. // ResetSopTask resets all changes to the "sop_task" edge.
  19510. func (m *SopStageMutation) ResetSopTask() {
  19511. m.sop_task = nil
  19512. m.clearedsop_task = false
  19513. }
  19514. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  19515. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  19516. if m.stage_nodes == nil {
  19517. m.stage_nodes = make(map[uint64]struct{})
  19518. }
  19519. for i := range ids {
  19520. m.stage_nodes[ids[i]] = struct{}{}
  19521. }
  19522. }
  19523. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  19524. func (m *SopStageMutation) ClearStageNodes() {
  19525. m.clearedstage_nodes = true
  19526. }
  19527. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  19528. func (m *SopStageMutation) StageNodesCleared() bool {
  19529. return m.clearedstage_nodes
  19530. }
  19531. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  19532. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  19533. if m.removedstage_nodes == nil {
  19534. m.removedstage_nodes = make(map[uint64]struct{})
  19535. }
  19536. for i := range ids {
  19537. delete(m.stage_nodes, ids[i])
  19538. m.removedstage_nodes[ids[i]] = struct{}{}
  19539. }
  19540. }
  19541. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  19542. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  19543. for id := range m.removedstage_nodes {
  19544. ids = append(ids, id)
  19545. }
  19546. return
  19547. }
  19548. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  19549. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  19550. for id := range m.stage_nodes {
  19551. ids = append(ids, id)
  19552. }
  19553. return
  19554. }
  19555. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  19556. func (m *SopStageMutation) ResetStageNodes() {
  19557. m.stage_nodes = nil
  19558. m.clearedstage_nodes = false
  19559. m.removedstage_nodes = nil
  19560. }
  19561. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  19562. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  19563. if m.stage_messages == nil {
  19564. m.stage_messages = make(map[uint64]struct{})
  19565. }
  19566. for i := range ids {
  19567. m.stage_messages[ids[i]] = struct{}{}
  19568. }
  19569. }
  19570. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  19571. func (m *SopStageMutation) ClearStageMessages() {
  19572. m.clearedstage_messages = true
  19573. }
  19574. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  19575. func (m *SopStageMutation) StageMessagesCleared() bool {
  19576. return m.clearedstage_messages
  19577. }
  19578. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  19579. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  19580. if m.removedstage_messages == nil {
  19581. m.removedstage_messages = make(map[uint64]struct{})
  19582. }
  19583. for i := range ids {
  19584. delete(m.stage_messages, ids[i])
  19585. m.removedstage_messages[ids[i]] = struct{}{}
  19586. }
  19587. }
  19588. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  19589. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  19590. for id := range m.removedstage_messages {
  19591. ids = append(ids, id)
  19592. }
  19593. return
  19594. }
  19595. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  19596. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  19597. for id := range m.stage_messages {
  19598. ids = append(ids, id)
  19599. }
  19600. return
  19601. }
  19602. // ResetStageMessages resets all changes to the "stage_messages" edge.
  19603. func (m *SopStageMutation) ResetStageMessages() {
  19604. m.stage_messages = nil
  19605. m.clearedstage_messages = false
  19606. m.removedstage_messages = nil
  19607. }
  19608. // Where appends a list predicates to the SopStageMutation builder.
  19609. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  19610. m.predicates = append(m.predicates, ps...)
  19611. }
  19612. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  19613. // users can use type-assertion to append predicates that do not depend on any generated package.
  19614. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  19615. p := make([]predicate.SopStage, len(ps))
  19616. for i := range ps {
  19617. p[i] = ps[i]
  19618. }
  19619. m.Where(p...)
  19620. }
  19621. // Op returns the operation name.
  19622. func (m *SopStageMutation) Op() Op {
  19623. return m.op
  19624. }
  19625. // SetOp allows setting the mutation operation.
  19626. func (m *SopStageMutation) SetOp(op Op) {
  19627. m.op = op
  19628. }
  19629. // Type returns the node type of this mutation (SopStage).
  19630. func (m *SopStageMutation) Type() string {
  19631. return m.typ
  19632. }
  19633. // Fields returns all fields that were changed during this mutation. Note that in
  19634. // order to get all numeric fields that were incremented/decremented, call
  19635. // AddedFields().
  19636. func (m *SopStageMutation) Fields() []string {
  19637. fields := make([]string, 0, 14)
  19638. if m.created_at != nil {
  19639. fields = append(fields, sopstage.FieldCreatedAt)
  19640. }
  19641. if m.updated_at != nil {
  19642. fields = append(fields, sopstage.FieldUpdatedAt)
  19643. }
  19644. if m.status != nil {
  19645. fields = append(fields, sopstage.FieldStatus)
  19646. }
  19647. if m.deleted_at != nil {
  19648. fields = append(fields, sopstage.FieldDeletedAt)
  19649. }
  19650. if m.sop_task != nil {
  19651. fields = append(fields, sopstage.FieldTaskID)
  19652. }
  19653. if m.name != nil {
  19654. fields = append(fields, sopstage.FieldName)
  19655. }
  19656. if m.condition_type != nil {
  19657. fields = append(fields, sopstage.FieldConditionType)
  19658. }
  19659. if m.condition_operator != nil {
  19660. fields = append(fields, sopstage.FieldConditionOperator)
  19661. }
  19662. if m.condition_list != nil {
  19663. fields = append(fields, sopstage.FieldConditionList)
  19664. }
  19665. if m.action_message != nil {
  19666. fields = append(fields, sopstage.FieldActionMessage)
  19667. }
  19668. if m.action_label_add != nil {
  19669. fields = append(fields, sopstage.FieldActionLabelAdd)
  19670. }
  19671. if m.action_label_del != nil {
  19672. fields = append(fields, sopstage.FieldActionLabelDel)
  19673. }
  19674. if m.action_forward != nil {
  19675. fields = append(fields, sopstage.FieldActionForward)
  19676. }
  19677. if m.index_sort != nil {
  19678. fields = append(fields, sopstage.FieldIndexSort)
  19679. }
  19680. return fields
  19681. }
  19682. // Field returns the value of a field with the given name. The second boolean
  19683. // return value indicates that this field was not set, or was not defined in the
  19684. // schema.
  19685. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  19686. switch name {
  19687. case sopstage.FieldCreatedAt:
  19688. return m.CreatedAt()
  19689. case sopstage.FieldUpdatedAt:
  19690. return m.UpdatedAt()
  19691. case sopstage.FieldStatus:
  19692. return m.Status()
  19693. case sopstage.FieldDeletedAt:
  19694. return m.DeletedAt()
  19695. case sopstage.FieldTaskID:
  19696. return m.TaskID()
  19697. case sopstage.FieldName:
  19698. return m.Name()
  19699. case sopstage.FieldConditionType:
  19700. return m.ConditionType()
  19701. case sopstage.FieldConditionOperator:
  19702. return m.ConditionOperator()
  19703. case sopstage.FieldConditionList:
  19704. return m.ConditionList()
  19705. case sopstage.FieldActionMessage:
  19706. return m.ActionMessage()
  19707. case sopstage.FieldActionLabelAdd:
  19708. return m.ActionLabelAdd()
  19709. case sopstage.FieldActionLabelDel:
  19710. return m.ActionLabelDel()
  19711. case sopstage.FieldActionForward:
  19712. return m.ActionForward()
  19713. case sopstage.FieldIndexSort:
  19714. return m.IndexSort()
  19715. }
  19716. return nil, false
  19717. }
  19718. // OldField returns the old value of the field from the database. An error is
  19719. // returned if the mutation operation is not UpdateOne, or the query to the
  19720. // database failed.
  19721. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19722. switch name {
  19723. case sopstage.FieldCreatedAt:
  19724. return m.OldCreatedAt(ctx)
  19725. case sopstage.FieldUpdatedAt:
  19726. return m.OldUpdatedAt(ctx)
  19727. case sopstage.FieldStatus:
  19728. return m.OldStatus(ctx)
  19729. case sopstage.FieldDeletedAt:
  19730. return m.OldDeletedAt(ctx)
  19731. case sopstage.FieldTaskID:
  19732. return m.OldTaskID(ctx)
  19733. case sopstage.FieldName:
  19734. return m.OldName(ctx)
  19735. case sopstage.FieldConditionType:
  19736. return m.OldConditionType(ctx)
  19737. case sopstage.FieldConditionOperator:
  19738. return m.OldConditionOperator(ctx)
  19739. case sopstage.FieldConditionList:
  19740. return m.OldConditionList(ctx)
  19741. case sopstage.FieldActionMessage:
  19742. return m.OldActionMessage(ctx)
  19743. case sopstage.FieldActionLabelAdd:
  19744. return m.OldActionLabelAdd(ctx)
  19745. case sopstage.FieldActionLabelDel:
  19746. return m.OldActionLabelDel(ctx)
  19747. case sopstage.FieldActionForward:
  19748. return m.OldActionForward(ctx)
  19749. case sopstage.FieldIndexSort:
  19750. return m.OldIndexSort(ctx)
  19751. }
  19752. return nil, fmt.Errorf("unknown SopStage field %s", name)
  19753. }
  19754. // SetField sets the value of a field with the given name. It returns an error if
  19755. // the field is not defined in the schema, or if the type mismatched the field
  19756. // type.
  19757. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  19758. switch name {
  19759. case sopstage.FieldCreatedAt:
  19760. v, ok := value.(time.Time)
  19761. if !ok {
  19762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19763. }
  19764. m.SetCreatedAt(v)
  19765. return nil
  19766. case sopstage.FieldUpdatedAt:
  19767. v, ok := value.(time.Time)
  19768. if !ok {
  19769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19770. }
  19771. m.SetUpdatedAt(v)
  19772. return nil
  19773. case sopstage.FieldStatus:
  19774. v, ok := value.(uint8)
  19775. if !ok {
  19776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19777. }
  19778. m.SetStatus(v)
  19779. return nil
  19780. case sopstage.FieldDeletedAt:
  19781. v, ok := value.(time.Time)
  19782. if !ok {
  19783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19784. }
  19785. m.SetDeletedAt(v)
  19786. return nil
  19787. case sopstage.FieldTaskID:
  19788. v, ok := value.(uint64)
  19789. if !ok {
  19790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19791. }
  19792. m.SetTaskID(v)
  19793. return nil
  19794. case sopstage.FieldName:
  19795. v, ok := value.(string)
  19796. if !ok {
  19797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19798. }
  19799. m.SetName(v)
  19800. return nil
  19801. case sopstage.FieldConditionType:
  19802. v, ok := value.(int)
  19803. if !ok {
  19804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19805. }
  19806. m.SetConditionType(v)
  19807. return nil
  19808. case sopstage.FieldConditionOperator:
  19809. v, ok := value.(int)
  19810. if !ok {
  19811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19812. }
  19813. m.SetConditionOperator(v)
  19814. return nil
  19815. case sopstage.FieldConditionList:
  19816. v, ok := value.([]custom_types.Condition)
  19817. if !ok {
  19818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19819. }
  19820. m.SetConditionList(v)
  19821. return nil
  19822. case sopstage.FieldActionMessage:
  19823. v, ok := value.([]custom_types.Action)
  19824. if !ok {
  19825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19826. }
  19827. m.SetActionMessage(v)
  19828. return nil
  19829. case sopstage.FieldActionLabelAdd:
  19830. v, ok := value.([]uint64)
  19831. if !ok {
  19832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19833. }
  19834. m.SetActionLabelAdd(v)
  19835. return nil
  19836. case sopstage.FieldActionLabelDel:
  19837. v, ok := value.([]uint64)
  19838. if !ok {
  19839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19840. }
  19841. m.SetActionLabelDel(v)
  19842. return nil
  19843. case sopstage.FieldActionForward:
  19844. v, ok := value.(*custom_types.ActionForward)
  19845. if !ok {
  19846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19847. }
  19848. m.SetActionForward(v)
  19849. return nil
  19850. case sopstage.FieldIndexSort:
  19851. v, ok := value.(int)
  19852. if !ok {
  19853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19854. }
  19855. m.SetIndexSort(v)
  19856. return nil
  19857. }
  19858. return fmt.Errorf("unknown SopStage field %s", name)
  19859. }
  19860. // AddedFields returns all numeric fields that were incremented/decremented during
  19861. // this mutation.
  19862. func (m *SopStageMutation) AddedFields() []string {
  19863. var fields []string
  19864. if m.addstatus != nil {
  19865. fields = append(fields, sopstage.FieldStatus)
  19866. }
  19867. if m.addcondition_type != nil {
  19868. fields = append(fields, sopstage.FieldConditionType)
  19869. }
  19870. if m.addcondition_operator != nil {
  19871. fields = append(fields, sopstage.FieldConditionOperator)
  19872. }
  19873. if m.addindex_sort != nil {
  19874. fields = append(fields, sopstage.FieldIndexSort)
  19875. }
  19876. return fields
  19877. }
  19878. // AddedField returns the numeric value that was incremented/decremented on a field
  19879. // with the given name. The second boolean return value indicates that this field
  19880. // was not set, or was not defined in the schema.
  19881. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  19882. switch name {
  19883. case sopstage.FieldStatus:
  19884. return m.AddedStatus()
  19885. case sopstage.FieldConditionType:
  19886. return m.AddedConditionType()
  19887. case sopstage.FieldConditionOperator:
  19888. return m.AddedConditionOperator()
  19889. case sopstage.FieldIndexSort:
  19890. return m.AddedIndexSort()
  19891. }
  19892. return nil, false
  19893. }
  19894. // AddField adds the value to the field with the given name. It returns an error if
  19895. // the field is not defined in the schema, or if the type mismatched the field
  19896. // type.
  19897. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  19898. switch name {
  19899. case sopstage.FieldStatus:
  19900. v, ok := value.(int8)
  19901. if !ok {
  19902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19903. }
  19904. m.AddStatus(v)
  19905. return nil
  19906. case sopstage.FieldConditionType:
  19907. v, ok := value.(int)
  19908. if !ok {
  19909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19910. }
  19911. m.AddConditionType(v)
  19912. return nil
  19913. case sopstage.FieldConditionOperator:
  19914. v, ok := value.(int)
  19915. if !ok {
  19916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19917. }
  19918. m.AddConditionOperator(v)
  19919. return nil
  19920. case sopstage.FieldIndexSort:
  19921. v, ok := value.(int)
  19922. if !ok {
  19923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19924. }
  19925. m.AddIndexSort(v)
  19926. return nil
  19927. }
  19928. return fmt.Errorf("unknown SopStage numeric field %s", name)
  19929. }
  19930. // ClearedFields returns all nullable fields that were cleared during this
  19931. // mutation.
  19932. func (m *SopStageMutation) ClearedFields() []string {
  19933. var fields []string
  19934. if m.FieldCleared(sopstage.FieldStatus) {
  19935. fields = append(fields, sopstage.FieldStatus)
  19936. }
  19937. if m.FieldCleared(sopstage.FieldDeletedAt) {
  19938. fields = append(fields, sopstage.FieldDeletedAt)
  19939. }
  19940. if m.FieldCleared(sopstage.FieldActionMessage) {
  19941. fields = append(fields, sopstage.FieldActionMessage)
  19942. }
  19943. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  19944. fields = append(fields, sopstage.FieldActionLabelAdd)
  19945. }
  19946. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  19947. fields = append(fields, sopstage.FieldActionLabelDel)
  19948. }
  19949. if m.FieldCleared(sopstage.FieldActionForward) {
  19950. fields = append(fields, sopstage.FieldActionForward)
  19951. }
  19952. if m.FieldCleared(sopstage.FieldIndexSort) {
  19953. fields = append(fields, sopstage.FieldIndexSort)
  19954. }
  19955. return fields
  19956. }
  19957. // FieldCleared returns a boolean indicating if a field with the given name was
  19958. // cleared in this mutation.
  19959. func (m *SopStageMutation) FieldCleared(name string) bool {
  19960. _, ok := m.clearedFields[name]
  19961. return ok
  19962. }
  19963. // ClearField clears the value of the field with the given name. It returns an
  19964. // error if the field is not defined in the schema.
  19965. func (m *SopStageMutation) ClearField(name string) error {
  19966. switch name {
  19967. case sopstage.FieldStatus:
  19968. m.ClearStatus()
  19969. return nil
  19970. case sopstage.FieldDeletedAt:
  19971. m.ClearDeletedAt()
  19972. return nil
  19973. case sopstage.FieldActionMessage:
  19974. m.ClearActionMessage()
  19975. return nil
  19976. case sopstage.FieldActionLabelAdd:
  19977. m.ClearActionLabelAdd()
  19978. return nil
  19979. case sopstage.FieldActionLabelDel:
  19980. m.ClearActionLabelDel()
  19981. return nil
  19982. case sopstage.FieldActionForward:
  19983. m.ClearActionForward()
  19984. return nil
  19985. case sopstage.FieldIndexSort:
  19986. m.ClearIndexSort()
  19987. return nil
  19988. }
  19989. return fmt.Errorf("unknown SopStage nullable field %s", name)
  19990. }
  19991. // ResetField resets all changes in the mutation for the field with the given name.
  19992. // It returns an error if the field is not defined in the schema.
  19993. func (m *SopStageMutation) ResetField(name string) error {
  19994. switch name {
  19995. case sopstage.FieldCreatedAt:
  19996. m.ResetCreatedAt()
  19997. return nil
  19998. case sopstage.FieldUpdatedAt:
  19999. m.ResetUpdatedAt()
  20000. return nil
  20001. case sopstage.FieldStatus:
  20002. m.ResetStatus()
  20003. return nil
  20004. case sopstage.FieldDeletedAt:
  20005. m.ResetDeletedAt()
  20006. return nil
  20007. case sopstage.FieldTaskID:
  20008. m.ResetTaskID()
  20009. return nil
  20010. case sopstage.FieldName:
  20011. m.ResetName()
  20012. return nil
  20013. case sopstage.FieldConditionType:
  20014. m.ResetConditionType()
  20015. return nil
  20016. case sopstage.FieldConditionOperator:
  20017. m.ResetConditionOperator()
  20018. return nil
  20019. case sopstage.FieldConditionList:
  20020. m.ResetConditionList()
  20021. return nil
  20022. case sopstage.FieldActionMessage:
  20023. m.ResetActionMessage()
  20024. return nil
  20025. case sopstage.FieldActionLabelAdd:
  20026. m.ResetActionLabelAdd()
  20027. return nil
  20028. case sopstage.FieldActionLabelDel:
  20029. m.ResetActionLabelDel()
  20030. return nil
  20031. case sopstage.FieldActionForward:
  20032. m.ResetActionForward()
  20033. return nil
  20034. case sopstage.FieldIndexSort:
  20035. m.ResetIndexSort()
  20036. return nil
  20037. }
  20038. return fmt.Errorf("unknown SopStage field %s", name)
  20039. }
  20040. // AddedEdges returns all edge names that were set/added in this mutation.
  20041. func (m *SopStageMutation) AddedEdges() []string {
  20042. edges := make([]string, 0, 3)
  20043. if m.sop_task != nil {
  20044. edges = append(edges, sopstage.EdgeSopTask)
  20045. }
  20046. if m.stage_nodes != nil {
  20047. edges = append(edges, sopstage.EdgeStageNodes)
  20048. }
  20049. if m.stage_messages != nil {
  20050. edges = append(edges, sopstage.EdgeStageMessages)
  20051. }
  20052. return edges
  20053. }
  20054. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20055. // name in this mutation.
  20056. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  20057. switch name {
  20058. case sopstage.EdgeSopTask:
  20059. if id := m.sop_task; id != nil {
  20060. return []ent.Value{*id}
  20061. }
  20062. case sopstage.EdgeStageNodes:
  20063. ids := make([]ent.Value, 0, len(m.stage_nodes))
  20064. for id := range m.stage_nodes {
  20065. ids = append(ids, id)
  20066. }
  20067. return ids
  20068. case sopstage.EdgeStageMessages:
  20069. ids := make([]ent.Value, 0, len(m.stage_messages))
  20070. for id := range m.stage_messages {
  20071. ids = append(ids, id)
  20072. }
  20073. return ids
  20074. }
  20075. return nil
  20076. }
  20077. // RemovedEdges returns all edge names that were removed in this mutation.
  20078. func (m *SopStageMutation) RemovedEdges() []string {
  20079. edges := make([]string, 0, 3)
  20080. if m.removedstage_nodes != nil {
  20081. edges = append(edges, sopstage.EdgeStageNodes)
  20082. }
  20083. if m.removedstage_messages != nil {
  20084. edges = append(edges, sopstage.EdgeStageMessages)
  20085. }
  20086. return edges
  20087. }
  20088. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20089. // the given name in this mutation.
  20090. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  20091. switch name {
  20092. case sopstage.EdgeStageNodes:
  20093. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  20094. for id := range m.removedstage_nodes {
  20095. ids = append(ids, id)
  20096. }
  20097. return ids
  20098. case sopstage.EdgeStageMessages:
  20099. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  20100. for id := range m.removedstage_messages {
  20101. ids = append(ids, id)
  20102. }
  20103. return ids
  20104. }
  20105. return nil
  20106. }
  20107. // ClearedEdges returns all edge names that were cleared in this mutation.
  20108. func (m *SopStageMutation) ClearedEdges() []string {
  20109. edges := make([]string, 0, 3)
  20110. if m.clearedsop_task {
  20111. edges = append(edges, sopstage.EdgeSopTask)
  20112. }
  20113. if m.clearedstage_nodes {
  20114. edges = append(edges, sopstage.EdgeStageNodes)
  20115. }
  20116. if m.clearedstage_messages {
  20117. edges = append(edges, sopstage.EdgeStageMessages)
  20118. }
  20119. return edges
  20120. }
  20121. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20122. // was cleared in this mutation.
  20123. func (m *SopStageMutation) EdgeCleared(name string) bool {
  20124. switch name {
  20125. case sopstage.EdgeSopTask:
  20126. return m.clearedsop_task
  20127. case sopstage.EdgeStageNodes:
  20128. return m.clearedstage_nodes
  20129. case sopstage.EdgeStageMessages:
  20130. return m.clearedstage_messages
  20131. }
  20132. return false
  20133. }
  20134. // ClearEdge clears the value of the edge with the given name. It returns an error
  20135. // if that edge is not defined in the schema.
  20136. func (m *SopStageMutation) ClearEdge(name string) error {
  20137. switch name {
  20138. case sopstage.EdgeSopTask:
  20139. m.ClearSopTask()
  20140. return nil
  20141. }
  20142. return fmt.Errorf("unknown SopStage unique edge %s", name)
  20143. }
  20144. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20145. // It returns an error if the edge is not defined in the schema.
  20146. func (m *SopStageMutation) ResetEdge(name string) error {
  20147. switch name {
  20148. case sopstage.EdgeSopTask:
  20149. m.ResetSopTask()
  20150. return nil
  20151. case sopstage.EdgeStageNodes:
  20152. m.ResetStageNodes()
  20153. return nil
  20154. case sopstage.EdgeStageMessages:
  20155. m.ResetStageMessages()
  20156. return nil
  20157. }
  20158. return fmt.Errorf("unknown SopStage edge %s", name)
  20159. }
  20160. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  20161. type SopTaskMutation struct {
  20162. config
  20163. op Op
  20164. typ string
  20165. id *uint64
  20166. created_at *time.Time
  20167. updated_at *time.Time
  20168. status *uint8
  20169. addstatus *int8
  20170. deleted_at *time.Time
  20171. name *string
  20172. bot_wxid_list *[]string
  20173. appendbot_wxid_list []string
  20174. _type *int
  20175. add_type *int
  20176. plan_start_time *time.Time
  20177. plan_end_time *time.Time
  20178. creator_id *string
  20179. organization_id *uint64
  20180. addorganization_id *int64
  20181. token *[]string
  20182. appendtoken []string
  20183. clearedFields map[string]struct{}
  20184. task_stages map[uint64]struct{}
  20185. removedtask_stages map[uint64]struct{}
  20186. clearedtask_stages bool
  20187. done bool
  20188. oldValue func(context.Context) (*SopTask, error)
  20189. predicates []predicate.SopTask
  20190. }
  20191. var _ ent.Mutation = (*SopTaskMutation)(nil)
  20192. // soptaskOption allows management of the mutation configuration using functional options.
  20193. type soptaskOption func(*SopTaskMutation)
  20194. // newSopTaskMutation creates new mutation for the SopTask entity.
  20195. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  20196. m := &SopTaskMutation{
  20197. config: c,
  20198. op: op,
  20199. typ: TypeSopTask,
  20200. clearedFields: make(map[string]struct{}),
  20201. }
  20202. for _, opt := range opts {
  20203. opt(m)
  20204. }
  20205. return m
  20206. }
  20207. // withSopTaskID sets the ID field of the mutation.
  20208. func withSopTaskID(id uint64) soptaskOption {
  20209. return func(m *SopTaskMutation) {
  20210. var (
  20211. err error
  20212. once sync.Once
  20213. value *SopTask
  20214. )
  20215. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  20216. once.Do(func() {
  20217. if m.done {
  20218. err = errors.New("querying old values post mutation is not allowed")
  20219. } else {
  20220. value, err = m.Client().SopTask.Get(ctx, id)
  20221. }
  20222. })
  20223. return value, err
  20224. }
  20225. m.id = &id
  20226. }
  20227. }
  20228. // withSopTask sets the old SopTask of the mutation.
  20229. func withSopTask(node *SopTask) soptaskOption {
  20230. return func(m *SopTaskMutation) {
  20231. m.oldValue = func(context.Context) (*SopTask, error) {
  20232. return node, nil
  20233. }
  20234. m.id = &node.ID
  20235. }
  20236. }
  20237. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20238. // executed in a transaction (ent.Tx), a transactional client is returned.
  20239. func (m SopTaskMutation) Client() *Client {
  20240. client := &Client{config: m.config}
  20241. client.init()
  20242. return client
  20243. }
  20244. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20245. // it returns an error otherwise.
  20246. func (m SopTaskMutation) Tx() (*Tx, error) {
  20247. if _, ok := m.driver.(*txDriver); !ok {
  20248. return nil, errors.New("ent: mutation is not running in a transaction")
  20249. }
  20250. tx := &Tx{config: m.config}
  20251. tx.init()
  20252. return tx, nil
  20253. }
  20254. // SetID sets the value of the id field. Note that this
  20255. // operation is only accepted on creation of SopTask entities.
  20256. func (m *SopTaskMutation) SetID(id uint64) {
  20257. m.id = &id
  20258. }
  20259. // ID returns the ID value in the mutation. Note that the ID is only available
  20260. // if it was provided to the builder or after it was returned from the database.
  20261. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  20262. if m.id == nil {
  20263. return
  20264. }
  20265. return *m.id, true
  20266. }
  20267. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20268. // That means, if the mutation is applied within a transaction with an isolation level such
  20269. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20270. // or updated by the mutation.
  20271. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  20272. switch {
  20273. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20274. id, exists := m.ID()
  20275. if exists {
  20276. return []uint64{id}, nil
  20277. }
  20278. fallthrough
  20279. case m.op.Is(OpUpdate | OpDelete):
  20280. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  20281. default:
  20282. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20283. }
  20284. }
  20285. // SetCreatedAt sets the "created_at" field.
  20286. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  20287. m.created_at = &t
  20288. }
  20289. // CreatedAt returns the value of the "created_at" field in the mutation.
  20290. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  20291. v := m.created_at
  20292. if v == nil {
  20293. return
  20294. }
  20295. return *v, true
  20296. }
  20297. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  20298. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20300. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20301. if !m.op.Is(OpUpdateOne) {
  20302. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20303. }
  20304. if m.id == nil || m.oldValue == nil {
  20305. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20306. }
  20307. oldValue, err := m.oldValue(ctx)
  20308. if err != nil {
  20309. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20310. }
  20311. return oldValue.CreatedAt, nil
  20312. }
  20313. // ResetCreatedAt resets all changes to the "created_at" field.
  20314. func (m *SopTaskMutation) ResetCreatedAt() {
  20315. m.created_at = nil
  20316. }
  20317. // SetUpdatedAt sets the "updated_at" field.
  20318. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  20319. m.updated_at = &t
  20320. }
  20321. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20322. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  20323. v := m.updated_at
  20324. if v == nil {
  20325. return
  20326. }
  20327. return *v, true
  20328. }
  20329. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  20330. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20332. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20333. if !m.op.Is(OpUpdateOne) {
  20334. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20335. }
  20336. if m.id == nil || m.oldValue == nil {
  20337. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20338. }
  20339. oldValue, err := m.oldValue(ctx)
  20340. if err != nil {
  20341. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20342. }
  20343. return oldValue.UpdatedAt, nil
  20344. }
  20345. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20346. func (m *SopTaskMutation) ResetUpdatedAt() {
  20347. m.updated_at = nil
  20348. }
  20349. // SetStatus sets the "status" field.
  20350. func (m *SopTaskMutation) SetStatus(u uint8) {
  20351. m.status = &u
  20352. m.addstatus = nil
  20353. }
  20354. // Status returns the value of the "status" field in the mutation.
  20355. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  20356. v := m.status
  20357. if v == nil {
  20358. return
  20359. }
  20360. return *v, true
  20361. }
  20362. // OldStatus returns the old "status" field's value of the SopTask entity.
  20363. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20365. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20366. if !m.op.Is(OpUpdateOne) {
  20367. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20368. }
  20369. if m.id == nil || m.oldValue == nil {
  20370. return v, errors.New("OldStatus requires an ID field in the mutation")
  20371. }
  20372. oldValue, err := m.oldValue(ctx)
  20373. if err != nil {
  20374. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20375. }
  20376. return oldValue.Status, nil
  20377. }
  20378. // AddStatus adds u to the "status" field.
  20379. func (m *SopTaskMutation) AddStatus(u int8) {
  20380. if m.addstatus != nil {
  20381. *m.addstatus += u
  20382. } else {
  20383. m.addstatus = &u
  20384. }
  20385. }
  20386. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20387. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  20388. v := m.addstatus
  20389. if v == nil {
  20390. return
  20391. }
  20392. return *v, true
  20393. }
  20394. // ClearStatus clears the value of the "status" field.
  20395. func (m *SopTaskMutation) ClearStatus() {
  20396. m.status = nil
  20397. m.addstatus = nil
  20398. m.clearedFields[soptask.FieldStatus] = struct{}{}
  20399. }
  20400. // StatusCleared returns if the "status" field was cleared in this mutation.
  20401. func (m *SopTaskMutation) StatusCleared() bool {
  20402. _, ok := m.clearedFields[soptask.FieldStatus]
  20403. return ok
  20404. }
  20405. // ResetStatus resets all changes to the "status" field.
  20406. func (m *SopTaskMutation) ResetStatus() {
  20407. m.status = nil
  20408. m.addstatus = nil
  20409. delete(m.clearedFields, soptask.FieldStatus)
  20410. }
  20411. // SetDeletedAt sets the "deleted_at" field.
  20412. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  20413. m.deleted_at = &t
  20414. }
  20415. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20416. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  20417. v := m.deleted_at
  20418. if v == nil {
  20419. return
  20420. }
  20421. return *v, true
  20422. }
  20423. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  20424. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20426. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20427. if !m.op.Is(OpUpdateOne) {
  20428. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20429. }
  20430. if m.id == nil || m.oldValue == nil {
  20431. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20432. }
  20433. oldValue, err := m.oldValue(ctx)
  20434. if err != nil {
  20435. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20436. }
  20437. return oldValue.DeletedAt, nil
  20438. }
  20439. // ClearDeletedAt clears the value of the "deleted_at" field.
  20440. func (m *SopTaskMutation) ClearDeletedAt() {
  20441. m.deleted_at = nil
  20442. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  20443. }
  20444. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20445. func (m *SopTaskMutation) DeletedAtCleared() bool {
  20446. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  20447. return ok
  20448. }
  20449. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20450. func (m *SopTaskMutation) ResetDeletedAt() {
  20451. m.deleted_at = nil
  20452. delete(m.clearedFields, soptask.FieldDeletedAt)
  20453. }
  20454. // SetName sets the "name" field.
  20455. func (m *SopTaskMutation) SetName(s string) {
  20456. m.name = &s
  20457. }
  20458. // Name returns the value of the "name" field in the mutation.
  20459. func (m *SopTaskMutation) Name() (r string, exists bool) {
  20460. v := m.name
  20461. if v == nil {
  20462. return
  20463. }
  20464. return *v, true
  20465. }
  20466. // OldName returns the old "name" field's value of the SopTask entity.
  20467. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20469. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  20470. if !m.op.Is(OpUpdateOne) {
  20471. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20472. }
  20473. if m.id == nil || m.oldValue == nil {
  20474. return v, errors.New("OldName requires an ID field in the mutation")
  20475. }
  20476. oldValue, err := m.oldValue(ctx)
  20477. if err != nil {
  20478. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20479. }
  20480. return oldValue.Name, nil
  20481. }
  20482. // ResetName resets all changes to the "name" field.
  20483. func (m *SopTaskMutation) ResetName() {
  20484. m.name = nil
  20485. }
  20486. // SetBotWxidList sets the "bot_wxid_list" field.
  20487. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  20488. m.bot_wxid_list = &s
  20489. m.appendbot_wxid_list = nil
  20490. }
  20491. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  20492. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  20493. v := m.bot_wxid_list
  20494. if v == nil {
  20495. return
  20496. }
  20497. return *v, true
  20498. }
  20499. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  20500. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20502. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  20503. if !m.op.Is(OpUpdateOne) {
  20504. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  20505. }
  20506. if m.id == nil || m.oldValue == nil {
  20507. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  20508. }
  20509. oldValue, err := m.oldValue(ctx)
  20510. if err != nil {
  20511. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  20512. }
  20513. return oldValue.BotWxidList, nil
  20514. }
  20515. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  20516. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  20517. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  20518. }
  20519. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  20520. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  20521. if len(m.appendbot_wxid_list) == 0 {
  20522. return nil, false
  20523. }
  20524. return m.appendbot_wxid_list, true
  20525. }
  20526. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  20527. func (m *SopTaskMutation) ClearBotWxidList() {
  20528. m.bot_wxid_list = nil
  20529. m.appendbot_wxid_list = nil
  20530. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  20531. }
  20532. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  20533. func (m *SopTaskMutation) BotWxidListCleared() bool {
  20534. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  20535. return ok
  20536. }
  20537. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  20538. func (m *SopTaskMutation) ResetBotWxidList() {
  20539. m.bot_wxid_list = nil
  20540. m.appendbot_wxid_list = nil
  20541. delete(m.clearedFields, soptask.FieldBotWxidList)
  20542. }
  20543. // SetType sets the "type" field.
  20544. func (m *SopTaskMutation) SetType(i int) {
  20545. m._type = &i
  20546. m.add_type = nil
  20547. }
  20548. // GetType returns the value of the "type" field in the mutation.
  20549. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  20550. v := m._type
  20551. if v == nil {
  20552. return
  20553. }
  20554. return *v, true
  20555. }
  20556. // OldType returns the old "type" field's value of the SopTask entity.
  20557. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20559. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  20560. if !m.op.Is(OpUpdateOne) {
  20561. return v, errors.New("OldType is only allowed on UpdateOne operations")
  20562. }
  20563. if m.id == nil || m.oldValue == nil {
  20564. return v, errors.New("OldType requires an ID field in the mutation")
  20565. }
  20566. oldValue, err := m.oldValue(ctx)
  20567. if err != nil {
  20568. return v, fmt.Errorf("querying old value for OldType: %w", err)
  20569. }
  20570. return oldValue.Type, nil
  20571. }
  20572. // AddType adds i to the "type" field.
  20573. func (m *SopTaskMutation) AddType(i int) {
  20574. if m.add_type != nil {
  20575. *m.add_type += i
  20576. } else {
  20577. m.add_type = &i
  20578. }
  20579. }
  20580. // AddedType returns the value that was added to the "type" field in this mutation.
  20581. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  20582. v := m.add_type
  20583. if v == nil {
  20584. return
  20585. }
  20586. return *v, true
  20587. }
  20588. // ResetType resets all changes to the "type" field.
  20589. func (m *SopTaskMutation) ResetType() {
  20590. m._type = nil
  20591. m.add_type = nil
  20592. }
  20593. // SetPlanStartTime sets the "plan_start_time" field.
  20594. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  20595. m.plan_start_time = &t
  20596. }
  20597. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  20598. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  20599. v := m.plan_start_time
  20600. if v == nil {
  20601. return
  20602. }
  20603. return *v, true
  20604. }
  20605. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  20606. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20608. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  20609. if !m.op.Is(OpUpdateOne) {
  20610. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  20611. }
  20612. if m.id == nil || m.oldValue == nil {
  20613. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  20614. }
  20615. oldValue, err := m.oldValue(ctx)
  20616. if err != nil {
  20617. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  20618. }
  20619. return oldValue.PlanStartTime, nil
  20620. }
  20621. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  20622. func (m *SopTaskMutation) ClearPlanStartTime() {
  20623. m.plan_start_time = nil
  20624. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  20625. }
  20626. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  20627. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  20628. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  20629. return ok
  20630. }
  20631. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  20632. func (m *SopTaskMutation) ResetPlanStartTime() {
  20633. m.plan_start_time = nil
  20634. delete(m.clearedFields, soptask.FieldPlanStartTime)
  20635. }
  20636. // SetPlanEndTime sets the "plan_end_time" field.
  20637. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  20638. m.plan_end_time = &t
  20639. }
  20640. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  20641. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  20642. v := m.plan_end_time
  20643. if v == nil {
  20644. return
  20645. }
  20646. return *v, true
  20647. }
  20648. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  20649. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20651. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  20652. if !m.op.Is(OpUpdateOne) {
  20653. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  20654. }
  20655. if m.id == nil || m.oldValue == nil {
  20656. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  20657. }
  20658. oldValue, err := m.oldValue(ctx)
  20659. if err != nil {
  20660. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  20661. }
  20662. return oldValue.PlanEndTime, nil
  20663. }
  20664. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  20665. func (m *SopTaskMutation) ClearPlanEndTime() {
  20666. m.plan_end_time = nil
  20667. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  20668. }
  20669. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  20670. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  20671. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  20672. return ok
  20673. }
  20674. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  20675. func (m *SopTaskMutation) ResetPlanEndTime() {
  20676. m.plan_end_time = nil
  20677. delete(m.clearedFields, soptask.FieldPlanEndTime)
  20678. }
  20679. // SetCreatorID sets the "creator_id" field.
  20680. func (m *SopTaskMutation) SetCreatorID(s string) {
  20681. m.creator_id = &s
  20682. }
  20683. // CreatorID returns the value of the "creator_id" field in the mutation.
  20684. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  20685. v := m.creator_id
  20686. if v == nil {
  20687. return
  20688. }
  20689. return *v, true
  20690. }
  20691. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  20692. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20694. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  20695. if !m.op.Is(OpUpdateOne) {
  20696. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  20697. }
  20698. if m.id == nil || m.oldValue == nil {
  20699. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  20700. }
  20701. oldValue, err := m.oldValue(ctx)
  20702. if err != nil {
  20703. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  20704. }
  20705. return oldValue.CreatorID, nil
  20706. }
  20707. // ClearCreatorID clears the value of the "creator_id" field.
  20708. func (m *SopTaskMutation) ClearCreatorID() {
  20709. m.creator_id = nil
  20710. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  20711. }
  20712. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  20713. func (m *SopTaskMutation) CreatorIDCleared() bool {
  20714. _, ok := m.clearedFields[soptask.FieldCreatorID]
  20715. return ok
  20716. }
  20717. // ResetCreatorID resets all changes to the "creator_id" field.
  20718. func (m *SopTaskMutation) ResetCreatorID() {
  20719. m.creator_id = nil
  20720. delete(m.clearedFields, soptask.FieldCreatorID)
  20721. }
  20722. // SetOrganizationID sets the "organization_id" field.
  20723. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  20724. m.organization_id = &u
  20725. m.addorganization_id = nil
  20726. }
  20727. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20728. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  20729. v := m.organization_id
  20730. if v == nil {
  20731. return
  20732. }
  20733. return *v, true
  20734. }
  20735. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  20736. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20738. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20739. if !m.op.Is(OpUpdateOne) {
  20740. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20741. }
  20742. if m.id == nil || m.oldValue == nil {
  20743. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20744. }
  20745. oldValue, err := m.oldValue(ctx)
  20746. if err != nil {
  20747. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20748. }
  20749. return oldValue.OrganizationID, nil
  20750. }
  20751. // AddOrganizationID adds u to the "organization_id" field.
  20752. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  20753. if m.addorganization_id != nil {
  20754. *m.addorganization_id += u
  20755. } else {
  20756. m.addorganization_id = &u
  20757. }
  20758. }
  20759. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20760. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  20761. v := m.addorganization_id
  20762. if v == nil {
  20763. return
  20764. }
  20765. return *v, true
  20766. }
  20767. // ClearOrganizationID clears the value of the "organization_id" field.
  20768. func (m *SopTaskMutation) ClearOrganizationID() {
  20769. m.organization_id = nil
  20770. m.addorganization_id = nil
  20771. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  20772. }
  20773. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20774. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  20775. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  20776. return ok
  20777. }
  20778. // ResetOrganizationID resets all changes to the "organization_id" field.
  20779. func (m *SopTaskMutation) ResetOrganizationID() {
  20780. m.organization_id = nil
  20781. m.addorganization_id = nil
  20782. delete(m.clearedFields, soptask.FieldOrganizationID)
  20783. }
  20784. // SetToken sets the "token" field.
  20785. func (m *SopTaskMutation) SetToken(s []string) {
  20786. m.token = &s
  20787. m.appendtoken = nil
  20788. }
  20789. // Token returns the value of the "token" field in the mutation.
  20790. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  20791. v := m.token
  20792. if v == nil {
  20793. return
  20794. }
  20795. return *v, true
  20796. }
  20797. // OldToken returns the old "token" field's value of the SopTask entity.
  20798. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20800. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  20801. if !m.op.Is(OpUpdateOne) {
  20802. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  20803. }
  20804. if m.id == nil || m.oldValue == nil {
  20805. return v, errors.New("OldToken requires an ID field in the mutation")
  20806. }
  20807. oldValue, err := m.oldValue(ctx)
  20808. if err != nil {
  20809. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  20810. }
  20811. return oldValue.Token, nil
  20812. }
  20813. // AppendToken adds s to the "token" field.
  20814. func (m *SopTaskMutation) AppendToken(s []string) {
  20815. m.appendtoken = append(m.appendtoken, s...)
  20816. }
  20817. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  20818. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  20819. if len(m.appendtoken) == 0 {
  20820. return nil, false
  20821. }
  20822. return m.appendtoken, true
  20823. }
  20824. // ClearToken clears the value of the "token" field.
  20825. func (m *SopTaskMutation) ClearToken() {
  20826. m.token = nil
  20827. m.appendtoken = nil
  20828. m.clearedFields[soptask.FieldToken] = struct{}{}
  20829. }
  20830. // TokenCleared returns if the "token" field was cleared in this mutation.
  20831. func (m *SopTaskMutation) TokenCleared() bool {
  20832. _, ok := m.clearedFields[soptask.FieldToken]
  20833. return ok
  20834. }
  20835. // ResetToken resets all changes to the "token" field.
  20836. func (m *SopTaskMutation) ResetToken() {
  20837. m.token = nil
  20838. m.appendtoken = nil
  20839. delete(m.clearedFields, soptask.FieldToken)
  20840. }
  20841. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  20842. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  20843. if m.task_stages == nil {
  20844. m.task_stages = make(map[uint64]struct{})
  20845. }
  20846. for i := range ids {
  20847. m.task_stages[ids[i]] = struct{}{}
  20848. }
  20849. }
  20850. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  20851. func (m *SopTaskMutation) ClearTaskStages() {
  20852. m.clearedtask_stages = true
  20853. }
  20854. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  20855. func (m *SopTaskMutation) TaskStagesCleared() bool {
  20856. return m.clearedtask_stages
  20857. }
  20858. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  20859. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  20860. if m.removedtask_stages == nil {
  20861. m.removedtask_stages = make(map[uint64]struct{})
  20862. }
  20863. for i := range ids {
  20864. delete(m.task_stages, ids[i])
  20865. m.removedtask_stages[ids[i]] = struct{}{}
  20866. }
  20867. }
  20868. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  20869. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  20870. for id := range m.removedtask_stages {
  20871. ids = append(ids, id)
  20872. }
  20873. return
  20874. }
  20875. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  20876. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  20877. for id := range m.task_stages {
  20878. ids = append(ids, id)
  20879. }
  20880. return
  20881. }
  20882. // ResetTaskStages resets all changes to the "task_stages" edge.
  20883. func (m *SopTaskMutation) ResetTaskStages() {
  20884. m.task_stages = nil
  20885. m.clearedtask_stages = false
  20886. m.removedtask_stages = nil
  20887. }
  20888. // Where appends a list predicates to the SopTaskMutation builder.
  20889. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  20890. m.predicates = append(m.predicates, ps...)
  20891. }
  20892. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  20893. // users can use type-assertion to append predicates that do not depend on any generated package.
  20894. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  20895. p := make([]predicate.SopTask, len(ps))
  20896. for i := range ps {
  20897. p[i] = ps[i]
  20898. }
  20899. m.Where(p...)
  20900. }
  20901. // Op returns the operation name.
  20902. func (m *SopTaskMutation) Op() Op {
  20903. return m.op
  20904. }
  20905. // SetOp allows setting the mutation operation.
  20906. func (m *SopTaskMutation) SetOp(op Op) {
  20907. m.op = op
  20908. }
  20909. // Type returns the node type of this mutation (SopTask).
  20910. func (m *SopTaskMutation) Type() string {
  20911. return m.typ
  20912. }
  20913. // Fields returns all fields that were changed during this mutation. Note that in
  20914. // order to get all numeric fields that were incremented/decremented, call
  20915. // AddedFields().
  20916. func (m *SopTaskMutation) Fields() []string {
  20917. fields := make([]string, 0, 12)
  20918. if m.created_at != nil {
  20919. fields = append(fields, soptask.FieldCreatedAt)
  20920. }
  20921. if m.updated_at != nil {
  20922. fields = append(fields, soptask.FieldUpdatedAt)
  20923. }
  20924. if m.status != nil {
  20925. fields = append(fields, soptask.FieldStatus)
  20926. }
  20927. if m.deleted_at != nil {
  20928. fields = append(fields, soptask.FieldDeletedAt)
  20929. }
  20930. if m.name != nil {
  20931. fields = append(fields, soptask.FieldName)
  20932. }
  20933. if m.bot_wxid_list != nil {
  20934. fields = append(fields, soptask.FieldBotWxidList)
  20935. }
  20936. if m._type != nil {
  20937. fields = append(fields, soptask.FieldType)
  20938. }
  20939. if m.plan_start_time != nil {
  20940. fields = append(fields, soptask.FieldPlanStartTime)
  20941. }
  20942. if m.plan_end_time != nil {
  20943. fields = append(fields, soptask.FieldPlanEndTime)
  20944. }
  20945. if m.creator_id != nil {
  20946. fields = append(fields, soptask.FieldCreatorID)
  20947. }
  20948. if m.organization_id != nil {
  20949. fields = append(fields, soptask.FieldOrganizationID)
  20950. }
  20951. if m.token != nil {
  20952. fields = append(fields, soptask.FieldToken)
  20953. }
  20954. return fields
  20955. }
  20956. // Field returns the value of a field with the given name. The second boolean
  20957. // return value indicates that this field was not set, or was not defined in the
  20958. // schema.
  20959. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  20960. switch name {
  20961. case soptask.FieldCreatedAt:
  20962. return m.CreatedAt()
  20963. case soptask.FieldUpdatedAt:
  20964. return m.UpdatedAt()
  20965. case soptask.FieldStatus:
  20966. return m.Status()
  20967. case soptask.FieldDeletedAt:
  20968. return m.DeletedAt()
  20969. case soptask.FieldName:
  20970. return m.Name()
  20971. case soptask.FieldBotWxidList:
  20972. return m.BotWxidList()
  20973. case soptask.FieldType:
  20974. return m.GetType()
  20975. case soptask.FieldPlanStartTime:
  20976. return m.PlanStartTime()
  20977. case soptask.FieldPlanEndTime:
  20978. return m.PlanEndTime()
  20979. case soptask.FieldCreatorID:
  20980. return m.CreatorID()
  20981. case soptask.FieldOrganizationID:
  20982. return m.OrganizationID()
  20983. case soptask.FieldToken:
  20984. return m.Token()
  20985. }
  20986. return nil, false
  20987. }
  20988. // OldField returns the old value of the field from the database. An error is
  20989. // returned if the mutation operation is not UpdateOne, or the query to the
  20990. // database failed.
  20991. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20992. switch name {
  20993. case soptask.FieldCreatedAt:
  20994. return m.OldCreatedAt(ctx)
  20995. case soptask.FieldUpdatedAt:
  20996. return m.OldUpdatedAt(ctx)
  20997. case soptask.FieldStatus:
  20998. return m.OldStatus(ctx)
  20999. case soptask.FieldDeletedAt:
  21000. return m.OldDeletedAt(ctx)
  21001. case soptask.FieldName:
  21002. return m.OldName(ctx)
  21003. case soptask.FieldBotWxidList:
  21004. return m.OldBotWxidList(ctx)
  21005. case soptask.FieldType:
  21006. return m.OldType(ctx)
  21007. case soptask.FieldPlanStartTime:
  21008. return m.OldPlanStartTime(ctx)
  21009. case soptask.FieldPlanEndTime:
  21010. return m.OldPlanEndTime(ctx)
  21011. case soptask.FieldCreatorID:
  21012. return m.OldCreatorID(ctx)
  21013. case soptask.FieldOrganizationID:
  21014. return m.OldOrganizationID(ctx)
  21015. case soptask.FieldToken:
  21016. return m.OldToken(ctx)
  21017. }
  21018. return nil, fmt.Errorf("unknown SopTask field %s", name)
  21019. }
  21020. // SetField sets the value of a field with the given name. It returns an error if
  21021. // the field is not defined in the schema, or if the type mismatched the field
  21022. // type.
  21023. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  21024. switch name {
  21025. case soptask.FieldCreatedAt:
  21026. v, ok := value.(time.Time)
  21027. if !ok {
  21028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21029. }
  21030. m.SetCreatedAt(v)
  21031. return nil
  21032. case soptask.FieldUpdatedAt:
  21033. v, ok := value.(time.Time)
  21034. if !ok {
  21035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21036. }
  21037. m.SetUpdatedAt(v)
  21038. return nil
  21039. case soptask.FieldStatus:
  21040. v, ok := value.(uint8)
  21041. if !ok {
  21042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21043. }
  21044. m.SetStatus(v)
  21045. return nil
  21046. case soptask.FieldDeletedAt:
  21047. v, ok := value.(time.Time)
  21048. if !ok {
  21049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21050. }
  21051. m.SetDeletedAt(v)
  21052. return nil
  21053. case soptask.FieldName:
  21054. v, ok := value.(string)
  21055. if !ok {
  21056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21057. }
  21058. m.SetName(v)
  21059. return nil
  21060. case soptask.FieldBotWxidList:
  21061. v, ok := value.([]string)
  21062. if !ok {
  21063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21064. }
  21065. m.SetBotWxidList(v)
  21066. return nil
  21067. case soptask.FieldType:
  21068. v, ok := value.(int)
  21069. if !ok {
  21070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21071. }
  21072. m.SetType(v)
  21073. return nil
  21074. case soptask.FieldPlanStartTime:
  21075. v, ok := value.(time.Time)
  21076. if !ok {
  21077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21078. }
  21079. m.SetPlanStartTime(v)
  21080. return nil
  21081. case soptask.FieldPlanEndTime:
  21082. v, ok := value.(time.Time)
  21083. if !ok {
  21084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21085. }
  21086. m.SetPlanEndTime(v)
  21087. return nil
  21088. case soptask.FieldCreatorID:
  21089. v, ok := value.(string)
  21090. if !ok {
  21091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21092. }
  21093. m.SetCreatorID(v)
  21094. return nil
  21095. case soptask.FieldOrganizationID:
  21096. v, ok := value.(uint64)
  21097. if !ok {
  21098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21099. }
  21100. m.SetOrganizationID(v)
  21101. return nil
  21102. case soptask.FieldToken:
  21103. v, ok := value.([]string)
  21104. if !ok {
  21105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21106. }
  21107. m.SetToken(v)
  21108. return nil
  21109. }
  21110. return fmt.Errorf("unknown SopTask field %s", name)
  21111. }
  21112. // AddedFields returns all numeric fields that were incremented/decremented during
  21113. // this mutation.
  21114. func (m *SopTaskMutation) AddedFields() []string {
  21115. var fields []string
  21116. if m.addstatus != nil {
  21117. fields = append(fields, soptask.FieldStatus)
  21118. }
  21119. if m.add_type != nil {
  21120. fields = append(fields, soptask.FieldType)
  21121. }
  21122. if m.addorganization_id != nil {
  21123. fields = append(fields, soptask.FieldOrganizationID)
  21124. }
  21125. return fields
  21126. }
  21127. // AddedField returns the numeric value that was incremented/decremented on a field
  21128. // with the given name. The second boolean return value indicates that this field
  21129. // was not set, or was not defined in the schema.
  21130. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  21131. switch name {
  21132. case soptask.FieldStatus:
  21133. return m.AddedStatus()
  21134. case soptask.FieldType:
  21135. return m.AddedType()
  21136. case soptask.FieldOrganizationID:
  21137. return m.AddedOrganizationID()
  21138. }
  21139. return nil, false
  21140. }
  21141. // AddField adds the value to the field with the given name. It returns an error if
  21142. // the field is not defined in the schema, or if the type mismatched the field
  21143. // type.
  21144. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  21145. switch name {
  21146. case soptask.FieldStatus:
  21147. v, ok := value.(int8)
  21148. if !ok {
  21149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21150. }
  21151. m.AddStatus(v)
  21152. return nil
  21153. case soptask.FieldType:
  21154. v, ok := value.(int)
  21155. if !ok {
  21156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21157. }
  21158. m.AddType(v)
  21159. return nil
  21160. case soptask.FieldOrganizationID:
  21161. v, ok := value.(int64)
  21162. if !ok {
  21163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21164. }
  21165. m.AddOrganizationID(v)
  21166. return nil
  21167. }
  21168. return fmt.Errorf("unknown SopTask numeric field %s", name)
  21169. }
  21170. // ClearedFields returns all nullable fields that were cleared during this
  21171. // mutation.
  21172. func (m *SopTaskMutation) ClearedFields() []string {
  21173. var fields []string
  21174. if m.FieldCleared(soptask.FieldStatus) {
  21175. fields = append(fields, soptask.FieldStatus)
  21176. }
  21177. if m.FieldCleared(soptask.FieldDeletedAt) {
  21178. fields = append(fields, soptask.FieldDeletedAt)
  21179. }
  21180. if m.FieldCleared(soptask.FieldBotWxidList) {
  21181. fields = append(fields, soptask.FieldBotWxidList)
  21182. }
  21183. if m.FieldCleared(soptask.FieldPlanStartTime) {
  21184. fields = append(fields, soptask.FieldPlanStartTime)
  21185. }
  21186. if m.FieldCleared(soptask.FieldPlanEndTime) {
  21187. fields = append(fields, soptask.FieldPlanEndTime)
  21188. }
  21189. if m.FieldCleared(soptask.FieldCreatorID) {
  21190. fields = append(fields, soptask.FieldCreatorID)
  21191. }
  21192. if m.FieldCleared(soptask.FieldOrganizationID) {
  21193. fields = append(fields, soptask.FieldOrganizationID)
  21194. }
  21195. if m.FieldCleared(soptask.FieldToken) {
  21196. fields = append(fields, soptask.FieldToken)
  21197. }
  21198. return fields
  21199. }
  21200. // FieldCleared returns a boolean indicating if a field with the given name was
  21201. // cleared in this mutation.
  21202. func (m *SopTaskMutation) FieldCleared(name string) bool {
  21203. _, ok := m.clearedFields[name]
  21204. return ok
  21205. }
  21206. // ClearField clears the value of the field with the given name. It returns an
  21207. // error if the field is not defined in the schema.
  21208. func (m *SopTaskMutation) ClearField(name string) error {
  21209. switch name {
  21210. case soptask.FieldStatus:
  21211. m.ClearStatus()
  21212. return nil
  21213. case soptask.FieldDeletedAt:
  21214. m.ClearDeletedAt()
  21215. return nil
  21216. case soptask.FieldBotWxidList:
  21217. m.ClearBotWxidList()
  21218. return nil
  21219. case soptask.FieldPlanStartTime:
  21220. m.ClearPlanStartTime()
  21221. return nil
  21222. case soptask.FieldPlanEndTime:
  21223. m.ClearPlanEndTime()
  21224. return nil
  21225. case soptask.FieldCreatorID:
  21226. m.ClearCreatorID()
  21227. return nil
  21228. case soptask.FieldOrganizationID:
  21229. m.ClearOrganizationID()
  21230. return nil
  21231. case soptask.FieldToken:
  21232. m.ClearToken()
  21233. return nil
  21234. }
  21235. return fmt.Errorf("unknown SopTask nullable field %s", name)
  21236. }
  21237. // ResetField resets all changes in the mutation for the field with the given name.
  21238. // It returns an error if the field is not defined in the schema.
  21239. func (m *SopTaskMutation) ResetField(name string) error {
  21240. switch name {
  21241. case soptask.FieldCreatedAt:
  21242. m.ResetCreatedAt()
  21243. return nil
  21244. case soptask.FieldUpdatedAt:
  21245. m.ResetUpdatedAt()
  21246. return nil
  21247. case soptask.FieldStatus:
  21248. m.ResetStatus()
  21249. return nil
  21250. case soptask.FieldDeletedAt:
  21251. m.ResetDeletedAt()
  21252. return nil
  21253. case soptask.FieldName:
  21254. m.ResetName()
  21255. return nil
  21256. case soptask.FieldBotWxidList:
  21257. m.ResetBotWxidList()
  21258. return nil
  21259. case soptask.FieldType:
  21260. m.ResetType()
  21261. return nil
  21262. case soptask.FieldPlanStartTime:
  21263. m.ResetPlanStartTime()
  21264. return nil
  21265. case soptask.FieldPlanEndTime:
  21266. m.ResetPlanEndTime()
  21267. return nil
  21268. case soptask.FieldCreatorID:
  21269. m.ResetCreatorID()
  21270. return nil
  21271. case soptask.FieldOrganizationID:
  21272. m.ResetOrganizationID()
  21273. return nil
  21274. case soptask.FieldToken:
  21275. m.ResetToken()
  21276. return nil
  21277. }
  21278. return fmt.Errorf("unknown SopTask field %s", name)
  21279. }
  21280. // AddedEdges returns all edge names that were set/added in this mutation.
  21281. func (m *SopTaskMutation) AddedEdges() []string {
  21282. edges := make([]string, 0, 1)
  21283. if m.task_stages != nil {
  21284. edges = append(edges, soptask.EdgeTaskStages)
  21285. }
  21286. return edges
  21287. }
  21288. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21289. // name in this mutation.
  21290. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  21291. switch name {
  21292. case soptask.EdgeTaskStages:
  21293. ids := make([]ent.Value, 0, len(m.task_stages))
  21294. for id := range m.task_stages {
  21295. ids = append(ids, id)
  21296. }
  21297. return ids
  21298. }
  21299. return nil
  21300. }
  21301. // RemovedEdges returns all edge names that were removed in this mutation.
  21302. func (m *SopTaskMutation) RemovedEdges() []string {
  21303. edges := make([]string, 0, 1)
  21304. if m.removedtask_stages != nil {
  21305. edges = append(edges, soptask.EdgeTaskStages)
  21306. }
  21307. return edges
  21308. }
  21309. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21310. // the given name in this mutation.
  21311. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  21312. switch name {
  21313. case soptask.EdgeTaskStages:
  21314. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  21315. for id := range m.removedtask_stages {
  21316. ids = append(ids, id)
  21317. }
  21318. return ids
  21319. }
  21320. return nil
  21321. }
  21322. // ClearedEdges returns all edge names that were cleared in this mutation.
  21323. func (m *SopTaskMutation) ClearedEdges() []string {
  21324. edges := make([]string, 0, 1)
  21325. if m.clearedtask_stages {
  21326. edges = append(edges, soptask.EdgeTaskStages)
  21327. }
  21328. return edges
  21329. }
  21330. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21331. // was cleared in this mutation.
  21332. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  21333. switch name {
  21334. case soptask.EdgeTaskStages:
  21335. return m.clearedtask_stages
  21336. }
  21337. return false
  21338. }
  21339. // ClearEdge clears the value of the edge with the given name. It returns an error
  21340. // if that edge is not defined in the schema.
  21341. func (m *SopTaskMutation) ClearEdge(name string) error {
  21342. switch name {
  21343. }
  21344. return fmt.Errorf("unknown SopTask unique edge %s", name)
  21345. }
  21346. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21347. // It returns an error if the edge is not defined in the schema.
  21348. func (m *SopTaskMutation) ResetEdge(name string) error {
  21349. switch name {
  21350. case soptask.EdgeTaskStages:
  21351. m.ResetTaskStages()
  21352. return nil
  21353. }
  21354. return fmt.Errorf("unknown SopTask edge %s", name)
  21355. }
  21356. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  21357. type TokenMutation struct {
  21358. config
  21359. op Op
  21360. typ string
  21361. id *uint64
  21362. created_at *time.Time
  21363. updated_at *time.Time
  21364. deleted_at *time.Time
  21365. expire_at *time.Time
  21366. token *string
  21367. mac *string
  21368. organization_id *uint64
  21369. addorganization_id *int64
  21370. custom_agent_base *string
  21371. custom_agent_key *string
  21372. openai_base *string
  21373. openai_key *string
  21374. clearedFields map[string]struct{}
  21375. agent *uint64
  21376. clearedagent bool
  21377. done bool
  21378. oldValue func(context.Context) (*Token, error)
  21379. predicates []predicate.Token
  21380. }
  21381. var _ ent.Mutation = (*TokenMutation)(nil)
  21382. // tokenOption allows management of the mutation configuration using functional options.
  21383. type tokenOption func(*TokenMutation)
  21384. // newTokenMutation creates new mutation for the Token entity.
  21385. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  21386. m := &TokenMutation{
  21387. config: c,
  21388. op: op,
  21389. typ: TypeToken,
  21390. clearedFields: make(map[string]struct{}),
  21391. }
  21392. for _, opt := range opts {
  21393. opt(m)
  21394. }
  21395. return m
  21396. }
  21397. // withTokenID sets the ID field of the mutation.
  21398. func withTokenID(id uint64) tokenOption {
  21399. return func(m *TokenMutation) {
  21400. var (
  21401. err error
  21402. once sync.Once
  21403. value *Token
  21404. )
  21405. m.oldValue = func(ctx context.Context) (*Token, error) {
  21406. once.Do(func() {
  21407. if m.done {
  21408. err = errors.New("querying old values post mutation is not allowed")
  21409. } else {
  21410. value, err = m.Client().Token.Get(ctx, id)
  21411. }
  21412. })
  21413. return value, err
  21414. }
  21415. m.id = &id
  21416. }
  21417. }
  21418. // withToken sets the old Token of the mutation.
  21419. func withToken(node *Token) tokenOption {
  21420. return func(m *TokenMutation) {
  21421. m.oldValue = func(context.Context) (*Token, error) {
  21422. return node, nil
  21423. }
  21424. m.id = &node.ID
  21425. }
  21426. }
  21427. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21428. // executed in a transaction (ent.Tx), a transactional client is returned.
  21429. func (m TokenMutation) Client() *Client {
  21430. client := &Client{config: m.config}
  21431. client.init()
  21432. return client
  21433. }
  21434. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21435. // it returns an error otherwise.
  21436. func (m TokenMutation) Tx() (*Tx, error) {
  21437. if _, ok := m.driver.(*txDriver); !ok {
  21438. return nil, errors.New("ent: mutation is not running in a transaction")
  21439. }
  21440. tx := &Tx{config: m.config}
  21441. tx.init()
  21442. return tx, nil
  21443. }
  21444. // SetID sets the value of the id field. Note that this
  21445. // operation is only accepted on creation of Token entities.
  21446. func (m *TokenMutation) SetID(id uint64) {
  21447. m.id = &id
  21448. }
  21449. // ID returns the ID value in the mutation. Note that the ID is only available
  21450. // if it was provided to the builder or after it was returned from the database.
  21451. func (m *TokenMutation) ID() (id uint64, exists bool) {
  21452. if m.id == nil {
  21453. return
  21454. }
  21455. return *m.id, true
  21456. }
  21457. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21458. // That means, if the mutation is applied within a transaction with an isolation level such
  21459. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21460. // or updated by the mutation.
  21461. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  21462. switch {
  21463. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21464. id, exists := m.ID()
  21465. if exists {
  21466. return []uint64{id}, nil
  21467. }
  21468. fallthrough
  21469. case m.op.Is(OpUpdate | OpDelete):
  21470. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  21471. default:
  21472. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21473. }
  21474. }
  21475. // SetCreatedAt sets the "created_at" field.
  21476. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  21477. m.created_at = &t
  21478. }
  21479. // CreatedAt returns the value of the "created_at" field in the mutation.
  21480. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  21481. v := m.created_at
  21482. if v == nil {
  21483. return
  21484. }
  21485. return *v, true
  21486. }
  21487. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  21488. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21490. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21491. if !m.op.Is(OpUpdateOne) {
  21492. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21493. }
  21494. if m.id == nil || m.oldValue == nil {
  21495. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21496. }
  21497. oldValue, err := m.oldValue(ctx)
  21498. if err != nil {
  21499. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21500. }
  21501. return oldValue.CreatedAt, nil
  21502. }
  21503. // ResetCreatedAt resets all changes to the "created_at" field.
  21504. func (m *TokenMutation) ResetCreatedAt() {
  21505. m.created_at = nil
  21506. }
  21507. // SetUpdatedAt sets the "updated_at" field.
  21508. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  21509. m.updated_at = &t
  21510. }
  21511. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21512. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  21513. v := m.updated_at
  21514. if v == nil {
  21515. return
  21516. }
  21517. return *v, true
  21518. }
  21519. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  21520. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21522. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21523. if !m.op.Is(OpUpdateOne) {
  21524. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21525. }
  21526. if m.id == nil || m.oldValue == nil {
  21527. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21528. }
  21529. oldValue, err := m.oldValue(ctx)
  21530. if err != nil {
  21531. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21532. }
  21533. return oldValue.UpdatedAt, nil
  21534. }
  21535. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21536. func (m *TokenMutation) ResetUpdatedAt() {
  21537. m.updated_at = nil
  21538. }
  21539. // SetDeletedAt sets the "deleted_at" field.
  21540. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  21541. m.deleted_at = &t
  21542. }
  21543. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21544. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  21545. v := m.deleted_at
  21546. if v == nil {
  21547. return
  21548. }
  21549. return *v, true
  21550. }
  21551. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  21552. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21554. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21555. if !m.op.Is(OpUpdateOne) {
  21556. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21557. }
  21558. if m.id == nil || m.oldValue == nil {
  21559. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21560. }
  21561. oldValue, err := m.oldValue(ctx)
  21562. if err != nil {
  21563. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21564. }
  21565. return oldValue.DeletedAt, nil
  21566. }
  21567. // ClearDeletedAt clears the value of the "deleted_at" field.
  21568. func (m *TokenMutation) ClearDeletedAt() {
  21569. m.deleted_at = nil
  21570. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  21571. }
  21572. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21573. func (m *TokenMutation) DeletedAtCleared() bool {
  21574. _, ok := m.clearedFields[token.FieldDeletedAt]
  21575. return ok
  21576. }
  21577. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21578. func (m *TokenMutation) ResetDeletedAt() {
  21579. m.deleted_at = nil
  21580. delete(m.clearedFields, token.FieldDeletedAt)
  21581. }
  21582. // SetExpireAt sets the "expire_at" field.
  21583. func (m *TokenMutation) SetExpireAt(t time.Time) {
  21584. m.expire_at = &t
  21585. }
  21586. // ExpireAt returns the value of the "expire_at" field in the mutation.
  21587. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  21588. v := m.expire_at
  21589. if v == nil {
  21590. return
  21591. }
  21592. return *v, true
  21593. }
  21594. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  21595. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21597. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  21598. if !m.op.Is(OpUpdateOne) {
  21599. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  21600. }
  21601. if m.id == nil || m.oldValue == nil {
  21602. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  21603. }
  21604. oldValue, err := m.oldValue(ctx)
  21605. if err != nil {
  21606. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  21607. }
  21608. return oldValue.ExpireAt, nil
  21609. }
  21610. // ClearExpireAt clears the value of the "expire_at" field.
  21611. func (m *TokenMutation) ClearExpireAt() {
  21612. m.expire_at = nil
  21613. m.clearedFields[token.FieldExpireAt] = struct{}{}
  21614. }
  21615. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  21616. func (m *TokenMutation) ExpireAtCleared() bool {
  21617. _, ok := m.clearedFields[token.FieldExpireAt]
  21618. return ok
  21619. }
  21620. // ResetExpireAt resets all changes to the "expire_at" field.
  21621. func (m *TokenMutation) ResetExpireAt() {
  21622. m.expire_at = nil
  21623. delete(m.clearedFields, token.FieldExpireAt)
  21624. }
  21625. // SetToken sets the "token" field.
  21626. func (m *TokenMutation) SetToken(s string) {
  21627. m.token = &s
  21628. }
  21629. // Token returns the value of the "token" field in the mutation.
  21630. func (m *TokenMutation) Token() (r string, exists bool) {
  21631. v := m.token
  21632. if v == nil {
  21633. return
  21634. }
  21635. return *v, true
  21636. }
  21637. // OldToken returns the old "token" field's value of the Token entity.
  21638. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21640. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  21641. if !m.op.Is(OpUpdateOne) {
  21642. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  21643. }
  21644. if m.id == nil || m.oldValue == nil {
  21645. return v, errors.New("OldToken requires an ID field in the mutation")
  21646. }
  21647. oldValue, err := m.oldValue(ctx)
  21648. if err != nil {
  21649. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  21650. }
  21651. return oldValue.Token, nil
  21652. }
  21653. // ClearToken clears the value of the "token" field.
  21654. func (m *TokenMutation) ClearToken() {
  21655. m.token = nil
  21656. m.clearedFields[token.FieldToken] = struct{}{}
  21657. }
  21658. // TokenCleared returns if the "token" field was cleared in this mutation.
  21659. func (m *TokenMutation) TokenCleared() bool {
  21660. _, ok := m.clearedFields[token.FieldToken]
  21661. return ok
  21662. }
  21663. // ResetToken resets all changes to the "token" field.
  21664. func (m *TokenMutation) ResetToken() {
  21665. m.token = nil
  21666. delete(m.clearedFields, token.FieldToken)
  21667. }
  21668. // SetMAC sets the "mac" field.
  21669. func (m *TokenMutation) SetMAC(s string) {
  21670. m.mac = &s
  21671. }
  21672. // MAC returns the value of the "mac" field in the mutation.
  21673. func (m *TokenMutation) MAC() (r string, exists bool) {
  21674. v := m.mac
  21675. if v == nil {
  21676. return
  21677. }
  21678. return *v, true
  21679. }
  21680. // OldMAC returns the old "mac" field's value of the Token entity.
  21681. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21683. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  21684. if !m.op.Is(OpUpdateOne) {
  21685. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  21686. }
  21687. if m.id == nil || m.oldValue == nil {
  21688. return v, errors.New("OldMAC requires an ID field in the mutation")
  21689. }
  21690. oldValue, err := m.oldValue(ctx)
  21691. if err != nil {
  21692. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  21693. }
  21694. return oldValue.MAC, nil
  21695. }
  21696. // ClearMAC clears the value of the "mac" field.
  21697. func (m *TokenMutation) ClearMAC() {
  21698. m.mac = nil
  21699. m.clearedFields[token.FieldMAC] = struct{}{}
  21700. }
  21701. // MACCleared returns if the "mac" field was cleared in this mutation.
  21702. func (m *TokenMutation) MACCleared() bool {
  21703. _, ok := m.clearedFields[token.FieldMAC]
  21704. return ok
  21705. }
  21706. // ResetMAC resets all changes to the "mac" field.
  21707. func (m *TokenMutation) ResetMAC() {
  21708. m.mac = nil
  21709. delete(m.clearedFields, token.FieldMAC)
  21710. }
  21711. // SetOrganizationID sets the "organization_id" field.
  21712. func (m *TokenMutation) SetOrganizationID(u uint64) {
  21713. m.organization_id = &u
  21714. m.addorganization_id = nil
  21715. }
  21716. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21717. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  21718. v := m.organization_id
  21719. if v == nil {
  21720. return
  21721. }
  21722. return *v, true
  21723. }
  21724. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  21725. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21727. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21728. if !m.op.Is(OpUpdateOne) {
  21729. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21730. }
  21731. if m.id == nil || m.oldValue == nil {
  21732. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21733. }
  21734. oldValue, err := m.oldValue(ctx)
  21735. if err != nil {
  21736. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21737. }
  21738. return oldValue.OrganizationID, nil
  21739. }
  21740. // AddOrganizationID adds u to the "organization_id" field.
  21741. func (m *TokenMutation) AddOrganizationID(u int64) {
  21742. if m.addorganization_id != nil {
  21743. *m.addorganization_id += u
  21744. } else {
  21745. m.addorganization_id = &u
  21746. }
  21747. }
  21748. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21749. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  21750. v := m.addorganization_id
  21751. if v == nil {
  21752. return
  21753. }
  21754. return *v, true
  21755. }
  21756. // ResetOrganizationID resets all changes to the "organization_id" field.
  21757. func (m *TokenMutation) ResetOrganizationID() {
  21758. m.organization_id = nil
  21759. m.addorganization_id = nil
  21760. }
  21761. // SetAgentID sets the "agent_id" field.
  21762. func (m *TokenMutation) SetAgentID(u uint64) {
  21763. m.agent = &u
  21764. }
  21765. // AgentID returns the value of the "agent_id" field in the mutation.
  21766. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  21767. v := m.agent
  21768. if v == nil {
  21769. return
  21770. }
  21771. return *v, true
  21772. }
  21773. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  21774. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21776. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  21777. if !m.op.Is(OpUpdateOne) {
  21778. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  21779. }
  21780. if m.id == nil || m.oldValue == nil {
  21781. return v, errors.New("OldAgentID requires an ID field in the mutation")
  21782. }
  21783. oldValue, err := m.oldValue(ctx)
  21784. if err != nil {
  21785. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  21786. }
  21787. return oldValue.AgentID, nil
  21788. }
  21789. // ResetAgentID resets all changes to the "agent_id" field.
  21790. func (m *TokenMutation) ResetAgentID() {
  21791. m.agent = nil
  21792. }
  21793. // SetCustomAgentBase sets the "custom_agent_base" field.
  21794. func (m *TokenMutation) SetCustomAgentBase(s string) {
  21795. m.custom_agent_base = &s
  21796. }
  21797. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  21798. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  21799. v := m.custom_agent_base
  21800. if v == nil {
  21801. return
  21802. }
  21803. return *v, true
  21804. }
  21805. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  21806. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21808. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  21809. if !m.op.Is(OpUpdateOne) {
  21810. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  21811. }
  21812. if m.id == nil || m.oldValue == nil {
  21813. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  21814. }
  21815. oldValue, err := m.oldValue(ctx)
  21816. if err != nil {
  21817. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  21818. }
  21819. return oldValue.CustomAgentBase, nil
  21820. }
  21821. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  21822. func (m *TokenMutation) ClearCustomAgentBase() {
  21823. m.custom_agent_base = nil
  21824. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  21825. }
  21826. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  21827. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  21828. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  21829. return ok
  21830. }
  21831. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  21832. func (m *TokenMutation) ResetCustomAgentBase() {
  21833. m.custom_agent_base = nil
  21834. delete(m.clearedFields, token.FieldCustomAgentBase)
  21835. }
  21836. // SetCustomAgentKey sets the "custom_agent_key" field.
  21837. func (m *TokenMutation) SetCustomAgentKey(s string) {
  21838. m.custom_agent_key = &s
  21839. }
  21840. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  21841. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  21842. v := m.custom_agent_key
  21843. if v == nil {
  21844. return
  21845. }
  21846. return *v, true
  21847. }
  21848. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  21849. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21851. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  21852. if !m.op.Is(OpUpdateOne) {
  21853. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  21854. }
  21855. if m.id == nil || m.oldValue == nil {
  21856. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  21857. }
  21858. oldValue, err := m.oldValue(ctx)
  21859. if err != nil {
  21860. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  21861. }
  21862. return oldValue.CustomAgentKey, nil
  21863. }
  21864. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  21865. func (m *TokenMutation) ClearCustomAgentKey() {
  21866. m.custom_agent_key = nil
  21867. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  21868. }
  21869. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  21870. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  21871. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  21872. return ok
  21873. }
  21874. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  21875. func (m *TokenMutation) ResetCustomAgentKey() {
  21876. m.custom_agent_key = nil
  21877. delete(m.clearedFields, token.FieldCustomAgentKey)
  21878. }
  21879. // SetOpenaiBase sets the "openai_base" field.
  21880. func (m *TokenMutation) SetOpenaiBase(s string) {
  21881. m.openai_base = &s
  21882. }
  21883. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  21884. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  21885. v := m.openai_base
  21886. if v == nil {
  21887. return
  21888. }
  21889. return *v, true
  21890. }
  21891. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  21892. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21894. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  21895. if !m.op.Is(OpUpdateOne) {
  21896. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  21897. }
  21898. if m.id == nil || m.oldValue == nil {
  21899. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  21900. }
  21901. oldValue, err := m.oldValue(ctx)
  21902. if err != nil {
  21903. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  21904. }
  21905. return oldValue.OpenaiBase, nil
  21906. }
  21907. // ClearOpenaiBase clears the value of the "openai_base" field.
  21908. func (m *TokenMutation) ClearOpenaiBase() {
  21909. m.openai_base = nil
  21910. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  21911. }
  21912. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  21913. func (m *TokenMutation) OpenaiBaseCleared() bool {
  21914. _, ok := m.clearedFields[token.FieldOpenaiBase]
  21915. return ok
  21916. }
  21917. // ResetOpenaiBase resets all changes to the "openai_base" field.
  21918. func (m *TokenMutation) ResetOpenaiBase() {
  21919. m.openai_base = nil
  21920. delete(m.clearedFields, token.FieldOpenaiBase)
  21921. }
  21922. // SetOpenaiKey sets the "openai_key" field.
  21923. func (m *TokenMutation) SetOpenaiKey(s string) {
  21924. m.openai_key = &s
  21925. }
  21926. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  21927. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  21928. v := m.openai_key
  21929. if v == nil {
  21930. return
  21931. }
  21932. return *v, true
  21933. }
  21934. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  21935. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21937. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  21938. if !m.op.Is(OpUpdateOne) {
  21939. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  21940. }
  21941. if m.id == nil || m.oldValue == nil {
  21942. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  21943. }
  21944. oldValue, err := m.oldValue(ctx)
  21945. if err != nil {
  21946. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  21947. }
  21948. return oldValue.OpenaiKey, nil
  21949. }
  21950. // ClearOpenaiKey clears the value of the "openai_key" field.
  21951. func (m *TokenMutation) ClearOpenaiKey() {
  21952. m.openai_key = nil
  21953. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  21954. }
  21955. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  21956. func (m *TokenMutation) OpenaiKeyCleared() bool {
  21957. _, ok := m.clearedFields[token.FieldOpenaiKey]
  21958. return ok
  21959. }
  21960. // ResetOpenaiKey resets all changes to the "openai_key" field.
  21961. func (m *TokenMutation) ResetOpenaiKey() {
  21962. m.openai_key = nil
  21963. delete(m.clearedFields, token.FieldOpenaiKey)
  21964. }
  21965. // ClearAgent clears the "agent" edge to the Agent entity.
  21966. func (m *TokenMutation) ClearAgent() {
  21967. m.clearedagent = true
  21968. m.clearedFields[token.FieldAgentID] = struct{}{}
  21969. }
  21970. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  21971. func (m *TokenMutation) AgentCleared() bool {
  21972. return m.clearedagent
  21973. }
  21974. // AgentIDs returns the "agent" edge IDs in the mutation.
  21975. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21976. // AgentID instead. It exists only for internal usage by the builders.
  21977. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  21978. if id := m.agent; id != nil {
  21979. ids = append(ids, *id)
  21980. }
  21981. return
  21982. }
  21983. // ResetAgent resets all changes to the "agent" edge.
  21984. func (m *TokenMutation) ResetAgent() {
  21985. m.agent = nil
  21986. m.clearedagent = false
  21987. }
  21988. // Where appends a list predicates to the TokenMutation builder.
  21989. func (m *TokenMutation) Where(ps ...predicate.Token) {
  21990. m.predicates = append(m.predicates, ps...)
  21991. }
  21992. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  21993. // users can use type-assertion to append predicates that do not depend on any generated package.
  21994. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  21995. p := make([]predicate.Token, len(ps))
  21996. for i := range ps {
  21997. p[i] = ps[i]
  21998. }
  21999. m.Where(p...)
  22000. }
  22001. // Op returns the operation name.
  22002. func (m *TokenMutation) Op() Op {
  22003. return m.op
  22004. }
  22005. // SetOp allows setting the mutation operation.
  22006. func (m *TokenMutation) SetOp(op Op) {
  22007. m.op = op
  22008. }
  22009. // Type returns the node type of this mutation (Token).
  22010. func (m *TokenMutation) Type() string {
  22011. return m.typ
  22012. }
  22013. // Fields returns all fields that were changed during this mutation. Note that in
  22014. // order to get all numeric fields that were incremented/decremented, call
  22015. // AddedFields().
  22016. func (m *TokenMutation) Fields() []string {
  22017. fields := make([]string, 0, 12)
  22018. if m.created_at != nil {
  22019. fields = append(fields, token.FieldCreatedAt)
  22020. }
  22021. if m.updated_at != nil {
  22022. fields = append(fields, token.FieldUpdatedAt)
  22023. }
  22024. if m.deleted_at != nil {
  22025. fields = append(fields, token.FieldDeletedAt)
  22026. }
  22027. if m.expire_at != nil {
  22028. fields = append(fields, token.FieldExpireAt)
  22029. }
  22030. if m.token != nil {
  22031. fields = append(fields, token.FieldToken)
  22032. }
  22033. if m.mac != nil {
  22034. fields = append(fields, token.FieldMAC)
  22035. }
  22036. if m.organization_id != nil {
  22037. fields = append(fields, token.FieldOrganizationID)
  22038. }
  22039. if m.agent != nil {
  22040. fields = append(fields, token.FieldAgentID)
  22041. }
  22042. if m.custom_agent_base != nil {
  22043. fields = append(fields, token.FieldCustomAgentBase)
  22044. }
  22045. if m.custom_agent_key != nil {
  22046. fields = append(fields, token.FieldCustomAgentKey)
  22047. }
  22048. if m.openai_base != nil {
  22049. fields = append(fields, token.FieldOpenaiBase)
  22050. }
  22051. if m.openai_key != nil {
  22052. fields = append(fields, token.FieldOpenaiKey)
  22053. }
  22054. return fields
  22055. }
  22056. // Field returns the value of a field with the given name. The second boolean
  22057. // return value indicates that this field was not set, or was not defined in the
  22058. // schema.
  22059. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  22060. switch name {
  22061. case token.FieldCreatedAt:
  22062. return m.CreatedAt()
  22063. case token.FieldUpdatedAt:
  22064. return m.UpdatedAt()
  22065. case token.FieldDeletedAt:
  22066. return m.DeletedAt()
  22067. case token.FieldExpireAt:
  22068. return m.ExpireAt()
  22069. case token.FieldToken:
  22070. return m.Token()
  22071. case token.FieldMAC:
  22072. return m.MAC()
  22073. case token.FieldOrganizationID:
  22074. return m.OrganizationID()
  22075. case token.FieldAgentID:
  22076. return m.AgentID()
  22077. case token.FieldCustomAgentBase:
  22078. return m.CustomAgentBase()
  22079. case token.FieldCustomAgentKey:
  22080. return m.CustomAgentKey()
  22081. case token.FieldOpenaiBase:
  22082. return m.OpenaiBase()
  22083. case token.FieldOpenaiKey:
  22084. return m.OpenaiKey()
  22085. }
  22086. return nil, false
  22087. }
  22088. // OldField returns the old value of the field from the database. An error is
  22089. // returned if the mutation operation is not UpdateOne, or the query to the
  22090. // database failed.
  22091. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22092. switch name {
  22093. case token.FieldCreatedAt:
  22094. return m.OldCreatedAt(ctx)
  22095. case token.FieldUpdatedAt:
  22096. return m.OldUpdatedAt(ctx)
  22097. case token.FieldDeletedAt:
  22098. return m.OldDeletedAt(ctx)
  22099. case token.FieldExpireAt:
  22100. return m.OldExpireAt(ctx)
  22101. case token.FieldToken:
  22102. return m.OldToken(ctx)
  22103. case token.FieldMAC:
  22104. return m.OldMAC(ctx)
  22105. case token.FieldOrganizationID:
  22106. return m.OldOrganizationID(ctx)
  22107. case token.FieldAgentID:
  22108. return m.OldAgentID(ctx)
  22109. case token.FieldCustomAgentBase:
  22110. return m.OldCustomAgentBase(ctx)
  22111. case token.FieldCustomAgentKey:
  22112. return m.OldCustomAgentKey(ctx)
  22113. case token.FieldOpenaiBase:
  22114. return m.OldOpenaiBase(ctx)
  22115. case token.FieldOpenaiKey:
  22116. return m.OldOpenaiKey(ctx)
  22117. }
  22118. return nil, fmt.Errorf("unknown Token field %s", name)
  22119. }
  22120. // SetField sets the value of a field with the given name. It returns an error if
  22121. // the field is not defined in the schema, or if the type mismatched the field
  22122. // type.
  22123. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  22124. switch name {
  22125. case token.FieldCreatedAt:
  22126. v, ok := value.(time.Time)
  22127. if !ok {
  22128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22129. }
  22130. m.SetCreatedAt(v)
  22131. return nil
  22132. case token.FieldUpdatedAt:
  22133. v, ok := value.(time.Time)
  22134. if !ok {
  22135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22136. }
  22137. m.SetUpdatedAt(v)
  22138. return nil
  22139. case token.FieldDeletedAt:
  22140. v, ok := value.(time.Time)
  22141. if !ok {
  22142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22143. }
  22144. m.SetDeletedAt(v)
  22145. return nil
  22146. case token.FieldExpireAt:
  22147. v, ok := value.(time.Time)
  22148. if !ok {
  22149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22150. }
  22151. m.SetExpireAt(v)
  22152. return nil
  22153. case token.FieldToken:
  22154. v, ok := value.(string)
  22155. if !ok {
  22156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22157. }
  22158. m.SetToken(v)
  22159. return nil
  22160. case token.FieldMAC:
  22161. v, ok := value.(string)
  22162. if !ok {
  22163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22164. }
  22165. m.SetMAC(v)
  22166. return nil
  22167. case token.FieldOrganizationID:
  22168. v, ok := value.(uint64)
  22169. if !ok {
  22170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22171. }
  22172. m.SetOrganizationID(v)
  22173. return nil
  22174. case token.FieldAgentID:
  22175. v, ok := value.(uint64)
  22176. if !ok {
  22177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22178. }
  22179. m.SetAgentID(v)
  22180. return nil
  22181. case token.FieldCustomAgentBase:
  22182. v, ok := value.(string)
  22183. if !ok {
  22184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22185. }
  22186. m.SetCustomAgentBase(v)
  22187. return nil
  22188. case token.FieldCustomAgentKey:
  22189. v, ok := value.(string)
  22190. if !ok {
  22191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22192. }
  22193. m.SetCustomAgentKey(v)
  22194. return nil
  22195. case token.FieldOpenaiBase:
  22196. v, ok := value.(string)
  22197. if !ok {
  22198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22199. }
  22200. m.SetOpenaiBase(v)
  22201. return nil
  22202. case token.FieldOpenaiKey:
  22203. v, ok := value.(string)
  22204. if !ok {
  22205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22206. }
  22207. m.SetOpenaiKey(v)
  22208. return nil
  22209. }
  22210. return fmt.Errorf("unknown Token field %s", name)
  22211. }
  22212. // AddedFields returns all numeric fields that were incremented/decremented during
  22213. // this mutation.
  22214. func (m *TokenMutation) AddedFields() []string {
  22215. var fields []string
  22216. if m.addorganization_id != nil {
  22217. fields = append(fields, token.FieldOrganizationID)
  22218. }
  22219. return fields
  22220. }
  22221. // AddedField returns the numeric value that was incremented/decremented on a field
  22222. // with the given name. The second boolean return value indicates that this field
  22223. // was not set, or was not defined in the schema.
  22224. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  22225. switch name {
  22226. case token.FieldOrganizationID:
  22227. return m.AddedOrganizationID()
  22228. }
  22229. return nil, false
  22230. }
  22231. // AddField adds the value to the field with the given name. It returns an error if
  22232. // the field is not defined in the schema, or if the type mismatched the field
  22233. // type.
  22234. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  22235. switch name {
  22236. case token.FieldOrganizationID:
  22237. v, ok := value.(int64)
  22238. if !ok {
  22239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22240. }
  22241. m.AddOrganizationID(v)
  22242. return nil
  22243. }
  22244. return fmt.Errorf("unknown Token numeric field %s", name)
  22245. }
  22246. // ClearedFields returns all nullable fields that were cleared during this
  22247. // mutation.
  22248. func (m *TokenMutation) ClearedFields() []string {
  22249. var fields []string
  22250. if m.FieldCleared(token.FieldDeletedAt) {
  22251. fields = append(fields, token.FieldDeletedAt)
  22252. }
  22253. if m.FieldCleared(token.FieldExpireAt) {
  22254. fields = append(fields, token.FieldExpireAt)
  22255. }
  22256. if m.FieldCleared(token.FieldToken) {
  22257. fields = append(fields, token.FieldToken)
  22258. }
  22259. if m.FieldCleared(token.FieldMAC) {
  22260. fields = append(fields, token.FieldMAC)
  22261. }
  22262. if m.FieldCleared(token.FieldCustomAgentBase) {
  22263. fields = append(fields, token.FieldCustomAgentBase)
  22264. }
  22265. if m.FieldCleared(token.FieldCustomAgentKey) {
  22266. fields = append(fields, token.FieldCustomAgentKey)
  22267. }
  22268. if m.FieldCleared(token.FieldOpenaiBase) {
  22269. fields = append(fields, token.FieldOpenaiBase)
  22270. }
  22271. if m.FieldCleared(token.FieldOpenaiKey) {
  22272. fields = append(fields, token.FieldOpenaiKey)
  22273. }
  22274. return fields
  22275. }
  22276. // FieldCleared returns a boolean indicating if a field with the given name was
  22277. // cleared in this mutation.
  22278. func (m *TokenMutation) FieldCleared(name string) bool {
  22279. _, ok := m.clearedFields[name]
  22280. return ok
  22281. }
  22282. // ClearField clears the value of the field with the given name. It returns an
  22283. // error if the field is not defined in the schema.
  22284. func (m *TokenMutation) ClearField(name string) error {
  22285. switch name {
  22286. case token.FieldDeletedAt:
  22287. m.ClearDeletedAt()
  22288. return nil
  22289. case token.FieldExpireAt:
  22290. m.ClearExpireAt()
  22291. return nil
  22292. case token.FieldToken:
  22293. m.ClearToken()
  22294. return nil
  22295. case token.FieldMAC:
  22296. m.ClearMAC()
  22297. return nil
  22298. case token.FieldCustomAgentBase:
  22299. m.ClearCustomAgentBase()
  22300. return nil
  22301. case token.FieldCustomAgentKey:
  22302. m.ClearCustomAgentKey()
  22303. return nil
  22304. case token.FieldOpenaiBase:
  22305. m.ClearOpenaiBase()
  22306. return nil
  22307. case token.FieldOpenaiKey:
  22308. m.ClearOpenaiKey()
  22309. return nil
  22310. }
  22311. return fmt.Errorf("unknown Token nullable field %s", name)
  22312. }
  22313. // ResetField resets all changes in the mutation for the field with the given name.
  22314. // It returns an error if the field is not defined in the schema.
  22315. func (m *TokenMutation) ResetField(name string) error {
  22316. switch name {
  22317. case token.FieldCreatedAt:
  22318. m.ResetCreatedAt()
  22319. return nil
  22320. case token.FieldUpdatedAt:
  22321. m.ResetUpdatedAt()
  22322. return nil
  22323. case token.FieldDeletedAt:
  22324. m.ResetDeletedAt()
  22325. return nil
  22326. case token.FieldExpireAt:
  22327. m.ResetExpireAt()
  22328. return nil
  22329. case token.FieldToken:
  22330. m.ResetToken()
  22331. return nil
  22332. case token.FieldMAC:
  22333. m.ResetMAC()
  22334. return nil
  22335. case token.FieldOrganizationID:
  22336. m.ResetOrganizationID()
  22337. return nil
  22338. case token.FieldAgentID:
  22339. m.ResetAgentID()
  22340. return nil
  22341. case token.FieldCustomAgentBase:
  22342. m.ResetCustomAgentBase()
  22343. return nil
  22344. case token.FieldCustomAgentKey:
  22345. m.ResetCustomAgentKey()
  22346. return nil
  22347. case token.FieldOpenaiBase:
  22348. m.ResetOpenaiBase()
  22349. return nil
  22350. case token.FieldOpenaiKey:
  22351. m.ResetOpenaiKey()
  22352. return nil
  22353. }
  22354. return fmt.Errorf("unknown Token field %s", name)
  22355. }
  22356. // AddedEdges returns all edge names that were set/added in this mutation.
  22357. func (m *TokenMutation) AddedEdges() []string {
  22358. edges := make([]string, 0, 1)
  22359. if m.agent != nil {
  22360. edges = append(edges, token.EdgeAgent)
  22361. }
  22362. return edges
  22363. }
  22364. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22365. // name in this mutation.
  22366. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  22367. switch name {
  22368. case token.EdgeAgent:
  22369. if id := m.agent; id != nil {
  22370. return []ent.Value{*id}
  22371. }
  22372. }
  22373. return nil
  22374. }
  22375. // RemovedEdges returns all edge names that were removed in this mutation.
  22376. func (m *TokenMutation) RemovedEdges() []string {
  22377. edges := make([]string, 0, 1)
  22378. return edges
  22379. }
  22380. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22381. // the given name in this mutation.
  22382. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  22383. return nil
  22384. }
  22385. // ClearedEdges returns all edge names that were cleared in this mutation.
  22386. func (m *TokenMutation) ClearedEdges() []string {
  22387. edges := make([]string, 0, 1)
  22388. if m.clearedagent {
  22389. edges = append(edges, token.EdgeAgent)
  22390. }
  22391. return edges
  22392. }
  22393. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22394. // was cleared in this mutation.
  22395. func (m *TokenMutation) EdgeCleared(name string) bool {
  22396. switch name {
  22397. case token.EdgeAgent:
  22398. return m.clearedagent
  22399. }
  22400. return false
  22401. }
  22402. // ClearEdge clears the value of the edge with the given name. It returns an error
  22403. // if that edge is not defined in the schema.
  22404. func (m *TokenMutation) ClearEdge(name string) error {
  22405. switch name {
  22406. case token.EdgeAgent:
  22407. m.ClearAgent()
  22408. return nil
  22409. }
  22410. return fmt.Errorf("unknown Token unique edge %s", name)
  22411. }
  22412. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22413. // It returns an error if the edge is not defined in the schema.
  22414. func (m *TokenMutation) ResetEdge(name string) error {
  22415. switch name {
  22416. case token.EdgeAgent:
  22417. m.ResetAgent()
  22418. return nil
  22419. }
  22420. return fmt.Errorf("unknown Token edge %s", name)
  22421. }
  22422. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  22423. type TutorialMutation struct {
  22424. config
  22425. op Op
  22426. typ string
  22427. id *uint64
  22428. created_at *time.Time
  22429. updated_at *time.Time
  22430. deleted_at *time.Time
  22431. index *int
  22432. addindex *int
  22433. title *string
  22434. content *string
  22435. organization_id *uint64
  22436. addorganization_id *int64
  22437. clearedFields map[string]struct{}
  22438. employee *uint64
  22439. clearedemployee bool
  22440. done bool
  22441. oldValue func(context.Context) (*Tutorial, error)
  22442. predicates []predicate.Tutorial
  22443. }
  22444. var _ ent.Mutation = (*TutorialMutation)(nil)
  22445. // tutorialOption allows management of the mutation configuration using functional options.
  22446. type tutorialOption func(*TutorialMutation)
  22447. // newTutorialMutation creates new mutation for the Tutorial entity.
  22448. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  22449. m := &TutorialMutation{
  22450. config: c,
  22451. op: op,
  22452. typ: TypeTutorial,
  22453. clearedFields: make(map[string]struct{}),
  22454. }
  22455. for _, opt := range opts {
  22456. opt(m)
  22457. }
  22458. return m
  22459. }
  22460. // withTutorialID sets the ID field of the mutation.
  22461. func withTutorialID(id uint64) tutorialOption {
  22462. return func(m *TutorialMutation) {
  22463. var (
  22464. err error
  22465. once sync.Once
  22466. value *Tutorial
  22467. )
  22468. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  22469. once.Do(func() {
  22470. if m.done {
  22471. err = errors.New("querying old values post mutation is not allowed")
  22472. } else {
  22473. value, err = m.Client().Tutorial.Get(ctx, id)
  22474. }
  22475. })
  22476. return value, err
  22477. }
  22478. m.id = &id
  22479. }
  22480. }
  22481. // withTutorial sets the old Tutorial of the mutation.
  22482. func withTutorial(node *Tutorial) tutorialOption {
  22483. return func(m *TutorialMutation) {
  22484. m.oldValue = func(context.Context) (*Tutorial, error) {
  22485. return node, nil
  22486. }
  22487. m.id = &node.ID
  22488. }
  22489. }
  22490. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22491. // executed in a transaction (ent.Tx), a transactional client is returned.
  22492. func (m TutorialMutation) Client() *Client {
  22493. client := &Client{config: m.config}
  22494. client.init()
  22495. return client
  22496. }
  22497. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22498. // it returns an error otherwise.
  22499. func (m TutorialMutation) Tx() (*Tx, error) {
  22500. if _, ok := m.driver.(*txDriver); !ok {
  22501. return nil, errors.New("ent: mutation is not running in a transaction")
  22502. }
  22503. tx := &Tx{config: m.config}
  22504. tx.init()
  22505. return tx, nil
  22506. }
  22507. // SetID sets the value of the id field. Note that this
  22508. // operation is only accepted on creation of Tutorial entities.
  22509. func (m *TutorialMutation) SetID(id uint64) {
  22510. m.id = &id
  22511. }
  22512. // ID returns the ID value in the mutation. Note that the ID is only available
  22513. // if it was provided to the builder or after it was returned from the database.
  22514. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  22515. if m.id == nil {
  22516. return
  22517. }
  22518. return *m.id, true
  22519. }
  22520. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22521. // That means, if the mutation is applied within a transaction with an isolation level such
  22522. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22523. // or updated by the mutation.
  22524. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  22525. switch {
  22526. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22527. id, exists := m.ID()
  22528. if exists {
  22529. return []uint64{id}, nil
  22530. }
  22531. fallthrough
  22532. case m.op.Is(OpUpdate | OpDelete):
  22533. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  22534. default:
  22535. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22536. }
  22537. }
  22538. // SetCreatedAt sets the "created_at" field.
  22539. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  22540. m.created_at = &t
  22541. }
  22542. // CreatedAt returns the value of the "created_at" field in the mutation.
  22543. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  22544. v := m.created_at
  22545. if v == nil {
  22546. return
  22547. }
  22548. return *v, true
  22549. }
  22550. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  22551. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22553. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22554. if !m.op.Is(OpUpdateOne) {
  22555. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22556. }
  22557. if m.id == nil || m.oldValue == nil {
  22558. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22559. }
  22560. oldValue, err := m.oldValue(ctx)
  22561. if err != nil {
  22562. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22563. }
  22564. return oldValue.CreatedAt, nil
  22565. }
  22566. // ResetCreatedAt resets all changes to the "created_at" field.
  22567. func (m *TutorialMutation) ResetCreatedAt() {
  22568. m.created_at = nil
  22569. }
  22570. // SetUpdatedAt sets the "updated_at" field.
  22571. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  22572. m.updated_at = &t
  22573. }
  22574. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22575. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  22576. v := m.updated_at
  22577. if v == nil {
  22578. return
  22579. }
  22580. return *v, true
  22581. }
  22582. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  22583. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22585. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22586. if !m.op.Is(OpUpdateOne) {
  22587. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22588. }
  22589. if m.id == nil || m.oldValue == nil {
  22590. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22591. }
  22592. oldValue, err := m.oldValue(ctx)
  22593. if err != nil {
  22594. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22595. }
  22596. return oldValue.UpdatedAt, nil
  22597. }
  22598. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22599. func (m *TutorialMutation) ResetUpdatedAt() {
  22600. m.updated_at = nil
  22601. }
  22602. // SetDeletedAt sets the "deleted_at" field.
  22603. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  22604. m.deleted_at = &t
  22605. }
  22606. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22607. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  22608. v := m.deleted_at
  22609. if v == nil {
  22610. return
  22611. }
  22612. return *v, true
  22613. }
  22614. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  22615. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22617. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22618. if !m.op.Is(OpUpdateOne) {
  22619. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22620. }
  22621. if m.id == nil || m.oldValue == nil {
  22622. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22623. }
  22624. oldValue, err := m.oldValue(ctx)
  22625. if err != nil {
  22626. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22627. }
  22628. return oldValue.DeletedAt, nil
  22629. }
  22630. // ClearDeletedAt clears the value of the "deleted_at" field.
  22631. func (m *TutorialMutation) ClearDeletedAt() {
  22632. m.deleted_at = nil
  22633. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  22634. }
  22635. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22636. func (m *TutorialMutation) DeletedAtCleared() bool {
  22637. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  22638. return ok
  22639. }
  22640. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22641. func (m *TutorialMutation) ResetDeletedAt() {
  22642. m.deleted_at = nil
  22643. delete(m.clearedFields, tutorial.FieldDeletedAt)
  22644. }
  22645. // SetEmployeeID sets the "employee_id" field.
  22646. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  22647. m.employee = &u
  22648. }
  22649. // EmployeeID returns the value of the "employee_id" field in the mutation.
  22650. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  22651. v := m.employee
  22652. if v == nil {
  22653. return
  22654. }
  22655. return *v, true
  22656. }
  22657. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  22658. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22660. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  22661. if !m.op.Is(OpUpdateOne) {
  22662. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  22663. }
  22664. if m.id == nil || m.oldValue == nil {
  22665. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  22666. }
  22667. oldValue, err := m.oldValue(ctx)
  22668. if err != nil {
  22669. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  22670. }
  22671. return oldValue.EmployeeID, nil
  22672. }
  22673. // ResetEmployeeID resets all changes to the "employee_id" field.
  22674. func (m *TutorialMutation) ResetEmployeeID() {
  22675. m.employee = nil
  22676. }
  22677. // SetIndex sets the "index" field.
  22678. func (m *TutorialMutation) SetIndex(i int) {
  22679. m.index = &i
  22680. m.addindex = nil
  22681. }
  22682. // Index returns the value of the "index" field in the mutation.
  22683. func (m *TutorialMutation) Index() (r int, exists bool) {
  22684. v := m.index
  22685. if v == nil {
  22686. return
  22687. }
  22688. return *v, true
  22689. }
  22690. // OldIndex returns the old "index" field's value of the Tutorial entity.
  22691. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22693. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  22694. if !m.op.Is(OpUpdateOne) {
  22695. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  22696. }
  22697. if m.id == nil || m.oldValue == nil {
  22698. return v, errors.New("OldIndex requires an ID field in the mutation")
  22699. }
  22700. oldValue, err := m.oldValue(ctx)
  22701. if err != nil {
  22702. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  22703. }
  22704. return oldValue.Index, nil
  22705. }
  22706. // AddIndex adds i to the "index" field.
  22707. func (m *TutorialMutation) AddIndex(i int) {
  22708. if m.addindex != nil {
  22709. *m.addindex += i
  22710. } else {
  22711. m.addindex = &i
  22712. }
  22713. }
  22714. // AddedIndex returns the value that was added to the "index" field in this mutation.
  22715. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  22716. v := m.addindex
  22717. if v == nil {
  22718. return
  22719. }
  22720. return *v, true
  22721. }
  22722. // ResetIndex resets all changes to the "index" field.
  22723. func (m *TutorialMutation) ResetIndex() {
  22724. m.index = nil
  22725. m.addindex = nil
  22726. }
  22727. // SetTitle sets the "title" field.
  22728. func (m *TutorialMutation) SetTitle(s string) {
  22729. m.title = &s
  22730. }
  22731. // Title returns the value of the "title" field in the mutation.
  22732. func (m *TutorialMutation) Title() (r string, exists bool) {
  22733. v := m.title
  22734. if v == nil {
  22735. return
  22736. }
  22737. return *v, true
  22738. }
  22739. // OldTitle returns the old "title" field's value of the Tutorial entity.
  22740. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22742. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  22743. if !m.op.Is(OpUpdateOne) {
  22744. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  22745. }
  22746. if m.id == nil || m.oldValue == nil {
  22747. return v, errors.New("OldTitle requires an ID field in the mutation")
  22748. }
  22749. oldValue, err := m.oldValue(ctx)
  22750. if err != nil {
  22751. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  22752. }
  22753. return oldValue.Title, nil
  22754. }
  22755. // ResetTitle resets all changes to the "title" field.
  22756. func (m *TutorialMutation) ResetTitle() {
  22757. m.title = nil
  22758. }
  22759. // SetContent sets the "content" field.
  22760. func (m *TutorialMutation) SetContent(s string) {
  22761. m.content = &s
  22762. }
  22763. // Content returns the value of the "content" field in the mutation.
  22764. func (m *TutorialMutation) Content() (r string, exists bool) {
  22765. v := m.content
  22766. if v == nil {
  22767. return
  22768. }
  22769. return *v, true
  22770. }
  22771. // OldContent returns the old "content" field's value of the Tutorial entity.
  22772. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22774. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  22775. if !m.op.Is(OpUpdateOne) {
  22776. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  22777. }
  22778. if m.id == nil || m.oldValue == nil {
  22779. return v, errors.New("OldContent requires an ID field in the mutation")
  22780. }
  22781. oldValue, err := m.oldValue(ctx)
  22782. if err != nil {
  22783. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  22784. }
  22785. return oldValue.Content, nil
  22786. }
  22787. // ResetContent resets all changes to the "content" field.
  22788. func (m *TutorialMutation) ResetContent() {
  22789. m.content = nil
  22790. }
  22791. // SetOrganizationID sets the "organization_id" field.
  22792. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  22793. m.organization_id = &u
  22794. m.addorganization_id = nil
  22795. }
  22796. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22797. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  22798. v := m.organization_id
  22799. if v == nil {
  22800. return
  22801. }
  22802. return *v, true
  22803. }
  22804. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  22805. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22807. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22808. if !m.op.Is(OpUpdateOne) {
  22809. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22810. }
  22811. if m.id == nil || m.oldValue == nil {
  22812. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22813. }
  22814. oldValue, err := m.oldValue(ctx)
  22815. if err != nil {
  22816. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22817. }
  22818. return oldValue.OrganizationID, nil
  22819. }
  22820. // AddOrganizationID adds u to the "organization_id" field.
  22821. func (m *TutorialMutation) AddOrganizationID(u int64) {
  22822. if m.addorganization_id != nil {
  22823. *m.addorganization_id += u
  22824. } else {
  22825. m.addorganization_id = &u
  22826. }
  22827. }
  22828. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22829. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  22830. v := m.addorganization_id
  22831. if v == nil {
  22832. return
  22833. }
  22834. return *v, true
  22835. }
  22836. // ResetOrganizationID resets all changes to the "organization_id" field.
  22837. func (m *TutorialMutation) ResetOrganizationID() {
  22838. m.organization_id = nil
  22839. m.addorganization_id = nil
  22840. }
  22841. // ClearEmployee clears the "employee" edge to the Employee entity.
  22842. func (m *TutorialMutation) ClearEmployee() {
  22843. m.clearedemployee = true
  22844. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  22845. }
  22846. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  22847. func (m *TutorialMutation) EmployeeCleared() bool {
  22848. return m.clearedemployee
  22849. }
  22850. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  22851. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22852. // EmployeeID instead. It exists only for internal usage by the builders.
  22853. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  22854. if id := m.employee; id != nil {
  22855. ids = append(ids, *id)
  22856. }
  22857. return
  22858. }
  22859. // ResetEmployee resets all changes to the "employee" edge.
  22860. func (m *TutorialMutation) ResetEmployee() {
  22861. m.employee = nil
  22862. m.clearedemployee = false
  22863. }
  22864. // Where appends a list predicates to the TutorialMutation builder.
  22865. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  22866. m.predicates = append(m.predicates, ps...)
  22867. }
  22868. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  22869. // users can use type-assertion to append predicates that do not depend on any generated package.
  22870. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  22871. p := make([]predicate.Tutorial, len(ps))
  22872. for i := range ps {
  22873. p[i] = ps[i]
  22874. }
  22875. m.Where(p...)
  22876. }
  22877. // Op returns the operation name.
  22878. func (m *TutorialMutation) Op() Op {
  22879. return m.op
  22880. }
  22881. // SetOp allows setting the mutation operation.
  22882. func (m *TutorialMutation) SetOp(op Op) {
  22883. m.op = op
  22884. }
  22885. // Type returns the node type of this mutation (Tutorial).
  22886. func (m *TutorialMutation) Type() string {
  22887. return m.typ
  22888. }
  22889. // Fields returns all fields that were changed during this mutation. Note that in
  22890. // order to get all numeric fields that were incremented/decremented, call
  22891. // AddedFields().
  22892. func (m *TutorialMutation) Fields() []string {
  22893. fields := make([]string, 0, 8)
  22894. if m.created_at != nil {
  22895. fields = append(fields, tutorial.FieldCreatedAt)
  22896. }
  22897. if m.updated_at != nil {
  22898. fields = append(fields, tutorial.FieldUpdatedAt)
  22899. }
  22900. if m.deleted_at != nil {
  22901. fields = append(fields, tutorial.FieldDeletedAt)
  22902. }
  22903. if m.employee != nil {
  22904. fields = append(fields, tutorial.FieldEmployeeID)
  22905. }
  22906. if m.index != nil {
  22907. fields = append(fields, tutorial.FieldIndex)
  22908. }
  22909. if m.title != nil {
  22910. fields = append(fields, tutorial.FieldTitle)
  22911. }
  22912. if m.content != nil {
  22913. fields = append(fields, tutorial.FieldContent)
  22914. }
  22915. if m.organization_id != nil {
  22916. fields = append(fields, tutorial.FieldOrganizationID)
  22917. }
  22918. return fields
  22919. }
  22920. // Field returns the value of a field with the given name. The second boolean
  22921. // return value indicates that this field was not set, or was not defined in the
  22922. // schema.
  22923. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  22924. switch name {
  22925. case tutorial.FieldCreatedAt:
  22926. return m.CreatedAt()
  22927. case tutorial.FieldUpdatedAt:
  22928. return m.UpdatedAt()
  22929. case tutorial.FieldDeletedAt:
  22930. return m.DeletedAt()
  22931. case tutorial.FieldEmployeeID:
  22932. return m.EmployeeID()
  22933. case tutorial.FieldIndex:
  22934. return m.Index()
  22935. case tutorial.FieldTitle:
  22936. return m.Title()
  22937. case tutorial.FieldContent:
  22938. return m.Content()
  22939. case tutorial.FieldOrganizationID:
  22940. return m.OrganizationID()
  22941. }
  22942. return nil, false
  22943. }
  22944. // OldField returns the old value of the field from the database. An error is
  22945. // returned if the mutation operation is not UpdateOne, or the query to the
  22946. // database failed.
  22947. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22948. switch name {
  22949. case tutorial.FieldCreatedAt:
  22950. return m.OldCreatedAt(ctx)
  22951. case tutorial.FieldUpdatedAt:
  22952. return m.OldUpdatedAt(ctx)
  22953. case tutorial.FieldDeletedAt:
  22954. return m.OldDeletedAt(ctx)
  22955. case tutorial.FieldEmployeeID:
  22956. return m.OldEmployeeID(ctx)
  22957. case tutorial.FieldIndex:
  22958. return m.OldIndex(ctx)
  22959. case tutorial.FieldTitle:
  22960. return m.OldTitle(ctx)
  22961. case tutorial.FieldContent:
  22962. return m.OldContent(ctx)
  22963. case tutorial.FieldOrganizationID:
  22964. return m.OldOrganizationID(ctx)
  22965. }
  22966. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  22967. }
  22968. // SetField sets the value of a field with the given name. It returns an error if
  22969. // the field is not defined in the schema, or if the type mismatched the field
  22970. // type.
  22971. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  22972. switch name {
  22973. case tutorial.FieldCreatedAt:
  22974. v, ok := value.(time.Time)
  22975. if !ok {
  22976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22977. }
  22978. m.SetCreatedAt(v)
  22979. return nil
  22980. case tutorial.FieldUpdatedAt:
  22981. v, ok := value.(time.Time)
  22982. if !ok {
  22983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22984. }
  22985. m.SetUpdatedAt(v)
  22986. return nil
  22987. case tutorial.FieldDeletedAt:
  22988. v, ok := value.(time.Time)
  22989. if !ok {
  22990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22991. }
  22992. m.SetDeletedAt(v)
  22993. return nil
  22994. case tutorial.FieldEmployeeID:
  22995. v, ok := value.(uint64)
  22996. if !ok {
  22997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22998. }
  22999. m.SetEmployeeID(v)
  23000. return nil
  23001. case tutorial.FieldIndex:
  23002. v, ok := value.(int)
  23003. if !ok {
  23004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23005. }
  23006. m.SetIndex(v)
  23007. return nil
  23008. case tutorial.FieldTitle:
  23009. v, ok := value.(string)
  23010. if !ok {
  23011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23012. }
  23013. m.SetTitle(v)
  23014. return nil
  23015. case tutorial.FieldContent:
  23016. v, ok := value.(string)
  23017. if !ok {
  23018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23019. }
  23020. m.SetContent(v)
  23021. return nil
  23022. case tutorial.FieldOrganizationID:
  23023. v, ok := value.(uint64)
  23024. if !ok {
  23025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23026. }
  23027. m.SetOrganizationID(v)
  23028. return nil
  23029. }
  23030. return fmt.Errorf("unknown Tutorial field %s", name)
  23031. }
  23032. // AddedFields returns all numeric fields that were incremented/decremented during
  23033. // this mutation.
  23034. func (m *TutorialMutation) AddedFields() []string {
  23035. var fields []string
  23036. if m.addindex != nil {
  23037. fields = append(fields, tutorial.FieldIndex)
  23038. }
  23039. if m.addorganization_id != nil {
  23040. fields = append(fields, tutorial.FieldOrganizationID)
  23041. }
  23042. return fields
  23043. }
  23044. // AddedField returns the numeric value that was incremented/decremented on a field
  23045. // with the given name. The second boolean return value indicates that this field
  23046. // was not set, or was not defined in the schema.
  23047. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  23048. switch name {
  23049. case tutorial.FieldIndex:
  23050. return m.AddedIndex()
  23051. case tutorial.FieldOrganizationID:
  23052. return m.AddedOrganizationID()
  23053. }
  23054. return nil, false
  23055. }
  23056. // AddField adds the value to the field with the given name. It returns an error if
  23057. // the field is not defined in the schema, or if the type mismatched the field
  23058. // type.
  23059. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  23060. switch name {
  23061. case tutorial.FieldIndex:
  23062. v, ok := value.(int)
  23063. if !ok {
  23064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23065. }
  23066. m.AddIndex(v)
  23067. return nil
  23068. case tutorial.FieldOrganizationID:
  23069. v, ok := value.(int64)
  23070. if !ok {
  23071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23072. }
  23073. m.AddOrganizationID(v)
  23074. return nil
  23075. }
  23076. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  23077. }
  23078. // ClearedFields returns all nullable fields that were cleared during this
  23079. // mutation.
  23080. func (m *TutorialMutation) ClearedFields() []string {
  23081. var fields []string
  23082. if m.FieldCleared(tutorial.FieldDeletedAt) {
  23083. fields = append(fields, tutorial.FieldDeletedAt)
  23084. }
  23085. return fields
  23086. }
  23087. // FieldCleared returns a boolean indicating if a field with the given name was
  23088. // cleared in this mutation.
  23089. func (m *TutorialMutation) FieldCleared(name string) bool {
  23090. _, ok := m.clearedFields[name]
  23091. return ok
  23092. }
  23093. // ClearField clears the value of the field with the given name. It returns an
  23094. // error if the field is not defined in the schema.
  23095. func (m *TutorialMutation) ClearField(name string) error {
  23096. switch name {
  23097. case tutorial.FieldDeletedAt:
  23098. m.ClearDeletedAt()
  23099. return nil
  23100. }
  23101. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  23102. }
  23103. // ResetField resets all changes in the mutation for the field with the given name.
  23104. // It returns an error if the field is not defined in the schema.
  23105. func (m *TutorialMutation) ResetField(name string) error {
  23106. switch name {
  23107. case tutorial.FieldCreatedAt:
  23108. m.ResetCreatedAt()
  23109. return nil
  23110. case tutorial.FieldUpdatedAt:
  23111. m.ResetUpdatedAt()
  23112. return nil
  23113. case tutorial.FieldDeletedAt:
  23114. m.ResetDeletedAt()
  23115. return nil
  23116. case tutorial.FieldEmployeeID:
  23117. m.ResetEmployeeID()
  23118. return nil
  23119. case tutorial.FieldIndex:
  23120. m.ResetIndex()
  23121. return nil
  23122. case tutorial.FieldTitle:
  23123. m.ResetTitle()
  23124. return nil
  23125. case tutorial.FieldContent:
  23126. m.ResetContent()
  23127. return nil
  23128. case tutorial.FieldOrganizationID:
  23129. m.ResetOrganizationID()
  23130. return nil
  23131. }
  23132. return fmt.Errorf("unknown Tutorial field %s", name)
  23133. }
  23134. // AddedEdges returns all edge names that were set/added in this mutation.
  23135. func (m *TutorialMutation) AddedEdges() []string {
  23136. edges := make([]string, 0, 1)
  23137. if m.employee != nil {
  23138. edges = append(edges, tutorial.EdgeEmployee)
  23139. }
  23140. return edges
  23141. }
  23142. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23143. // name in this mutation.
  23144. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  23145. switch name {
  23146. case tutorial.EdgeEmployee:
  23147. if id := m.employee; id != nil {
  23148. return []ent.Value{*id}
  23149. }
  23150. }
  23151. return nil
  23152. }
  23153. // RemovedEdges returns all edge names that were removed in this mutation.
  23154. func (m *TutorialMutation) RemovedEdges() []string {
  23155. edges := make([]string, 0, 1)
  23156. return edges
  23157. }
  23158. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23159. // the given name in this mutation.
  23160. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  23161. return nil
  23162. }
  23163. // ClearedEdges returns all edge names that were cleared in this mutation.
  23164. func (m *TutorialMutation) ClearedEdges() []string {
  23165. edges := make([]string, 0, 1)
  23166. if m.clearedemployee {
  23167. edges = append(edges, tutorial.EdgeEmployee)
  23168. }
  23169. return edges
  23170. }
  23171. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23172. // was cleared in this mutation.
  23173. func (m *TutorialMutation) EdgeCleared(name string) bool {
  23174. switch name {
  23175. case tutorial.EdgeEmployee:
  23176. return m.clearedemployee
  23177. }
  23178. return false
  23179. }
  23180. // ClearEdge clears the value of the edge with the given name. It returns an error
  23181. // if that edge is not defined in the schema.
  23182. func (m *TutorialMutation) ClearEdge(name string) error {
  23183. switch name {
  23184. case tutorial.EdgeEmployee:
  23185. m.ClearEmployee()
  23186. return nil
  23187. }
  23188. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  23189. }
  23190. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23191. // It returns an error if the edge is not defined in the schema.
  23192. func (m *TutorialMutation) ResetEdge(name string) error {
  23193. switch name {
  23194. case tutorial.EdgeEmployee:
  23195. m.ResetEmployee()
  23196. return nil
  23197. }
  23198. return fmt.Errorf("unknown Tutorial edge %s", name)
  23199. }
  23200. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  23201. type UsageDetailMutation struct {
  23202. config
  23203. op Op
  23204. typ string
  23205. id *uint64
  23206. created_at *time.Time
  23207. updated_at *time.Time
  23208. status *uint8
  23209. addstatus *int8
  23210. _type *int
  23211. add_type *int
  23212. bot_id *string
  23213. receiver_id *string
  23214. app *int
  23215. addapp *int
  23216. session_id *uint64
  23217. addsession_id *int64
  23218. request *string
  23219. response *string
  23220. total_tokens *uint64
  23221. addtotal_tokens *int64
  23222. prompt_tokens *uint64
  23223. addprompt_tokens *int64
  23224. completion_tokens *uint64
  23225. addcompletion_tokens *int64
  23226. organization_id *uint64
  23227. addorganization_id *int64
  23228. clearedFields map[string]struct{}
  23229. done bool
  23230. oldValue func(context.Context) (*UsageDetail, error)
  23231. predicates []predicate.UsageDetail
  23232. }
  23233. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  23234. // usagedetailOption allows management of the mutation configuration using functional options.
  23235. type usagedetailOption func(*UsageDetailMutation)
  23236. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  23237. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  23238. m := &UsageDetailMutation{
  23239. config: c,
  23240. op: op,
  23241. typ: TypeUsageDetail,
  23242. clearedFields: make(map[string]struct{}),
  23243. }
  23244. for _, opt := range opts {
  23245. opt(m)
  23246. }
  23247. return m
  23248. }
  23249. // withUsageDetailID sets the ID field of the mutation.
  23250. func withUsageDetailID(id uint64) usagedetailOption {
  23251. return func(m *UsageDetailMutation) {
  23252. var (
  23253. err error
  23254. once sync.Once
  23255. value *UsageDetail
  23256. )
  23257. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  23258. once.Do(func() {
  23259. if m.done {
  23260. err = errors.New("querying old values post mutation is not allowed")
  23261. } else {
  23262. value, err = m.Client().UsageDetail.Get(ctx, id)
  23263. }
  23264. })
  23265. return value, err
  23266. }
  23267. m.id = &id
  23268. }
  23269. }
  23270. // withUsageDetail sets the old UsageDetail of the mutation.
  23271. func withUsageDetail(node *UsageDetail) usagedetailOption {
  23272. return func(m *UsageDetailMutation) {
  23273. m.oldValue = func(context.Context) (*UsageDetail, error) {
  23274. return node, nil
  23275. }
  23276. m.id = &node.ID
  23277. }
  23278. }
  23279. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23280. // executed in a transaction (ent.Tx), a transactional client is returned.
  23281. func (m UsageDetailMutation) Client() *Client {
  23282. client := &Client{config: m.config}
  23283. client.init()
  23284. return client
  23285. }
  23286. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23287. // it returns an error otherwise.
  23288. func (m UsageDetailMutation) Tx() (*Tx, error) {
  23289. if _, ok := m.driver.(*txDriver); !ok {
  23290. return nil, errors.New("ent: mutation is not running in a transaction")
  23291. }
  23292. tx := &Tx{config: m.config}
  23293. tx.init()
  23294. return tx, nil
  23295. }
  23296. // SetID sets the value of the id field. Note that this
  23297. // operation is only accepted on creation of UsageDetail entities.
  23298. func (m *UsageDetailMutation) SetID(id uint64) {
  23299. m.id = &id
  23300. }
  23301. // ID returns the ID value in the mutation. Note that the ID is only available
  23302. // if it was provided to the builder or after it was returned from the database.
  23303. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  23304. if m.id == nil {
  23305. return
  23306. }
  23307. return *m.id, true
  23308. }
  23309. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23310. // That means, if the mutation is applied within a transaction with an isolation level such
  23311. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23312. // or updated by the mutation.
  23313. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  23314. switch {
  23315. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23316. id, exists := m.ID()
  23317. if exists {
  23318. return []uint64{id}, nil
  23319. }
  23320. fallthrough
  23321. case m.op.Is(OpUpdate | OpDelete):
  23322. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  23323. default:
  23324. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23325. }
  23326. }
  23327. // SetCreatedAt sets the "created_at" field.
  23328. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  23329. m.created_at = &t
  23330. }
  23331. // CreatedAt returns the value of the "created_at" field in the mutation.
  23332. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  23333. v := m.created_at
  23334. if v == nil {
  23335. return
  23336. }
  23337. return *v, true
  23338. }
  23339. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  23340. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23342. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23343. if !m.op.Is(OpUpdateOne) {
  23344. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23345. }
  23346. if m.id == nil || m.oldValue == nil {
  23347. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23348. }
  23349. oldValue, err := m.oldValue(ctx)
  23350. if err != nil {
  23351. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23352. }
  23353. return oldValue.CreatedAt, nil
  23354. }
  23355. // ResetCreatedAt resets all changes to the "created_at" field.
  23356. func (m *UsageDetailMutation) ResetCreatedAt() {
  23357. m.created_at = nil
  23358. }
  23359. // SetUpdatedAt sets the "updated_at" field.
  23360. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  23361. m.updated_at = &t
  23362. }
  23363. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23364. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  23365. v := m.updated_at
  23366. if v == nil {
  23367. return
  23368. }
  23369. return *v, true
  23370. }
  23371. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  23372. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23374. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23375. if !m.op.Is(OpUpdateOne) {
  23376. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23377. }
  23378. if m.id == nil || m.oldValue == nil {
  23379. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23380. }
  23381. oldValue, err := m.oldValue(ctx)
  23382. if err != nil {
  23383. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23384. }
  23385. return oldValue.UpdatedAt, nil
  23386. }
  23387. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23388. func (m *UsageDetailMutation) ResetUpdatedAt() {
  23389. m.updated_at = nil
  23390. }
  23391. // SetStatus sets the "status" field.
  23392. func (m *UsageDetailMutation) SetStatus(u uint8) {
  23393. m.status = &u
  23394. m.addstatus = nil
  23395. }
  23396. // Status returns the value of the "status" field in the mutation.
  23397. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  23398. v := m.status
  23399. if v == nil {
  23400. return
  23401. }
  23402. return *v, true
  23403. }
  23404. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  23405. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23407. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23408. if !m.op.Is(OpUpdateOne) {
  23409. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23410. }
  23411. if m.id == nil || m.oldValue == nil {
  23412. return v, errors.New("OldStatus requires an ID field in the mutation")
  23413. }
  23414. oldValue, err := m.oldValue(ctx)
  23415. if err != nil {
  23416. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23417. }
  23418. return oldValue.Status, nil
  23419. }
  23420. // AddStatus adds u to the "status" field.
  23421. func (m *UsageDetailMutation) AddStatus(u int8) {
  23422. if m.addstatus != nil {
  23423. *m.addstatus += u
  23424. } else {
  23425. m.addstatus = &u
  23426. }
  23427. }
  23428. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23429. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  23430. v := m.addstatus
  23431. if v == nil {
  23432. return
  23433. }
  23434. return *v, true
  23435. }
  23436. // ClearStatus clears the value of the "status" field.
  23437. func (m *UsageDetailMutation) ClearStatus() {
  23438. m.status = nil
  23439. m.addstatus = nil
  23440. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  23441. }
  23442. // StatusCleared returns if the "status" field was cleared in this mutation.
  23443. func (m *UsageDetailMutation) StatusCleared() bool {
  23444. _, ok := m.clearedFields[usagedetail.FieldStatus]
  23445. return ok
  23446. }
  23447. // ResetStatus resets all changes to the "status" field.
  23448. func (m *UsageDetailMutation) ResetStatus() {
  23449. m.status = nil
  23450. m.addstatus = nil
  23451. delete(m.clearedFields, usagedetail.FieldStatus)
  23452. }
  23453. // SetType sets the "type" field.
  23454. func (m *UsageDetailMutation) SetType(i int) {
  23455. m._type = &i
  23456. m.add_type = nil
  23457. }
  23458. // GetType returns the value of the "type" field in the mutation.
  23459. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  23460. v := m._type
  23461. if v == nil {
  23462. return
  23463. }
  23464. return *v, true
  23465. }
  23466. // OldType returns the old "type" field's value of the UsageDetail entity.
  23467. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23469. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  23470. if !m.op.Is(OpUpdateOne) {
  23471. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23472. }
  23473. if m.id == nil || m.oldValue == nil {
  23474. return v, errors.New("OldType requires an ID field in the mutation")
  23475. }
  23476. oldValue, err := m.oldValue(ctx)
  23477. if err != nil {
  23478. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23479. }
  23480. return oldValue.Type, nil
  23481. }
  23482. // AddType adds i to the "type" field.
  23483. func (m *UsageDetailMutation) AddType(i int) {
  23484. if m.add_type != nil {
  23485. *m.add_type += i
  23486. } else {
  23487. m.add_type = &i
  23488. }
  23489. }
  23490. // AddedType returns the value that was added to the "type" field in this mutation.
  23491. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  23492. v := m.add_type
  23493. if v == nil {
  23494. return
  23495. }
  23496. return *v, true
  23497. }
  23498. // ClearType clears the value of the "type" field.
  23499. func (m *UsageDetailMutation) ClearType() {
  23500. m._type = nil
  23501. m.add_type = nil
  23502. m.clearedFields[usagedetail.FieldType] = struct{}{}
  23503. }
  23504. // TypeCleared returns if the "type" field was cleared in this mutation.
  23505. func (m *UsageDetailMutation) TypeCleared() bool {
  23506. _, ok := m.clearedFields[usagedetail.FieldType]
  23507. return ok
  23508. }
  23509. // ResetType resets all changes to the "type" field.
  23510. func (m *UsageDetailMutation) ResetType() {
  23511. m._type = nil
  23512. m.add_type = nil
  23513. delete(m.clearedFields, usagedetail.FieldType)
  23514. }
  23515. // SetBotID sets the "bot_id" field.
  23516. func (m *UsageDetailMutation) SetBotID(s string) {
  23517. m.bot_id = &s
  23518. }
  23519. // BotID returns the value of the "bot_id" field in the mutation.
  23520. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  23521. v := m.bot_id
  23522. if v == nil {
  23523. return
  23524. }
  23525. return *v, true
  23526. }
  23527. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  23528. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23530. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  23531. if !m.op.Is(OpUpdateOne) {
  23532. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  23533. }
  23534. if m.id == nil || m.oldValue == nil {
  23535. return v, errors.New("OldBotID requires an ID field in the mutation")
  23536. }
  23537. oldValue, err := m.oldValue(ctx)
  23538. if err != nil {
  23539. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  23540. }
  23541. return oldValue.BotID, nil
  23542. }
  23543. // ResetBotID resets all changes to the "bot_id" field.
  23544. func (m *UsageDetailMutation) ResetBotID() {
  23545. m.bot_id = nil
  23546. }
  23547. // SetReceiverID sets the "receiver_id" field.
  23548. func (m *UsageDetailMutation) SetReceiverID(s string) {
  23549. m.receiver_id = &s
  23550. }
  23551. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  23552. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  23553. v := m.receiver_id
  23554. if v == nil {
  23555. return
  23556. }
  23557. return *v, true
  23558. }
  23559. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  23560. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23562. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  23563. if !m.op.Is(OpUpdateOne) {
  23564. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  23565. }
  23566. if m.id == nil || m.oldValue == nil {
  23567. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  23568. }
  23569. oldValue, err := m.oldValue(ctx)
  23570. if err != nil {
  23571. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  23572. }
  23573. return oldValue.ReceiverID, nil
  23574. }
  23575. // ResetReceiverID resets all changes to the "receiver_id" field.
  23576. func (m *UsageDetailMutation) ResetReceiverID() {
  23577. m.receiver_id = nil
  23578. }
  23579. // SetApp sets the "app" field.
  23580. func (m *UsageDetailMutation) SetApp(i int) {
  23581. m.app = &i
  23582. m.addapp = nil
  23583. }
  23584. // App returns the value of the "app" field in the mutation.
  23585. func (m *UsageDetailMutation) App() (r int, exists bool) {
  23586. v := m.app
  23587. if v == nil {
  23588. return
  23589. }
  23590. return *v, true
  23591. }
  23592. // OldApp returns the old "app" field's value of the UsageDetail entity.
  23593. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23595. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  23596. if !m.op.Is(OpUpdateOne) {
  23597. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  23598. }
  23599. if m.id == nil || m.oldValue == nil {
  23600. return v, errors.New("OldApp requires an ID field in the mutation")
  23601. }
  23602. oldValue, err := m.oldValue(ctx)
  23603. if err != nil {
  23604. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  23605. }
  23606. return oldValue.App, nil
  23607. }
  23608. // AddApp adds i to the "app" field.
  23609. func (m *UsageDetailMutation) AddApp(i int) {
  23610. if m.addapp != nil {
  23611. *m.addapp += i
  23612. } else {
  23613. m.addapp = &i
  23614. }
  23615. }
  23616. // AddedApp returns the value that was added to the "app" field in this mutation.
  23617. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  23618. v := m.addapp
  23619. if v == nil {
  23620. return
  23621. }
  23622. return *v, true
  23623. }
  23624. // ClearApp clears the value of the "app" field.
  23625. func (m *UsageDetailMutation) ClearApp() {
  23626. m.app = nil
  23627. m.addapp = nil
  23628. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  23629. }
  23630. // AppCleared returns if the "app" field was cleared in this mutation.
  23631. func (m *UsageDetailMutation) AppCleared() bool {
  23632. _, ok := m.clearedFields[usagedetail.FieldApp]
  23633. return ok
  23634. }
  23635. // ResetApp resets all changes to the "app" field.
  23636. func (m *UsageDetailMutation) ResetApp() {
  23637. m.app = nil
  23638. m.addapp = nil
  23639. delete(m.clearedFields, usagedetail.FieldApp)
  23640. }
  23641. // SetSessionID sets the "session_id" field.
  23642. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  23643. m.session_id = &u
  23644. m.addsession_id = nil
  23645. }
  23646. // SessionID returns the value of the "session_id" field in the mutation.
  23647. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  23648. v := m.session_id
  23649. if v == nil {
  23650. return
  23651. }
  23652. return *v, true
  23653. }
  23654. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  23655. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23657. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  23658. if !m.op.Is(OpUpdateOne) {
  23659. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  23660. }
  23661. if m.id == nil || m.oldValue == nil {
  23662. return v, errors.New("OldSessionID requires an ID field in the mutation")
  23663. }
  23664. oldValue, err := m.oldValue(ctx)
  23665. if err != nil {
  23666. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  23667. }
  23668. return oldValue.SessionID, nil
  23669. }
  23670. // AddSessionID adds u to the "session_id" field.
  23671. func (m *UsageDetailMutation) AddSessionID(u int64) {
  23672. if m.addsession_id != nil {
  23673. *m.addsession_id += u
  23674. } else {
  23675. m.addsession_id = &u
  23676. }
  23677. }
  23678. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  23679. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  23680. v := m.addsession_id
  23681. if v == nil {
  23682. return
  23683. }
  23684. return *v, true
  23685. }
  23686. // ClearSessionID clears the value of the "session_id" field.
  23687. func (m *UsageDetailMutation) ClearSessionID() {
  23688. m.session_id = nil
  23689. m.addsession_id = nil
  23690. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  23691. }
  23692. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  23693. func (m *UsageDetailMutation) SessionIDCleared() bool {
  23694. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  23695. return ok
  23696. }
  23697. // ResetSessionID resets all changes to the "session_id" field.
  23698. func (m *UsageDetailMutation) ResetSessionID() {
  23699. m.session_id = nil
  23700. m.addsession_id = nil
  23701. delete(m.clearedFields, usagedetail.FieldSessionID)
  23702. }
  23703. // SetRequest sets the "request" field.
  23704. func (m *UsageDetailMutation) SetRequest(s string) {
  23705. m.request = &s
  23706. }
  23707. // Request returns the value of the "request" field in the mutation.
  23708. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  23709. v := m.request
  23710. if v == nil {
  23711. return
  23712. }
  23713. return *v, true
  23714. }
  23715. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  23716. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23718. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  23719. if !m.op.Is(OpUpdateOne) {
  23720. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  23721. }
  23722. if m.id == nil || m.oldValue == nil {
  23723. return v, errors.New("OldRequest requires an ID field in the mutation")
  23724. }
  23725. oldValue, err := m.oldValue(ctx)
  23726. if err != nil {
  23727. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  23728. }
  23729. return oldValue.Request, nil
  23730. }
  23731. // ResetRequest resets all changes to the "request" field.
  23732. func (m *UsageDetailMutation) ResetRequest() {
  23733. m.request = nil
  23734. }
  23735. // SetResponse sets the "response" field.
  23736. func (m *UsageDetailMutation) SetResponse(s string) {
  23737. m.response = &s
  23738. }
  23739. // Response returns the value of the "response" field in the mutation.
  23740. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  23741. v := m.response
  23742. if v == nil {
  23743. return
  23744. }
  23745. return *v, true
  23746. }
  23747. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  23748. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23750. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  23751. if !m.op.Is(OpUpdateOne) {
  23752. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  23753. }
  23754. if m.id == nil || m.oldValue == nil {
  23755. return v, errors.New("OldResponse requires an ID field in the mutation")
  23756. }
  23757. oldValue, err := m.oldValue(ctx)
  23758. if err != nil {
  23759. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  23760. }
  23761. return oldValue.Response, nil
  23762. }
  23763. // ResetResponse resets all changes to the "response" field.
  23764. func (m *UsageDetailMutation) ResetResponse() {
  23765. m.response = nil
  23766. }
  23767. // SetTotalTokens sets the "total_tokens" field.
  23768. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  23769. m.total_tokens = &u
  23770. m.addtotal_tokens = nil
  23771. }
  23772. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  23773. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  23774. v := m.total_tokens
  23775. if v == nil {
  23776. return
  23777. }
  23778. return *v, true
  23779. }
  23780. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  23781. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23783. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  23784. if !m.op.Is(OpUpdateOne) {
  23785. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  23786. }
  23787. if m.id == nil || m.oldValue == nil {
  23788. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  23789. }
  23790. oldValue, err := m.oldValue(ctx)
  23791. if err != nil {
  23792. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  23793. }
  23794. return oldValue.TotalTokens, nil
  23795. }
  23796. // AddTotalTokens adds u to the "total_tokens" field.
  23797. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  23798. if m.addtotal_tokens != nil {
  23799. *m.addtotal_tokens += u
  23800. } else {
  23801. m.addtotal_tokens = &u
  23802. }
  23803. }
  23804. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  23805. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  23806. v := m.addtotal_tokens
  23807. if v == nil {
  23808. return
  23809. }
  23810. return *v, true
  23811. }
  23812. // ClearTotalTokens clears the value of the "total_tokens" field.
  23813. func (m *UsageDetailMutation) ClearTotalTokens() {
  23814. m.total_tokens = nil
  23815. m.addtotal_tokens = nil
  23816. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  23817. }
  23818. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  23819. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  23820. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  23821. return ok
  23822. }
  23823. // ResetTotalTokens resets all changes to the "total_tokens" field.
  23824. func (m *UsageDetailMutation) ResetTotalTokens() {
  23825. m.total_tokens = nil
  23826. m.addtotal_tokens = nil
  23827. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  23828. }
  23829. // SetPromptTokens sets the "prompt_tokens" field.
  23830. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  23831. m.prompt_tokens = &u
  23832. m.addprompt_tokens = nil
  23833. }
  23834. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  23835. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  23836. v := m.prompt_tokens
  23837. if v == nil {
  23838. return
  23839. }
  23840. return *v, true
  23841. }
  23842. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  23843. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23845. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  23846. if !m.op.Is(OpUpdateOne) {
  23847. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  23848. }
  23849. if m.id == nil || m.oldValue == nil {
  23850. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  23851. }
  23852. oldValue, err := m.oldValue(ctx)
  23853. if err != nil {
  23854. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  23855. }
  23856. return oldValue.PromptTokens, nil
  23857. }
  23858. // AddPromptTokens adds u to the "prompt_tokens" field.
  23859. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  23860. if m.addprompt_tokens != nil {
  23861. *m.addprompt_tokens += u
  23862. } else {
  23863. m.addprompt_tokens = &u
  23864. }
  23865. }
  23866. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  23867. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  23868. v := m.addprompt_tokens
  23869. if v == nil {
  23870. return
  23871. }
  23872. return *v, true
  23873. }
  23874. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  23875. func (m *UsageDetailMutation) ClearPromptTokens() {
  23876. m.prompt_tokens = nil
  23877. m.addprompt_tokens = nil
  23878. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  23879. }
  23880. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  23881. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  23882. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  23883. return ok
  23884. }
  23885. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  23886. func (m *UsageDetailMutation) ResetPromptTokens() {
  23887. m.prompt_tokens = nil
  23888. m.addprompt_tokens = nil
  23889. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  23890. }
  23891. // SetCompletionTokens sets the "completion_tokens" field.
  23892. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  23893. m.completion_tokens = &u
  23894. m.addcompletion_tokens = nil
  23895. }
  23896. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  23897. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  23898. v := m.completion_tokens
  23899. if v == nil {
  23900. return
  23901. }
  23902. return *v, true
  23903. }
  23904. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  23905. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23907. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  23908. if !m.op.Is(OpUpdateOne) {
  23909. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  23910. }
  23911. if m.id == nil || m.oldValue == nil {
  23912. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  23913. }
  23914. oldValue, err := m.oldValue(ctx)
  23915. if err != nil {
  23916. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  23917. }
  23918. return oldValue.CompletionTokens, nil
  23919. }
  23920. // AddCompletionTokens adds u to the "completion_tokens" field.
  23921. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  23922. if m.addcompletion_tokens != nil {
  23923. *m.addcompletion_tokens += u
  23924. } else {
  23925. m.addcompletion_tokens = &u
  23926. }
  23927. }
  23928. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  23929. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  23930. v := m.addcompletion_tokens
  23931. if v == nil {
  23932. return
  23933. }
  23934. return *v, true
  23935. }
  23936. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  23937. func (m *UsageDetailMutation) ClearCompletionTokens() {
  23938. m.completion_tokens = nil
  23939. m.addcompletion_tokens = nil
  23940. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  23941. }
  23942. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  23943. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  23944. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  23945. return ok
  23946. }
  23947. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  23948. func (m *UsageDetailMutation) ResetCompletionTokens() {
  23949. m.completion_tokens = nil
  23950. m.addcompletion_tokens = nil
  23951. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  23952. }
  23953. // SetOrganizationID sets the "organization_id" field.
  23954. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  23955. m.organization_id = &u
  23956. m.addorganization_id = nil
  23957. }
  23958. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23959. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  23960. v := m.organization_id
  23961. if v == nil {
  23962. return
  23963. }
  23964. return *v, true
  23965. }
  23966. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  23967. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23969. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23970. if !m.op.Is(OpUpdateOne) {
  23971. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23972. }
  23973. if m.id == nil || m.oldValue == nil {
  23974. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23975. }
  23976. oldValue, err := m.oldValue(ctx)
  23977. if err != nil {
  23978. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23979. }
  23980. return oldValue.OrganizationID, nil
  23981. }
  23982. // AddOrganizationID adds u to the "organization_id" field.
  23983. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  23984. if m.addorganization_id != nil {
  23985. *m.addorganization_id += u
  23986. } else {
  23987. m.addorganization_id = &u
  23988. }
  23989. }
  23990. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23991. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  23992. v := m.addorganization_id
  23993. if v == nil {
  23994. return
  23995. }
  23996. return *v, true
  23997. }
  23998. // ClearOrganizationID clears the value of the "organization_id" field.
  23999. func (m *UsageDetailMutation) ClearOrganizationID() {
  24000. m.organization_id = nil
  24001. m.addorganization_id = nil
  24002. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  24003. }
  24004. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24005. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  24006. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  24007. return ok
  24008. }
  24009. // ResetOrganizationID resets all changes to the "organization_id" field.
  24010. func (m *UsageDetailMutation) ResetOrganizationID() {
  24011. m.organization_id = nil
  24012. m.addorganization_id = nil
  24013. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  24014. }
  24015. // Where appends a list predicates to the UsageDetailMutation builder.
  24016. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  24017. m.predicates = append(m.predicates, ps...)
  24018. }
  24019. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  24020. // users can use type-assertion to append predicates that do not depend on any generated package.
  24021. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  24022. p := make([]predicate.UsageDetail, len(ps))
  24023. for i := range ps {
  24024. p[i] = ps[i]
  24025. }
  24026. m.Where(p...)
  24027. }
  24028. // Op returns the operation name.
  24029. func (m *UsageDetailMutation) Op() Op {
  24030. return m.op
  24031. }
  24032. // SetOp allows setting the mutation operation.
  24033. func (m *UsageDetailMutation) SetOp(op Op) {
  24034. m.op = op
  24035. }
  24036. // Type returns the node type of this mutation (UsageDetail).
  24037. func (m *UsageDetailMutation) Type() string {
  24038. return m.typ
  24039. }
  24040. // Fields returns all fields that were changed during this mutation. Note that in
  24041. // order to get all numeric fields that were incremented/decremented, call
  24042. // AddedFields().
  24043. func (m *UsageDetailMutation) Fields() []string {
  24044. fields := make([]string, 0, 14)
  24045. if m.created_at != nil {
  24046. fields = append(fields, usagedetail.FieldCreatedAt)
  24047. }
  24048. if m.updated_at != nil {
  24049. fields = append(fields, usagedetail.FieldUpdatedAt)
  24050. }
  24051. if m.status != nil {
  24052. fields = append(fields, usagedetail.FieldStatus)
  24053. }
  24054. if m._type != nil {
  24055. fields = append(fields, usagedetail.FieldType)
  24056. }
  24057. if m.bot_id != nil {
  24058. fields = append(fields, usagedetail.FieldBotID)
  24059. }
  24060. if m.receiver_id != nil {
  24061. fields = append(fields, usagedetail.FieldReceiverID)
  24062. }
  24063. if m.app != nil {
  24064. fields = append(fields, usagedetail.FieldApp)
  24065. }
  24066. if m.session_id != nil {
  24067. fields = append(fields, usagedetail.FieldSessionID)
  24068. }
  24069. if m.request != nil {
  24070. fields = append(fields, usagedetail.FieldRequest)
  24071. }
  24072. if m.response != nil {
  24073. fields = append(fields, usagedetail.FieldResponse)
  24074. }
  24075. if m.total_tokens != nil {
  24076. fields = append(fields, usagedetail.FieldTotalTokens)
  24077. }
  24078. if m.prompt_tokens != nil {
  24079. fields = append(fields, usagedetail.FieldPromptTokens)
  24080. }
  24081. if m.completion_tokens != nil {
  24082. fields = append(fields, usagedetail.FieldCompletionTokens)
  24083. }
  24084. if m.organization_id != nil {
  24085. fields = append(fields, usagedetail.FieldOrganizationID)
  24086. }
  24087. return fields
  24088. }
  24089. // Field returns the value of a field with the given name. The second boolean
  24090. // return value indicates that this field was not set, or was not defined in the
  24091. // schema.
  24092. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  24093. switch name {
  24094. case usagedetail.FieldCreatedAt:
  24095. return m.CreatedAt()
  24096. case usagedetail.FieldUpdatedAt:
  24097. return m.UpdatedAt()
  24098. case usagedetail.FieldStatus:
  24099. return m.Status()
  24100. case usagedetail.FieldType:
  24101. return m.GetType()
  24102. case usagedetail.FieldBotID:
  24103. return m.BotID()
  24104. case usagedetail.FieldReceiverID:
  24105. return m.ReceiverID()
  24106. case usagedetail.FieldApp:
  24107. return m.App()
  24108. case usagedetail.FieldSessionID:
  24109. return m.SessionID()
  24110. case usagedetail.FieldRequest:
  24111. return m.Request()
  24112. case usagedetail.FieldResponse:
  24113. return m.Response()
  24114. case usagedetail.FieldTotalTokens:
  24115. return m.TotalTokens()
  24116. case usagedetail.FieldPromptTokens:
  24117. return m.PromptTokens()
  24118. case usagedetail.FieldCompletionTokens:
  24119. return m.CompletionTokens()
  24120. case usagedetail.FieldOrganizationID:
  24121. return m.OrganizationID()
  24122. }
  24123. return nil, false
  24124. }
  24125. // OldField returns the old value of the field from the database. An error is
  24126. // returned if the mutation operation is not UpdateOne, or the query to the
  24127. // database failed.
  24128. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24129. switch name {
  24130. case usagedetail.FieldCreatedAt:
  24131. return m.OldCreatedAt(ctx)
  24132. case usagedetail.FieldUpdatedAt:
  24133. return m.OldUpdatedAt(ctx)
  24134. case usagedetail.FieldStatus:
  24135. return m.OldStatus(ctx)
  24136. case usagedetail.FieldType:
  24137. return m.OldType(ctx)
  24138. case usagedetail.FieldBotID:
  24139. return m.OldBotID(ctx)
  24140. case usagedetail.FieldReceiverID:
  24141. return m.OldReceiverID(ctx)
  24142. case usagedetail.FieldApp:
  24143. return m.OldApp(ctx)
  24144. case usagedetail.FieldSessionID:
  24145. return m.OldSessionID(ctx)
  24146. case usagedetail.FieldRequest:
  24147. return m.OldRequest(ctx)
  24148. case usagedetail.FieldResponse:
  24149. return m.OldResponse(ctx)
  24150. case usagedetail.FieldTotalTokens:
  24151. return m.OldTotalTokens(ctx)
  24152. case usagedetail.FieldPromptTokens:
  24153. return m.OldPromptTokens(ctx)
  24154. case usagedetail.FieldCompletionTokens:
  24155. return m.OldCompletionTokens(ctx)
  24156. case usagedetail.FieldOrganizationID:
  24157. return m.OldOrganizationID(ctx)
  24158. }
  24159. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  24160. }
  24161. // SetField sets the value of a field with the given name. It returns an error if
  24162. // the field is not defined in the schema, or if the type mismatched the field
  24163. // type.
  24164. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  24165. switch name {
  24166. case usagedetail.FieldCreatedAt:
  24167. v, ok := value.(time.Time)
  24168. if !ok {
  24169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24170. }
  24171. m.SetCreatedAt(v)
  24172. return nil
  24173. case usagedetail.FieldUpdatedAt:
  24174. v, ok := value.(time.Time)
  24175. if !ok {
  24176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24177. }
  24178. m.SetUpdatedAt(v)
  24179. return nil
  24180. case usagedetail.FieldStatus:
  24181. v, ok := value.(uint8)
  24182. if !ok {
  24183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24184. }
  24185. m.SetStatus(v)
  24186. return nil
  24187. case usagedetail.FieldType:
  24188. v, ok := value.(int)
  24189. if !ok {
  24190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24191. }
  24192. m.SetType(v)
  24193. return nil
  24194. case usagedetail.FieldBotID:
  24195. v, ok := value.(string)
  24196. if !ok {
  24197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24198. }
  24199. m.SetBotID(v)
  24200. return nil
  24201. case usagedetail.FieldReceiverID:
  24202. v, ok := value.(string)
  24203. if !ok {
  24204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24205. }
  24206. m.SetReceiverID(v)
  24207. return nil
  24208. case usagedetail.FieldApp:
  24209. v, ok := value.(int)
  24210. if !ok {
  24211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24212. }
  24213. m.SetApp(v)
  24214. return nil
  24215. case usagedetail.FieldSessionID:
  24216. v, ok := value.(uint64)
  24217. if !ok {
  24218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24219. }
  24220. m.SetSessionID(v)
  24221. return nil
  24222. case usagedetail.FieldRequest:
  24223. v, ok := value.(string)
  24224. if !ok {
  24225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24226. }
  24227. m.SetRequest(v)
  24228. return nil
  24229. case usagedetail.FieldResponse:
  24230. v, ok := value.(string)
  24231. if !ok {
  24232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24233. }
  24234. m.SetResponse(v)
  24235. return nil
  24236. case usagedetail.FieldTotalTokens:
  24237. v, ok := value.(uint64)
  24238. if !ok {
  24239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24240. }
  24241. m.SetTotalTokens(v)
  24242. return nil
  24243. case usagedetail.FieldPromptTokens:
  24244. v, ok := value.(uint64)
  24245. if !ok {
  24246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24247. }
  24248. m.SetPromptTokens(v)
  24249. return nil
  24250. case usagedetail.FieldCompletionTokens:
  24251. v, ok := value.(uint64)
  24252. if !ok {
  24253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24254. }
  24255. m.SetCompletionTokens(v)
  24256. return nil
  24257. case usagedetail.FieldOrganizationID:
  24258. v, ok := value.(uint64)
  24259. if !ok {
  24260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24261. }
  24262. m.SetOrganizationID(v)
  24263. return nil
  24264. }
  24265. return fmt.Errorf("unknown UsageDetail field %s", name)
  24266. }
  24267. // AddedFields returns all numeric fields that were incremented/decremented during
  24268. // this mutation.
  24269. func (m *UsageDetailMutation) AddedFields() []string {
  24270. var fields []string
  24271. if m.addstatus != nil {
  24272. fields = append(fields, usagedetail.FieldStatus)
  24273. }
  24274. if m.add_type != nil {
  24275. fields = append(fields, usagedetail.FieldType)
  24276. }
  24277. if m.addapp != nil {
  24278. fields = append(fields, usagedetail.FieldApp)
  24279. }
  24280. if m.addsession_id != nil {
  24281. fields = append(fields, usagedetail.FieldSessionID)
  24282. }
  24283. if m.addtotal_tokens != nil {
  24284. fields = append(fields, usagedetail.FieldTotalTokens)
  24285. }
  24286. if m.addprompt_tokens != nil {
  24287. fields = append(fields, usagedetail.FieldPromptTokens)
  24288. }
  24289. if m.addcompletion_tokens != nil {
  24290. fields = append(fields, usagedetail.FieldCompletionTokens)
  24291. }
  24292. if m.addorganization_id != nil {
  24293. fields = append(fields, usagedetail.FieldOrganizationID)
  24294. }
  24295. return fields
  24296. }
  24297. // AddedField returns the numeric value that was incremented/decremented on a field
  24298. // with the given name. The second boolean return value indicates that this field
  24299. // was not set, or was not defined in the schema.
  24300. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  24301. switch name {
  24302. case usagedetail.FieldStatus:
  24303. return m.AddedStatus()
  24304. case usagedetail.FieldType:
  24305. return m.AddedType()
  24306. case usagedetail.FieldApp:
  24307. return m.AddedApp()
  24308. case usagedetail.FieldSessionID:
  24309. return m.AddedSessionID()
  24310. case usagedetail.FieldTotalTokens:
  24311. return m.AddedTotalTokens()
  24312. case usagedetail.FieldPromptTokens:
  24313. return m.AddedPromptTokens()
  24314. case usagedetail.FieldCompletionTokens:
  24315. return m.AddedCompletionTokens()
  24316. case usagedetail.FieldOrganizationID:
  24317. return m.AddedOrganizationID()
  24318. }
  24319. return nil, false
  24320. }
  24321. // AddField adds the value to the field with the given name. It returns an error if
  24322. // the field is not defined in the schema, or if the type mismatched the field
  24323. // type.
  24324. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  24325. switch name {
  24326. case usagedetail.FieldStatus:
  24327. v, ok := value.(int8)
  24328. if !ok {
  24329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24330. }
  24331. m.AddStatus(v)
  24332. return nil
  24333. case usagedetail.FieldType:
  24334. v, ok := value.(int)
  24335. if !ok {
  24336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24337. }
  24338. m.AddType(v)
  24339. return nil
  24340. case usagedetail.FieldApp:
  24341. v, ok := value.(int)
  24342. if !ok {
  24343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24344. }
  24345. m.AddApp(v)
  24346. return nil
  24347. case usagedetail.FieldSessionID:
  24348. v, ok := value.(int64)
  24349. if !ok {
  24350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24351. }
  24352. m.AddSessionID(v)
  24353. return nil
  24354. case usagedetail.FieldTotalTokens:
  24355. v, ok := value.(int64)
  24356. if !ok {
  24357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24358. }
  24359. m.AddTotalTokens(v)
  24360. return nil
  24361. case usagedetail.FieldPromptTokens:
  24362. v, ok := value.(int64)
  24363. if !ok {
  24364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24365. }
  24366. m.AddPromptTokens(v)
  24367. return nil
  24368. case usagedetail.FieldCompletionTokens:
  24369. v, ok := value.(int64)
  24370. if !ok {
  24371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24372. }
  24373. m.AddCompletionTokens(v)
  24374. return nil
  24375. case usagedetail.FieldOrganizationID:
  24376. v, ok := value.(int64)
  24377. if !ok {
  24378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24379. }
  24380. m.AddOrganizationID(v)
  24381. return nil
  24382. }
  24383. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  24384. }
  24385. // ClearedFields returns all nullable fields that were cleared during this
  24386. // mutation.
  24387. func (m *UsageDetailMutation) ClearedFields() []string {
  24388. var fields []string
  24389. if m.FieldCleared(usagedetail.FieldStatus) {
  24390. fields = append(fields, usagedetail.FieldStatus)
  24391. }
  24392. if m.FieldCleared(usagedetail.FieldType) {
  24393. fields = append(fields, usagedetail.FieldType)
  24394. }
  24395. if m.FieldCleared(usagedetail.FieldApp) {
  24396. fields = append(fields, usagedetail.FieldApp)
  24397. }
  24398. if m.FieldCleared(usagedetail.FieldSessionID) {
  24399. fields = append(fields, usagedetail.FieldSessionID)
  24400. }
  24401. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  24402. fields = append(fields, usagedetail.FieldTotalTokens)
  24403. }
  24404. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  24405. fields = append(fields, usagedetail.FieldPromptTokens)
  24406. }
  24407. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  24408. fields = append(fields, usagedetail.FieldCompletionTokens)
  24409. }
  24410. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  24411. fields = append(fields, usagedetail.FieldOrganizationID)
  24412. }
  24413. return fields
  24414. }
  24415. // FieldCleared returns a boolean indicating if a field with the given name was
  24416. // cleared in this mutation.
  24417. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  24418. _, ok := m.clearedFields[name]
  24419. return ok
  24420. }
  24421. // ClearField clears the value of the field with the given name. It returns an
  24422. // error if the field is not defined in the schema.
  24423. func (m *UsageDetailMutation) ClearField(name string) error {
  24424. switch name {
  24425. case usagedetail.FieldStatus:
  24426. m.ClearStatus()
  24427. return nil
  24428. case usagedetail.FieldType:
  24429. m.ClearType()
  24430. return nil
  24431. case usagedetail.FieldApp:
  24432. m.ClearApp()
  24433. return nil
  24434. case usagedetail.FieldSessionID:
  24435. m.ClearSessionID()
  24436. return nil
  24437. case usagedetail.FieldTotalTokens:
  24438. m.ClearTotalTokens()
  24439. return nil
  24440. case usagedetail.FieldPromptTokens:
  24441. m.ClearPromptTokens()
  24442. return nil
  24443. case usagedetail.FieldCompletionTokens:
  24444. m.ClearCompletionTokens()
  24445. return nil
  24446. case usagedetail.FieldOrganizationID:
  24447. m.ClearOrganizationID()
  24448. return nil
  24449. }
  24450. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  24451. }
  24452. // ResetField resets all changes in the mutation for the field with the given name.
  24453. // It returns an error if the field is not defined in the schema.
  24454. func (m *UsageDetailMutation) ResetField(name string) error {
  24455. switch name {
  24456. case usagedetail.FieldCreatedAt:
  24457. m.ResetCreatedAt()
  24458. return nil
  24459. case usagedetail.FieldUpdatedAt:
  24460. m.ResetUpdatedAt()
  24461. return nil
  24462. case usagedetail.FieldStatus:
  24463. m.ResetStatus()
  24464. return nil
  24465. case usagedetail.FieldType:
  24466. m.ResetType()
  24467. return nil
  24468. case usagedetail.FieldBotID:
  24469. m.ResetBotID()
  24470. return nil
  24471. case usagedetail.FieldReceiverID:
  24472. m.ResetReceiverID()
  24473. return nil
  24474. case usagedetail.FieldApp:
  24475. m.ResetApp()
  24476. return nil
  24477. case usagedetail.FieldSessionID:
  24478. m.ResetSessionID()
  24479. return nil
  24480. case usagedetail.FieldRequest:
  24481. m.ResetRequest()
  24482. return nil
  24483. case usagedetail.FieldResponse:
  24484. m.ResetResponse()
  24485. return nil
  24486. case usagedetail.FieldTotalTokens:
  24487. m.ResetTotalTokens()
  24488. return nil
  24489. case usagedetail.FieldPromptTokens:
  24490. m.ResetPromptTokens()
  24491. return nil
  24492. case usagedetail.FieldCompletionTokens:
  24493. m.ResetCompletionTokens()
  24494. return nil
  24495. case usagedetail.FieldOrganizationID:
  24496. m.ResetOrganizationID()
  24497. return nil
  24498. }
  24499. return fmt.Errorf("unknown UsageDetail field %s", name)
  24500. }
  24501. // AddedEdges returns all edge names that were set/added in this mutation.
  24502. func (m *UsageDetailMutation) AddedEdges() []string {
  24503. edges := make([]string, 0, 0)
  24504. return edges
  24505. }
  24506. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24507. // name in this mutation.
  24508. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  24509. return nil
  24510. }
  24511. // RemovedEdges returns all edge names that were removed in this mutation.
  24512. func (m *UsageDetailMutation) RemovedEdges() []string {
  24513. edges := make([]string, 0, 0)
  24514. return edges
  24515. }
  24516. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24517. // the given name in this mutation.
  24518. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  24519. return nil
  24520. }
  24521. // ClearedEdges returns all edge names that were cleared in this mutation.
  24522. func (m *UsageDetailMutation) ClearedEdges() []string {
  24523. edges := make([]string, 0, 0)
  24524. return edges
  24525. }
  24526. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24527. // was cleared in this mutation.
  24528. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  24529. return false
  24530. }
  24531. // ClearEdge clears the value of the edge with the given name. It returns an error
  24532. // if that edge is not defined in the schema.
  24533. func (m *UsageDetailMutation) ClearEdge(name string) error {
  24534. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  24535. }
  24536. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24537. // It returns an error if the edge is not defined in the schema.
  24538. func (m *UsageDetailMutation) ResetEdge(name string) error {
  24539. return fmt.Errorf("unknown UsageDetail edge %s", name)
  24540. }
  24541. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  24542. type UsageTotalMutation struct {
  24543. config
  24544. op Op
  24545. typ string
  24546. id *uint64
  24547. created_at *time.Time
  24548. updated_at *time.Time
  24549. status *uint8
  24550. addstatus *int8
  24551. _type *int
  24552. add_type *int
  24553. bot_id *string
  24554. total_tokens *uint64
  24555. addtotal_tokens *int64
  24556. start_index *uint64
  24557. addstart_index *int64
  24558. end_index *uint64
  24559. addend_index *int64
  24560. organization_id *uint64
  24561. addorganization_id *int64
  24562. clearedFields map[string]struct{}
  24563. done bool
  24564. oldValue func(context.Context) (*UsageTotal, error)
  24565. predicates []predicate.UsageTotal
  24566. }
  24567. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  24568. // usagetotalOption allows management of the mutation configuration using functional options.
  24569. type usagetotalOption func(*UsageTotalMutation)
  24570. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  24571. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  24572. m := &UsageTotalMutation{
  24573. config: c,
  24574. op: op,
  24575. typ: TypeUsageTotal,
  24576. clearedFields: make(map[string]struct{}),
  24577. }
  24578. for _, opt := range opts {
  24579. opt(m)
  24580. }
  24581. return m
  24582. }
  24583. // withUsageTotalID sets the ID field of the mutation.
  24584. func withUsageTotalID(id uint64) usagetotalOption {
  24585. return func(m *UsageTotalMutation) {
  24586. var (
  24587. err error
  24588. once sync.Once
  24589. value *UsageTotal
  24590. )
  24591. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  24592. once.Do(func() {
  24593. if m.done {
  24594. err = errors.New("querying old values post mutation is not allowed")
  24595. } else {
  24596. value, err = m.Client().UsageTotal.Get(ctx, id)
  24597. }
  24598. })
  24599. return value, err
  24600. }
  24601. m.id = &id
  24602. }
  24603. }
  24604. // withUsageTotal sets the old UsageTotal of the mutation.
  24605. func withUsageTotal(node *UsageTotal) usagetotalOption {
  24606. return func(m *UsageTotalMutation) {
  24607. m.oldValue = func(context.Context) (*UsageTotal, error) {
  24608. return node, nil
  24609. }
  24610. m.id = &node.ID
  24611. }
  24612. }
  24613. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24614. // executed in a transaction (ent.Tx), a transactional client is returned.
  24615. func (m UsageTotalMutation) Client() *Client {
  24616. client := &Client{config: m.config}
  24617. client.init()
  24618. return client
  24619. }
  24620. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24621. // it returns an error otherwise.
  24622. func (m UsageTotalMutation) Tx() (*Tx, error) {
  24623. if _, ok := m.driver.(*txDriver); !ok {
  24624. return nil, errors.New("ent: mutation is not running in a transaction")
  24625. }
  24626. tx := &Tx{config: m.config}
  24627. tx.init()
  24628. return tx, nil
  24629. }
  24630. // SetID sets the value of the id field. Note that this
  24631. // operation is only accepted on creation of UsageTotal entities.
  24632. func (m *UsageTotalMutation) SetID(id uint64) {
  24633. m.id = &id
  24634. }
  24635. // ID returns the ID value in the mutation. Note that the ID is only available
  24636. // if it was provided to the builder or after it was returned from the database.
  24637. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  24638. if m.id == nil {
  24639. return
  24640. }
  24641. return *m.id, true
  24642. }
  24643. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24644. // That means, if the mutation is applied within a transaction with an isolation level such
  24645. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24646. // or updated by the mutation.
  24647. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  24648. switch {
  24649. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24650. id, exists := m.ID()
  24651. if exists {
  24652. return []uint64{id}, nil
  24653. }
  24654. fallthrough
  24655. case m.op.Is(OpUpdate | OpDelete):
  24656. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  24657. default:
  24658. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24659. }
  24660. }
  24661. // SetCreatedAt sets the "created_at" field.
  24662. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  24663. m.created_at = &t
  24664. }
  24665. // CreatedAt returns the value of the "created_at" field in the mutation.
  24666. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  24667. v := m.created_at
  24668. if v == nil {
  24669. return
  24670. }
  24671. return *v, true
  24672. }
  24673. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  24674. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24676. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24677. if !m.op.Is(OpUpdateOne) {
  24678. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24679. }
  24680. if m.id == nil || m.oldValue == nil {
  24681. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24682. }
  24683. oldValue, err := m.oldValue(ctx)
  24684. if err != nil {
  24685. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24686. }
  24687. return oldValue.CreatedAt, nil
  24688. }
  24689. // ResetCreatedAt resets all changes to the "created_at" field.
  24690. func (m *UsageTotalMutation) ResetCreatedAt() {
  24691. m.created_at = nil
  24692. }
  24693. // SetUpdatedAt sets the "updated_at" field.
  24694. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  24695. m.updated_at = &t
  24696. }
  24697. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24698. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  24699. v := m.updated_at
  24700. if v == nil {
  24701. return
  24702. }
  24703. return *v, true
  24704. }
  24705. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  24706. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24708. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24709. if !m.op.Is(OpUpdateOne) {
  24710. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24711. }
  24712. if m.id == nil || m.oldValue == nil {
  24713. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24714. }
  24715. oldValue, err := m.oldValue(ctx)
  24716. if err != nil {
  24717. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24718. }
  24719. return oldValue.UpdatedAt, nil
  24720. }
  24721. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24722. func (m *UsageTotalMutation) ResetUpdatedAt() {
  24723. m.updated_at = nil
  24724. }
  24725. // SetStatus sets the "status" field.
  24726. func (m *UsageTotalMutation) SetStatus(u uint8) {
  24727. m.status = &u
  24728. m.addstatus = nil
  24729. }
  24730. // Status returns the value of the "status" field in the mutation.
  24731. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  24732. v := m.status
  24733. if v == nil {
  24734. return
  24735. }
  24736. return *v, true
  24737. }
  24738. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  24739. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24741. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24742. if !m.op.Is(OpUpdateOne) {
  24743. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24744. }
  24745. if m.id == nil || m.oldValue == nil {
  24746. return v, errors.New("OldStatus requires an ID field in the mutation")
  24747. }
  24748. oldValue, err := m.oldValue(ctx)
  24749. if err != nil {
  24750. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24751. }
  24752. return oldValue.Status, nil
  24753. }
  24754. // AddStatus adds u to the "status" field.
  24755. func (m *UsageTotalMutation) AddStatus(u int8) {
  24756. if m.addstatus != nil {
  24757. *m.addstatus += u
  24758. } else {
  24759. m.addstatus = &u
  24760. }
  24761. }
  24762. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24763. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  24764. v := m.addstatus
  24765. if v == nil {
  24766. return
  24767. }
  24768. return *v, true
  24769. }
  24770. // ClearStatus clears the value of the "status" field.
  24771. func (m *UsageTotalMutation) ClearStatus() {
  24772. m.status = nil
  24773. m.addstatus = nil
  24774. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  24775. }
  24776. // StatusCleared returns if the "status" field was cleared in this mutation.
  24777. func (m *UsageTotalMutation) StatusCleared() bool {
  24778. _, ok := m.clearedFields[usagetotal.FieldStatus]
  24779. return ok
  24780. }
  24781. // ResetStatus resets all changes to the "status" field.
  24782. func (m *UsageTotalMutation) ResetStatus() {
  24783. m.status = nil
  24784. m.addstatus = nil
  24785. delete(m.clearedFields, usagetotal.FieldStatus)
  24786. }
  24787. // SetType sets the "type" field.
  24788. func (m *UsageTotalMutation) SetType(i int) {
  24789. m._type = &i
  24790. m.add_type = nil
  24791. }
  24792. // GetType returns the value of the "type" field in the mutation.
  24793. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  24794. v := m._type
  24795. if v == nil {
  24796. return
  24797. }
  24798. return *v, true
  24799. }
  24800. // OldType returns the old "type" field's value of the UsageTotal entity.
  24801. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24803. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  24804. if !m.op.Is(OpUpdateOne) {
  24805. return v, errors.New("OldType is only allowed on UpdateOne operations")
  24806. }
  24807. if m.id == nil || m.oldValue == nil {
  24808. return v, errors.New("OldType requires an ID field in the mutation")
  24809. }
  24810. oldValue, err := m.oldValue(ctx)
  24811. if err != nil {
  24812. return v, fmt.Errorf("querying old value for OldType: %w", err)
  24813. }
  24814. return oldValue.Type, nil
  24815. }
  24816. // AddType adds i to the "type" field.
  24817. func (m *UsageTotalMutation) AddType(i int) {
  24818. if m.add_type != nil {
  24819. *m.add_type += i
  24820. } else {
  24821. m.add_type = &i
  24822. }
  24823. }
  24824. // AddedType returns the value that was added to the "type" field in this mutation.
  24825. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  24826. v := m.add_type
  24827. if v == nil {
  24828. return
  24829. }
  24830. return *v, true
  24831. }
  24832. // ClearType clears the value of the "type" field.
  24833. func (m *UsageTotalMutation) ClearType() {
  24834. m._type = nil
  24835. m.add_type = nil
  24836. m.clearedFields[usagetotal.FieldType] = struct{}{}
  24837. }
  24838. // TypeCleared returns if the "type" field was cleared in this mutation.
  24839. func (m *UsageTotalMutation) TypeCleared() bool {
  24840. _, ok := m.clearedFields[usagetotal.FieldType]
  24841. return ok
  24842. }
  24843. // ResetType resets all changes to the "type" field.
  24844. func (m *UsageTotalMutation) ResetType() {
  24845. m._type = nil
  24846. m.add_type = nil
  24847. delete(m.clearedFields, usagetotal.FieldType)
  24848. }
  24849. // SetBotID sets the "bot_id" field.
  24850. func (m *UsageTotalMutation) SetBotID(s string) {
  24851. m.bot_id = &s
  24852. }
  24853. // BotID returns the value of the "bot_id" field in the mutation.
  24854. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  24855. v := m.bot_id
  24856. if v == nil {
  24857. return
  24858. }
  24859. return *v, true
  24860. }
  24861. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  24862. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24864. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  24865. if !m.op.Is(OpUpdateOne) {
  24866. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  24867. }
  24868. if m.id == nil || m.oldValue == nil {
  24869. return v, errors.New("OldBotID requires an ID field in the mutation")
  24870. }
  24871. oldValue, err := m.oldValue(ctx)
  24872. if err != nil {
  24873. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  24874. }
  24875. return oldValue.BotID, nil
  24876. }
  24877. // ResetBotID resets all changes to the "bot_id" field.
  24878. func (m *UsageTotalMutation) ResetBotID() {
  24879. m.bot_id = nil
  24880. }
  24881. // SetTotalTokens sets the "total_tokens" field.
  24882. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  24883. m.total_tokens = &u
  24884. m.addtotal_tokens = nil
  24885. }
  24886. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  24887. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  24888. v := m.total_tokens
  24889. if v == nil {
  24890. return
  24891. }
  24892. return *v, true
  24893. }
  24894. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  24895. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24897. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  24898. if !m.op.Is(OpUpdateOne) {
  24899. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  24900. }
  24901. if m.id == nil || m.oldValue == nil {
  24902. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  24903. }
  24904. oldValue, err := m.oldValue(ctx)
  24905. if err != nil {
  24906. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  24907. }
  24908. return oldValue.TotalTokens, nil
  24909. }
  24910. // AddTotalTokens adds u to the "total_tokens" field.
  24911. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  24912. if m.addtotal_tokens != nil {
  24913. *m.addtotal_tokens += u
  24914. } else {
  24915. m.addtotal_tokens = &u
  24916. }
  24917. }
  24918. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  24919. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  24920. v := m.addtotal_tokens
  24921. if v == nil {
  24922. return
  24923. }
  24924. return *v, true
  24925. }
  24926. // ClearTotalTokens clears the value of the "total_tokens" field.
  24927. func (m *UsageTotalMutation) ClearTotalTokens() {
  24928. m.total_tokens = nil
  24929. m.addtotal_tokens = nil
  24930. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  24931. }
  24932. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  24933. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  24934. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  24935. return ok
  24936. }
  24937. // ResetTotalTokens resets all changes to the "total_tokens" field.
  24938. func (m *UsageTotalMutation) ResetTotalTokens() {
  24939. m.total_tokens = nil
  24940. m.addtotal_tokens = nil
  24941. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  24942. }
  24943. // SetStartIndex sets the "start_index" field.
  24944. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  24945. m.start_index = &u
  24946. m.addstart_index = nil
  24947. }
  24948. // StartIndex returns the value of the "start_index" field in the mutation.
  24949. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  24950. v := m.start_index
  24951. if v == nil {
  24952. return
  24953. }
  24954. return *v, true
  24955. }
  24956. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  24957. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24959. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  24960. if !m.op.Is(OpUpdateOne) {
  24961. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  24962. }
  24963. if m.id == nil || m.oldValue == nil {
  24964. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  24965. }
  24966. oldValue, err := m.oldValue(ctx)
  24967. if err != nil {
  24968. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  24969. }
  24970. return oldValue.StartIndex, nil
  24971. }
  24972. // AddStartIndex adds u to the "start_index" field.
  24973. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  24974. if m.addstart_index != nil {
  24975. *m.addstart_index += u
  24976. } else {
  24977. m.addstart_index = &u
  24978. }
  24979. }
  24980. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  24981. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  24982. v := m.addstart_index
  24983. if v == nil {
  24984. return
  24985. }
  24986. return *v, true
  24987. }
  24988. // ClearStartIndex clears the value of the "start_index" field.
  24989. func (m *UsageTotalMutation) ClearStartIndex() {
  24990. m.start_index = nil
  24991. m.addstart_index = nil
  24992. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  24993. }
  24994. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  24995. func (m *UsageTotalMutation) StartIndexCleared() bool {
  24996. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  24997. return ok
  24998. }
  24999. // ResetStartIndex resets all changes to the "start_index" field.
  25000. func (m *UsageTotalMutation) ResetStartIndex() {
  25001. m.start_index = nil
  25002. m.addstart_index = nil
  25003. delete(m.clearedFields, usagetotal.FieldStartIndex)
  25004. }
  25005. // SetEndIndex sets the "end_index" field.
  25006. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  25007. m.end_index = &u
  25008. m.addend_index = nil
  25009. }
  25010. // EndIndex returns the value of the "end_index" field in the mutation.
  25011. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  25012. v := m.end_index
  25013. if v == nil {
  25014. return
  25015. }
  25016. return *v, true
  25017. }
  25018. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  25019. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  25020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25021. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  25022. if !m.op.Is(OpUpdateOne) {
  25023. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  25024. }
  25025. if m.id == nil || m.oldValue == nil {
  25026. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  25027. }
  25028. oldValue, err := m.oldValue(ctx)
  25029. if err != nil {
  25030. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  25031. }
  25032. return oldValue.EndIndex, nil
  25033. }
  25034. // AddEndIndex adds u to the "end_index" field.
  25035. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  25036. if m.addend_index != nil {
  25037. *m.addend_index += u
  25038. } else {
  25039. m.addend_index = &u
  25040. }
  25041. }
  25042. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  25043. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  25044. v := m.addend_index
  25045. if v == nil {
  25046. return
  25047. }
  25048. return *v, true
  25049. }
  25050. // ClearEndIndex clears the value of the "end_index" field.
  25051. func (m *UsageTotalMutation) ClearEndIndex() {
  25052. m.end_index = nil
  25053. m.addend_index = nil
  25054. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  25055. }
  25056. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  25057. func (m *UsageTotalMutation) EndIndexCleared() bool {
  25058. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  25059. return ok
  25060. }
  25061. // ResetEndIndex resets all changes to the "end_index" field.
  25062. func (m *UsageTotalMutation) ResetEndIndex() {
  25063. m.end_index = nil
  25064. m.addend_index = nil
  25065. delete(m.clearedFields, usagetotal.FieldEndIndex)
  25066. }
  25067. // SetOrganizationID sets the "organization_id" field.
  25068. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  25069. m.organization_id = &u
  25070. m.addorganization_id = nil
  25071. }
  25072. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25073. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  25074. v := m.organization_id
  25075. if v == nil {
  25076. return
  25077. }
  25078. return *v, true
  25079. }
  25080. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  25081. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  25082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25083. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25084. if !m.op.Is(OpUpdateOne) {
  25085. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25086. }
  25087. if m.id == nil || m.oldValue == nil {
  25088. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25089. }
  25090. oldValue, err := m.oldValue(ctx)
  25091. if err != nil {
  25092. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25093. }
  25094. return oldValue.OrganizationID, nil
  25095. }
  25096. // AddOrganizationID adds u to the "organization_id" field.
  25097. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  25098. if m.addorganization_id != nil {
  25099. *m.addorganization_id += u
  25100. } else {
  25101. m.addorganization_id = &u
  25102. }
  25103. }
  25104. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25105. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  25106. v := m.addorganization_id
  25107. if v == nil {
  25108. return
  25109. }
  25110. return *v, true
  25111. }
  25112. // ClearOrganizationID clears the value of the "organization_id" field.
  25113. func (m *UsageTotalMutation) ClearOrganizationID() {
  25114. m.organization_id = nil
  25115. m.addorganization_id = nil
  25116. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  25117. }
  25118. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  25119. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  25120. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  25121. return ok
  25122. }
  25123. // ResetOrganizationID resets all changes to the "organization_id" field.
  25124. func (m *UsageTotalMutation) ResetOrganizationID() {
  25125. m.organization_id = nil
  25126. m.addorganization_id = nil
  25127. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  25128. }
  25129. // Where appends a list predicates to the UsageTotalMutation builder.
  25130. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  25131. m.predicates = append(m.predicates, ps...)
  25132. }
  25133. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  25134. // users can use type-assertion to append predicates that do not depend on any generated package.
  25135. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  25136. p := make([]predicate.UsageTotal, len(ps))
  25137. for i := range ps {
  25138. p[i] = ps[i]
  25139. }
  25140. m.Where(p...)
  25141. }
  25142. // Op returns the operation name.
  25143. func (m *UsageTotalMutation) Op() Op {
  25144. return m.op
  25145. }
  25146. // SetOp allows setting the mutation operation.
  25147. func (m *UsageTotalMutation) SetOp(op Op) {
  25148. m.op = op
  25149. }
  25150. // Type returns the node type of this mutation (UsageTotal).
  25151. func (m *UsageTotalMutation) Type() string {
  25152. return m.typ
  25153. }
  25154. // Fields returns all fields that were changed during this mutation. Note that in
  25155. // order to get all numeric fields that were incremented/decremented, call
  25156. // AddedFields().
  25157. func (m *UsageTotalMutation) Fields() []string {
  25158. fields := make([]string, 0, 9)
  25159. if m.created_at != nil {
  25160. fields = append(fields, usagetotal.FieldCreatedAt)
  25161. }
  25162. if m.updated_at != nil {
  25163. fields = append(fields, usagetotal.FieldUpdatedAt)
  25164. }
  25165. if m.status != nil {
  25166. fields = append(fields, usagetotal.FieldStatus)
  25167. }
  25168. if m._type != nil {
  25169. fields = append(fields, usagetotal.FieldType)
  25170. }
  25171. if m.bot_id != nil {
  25172. fields = append(fields, usagetotal.FieldBotID)
  25173. }
  25174. if m.total_tokens != nil {
  25175. fields = append(fields, usagetotal.FieldTotalTokens)
  25176. }
  25177. if m.start_index != nil {
  25178. fields = append(fields, usagetotal.FieldStartIndex)
  25179. }
  25180. if m.end_index != nil {
  25181. fields = append(fields, usagetotal.FieldEndIndex)
  25182. }
  25183. if m.organization_id != nil {
  25184. fields = append(fields, usagetotal.FieldOrganizationID)
  25185. }
  25186. return fields
  25187. }
  25188. // Field returns the value of a field with the given name. The second boolean
  25189. // return value indicates that this field was not set, or was not defined in the
  25190. // schema.
  25191. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  25192. switch name {
  25193. case usagetotal.FieldCreatedAt:
  25194. return m.CreatedAt()
  25195. case usagetotal.FieldUpdatedAt:
  25196. return m.UpdatedAt()
  25197. case usagetotal.FieldStatus:
  25198. return m.Status()
  25199. case usagetotal.FieldType:
  25200. return m.GetType()
  25201. case usagetotal.FieldBotID:
  25202. return m.BotID()
  25203. case usagetotal.FieldTotalTokens:
  25204. return m.TotalTokens()
  25205. case usagetotal.FieldStartIndex:
  25206. return m.StartIndex()
  25207. case usagetotal.FieldEndIndex:
  25208. return m.EndIndex()
  25209. case usagetotal.FieldOrganizationID:
  25210. return m.OrganizationID()
  25211. }
  25212. return nil, false
  25213. }
  25214. // OldField returns the old value of the field from the database. An error is
  25215. // returned if the mutation operation is not UpdateOne, or the query to the
  25216. // database failed.
  25217. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25218. switch name {
  25219. case usagetotal.FieldCreatedAt:
  25220. return m.OldCreatedAt(ctx)
  25221. case usagetotal.FieldUpdatedAt:
  25222. return m.OldUpdatedAt(ctx)
  25223. case usagetotal.FieldStatus:
  25224. return m.OldStatus(ctx)
  25225. case usagetotal.FieldType:
  25226. return m.OldType(ctx)
  25227. case usagetotal.FieldBotID:
  25228. return m.OldBotID(ctx)
  25229. case usagetotal.FieldTotalTokens:
  25230. return m.OldTotalTokens(ctx)
  25231. case usagetotal.FieldStartIndex:
  25232. return m.OldStartIndex(ctx)
  25233. case usagetotal.FieldEndIndex:
  25234. return m.OldEndIndex(ctx)
  25235. case usagetotal.FieldOrganizationID:
  25236. return m.OldOrganizationID(ctx)
  25237. }
  25238. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  25239. }
  25240. // SetField sets the value of a field with the given name. It returns an error if
  25241. // the field is not defined in the schema, or if the type mismatched the field
  25242. // type.
  25243. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  25244. switch name {
  25245. case usagetotal.FieldCreatedAt:
  25246. v, ok := value.(time.Time)
  25247. if !ok {
  25248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25249. }
  25250. m.SetCreatedAt(v)
  25251. return nil
  25252. case usagetotal.FieldUpdatedAt:
  25253. v, ok := value.(time.Time)
  25254. if !ok {
  25255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25256. }
  25257. m.SetUpdatedAt(v)
  25258. return nil
  25259. case usagetotal.FieldStatus:
  25260. v, ok := value.(uint8)
  25261. if !ok {
  25262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25263. }
  25264. m.SetStatus(v)
  25265. return nil
  25266. case usagetotal.FieldType:
  25267. v, ok := value.(int)
  25268. if !ok {
  25269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25270. }
  25271. m.SetType(v)
  25272. return nil
  25273. case usagetotal.FieldBotID:
  25274. v, ok := value.(string)
  25275. if !ok {
  25276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25277. }
  25278. m.SetBotID(v)
  25279. return nil
  25280. case usagetotal.FieldTotalTokens:
  25281. v, ok := value.(uint64)
  25282. if !ok {
  25283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25284. }
  25285. m.SetTotalTokens(v)
  25286. return nil
  25287. case usagetotal.FieldStartIndex:
  25288. v, ok := value.(uint64)
  25289. if !ok {
  25290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25291. }
  25292. m.SetStartIndex(v)
  25293. return nil
  25294. case usagetotal.FieldEndIndex:
  25295. v, ok := value.(uint64)
  25296. if !ok {
  25297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25298. }
  25299. m.SetEndIndex(v)
  25300. return nil
  25301. case usagetotal.FieldOrganizationID:
  25302. v, ok := value.(uint64)
  25303. if !ok {
  25304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25305. }
  25306. m.SetOrganizationID(v)
  25307. return nil
  25308. }
  25309. return fmt.Errorf("unknown UsageTotal field %s", name)
  25310. }
  25311. // AddedFields returns all numeric fields that were incremented/decremented during
  25312. // this mutation.
  25313. func (m *UsageTotalMutation) AddedFields() []string {
  25314. var fields []string
  25315. if m.addstatus != nil {
  25316. fields = append(fields, usagetotal.FieldStatus)
  25317. }
  25318. if m.add_type != nil {
  25319. fields = append(fields, usagetotal.FieldType)
  25320. }
  25321. if m.addtotal_tokens != nil {
  25322. fields = append(fields, usagetotal.FieldTotalTokens)
  25323. }
  25324. if m.addstart_index != nil {
  25325. fields = append(fields, usagetotal.FieldStartIndex)
  25326. }
  25327. if m.addend_index != nil {
  25328. fields = append(fields, usagetotal.FieldEndIndex)
  25329. }
  25330. if m.addorganization_id != nil {
  25331. fields = append(fields, usagetotal.FieldOrganizationID)
  25332. }
  25333. return fields
  25334. }
  25335. // AddedField returns the numeric value that was incremented/decremented on a field
  25336. // with the given name. The second boolean return value indicates that this field
  25337. // was not set, or was not defined in the schema.
  25338. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  25339. switch name {
  25340. case usagetotal.FieldStatus:
  25341. return m.AddedStatus()
  25342. case usagetotal.FieldType:
  25343. return m.AddedType()
  25344. case usagetotal.FieldTotalTokens:
  25345. return m.AddedTotalTokens()
  25346. case usagetotal.FieldStartIndex:
  25347. return m.AddedStartIndex()
  25348. case usagetotal.FieldEndIndex:
  25349. return m.AddedEndIndex()
  25350. case usagetotal.FieldOrganizationID:
  25351. return m.AddedOrganizationID()
  25352. }
  25353. return nil, false
  25354. }
  25355. // AddField adds the value to the field with the given name. It returns an error if
  25356. // the field is not defined in the schema, or if the type mismatched the field
  25357. // type.
  25358. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  25359. switch name {
  25360. case usagetotal.FieldStatus:
  25361. v, ok := value.(int8)
  25362. if !ok {
  25363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25364. }
  25365. m.AddStatus(v)
  25366. return nil
  25367. case usagetotal.FieldType:
  25368. v, ok := value.(int)
  25369. if !ok {
  25370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25371. }
  25372. m.AddType(v)
  25373. return nil
  25374. case usagetotal.FieldTotalTokens:
  25375. v, ok := value.(int64)
  25376. if !ok {
  25377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25378. }
  25379. m.AddTotalTokens(v)
  25380. return nil
  25381. case usagetotal.FieldStartIndex:
  25382. v, ok := value.(int64)
  25383. if !ok {
  25384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25385. }
  25386. m.AddStartIndex(v)
  25387. return nil
  25388. case usagetotal.FieldEndIndex:
  25389. v, ok := value.(int64)
  25390. if !ok {
  25391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25392. }
  25393. m.AddEndIndex(v)
  25394. return nil
  25395. case usagetotal.FieldOrganizationID:
  25396. v, ok := value.(int64)
  25397. if !ok {
  25398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25399. }
  25400. m.AddOrganizationID(v)
  25401. return nil
  25402. }
  25403. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  25404. }
  25405. // ClearedFields returns all nullable fields that were cleared during this
  25406. // mutation.
  25407. func (m *UsageTotalMutation) ClearedFields() []string {
  25408. var fields []string
  25409. if m.FieldCleared(usagetotal.FieldStatus) {
  25410. fields = append(fields, usagetotal.FieldStatus)
  25411. }
  25412. if m.FieldCleared(usagetotal.FieldType) {
  25413. fields = append(fields, usagetotal.FieldType)
  25414. }
  25415. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  25416. fields = append(fields, usagetotal.FieldTotalTokens)
  25417. }
  25418. if m.FieldCleared(usagetotal.FieldStartIndex) {
  25419. fields = append(fields, usagetotal.FieldStartIndex)
  25420. }
  25421. if m.FieldCleared(usagetotal.FieldEndIndex) {
  25422. fields = append(fields, usagetotal.FieldEndIndex)
  25423. }
  25424. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  25425. fields = append(fields, usagetotal.FieldOrganizationID)
  25426. }
  25427. return fields
  25428. }
  25429. // FieldCleared returns a boolean indicating if a field with the given name was
  25430. // cleared in this mutation.
  25431. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  25432. _, ok := m.clearedFields[name]
  25433. return ok
  25434. }
  25435. // ClearField clears the value of the field with the given name. It returns an
  25436. // error if the field is not defined in the schema.
  25437. func (m *UsageTotalMutation) ClearField(name string) error {
  25438. switch name {
  25439. case usagetotal.FieldStatus:
  25440. m.ClearStatus()
  25441. return nil
  25442. case usagetotal.FieldType:
  25443. m.ClearType()
  25444. return nil
  25445. case usagetotal.FieldTotalTokens:
  25446. m.ClearTotalTokens()
  25447. return nil
  25448. case usagetotal.FieldStartIndex:
  25449. m.ClearStartIndex()
  25450. return nil
  25451. case usagetotal.FieldEndIndex:
  25452. m.ClearEndIndex()
  25453. return nil
  25454. case usagetotal.FieldOrganizationID:
  25455. m.ClearOrganizationID()
  25456. return nil
  25457. }
  25458. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  25459. }
  25460. // ResetField resets all changes in the mutation for the field with the given name.
  25461. // It returns an error if the field is not defined in the schema.
  25462. func (m *UsageTotalMutation) ResetField(name string) error {
  25463. switch name {
  25464. case usagetotal.FieldCreatedAt:
  25465. m.ResetCreatedAt()
  25466. return nil
  25467. case usagetotal.FieldUpdatedAt:
  25468. m.ResetUpdatedAt()
  25469. return nil
  25470. case usagetotal.FieldStatus:
  25471. m.ResetStatus()
  25472. return nil
  25473. case usagetotal.FieldType:
  25474. m.ResetType()
  25475. return nil
  25476. case usagetotal.FieldBotID:
  25477. m.ResetBotID()
  25478. return nil
  25479. case usagetotal.FieldTotalTokens:
  25480. m.ResetTotalTokens()
  25481. return nil
  25482. case usagetotal.FieldStartIndex:
  25483. m.ResetStartIndex()
  25484. return nil
  25485. case usagetotal.FieldEndIndex:
  25486. m.ResetEndIndex()
  25487. return nil
  25488. case usagetotal.FieldOrganizationID:
  25489. m.ResetOrganizationID()
  25490. return nil
  25491. }
  25492. return fmt.Errorf("unknown UsageTotal field %s", name)
  25493. }
  25494. // AddedEdges returns all edge names that were set/added in this mutation.
  25495. func (m *UsageTotalMutation) AddedEdges() []string {
  25496. edges := make([]string, 0, 0)
  25497. return edges
  25498. }
  25499. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25500. // name in this mutation.
  25501. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  25502. return nil
  25503. }
  25504. // RemovedEdges returns all edge names that were removed in this mutation.
  25505. func (m *UsageTotalMutation) RemovedEdges() []string {
  25506. edges := make([]string, 0, 0)
  25507. return edges
  25508. }
  25509. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25510. // the given name in this mutation.
  25511. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  25512. return nil
  25513. }
  25514. // ClearedEdges returns all edge names that were cleared in this mutation.
  25515. func (m *UsageTotalMutation) ClearedEdges() []string {
  25516. edges := make([]string, 0, 0)
  25517. return edges
  25518. }
  25519. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25520. // was cleared in this mutation.
  25521. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  25522. return false
  25523. }
  25524. // ClearEdge clears the value of the edge with the given name. It returns an error
  25525. // if that edge is not defined in the schema.
  25526. func (m *UsageTotalMutation) ClearEdge(name string) error {
  25527. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  25528. }
  25529. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25530. // It returns an error if the edge is not defined in the schema.
  25531. func (m *UsageTotalMutation) ResetEdge(name string) error {
  25532. return fmt.Errorf("unknown UsageTotal edge %s", name)
  25533. }
  25534. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  25535. type WorkExperienceMutation struct {
  25536. config
  25537. op Op
  25538. typ string
  25539. id *uint64
  25540. created_at *time.Time
  25541. updated_at *time.Time
  25542. deleted_at *time.Time
  25543. start_date *time.Time
  25544. end_date *time.Time
  25545. company *string
  25546. experience *string
  25547. organization_id *uint64
  25548. addorganization_id *int64
  25549. clearedFields map[string]struct{}
  25550. employee *uint64
  25551. clearedemployee bool
  25552. done bool
  25553. oldValue func(context.Context) (*WorkExperience, error)
  25554. predicates []predicate.WorkExperience
  25555. }
  25556. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  25557. // workexperienceOption allows management of the mutation configuration using functional options.
  25558. type workexperienceOption func(*WorkExperienceMutation)
  25559. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  25560. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  25561. m := &WorkExperienceMutation{
  25562. config: c,
  25563. op: op,
  25564. typ: TypeWorkExperience,
  25565. clearedFields: make(map[string]struct{}),
  25566. }
  25567. for _, opt := range opts {
  25568. opt(m)
  25569. }
  25570. return m
  25571. }
  25572. // withWorkExperienceID sets the ID field of the mutation.
  25573. func withWorkExperienceID(id uint64) workexperienceOption {
  25574. return func(m *WorkExperienceMutation) {
  25575. var (
  25576. err error
  25577. once sync.Once
  25578. value *WorkExperience
  25579. )
  25580. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  25581. once.Do(func() {
  25582. if m.done {
  25583. err = errors.New("querying old values post mutation is not allowed")
  25584. } else {
  25585. value, err = m.Client().WorkExperience.Get(ctx, id)
  25586. }
  25587. })
  25588. return value, err
  25589. }
  25590. m.id = &id
  25591. }
  25592. }
  25593. // withWorkExperience sets the old WorkExperience of the mutation.
  25594. func withWorkExperience(node *WorkExperience) workexperienceOption {
  25595. return func(m *WorkExperienceMutation) {
  25596. m.oldValue = func(context.Context) (*WorkExperience, error) {
  25597. return node, nil
  25598. }
  25599. m.id = &node.ID
  25600. }
  25601. }
  25602. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25603. // executed in a transaction (ent.Tx), a transactional client is returned.
  25604. func (m WorkExperienceMutation) Client() *Client {
  25605. client := &Client{config: m.config}
  25606. client.init()
  25607. return client
  25608. }
  25609. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25610. // it returns an error otherwise.
  25611. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  25612. if _, ok := m.driver.(*txDriver); !ok {
  25613. return nil, errors.New("ent: mutation is not running in a transaction")
  25614. }
  25615. tx := &Tx{config: m.config}
  25616. tx.init()
  25617. return tx, nil
  25618. }
  25619. // SetID sets the value of the id field. Note that this
  25620. // operation is only accepted on creation of WorkExperience entities.
  25621. func (m *WorkExperienceMutation) SetID(id uint64) {
  25622. m.id = &id
  25623. }
  25624. // ID returns the ID value in the mutation. Note that the ID is only available
  25625. // if it was provided to the builder or after it was returned from the database.
  25626. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  25627. if m.id == nil {
  25628. return
  25629. }
  25630. return *m.id, true
  25631. }
  25632. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25633. // That means, if the mutation is applied within a transaction with an isolation level such
  25634. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25635. // or updated by the mutation.
  25636. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  25637. switch {
  25638. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25639. id, exists := m.ID()
  25640. if exists {
  25641. return []uint64{id}, nil
  25642. }
  25643. fallthrough
  25644. case m.op.Is(OpUpdate | OpDelete):
  25645. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  25646. default:
  25647. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25648. }
  25649. }
  25650. // SetCreatedAt sets the "created_at" field.
  25651. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  25652. m.created_at = &t
  25653. }
  25654. // CreatedAt returns the value of the "created_at" field in the mutation.
  25655. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  25656. v := m.created_at
  25657. if v == nil {
  25658. return
  25659. }
  25660. return *v, true
  25661. }
  25662. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  25663. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25665. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25666. if !m.op.Is(OpUpdateOne) {
  25667. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25668. }
  25669. if m.id == nil || m.oldValue == nil {
  25670. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25671. }
  25672. oldValue, err := m.oldValue(ctx)
  25673. if err != nil {
  25674. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25675. }
  25676. return oldValue.CreatedAt, nil
  25677. }
  25678. // ResetCreatedAt resets all changes to the "created_at" field.
  25679. func (m *WorkExperienceMutation) ResetCreatedAt() {
  25680. m.created_at = nil
  25681. }
  25682. // SetUpdatedAt sets the "updated_at" field.
  25683. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  25684. m.updated_at = &t
  25685. }
  25686. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25687. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  25688. v := m.updated_at
  25689. if v == nil {
  25690. return
  25691. }
  25692. return *v, true
  25693. }
  25694. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  25695. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25697. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25698. if !m.op.Is(OpUpdateOne) {
  25699. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25700. }
  25701. if m.id == nil || m.oldValue == nil {
  25702. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25703. }
  25704. oldValue, err := m.oldValue(ctx)
  25705. if err != nil {
  25706. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25707. }
  25708. return oldValue.UpdatedAt, nil
  25709. }
  25710. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25711. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  25712. m.updated_at = nil
  25713. }
  25714. // SetDeletedAt sets the "deleted_at" field.
  25715. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  25716. m.deleted_at = &t
  25717. }
  25718. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25719. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  25720. v := m.deleted_at
  25721. if v == nil {
  25722. return
  25723. }
  25724. return *v, true
  25725. }
  25726. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  25727. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25729. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25730. if !m.op.Is(OpUpdateOne) {
  25731. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25732. }
  25733. if m.id == nil || m.oldValue == nil {
  25734. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25735. }
  25736. oldValue, err := m.oldValue(ctx)
  25737. if err != nil {
  25738. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25739. }
  25740. return oldValue.DeletedAt, nil
  25741. }
  25742. // ClearDeletedAt clears the value of the "deleted_at" field.
  25743. func (m *WorkExperienceMutation) ClearDeletedAt() {
  25744. m.deleted_at = nil
  25745. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  25746. }
  25747. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25748. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  25749. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  25750. return ok
  25751. }
  25752. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25753. func (m *WorkExperienceMutation) ResetDeletedAt() {
  25754. m.deleted_at = nil
  25755. delete(m.clearedFields, workexperience.FieldDeletedAt)
  25756. }
  25757. // SetEmployeeID sets the "employee_id" field.
  25758. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  25759. m.employee = &u
  25760. }
  25761. // EmployeeID returns the value of the "employee_id" field in the mutation.
  25762. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  25763. v := m.employee
  25764. if v == nil {
  25765. return
  25766. }
  25767. return *v, true
  25768. }
  25769. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  25770. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25772. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  25773. if !m.op.Is(OpUpdateOne) {
  25774. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  25775. }
  25776. if m.id == nil || m.oldValue == nil {
  25777. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  25778. }
  25779. oldValue, err := m.oldValue(ctx)
  25780. if err != nil {
  25781. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  25782. }
  25783. return oldValue.EmployeeID, nil
  25784. }
  25785. // ResetEmployeeID resets all changes to the "employee_id" field.
  25786. func (m *WorkExperienceMutation) ResetEmployeeID() {
  25787. m.employee = nil
  25788. }
  25789. // SetStartDate sets the "start_date" field.
  25790. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  25791. m.start_date = &t
  25792. }
  25793. // StartDate returns the value of the "start_date" field in the mutation.
  25794. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  25795. v := m.start_date
  25796. if v == nil {
  25797. return
  25798. }
  25799. return *v, true
  25800. }
  25801. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  25802. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25804. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  25805. if !m.op.Is(OpUpdateOne) {
  25806. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  25807. }
  25808. if m.id == nil || m.oldValue == nil {
  25809. return v, errors.New("OldStartDate requires an ID field in the mutation")
  25810. }
  25811. oldValue, err := m.oldValue(ctx)
  25812. if err != nil {
  25813. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  25814. }
  25815. return oldValue.StartDate, nil
  25816. }
  25817. // ResetStartDate resets all changes to the "start_date" field.
  25818. func (m *WorkExperienceMutation) ResetStartDate() {
  25819. m.start_date = nil
  25820. }
  25821. // SetEndDate sets the "end_date" field.
  25822. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  25823. m.end_date = &t
  25824. }
  25825. // EndDate returns the value of the "end_date" field in the mutation.
  25826. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  25827. v := m.end_date
  25828. if v == nil {
  25829. return
  25830. }
  25831. return *v, true
  25832. }
  25833. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  25834. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25836. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  25837. if !m.op.Is(OpUpdateOne) {
  25838. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  25839. }
  25840. if m.id == nil || m.oldValue == nil {
  25841. return v, errors.New("OldEndDate requires an ID field in the mutation")
  25842. }
  25843. oldValue, err := m.oldValue(ctx)
  25844. if err != nil {
  25845. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  25846. }
  25847. return oldValue.EndDate, nil
  25848. }
  25849. // ResetEndDate resets all changes to the "end_date" field.
  25850. func (m *WorkExperienceMutation) ResetEndDate() {
  25851. m.end_date = nil
  25852. }
  25853. // SetCompany sets the "company" field.
  25854. func (m *WorkExperienceMutation) SetCompany(s string) {
  25855. m.company = &s
  25856. }
  25857. // Company returns the value of the "company" field in the mutation.
  25858. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  25859. v := m.company
  25860. if v == nil {
  25861. return
  25862. }
  25863. return *v, true
  25864. }
  25865. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  25866. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25868. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  25869. if !m.op.Is(OpUpdateOne) {
  25870. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  25871. }
  25872. if m.id == nil || m.oldValue == nil {
  25873. return v, errors.New("OldCompany requires an ID field in the mutation")
  25874. }
  25875. oldValue, err := m.oldValue(ctx)
  25876. if err != nil {
  25877. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  25878. }
  25879. return oldValue.Company, nil
  25880. }
  25881. // ResetCompany resets all changes to the "company" field.
  25882. func (m *WorkExperienceMutation) ResetCompany() {
  25883. m.company = nil
  25884. }
  25885. // SetExperience sets the "experience" field.
  25886. func (m *WorkExperienceMutation) SetExperience(s string) {
  25887. m.experience = &s
  25888. }
  25889. // Experience returns the value of the "experience" field in the mutation.
  25890. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  25891. v := m.experience
  25892. if v == nil {
  25893. return
  25894. }
  25895. return *v, true
  25896. }
  25897. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  25898. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25900. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  25901. if !m.op.Is(OpUpdateOne) {
  25902. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  25903. }
  25904. if m.id == nil || m.oldValue == nil {
  25905. return v, errors.New("OldExperience requires an ID field in the mutation")
  25906. }
  25907. oldValue, err := m.oldValue(ctx)
  25908. if err != nil {
  25909. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  25910. }
  25911. return oldValue.Experience, nil
  25912. }
  25913. // ResetExperience resets all changes to the "experience" field.
  25914. func (m *WorkExperienceMutation) ResetExperience() {
  25915. m.experience = nil
  25916. }
  25917. // SetOrganizationID sets the "organization_id" field.
  25918. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  25919. m.organization_id = &u
  25920. m.addorganization_id = nil
  25921. }
  25922. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25923. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  25924. v := m.organization_id
  25925. if v == nil {
  25926. return
  25927. }
  25928. return *v, true
  25929. }
  25930. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  25931. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25933. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25934. if !m.op.Is(OpUpdateOne) {
  25935. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25936. }
  25937. if m.id == nil || m.oldValue == nil {
  25938. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25939. }
  25940. oldValue, err := m.oldValue(ctx)
  25941. if err != nil {
  25942. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25943. }
  25944. return oldValue.OrganizationID, nil
  25945. }
  25946. // AddOrganizationID adds u to the "organization_id" field.
  25947. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  25948. if m.addorganization_id != nil {
  25949. *m.addorganization_id += u
  25950. } else {
  25951. m.addorganization_id = &u
  25952. }
  25953. }
  25954. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25955. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  25956. v := m.addorganization_id
  25957. if v == nil {
  25958. return
  25959. }
  25960. return *v, true
  25961. }
  25962. // ResetOrganizationID resets all changes to the "organization_id" field.
  25963. func (m *WorkExperienceMutation) ResetOrganizationID() {
  25964. m.organization_id = nil
  25965. m.addorganization_id = nil
  25966. }
  25967. // ClearEmployee clears the "employee" edge to the Employee entity.
  25968. func (m *WorkExperienceMutation) ClearEmployee() {
  25969. m.clearedemployee = true
  25970. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  25971. }
  25972. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  25973. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  25974. return m.clearedemployee
  25975. }
  25976. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  25977. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25978. // EmployeeID instead. It exists only for internal usage by the builders.
  25979. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  25980. if id := m.employee; id != nil {
  25981. ids = append(ids, *id)
  25982. }
  25983. return
  25984. }
  25985. // ResetEmployee resets all changes to the "employee" edge.
  25986. func (m *WorkExperienceMutation) ResetEmployee() {
  25987. m.employee = nil
  25988. m.clearedemployee = false
  25989. }
  25990. // Where appends a list predicates to the WorkExperienceMutation builder.
  25991. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  25992. m.predicates = append(m.predicates, ps...)
  25993. }
  25994. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  25995. // users can use type-assertion to append predicates that do not depend on any generated package.
  25996. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  25997. p := make([]predicate.WorkExperience, len(ps))
  25998. for i := range ps {
  25999. p[i] = ps[i]
  26000. }
  26001. m.Where(p...)
  26002. }
  26003. // Op returns the operation name.
  26004. func (m *WorkExperienceMutation) Op() Op {
  26005. return m.op
  26006. }
  26007. // SetOp allows setting the mutation operation.
  26008. func (m *WorkExperienceMutation) SetOp(op Op) {
  26009. m.op = op
  26010. }
  26011. // Type returns the node type of this mutation (WorkExperience).
  26012. func (m *WorkExperienceMutation) Type() string {
  26013. return m.typ
  26014. }
  26015. // Fields returns all fields that were changed during this mutation. Note that in
  26016. // order to get all numeric fields that were incremented/decremented, call
  26017. // AddedFields().
  26018. func (m *WorkExperienceMutation) Fields() []string {
  26019. fields := make([]string, 0, 9)
  26020. if m.created_at != nil {
  26021. fields = append(fields, workexperience.FieldCreatedAt)
  26022. }
  26023. if m.updated_at != nil {
  26024. fields = append(fields, workexperience.FieldUpdatedAt)
  26025. }
  26026. if m.deleted_at != nil {
  26027. fields = append(fields, workexperience.FieldDeletedAt)
  26028. }
  26029. if m.employee != nil {
  26030. fields = append(fields, workexperience.FieldEmployeeID)
  26031. }
  26032. if m.start_date != nil {
  26033. fields = append(fields, workexperience.FieldStartDate)
  26034. }
  26035. if m.end_date != nil {
  26036. fields = append(fields, workexperience.FieldEndDate)
  26037. }
  26038. if m.company != nil {
  26039. fields = append(fields, workexperience.FieldCompany)
  26040. }
  26041. if m.experience != nil {
  26042. fields = append(fields, workexperience.FieldExperience)
  26043. }
  26044. if m.organization_id != nil {
  26045. fields = append(fields, workexperience.FieldOrganizationID)
  26046. }
  26047. return fields
  26048. }
  26049. // Field returns the value of a field with the given name. The second boolean
  26050. // return value indicates that this field was not set, or was not defined in the
  26051. // schema.
  26052. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  26053. switch name {
  26054. case workexperience.FieldCreatedAt:
  26055. return m.CreatedAt()
  26056. case workexperience.FieldUpdatedAt:
  26057. return m.UpdatedAt()
  26058. case workexperience.FieldDeletedAt:
  26059. return m.DeletedAt()
  26060. case workexperience.FieldEmployeeID:
  26061. return m.EmployeeID()
  26062. case workexperience.FieldStartDate:
  26063. return m.StartDate()
  26064. case workexperience.FieldEndDate:
  26065. return m.EndDate()
  26066. case workexperience.FieldCompany:
  26067. return m.Company()
  26068. case workexperience.FieldExperience:
  26069. return m.Experience()
  26070. case workexperience.FieldOrganizationID:
  26071. return m.OrganizationID()
  26072. }
  26073. return nil, false
  26074. }
  26075. // OldField returns the old value of the field from the database. An error is
  26076. // returned if the mutation operation is not UpdateOne, or the query to the
  26077. // database failed.
  26078. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26079. switch name {
  26080. case workexperience.FieldCreatedAt:
  26081. return m.OldCreatedAt(ctx)
  26082. case workexperience.FieldUpdatedAt:
  26083. return m.OldUpdatedAt(ctx)
  26084. case workexperience.FieldDeletedAt:
  26085. return m.OldDeletedAt(ctx)
  26086. case workexperience.FieldEmployeeID:
  26087. return m.OldEmployeeID(ctx)
  26088. case workexperience.FieldStartDate:
  26089. return m.OldStartDate(ctx)
  26090. case workexperience.FieldEndDate:
  26091. return m.OldEndDate(ctx)
  26092. case workexperience.FieldCompany:
  26093. return m.OldCompany(ctx)
  26094. case workexperience.FieldExperience:
  26095. return m.OldExperience(ctx)
  26096. case workexperience.FieldOrganizationID:
  26097. return m.OldOrganizationID(ctx)
  26098. }
  26099. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  26100. }
  26101. // SetField sets the value of a field with the given name. It returns an error if
  26102. // the field is not defined in the schema, or if the type mismatched the field
  26103. // type.
  26104. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  26105. switch name {
  26106. case workexperience.FieldCreatedAt:
  26107. v, ok := value.(time.Time)
  26108. if !ok {
  26109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26110. }
  26111. m.SetCreatedAt(v)
  26112. return nil
  26113. case workexperience.FieldUpdatedAt:
  26114. v, ok := value.(time.Time)
  26115. if !ok {
  26116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26117. }
  26118. m.SetUpdatedAt(v)
  26119. return nil
  26120. case workexperience.FieldDeletedAt:
  26121. v, ok := value.(time.Time)
  26122. if !ok {
  26123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26124. }
  26125. m.SetDeletedAt(v)
  26126. return nil
  26127. case workexperience.FieldEmployeeID:
  26128. v, ok := value.(uint64)
  26129. if !ok {
  26130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26131. }
  26132. m.SetEmployeeID(v)
  26133. return nil
  26134. case workexperience.FieldStartDate:
  26135. v, ok := value.(time.Time)
  26136. if !ok {
  26137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26138. }
  26139. m.SetStartDate(v)
  26140. return nil
  26141. case workexperience.FieldEndDate:
  26142. v, ok := value.(time.Time)
  26143. if !ok {
  26144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26145. }
  26146. m.SetEndDate(v)
  26147. return nil
  26148. case workexperience.FieldCompany:
  26149. v, ok := value.(string)
  26150. if !ok {
  26151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26152. }
  26153. m.SetCompany(v)
  26154. return nil
  26155. case workexperience.FieldExperience:
  26156. v, ok := value.(string)
  26157. if !ok {
  26158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26159. }
  26160. m.SetExperience(v)
  26161. return nil
  26162. case workexperience.FieldOrganizationID:
  26163. v, ok := value.(uint64)
  26164. if !ok {
  26165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26166. }
  26167. m.SetOrganizationID(v)
  26168. return nil
  26169. }
  26170. return fmt.Errorf("unknown WorkExperience field %s", name)
  26171. }
  26172. // AddedFields returns all numeric fields that were incremented/decremented during
  26173. // this mutation.
  26174. func (m *WorkExperienceMutation) AddedFields() []string {
  26175. var fields []string
  26176. if m.addorganization_id != nil {
  26177. fields = append(fields, workexperience.FieldOrganizationID)
  26178. }
  26179. return fields
  26180. }
  26181. // AddedField returns the numeric value that was incremented/decremented on a field
  26182. // with the given name. The second boolean return value indicates that this field
  26183. // was not set, or was not defined in the schema.
  26184. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  26185. switch name {
  26186. case workexperience.FieldOrganizationID:
  26187. return m.AddedOrganizationID()
  26188. }
  26189. return nil, false
  26190. }
  26191. // AddField adds the value to the field with the given name. It returns an error if
  26192. // the field is not defined in the schema, or if the type mismatched the field
  26193. // type.
  26194. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  26195. switch name {
  26196. case workexperience.FieldOrganizationID:
  26197. v, ok := value.(int64)
  26198. if !ok {
  26199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26200. }
  26201. m.AddOrganizationID(v)
  26202. return nil
  26203. }
  26204. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  26205. }
  26206. // ClearedFields returns all nullable fields that were cleared during this
  26207. // mutation.
  26208. func (m *WorkExperienceMutation) ClearedFields() []string {
  26209. var fields []string
  26210. if m.FieldCleared(workexperience.FieldDeletedAt) {
  26211. fields = append(fields, workexperience.FieldDeletedAt)
  26212. }
  26213. return fields
  26214. }
  26215. // FieldCleared returns a boolean indicating if a field with the given name was
  26216. // cleared in this mutation.
  26217. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  26218. _, ok := m.clearedFields[name]
  26219. return ok
  26220. }
  26221. // ClearField clears the value of the field with the given name. It returns an
  26222. // error if the field is not defined in the schema.
  26223. func (m *WorkExperienceMutation) ClearField(name string) error {
  26224. switch name {
  26225. case workexperience.FieldDeletedAt:
  26226. m.ClearDeletedAt()
  26227. return nil
  26228. }
  26229. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  26230. }
  26231. // ResetField resets all changes in the mutation for the field with the given name.
  26232. // It returns an error if the field is not defined in the schema.
  26233. func (m *WorkExperienceMutation) ResetField(name string) error {
  26234. switch name {
  26235. case workexperience.FieldCreatedAt:
  26236. m.ResetCreatedAt()
  26237. return nil
  26238. case workexperience.FieldUpdatedAt:
  26239. m.ResetUpdatedAt()
  26240. return nil
  26241. case workexperience.FieldDeletedAt:
  26242. m.ResetDeletedAt()
  26243. return nil
  26244. case workexperience.FieldEmployeeID:
  26245. m.ResetEmployeeID()
  26246. return nil
  26247. case workexperience.FieldStartDate:
  26248. m.ResetStartDate()
  26249. return nil
  26250. case workexperience.FieldEndDate:
  26251. m.ResetEndDate()
  26252. return nil
  26253. case workexperience.FieldCompany:
  26254. m.ResetCompany()
  26255. return nil
  26256. case workexperience.FieldExperience:
  26257. m.ResetExperience()
  26258. return nil
  26259. case workexperience.FieldOrganizationID:
  26260. m.ResetOrganizationID()
  26261. return nil
  26262. }
  26263. return fmt.Errorf("unknown WorkExperience field %s", name)
  26264. }
  26265. // AddedEdges returns all edge names that were set/added in this mutation.
  26266. func (m *WorkExperienceMutation) AddedEdges() []string {
  26267. edges := make([]string, 0, 1)
  26268. if m.employee != nil {
  26269. edges = append(edges, workexperience.EdgeEmployee)
  26270. }
  26271. return edges
  26272. }
  26273. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26274. // name in this mutation.
  26275. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  26276. switch name {
  26277. case workexperience.EdgeEmployee:
  26278. if id := m.employee; id != nil {
  26279. return []ent.Value{*id}
  26280. }
  26281. }
  26282. return nil
  26283. }
  26284. // RemovedEdges returns all edge names that were removed in this mutation.
  26285. func (m *WorkExperienceMutation) RemovedEdges() []string {
  26286. edges := make([]string, 0, 1)
  26287. return edges
  26288. }
  26289. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26290. // the given name in this mutation.
  26291. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  26292. return nil
  26293. }
  26294. // ClearedEdges returns all edge names that were cleared in this mutation.
  26295. func (m *WorkExperienceMutation) ClearedEdges() []string {
  26296. edges := make([]string, 0, 1)
  26297. if m.clearedemployee {
  26298. edges = append(edges, workexperience.EdgeEmployee)
  26299. }
  26300. return edges
  26301. }
  26302. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26303. // was cleared in this mutation.
  26304. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  26305. switch name {
  26306. case workexperience.EdgeEmployee:
  26307. return m.clearedemployee
  26308. }
  26309. return false
  26310. }
  26311. // ClearEdge clears the value of the edge with the given name. It returns an error
  26312. // if that edge is not defined in the schema.
  26313. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  26314. switch name {
  26315. case workexperience.EdgeEmployee:
  26316. m.ClearEmployee()
  26317. return nil
  26318. }
  26319. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  26320. }
  26321. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26322. // It returns an error if the edge is not defined in the schema.
  26323. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  26324. switch name {
  26325. case workexperience.EdgeEmployee:
  26326. m.ResetEmployee()
  26327. return nil
  26328. }
  26329. return fmt.Errorf("unknown WorkExperience edge %s", name)
  26330. }
  26331. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  26332. type WpChatroomMutation struct {
  26333. config
  26334. op Op
  26335. typ string
  26336. id *uint64
  26337. created_at *time.Time
  26338. updated_at *time.Time
  26339. status *uint8
  26340. addstatus *int8
  26341. wx_wxid *string
  26342. chatroom_id *string
  26343. nickname *string
  26344. owner *string
  26345. avatar *string
  26346. member_list *[]string
  26347. appendmember_list []string
  26348. clearedFields map[string]struct{}
  26349. done bool
  26350. oldValue func(context.Context) (*WpChatroom, error)
  26351. predicates []predicate.WpChatroom
  26352. }
  26353. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  26354. // wpchatroomOption allows management of the mutation configuration using functional options.
  26355. type wpchatroomOption func(*WpChatroomMutation)
  26356. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  26357. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  26358. m := &WpChatroomMutation{
  26359. config: c,
  26360. op: op,
  26361. typ: TypeWpChatroom,
  26362. clearedFields: make(map[string]struct{}),
  26363. }
  26364. for _, opt := range opts {
  26365. opt(m)
  26366. }
  26367. return m
  26368. }
  26369. // withWpChatroomID sets the ID field of the mutation.
  26370. func withWpChatroomID(id uint64) wpchatroomOption {
  26371. return func(m *WpChatroomMutation) {
  26372. var (
  26373. err error
  26374. once sync.Once
  26375. value *WpChatroom
  26376. )
  26377. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  26378. once.Do(func() {
  26379. if m.done {
  26380. err = errors.New("querying old values post mutation is not allowed")
  26381. } else {
  26382. value, err = m.Client().WpChatroom.Get(ctx, id)
  26383. }
  26384. })
  26385. return value, err
  26386. }
  26387. m.id = &id
  26388. }
  26389. }
  26390. // withWpChatroom sets the old WpChatroom of the mutation.
  26391. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  26392. return func(m *WpChatroomMutation) {
  26393. m.oldValue = func(context.Context) (*WpChatroom, error) {
  26394. return node, nil
  26395. }
  26396. m.id = &node.ID
  26397. }
  26398. }
  26399. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26400. // executed in a transaction (ent.Tx), a transactional client is returned.
  26401. func (m WpChatroomMutation) Client() *Client {
  26402. client := &Client{config: m.config}
  26403. client.init()
  26404. return client
  26405. }
  26406. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26407. // it returns an error otherwise.
  26408. func (m WpChatroomMutation) Tx() (*Tx, error) {
  26409. if _, ok := m.driver.(*txDriver); !ok {
  26410. return nil, errors.New("ent: mutation is not running in a transaction")
  26411. }
  26412. tx := &Tx{config: m.config}
  26413. tx.init()
  26414. return tx, nil
  26415. }
  26416. // SetID sets the value of the id field. Note that this
  26417. // operation is only accepted on creation of WpChatroom entities.
  26418. func (m *WpChatroomMutation) SetID(id uint64) {
  26419. m.id = &id
  26420. }
  26421. // ID returns the ID value in the mutation. Note that the ID is only available
  26422. // if it was provided to the builder or after it was returned from the database.
  26423. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  26424. if m.id == nil {
  26425. return
  26426. }
  26427. return *m.id, true
  26428. }
  26429. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26430. // That means, if the mutation is applied within a transaction with an isolation level such
  26431. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26432. // or updated by the mutation.
  26433. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  26434. switch {
  26435. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26436. id, exists := m.ID()
  26437. if exists {
  26438. return []uint64{id}, nil
  26439. }
  26440. fallthrough
  26441. case m.op.Is(OpUpdate | OpDelete):
  26442. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  26443. default:
  26444. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26445. }
  26446. }
  26447. // SetCreatedAt sets the "created_at" field.
  26448. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  26449. m.created_at = &t
  26450. }
  26451. // CreatedAt returns the value of the "created_at" field in the mutation.
  26452. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  26453. v := m.created_at
  26454. if v == nil {
  26455. return
  26456. }
  26457. return *v, true
  26458. }
  26459. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  26460. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26462. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26463. if !m.op.Is(OpUpdateOne) {
  26464. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26465. }
  26466. if m.id == nil || m.oldValue == nil {
  26467. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26468. }
  26469. oldValue, err := m.oldValue(ctx)
  26470. if err != nil {
  26471. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26472. }
  26473. return oldValue.CreatedAt, nil
  26474. }
  26475. // ResetCreatedAt resets all changes to the "created_at" field.
  26476. func (m *WpChatroomMutation) ResetCreatedAt() {
  26477. m.created_at = nil
  26478. }
  26479. // SetUpdatedAt sets the "updated_at" field.
  26480. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  26481. m.updated_at = &t
  26482. }
  26483. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26484. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  26485. v := m.updated_at
  26486. if v == nil {
  26487. return
  26488. }
  26489. return *v, true
  26490. }
  26491. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  26492. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26494. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26495. if !m.op.Is(OpUpdateOne) {
  26496. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26497. }
  26498. if m.id == nil || m.oldValue == nil {
  26499. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26500. }
  26501. oldValue, err := m.oldValue(ctx)
  26502. if err != nil {
  26503. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26504. }
  26505. return oldValue.UpdatedAt, nil
  26506. }
  26507. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26508. func (m *WpChatroomMutation) ResetUpdatedAt() {
  26509. m.updated_at = nil
  26510. }
  26511. // SetStatus sets the "status" field.
  26512. func (m *WpChatroomMutation) SetStatus(u uint8) {
  26513. m.status = &u
  26514. m.addstatus = nil
  26515. }
  26516. // Status returns the value of the "status" field in the mutation.
  26517. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  26518. v := m.status
  26519. if v == nil {
  26520. return
  26521. }
  26522. return *v, true
  26523. }
  26524. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  26525. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26527. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26528. if !m.op.Is(OpUpdateOne) {
  26529. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26530. }
  26531. if m.id == nil || m.oldValue == nil {
  26532. return v, errors.New("OldStatus requires an ID field in the mutation")
  26533. }
  26534. oldValue, err := m.oldValue(ctx)
  26535. if err != nil {
  26536. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26537. }
  26538. return oldValue.Status, nil
  26539. }
  26540. // AddStatus adds u to the "status" field.
  26541. func (m *WpChatroomMutation) AddStatus(u int8) {
  26542. if m.addstatus != nil {
  26543. *m.addstatus += u
  26544. } else {
  26545. m.addstatus = &u
  26546. }
  26547. }
  26548. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26549. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  26550. v := m.addstatus
  26551. if v == nil {
  26552. return
  26553. }
  26554. return *v, true
  26555. }
  26556. // ClearStatus clears the value of the "status" field.
  26557. func (m *WpChatroomMutation) ClearStatus() {
  26558. m.status = nil
  26559. m.addstatus = nil
  26560. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  26561. }
  26562. // StatusCleared returns if the "status" field was cleared in this mutation.
  26563. func (m *WpChatroomMutation) StatusCleared() bool {
  26564. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  26565. return ok
  26566. }
  26567. // ResetStatus resets all changes to the "status" field.
  26568. func (m *WpChatroomMutation) ResetStatus() {
  26569. m.status = nil
  26570. m.addstatus = nil
  26571. delete(m.clearedFields, wpchatroom.FieldStatus)
  26572. }
  26573. // SetWxWxid sets the "wx_wxid" field.
  26574. func (m *WpChatroomMutation) SetWxWxid(s string) {
  26575. m.wx_wxid = &s
  26576. }
  26577. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  26578. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  26579. v := m.wx_wxid
  26580. if v == nil {
  26581. return
  26582. }
  26583. return *v, true
  26584. }
  26585. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  26586. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26588. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  26589. if !m.op.Is(OpUpdateOne) {
  26590. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  26591. }
  26592. if m.id == nil || m.oldValue == nil {
  26593. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  26594. }
  26595. oldValue, err := m.oldValue(ctx)
  26596. if err != nil {
  26597. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  26598. }
  26599. return oldValue.WxWxid, nil
  26600. }
  26601. // ResetWxWxid resets all changes to the "wx_wxid" field.
  26602. func (m *WpChatroomMutation) ResetWxWxid() {
  26603. m.wx_wxid = nil
  26604. }
  26605. // SetChatroomID sets the "chatroom_id" field.
  26606. func (m *WpChatroomMutation) SetChatroomID(s string) {
  26607. m.chatroom_id = &s
  26608. }
  26609. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  26610. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  26611. v := m.chatroom_id
  26612. if v == nil {
  26613. return
  26614. }
  26615. return *v, true
  26616. }
  26617. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  26618. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26620. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  26621. if !m.op.Is(OpUpdateOne) {
  26622. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  26623. }
  26624. if m.id == nil || m.oldValue == nil {
  26625. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  26626. }
  26627. oldValue, err := m.oldValue(ctx)
  26628. if err != nil {
  26629. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  26630. }
  26631. return oldValue.ChatroomID, nil
  26632. }
  26633. // ResetChatroomID resets all changes to the "chatroom_id" field.
  26634. func (m *WpChatroomMutation) ResetChatroomID() {
  26635. m.chatroom_id = nil
  26636. }
  26637. // SetNickname sets the "nickname" field.
  26638. func (m *WpChatroomMutation) SetNickname(s string) {
  26639. m.nickname = &s
  26640. }
  26641. // Nickname returns the value of the "nickname" field in the mutation.
  26642. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  26643. v := m.nickname
  26644. if v == nil {
  26645. return
  26646. }
  26647. return *v, true
  26648. }
  26649. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  26650. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26652. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  26653. if !m.op.Is(OpUpdateOne) {
  26654. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  26655. }
  26656. if m.id == nil || m.oldValue == nil {
  26657. return v, errors.New("OldNickname requires an ID field in the mutation")
  26658. }
  26659. oldValue, err := m.oldValue(ctx)
  26660. if err != nil {
  26661. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  26662. }
  26663. return oldValue.Nickname, nil
  26664. }
  26665. // ResetNickname resets all changes to the "nickname" field.
  26666. func (m *WpChatroomMutation) ResetNickname() {
  26667. m.nickname = nil
  26668. }
  26669. // SetOwner sets the "owner" field.
  26670. func (m *WpChatroomMutation) SetOwner(s string) {
  26671. m.owner = &s
  26672. }
  26673. // Owner returns the value of the "owner" field in the mutation.
  26674. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  26675. v := m.owner
  26676. if v == nil {
  26677. return
  26678. }
  26679. return *v, true
  26680. }
  26681. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  26682. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26684. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  26685. if !m.op.Is(OpUpdateOne) {
  26686. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  26687. }
  26688. if m.id == nil || m.oldValue == nil {
  26689. return v, errors.New("OldOwner requires an ID field in the mutation")
  26690. }
  26691. oldValue, err := m.oldValue(ctx)
  26692. if err != nil {
  26693. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  26694. }
  26695. return oldValue.Owner, nil
  26696. }
  26697. // ResetOwner resets all changes to the "owner" field.
  26698. func (m *WpChatroomMutation) ResetOwner() {
  26699. m.owner = nil
  26700. }
  26701. // SetAvatar sets the "avatar" field.
  26702. func (m *WpChatroomMutation) SetAvatar(s string) {
  26703. m.avatar = &s
  26704. }
  26705. // Avatar returns the value of the "avatar" field in the mutation.
  26706. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  26707. v := m.avatar
  26708. if v == nil {
  26709. return
  26710. }
  26711. return *v, true
  26712. }
  26713. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  26714. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26716. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  26717. if !m.op.Is(OpUpdateOne) {
  26718. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  26719. }
  26720. if m.id == nil || m.oldValue == nil {
  26721. return v, errors.New("OldAvatar requires an ID field in the mutation")
  26722. }
  26723. oldValue, err := m.oldValue(ctx)
  26724. if err != nil {
  26725. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  26726. }
  26727. return oldValue.Avatar, nil
  26728. }
  26729. // ResetAvatar resets all changes to the "avatar" field.
  26730. func (m *WpChatroomMutation) ResetAvatar() {
  26731. m.avatar = nil
  26732. }
  26733. // SetMemberList sets the "member_list" field.
  26734. func (m *WpChatroomMutation) SetMemberList(s []string) {
  26735. m.member_list = &s
  26736. m.appendmember_list = nil
  26737. }
  26738. // MemberList returns the value of the "member_list" field in the mutation.
  26739. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  26740. v := m.member_list
  26741. if v == nil {
  26742. return
  26743. }
  26744. return *v, true
  26745. }
  26746. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  26747. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26749. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  26750. if !m.op.Is(OpUpdateOne) {
  26751. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  26752. }
  26753. if m.id == nil || m.oldValue == nil {
  26754. return v, errors.New("OldMemberList requires an ID field in the mutation")
  26755. }
  26756. oldValue, err := m.oldValue(ctx)
  26757. if err != nil {
  26758. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  26759. }
  26760. return oldValue.MemberList, nil
  26761. }
  26762. // AppendMemberList adds s to the "member_list" field.
  26763. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  26764. m.appendmember_list = append(m.appendmember_list, s...)
  26765. }
  26766. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  26767. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  26768. if len(m.appendmember_list) == 0 {
  26769. return nil, false
  26770. }
  26771. return m.appendmember_list, true
  26772. }
  26773. // ResetMemberList resets all changes to the "member_list" field.
  26774. func (m *WpChatroomMutation) ResetMemberList() {
  26775. m.member_list = nil
  26776. m.appendmember_list = nil
  26777. }
  26778. // Where appends a list predicates to the WpChatroomMutation builder.
  26779. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  26780. m.predicates = append(m.predicates, ps...)
  26781. }
  26782. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  26783. // users can use type-assertion to append predicates that do not depend on any generated package.
  26784. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  26785. p := make([]predicate.WpChatroom, len(ps))
  26786. for i := range ps {
  26787. p[i] = ps[i]
  26788. }
  26789. m.Where(p...)
  26790. }
  26791. // Op returns the operation name.
  26792. func (m *WpChatroomMutation) Op() Op {
  26793. return m.op
  26794. }
  26795. // SetOp allows setting the mutation operation.
  26796. func (m *WpChatroomMutation) SetOp(op Op) {
  26797. m.op = op
  26798. }
  26799. // Type returns the node type of this mutation (WpChatroom).
  26800. func (m *WpChatroomMutation) Type() string {
  26801. return m.typ
  26802. }
  26803. // Fields returns all fields that were changed during this mutation. Note that in
  26804. // order to get all numeric fields that were incremented/decremented, call
  26805. // AddedFields().
  26806. func (m *WpChatroomMutation) Fields() []string {
  26807. fields := make([]string, 0, 9)
  26808. if m.created_at != nil {
  26809. fields = append(fields, wpchatroom.FieldCreatedAt)
  26810. }
  26811. if m.updated_at != nil {
  26812. fields = append(fields, wpchatroom.FieldUpdatedAt)
  26813. }
  26814. if m.status != nil {
  26815. fields = append(fields, wpchatroom.FieldStatus)
  26816. }
  26817. if m.wx_wxid != nil {
  26818. fields = append(fields, wpchatroom.FieldWxWxid)
  26819. }
  26820. if m.chatroom_id != nil {
  26821. fields = append(fields, wpchatroom.FieldChatroomID)
  26822. }
  26823. if m.nickname != nil {
  26824. fields = append(fields, wpchatroom.FieldNickname)
  26825. }
  26826. if m.owner != nil {
  26827. fields = append(fields, wpchatroom.FieldOwner)
  26828. }
  26829. if m.avatar != nil {
  26830. fields = append(fields, wpchatroom.FieldAvatar)
  26831. }
  26832. if m.member_list != nil {
  26833. fields = append(fields, wpchatroom.FieldMemberList)
  26834. }
  26835. return fields
  26836. }
  26837. // Field returns the value of a field with the given name. The second boolean
  26838. // return value indicates that this field was not set, or was not defined in the
  26839. // schema.
  26840. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  26841. switch name {
  26842. case wpchatroom.FieldCreatedAt:
  26843. return m.CreatedAt()
  26844. case wpchatroom.FieldUpdatedAt:
  26845. return m.UpdatedAt()
  26846. case wpchatroom.FieldStatus:
  26847. return m.Status()
  26848. case wpchatroom.FieldWxWxid:
  26849. return m.WxWxid()
  26850. case wpchatroom.FieldChatroomID:
  26851. return m.ChatroomID()
  26852. case wpchatroom.FieldNickname:
  26853. return m.Nickname()
  26854. case wpchatroom.FieldOwner:
  26855. return m.Owner()
  26856. case wpchatroom.FieldAvatar:
  26857. return m.Avatar()
  26858. case wpchatroom.FieldMemberList:
  26859. return m.MemberList()
  26860. }
  26861. return nil, false
  26862. }
  26863. // OldField returns the old value of the field from the database. An error is
  26864. // returned if the mutation operation is not UpdateOne, or the query to the
  26865. // database failed.
  26866. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26867. switch name {
  26868. case wpchatroom.FieldCreatedAt:
  26869. return m.OldCreatedAt(ctx)
  26870. case wpchatroom.FieldUpdatedAt:
  26871. return m.OldUpdatedAt(ctx)
  26872. case wpchatroom.FieldStatus:
  26873. return m.OldStatus(ctx)
  26874. case wpchatroom.FieldWxWxid:
  26875. return m.OldWxWxid(ctx)
  26876. case wpchatroom.FieldChatroomID:
  26877. return m.OldChatroomID(ctx)
  26878. case wpchatroom.FieldNickname:
  26879. return m.OldNickname(ctx)
  26880. case wpchatroom.FieldOwner:
  26881. return m.OldOwner(ctx)
  26882. case wpchatroom.FieldAvatar:
  26883. return m.OldAvatar(ctx)
  26884. case wpchatroom.FieldMemberList:
  26885. return m.OldMemberList(ctx)
  26886. }
  26887. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  26888. }
  26889. // SetField sets the value of a field with the given name. It returns an error if
  26890. // the field is not defined in the schema, or if the type mismatched the field
  26891. // type.
  26892. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  26893. switch name {
  26894. case wpchatroom.FieldCreatedAt:
  26895. v, ok := value.(time.Time)
  26896. if !ok {
  26897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26898. }
  26899. m.SetCreatedAt(v)
  26900. return nil
  26901. case wpchatroom.FieldUpdatedAt:
  26902. v, ok := value.(time.Time)
  26903. if !ok {
  26904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26905. }
  26906. m.SetUpdatedAt(v)
  26907. return nil
  26908. case wpchatroom.FieldStatus:
  26909. v, ok := value.(uint8)
  26910. if !ok {
  26911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26912. }
  26913. m.SetStatus(v)
  26914. return nil
  26915. case wpchatroom.FieldWxWxid:
  26916. v, ok := value.(string)
  26917. if !ok {
  26918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26919. }
  26920. m.SetWxWxid(v)
  26921. return nil
  26922. case wpchatroom.FieldChatroomID:
  26923. v, ok := value.(string)
  26924. if !ok {
  26925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26926. }
  26927. m.SetChatroomID(v)
  26928. return nil
  26929. case wpchatroom.FieldNickname:
  26930. v, ok := value.(string)
  26931. if !ok {
  26932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26933. }
  26934. m.SetNickname(v)
  26935. return nil
  26936. case wpchatroom.FieldOwner:
  26937. v, ok := value.(string)
  26938. if !ok {
  26939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26940. }
  26941. m.SetOwner(v)
  26942. return nil
  26943. case wpchatroom.FieldAvatar:
  26944. v, ok := value.(string)
  26945. if !ok {
  26946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26947. }
  26948. m.SetAvatar(v)
  26949. return nil
  26950. case wpchatroom.FieldMemberList:
  26951. v, ok := value.([]string)
  26952. if !ok {
  26953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26954. }
  26955. m.SetMemberList(v)
  26956. return nil
  26957. }
  26958. return fmt.Errorf("unknown WpChatroom field %s", name)
  26959. }
  26960. // AddedFields returns all numeric fields that were incremented/decremented during
  26961. // this mutation.
  26962. func (m *WpChatroomMutation) AddedFields() []string {
  26963. var fields []string
  26964. if m.addstatus != nil {
  26965. fields = append(fields, wpchatroom.FieldStatus)
  26966. }
  26967. return fields
  26968. }
  26969. // AddedField returns the numeric value that was incremented/decremented on a field
  26970. // with the given name. The second boolean return value indicates that this field
  26971. // was not set, or was not defined in the schema.
  26972. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  26973. switch name {
  26974. case wpchatroom.FieldStatus:
  26975. return m.AddedStatus()
  26976. }
  26977. return nil, false
  26978. }
  26979. // AddField adds the value to the field with the given name. It returns an error if
  26980. // the field is not defined in the schema, or if the type mismatched the field
  26981. // type.
  26982. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  26983. switch name {
  26984. case wpchatroom.FieldStatus:
  26985. v, ok := value.(int8)
  26986. if !ok {
  26987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26988. }
  26989. m.AddStatus(v)
  26990. return nil
  26991. }
  26992. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  26993. }
  26994. // ClearedFields returns all nullable fields that were cleared during this
  26995. // mutation.
  26996. func (m *WpChatroomMutation) ClearedFields() []string {
  26997. var fields []string
  26998. if m.FieldCleared(wpchatroom.FieldStatus) {
  26999. fields = append(fields, wpchatroom.FieldStatus)
  27000. }
  27001. return fields
  27002. }
  27003. // FieldCleared returns a boolean indicating if a field with the given name was
  27004. // cleared in this mutation.
  27005. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  27006. _, ok := m.clearedFields[name]
  27007. return ok
  27008. }
  27009. // ClearField clears the value of the field with the given name. It returns an
  27010. // error if the field is not defined in the schema.
  27011. func (m *WpChatroomMutation) ClearField(name string) error {
  27012. switch name {
  27013. case wpchatroom.FieldStatus:
  27014. m.ClearStatus()
  27015. return nil
  27016. }
  27017. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  27018. }
  27019. // ResetField resets all changes in the mutation for the field with the given name.
  27020. // It returns an error if the field is not defined in the schema.
  27021. func (m *WpChatroomMutation) ResetField(name string) error {
  27022. switch name {
  27023. case wpchatroom.FieldCreatedAt:
  27024. m.ResetCreatedAt()
  27025. return nil
  27026. case wpchatroom.FieldUpdatedAt:
  27027. m.ResetUpdatedAt()
  27028. return nil
  27029. case wpchatroom.FieldStatus:
  27030. m.ResetStatus()
  27031. return nil
  27032. case wpchatroom.FieldWxWxid:
  27033. m.ResetWxWxid()
  27034. return nil
  27035. case wpchatroom.FieldChatroomID:
  27036. m.ResetChatroomID()
  27037. return nil
  27038. case wpchatroom.FieldNickname:
  27039. m.ResetNickname()
  27040. return nil
  27041. case wpchatroom.FieldOwner:
  27042. m.ResetOwner()
  27043. return nil
  27044. case wpchatroom.FieldAvatar:
  27045. m.ResetAvatar()
  27046. return nil
  27047. case wpchatroom.FieldMemberList:
  27048. m.ResetMemberList()
  27049. return nil
  27050. }
  27051. return fmt.Errorf("unknown WpChatroom field %s", name)
  27052. }
  27053. // AddedEdges returns all edge names that were set/added in this mutation.
  27054. func (m *WpChatroomMutation) AddedEdges() []string {
  27055. edges := make([]string, 0, 0)
  27056. return edges
  27057. }
  27058. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27059. // name in this mutation.
  27060. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  27061. return nil
  27062. }
  27063. // RemovedEdges returns all edge names that were removed in this mutation.
  27064. func (m *WpChatroomMutation) RemovedEdges() []string {
  27065. edges := make([]string, 0, 0)
  27066. return edges
  27067. }
  27068. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27069. // the given name in this mutation.
  27070. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  27071. return nil
  27072. }
  27073. // ClearedEdges returns all edge names that were cleared in this mutation.
  27074. func (m *WpChatroomMutation) ClearedEdges() []string {
  27075. edges := make([]string, 0, 0)
  27076. return edges
  27077. }
  27078. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27079. // was cleared in this mutation.
  27080. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  27081. return false
  27082. }
  27083. // ClearEdge clears the value of the edge with the given name. It returns an error
  27084. // if that edge is not defined in the schema.
  27085. func (m *WpChatroomMutation) ClearEdge(name string) error {
  27086. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  27087. }
  27088. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27089. // It returns an error if the edge is not defined in the schema.
  27090. func (m *WpChatroomMutation) ResetEdge(name string) error {
  27091. return fmt.Errorf("unknown WpChatroom edge %s", name)
  27092. }
  27093. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  27094. type WpChatroomMemberMutation struct {
  27095. config
  27096. op Op
  27097. typ string
  27098. id *uint64
  27099. created_at *time.Time
  27100. updated_at *time.Time
  27101. status *uint8
  27102. addstatus *int8
  27103. wx_wxid *string
  27104. wxid *string
  27105. nickname *string
  27106. avatar *string
  27107. clearedFields map[string]struct{}
  27108. done bool
  27109. oldValue func(context.Context) (*WpChatroomMember, error)
  27110. predicates []predicate.WpChatroomMember
  27111. }
  27112. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  27113. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  27114. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  27115. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  27116. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  27117. m := &WpChatroomMemberMutation{
  27118. config: c,
  27119. op: op,
  27120. typ: TypeWpChatroomMember,
  27121. clearedFields: make(map[string]struct{}),
  27122. }
  27123. for _, opt := range opts {
  27124. opt(m)
  27125. }
  27126. return m
  27127. }
  27128. // withWpChatroomMemberID sets the ID field of the mutation.
  27129. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  27130. return func(m *WpChatroomMemberMutation) {
  27131. var (
  27132. err error
  27133. once sync.Once
  27134. value *WpChatroomMember
  27135. )
  27136. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  27137. once.Do(func() {
  27138. if m.done {
  27139. err = errors.New("querying old values post mutation is not allowed")
  27140. } else {
  27141. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  27142. }
  27143. })
  27144. return value, err
  27145. }
  27146. m.id = &id
  27147. }
  27148. }
  27149. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  27150. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  27151. return func(m *WpChatroomMemberMutation) {
  27152. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  27153. return node, nil
  27154. }
  27155. m.id = &node.ID
  27156. }
  27157. }
  27158. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27159. // executed in a transaction (ent.Tx), a transactional client is returned.
  27160. func (m WpChatroomMemberMutation) Client() *Client {
  27161. client := &Client{config: m.config}
  27162. client.init()
  27163. return client
  27164. }
  27165. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27166. // it returns an error otherwise.
  27167. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  27168. if _, ok := m.driver.(*txDriver); !ok {
  27169. return nil, errors.New("ent: mutation is not running in a transaction")
  27170. }
  27171. tx := &Tx{config: m.config}
  27172. tx.init()
  27173. return tx, nil
  27174. }
  27175. // SetID sets the value of the id field. Note that this
  27176. // operation is only accepted on creation of WpChatroomMember entities.
  27177. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  27178. m.id = &id
  27179. }
  27180. // ID returns the ID value in the mutation. Note that the ID is only available
  27181. // if it was provided to the builder or after it was returned from the database.
  27182. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  27183. if m.id == nil {
  27184. return
  27185. }
  27186. return *m.id, true
  27187. }
  27188. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27189. // That means, if the mutation is applied within a transaction with an isolation level such
  27190. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27191. // or updated by the mutation.
  27192. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  27193. switch {
  27194. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27195. id, exists := m.ID()
  27196. if exists {
  27197. return []uint64{id}, nil
  27198. }
  27199. fallthrough
  27200. case m.op.Is(OpUpdate | OpDelete):
  27201. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  27202. default:
  27203. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27204. }
  27205. }
  27206. // SetCreatedAt sets the "created_at" field.
  27207. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  27208. m.created_at = &t
  27209. }
  27210. // CreatedAt returns the value of the "created_at" field in the mutation.
  27211. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  27212. v := m.created_at
  27213. if v == nil {
  27214. return
  27215. }
  27216. return *v, true
  27217. }
  27218. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  27219. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27221. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27222. if !m.op.Is(OpUpdateOne) {
  27223. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27224. }
  27225. if m.id == nil || m.oldValue == nil {
  27226. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27227. }
  27228. oldValue, err := m.oldValue(ctx)
  27229. if err != nil {
  27230. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27231. }
  27232. return oldValue.CreatedAt, nil
  27233. }
  27234. // ResetCreatedAt resets all changes to the "created_at" field.
  27235. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  27236. m.created_at = nil
  27237. }
  27238. // SetUpdatedAt sets the "updated_at" field.
  27239. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  27240. m.updated_at = &t
  27241. }
  27242. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27243. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  27244. v := m.updated_at
  27245. if v == nil {
  27246. return
  27247. }
  27248. return *v, true
  27249. }
  27250. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  27251. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27253. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27254. if !m.op.Is(OpUpdateOne) {
  27255. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27256. }
  27257. if m.id == nil || m.oldValue == nil {
  27258. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27259. }
  27260. oldValue, err := m.oldValue(ctx)
  27261. if err != nil {
  27262. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27263. }
  27264. return oldValue.UpdatedAt, nil
  27265. }
  27266. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27267. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  27268. m.updated_at = nil
  27269. }
  27270. // SetStatus sets the "status" field.
  27271. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  27272. m.status = &u
  27273. m.addstatus = nil
  27274. }
  27275. // Status returns the value of the "status" field in the mutation.
  27276. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  27277. v := m.status
  27278. if v == nil {
  27279. return
  27280. }
  27281. return *v, true
  27282. }
  27283. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  27284. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27286. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27287. if !m.op.Is(OpUpdateOne) {
  27288. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27289. }
  27290. if m.id == nil || m.oldValue == nil {
  27291. return v, errors.New("OldStatus requires an ID field in the mutation")
  27292. }
  27293. oldValue, err := m.oldValue(ctx)
  27294. if err != nil {
  27295. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27296. }
  27297. return oldValue.Status, nil
  27298. }
  27299. // AddStatus adds u to the "status" field.
  27300. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  27301. if m.addstatus != nil {
  27302. *m.addstatus += u
  27303. } else {
  27304. m.addstatus = &u
  27305. }
  27306. }
  27307. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27308. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  27309. v := m.addstatus
  27310. if v == nil {
  27311. return
  27312. }
  27313. return *v, true
  27314. }
  27315. // ClearStatus clears the value of the "status" field.
  27316. func (m *WpChatroomMemberMutation) ClearStatus() {
  27317. m.status = nil
  27318. m.addstatus = nil
  27319. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  27320. }
  27321. // StatusCleared returns if the "status" field was cleared in this mutation.
  27322. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  27323. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  27324. return ok
  27325. }
  27326. // ResetStatus resets all changes to the "status" field.
  27327. func (m *WpChatroomMemberMutation) ResetStatus() {
  27328. m.status = nil
  27329. m.addstatus = nil
  27330. delete(m.clearedFields, wpchatroommember.FieldStatus)
  27331. }
  27332. // SetWxWxid sets the "wx_wxid" field.
  27333. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  27334. m.wx_wxid = &s
  27335. }
  27336. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  27337. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  27338. v := m.wx_wxid
  27339. if v == nil {
  27340. return
  27341. }
  27342. return *v, true
  27343. }
  27344. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  27345. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27347. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  27348. if !m.op.Is(OpUpdateOne) {
  27349. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  27350. }
  27351. if m.id == nil || m.oldValue == nil {
  27352. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  27353. }
  27354. oldValue, err := m.oldValue(ctx)
  27355. if err != nil {
  27356. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  27357. }
  27358. return oldValue.WxWxid, nil
  27359. }
  27360. // ResetWxWxid resets all changes to the "wx_wxid" field.
  27361. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  27362. m.wx_wxid = nil
  27363. }
  27364. // SetWxid sets the "wxid" field.
  27365. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  27366. m.wxid = &s
  27367. }
  27368. // Wxid returns the value of the "wxid" field in the mutation.
  27369. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  27370. v := m.wxid
  27371. if v == nil {
  27372. return
  27373. }
  27374. return *v, true
  27375. }
  27376. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  27377. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27379. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  27380. if !m.op.Is(OpUpdateOne) {
  27381. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  27382. }
  27383. if m.id == nil || m.oldValue == nil {
  27384. return v, errors.New("OldWxid requires an ID field in the mutation")
  27385. }
  27386. oldValue, err := m.oldValue(ctx)
  27387. if err != nil {
  27388. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  27389. }
  27390. return oldValue.Wxid, nil
  27391. }
  27392. // ResetWxid resets all changes to the "wxid" field.
  27393. func (m *WpChatroomMemberMutation) ResetWxid() {
  27394. m.wxid = nil
  27395. }
  27396. // SetNickname sets the "nickname" field.
  27397. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  27398. m.nickname = &s
  27399. }
  27400. // Nickname returns the value of the "nickname" field in the mutation.
  27401. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  27402. v := m.nickname
  27403. if v == nil {
  27404. return
  27405. }
  27406. return *v, true
  27407. }
  27408. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  27409. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27411. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  27412. if !m.op.Is(OpUpdateOne) {
  27413. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  27414. }
  27415. if m.id == nil || m.oldValue == nil {
  27416. return v, errors.New("OldNickname requires an ID field in the mutation")
  27417. }
  27418. oldValue, err := m.oldValue(ctx)
  27419. if err != nil {
  27420. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  27421. }
  27422. return oldValue.Nickname, nil
  27423. }
  27424. // ResetNickname resets all changes to the "nickname" field.
  27425. func (m *WpChatroomMemberMutation) ResetNickname() {
  27426. m.nickname = nil
  27427. }
  27428. // SetAvatar sets the "avatar" field.
  27429. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  27430. m.avatar = &s
  27431. }
  27432. // Avatar returns the value of the "avatar" field in the mutation.
  27433. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  27434. v := m.avatar
  27435. if v == nil {
  27436. return
  27437. }
  27438. return *v, true
  27439. }
  27440. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  27441. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27443. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  27444. if !m.op.Is(OpUpdateOne) {
  27445. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  27446. }
  27447. if m.id == nil || m.oldValue == nil {
  27448. return v, errors.New("OldAvatar requires an ID field in the mutation")
  27449. }
  27450. oldValue, err := m.oldValue(ctx)
  27451. if err != nil {
  27452. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  27453. }
  27454. return oldValue.Avatar, nil
  27455. }
  27456. // ResetAvatar resets all changes to the "avatar" field.
  27457. func (m *WpChatroomMemberMutation) ResetAvatar() {
  27458. m.avatar = nil
  27459. }
  27460. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  27461. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  27462. m.predicates = append(m.predicates, ps...)
  27463. }
  27464. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  27465. // users can use type-assertion to append predicates that do not depend on any generated package.
  27466. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  27467. p := make([]predicate.WpChatroomMember, len(ps))
  27468. for i := range ps {
  27469. p[i] = ps[i]
  27470. }
  27471. m.Where(p...)
  27472. }
  27473. // Op returns the operation name.
  27474. func (m *WpChatroomMemberMutation) Op() Op {
  27475. return m.op
  27476. }
  27477. // SetOp allows setting the mutation operation.
  27478. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  27479. m.op = op
  27480. }
  27481. // Type returns the node type of this mutation (WpChatroomMember).
  27482. func (m *WpChatroomMemberMutation) Type() string {
  27483. return m.typ
  27484. }
  27485. // Fields returns all fields that were changed during this mutation. Note that in
  27486. // order to get all numeric fields that were incremented/decremented, call
  27487. // AddedFields().
  27488. func (m *WpChatroomMemberMutation) Fields() []string {
  27489. fields := make([]string, 0, 7)
  27490. if m.created_at != nil {
  27491. fields = append(fields, wpchatroommember.FieldCreatedAt)
  27492. }
  27493. if m.updated_at != nil {
  27494. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  27495. }
  27496. if m.status != nil {
  27497. fields = append(fields, wpchatroommember.FieldStatus)
  27498. }
  27499. if m.wx_wxid != nil {
  27500. fields = append(fields, wpchatroommember.FieldWxWxid)
  27501. }
  27502. if m.wxid != nil {
  27503. fields = append(fields, wpchatroommember.FieldWxid)
  27504. }
  27505. if m.nickname != nil {
  27506. fields = append(fields, wpchatroommember.FieldNickname)
  27507. }
  27508. if m.avatar != nil {
  27509. fields = append(fields, wpchatroommember.FieldAvatar)
  27510. }
  27511. return fields
  27512. }
  27513. // Field returns the value of a field with the given name. The second boolean
  27514. // return value indicates that this field was not set, or was not defined in the
  27515. // schema.
  27516. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  27517. switch name {
  27518. case wpchatroommember.FieldCreatedAt:
  27519. return m.CreatedAt()
  27520. case wpchatroommember.FieldUpdatedAt:
  27521. return m.UpdatedAt()
  27522. case wpchatroommember.FieldStatus:
  27523. return m.Status()
  27524. case wpchatroommember.FieldWxWxid:
  27525. return m.WxWxid()
  27526. case wpchatroommember.FieldWxid:
  27527. return m.Wxid()
  27528. case wpchatroommember.FieldNickname:
  27529. return m.Nickname()
  27530. case wpchatroommember.FieldAvatar:
  27531. return m.Avatar()
  27532. }
  27533. return nil, false
  27534. }
  27535. // OldField returns the old value of the field from the database. An error is
  27536. // returned if the mutation operation is not UpdateOne, or the query to the
  27537. // database failed.
  27538. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27539. switch name {
  27540. case wpchatroommember.FieldCreatedAt:
  27541. return m.OldCreatedAt(ctx)
  27542. case wpchatroommember.FieldUpdatedAt:
  27543. return m.OldUpdatedAt(ctx)
  27544. case wpchatroommember.FieldStatus:
  27545. return m.OldStatus(ctx)
  27546. case wpchatroommember.FieldWxWxid:
  27547. return m.OldWxWxid(ctx)
  27548. case wpchatroommember.FieldWxid:
  27549. return m.OldWxid(ctx)
  27550. case wpchatroommember.FieldNickname:
  27551. return m.OldNickname(ctx)
  27552. case wpchatroommember.FieldAvatar:
  27553. return m.OldAvatar(ctx)
  27554. }
  27555. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  27556. }
  27557. // SetField sets the value of a field with the given name. It returns an error if
  27558. // the field is not defined in the schema, or if the type mismatched the field
  27559. // type.
  27560. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  27561. switch name {
  27562. case wpchatroommember.FieldCreatedAt:
  27563. v, ok := value.(time.Time)
  27564. if !ok {
  27565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27566. }
  27567. m.SetCreatedAt(v)
  27568. return nil
  27569. case wpchatroommember.FieldUpdatedAt:
  27570. v, ok := value.(time.Time)
  27571. if !ok {
  27572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27573. }
  27574. m.SetUpdatedAt(v)
  27575. return nil
  27576. case wpchatroommember.FieldStatus:
  27577. v, ok := value.(uint8)
  27578. if !ok {
  27579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27580. }
  27581. m.SetStatus(v)
  27582. return nil
  27583. case wpchatroommember.FieldWxWxid:
  27584. v, ok := value.(string)
  27585. if !ok {
  27586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27587. }
  27588. m.SetWxWxid(v)
  27589. return nil
  27590. case wpchatroommember.FieldWxid:
  27591. v, ok := value.(string)
  27592. if !ok {
  27593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27594. }
  27595. m.SetWxid(v)
  27596. return nil
  27597. case wpchatroommember.FieldNickname:
  27598. v, ok := value.(string)
  27599. if !ok {
  27600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27601. }
  27602. m.SetNickname(v)
  27603. return nil
  27604. case wpchatroommember.FieldAvatar:
  27605. v, ok := value.(string)
  27606. if !ok {
  27607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27608. }
  27609. m.SetAvatar(v)
  27610. return nil
  27611. }
  27612. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  27613. }
  27614. // AddedFields returns all numeric fields that were incremented/decremented during
  27615. // this mutation.
  27616. func (m *WpChatroomMemberMutation) AddedFields() []string {
  27617. var fields []string
  27618. if m.addstatus != nil {
  27619. fields = append(fields, wpchatroommember.FieldStatus)
  27620. }
  27621. return fields
  27622. }
  27623. // AddedField returns the numeric value that was incremented/decremented on a field
  27624. // with the given name. The second boolean return value indicates that this field
  27625. // was not set, or was not defined in the schema.
  27626. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  27627. switch name {
  27628. case wpchatroommember.FieldStatus:
  27629. return m.AddedStatus()
  27630. }
  27631. return nil, false
  27632. }
  27633. // AddField adds the value to the field with the given name. It returns an error if
  27634. // the field is not defined in the schema, or if the type mismatched the field
  27635. // type.
  27636. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  27637. switch name {
  27638. case wpchatroommember.FieldStatus:
  27639. v, ok := value.(int8)
  27640. if !ok {
  27641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27642. }
  27643. m.AddStatus(v)
  27644. return nil
  27645. }
  27646. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  27647. }
  27648. // ClearedFields returns all nullable fields that were cleared during this
  27649. // mutation.
  27650. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  27651. var fields []string
  27652. if m.FieldCleared(wpchatroommember.FieldStatus) {
  27653. fields = append(fields, wpchatroommember.FieldStatus)
  27654. }
  27655. return fields
  27656. }
  27657. // FieldCleared returns a boolean indicating if a field with the given name was
  27658. // cleared in this mutation.
  27659. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  27660. _, ok := m.clearedFields[name]
  27661. return ok
  27662. }
  27663. // ClearField clears the value of the field with the given name. It returns an
  27664. // error if the field is not defined in the schema.
  27665. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  27666. switch name {
  27667. case wpchatroommember.FieldStatus:
  27668. m.ClearStatus()
  27669. return nil
  27670. }
  27671. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  27672. }
  27673. // ResetField resets all changes in the mutation for the field with the given name.
  27674. // It returns an error if the field is not defined in the schema.
  27675. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  27676. switch name {
  27677. case wpchatroommember.FieldCreatedAt:
  27678. m.ResetCreatedAt()
  27679. return nil
  27680. case wpchatroommember.FieldUpdatedAt:
  27681. m.ResetUpdatedAt()
  27682. return nil
  27683. case wpchatroommember.FieldStatus:
  27684. m.ResetStatus()
  27685. return nil
  27686. case wpchatroommember.FieldWxWxid:
  27687. m.ResetWxWxid()
  27688. return nil
  27689. case wpchatroommember.FieldWxid:
  27690. m.ResetWxid()
  27691. return nil
  27692. case wpchatroommember.FieldNickname:
  27693. m.ResetNickname()
  27694. return nil
  27695. case wpchatroommember.FieldAvatar:
  27696. m.ResetAvatar()
  27697. return nil
  27698. }
  27699. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  27700. }
  27701. // AddedEdges returns all edge names that were set/added in this mutation.
  27702. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  27703. edges := make([]string, 0, 0)
  27704. return edges
  27705. }
  27706. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27707. // name in this mutation.
  27708. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  27709. return nil
  27710. }
  27711. // RemovedEdges returns all edge names that were removed in this mutation.
  27712. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  27713. edges := make([]string, 0, 0)
  27714. return edges
  27715. }
  27716. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27717. // the given name in this mutation.
  27718. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  27719. return nil
  27720. }
  27721. // ClearedEdges returns all edge names that were cleared in this mutation.
  27722. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  27723. edges := make([]string, 0, 0)
  27724. return edges
  27725. }
  27726. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27727. // was cleared in this mutation.
  27728. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  27729. return false
  27730. }
  27731. // ClearEdge clears the value of the edge with the given name. It returns an error
  27732. // if that edge is not defined in the schema.
  27733. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  27734. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  27735. }
  27736. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27737. // It returns an error if the edge is not defined in the schema.
  27738. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  27739. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  27740. }
  27741. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  27742. type WxMutation struct {
  27743. config
  27744. op Op
  27745. typ string
  27746. id *uint64
  27747. created_at *time.Time
  27748. updated_at *time.Time
  27749. status *uint8
  27750. addstatus *int8
  27751. deleted_at *time.Time
  27752. port *string
  27753. process_id *string
  27754. callback *string
  27755. wxid *string
  27756. account *string
  27757. nickname *string
  27758. tel *string
  27759. head_big *string
  27760. organization_id *uint64
  27761. addorganization_id *int64
  27762. api_base *string
  27763. api_key *string
  27764. allow_list *[]string
  27765. appendallow_list []string
  27766. group_allow_list *[]string
  27767. appendgroup_allow_list []string
  27768. block_list *[]string
  27769. appendblock_list []string
  27770. group_block_list *[]string
  27771. appendgroup_block_list []string
  27772. clearedFields map[string]struct{}
  27773. server *uint64
  27774. clearedserver bool
  27775. agent *uint64
  27776. clearedagent bool
  27777. done bool
  27778. oldValue func(context.Context) (*Wx, error)
  27779. predicates []predicate.Wx
  27780. }
  27781. var _ ent.Mutation = (*WxMutation)(nil)
  27782. // wxOption allows management of the mutation configuration using functional options.
  27783. type wxOption func(*WxMutation)
  27784. // newWxMutation creates new mutation for the Wx entity.
  27785. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  27786. m := &WxMutation{
  27787. config: c,
  27788. op: op,
  27789. typ: TypeWx,
  27790. clearedFields: make(map[string]struct{}),
  27791. }
  27792. for _, opt := range opts {
  27793. opt(m)
  27794. }
  27795. return m
  27796. }
  27797. // withWxID sets the ID field of the mutation.
  27798. func withWxID(id uint64) wxOption {
  27799. return func(m *WxMutation) {
  27800. var (
  27801. err error
  27802. once sync.Once
  27803. value *Wx
  27804. )
  27805. m.oldValue = func(ctx context.Context) (*Wx, error) {
  27806. once.Do(func() {
  27807. if m.done {
  27808. err = errors.New("querying old values post mutation is not allowed")
  27809. } else {
  27810. value, err = m.Client().Wx.Get(ctx, id)
  27811. }
  27812. })
  27813. return value, err
  27814. }
  27815. m.id = &id
  27816. }
  27817. }
  27818. // withWx sets the old Wx of the mutation.
  27819. func withWx(node *Wx) wxOption {
  27820. return func(m *WxMutation) {
  27821. m.oldValue = func(context.Context) (*Wx, error) {
  27822. return node, nil
  27823. }
  27824. m.id = &node.ID
  27825. }
  27826. }
  27827. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27828. // executed in a transaction (ent.Tx), a transactional client is returned.
  27829. func (m WxMutation) Client() *Client {
  27830. client := &Client{config: m.config}
  27831. client.init()
  27832. return client
  27833. }
  27834. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27835. // it returns an error otherwise.
  27836. func (m WxMutation) Tx() (*Tx, error) {
  27837. if _, ok := m.driver.(*txDriver); !ok {
  27838. return nil, errors.New("ent: mutation is not running in a transaction")
  27839. }
  27840. tx := &Tx{config: m.config}
  27841. tx.init()
  27842. return tx, nil
  27843. }
  27844. // SetID sets the value of the id field. Note that this
  27845. // operation is only accepted on creation of Wx entities.
  27846. func (m *WxMutation) SetID(id uint64) {
  27847. m.id = &id
  27848. }
  27849. // ID returns the ID value in the mutation. Note that the ID is only available
  27850. // if it was provided to the builder or after it was returned from the database.
  27851. func (m *WxMutation) ID() (id uint64, exists bool) {
  27852. if m.id == nil {
  27853. return
  27854. }
  27855. return *m.id, true
  27856. }
  27857. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27858. // That means, if the mutation is applied within a transaction with an isolation level such
  27859. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27860. // or updated by the mutation.
  27861. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  27862. switch {
  27863. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27864. id, exists := m.ID()
  27865. if exists {
  27866. return []uint64{id}, nil
  27867. }
  27868. fallthrough
  27869. case m.op.Is(OpUpdate | OpDelete):
  27870. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  27871. default:
  27872. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27873. }
  27874. }
  27875. // SetCreatedAt sets the "created_at" field.
  27876. func (m *WxMutation) SetCreatedAt(t time.Time) {
  27877. m.created_at = &t
  27878. }
  27879. // CreatedAt returns the value of the "created_at" field in the mutation.
  27880. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  27881. v := m.created_at
  27882. if v == nil {
  27883. return
  27884. }
  27885. return *v, true
  27886. }
  27887. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  27888. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27890. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27891. if !m.op.Is(OpUpdateOne) {
  27892. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27893. }
  27894. if m.id == nil || m.oldValue == nil {
  27895. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27896. }
  27897. oldValue, err := m.oldValue(ctx)
  27898. if err != nil {
  27899. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27900. }
  27901. return oldValue.CreatedAt, nil
  27902. }
  27903. // ResetCreatedAt resets all changes to the "created_at" field.
  27904. func (m *WxMutation) ResetCreatedAt() {
  27905. m.created_at = nil
  27906. }
  27907. // SetUpdatedAt sets the "updated_at" field.
  27908. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  27909. m.updated_at = &t
  27910. }
  27911. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27912. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  27913. v := m.updated_at
  27914. if v == nil {
  27915. return
  27916. }
  27917. return *v, true
  27918. }
  27919. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  27920. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27922. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27923. if !m.op.Is(OpUpdateOne) {
  27924. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27925. }
  27926. if m.id == nil || m.oldValue == nil {
  27927. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27928. }
  27929. oldValue, err := m.oldValue(ctx)
  27930. if err != nil {
  27931. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27932. }
  27933. return oldValue.UpdatedAt, nil
  27934. }
  27935. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27936. func (m *WxMutation) ResetUpdatedAt() {
  27937. m.updated_at = nil
  27938. }
  27939. // SetStatus sets the "status" field.
  27940. func (m *WxMutation) SetStatus(u uint8) {
  27941. m.status = &u
  27942. m.addstatus = nil
  27943. }
  27944. // Status returns the value of the "status" field in the mutation.
  27945. func (m *WxMutation) Status() (r uint8, exists bool) {
  27946. v := m.status
  27947. if v == nil {
  27948. return
  27949. }
  27950. return *v, true
  27951. }
  27952. // OldStatus returns the old "status" field's value of the Wx entity.
  27953. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27955. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27956. if !m.op.Is(OpUpdateOne) {
  27957. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27958. }
  27959. if m.id == nil || m.oldValue == nil {
  27960. return v, errors.New("OldStatus requires an ID field in the mutation")
  27961. }
  27962. oldValue, err := m.oldValue(ctx)
  27963. if err != nil {
  27964. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27965. }
  27966. return oldValue.Status, nil
  27967. }
  27968. // AddStatus adds u to the "status" field.
  27969. func (m *WxMutation) AddStatus(u int8) {
  27970. if m.addstatus != nil {
  27971. *m.addstatus += u
  27972. } else {
  27973. m.addstatus = &u
  27974. }
  27975. }
  27976. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27977. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  27978. v := m.addstatus
  27979. if v == nil {
  27980. return
  27981. }
  27982. return *v, true
  27983. }
  27984. // ClearStatus clears the value of the "status" field.
  27985. func (m *WxMutation) ClearStatus() {
  27986. m.status = nil
  27987. m.addstatus = nil
  27988. m.clearedFields[wx.FieldStatus] = struct{}{}
  27989. }
  27990. // StatusCleared returns if the "status" field was cleared in this mutation.
  27991. func (m *WxMutation) StatusCleared() bool {
  27992. _, ok := m.clearedFields[wx.FieldStatus]
  27993. return ok
  27994. }
  27995. // ResetStatus resets all changes to the "status" field.
  27996. func (m *WxMutation) ResetStatus() {
  27997. m.status = nil
  27998. m.addstatus = nil
  27999. delete(m.clearedFields, wx.FieldStatus)
  28000. }
  28001. // SetDeletedAt sets the "deleted_at" field.
  28002. func (m *WxMutation) SetDeletedAt(t time.Time) {
  28003. m.deleted_at = &t
  28004. }
  28005. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28006. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  28007. v := m.deleted_at
  28008. if v == nil {
  28009. return
  28010. }
  28011. return *v, true
  28012. }
  28013. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  28014. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28016. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28017. if !m.op.Is(OpUpdateOne) {
  28018. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28019. }
  28020. if m.id == nil || m.oldValue == nil {
  28021. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28022. }
  28023. oldValue, err := m.oldValue(ctx)
  28024. if err != nil {
  28025. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28026. }
  28027. return oldValue.DeletedAt, nil
  28028. }
  28029. // ClearDeletedAt clears the value of the "deleted_at" field.
  28030. func (m *WxMutation) ClearDeletedAt() {
  28031. m.deleted_at = nil
  28032. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  28033. }
  28034. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28035. func (m *WxMutation) DeletedAtCleared() bool {
  28036. _, ok := m.clearedFields[wx.FieldDeletedAt]
  28037. return ok
  28038. }
  28039. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28040. func (m *WxMutation) ResetDeletedAt() {
  28041. m.deleted_at = nil
  28042. delete(m.clearedFields, wx.FieldDeletedAt)
  28043. }
  28044. // SetServerID sets the "server_id" field.
  28045. func (m *WxMutation) SetServerID(u uint64) {
  28046. m.server = &u
  28047. }
  28048. // ServerID returns the value of the "server_id" field in the mutation.
  28049. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  28050. v := m.server
  28051. if v == nil {
  28052. return
  28053. }
  28054. return *v, true
  28055. }
  28056. // OldServerID returns the old "server_id" field's value of the Wx entity.
  28057. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28058. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28059. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  28060. if !m.op.Is(OpUpdateOne) {
  28061. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  28062. }
  28063. if m.id == nil || m.oldValue == nil {
  28064. return v, errors.New("OldServerID requires an ID field in the mutation")
  28065. }
  28066. oldValue, err := m.oldValue(ctx)
  28067. if err != nil {
  28068. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  28069. }
  28070. return oldValue.ServerID, nil
  28071. }
  28072. // ClearServerID clears the value of the "server_id" field.
  28073. func (m *WxMutation) ClearServerID() {
  28074. m.server = nil
  28075. m.clearedFields[wx.FieldServerID] = struct{}{}
  28076. }
  28077. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  28078. func (m *WxMutation) ServerIDCleared() bool {
  28079. _, ok := m.clearedFields[wx.FieldServerID]
  28080. return ok
  28081. }
  28082. // ResetServerID resets all changes to the "server_id" field.
  28083. func (m *WxMutation) ResetServerID() {
  28084. m.server = nil
  28085. delete(m.clearedFields, wx.FieldServerID)
  28086. }
  28087. // SetPort sets the "port" field.
  28088. func (m *WxMutation) SetPort(s string) {
  28089. m.port = &s
  28090. }
  28091. // Port returns the value of the "port" field in the mutation.
  28092. func (m *WxMutation) Port() (r string, exists bool) {
  28093. v := m.port
  28094. if v == nil {
  28095. return
  28096. }
  28097. return *v, true
  28098. }
  28099. // OldPort returns the old "port" field's value of the Wx entity.
  28100. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28102. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  28103. if !m.op.Is(OpUpdateOne) {
  28104. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  28105. }
  28106. if m.id == nil || m.oldValue == nil {
  28107. return v, errors.New("OldPort requires an ID field in the mutation")
  28108. }
  28109. oldValue, err := m.oldValue(ctx)
  28110. if err != nil {
  28111. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  28112. }
  28113. return oldValue.Port, nil
  28114. }
  28115. // ResetPort resets all changes to the "port" field.
  28116. func (m *WxMutation) ResetPort() {
  28117. m.port = nil
  28118. }
  28119. // SetProcessID sets the "process_id" field.
  28120. func (m *WxMutation) SetProcessID(s string) {
  28121. m.process_id = &s
  28122. }
  28123. // ProcessID returns the value of the "process_id" field in the mutation.
  28124. func (m *WxMutation) ProcessID() (r string, exists bool) {
  28125. v := m.process_id
  28126. if v == nil {
  28127. return
  28128. }
  28129. return *v, true
  28130. }
  28131. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  28132. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28134. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  28135. if !m.op.Is(OpUpdateOne) {
  28136. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  28137. }
  28138. if m.id == nil || m.oldValue == nil {
  28139. return v, errors.New("OldProcessID requires an ID field in the mutation")
  28140. }
  28141. oldValue, err := m.oldValue(ctx)
  28142. if err != nil {
  28143. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  28144. }
  28145. return oldValue.ProcessID, nil
  28146. }
  28147. // ResetProcessID resets all changes to the "process_id" field.
  28148. func (m *WxMutation) ResetProcessID() {
  28149. m.process_id = nil
  28150. }
  28151. // SetCallback sets the "callback" field.
  28152. func (m *WxMutation) SetCallback(s string) {
  28153. m.callback = &s
  28154. }
  28155. // Callback returns the value of the "callback" field in the mutation.
  28156. func (m *WxMutation) Callback() (r string, exists bool) {
  28157. v := m.callback
  28158. if v == nil {
  28159. return
  28160. }
  28161. return *v, true
  28162. }
  28163. // OldCallback returns the old "callback" field's value of the Wx entity.
  28164. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28166. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  28167. if !m.op.Is(OpUpdateOne) {
  28168. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  28169. }
  28170. if m.id == nil || m.oldValue == nil {
  28171. return v, errors.New("OldCallback requires an ID field in the mutation")
  28172. }
  28173. oldValue, err := m.oldValue(ctx)
  28174. if err != nil {
  28175. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  28176. }
  28177. return oldValue.Callback, nil
  28178. }
  28179. // ResetCallback resets all changes to the "callback" field.
  28180. func (m *WxMutation) ResetCallback() {
  28181. m.callback = nil
  28182. }
  28183. // SetWxid sets the "wxid" field.
  28184. func (m *WxMutation) SetWxid(s string) {
  28185. m.wxid = &s
  28186. }
  28187. // Wxid returns the value of the "wxid" field in the mutation.
  28188. func (m *WxMutation) Wxid() (r string, exists bool) {
  28189. v := m.wxid
  28190. if v == nil {
  28191. return
  28192. }
  28193. return *v, true
  28194. }
  28195. // OldWxid returns the old "wxid" field's value of the Wx entity.
  28196. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28198. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  28199. if !m.op.Is(OpUpdateOne) {
  28200. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  28201. }
  28202. if m.id == nil || m.oldValue == nil {
  28203. return v, errors.New("OldWxid requires an ID field in the mutation")
  28204. }
  28205. oldValue, err := m.oldValue(ctx)
  28206. if err != nil {
  28207. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  28208. }
  28209. return oldValue.Wxid, nil
  28210. }
  28211. // ResetWxid resets all changes to the "wxid" field.
  28212. func (m *WxMutation) ResetWxid() {
  28213. m.wxid = nil
  28214. }
  28215. // SetAccount sets the "account" field.
  28216. func (m *WxMutation) SetAccount(s string) {
  28217. m.account = &s
  28218. }
  28219. // Account returns the value of the "account" field in the mutation.
  28220. func (m *WxMutation) Account() (r string, exists bool) {
  28221. v := m.account
  28222. if v == nil {
  28223. return
  28224. }
  28225. return *v, true
  28226. }
  28227. // OldAccount returns the old "account" field's value of the Wx entity.
  28228. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28230. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  28231. if !m.op.Is(OpUpdateOne) {
  28232. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  28233. }
  28234. if m.id == nil || m.oldValue == nil {
  28235. return v, errors.New("OldAccount requires an ID field in the mutation")
  28236. }
  28237. oldValue, err := m.oldValue(ctx)
  28238. if err != nil {
  28239. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  28240. }
  28241. return oldValue.Account, nil
  28242. }
  28243. // ResetAccount resets all changes to the "account" field.
  28244. func (m *WxMutation) ResetAccount() {
  28245. m.account = nil
  28246. }
  28247. // SetNickname sets the "nickname" field.
  28248. func (m *WxMutation) SetNickname(s string) {
  28249. m.nickname = &s
  28250. }
  28251. // Nickname returns the value of the "nickname" field in the mutation.
  28252. func (m *WxMutation) Nickname() (r string, exists bool) {
  28253. v := m.nickname
  28254. if v == nil {
  28255. return
  28256. }
  28257. return *v, true
  28258. }
  28259. // OldNickname returns the old "nickname" field's value of the Wx entity.
  28260. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28262. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  28263. if !m.op.Is(OpUpdateOne) {
  28264. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  28265. }
  28266. if m.id == nil || m.oldValue == nil {
  28267. return v, errors.New("OldNickname requires an ID field in the mutation")
  28268. }
  28269. oldValue, err := m.oldValue(ctx)
  28270. if err != nil {
  28271. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  28272. }
  28273. return oldValue.Nickname, nil
  28274. }
  28275. // ResetNickname resets all changes to the "nickname" field.
  28276. func (m *WxMutation) ResetNickname() {
  28277. m.nickname = nil
  28278. }
  28279. // SetTel sets the "tel" field.
  28280. func (m *WxMutation) SetTel(s string) {
  28281. m.tel = &s
  28282. }
  28283. // Tel returns the value of the "tel" field in the mutation.
  28284. func (m *WxMutation) Tel() (r string, exists bool) {
  28285. v := m.tel
  28286. if v == nil {
  28287. return
  28288. }
  28289. return *v, true
  28290. }
  28291. // OldTel returns the old "tel" field's value of the Wx entity.
  28292. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28294. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  28295. if !m.op.Is(OpUpdateOne) {
  28296. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  28297. }
  28298. if m.id == nil || m.oldValue == nil {
  28299. return v, errors.New("OldTel requires an ID field in the mutation")
  28300. }
  28301. oldValue, err := m.oldValue(ctx)
  28302. if err != nil {
  28303. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  28304. }
  28305. return oldValue.Tel, nil
  28306. }
  28307. // ResetTel resets all changes to the "tel" field.
  28308. func (m *WxMutation) ResetTel() {
  28309. m.tel = nil
  28310. }
  28311. // SetHeadBig sets the "head_big" field.
  28312. func (m *WxMutation) SetHeadBig(s string) {
  28313. m.head_big = &s
  28314. }
  28315. // HeadBig returns the value of the "head_big" field in the mutation.
  28316. func (m *WxMutation) HeadBig() (r string, exists bool) {
  28317. v := m.head_big
  28318. if v == nil {
  28319. return
  28320. }
  28321. return *v, true
  28322. }
  28323. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  28324. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28326. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  28327. if !m.op.Is(OpUpdateOne) {
  28328. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  28329. }
  28330. if m.id == nil || m.oldValue == nil {
  28331. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  28332. }
  28333. oldValue, err := m.oldValue(ctx)
  28334. if err != nil {
  28335. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  28336. }
  28337. return oldValue.HeadBig, nil
  28338. }
  28339. // ResetHeadBig resets all changes to the "head_big" field.
  28340. func (m *WxMutation) ResetHeadBig() {
  28341. m.head_big = nil
  28342. }
  28343. // SetOrganizationID sets the "organization_id" field.
  28344. func (m *WxMutation) SetOrganizationID(u uint64) {
  28345. m.organization_id = &u
  28346. m.addorganization_id = nil
  28347. }
  28348. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28349. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  28350. v := m.organization_id
  28351. if v == nil {
  28352. return
  28353. }
  28354. return *v, true
  28355. }
  28356. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  28357. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28359. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28360. if !m.op.Is(OpUpdateOne) {
  28361. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28362. }
  28363. if m.id == nil || m.oldValue == nil {
  28364. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28365. }
  28366. oldValue, err := m.oldValue(ctx)
  28367. if err != nil {
  28368. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28369. }
  28370. return oldValue.OrganizationID, nil
  28371. }
  28372. // AddOrganizationID adds u to the "organization_id" field.
  28373. func (m *WxMutation) AddOrganizationID(u int64) {
  28374. if m.addorganization_id != nil {
  28375. *m.addorganization_id += u
  28376. } else {
  28377. m.addorganization_id = &u
  28378. }
  28379. }
  28380. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28381. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  28382. v := m.addorganization_id
  28383. if v == nil {
  28384. return
  28385. }
  28386. return *v, true
  28387. }
  28388. // ClearOrganizationID clears the value of the "organization_id" field.
  28389. func (m *WxMutation) ClearOrganizationID() {
  28390. m.organization_id = nil
  28391. m.addorganization_id = nil
  28392. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  28393. }
  28394. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28395. func (m *WxMutation) OrganizationIDCleared() bool {
  28396. _, ok := m.clearedFields[wx.FieldOrganizationID]
  28397. return ok
  28398. }
  28399. // ResetOrganizationID resets all changes to the "organization_id" field.
  28400. func (m *WxMutation) ResetOrganizationID() {
  28401. m.organization_id = nil
  28402. m.addorganization_id = nil
  28403. delete(m.clearedFields, wx.FieldOrganizationID)
  28404. }
  28405. // SetAgentID sets the "agent_id" field.
  28406. func (m *WxMutation) SetAgentID(u uint64) {
  28407. m.agent = &u
  28408. }
  28409. // AgentID returns the value of the "agent_id" field in the mutation.
  28410. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  28411. v := m.agent
  28412. if v == nil {
  28413. return
  28414. }
  28415. return *v, true
  28416. }
  28417. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  28418. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28420. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  28421. if !m.op.Is(OpUpdateOne) {
  28422. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  28423. }
  28424. if m.id == nil || m.oldValue == nil {
  28425. return v, errors.New("OldAgentID requires an ID field in the mutation")
  28426. }
  28427. oldValue, err := m.oldValue(ctx)
  28428. if err != nil {
  28429. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  28430. }
  28431. return oldValue.AgentID, nil
  28432. }
  28433. // ResetAgentID resets all changes to the "agent_id" field.
  28434. func (m *WxMutation) ResetAgentID() {
  28435. m.agent = nil
  28436. }
  28437. // SetAPIBase sets the "api_base" field.
  28438. func (m *WxMutation) SetAPIBase(s string) {
  28439. m.api_base = &s
  28440. }
  28441. // APIBase returns the value of the "api_base" field in the mutation.
  28442. func (m *WxMutation) APIBase() (r string, exists bool) {
  28443. v := m.api_base
  28444. if v == nil {
  28445. return
  28446. }
  28447. return *v, true
  28448. }
  28449. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  28450. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28452. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  28453. if !m.op.Is(OpUpdateOne) {
  28454. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  28455. }
  28456. if m.id == nil || m.oldValue == nil {
  28457. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  28458. }
  28459. oldValue, err := m.oldValue(ctx)
  28460. if err != nil {
  28461. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  28462. }
  28463. return oldValue.APIBase, nil
  28464. }
  28465. // ClearAPIBase clears the value of the "api_base" field.
  28466. func (m *WxMutation) ClearAPIBase() {
  28467. m.api_base = nil
  28468. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  28469. }
  28470. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  28471. func (m *WxMutation) APIBaseCleared() bool {
  28472. _, ok := m.clearedFields[wx.FieldAPIBase]
  28473. return ok
  28474. }
  28475. // ResetAPIBase resets all changes to the "api_base" field.
  28476. func (m *WxMutation) ResetAPIBase() {
  28477. m.api_base = nil
  28478. delete(m.clearedFields, wx.FieldAPIBase)
  28479. }
  28480. // SetAPIKey sets the "api_key" field.
  28481. func (m *WxMutation) SetAPIKey(s string) {
  28482. m.api_key = &s
  28483. }
  28484. // APIKey returns the value of the "api_key" field in the mutation.
  28485. func (m *WxMutation) APIKey() (r string, exists bool) {
  28486. v := m.api_key
  28487. if v == nil {
  28488. return
  28489. }
  28490. return *v, true
  28491. }
  28492. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  28493. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28495. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  28496. if !m.op.Is(OpUpdateOne) {
  28497. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  28498. }
  28499. if m.id == nil || m.oldValue == nil {
  28500. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  28501. }
  28502. oldValue, err := m.oldValue(ctx)
  28503. if err != nil {
  28504. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  28505. }
  28506. return oldValue.APIKey, nil
  28507. }
  28508. // ClearAPIKey clears the value of the "api_key" field.
  28509. func (m *WxMutation) ClearAPIKey() {
  28510. m.api_key = nil
  28511. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  28512. }
  28513. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  28514. func (m *WxMutation) APIKeyCleared() bool {
  28515. _, ok := m.clearedFields[wx.FieldAPIKey]
  28516. return ok
  28517. }
  28518. // ResetAPIKey resets all changes to the "api_key" field.
  28519. func (m *WxMutation) ResetAPIKey() {
  28520. m.api_key = nil
  28521. delete(m.clearedFields, wx.FieldAPIKey)
  28522. }
  28523. // SetAllowList sets the "allow_list" field.
  28524. func (m *WxMutation) SetAllowList(s []string) {
  28525. m.allow_list = &s
  28526. m.appendallow_list = nil
  28527. }
  28528. // AllowList returns the value of the "allow_list" field in the mutation.
  28529. func (m *WxMutation) AllowList() (r []string, exists bool) {
  28530. v := m.allow_list
  28531. if v == nil {
  28532. return
  28533. }
  28534. return *v, true
  28535. }
  28536. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  28537. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28539. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  28540. if !m.op.Is(OpUpdateOne) {
  28541. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  28542. }
  28543. if m.id == nil || m.oldValue == nil {
  28544. return v, errors.New("OldAllowList requires an ID field in the mutation")
  28545. }
  28546. oldValue, err := m.oldValue(ctx)
  28547. if err != nil {
  28548. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  28549. }
  28550. return oldValue.AllowList, nil
  28551. }
  28552. // AppendAllowList adds s to the "allow_list" field.
  28553. func (m *WxMutation) AppendAllowList(s []string) {
  28554. m.appendallow_list = append(m.appendallow_list, s...)
  28555. }
  28556. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  28557. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  28558. if len(m.appendallow_list) == 0 {
  28559. return nil, false
  28560. }
  28561. return m.appendallow_list, true
  28562. }
  28563. // ResetAllowList resets all changes to the "allow_list" field.
  28564. func (m *WxMutation) ResetAllowList() {
  28565. m.allow_list = nil
  28566. m.appendallow_list = nil
  28567. }
  28568. // SetGroupAllowList sets the "group_allow_list" field.
  28569. func (m *WxMutation) SetGroupAllowList(s []string) {
  28570. m.group_allow_list = &s
  28571. m.appendgroup_allow_list = nil
  28572. }
  28573. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  28574. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  28575. v := m.group_allow_list
  28576. if v == nil {
  28577. return
  28578. }
  28579. return *v, true
  28580. }
  28581. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  28582. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28584. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  28585. if !m.op.Is(OpUpdateOne) {
  28586. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  28587. }
  28588. if m.id == nil || m.oldValue == nil {
  28589. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  28590. }
  28591. oldValue, err := m.oldValue(ctx)
  28592. if err != nil {
  28593. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  28594. }
  28595. return oldValue.GroupAllowList, nil
  28596. }
  28597. // AppendGroupAllowList adds s to the "group_allow_list" field.
  28598. func (m *WxMutation) AppendGroupAllowList(s []string) {
  28599. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  28600. }
  28601. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  28602. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  28603. if len(m.appendgroup_allow_list) == 0 {
  28604. return nil, false
  28605. }
  28606. return m.appendgroup_allow_list, true
  28607. }
  28608. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  28609. func (m *WxMutation) ResetGroupAllowList() {
  28610. m.group_allow_list = nil
  28611. m.appendgroup_allow_list = nil
  28612. }
  28613. // SetBlockList sets the "block_list" field.
  28614. func (m *WxMutation) SetBlockList(s []string) {
  28615. m.block_list = &s
  28616. m.appendblock_list = nil
  28617. }
  28618. // BlockList returns the value of the "block_list" field in the mutation.
  28619. func (m *WxMutation) BlockList() (r []string, exists bool) {
  28620. v := m.block_list
  28621. if v == nil {
  28622. return
  28623. }
  28624. return *v, true
  28625. }
  28626. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  28627. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28629. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  28630. if !m.op.Is(OpUpdateOne) {
  28631. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  28632. }
  28633. if m.id == nil || m.oldValue == nil {
  28634. return v, errors.New("OldBlockList requires an ID field in the mutation")
  28635. }
  28636. oldValue, err := m.oldValue(ctx)
  28637. if err != nil {
  28638. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  28639. }
  28640. return oldValue.BlockList, nil
  28641. }
  28642. // AppendBlockList adds s to the "block_list" field.
  28643. func (m *WxMutation) AppendBlockList(s []string) {
  28644. m.appendblock_list = append(m.appendblock_list, s...)
  28645. }
  28646. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  28647. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  28648. if len(m.appendblock_list) == 0 {
  28649. return nil, false
  28650. }
  28651. return m.appendblock_list, true
  28652. }
  28653. // ResetBlockList resets all changes to the "block_list" field.
  28654. func (m *WxMutation) ResetBlockList() {
  28655. m.block_list = nil
  28656. m.appendblock_list = nil
  28657. }
  28658. // SetGroupBlockList sets the "group_block_list" field.
  28659. func (m *WxMutation) SetGroupBlockList(s []string) {
  28660. m.group_block_list = &s
  28661. m.appendgroup_block_list = nil
  28662. }
  28663. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  28664. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  28665. v := m.group_block_list
  28666. if v == nil {
  28667. return
  28668. }
  28669. return *v, true
  28670. }
  28671. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  28672. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28674. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  28675. if !m.op.Is(OpUpdateOne) {
  28676. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  28677. }
  28678. if m.id == nil || m.oldValue == nil {
  28679. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  28680. }
  28681. oldValue, err := m.oldValue(ctx)
  28682. if err != nil {
  28683. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  28684. }
  28685. return oldValue.GroupBlockList, nil
  28686. }
  28687. // AppendGroupBlockList adds s to the "group_block_list" field.
  28688. func (m *WxMutation) AppendGroupBlockList(s []string) {
  28689. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  28690. }
  28691. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  28692. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  28693. if len(m.appendgroup_block_list) == 0 {
  28694. return nil, false
  28695. }
  28696. return m.appendgroup_block_list, true
  28697. }
  28698. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  28699. func (m *WxMutation) ResetGroupBlockList() {
  28700. m.group_block_list = nil
  28701. m.appendgroup_block_list = nil
  28702. }
  28703. // ClearServer clears the "server" edge to the Server entity.
  28704. func (m *WxMutation) ClearServer() {
  28705. m.clearedserver = true
  28706. m.clearedFields[wx.FieldServerID] = struct{}{}
  28707. }
  28708. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  28709. func (m *WxMutation) ServerCleared() bool {
  28710. return m.ServerIDCleared() || m.clearedserver
  28711. }
  28712. // ServerIDs returns the "server" edge IDs in the mutation.
  28713. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28714. // ServerID instead. It exists only for internal usage by the builders.
  28715. func (m *WxMutation) ServerIDs() (ids []uint64) {
  28716. if id := m.server; id != nil {
  28717. ids = append(ids, *id)
  28718. }
  28719. return
  28720. }
  28721. // ResetServer resets all changes to the "server" edge.
  28722. func (m *WxMutation) ResetServer() {
  28723. m.server = nil
  28724. m.clearedserver = false
  28725. }
  28726. // ClearAgent clears the "agent" edge to the Agent entity.
  28727. func (m *WxMutation) ClearAgent() {
  28728. m.clearedagent = true
  28729. m.clearedFields[wx.FieldAgentID] = struct{}{}
  28730. }
  28731. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  28732. func (m *WxMutation) AgentCleared() bool {
  28733. return m.clearedagent
  28734. }
  28735. // AgentIDs returns the "agent" edge IDs in the mutation.
  28736. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28737. // AgentID instead. It exists only for internal usage by the builders.
  28738. func (m *WxMutation) AgentIDs() (ids []uint64) {
  28739. if id := m.agent; id != nil {
  28740. ids = append(ids, *id)
  28741. }
  28742. return
  28743. }
  28744. // ResetAgent resets all changes to the "agent" edge.
  28745. func (m *WxMutation) ResetAgent() {
  28746. m.agent = nil
  28747. m.clearedagent = false
  28748. }
  28749. // Where appends a list predicates to the WxMutation builder.
  28750. func (m *WxMutation) Where(ps ...predicate.Wx) {
  28751. m.predicates = append(m.predicates, ps...)
  28752. }
  28753. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  28754. // users can use type-assertion to append predicates that do not depend on any generated package.
  28755. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  28756. p := make([]predicate.Wx, len(ps))
  28757. for i := range ps {
  28758. p[i] = ps[i]
  28759. }
  28760. m.Where(p...)
  28761. }
  28762. // Op returns the operation name.
  28763. func (m *WxMutation) Op() Op {
  28764. return m.op
  28765. }
  28766. // SetOp allows setting the mutation operation.
  28767. func (m *WxMutation) SetOp(op Op) {
  28768. m.op = op
  28769. }
  28770. // Type returns the node type of this mutation (Wx).
  28771. func (m *WxMutation) Type() string {
  28772. return m.typ
  28773. }
  28774. // Fields returns all fields that were changed during this mutation. Note that in
  28775. // order to get all numeric fields that were incremented/decremented, call
  28776. // AddedFields().
  28777. func (m *WxMutation) Fields() []string {
  28778. fields := make([]string, 0, 21)
  28779. if m.created_at != nil {
  28780. fields = append(fields, wx.FieldCreatedAt)
  28781. }
  28782. if m.updated_at != nil {
  28783. fields = append(fields, wx.FieldUpdatedAt)
  28784. }
  28785. if m.status != nil {
  28786. fields = append(fields, wx.FieldStatus)
  28787. }
  28788. if m.deleted_at != nil {
  28789. fields = append(fields, wx.FieldDeletedAt)
  28790. }
  28791. if m.server != nil {
  28792. fields = append(fields, wx.FieldServerID)
  28793. }
  28794. if m.port != nil {
  28795. fields = append(fields, wx.FieldPort)
  28796. }
  28797. if m.process_id != nil {
  28798. fields = append(fields, wx.FieldProcessID)
  28799. }
  28800. if m.callback != nil {
  28801. fields = append(fields, wx.FieldCallback)
  28802. }
  28803. if m.wxid != nil {
  28804. fields = append(fields, wx.FieldWxid)
  28805. }
  28806. if m.account != nil {
  28807. fields = append(fields, wx.FieldAccount)
  28808. }
  28809. if m.nickname != nil {
  28810. fields = append(fields, wx.FieldNickname)
  28811. }
  28812. if m.tel != nil {
  28813. fields = append(fields, wx.FieldTel)
  28814. }
  28815. if m.head_big != nil {
  28816. fields = append(fields, wx.FieldHeadBig)
  28817. }
  28818. if m.organization_id != nil {
  28819. fields = append(fields, wx.FieldOrganizationID)
  28820. }
  28821. if m.agent != nil {
  28822. fields = append(fields, wx.FieldAgentID)
  28823. }
  28824. if m.api_base != nil {
  28825. fields = append(fields, wx.FieldAPIBase)
  28826. }
  28827. if m.api_key != nil {
  28828. fields = append(fields, wx.FieldAPIKey)
  28829. }
  28830. if m.allow_list != nil {
  28831. fields = append(fields, wx.FieldAllowList)
  28832. }
  28833. if m.group_allow_list != nil {
  28834. fields = append(fields, wx.FieldGroupAllowList)
  28835. }
  28836. if m.block_list != nil {
  28837. fields = append(fields, wx.FieldBlockList)
  28838. }
  28839. if m.group_block_list != nil {
  28840. fields = append(fields, wx.FieldGroupBlockList)
  28841. }
  28842. return fields
  28843. }
  28844. // Field returns the value of a field with the given name. The second boolean
  28845. // return value indicates that this field was not set, or was not defined in the
  28846. // schema.
  28847. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  28848. switch name {
  28849. case wx.FieldCreatedAt:
  28850. return m.CreatedAt()
  28851. case wx.FieldUpdatedAt:
  28852. return m.UpdatedAt()
  28853. case wx.FieldStatus:
  28854. return m.Status()
  28855. case wx.FieldDeletedAt:
  28856. return m.DeletedAt()
  28857. case wx.FieldServerID:
  28858. return m.ServerID()
  28859. case wx.FieldPort:
  28860. return m.Port()
  28861. case wx.FieldProcessID:
  28862. return m.ProcessID()
  28863. case wx.FieldCallback:
  28864. return m.Callback()
  28865. case wx.FieldWxid:
  28866. return m.Wxid()
  28867. case wx.FieldAccount:
  28868. return m.Account()
  28869. case wx.FieldNickname:
  28870. return m.Nickname()
  28871. case wx.FieldTel:
  28872. return m.Tel()
  28873. case wx.FieldHeadBig:
  28874. return m.HeadBig()
  28875. case wx.FieldOrganizationID:
  28876. return m.OrganizationID()
  28877. case wx.FieldAgentID:
  28878. return m.AgentID()
  28879. case wx.FieldAPIBase:
  28880. return m.APIBase()
  28881. case wx.FieldAPIKey:
  28882. return m.APIKey()
  28883. case wx.FieldAllowList:
  28884. return m.AllowList()
  28885. case wx.FieldGroupAllowList:
  28886. return m.GroupAllowList()
  28887. case wx.FieldBlockList:
  28888. return m.BlockList()
  28889. case wx.FieldGroupBlockList:
  28890. return m.GroupBlockList()
  28891. }
  28892. return nil, false
  28893. }
  28894. // OldField returns the old value of the field from the database. An error is
  28895. // returned if the mutation operation is not UpdateOne, or the query to the
  28896. // database failed.
  28897. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28898. switch name {
  28899. case wx.FieldCreatedAt:
  28900. return m.OldCreatedAt(ctx)
  28901. case wx.FieldUpdatedAt:
  28902. return m.OldUpdatedAt(ctx)
  28903. case wx.FieldStatus:
  28904. return m.OldStatus(ctx)
  28905. case wx.FieldDeletedAt:
  28906. return m.OldDeletedAt(ctx)
  28907. case wx.FieldServerID:
  28908. return m.OldServerID(ctx)
  28909. case wx.FieldPort:
  28910. return m.OldPort(ctx)
  28911. case wx.FieldProcessID:
  28912. return m.OldProcessID(ctx)
  28913. case wx.FieldCallback:
  28914. return m.OldCallback(ctx)
  28915. case wx.FieldWxid:
  28916. return m.OldWxid(ctx)
  28917. case wx.FieldAccount:
  28918. return m.OldAccount(ctx)
  28919. case wx.FieldNickname:
  28920. return m.OldNickname(ctx)
  28921. case wx.FieldTel:
  28922. return m.OldTel(ctx)
  28923. case wx.FieldHeadBig:
  28924. return m.OldHeadBig(ctx)
  28925. case wx.FieldOrganizationID:
  28926. return m.OldOrganizationID(ctx)
  28927. case wx.FieldAgentID:
  28928. return m.OldAgentID(ctx)
  28929. case wx.FieldAPIBase:
  28930. return m.OldAPIBase(ctx)
  28931. case wx.FieldAPIKey:
  28932. return m.OldAPIKey(ctx)
  28933. case wx.FieldAllowList:
  28934. return m.OldAllowList(ctx)
  28935. case wx.FieldGroupAllowList:
  28936. return m.OldGroupAllowList(ctx)
  28937. case wx.FieldBlockList:
  28938. return m.OldBlockList(ctx)
  28939. case wx.FieldGroupBlockList:
  28940. return m.OldGroupBlockList(ctx)
  28941. }
  28942. return nil, fmt.Errorf("unknown Wx field %s", name)
  28943. }
  28944. // SetField sets the value of a field with the given name. It returns an error if
  28945. // the field is not defined in the schema, or if the type mismatched the field
  28946. // type.
  28947. func (m *WxMutation) SetField(name string, value ent.Value) error {
  28948. switch name {
  28949. case wx.FieldCreatedAt:
  28950. v, ok := value.(time.Time)
  28951. if !ok {
  28952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28953. }
  28954. m.SetCreatedAt(v)
  28955. return nil
  28956. case wx.FieldUpdatedAt:
  28957. v, ok := value.(time.Time)
  28958. if !ok {
  28959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28960. }
  28961. m.SetUpdatedAt(v)
  28962. return nil
  28963. case wx.FieldStatus:
  28964. v, ok := value.(uint8)
  28965. if !ok {
  28966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28967. }
  28968. m.SetStatus(v)
  28969. return nil
  28970. case wx.FieldDeletedAt:
  28971. v, ok := value.(time.Time)
  28972. if !ok {
  28973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28974. }
  28975. m.SetDeletedAt(v)
  28976. return nil
  28977. case wx.FieldServerID:
  28978. v, ok := value.(uint64)
  28979. if !ok {
  28980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28981. }
  28982. m.SetServerID(v)
  28983. return nil
  28984. case wx.FieldPort:
  28985. v, ok := value.(string)
  28986. if !ok {
  28987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28988. }
  28989. m.SetPort(v)
  28990. return nil
  28991. case wx.FieldProcessID:
  28992. v, ok := value.(string)
  28993. if !ok {
  28994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28995. }
  28996. m.SetProcessID(v)
  28997. return nil
  28998. case wx.FieldCallback:
  28999. v, ok := value.(string)
  29000. if !ok {
  29001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29002. }
  29003. m.SetCallback(v)
  29004. return nil
  29005. case wx.FieldWxid:
  29006. v, ok := value.(string)
  29007. if !ok {
  29008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29009. }
  29010. m.SetWxid(v)
  29011. return nil
  29012. case wx.FieldAccount:
  29013. v, ok := value.(string)
  29014. if !ok {
  29015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29016. }
  29017. m.SetAccount(v)
  29018. return nil
  29019. case wx.FieldNickname:
  29020. v, ok := value.(string)
  29021. if !ok {
  29022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29023. }
  29024. m.SetNickname(v)
  29025. return nil
  29026. case wx.FieldTel:
  29027. v, ok := value.(string)
  29028. if !ok {
  29029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29030. }
  29031. m.SetTel(v)
  29032. return nil
  29033. case wx.FieldHeadBig:
  29034. v, ok := value.(string)
  29035. if !ok {
  29036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29037. }
  29038. m.SetHeadBig(v)
  29039. return nil
  29040. case wx.FieldOrganizationID:
  29041. v, ok := value.(uint64)
  29042. if !ok {
  29043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29044. }
  29045. m.SetOrganizationID(v)
  29046. return nil
  29047. case wx.FieldAgentID:
  29048. v, ok := value.(uint64)
  29049. if !ok {
  29050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29051. }
  29052. m.SetAgentID(v)
  29053. return nil
  29054. case wx.FieldAPIBase:
  29055. v, ok := value.(string)
  29056. if !ok {
  29057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29058. }
  29059. m.SetAPIBase(v)
  29060. return nil
  29061. case wx.FieldAPIKey:
  29062. v, ok := value.(string)
  29063. if !ok {
  29064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29065. }
  29066. m.SetAPIKey(v)
  29067. return nil
  29068. case wx.FieldAllowList:
  29069. v, ok := value.([]string)
  29070. if !ok {
  29071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29072. }
  29073. m.SetAllowList(v)
  29074. return nil
  29075. case wx.FieldGroupAllowList:
  29076. v, ok := value.([]string)
  29077. if !ok {
  29078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29079. }
  29080. m.SetGroupAllowList(v)
  29081. return nil
  29082. case wx.FieldBlockList:
  29083. v, ok := value.([]string)
  29084. if !ok {
  29085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29086. }
  29087. m.SetBlockList(v)
  29088. return nil
  29089. case wx.FieldGroupBlockList:
  29090. v, ok := value.([]string)
  29091. if !ok {
  29092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29093. }
  29094. m.SetGroupBlockList(v)
  29095. return nil
  29096. }
  29097. return fmt.Errorf("unknown Wx field %s", name)
  29098. }
  29099. // AddedFields returns all numeric fields that were incremented/decremented during
  29100. // this mutation.
  29101. func (m *WxMutation) AddedFields() []string {
  29102. var fields []string
  29103. if m.addstatus != nil {
  29104. fields = append(fields, wx.FieldStatus)
  29105. }
  29106. if m.addorganization_id != nil {
  29107. fields = append(fields, wx.FieldOrganizationID)
  29108. }
  29109. return fields
  29110. }
  29111. // AddedField returns the numeric value that was incremented/decremented on a field
  29112. // with the given name. The second boolean return value indicates that this field
  29113. // was not set, or was not defined in the schema.
  29114. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  29115. switch name {
  29116. case wx.FieldStatus:
  29117. return m.AddedStatus()
  29118. case wx.FieldOrganizationID:
  29119. return m.AddedOrganizationID()
  29120. }
  29121. return nil, false
  29122. }
  29123. // AddField adds the value to the field with the given name. It returns an error if
  29124. // the field is not defined in the schema, or if the type mismatched the field
  29125. // type.
  29126. func (m *WxMutation) AddField(name string, value ent.Value) error {
  29127. switch name {
  29128. case wx.FieldStatus:
  29129. v, ok := value.(int8)
  29130. if !ok {
  29131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29132. }
  29133. m.AddStatus(v)
  29134. return nil
  29135. case wx.FieldOrganizationID:
  29136. v, ok := value.(int64)
  29137. if !ok {
  29138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29139. }
  29140. m.AddOrganizationID(v)
  29141. return nil
  29142. }
  29143. return fmt.Errorf("unknown Wx numeric field %s", name)
  29144. }
  29145. // ClearedFields returns all nullable fields that were cleared during this
  29146. // mutation.
  29147. func (m *WxMutation) ClearedFields() []string {
  29148. var fields []string
  29149. if m.FieldCleared(wx.FieldStatus) {
  29150. fields = append(fields, wx.FieldStatus)
  29151. }
  29152. if m.FieldCleared(wx.FieldDeletedAt) {
  29153. fields = append(fields, wx.FieldDeletedAt)
  29154. }
  29155. if m.FieldCleared(wx.FieldServerID) {
  29156. fields = append(fields, wx.FieldServerID)
  29157. }
  29158. if m.FieldCleared(wx.FieldOrganizationID) {
  29159. fields = append(fields, wx.FieldOrganizationID)
  29160. }
  29161. if m.FieldCleared(wx.FieldAPIBase) {
  29162. fields = append(fields, wx.FieldAPIBase)
  29163. }
  29164. if m.FieldCleared(wx.FieldAPIKey) {
  29165. fields = append(fields, wx.FieldAPIKey)
  29166. }
  29167. return fields
  29168. }
  29169. // FieldCleared returns a boolean indicating if a field with the given name was
  29170. // cleared in this mutation.
  29171. func (m *WxMutation) FieldCleared(name string) bool {
  29172. _, ok := m.clearedFields[name]
  29173. return ok
  29174. }
  29175. // ClearField clears the value of the field with the given name. It returns an
  29176. // error if the field is not defined in the schema.
  29177. func (m *WxMutation) ClearField(name string) error {
  29178. switch name {
  29179. case wx.FieldStatus:
  29180. m.ClearStatus()
  29181. return nil
  29182. case wx.FieldDeletedAt:
  29183. m.ClearDeletedAt()
  29184. return nil
  29185. case wx.FieldServerID:
  29186. m.ClearServerID()
  29187. return nil
  29188. case wx.FieldOrganizationID:
  29189. m.ClearOrganizationID()
  29190. return nil
  29191. case wx.FieldAPIBase:
  29192. m.ClearAPIBase()
  29193. return nil
  29194. case wx.FieldAPIKey:
  29195. m.ClearAPIKey()
  29196. return nil
  29197. }
  29198. return fmt.Errorf("unknown Wx nullable field %s", name)
  29199. }
  29200. // ResetField resets all changes in the mutation for the field with the given name.
  29201. // It returns an error if the field is not defined in the schema.
  29202. func (m *WxMutation) ResetField(name string) error {
  29203. switch name {
  29204. case wx.FieldCreatedAt:
  29205. m.ResetCreatedAt()
  29206. return nil
  29207. case wx.FieldUpdatedAt:
  29208. m.ResetUpdatedAt()
  29209. return nil
  29210. case wx.FieldStatus:
  29211. m.ResetStatus()
  29212. return nil
  29213. case wx.FieldDeletedAt:
  29214. m.ResetDeletedAt()
  29215. return nil
  29216. case wx.FieldServerID:
  29217. m.ResetServerID()
  29218. return nil
  29219. case wx.FieldPort:
  29220. m.ResetPort()
  29221. return nil
  29222. case wx.FieldProcessID:
  29223. m.ResetProcessID()
  29224. return nil
  29225. case wx.FieldCallback:
  29226. m.ResetCallback()
  29227. return nil
  29228. case wx.FieldWxid:
  29229. m.ResetWxid()
  29230. return nil
  29231. case wx.FieldAccount:
  29232. m.ResetAccount()
  29233. return nil
  29234. case wx.FieldNickname:
  29235. m.ResetNickname()
  29236. return nil
  29237. case wx.FieldTel:
  29238. m.ResetTel()
  29239. return nil
  29240. case wx.FieldHeadBig:
  29241. m.ResetHeadBig()
  29242. return nil
  29243. case wx.FieldOrganizationID:
  29244. m.ResetOrganizationID()
  29245. return nil
  29246. case wx.FieldAgentID:
  29247. m.ResetAgentID()
  29248. return nil
  29249. case wx.FieldAPIBase:
  29250. m.ResetAPIBase()
  29251. return nil
  29252. case wx.FieldAPIKey:
  29253. m.ResetAPIKey()
  29254. return nil
  29255. case wx.FieldAllowList:
  29256. m.ResetAllowList()
  29257. return nil
  29258. case wx.FieldGroupAllowList:
  29259. m.ResetGroupAllowList()
  29260. return nil
  29261. case wx.FieldBlockList:
  29262. m.ResetBlockList()
  29263. return nil
  29264. case wx.FieldGroupBlockList:
  29265. m.ResetGroupBlockList()
  29266. return nil
  29267. }
  29268. return fmt.Errorf("unknown Wx field %s", name)
  29269. }
  29270. // AddedEdges returns all edge names that were set/added in this mutation.
  29271. func (m *WxMutation) AddedEdges() []string {
  29272. edges := make([]string, 0, 2)
  29273. if m.server != nil {
  29274. edges = append(edges, wx.EdgeServer)
  29275. }
  29276. if m.agent != nil {
  29277. edges = append(edges, wx.EdgeAgent)
  29278. }
  29279. return edges
  29280. }
  29281. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29282. // name in this mutation.
  29283. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  29284. switch name {
  29285. case wx.EdgeServer:
  29286. if id := m.server; id != nil {
  29287. return []ent.Value{*id}
  29288. }
  29289. case wx.EdgeAgent:
  29290. if id := m.agent; id != nil {
  29291. return []ent.Value{*id}
  29292. }
  29293. }
  29294. return nil
  29295. }
  29296. // RemovedEdges returns all edge names that were removed in this mutation.
  29297. func (m *WxMutation) RemovedEdges() []string {
  29298. edges := make([]string, 0, 2)
  29299. return edges
  29300. }
  29301. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29302. // the given name in this mutation.
  29303. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  29304. return nil
  29305. }
  29306. // ClearedEdges returns all edge names that were cleared in this mutation.
  29307. func (m *WxMutation) ClearedEdges() []string {
  29308. edges := make([]string, 0, 2)
  29309. if m.clearedserver {
  29310. edges = append(edges, wx.EdgeServer)
  29311. }
  29312. if m.clearedagent {
  29313. edges = append(edges, wx.EdgeAgent)
  29314. }
  29315. return edges
  29316. }
  29317. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29318. // was cleared in this mutation.
  29319. func (m *WxMutation) EdgeCleared(name string) bool {
  29320. switch name {
  29321. case wx.EdgeServer:
  29322. return m.clearedserver
  29323. case wx.EdgeAgent:
  29324. return m.clearedagent
  29325. }
  29326. return false
  29327. }
  29328. // ClearEdge clears the value of the edge with the given name. It returns an error
  29329. // if that edge is not defined in the schema.
  29330. func (m *WxMutation) ClearEdge(name string) error {
  29331. switch name {
  29332. case wx.EdgeServer:
  29333. m.ClearServer()
  29334. return nil
  29335. case wx.EdgeAgent:
  29336. m.ClearAgent()
  29337. return nil
  29338. }
  29339. return fmt.Errorf("unknown Wx unique edge %s", name)
  29340. }
  29341. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29342. // It returns an error if the edge is not defined in the schema.
  29343. func (m *WxMutation) ResetEdge(name string) error {
  29344. switch name {
  29345. case wx.EdgeServer:
  29346. m.ResetServer()
  29347. return nil
  29348. case wx.EdgeAgent:
  29349. m.ResetAgent()
  29350. return nil
  29351. }
  29352. return fmt.Errorf("unknown Wx edge %s", name)
  29353. }
  29354. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  29355. type WxCardMutation struct {
  29356. config
  29357. op Op
  29358. typ string
  29359. id *uint64
  29360. created_at *time.Time
  29361. updated_at *time.Time
  29362. deleted_at *time.Time
  29363. user_id *uint64
  29364. adduser_id *int64
  29365. wx_user_id *uint64
  29366. addwx_user_id *int64
  29367. avatar *string
  29368. logo *string
  29369. name *string
  29370. company *string
  29371. address *string
  29372. phone *string
  29373. official_account *string
  29374. wechat_account *string
  29375. email *string
  29376. api_base *string
  29377. api_key *string
  29378. ai_info *string
  29379. intro *string
  29380. clearedFields map[string]struct{}
  29381. done bool
  29382. oldValue func(context.Context) (*WxCard, error)
  29383. predicates []predicate.WxCard
  29384. }
  29385. var _ ent.Mutation = (*WxCardMutation)(nil)
  29386. // wxcardOption allows management of the mutation configuration using functional options.
  29387. type wxcardOption func(*WxCardMutation)
  29388. // newWxCardMutation creates new mutation for the WxCard entity.
  29389. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  29390. m := &WxCardMutation{
  29391. config: c,
  29392. op: op,
  29393. typ: TypeWxCard,
  29394. clearedFields: make(map[string]struct{}),
  29395. }
  29396. for _, opt := range opts {
  29397. opt(m)
  29398. }
  29399. return m
  29400. }
  29401. // withWxCardID sets the ID field of the mutation.
  29402. func withWxCardID(id uint64) wxcardOption {
  29403. return func(m *WxCardMutation) {
  29404. var (
  29405. err error
  29406. once sync.Once
  29407. value *WxCard
  29408. )
  29409. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  29410. once.Do(func() {
  29411. if m.done {
  29412. err = errors.New("querying old values post mutation is not allowed")
  29413. } else {
  29414. value, err = m.Client().WxCard.Get(ctx, id)
  29415. }
  29416. })
  29417. return value, err
  29418. }
  29419. m.id = &id
  29420. }
  29421. }
  29422. // withWxCard sets the old WxCard of the mutation.
  29423. func withWxCard(node *WxCard) wxcardOption {
  29424. return func(m *WxCardMutation) {
  29425. m.oldValue = func(context.Context) (*WxCard, error) {
  29426. return node, nil
  29427. }
  29428. m.id = &node.ID
  29429. }
  29430. }
  29431. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29432. // executed in a transaction (ent.Tx), a transactional client is returned.
  29433. func (m WxCardMutation) Client() *Client {
  29434. client := &Client{config: m.config}
  29435. client.init()
  29436. return client
  29437. }
  29438. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29439. // it returns an error otherwise.
  29440. func (m WxCardMutation) Tx() (*Tx, error) {
  29441. if _, ok := m.driver.(*txDriver); !ok {
  29442. return nil, errors.New("ent: mutation is not running in a transaction")
  29443. }
  29444. tx := &Tx{config: m.config}
  29445. tx.init()
  29446. return tx, nil
  29447. }
  29448. // SetID sets the value of the id field. Note that this
  29449. // operation is only accepted on creation of WxCard entities.
  29450. func (m *WxCardMutation) SetID(id uint64) {
  29451. m.id = &id
  29452. }
  29453. // ID returns the ID value in the mutation. Note that the ID is only available
  29454. // if it was provided to the builder or after it was returned from the database.
  29455. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  29456. if m.id == nil {
  29457. return
  29458. }
  29459. return *m.id, true
  29460. }
  29461. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29462. // That means, if the mutation is applied within a transaction with an isolation level such
  29463. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29464. // or updated by the mutation.
  29465. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  29466. switch {
  29467. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29468. id, exists := m.ID()
  29469. if exists {
  29470. return []uint64{id}, nil
  29471. }
  29472. fallthrough
  29473. case m.op.Is(OpUpdate | OpDelete):
  29474. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  29475. default:
  29476. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29477. }
  29478. }
  29479. // SetCreatedAt sets the "created_at" field.
  29480. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  29481. m.created_at = &t
  29482. }
  29483. // CreatedAt returns the value of the "created_at" field in the mutation.
  29484. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  29485. v := m.created_at
  29486. if v == nil {
  29487. return
  29488. }
  29489. return *v, true
  29490. }
  29491. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  29492. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29494. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29495. if !m.op.Is(OpUpdateOne) {
  29496. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29497. }
  29498. if m.id == nil || m.oldValue == nil {
  29499. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29500. }
  29501. oldValue, err := m.oldValue(ctx)
  29502. if err != nil {
  29503. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29504. }
  29505. return oldValue.CreatedAt, nil
  29506. }
  29507. // ResetCreatedAt resets all changes to the "created_at" field.
  29508. func (m *WxCardMutation) ResetCreatedAt() {
  29509. m.created_at = nil
  29510. }
  29511. // SetUpdatedAt sets the "updated_at" field.
  29512. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  29513. m.updated_at = &t
  29514. }
  29515. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29516. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  29517. v := m.updated_at
  29518. if v == nil {
  29519. return
  29520. }
  29521. return *v, true
  29522. }
  29523. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  29524. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29526. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29527. if !m.op.Is(OpUpdateOne) {
  29528. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29529. }
  29530. if m.id == nil || m.oldValue == nil {
  29531. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29532. }
  29533. oldValue, err := m.oldValue(ctx)
  29534. if err != nil {
  29535. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29536. }
  29537. return oldValue.UpdatedAt, nil
  29538. }
  29539. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29540. func (m *WxCardMutation) ResetUpdatedAt() {
  29541. m.updated_at = nil
  29542. }
  29543. // SetDeletedAt sets the "deleted_at" field.
  29544. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  29545. m.deleted_at = &t
  29546. }
  29547. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29548. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  29549. v := m.deleted_at
  29550. if v == nil {
  29551. return
  29552. }
  29553. return *v, true
  29554. }
  29555. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  29556. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29558. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29559. if !m.op.Is(OpUpdateOne) {
  29560. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29561. }
  29562. if m.id == nil || m.oldValue == nil {
  29563. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29564. }
  29565. oldValue, err := m.oldValue(ctx)
  29566. if err != nil {
  29567. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29568. }
  29569. return oldValue.DeletedAt, nil
  29570. }
  29571. // ClearDeletedAt clears the value of the "deleted_at" field.
  29572. func (m *WxCardMutation) ClearDeletedAt() {
  29573. m.deleted_at = nil
  29574. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  29575. }
  29576. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29577. func (m *WxCardMutation) DeletedAtCleared() bool {
  29578. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  29579. return ok
  29580. }
  29581. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29582. func (m *WxCardMutation) ResetDeletedAt() {
  29583. m.deleted_at = nil
  29584. delete(m.clearedFields, wxcard.FieldDeletedAt)
  29585. }
  29586. // SetUserID sets the "user_id" field.
  29587. func (m *WxCardMutation) SetUserID(u uint64) {
  29588. m.user_id = &u
  29589. m.adduser_id = nil
  29590. }
  29591. // UserID returns the value of the "user_id" field in the mutation.
  29592. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  29593. v := m.user_id
  29594. if v == nil {
  29595. return
  29596. }
  29597. return *v, true
  29598. }
  29599. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  29600. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29602. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  29603. if !m.op.Is(OpUpdateOne) {
  29604. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  29605. }
  29606. if m.id == nil || m.oldValue == nil {
  29607. return v, errors.New("OldUserID requires an ID field in the mutation")
  29608. }
  29609. oldValue, err := m.oldValue(ctx)
  29610. if err != nil {
  29611. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  29612. }
  29613. return oldValue.UserID, nil
  29614. }
  29615. // AddUserID adds u to the "user_id" field.
  29616. func (m *WxCardMutation) AddUserID(u int64) {
  29617. if m.adduser_id != nil {
  29618. *m.adduser_id += u
  29619. } else {
  29620. m.adduser_id = &u
  29621. }
  29622. }
  29623. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  29624. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  29625. v := m.adduser_id
  29626. if v == nil {
  29627. return
  29628. }
  29629. return *v, true
  29630. }
  29631. // ClearUserID clears the value of the "user_id" field.
  29632. func (m *WxCardMutation) ClearUserID() {
  29633. m.user_id = nil
  29634. m.adduser_id = nil
  29635. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  29636. }
  29637. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  29638. func (m *WxCardMutation) UserIDCleared() bool {
  29639. _, ok := m.clearedFields[wxcard.FieldUserID]
  29640. return ok
  29641. }
  29642. // ResetUserID resets all changes to the "user_id" field.
  29643. func (m *WxCardMutation) ResetUserID() {
  29644. m.user_id = nil
  29645. m.adduser_id = nil
  29646. delete(m.clearedFields, wxcard.FieldUserID)
  29647. }
  29648. // SetWxUserID sets the "wx_user_id" field.
  29649. func (m *WxCardMutation) SetWxUserID(u uint64) {
  29650. m.wx_user_id = &u
  29651. m.addwx_user_id = nil
  29652. }
  29653. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  29654. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  29655. v := m.wx_user_id
  29656. if v == nil {
  29657. return
  29658. }
  29659. return *v, true
  29660. }
  29661. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  29662. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29664. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  29665. if !m.op.Is(OpUpdateOne) {
  29666. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  29667. }
  29668. if m.id == nil || m.oldValue == nil {
  29669. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  29670. }
  29671. oldValue, err := m.oldValue(ctx)
  29672. if err != nil {
  29673. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  29674. }
  29675. return oldValue.WxUserID, nil
  29676. }
  29677. // AddWxUserID adds u to the "wx_user_id" field.
  29678. func (m *WxCardMutation) AddWxUserID(u int64) {
  29679. if m.addwx_user_id != nil {
  29680. *m.addwx_user_id += u
  29681. } else {
  29682. m.addwx_user_id = &u
  29683. }
  29684. }
  29685. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  29686. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  29687. v := m.addwx_user_id
  29688. if v == nil {
  29689. return
  29690. }
  29691. return *v, true
  29692. }
  29693. // ClearWxUserID clears the value of the "wx_user_id" field.
  29694. func (m *WxCardMutation) ClearWxUserID() {
  29695. m.wx_user_id = nil
  29696. m.addwx_user_id = nil
  29697. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  29698. }
  29699. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  29700. func (m *WxCardMutation) WxUserIDCleared() bool {
  29701. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  29702. return ok
  29703. }
  29704. // ResetWxUserID resets all changes to the "wx_user_id" field.
  29705. func (m *WxCardMutation) ResetWxUserID() {
  29706. m.wx_user_id = nil
  29707. m.addwx_user_id = nil
  29708. delete(m.clearedFields, wxcard.FieldWxUserID)
  29709. }
  29710. // SetAvatar sets the "avatar" field.
  29711. func (m *WxCardMutation) SetAvatar(s string) {
  29712. m.avatar = &s
  29713. }
  29714. // Avatar returns the value of the "avatar" field in the mutation.
  29715. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  29716. v := m.avatar
  29717. if v == nil {
  29718. return
  29719. }
  29720. return *v, true
  29721. }
  29722. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  29723. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29725. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  29726. if !m.op.Is(OpUpdateOne) {
  29727. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  29728. }
  29729. if m.id == nil || m.oldValue == nil {
  29730. return v, errors.New("OldAvatar requires an ID field in the mutation")
  29731. }
  29732. oldValue, err := m.oldValue(ctx)
  29733. if err != nil {
  29734. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  29735. }
  29736. return oldValue.Avatar, nil
  29737. }
  29738. // ResetAvatar resets all changes to the "avatar" field.
  29739. func (m *WxCardMutation) ResetAvatar() {
  29740. m.avatar = nil
  29741. }
  29742. // SetLogo sets the "logo" field.
  29743. func (m *WxCardMutation) SetLogo(s string) {
  29744. m.logo = &s
  29745. }
  29746. // Logo returns the value of the "logo" field in the mutation.
  29747. func (m *WxCardMutation) Logo() (r string, exists bool) {
  29748. v := m.logo
  29749. if v == nil {
  29750. return
  29751. }
  29752. return *v, true
  29753. }
  29754. // OldLogo returns the old "logo" field's value of the WxCard entity.
  29755. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29757. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  29758. if !m.op.Is(OpUpdateOne) {
  29759. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  29760. }
  29761. if m.id == nil || m.oldValue == nil {
  29762. return v, errors.New("OldLogo requires an ID field in the mutation")
  29763. }
  29764. oldValue, err := m.oldValue(ctx)
  29765. if err != nil {
  29766. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  29767. }
  29768. return oldValue.Logo, nil
  29769. }
  29770. // ResetLogo resets all changes to the "logo" field.
  29771. func (m *WxCardMutation) ResetLogo() {
  29772. m.logo = nil
  29773. }
  29774. // SetName sets the "name" field.
  29775. func (m *WxCardMutation) SetName(s string) {
  29776. m.name = &s
  29777. }
  29778. // Name returns the value of the "name" field in the mutation.
  29779. func (m *WxCardMutation) Name() (r string, exists bool) {
  29780. v := m.name
  29781. if v == nil {
  29782. return
  29783. }
  29784. return *v, true
  29785. }
  29786. // OldName returns the old "name" field's value of the WxCard entity.
  29787. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29789. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  29790. if !m.op.Is(OpUpdateOne) {
  29791. return v, errors.New("OldName is only allowed on UpdateOne operations")
  29792. }
  29793. if m.id == nil || m.oldValue == nil {
  29794. return v, errors.New("OldName requires an ID field in the mutation")
  29795. }
  29796. oldValue, err := m.oldValue(ctx)
  29797. if err != nil {
  29798. return v, fmt.Errorf("querying old value for OldName: %w", err)
  29799. }
  29800. return oldValue.Name, nil
  29801. }
  29802. // ResetName resets all changes to the "name" field.
  29803. func (m *WxCardMutation) ResetName() {
  29804. m.name = nil
  29805. }
  29806. // SetCompany sets the "company" field.
  29807. func (m *WxCardMutation) SetCompany(s string) {
  29808. m.company = &s
  29809. }
  29810. // Company returns the value of the "company" field in the mutation.
  29811. func (m *WxCardMutation) Company() (r string, exists bool) {
  29812. v := m.company
  29813. if v == nil {
  29814. return
  29815. }
  29816. return *v, true
  29817. }
  29818. // OldCompany returns the old "company" field's value of the WxCard entity.
  29819. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29821. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  29822. if !m.op.Is(OpUpdateOne) {
  29823. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  29824. }
  29825. if m.id == nil || m.oldValue == nil {
  29826. return v, errors.New("OldCompany requires an ID field in the mutation")
  29827. }
  29828. oldValue, err := m.oldValue(ctx)
  29829. if err != nil {
  29830. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  29831. }
  29832. return oldValue.Company, nil
  29833. }
  29834. // ResetCompany resets all changes to the "company" field.
  29835. func (m *WxCardMutation) ResetCompany() {
  29836. m.company = nil
  29837. }
  29838. // SetAddress sets the "address" field.
  29839. func (m *WxCardMutation) SetAddress(s string) {
  29840. m.address = &s
  29841. }
  29842. // Address returns the value of the "address" field in the mutation.
  29843. func (m *WxCardMutation) Address() (r string, exists bool) {
  29844. v := m.address
  29845. if v == nil {
  29846. return
  29847. }
  29848. return *v, true
  29849. }
  29850. // OldAddress returns the old "address" field's value of the WxCard entity.
  29851. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29853. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  29854. if !m.op.Is(OpUpdateOne) {
  29855. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  29856. }
  29857. if m.id == nil || m.oldValue == nil {
  29858. return v, errors.New("OldAddress requires an ID field in the mutation")
  29859. }
  29860. oldValue, err := m.oldValue(ctx)
  29861. if err != nil {
  29862. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  29863. }
  29864. return oldValue.Address, nil
  29865. }
  29866. // ResetAddress resets all changes to the "address" field.
  29867. func (m *WxCardMutation) ResetAddress() {
  29868. m.address = nil
  29869. }
  29870. // SetPhone sets the "phone" field.
  29871. func (m *WxCardMutation) SetPhone(s string) {
  29872. m.phone = &s
  29873. }
  29874. // Phone returns the value of the "phone" field in the mutation.
  29875. func (m *WxCardMutation) Phone() (r string, exists bool) {
  29876. v := m.phone
  29877. if v == nil {
  29878. return
  29879. }
  29880. return *v, true
  29881. }
  29882. // OldPhone returns the old "phone" field's value of the WxCard entity.
  29883. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29885. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  29886. if !m.op.Is(OpUpdateOne) {
  29887. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  29888. }
  29889. if m.id == nil || m.oldValue == nil {
  29890. return v, errors.New("OldPhone requires an ID field in the mutation")
  29891. }
  29892. oldValue, err := m.oldValue(ctx)
  29893. if err != nil {
  29894. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  29895. }
  29896. return oldValue.Phone, nil
  29897. }
  29898. // ResetPhone resets all changes to the "phone" field.
  29899. func (m *WxCardMutation) ResetPhone() {
  29900. m.phone = nil
  29901. }
  29902. // SetOfficialAccount sets the "official_account" field.
  29903. func (m *WxCardMutation) SetOfficialAccount(s string) {
  29904. m.official_account = &s
  29905. }
  29906. // OfficialAccount returns the value of the "official_account" field in the mutation.
  29907. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  29908. v := m.official_account
  29909. if v == nil {
  29910. return
  29911. }
  29912. return *v, true
  29913. }
  29914. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  29915. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29917. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  29918. if !m.op.Is(OpUpdateOne) {
  29919. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  29920. }
  29921. if m.id == nil || m.oldValue == nil {
  29922. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  29923. }
  29924. oldValue, err := m.oldValue(ctx)
  29925. if err != nil {
  29926. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  29927. }
  29928. return oldValue.OfficialAccount, nil
  29929. }
  29930. // ResetOfficialAccount resets all changes to the "official_account" field.
  29931. func (m *WxCardMutation) ResetOfficialAccount() {
  29932. m.official_account = nil
  29933. }
  29934. // SetWechatAccount sets the "wechat_account" field.
  29935. func (m *WxCardMutation) SetWechatAccount(s string) {
  29936. m.wechat_account = &s
  29937. }
  29938. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  29939. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  29940. v := m.wechat_account
  29941. if v == nil {
  29942. return
  29943. }
  29944. return *v, true
  29945. }
  29946. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  29947. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29949. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  29950. if !m.op.Is(OpUpdateOne) {
  29951. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  29952. }
  29953. if m.id == nil || m.oldValue == nil {
  29954. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  29955. }
  29956. oldValue, err := m.oldValue(ctx)
  29957. if err != nil {
  29958. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  29959. }
  29960. return oldValue.WechatAccount, nil
  29961. }
  29962. // ResetWechatAccount resets all changes to the "wechat_account" field.
  29963. func (m *WxCardMutation) ResetWechatAccount() {
  29964. m.wechat_account = nil
  29965. }
  29966. // SetEmail sets the "email" field.
  29967. func (m *WxCardMutation) SetEmail(s string) {
  29968. m.email = &s
  29969. }
  29970. // Email returns the value of the "email" field in the mutation.
  29971. func (m *WxCardMutation) Email() (r string, exists bool) {
  29972. v := m.email
  29973. if v == nil {
  29974. return
  29975. }
  29976. return *v, true
  29977. }
  29978. // OldEmail returns the old "email" field's value of the WxCard entity.
  29979. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29981. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  29982. if !m.op.Is(OpUpdateOne) {
  29983. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  29984. }
  29985. if m.id == nil || m.oldValue == nil {
  29986. return v, errors.New("OldEmail requires an ID field in the mutation")
  29987. }
  29988. oldValue, err := m.oldValue(ctx)
  29989. if err != nil {
  29990. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  29991. }
  29992. return oldValue.Email, nil
  29993. }
  29994. // ClearEmail clears the value of the "email" field.
  29995. func (m *WxCardMutation) ClearEmail() {
  29996. m.email = nil
  29997. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  29998. }
  29999. // EmailCleared returns if the "email" field was cleared in this mutation.
  30000. func (m *WxCardMutation) EmailCleared() bool {
  30001. _, ok := m.clearedFields[wxcard.FieldEmail]
  30002. return ok
  30003. }
  30004. // ResetEmail resets all changes to the "email" field.
  30005. func (m *WxCardMutation) ResetEmail() {
  30006. m.email = nil
  30007. delete(m.clearedFields, wxcard.FieldEmail)
  30008. }
  30009. // SetAPIBase sets the "api_base" field.
  30010. func (m *WxCardMutation) SetAPIBase(s string) {
  30011. m.api_base = &s
  30012. }
  30013. // APIBase returns the value of the "api_base" field in the mutation.
  30014. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  30015. v := m.api_base
  30016. if v == nil {
  30017. return
  30018. }
  30019. return *v, true
  30020. }
  30021. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  30022. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  30023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30024. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  30025. if !m.op.Is(OpUpdateOne) {
  30026. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  30027. }
  30028. if m.id == nil || m.oldValue == nil {
  30029. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  30030. }
  30031. oldValue, err := m.oldValue(ctx)
  30032. if err != nil {
  30033. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  30034. }
  30035. return oldValue.APIBase, nil
  30036. }
  30037. // ClearAPIBase clears the value of the "api_base" field.
  30038. func (m *WxCardMutation) ClearAPIBase() {
  30039. m.api_base = nil
  30040. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  30041. }
  30042. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  30043. func (m *WxCardMutation) APIBaseCleared() bool {
  30044. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  30045. return ok
  30046. }
  30047. // ResetAPIBase resets all changes to the "api_base" field.
  30048. func (m *WxCardMutation) ResetAPIBase() {
  30049. m.api_base = nil
  30050. delete(m.clearedFields, wxcard.FieldAPIBase)
  30051. }
  30052. // SetAPIKey sets the "api_key" field.
  30053. func (m *WxCardMutation) SetAPIKey(s string) {
  30054. m.api_key = &s
  30055. }
  30056. // APIKey returns the value of the "api_key" field in the mutation.
  30057. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  30058. v := m.api_key
  30059. if v == nil {
  30060. return
  30061. }
  30062. return *v, true
  30063. }
  30064. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  30065. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  30066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30067. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  30068. if !m.op.Is(OpUpdateOne) {
  30069. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  30070. }
  30071. if m.id == nil || m.oldValue == nil {
  30072. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  30073. }
  30074. oldValue, err := m.oldValue(ctx)
  30075. if err != nil {
  30076. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  30077. }
  30078. return oldValue.APIKey, nil
  30079. }
  30080. // ClearAPIKey clears the value of the "api_key" field.
  30081. func (m *WxCardMutation) ClearAPIKey() {
  30082. m.api_key = nil
  30083. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  30084. }
  30085. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  30086. func (m *WxCardMutation) APIKeyCleared() bool {
  30087. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  30088. return ok
  30089. }
  30090. // ResetAPIKey resets all changes to the "api_key" field.
  30091. func (m *WxCardMutation) ResetAPIKey() {
  30092. m.api_key = nil
  30093. delete(m.clearedFields, wxcard.FieldAPIKey)
  30094. }
  30095. // SetAiInfo sets the "ai_info" field.
  30096. func (m *WxCardMutation) SetAiInfo(s string) {
  30097. m.ai_info = &s
  30098. }
  30099. // AiInfo returns the value of the "ai_info" field in the mutation.
  30100. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  30101. v := m.ai_info
  30102. if v == nil {
  30103. return
  30104. }
  30105. return *v, true
  30106. }
  30107. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  30108. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  30109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30110. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  30111. if !m.op.Is(OpUpdateOne) {
  30112. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  30113. }
  30114. if m.id == nil || m.oldValue == nil {
  30115. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  30116. }
  30117. oldValue, err := m.oldValue(ctx)
  30118. if err != nil {
  30119. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  30120. }
  30121. return oldValue.AiInfo, nil
  30122. }
  30123. // ClearAiInfo clears the value of the "ai_info" field.
  30124. func (m *WxCardMutation) ClearAiInfo() {
  30125. m.ai_info = nil
  30126. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  30127. }
  30128. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  30129. func (m *WxCardMutation) AiInfoCleared() bool {
  30130. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  30131. return ok
  30132. }
  30133. // ResetAiInfo resets all changes to the "ai_info" field.
  30134. func (m *WxCardMutation) ResetAiInfo() {
  30135. m.ai_info = nil
  30136. delete(m.clearedFields, wxcard.FieldAiInfo)
  30137. }
  30138. // SetIntro sets the "intro" field.
  30139. func (m *WxCardMutation) SetIntro(s string) {
  30140. m.intro = &s
  30141. }
  30142. // Intro returns the value of the "intro" field in the mutation.
  30143. func (m *WxCardMutation) Intro() (r string, exists bool) {
  30144. v := m.intro
  30145. if v == nil {
  30146. return
  30147. }
  30148. return *v, true
  30149. }
  30150. // OldIntro returns the old "intro" field's value of the WxCard entity.
  30151. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  30152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30153. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  30154. if !m.op.Is(OpUpdateOne) {
  30155. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  30156. }
  30157. if m.id == nil || m.oldValue == nil {
  30158. return v, errors.New("OldIntro requires an ID field in the mutation")
  30159. }
  30160. oldValue, err := m.oldValue(ctx)
  30161. if err != nil {
  30162. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  30163. }
  30164. return oldValue.Intro, nil
  30165. }
  30166. // ClearIntro clears the value of the "intro" field.
  30167. func (m *WxCardMutation) ClearIntro() {
  30168. m.intro = nil
  30169. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  30170. }
  30171. // IntroCleared returns if the "intro" field was cleared in this mutation.
  30172. func (m *WxCardMutation) IntroCleared() bool {
  30173. _, ok := m.clearedFields[wxcard.FieldIntro]
  30174. return ok
  30175. }
  30176. // ResetIntro resets all changes to the "intro" field.
  30177. func (m *WxCardMutation) ResetIntro() {
  30178. m.intro = nil
  30179. delete(m.clearedFields, wxcard.FieldIntro)
  30180. }
  30181. // Where appends a list predicates to the WxCardMutation builder.
  30182. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  30183. m.predicates = append(m.predicates, ps...)
  30184. }
  30185. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  30186. // users can use type-assertion to append predicates that do not depend on any generated package.
  30187. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  30188. p := make([]predicate.WxCard, len(ps))
  30189. for i := range ps {
  30190. p[i] = ps[i]
  30191. }
  30192. m.Where(p...)
  30193. }
  30194. // Op returns the operation name.
  30195. func (m *WxCardMutation) Op() Op {
  30196. return m.op
  30197. }
  30198. // SetOp allows setting the mutation operation.
  30199. func (m *WxCardMutation) SetOp(op Op) {
  30200. m.op = op
  30201. }
  30202. // Type returns the node type of this mutation (WxCard).
  30203. func (m *WxCardMutation) Type() string {
  30204. return m.typ
  30205. }
  30206. // Fields returns all fields that were changed during this mutation. Note that in
  30207. // order to get all numeric fields that were incremented/decremented, call
  30208. // AddedFields().
  30209. func (m *WxCardMutation) Fields() []string {
  30210. fields := make([]string, 0, 18)
  30211. if m.created_at != nil {
  30212. fields = append(fields, wxcard.FieldCreatedAt)
  30213. }
  30214. if m.updated_at != nil {
  30215. fields = append(fields, wxcard.FieldUpdatedAt)
  30216. }
  30217. if m.deleted_at != nil {
  30218. fields = append(fields, wxcard.FieldDeletedAt)
  30219. }
  30220. if m.user_id != nil {
  30221. fields = append(fields, wxcard.FieldUserID)
  30222. }
  30223. if m.wx_user_id != nil {
  30224. fields = append(fields, wxcard.FieldWxUserID)
  30225. }
  30226. if m.avatar != nil {
  30227. fields = append(fields, wxcard.FieldAvatar)
  30228. }
  30229. if m.logo != nil {
  30230. fields = append(fields, wxcard.FieldLogo)
  30231. }
  30232. if m.name != nil {
  30233. fields = append(fields, wxcard.FieldName)
  30234. }
  30235. if m.company != nil {
  30236. fields = append(fields, wxcard.FieldCompany)
  30237. }
  30238. if m.address != nil {
  30239. fields = append(fields, wxcard.FieldAddress)
  30240. }
  30241. if m.phone != nil {
  30242. fields = append(fields, wxcard.FieldPhone)
  30243. }
  30244. if m.official_account != nil {
  30245. fields = append(fields, wxcard.FieldOfficialAccount)
  30246. }
  30247. if m.wechat_account != nil {
  30248. fields = append(fields, wxcard.FieldWechatAccount)
  30249. }
  30250. if m.email != nil {
  30251. fields = append(fields, wxcard.FieldEmail)
  30252. }
  30253. if m.api_base != nil {
  30254. fields = append(fields, wxcard.FieldAPIBase)
  30255. }
  30256. if m.api_key != nil {
  30257. fields = append(fields, wxcard.FieldAPIKey)
  30258. }
  30259. if m.ai_info != nil {
  30260. fields = append(fields, wxcard.FieldAiInfo)
  30261. }
  30262. if m.intro != nil {
  30263. fields = append(fields, wxcard.FieldIntro)
  30264. }
  30265. return fields
  30266. }
  30267. // Field returns the value of a field with the given name. The second boolean
  30268. // return value indicates that this field was not set, or was not defined in the
  30269. // schema.
  30270. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  30271. switch name {
  30272. case wxcard.FieldCreatedAt:
  30273. return m.CreatedAt()
  30274. case wxcard.FieldUpdatedAt:
  30275. return m.UpdatedAt()
  30276. case wxcard.FieldDeletedAt:
  30277. return m.DeletedAt()
  30278. case wxcard.FieldUserID:
  30279. return m.UserID()
  30280. case wxcard.FieldWxUserID:
  30281. return m.WxUserID()
  30282. case wxcard.FieldAvatar:
  30283. return m.Avatar()
  30284. case wxcard.FieldLogo:
  30285. return m.Logo()
  30286. case wxcard.FieldName:
  30287. return m.Name()
  30288. case wxcard.FieldCompany:
  30289. return m.Company()
  30290. case wxcard.FieldAddress:
  30291. return m.Address()
  30292. case wxcard.FieldPhone:
  30293. return m.Phone()
  30294. case wxcard.FieldOfficialAccount:
  30295. return m.OfficialAccount()
  30296. case wxcard.FieldWechatAccount:
  30297. return m.WechatAccount()
  30298. case wxcard.FieldEmail:
  30299. return m.Email()
  30300. case wxcard.FieldAPIBase:
  30301. return m.APIBase()
  30302. case wxcard.FieldAPIKey:
  30303. return m.APIKey()
  30304. case wxcard.FieldAiInfo:
  30305. return m.AiInfo()
  30306. case wxcard.FieldIntro:
  30307. return m.Intro()
  30308. }
  30309. return nil, false
  30310. }
  30311. // OldField returns the old value of the field from the database. An error is
  30312. // returned if the mutation operation is not UpdateOne, or the query to the
  30313. // database failed.
  30314. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30315. switch name {
  30316. case wxcard.FieldCreatedAt:
  30317. return m.OldCreatedAt(ctx)
  30318. case wxcard.FieldUpdatedAt:
  30319. return m.OldUpdatedAt(ctx)
  30320. case wxcard.FieldDeletedAt:
  30321. return m.OldDeletedAt(ctx)
  30322. case wxcard.FieldUserID:
  30323. return m.OldUserID(ctx)
  30324. case wxcard.FieldWxUserID:
  30325. return m.OldWxUserID(ctx)
  30326. case wxcard.FieldAvatar:
  30327. return m.OldAvatar(ctx)
  30328. case wxcard.FieldLogo:
  30329. return m.OldLogo(ctx)
  30330. case wxcard.FieldName:
  30331. return m.OldName(ctx)
  30332. case wxcard.FieldCompany:
  30333. return m.OldCompany(ctx)
  30334. case wxcard.FieldAddress:
  30335. return m.OldAddress(ctx)
  30336. case wxcard.FieldPhone:
  30337. return m.OldPhone(ctx)
  30338. case wxcard.FieldOfficialAccount:
  30339. return m.OldOfficialAccount(ctx)
  30340. case wxcard.FieldWechatAccount:
  30341. return m.OldWechatAccount(ctx)
  30342. case wxcard.FieldEmail:
  30343. return m.OldEmail(ctx)
  30344. case wxcard.FieldAPIBase:
  30345. return m.OldAPIBase(ctx)
  30346. case wxcard.FieldAPIKey:
  30347. return m.OldAPIKey(ctx)
  30348. case wxcard.FieldAiInfo:
  30349. return m.OldAiInfo(ctx)
  30350. case wxcard.FieldIntro:
  30351. return m.OldIntro(ctx)
  30352. }
  30353. return nil, fmt.Errorf("unknown WxCard field %s", name)
  30354. }
  30355. // SetField sets the value of a field with the given name. It returns an error if
  30356. // the field is not defined in the schema, or if the type mismatched the field
  30357. // type.
  30358. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  30359. switch name {
  30360. case wxcard.FieldCreatedAt:
  30361. v, ok := value.(time.Time)
  30362. if !ok {
  30363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30364. }
  30365. m.SetCreatedAt(v)
  30366. return nil
  30367. case wxcard.FieldUpdatedAt:
  30368. v, ok := value.(time.Time)
  30369. if !ok {
  30370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30371. }
  30372. m.SetUpdatedAt(v)
  30373. return nil
  30374. case wxcard.FieldDeletedAt:
  30375. v, ok := value.(time.Time)
  30376. if !ok {
  30377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30378. }
  30379. m.SetDeletedAt(v)
  30380. return nil
  30381. case wxcard.FieldUserID:
  30382. v, ok := value.(uint64)
  30383. if !ok {
  30384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30385. }
  30386. m.SetUserID(v)
  30387. return nil
  30388. case wxcard.FieldWxUserID:
  30389. v, ok := value.(uint64)
  30390. if !ok {
  30391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30392. }
  30393. m.SetWxUserID(v)
  30394. return nil
  30395. case wxcard.FieldAvatar:
  30396. v, ok := value.(string)
  30397. if !ok {
  30398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30399. }
  30400. m.SetAvatar(v)
  30401. return nil
  30402. case wxcard.FieldLogo:
  30403. v, ok := value.(string)
  30404. if !ok {
  30405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30406. }
  30407. m.SetLogo(v)
  30408. return nil
  30409. case wxcard.FieldName:
  30410. v, ok := value.(string)
  30411. if !ok {
  30412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30413. }
  30414. m.SetName(v)
  30415. return nil
  30416. case wxcard.FieldCompany:
  30417. v, ok := value.(string)
  30418. if !ok {
  30419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30420. }
  30421. m.SetCompany(v)
  30422. return nil
  30423. case wxcard.FieldAddress:
  30424. v, ok := value.(string)
  30425. if !ok {
  30426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30427. }
  30428. m.SetAddress(v)
  30429. return nil
  30430. case wxcard.FieldPhone:
  30431. v, ok := value.(string)
  30432. if !ok {
  30433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30434. }
  30435. m.SetPhone(v)
  30436. return nil
  30437. case wxcard.FieldOfficialAccount:
  30438. v, ok := value.(string)
  30439. if !ok {
  30440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30441. }
  30442. m.SetOfficialAccount(v)
  30443. return nil
  30444. case wxcard.FieldWechatAccount:
  30445. v, ok := value.(string)
  30446. if !ok {
  30447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30448. }
  30449. m.SetWechatAccount(v)
  30450. return nil
  30451. case wxcard.FieldEmail:
  30452. v, ok := value.(string)
  30453. if !ok {
  30454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30455. }
  30456. m.SetEmail(v)
  30457. return nil
  30458. case wxcard.FieldAPIBase:
  30459. v, ok := value.(string)
  30460. if !ok {
  30461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30462. }
  30463. m.SetAPIBase(v)
  30464. return nil
  30465. case wxcard.FieldAPIKey:
  30466. v, ok := value.(string)
  30467. if !ok {
  30468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30469. }
  30470. m.SetAPIKey(v)
  30471. return nil
  30472. case wxcard.FieldAiInfo:
  30473. v, ok := value.(string)
  30474. if !ok {
  30475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30476. }
  30477. m.SetAiInfo(v)
  30478. return nil
  30479. case wxcard.FieldIntro:
  30480. v, ok := value.(string)
  30481. if !ok {
  30482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30483. }
  30484. m.SetIntro(v)
  30485. return nil
  30486. }
  30487. return fmt.Errorf("unknown WxCard field %s", name)
  30488. }
  30489. // AddedFields returns all numeric fields that were incremented/decremented during
  30490. // this mutation.
  30491. func (m *WxCardMutation) AddedFields() []string {
  30492. var fields []string
  30493. if m.adduser_id != nil {
  30494. fields = append(fields, wxcard.FieldUserID)
  30495. }
  30496. if m.addwx_user_id != nil {
  30497. fields = append(fields, wxcard.FieldWxUserID)
  30498. }
  30499. return fields
  30500. }
  30501. // AddedField returns the numeric value that was incremented/decremented on a field
  30502. // with the given name. The second boolean return value indicates that this field
  30503. // was not set, or was not defined in the schema.
  30504. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  30505. switch name {
  30506. case wxcard.FieldUserID:
  30507. return m.AddedUserID()
  30508. case wxcard.FieldWxUserID:
  30509. return m.AddedWxUserID()
  30510. }
  30511. return nil, false
  30512. }
  30513. // AddField adds the value to the field with the given name. It returns an error if
  30514. // the field is not defined in the schema, or if the type mismatched the field
  30515. // type.
  30516. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  30517. switch name {
  30518. case wxcard.FieldUserID:
  30519. v, ok := value.(int64)
  30520. if !ok {
  30521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30522. }
  30523. m.AddUserID(v)
  30524. return nil
  30525. case wxcard.FieldWxUserID:
  30526. v, ok := value.(int64)
  30527. if !ok {
  30528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30529. }
  30530. m.AddWxUserID(v)
  30531. return nil
  30532. }
  30533. return fmt.Errorf("unknown WxCard numeric field %s", name)
  30534. }
  30535. // ClearedFields returns all nullable fields that were cleared during this
  30536. // mutation.
  30537. func (m *WxCardMutation) ClearedFields() []string {
  30538. var fields []string
  30539. if m.FieldCleared(wxcard.FieldDeletedAt) {
  30540. fields = append(fields, wxcard.FieldDeletedAt)
  30541. }
  30542. if m.FieldCleared(wxcard.FieldUserID) {
  30543. fields = append(fields, wxcard.FieldUserID)
  30544. }
  30545. if m.FieldCleared(wxcard.FieldWxUserID) {
  30546. fields = append(fields, wxcard.FieldWxUserID)
  30547. }
  30548. if m.FieldCleared(wxcard.FieldEmail) {
  30549. fields = append(fields, wxcard.FieldEmail)
  30550. }
  30551. if m.FieldCleared(wxcard.FieldAPIBase) {
  30552. fields = append(fields, wxcard.FieldAPIBase)
  30553. }
  30554. if m.FieldCleared(wxcard.FieldAPIKey) {
  30555. fields = append(fields, wxcard.FieldAPIKey)
  30556. }
  30557. if m.FieldCleared(wxcard.FieldAiInfo) {
  30558. fields = append(fields, wxcard.FieldAiInfo)
  30559. }
  30560. if m.FieldCleared(wxcard.FieldIntro) {
  30561. fields = append(fields, wxcard.FieldIntro)
  30562. }
  30563. return fields
  30564. }
  30565. // FieldCleared returns a boolean indicating if a field with the given name was
  30566. // cleared in this mutation.
  30567. func (m *WxCardMutation) FieldCleared(name string) bool {
  30568. _, ok := m.clearedFields[name]
  30569. return ok
  30570. }
  30571. // ClearField clears the value of the field with the given name. It returns an
  30572. // error if the field is not defined in the schema.
  30573. func (m *WxCardMutation) ClearField(name string) error {
  30574. switch name {
  30575. case wxcard.FieldDeletedAt:
  30576. m.ClearDeletedAt()
  30577. return nil
  30578. case wxcard.FieldUserID:
  30579. m.ClearUserID()
  30580. return nil
  30581. case wxcard.FieldWxUserID:
  30582. m.ClearWxUserID()
  30583. return nil
  30584. case wxcard.FieldEmail:
  30585. m.ClearEmail()
  30586. return nil
  30587. case wxcard.FieldAPIBase:
  30588. m.ClearAPIBase()
  30589. return nil
  30590. case wxcard.FieldAPIKey:
  30591. m.ClearAPIKey()
  30592. return nil
  30593. case wxcard.FieldAiInfo:
  30594. m.ClearAiInfo()
  30595. return nil
  30596. case wxcard.FieldIntro:
  30597. m.ClearIntro()
  30598. return nil
  30599. }
  30600. return fmt.Errorf("unknown WxCard nullable field %s", name)
  30601. }
  30602. // ResetField resets all changes in the mutation for the field with the given name.
  30603. // It returns an error if the field is not defined in the schema.
  30604. func (m *WxCardMutation) ResetField(name string) error {
  30605. switch name {
  30606. case wxcard.FieldCreatedAt:
  30607. m.ResetCreatedAt()
  30608. return nil
  30609. case wxcard.FieldUpdatedAt:
  30610. m.ResetUpdatedAt()
  30611. return nil
  30612. case wxcard.FieldDeletedAt:
  30613. m.ResetDeletedAt()
  30614. return nil
  30615. case wxcard.FieldUserID:
  30616. m.ResetUserID()
  30617. return nil
  30618. case wxcard.FieldWxUserID:
  30619. m.ResetWxUserID()
  30620. return nil
  30621. case wxcard.FieldAvatar:
  30622. m.ResetAvatar()
  30623. return nil
  30624. case wxcard.FieldLogo:
  30625. m.ResetLogo()
  30626. return nil
  30627. case wxcard.FieldName:
  30628. m.ResetName()
  30629. return nil
  30630. case wxcard.FieldCompany:
  30631. m.ResetCompany()
  30632. return nil
  30633. case wxcard.FieldAddress:
  30634. m.ResetAddress()
  30635. return nil
  30636. case wxcard.FieldPhone:
  30637. m.ResetPhone()
  30638. return nil
  30639. case wxcard.FieldOfficialAccount:
  30640. m.ResetOfficialAccount()
  30641. return nil
  30642. case wxcard.FieldWechatAccount:
  30643. m.ResetWechatAccount()
  30644. return nil
  30645. case wxcard.FieldEmail:
  30646. m.ResetEmail()
  30647. return nil
  30648. case wxcard.FieldAPIBase:
  30649. m.ResetAPIBase()
  30650. return nil
  30651. case wxcard.FieldAPIKey:
  30652. m.ResetAPIKey()
  30653. return nil
  30654. case wxcard.FieldAiInfo:
  30655. m.ResetAiInfo()
  30656. return nil
  30657. case wxcard.FieldIntro:
  30658. m.ResetIntro()
  30659. return nil
  30660. }
  30661. return fmt.Errorf("unknown WxCard field %s", name)
  30662. }
  30663. // AddedEdges returns all edge names that were set/added in this mutation.
  30664. func (m *WxCardMutation) AddedEdges() []string {
  30665. edges := make([]string, 0, 0)
  30666. return edges
  30667. }
  30668. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30669. // name in this mutation.
  30670. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  30671. return nil
  30672. }
  30673. // RemovedEdges returns all edge names that were removed in this mutation.
  30674. func (m *WxCardMutation) RemovedEdges() []string {
  30675. edges := make([]string, 0, 0)
  30676. return edges
  30677. }
  30678. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30679. // the given name in this mutation.
  30680. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  30681. return nil
  30682. }
  30683. // ClearedEdges returns all edge names that were cleared in this mutation.
  30684. func (m *WxCardMutation) ClearedEdges() []string {
  30685. edges := make([]string, 0, 0)
  30686. return edges
  30687. }
  30688. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30689. // was cleared in this mutation.
  30690. func (m *WxCardMutation) EdgeCleared(name string) bool {
  30691. return false
  30692. }
  30693. // ClearEdge clears the value of the edge with the given name. It returns an error
  30694. // if that edge is not defined in the schema.
  30695. func (m *WxCardMutation) ClearEdge(name string) error {
  30696. return fmt.Errorf("unknown WxCard unique edge %s", name)
  30697. }
  30698. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30699. // It returns an error if the edge is not defined in the schema.
  30700. func (m *WxCardMutation) ResetEdge(name string) error {
  30701. return fmt.Errorf("unknown WxCard edge %s", name)
  30702. }
  30703. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  30704. type WxCardUserMutation struct {
  30705. config
  30706. op Op
  30707. typ string
  30708. id *uint64
  30709. created_at *time.Time
  30710. updated_at *time.Time
  30711. deleted_at *time.Time
  30712. wxid *string
  30713. account *string
  30714. avatar *string
  30715. nickname *string
  30716. remark *string
  30717. phone *string
  30718. open_id *string
  30719. union_id *string
  30720. session_key *string
  30721. is_vip *int
  30722. addis_vip *int
  30723. clearedFields map[string]struct{}
  30724. done bool
  30725. oldValue func(context.Context) (*WxCardUser, error)
  30726. predicates []predicate.WxCardUser
  30727. }
  30728. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  30729. // wxcarduserOption allows management of the mutation configuration using functional options.
  30730. type wxcarduserOption func(*WxCardUserMutation)
  30731. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  30732. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  30733. m := &WxCardUserMutation{
  30734. config: c,
  30735. op: op,
  30736. typ: TypeWxCardUser,
  30737. clearedFields: make(map[string]struct{}),
  30738. }
  30739. for _, opt := range opts {
  30740. opt(m)
  30741. }
  30742. return m
  30743. }
  30744. // withWxCardUserID sets the ID field of the mutation.
  30745. func withWxCardUserID(id uint64) wxcarduserOption {
  30746. return func(m *WxCardUserMutation) {
  30747. var (
  30748. err error
  30749. once sync.Once
  30750. value *WxCardUser
  30751. )
  30752. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  30753. once.Do(func() {
  30754. if m.done {
  30755. err = errors.New("querying old values post mutation is not allowed")
  30756. } else {
  30757. value, err = m.Client().WxCardUser.Get(ctx, id)
  30758. }
  30759. })
  30760. return value, err
  30761. }
  30762. m.id = &id
  30763. }
  30764. }
  30765. // withWxCardUser sets the old WxCardUser of the mutation.
  30766. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  30767. return func(m *WxCardUserMutation) {
  30768. m.oldValue = func(context.Context) (*WxCardUser, error) {
  30769. return node, nil
  30770. }
  30771. m.id = &node.ID
  30772. }
  30773. }
  30774. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30775. // executed in a transaction (ent.Tx), a transactional client is returned.
  30776. func (m WxCardUserMutation) Client() *Client {
  30777. client := &Client{config: m.config}
  30778. client.init()
  30779. return client
  30780. }
  30781. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30782. // it returns an error otherwise.
  30783. func (m WxCardUserMutation) Tx() (*Tx, error) {
  30784. if _, ok := m.driver.(*txDriver); !ok {
  30785. return nil, errors.New("ent: mutation is not running in a transaction")
  30786. }
  30787. tx := &Tx{config: m.config}
  30788. tx.init()
  30789. return tx, nil
  30790. }
  30791. // SetID sets the value of the id field. Note that this
  30792. // operation is only accepted on creation of WxCardUser entities.
  30793. func (m *WxCardUserMutation) SetID(id uint64) {
  30794. m.id = &id
  30795. }
  30796. // ID returns the ID value in the mutation. Note that the ID is only available
  30797. // if it was provided to the builder or after it was returned from the database.
  30798. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  30799. if m.id == nil {
  30800. return
  30801. }
  30802. return *m.id, true
  30803. }
  30804. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30805. // That means, if the mutation is applied within a transaction with an isolation level such
  30806. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30807. // or updated by the mutation.
  30808. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  30809. switch {
  30810. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30811. id, exists := m.ID()
  30812. if exists {
  30813. return []uint64{id}, nil
  30814. }
  30815. fallthrough
  30816. case m.op.Is(OpUpdate | OpDelete):
  30817. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  30818. default:
  30819. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30820. }
  30821. }
  30822. // SetCreatedAt sets the "created_at" field.
  30823. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  30824. m.created_at = &t
  30825. }
  30826. // CreatedAt returns the value of the "created_at" field in the mutation.
  30827. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  30828. v := m.created_at
  30829. if v == nil {
  30830. return
  30831. }
  30832. return *v, true
  30833. }
  30834. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  30835. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30837. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30838. if !m.op.Is(OpUpdateOne) {
  30839. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30840. }
  30841. if m.id == nil || m.oldValue == nil {
  30842. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30843. }
  30844. oldValue, err := m.oldValue(ctx)
  30845. if err != nil {
  30846. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30847. }
  30848. return oldValue.CreatedAt, nil
  30849. }
  30850. // ResetCreatedAt resets all changes to the "created_at" field.
  30851. func (m *WxCardUserMutation) ResetCreatedAt() {
  30852. m.created_at = nil
  30853. }
  30854. // SetUpdatedAt sets the "updated_at" field.
  30855. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  30856. m.updated_at = &t
  30857. }
  30858. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30859. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  30860. v := m.updated_at
  30861. if v == nil {
  30862. return
  30863. }
  30864. return *v, true
  30865. }
  30866. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  30867. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30869. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30870. if !m.op.Is(OpUpdateOne) {
  30871. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30872. }
  30873. if m.id == nil || m.oldValue == nil {
  30874. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30875. }
  30876. oldValue, err := m.oldValue(ctx)
  30877. if err != nil {
  30878. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30879. }
  30880. return oldValue.UpdatedAt, nil
  30881. }
  30882. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30883. func (m *WxCardUserMutation) ResetUpdatedAt() {
  30884. m.updated_at = nil
  30885. }
  30886. // SetDeletedAt sets the "deleted_at" field.
  30887. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  30888. m.deleted_at = &t
  30889. }
  30890. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30891. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  30892. v := m.deleted_at
  30893. if v == nil {
  30894. return
  30895. }
  30896. return *v, true
  30897. }
  30898. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  30899. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30901. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30902. if !m.op.Is(OpUpdateOne) {
  30903. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30904. }
  30905. if m.id == nil || m.oldValue == nil {
  30906. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30907. }
  30908. oldValue, err := m.oldValue(ctx)
  30909. if err != nil {
  30910. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30911. }
  30912. return oldValue.DeletedAt, nil
  30913. }
  30914. // ClearDeletedAt clears the value of the "deleted_at" field.
  30915. func (m *WxCardUserMutation) ClearDeletedAt() {
  30916. m.deleted_at = nil
  30917. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  30918. }
  30919. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30920. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  30921. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  30922. return ok
  30923. }
  30924. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30925. func (m *WxCardUserMutation) ResetDeletedAt() {
  30926. m.deleted_at = nil
  30927. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  30928. }
  30929. // SetWxid sets the "wxid" field.
  30930. func (m *WxCardUserMutation) SetWxid(s string) {
  30931. m.wxid = &s
  30932. }
  30933. // Wxid returns the value of the "wxid" field in the mutation.
  30934. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  30935. v := m.wxid
  30936. if v == nil {
  30937. return
  30938. }
  30939. return *v, true
  30940. }
  30941. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  30942. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30944. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  30945. if !m.op.Is(OpUpdateOne) {
  30946. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  30947. }
  30948. if m.id == nil || m.oldValue == nil {
  30949. return v, errors.New("OldWxid requires an ID field in the mutation")
  30950. }
  30951. oldValue, err := m.oldValue(ctx)
  30952. if err != nil {
  30953. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  30954. }
  30955. return oldValue.Wxid, nil
  30956. }
  30957. // ResetWxid resets all changes to the "wxid" field.
  30958. func (m *WxCardUserMutation) ResetWxid() {
  30959. m.wxid = nil
  30960. }
  30961. // SetAccount sets the "account" field.
  30962. func (m *WxCardUserMutation) SetAccount(s string) {
  30963. m.account = &s
  30964. }
  30965. // Account returns the value of the "account" field in the mutation.
  30966. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  30967. v := m.account
  30968. if v == nil {
  30969. return
  30970. }
  30971. return *v, true
  30972. }
  30973. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  30974. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30976. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  30977. if !m.op.Is(OpUpdateOne) {
  30978. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  30979. }
  30980. if m.id == nil || m.oldValue == nil {
  30981. return v, errors.New("OldAccount requires an ID field in the mutation")
  30982. }
  30983. oldValue, err := m.oldValue(ctx)
  30984. if err != nil {
  30985. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  30986. }
  30987. return oldValue.Account, nil
  30988. }
  30989. // ResetAccount resets all changes to the "account" field.
  30990. func (m *WxCardUserMutation) ResetAccount() {
  30991. m.account = nil
  30992. }
  30993. // SetAvatar sets the "avatar" field.
  30994. func (m *WxCardUserMutation) SetAvatar(s string) {
  30995. m.avatar = &s
  30996. }
  30997. // Avatar returns the value of the "avatar" field in the mutation.
  30998. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  30999. v := m.avatar
  31000. if v == nil {
  31001. return
  31002. }
  31003. return *v, true
  31004. }
  31005. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  31006. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31008. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  31009. if !m.op.Is(OpUpdateOne) {
  31010. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  31011. }
  31012. if m.id == nil || m.oldValue == nil {
  31013. return v, errors.New("OldAvatar requires an ID field in the mutation")
  31014. }
  31015. oldValue, err := m.oldValue(ctx)
  31016. if err != nil {
  31017. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  31018. }
  31019. return oldValue.Avatar, nil
  31020. }
  31021. // ResetAvatar resets all changes to the "avatar" field.
  31022. func (m *WxCardUserMutation) ResetAvatar() {
  31023. m.avatar = nil
  31024. }
  31025. // SetNickname sets the "nickname" field.
  31026. func (m *WxCardUserMutation) SetNickname(s string) {
  31027. m.nickname = &s
  31028. }
  31029. // Nickname returns the value of the "nickname" field in the mutation.
  31030. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  31031. v := m.nickname
  31032. if v == nil {
  31033. return
  31034. }
  31035. return *v, true
  31036. }
  31037. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  31038. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31040. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  31041. if !m.op.Is(OpUpdateOne) {
  31042. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  31043. }
  31044. if m.id == nil || m.oldValue == nil {
  31045. return v, errors.New("OldNickname requires an ID field in the mutation")
  31046. }
  31047. oldValue, err := m.oldValue(ctx)
  31048. if err != nil {
  31049. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  31050. }
  31051. return oldValue.Nickname, nil
  31052. }
  31053. // ResetNickname resets all changes to the "nickname" field.
  31054. func (m *WxCardUserMutation) ResetNickname() {
  31055. m.nickname = nil
  31056. }
  31057. // SetRemark sets the "remark" field.
  31058. func (m *WxCardUserMutation) SetRemark(s string) {
  31059. m.remark = &s
  31060. }
  31061. // Remark returns the value of the "remark" field in the mutation.
  31062. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  31063. v := m.remark
  31064. if v == nil {
  31065. return
  31066. }
  31067. return *v, true
  31068. }
  31069. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  31070. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31072. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  31073. if !m.op.Is(OpUpdateOne) {
  31074. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  31075. }
  31076. if m.id == nil || m.oldValue == nil {
  31077. return v, errors.New("OldRemark requires an ID field in the mutation")
  31078. }
  31079. oldValue, err := m.oldValue(ctx)
  31080. if err != nil {
  31081. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  31082. }
  31083. return oldValue.Remark, nil
  31084. }
  31085. // ResetRemark resets all changes to the "remark" field.
  31086. func (m *WxCardUserMutation) ResetRemark() {
  31087. m.remark = nil
  31088. }
  31089. // SetPhone sets the "phone" field.
  31090. func (m *WxCardUserMutation) SetPhone(s string) {
  31091. m.phone = &s
  31092. }
  31093. // Phone returns the value of the "phone" field in the mutation.
  31094. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  31095. v := m.phone
  31096. if v == nil {
  31097. return
  31098. }
  31099. return *v, true
  31100. }
  31101. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  31102. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31104. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  31105. if !m.op.Is(OpUpdateOne) {
  31106. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  31107. }
  31108. if m.id == nil || m.oldValue == nil {
  31109. return v, errors.New("OldPhone requires an ID field in the mutation")
  31110. }
  31111. oldValue, err := m.oldValue(ctx)
  31112. if err != nil {
  31113. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  31114. }
  31115. return oldValue.Phone, nil
  31116. }
  31117. // ResetPhone resets all changes to the "phone" field.
  31118. func (m *WxCardUserMutation) ResetPhone() {
  31119. m.phone = nil
  31120. }
  31121. // SetOpenID sets the "open_id" field.
  31122. func (m *WxCardUserMutation) SetOpenID(s string) {
  31123. m.open_id = &s
  31124. }
  31125. // OpenID returns the value of the "open_id" field in the mutation.
  31126. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  31127. v := m.open_id
  31128. if v == nil {
  31129. return
  31130. }
  31131. return *v, true
  31132. }
  31133. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  31134. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31136. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  31137. if !m.op.Is(OpUpdateOne) {
  31138. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  31139. }
  31140. if m.id == nil || m.oldValue == nil {
  31141. return v, errors.New("OldOpenID requires an ID field in the mutation")
  31142. }
  31143. oldValue, err := m.oldValue(ctx)
  31144. if err != nil {
  31145. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  31146. }
  31147. return oldValue.OpenID, nil
  31148. }
  31149. // ResetOpenID resets all changes to the "open_id" field.
  31150. func (m *WxCardUserMutation) ResetOpenID() {
  31151. m.open_id = nil
  31152. }
  31153. // SetUnionID sets the "union_id" field.
  31154. func (m *WxCardUserMutation) SetUnionID(s string) {
  31155. m.union_id = &s
  31156. }
  31157. // UnionID returns the value of the "union_id" field in the mutation.
  31158. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  31159. v := m.union_id
  31160. if v == nil {
  31161. return
  31162. }
  31163. return *v, true
  31164. }
  31165. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  31166. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31168. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  31169. if !m.op.Is(OpUpdateOne) {
  31170. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  31171. }
  31172. if m.id == nil || m.oldValue == nil {
  31173. return v, errors.New("OldUnionID requires an ID field in the mutation")
  31174. }
  31175. oldValue, err := m.oldValue(ctx)
  31176. if err != nil {
  31177. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  31178. }
  31179. return oldValue.UnionID, nil
  31180. }
  31181. // ResetUnionID resets all changes to the "union_id" field.
  31182. func (m *WxCardUserMutation) ResetUnionID() {
  31183. m.union_id = nil
  31184. }
  31185. // SetSessionKey sets the "session_key" field.
  31186. func (m *WxCardUserMutation) SetSessionKey(s string) {
  31187. m.session_key = &s
  31188. }
  31189. // SessionKey returns the value of the "session_key" field in the mutation.
  31190. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  31191. v := m.session_key
  31192. if v == nil {
  31193. return
  31194. }
  31195. return *v, true
  31196. }
  31197. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  31198. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31200. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  31201. if !m.op.Is(OpUpdateOne) {
  31202. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  31203. }
  31204. if m.id == nil || m.oldValue == nil {
  31205. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  31206. }
  31207. oldValue, err := m.oldValue(ctx)
  31208. if err != nil {
  31209. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  31210. }
  31211. return oldValue.SessionKey, nil
  31212. }
  31213. // ResetSessionKey resets all changes to the "session_key" field.
  31214. func (m *WxCardUserMutation) ResetSessionKey() {
  31215. m.session_key = nil
  31216. }
  31217. // SetIsVip sets the "is_vip" field.
  31218. func (m *WxCardUserMutation) SetIsVip(i int) {
  31219. m.is_vip = &i
  31220. m.addis_vip = nil
  31221. }
  31222. // IsVip returns the value of the "is_vip" field in the mutation.
  31223. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  31224. v := m.is_vip
  31225. if v == nil {
  31226. return
  31227. }
  31228. return *v, true
  31229. }
  31230. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  31231. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31233. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  31234. if !m.op.Is(OpUpdateOne) {
  31235. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  31236. }
  31237. if m.id == nil || m.oldValue == nil {
  31238. return v, errors.New("OldIsVip requires an ID field in the mutation")
  31239. }
  31240. oldValue, err := m.oldValue(ctx)
  31241. if err != nil {
  31242. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  31243. }
  31244. return oldValue.IsVip, nil
  31245. }
  31246. // AddIsVip adds i to the "is_vip" field.
  31247. func (m *WxCardUserMutation) AddIsVip(i int) {
  31248. if m.addis_vip != nil {
  31249. *m.addis_vip += i
  31250. } else {
  31251. m.addis_vip = &i
  31252. }
  31253. }
  31254. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  31255. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  31256. v := m.addis_vip
  31257. if v == nil {
  31258. return
  31259. }
  31260. return *v, true
  31261. }
  31262. // ResetIsVip resets all changes to the "is_vip" field.
  31263. func (m *WxCardUserMutation) ResetIsVip() {
  31264. m.is_vip = nil
  31265. m.addis_vip = nil
  31266. }
  31267. // Where appends a list predicates to the WxCardUserMutation builder.
  31268. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  31269. m.predicates = append(m.predicates, ps...)
  31270. }
  31271. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  31272. // users can use type-assertion to append predicates that do not depend on any generated package.
  31273. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  31274. p := make([]predicate.WxCardUser, len(ps))
  31275. for i := range ps {
  31276. p[i] = ps[i]
  31277. }
  31278. m.Where(p...)
  31279. }
  31280. // Op returns the operation name.
  31281. func (m *WxCardUserMutation) Op() Op {
  31282. return m.op
  31283. }
  31284. // SetOp allows setting the mutation operation.
  31285. func (m *WxCardUserMutation) SetOp(op Op) {
  31286. m.op = op
  31287. }
  31288. // Type returns the node type of this mutation (WxCardUser).
  31289. func (m *WxCardUserMutation) Type() string {
  31290. return m.typ
  31291. }
  31292. // Fields returns all fields that were changed during this mutation. Note that in
  31293. // order to get all numeric fields that were incremented/decremented, call
  31294. // AddedFields().
  31295. func (m *WxCardUserMutation) Fields() []string {
  31296. fields := make([]string, 0, 13)
  31297. if m.created_at != nil {
  31298. fields = append(fields, wxcarduser.FieldCreatedAt)
  31299. }
  31300. if m.updated_at != nil {
  31301. fields = append(fields, wxcarduser.FieldUpdatedAt)
  31302. }
  31303. if m.deleted_at != nil {
  31304. fields = append(fields, wxcarduser.FieldDeletedAt)
  31305. }
  31306. if m.wxid != nil {
  31307. fields = append(fields, wxcarduser.FieldWxid)
  31308. }
  31309. if m.account != nil {
  31310. fields = append(fields, wxcarduser.FieldAccount)
  31311. }
  31312. if m.avatar != nil {
  31313. fields = append(fields, wxcarduser.FieldAvatar)
  31314. }
  31315. if m.nickname != nil {
  31316. fields = append(fields, wxcarduser.FieldNickname)
  31317. }
  31318. if m.remark != nil {
  31319. fields = append(fields, wxcarduser.FieldRemark)
  31320. }
  31321. if m.phone != nil {
  31322. fields = append(fields, wxcarduser.FieldPhone)
  31323. }
  31324. if m.open_id != nil {
  31325. fields = append(fields, wxcarduser.FieldOpenID)
  31326. }
  31327. if m.union_id != nil {
  31328. fields = append(fields, wxcarduser.FieldUnionID)
  31329. }
  31330. if m.session_key != nil {
  31331. fields = append(fields, wxcarduser.FieldSessionKey)
  31332. }
  31333. if m.is_vip != nil {
  31334. fields = append(fields, wxcarduser.FieldIsVip)
  31335. }
  31336. return fields
  31337. }
  31338. // Field returns the value of a field with the given name. The second boolean
  31339. // return value indicates that this field was not set, or was not defined in the
  31340. // schema.
  31341. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  31342. switch name {
  31343. case wxcarduser.FieldCreatedAt:
  31344. return m.CreatedAt()
  31345. case wxcarduser.FieldUpdatedAt:
  31346. return m.UpdatedAt()
  31347. case wxcarduser.FieldDeletedAt:
  31348. return m.DeletedAt()
  31349. case wxcarduser.FieldWxid:
  31350. return m.Wxid()
  31351. case wxcarduser.FieldAccount:
  31352. return m.Account()
  31353. case wxcarduser.FieldAvatar:
  31354. return m.Avatar()
  31355. case wxcarduser.FieldNickname:
  31356. return m.Nickname()
  31357. case wxcarduser.FieldRemark:
  31358. return m.Remark()
  31359. case wxcarduser.FieldPhone:
  31360. return m.Phone()
  31361. case wxcarduser.FieldOpenID:
  31362. return m.OpenID()
  31363. case wxcarduser.FieldUnionID:
  31364. return m.UnionID()
  31365. case wxcarduser.FieldSessionKey:
  31366. return m.SessionKey()
  31367. case wxcarduser.FieldIsVip:
  31368. return m.IsVip()
  31369. }
  31370. return nil, false
  31371. }
  31372. // OldField returns the old value of the field from the database. An error is
  31373. // returned if the mutation operation is not UpdateOne, or the query to the
  31374. // database failed.
  31375. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31376. switch name {
  31377. case wxcarduser.FieldCreatedAt:
  31378. return m.OldCreatedAt(ctx)
  31379. case wxcarduser.FieldUpdatedAt:
  31380. return m.OldUpdatedAt(ctx)
  31381. case wxcarduser.FieldDeletedAt:
  31382. return m.OldDeletedAt(ctx)
  31383. case wxcarduser.FieldWxid:
  31384. return m.OldWxid(ctx)
  31385. case wxcarduser.FieldAccount:
  31386. return m.OldAccount(ctx)
  31387. case wxcarduser.FieldAvatar:
  31388. return m.OldAvatar(ctx)
  31389. case wxcarduser.FieldNickname:
  31390. return m.OldNickname(ctx)
  31391. case wxcarduser.FieldRemark:
  31392. return m.OldRemark(ctx)
  31393. case wxcarduser.FieldPhone:
  31394. return m.OldPhone(ctx)
  31395. case wxcarduser.FieldOpenID:
  31396. return m.OldOpenID(ctx)
  31397. case wxcarduser.FieldUnionID:
  31398. return m.OldUnionID(ctx)
  31399. case wxcarduser.FieldSessionKey:
  31400. return m.OldSessionKey(ctx)
  31401. case wxcarduser.FieldIsVip:
  31402. return m.OldIsVip(ctx)
  31403. }
  31404. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  31405. }
  31406. // SetField sets the value of a field with the given name. It returns an error if
  31407. // the field is not defined in the schema, or if the type mismatched the field
  31408. // type.
  31409. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  31410. switch name {
  31411. case wxcarduser.FieldCreatedAt:
  31412. v, ok := value.(time.Time)
  31413. if !ok {
  31414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31415. }
  31416. m.SetCreatedAt(v)
  31417. return nil
  31418. case wxcarduser.FieldUpdatedAt:
  31419. v, ok := value.(time.Time)
  31420. if !ok {
  31421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31422. }
  31423. m.SetUpdatedAt(v)
  31424. return nil
  31425. case wxcarduser.FieldDeletedAt:
  31426. v, ok := value.(time.Time)
  31427. if !ok {
  31428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31429. }
  31430. m.SetDeletedAt(v)
  31431. return nil
  31432. case wxcarduser.FieldWxid:
  31433. v, ok := value.(string)
  31434. if !ok {
  31435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31436. }
  31437. m.SetWxid(v)
  31438. return nil
  31439. case wxcarduser.FieldAccount:
  31440. v, ok := value.(string)
  31441. if !ok {
  31442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31443. }
  31444. m.SetAccount(v)
  31445. return nil
  31446. case wxcarduser.FieldAvatar:
  31447. v, ok := value.(string)
  31448. if !ok {
  31449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31450. }
  31451. m.SetAvatar(v)
  31452. return nil
  31453. case wxcarduser.FieldNickname:
  31454. v, ok := value.(string)
  31455. if !ok {
  31456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31457. }
  31458. m.SetNickname(v)
  31459. return nil
  31460. case wxcarduser.FieldRemark:
  31461. v, ok := value.(string)
  31462. if !ok {
  31463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31464. }
  31465. m.SetRemark(v)
  31466. return nil
  31467. case wxcarduser.FieldPhone:
  31468. v, ok := value.(string)
  31469. if !ok {
  31470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31471. }
  31472. m.SetPhone(v)
  31473. return nil
  31474. case wxcarduser.FieldOpenID:
  31475. v, ok := value.(string)
  31476. if !ok {
  31477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31478. }
  31479. m.SetOpenID(v)
  31480. return nil
  31481. case wxcarduser.FieldUnionID:
  31482. v, ok := value.(string)
  31483. if !ok {
  31484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31485. }
  31486. m.SetUnionID(v)
  31487. return nil
  31488. case wxcarduser.FieldSessionKey:
  31489. v, ok := value.(string)
  31490. if !ok {
  31491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31492. }
  31493. m.SetSessionKey(v)
  31494. return nil
  31495. case wxcarduser.FieldIsVip:
  31496. v, ok := value.(int)
  31497. if !ok {
  31498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31499. }
  31500. m.SetIsVip(v)
  31501. return nil
  31502. }
  31503. return fmt.Errorf("unknown WxCardUser field %s", name)
  31504. }
  31505. // AddedFields returns all numeric fields that were incremented/decremented during
  31506. // this mutation.
  31507. func (m *WxCardUserMutation) AddedFields() []string {
  31508. var fields []string
  31509. if m.addis_vip != nil {
  31510. fields = append(fields, wxcarduser.FieldIsVip)
  31511. }
  31512. return fields
  31513. }
  31514. // AddedField returns the numeric value that was incremented/decremented on a field
  31515. // with the given name. The second boolean return value indicates that this field
  31516. // was not set, or was not defined in the schema.
  31517. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  31518. switch name {
  31519. case wxcarduser.FieldIsVip:
  31520. return m.AddedIsVip()
  31521. }
  31522. return nil, false
  31523. }
  31524. // AddField adds the value to the field with the given name. It returns an error if
  31525. // the field is not defined in the schema, or if the type mismatched the field
  31526. // type.
  31527. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  31528. switch name {
  31529. case wxcarduser.FieldIsVip:
  31530. v, ok := value.(int)
  31531. if !ok {
  31532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31533. }
  31534. m.AddIsVip(v)
  31535. return nil
  31536. }
  31537. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  31538. }
  31539. // ClearedFields returns all nullable fields that were cleared during this
  31540. // mutation.
  31541. func (m *WxCardUserMutation) ClearedFields() []string {
  31542. var fields []string
  31543. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  31544. fields = append(fields, wxcarduser.FieldDeletedAt)
  31545. }
  31546. return fields
  31547. }
  31548. // FieldCleared returns a boolean indicating if a field with the given name was
  31549. // cleared in this mutation.
  31550. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  31551. _, ok := m.clearedFields[name]
  31552. return ok
  31553. }
  31554. // ClearField clears the value of the field with the given name. It returns an
  31555. // error if the field is not defined in the schema.
  31556. func (m *WxCardUserMutation) ClearField(name string) error {
  31557. switch name {
  31558. case wxcarduser.FieldDeletedAt:
  31559. m.ClearDeletedAt()
  31560. return nil
  31561. }
  31562. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  31563. }
  31564. // ResetField resets all changes in the mutation for the field with the given name.
  31565. // It returns an error if the field is not defined in the schema.
  31566. func (m *WxCardUserMutation) ResetField(name string) error {
  31567. switch name {
  31568. case wxcarduser.FieldCreatedAt:
  31569. m.ResetCreatedAt()
  31570. return nil
  31571. case wxcarduser.FieldUpdatedAt:
  31572. m.ResetUpdatedAt()
  31573. return nil
  31574. case wxcarduser.FieldDeletedAt:
  31575. m.ResetDeletedAt()
  31576. return nil
  31577. case wxcarduser.FieldWxid:
  31578. m.ResetWxid()
  31579. return nil
  31580. case wxcarduser.FieldAccount:
  31581. m.ResetAccount()
  31582. return nil
  31583. case wxcarduser.FieldAvatar:
  31584. m.ResetAvatar()
  31585. return nil
  31586. case wxcarduser.FieldNickname:
  31587. m.ResetNickname()
  31588. return nil
  31589. case wxcarduser.FieldRemark:
  31590. m.ResetRemark()
  31591. return nil
  31592. case wxcarduser.FieldPhone:
  31593. m.ResetPhone()
  31594. return nil
  31595. case wxcarduser.FieldOpenID:
  31596. m.ResetOpenID()
  31597. return nil
  31598. case wxcarduser.FieldUnionID:
  31599. m.ResetUnionID()
  31600. return nil
  31601. case wxcarduser.FieldSessionKey:
  31602. m.ResetSessionKey()
  31603. return nil
  31604. case wxcarduser.FieldIsVip:
  31605. m.ResetIsVip()
  31606. return nil
  31607. }
  31608. return fmt.Errorf("unknown WxCardUser field %s", name)
  31609. }
  31610. // AddedEdges returns all edge names that were set/added in this mutation.
  31611. func (m *WxCardUserMutation) AddedEdges() []string {
  31612. edges := make([]string, 0, 0)
  31613. return edges
  31614. }
  31615. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31616. // name in this mutation.
  31617. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  31618. return nil
  31619. }
  31620. // RemovedEdges returns all edge names that were removed in this mutation.
  31621. func (m *WxCardUserMutation) RemovedEdges() []string {
  31622. edges := make([]string, 0, 0)
  31623. return edges
  31624. }
  31625. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31626. // the given name in this mutation.
  31627. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  31628. return nil
  31629. }
  31630. // ClearedEdges returns all edge names that were cleared in this mutation.
  31631. func (m *WxCardUserMutation) ClearedEdges() []string {
  31632. edges := make([]string, 0, 0)
  31633. return edges
  31634. }
  31635. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31636. // was cleared in this mutation.
  31637. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  31638. return false
  31639. }
  31640. // ClearEdge clears the value of the edge with the given name. It returns an error
  31641. // if that edge is not defined in the schema.
  31642. func (m *WxCardUserMutation) ClearEdge(name string) error {
  31643. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  31644. }
  31645. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31646. // It returns an error if the edge is not defined in the schema.
  31647. func (m *WxCardUserMutation) ResetEdge(name string) error {
  31648. return fmt.Errorf("unknown WxCardUser edge %s", name)
  31649. }
  31650. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  31651. type WxCardVisitMutation struct {
  31652. config
  31653. op Op
  31654. typ string
  31655. id *uint64
  31656. created_at *time.Time
  31657. updated_at *time.Time
  31658. deleted_at *time.Time
  31659. user_id *uint64
  31660. adduser_id *int64
  31661. bot_id *uint64
  31662. addbot_id *int64
  31663. bot_type *uint8
  31664. addbot_type *int8
  31665. clearedFields map[string]struct{}
  31666. done bool
  31667. oldValue func(context.Context) (*WxCardVisit, error)
  31668. predicates []predicate.WxCardVisit
  31669. }
  31670. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  31671. // wxcardvisitOption allows management of the mutation configuration using functional options.
  31672. type wxcardvisitOption func(*WxCardVisitMutation)
  31673. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  31674. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  31675. m := &WxCardVisitMutation{
  31676. config: c,
  31677. op: op,
  31678. typ: TypeWxCardVisit,
  31679. clearedFields: make(map[string]struct{}),
  31680. }
  31681. for _, opt := range opts {
  31682. opt(m)
  31683. }
  31684. return m
  31685. }
  31686. // withWxCardVisitID sets the ID field of the mutation.
  31687. func withWxCardVisitID(id uint64) wxcardvisitOption {
  31688. return func(m *WxCardVisitMutation) {
  31689. var (
  31690. err error
  31691. once sync.Once
  31692. value *WxCardVisit
  31693. )
  31694. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  31695. once.Do(func() {
  31696. if m.done {
  31697. err = errors.New("querying old values post mutation is not allowed")
  31698. } else {
  31699. value, err = m.Client().WxCardVisit.Get(ctx, id)
  31700. }
  31701. })
  31702. return value, err
  31703. }
  31704. m.id = &id
  31705. }
  31706. }
  31707. // withWxCardVisit sets the old WxCardVisit of the mutation.
  31708. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  31709. return func(m *WxCardVisitMutation) {
  31710. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  31711. return node, nil
  31712. }
  31713. m.id = &node.ID
  31714. }
  31715. }
  31716. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31717. // executed in a transaction (ent.Tx), a transactional client is returned.
  31718. func (m WxCardVisitMutation) Client() *Client {
  31719. client := &Client{config: m.config}
  31720. client.init()
  31721. return client
  31722. }
  31723. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31724. // it returns an error otherwise.
  31725. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  31726. if _, ok := m.driver.(*txDriver); !ok {
  31727. return nil, errors.New("ent: mutation is not running in a transaction")
  31728. }
  31729. tx := &Tx{config: m.config}
  31730. tx.init()
  31731. return tx, nil
  31732. }
  31733. // SetID sets the value of the id field. Note that this
  31734. // operation is only accepted on creation of WxCardVisit entities.
  31735. func (m *WxCardVisitMutation) SetID(id uint64) {
  31736. m.id = &id
  31737. }
  31738. // ID returns the ID value in the mutation. Note that the ID is only available
  31739. // if it was provided to the builder or after it was returned from the database.
  31740. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  31741. if m.id == nil {
  31742. return
  31743. }
  31744. return *m.id, true
  31745. }
  31746. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31747. // That means, if the mutation is applied within a transaction with an isolation level such
  31748. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31749. // or updated by the mutation.
  31750. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  31751. switch {
  31752. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31753. id, exists := m.ID()
  31754. if exists {
  31755. return []uint64{id}, nil
  31756. }
  31757. fallthrough
  31758. case m.op.Is(OpUpdate | OpDelete):
  31759. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  31760. default:
  31761. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31762. }
  31763. }
  31764. // SetCreatedAt sets the "created_at" field.
  31765. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  31766. m.created_at = &t
  31767. }
  31768. // CreatedAt returns the value of the "created_at" field in the mutation.
  31769. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  31770. v := m.created_at
  31771. if v == nil {
  31772. return
  31773. }
  31774. return *v, true
  31775. }
  31776. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  31777. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31779. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31780. if !m.op.Is(OpUpdateOne) {
  31781. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31782. }
  31783. if m.id == nil || m.oldValue == nil {
  31784. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31785. }
  31786. oldValue, err := m.oldValue(ctx)
  31787. if err != nil {
  31788. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31789. }
  31790. return oldValue.CreatedAt, nil
  31791. }
  31792. // ResetCreatedAt resets all changes to the "created_at" field.
  31793. func (m *WxCardVisitMutation) ResetCreatedAt() {
  31794. m.created_at = nil
  31795. }
  31796. // SetUpdatedAt sets the "updated_at" field.
  31797. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  31798. m.updated_at = &t
  31799. }
  31800. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31801. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  31802. v := m.updated_at
  31803. if v == nil {
  31804. return
  31805. }
  31806. return *v, true
  31807. }
  31808. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  31809. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31811. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31812. if !m.op.Is(OpUpdateOne) {
  31813. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31814. }
  31815. if m.id == nil || m.oldValue == nil {
  31816. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31817. }
  31818. oldValue, err := m.oldValue(ctx)
  31819. if err != nil {
  31820. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31821. }
  31822. return oldValue.UpdatedAt, nil
  31823. }
  31824. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31825. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  31826. m.updated_at = nil
  31827. }
  31828. // SetDeletedAt sets the "deleted_at" field.
  31829. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  31830. m.deleted_at = &t
  31831. }
  31832. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31833. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  31834. v := m.deleted_at
  31835. if v == nil {
  31836. return
  31837. }
  31838. return *v, true
  31839. }
  31840. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  31841. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31843. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31844. if !m.op.Is(OpUpdateOne) {
  31845. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31846. }
  31847. if m.id == nil || m.oldValue == nil {
  31848. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31849. }
  31850. oldValue, err := m.oldValue(ctx)
  31851. if err != nil {
  31852. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31853. }
  31854. return oldValue.DeletedAt, nil
  31855. }
  31856. // ClearDeletedAt clears the value of the "deleted_at" field.
  31857. func (m *WxCardVisitMutation) ClearDeletedAt() {
  31858. m.deleted_at = nil
  31859. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  31860. }
  31861. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31862. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  31863. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  31864. return ok
  31865. }
  31866. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31867. func (m *WxCardVisitMutation) ResetDeletedAt() {
  31868. m.deleted_at = nil
  31869. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  31870. }
  31871. // SetUserID sets the "user_id" field.
  31872. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  31873. m.user_id = &u
  31874. m.adduser_id = nil
  31875. }
  31876. // UserID returns the value of the "user_id" field in the mutation.
  31877. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  31878. v := m.user_id
  31879. if v == nil {
  31880. return
  31881. }
  31882. return *v, true
  31883. }
  31884. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  31885. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31887. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  31888. if !m.op.Is(OpUpdateOne) {
  31889. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  31890. }
  31891. if m.id == nil || m.oldValue == nil {
  31892. return v, errors.New("OldUserID requires an ID field in the mutation")
  31893. }
  31894. oldValue, err := m.oldValue(ctx)
  31895. if err != nil {
  31896. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  31897. }
  31898. return oldValue.UserID, nil
  31899. }
  31900. // AddUserID adds u to the "user_id" field.
  31901. func (m *WxCardVisitMutation) AddUserID(u int64) {
  31902. if m.adduser_id != nil {
  31903. *m.adduser_id += u
  31904. } else {
  31905. m.adduser_id = &u
  31906. }
  31907. }
  31908. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  31909. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  31910. v := m.adduser_id
  31911. if v == nil {
  31912. return
  31913. }
  31914. return *v, true
  31915. }
  31916. // ClearUserID clears the value of the "user_id" field.
  31917. func (m *WxCardVisitMutation) ClearUserID() {
  31918. m.user_id = nil
  31919. m.adduser_id = nil
  31920. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  31921. }
  31922. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  31923. func (m *WxCardVisitMutation) UserIDCleared() bool {
  31924. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  31925. return ok
  31926. }
  31927. // ResetUserID resets all changes to the "user_id" field.
  31928. func (m *WxCardVisitMutation) ResetUserID() {
  31929. m.user_id = nil
  31930. m.adduser_id = nil
  31931. delete(m.clearedFields, wxcardvisit.FieldUserID)
  31932. }
  31933. // SetBotID sets the "bot_id" field.
  31934. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  31935. m.bot_id = &u
  31936. m.addbot_id = nil
  31937. }
  31938. // BotID returns the value of the "bot_id" field in the mutation.
  31939. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  31940. v := m.bot_id
  31941. if v == nil {
  31942. return
  31943. }
  31944. return *v, true
  31945. }
  31946. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  31947. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31949. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  31950. if !m.op.Is(OpUpdateOne) {
  31951. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31952. }
  31953. if m.id == nil || m.oldValue == nil {
  31954. return v, errors.New("OldBotID requires an ID field in the mutation")
  31955. }
  31956. oldValue, err := m.oldValue(ctx)
  31957. if err != nil {
  31958. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31959. }
  31960. return oldValue.BotID, nil
  31961. }
  31962. // AddBotID adds u to the "bot_id" field.
  31963. func (m *WxCardVisitMutation) AddBotID(u int64) {
  31964. if m.addbot_id != nil {
  31965. *m.addbot_id += u
  31966. } else {
  31967. m.addbot_id = &u
  31968. }
  31969. }
  31970. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  31971. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  31972. v := m.addbot_id
  31973. if v == nil {
  31974. return
  31975. }
  31976. return *v, true
  31977. }
  31978. // ResetBotID resets all changes to the "bot_id" field.
  31979. func (m *WxCardVisitMutation) ResetBotID() {
  31980. m.bot_id = nil
  31981. m.addbot_id = nil
  31982. }
  31983. // SetBotType sets the "bot_type" field.
  31984. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  31985. m.bot_type = &u
  31986. m.addbot_type = nil
  31987. }
  31988. // BotType returns the value of the "bot_type" field in the mutation.
  31989. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  31990. v := m.bot_type
  31991. if v == nil {
  31992. return
  31993. }
  31994. return *v, true
  31995. }
  31996. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  31997. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31999. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  32000. if !m.op.Is(OpUpdateOne) {
  32001. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  32002. }
  32003. if m.id == nil || m.oldValue == nil {
  32004. return v, errors.New("OldBotType requires an ID field in the mutation")
  32005. }
  32006. oldValue, err := m.oldValue(ctx)
  32007. if err != nil {
  32008. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  32009. }
  32010. return oldValue.BotType, nil
  32011. }
  32012. // AddBotType adds u to the "bot_type" field.
  32013. func (m *WxCardVisitMutation) AddBotType(u int8) {
  32014. if m.addbot_type != nil {
  32015. *m.addbot_type += u
  32016. } else {
  32017. m.addbot_type = &u
  32018. }
  32019. }
  32020. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  32021. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  32022. v := m.addbot_type
  32023. if v == nil {
  32024. return
  32025. }
  32026. return *v, true
  32027. }
  32028. // ResetBotType resets all changes to the "bot_type" field.
  32029. func (m *WxCardVisitMutation) ResetBotType() {
  32030. m.bot_type = nil
  32031. m.addbot_type = nil
  32032. }
  32033. // Where appends a list predicates to the WxCardVisitMutation builder.
  32034. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  32035. m.predicates = append(m.predicates, ps...)
  32036. }
  32037. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  32038. // users can use type-assertion to append predicates that do not depend on any generated package.
  32039. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  32040. p := make([]predicate.WxCardVisit, len(ps))
  32041. for i := range ps {
  32042. p[i] = ps[i]
  32043. }
  32044. m.Where(p...)
  32045. }
  32046. // Op returns the operation name.
  32047. func (m *WxCardVisitMutation) Op() Op {
  32048. return m.op
  32049. }
  32050. // SetOp allows setting the mutation operation.
  32051. func (m *WxCardVisitMutation) SetOp(op Op) {
  32052. m.op = op
  32053. }
  32054. // Type returns the node type of this mutation (WxCardVisit).
  32055. func (m *WxCardVisitMutation) Type() string {
  32056. return m.typ
  32057. }
  32058. // Fields returns all fields that were changed during this mutation. Note that in
  32059. // order to get all numeric fields that were incremented/decremented, call
  32060. // AddedFields().
  32061. func (m *WxCardVisitMutation) Fields() []string {
  32062. fields := make([]string, 0, 6)
  32063. if m.created_at != nil {
  32064. fields = append(fields, wxcardvisit.FieldCreatedAt)
  32065. }
  32066. if m.updated_at != nil {
  32067. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  32068. }
  32069. if m.deleted_at != nil {
  32070. fields = append(fields, wxcardvisit.FieldDeletedAt)
  32071. }
  32072. if m.user_id != nil {
  32073. fields = append(fields, wxcardvisit.FieldUserID)
  32074. }
  32075. if m.bot_id != nil {
  32076. fields = append(fields, wxcardvisit.FieldBotID)
  32077. }
  32078. if m.bot_type != nil {
  32079. fields = append(fields, wxcardvisit.FieldBotType)
  32080. }
  32081. return fields
  32082. }
  32083. // Field returns the value of a field with the given name. The second boolean
  32084. // return value indicates that this field was not set, or was not defined in the
  32085. // schema.
  32086. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  32087. switch name {
  32088. case wxcardvisit.FieldCreatedAt:
  32089. return m.CreatedAt()
  32090. case wxcardvisit.FieldUpdatedAt:
  32091. return m.UpdatedAt()
  32092. case wxcardvisit.FieldDeletedAt:
  32093. return m.DeletedAt()
  32094. case wxcardvisit.FieldUserID:
  32095. return m.UserID()
  32096. case wxcardvisit.FieldBotID:
  32097. return m.BotID()
  32098. case wxcardvisit.FieldBotType:
  32099. return m.BotType()
  32100. }
  32101. return nil, false
  32102. }
  32103. // OldField returns the old value of the field from the database. An error is
  32104. // returned if the mutation operation is not UpdateOne, or the query to the
  32105. // database failed.
  32106. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32107. switch name {
  32108. case wxcardvisit.FieldCreatedAt:
  32109. return m.OldCreatedAt(ctx)
  32110. case wxcardvisit.FieldUpdatedAt:
  32111. return m.OldUpdatedAt(ctx)
  32112. case wxcardvisit.FieldDeletedAt:
  32113. return m.OldDeletedAt(ctx)
  32114. case wxcardvisit.FieldUserID:
  32115. return m.OldUserID(ctx)
  32116. case wxcardvisit.FieldBotID:
  32117. return m.OldBotID(ctx)
  32118. case wxcardvisit.FieldBotType:
  32119. return m.OldBotType(ctx)
  32120. }
  32121. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  32122. }
  32123. // SetField sets the value of a field with the given name. It returns an error if
  32124. // the field is not defined in the schema, or if the type mismatched the field
  32125. // type.
  32126. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  32127. switch name {
  32128. case wxcardvisit.FieldCreatedAt:
  32129. v, ok := value.(time.Time)
  32130. if !ok {
  32131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32132. }
  32133. m.SetCreatedAt(v)
  32134. return nil
  32135. case wxcardvisit.FieldUpdatedAt:
  32136. v, ok := value.(time.Time)
  32137. if !ok {
  32138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32139. }
  32140. m.SetUpdatedAt(v)
  32141. return nil
  32142. case wxcardvisit.FieldDeletedAt:
  32143. v, ok := value.(time.Time)
  32144. if !ok {
  32145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32146. }
  32147. m.SetDeletedAt(v)
  32148. return nil
  32149. case wxcardvisit.FieldUserID:
  32150. v, ok := value.(uint64)
  32151. if !ok {
  32152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32153. }
  32154. m.SetUserID(v)
  32155. return nil
  32156. case wxcardvisit.FieldBotID:
  32157. v, ok := value.(uint64)
  32158. if !ok {
  32159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32160. }
  32161. m.SetBotID(v)
  32162. return nil
  32163. case wxcardvisit.FieldBotType:
  32164. v, ok := value.(uint8)
  32165. if !ok {
  32166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32167. }
  32168. m.SetBotType(v)
  32169. return nil
  32170. }
  32171. return fmt.Errorf("unknown WxCardVisit field %s", name)
  32172. }
  32173. // AddedFields returns all numeric fields that were incremented/decremented during
  32174. // this mutation.
  32175. func (m *WxCardVisitMutation) AddedFields() []string {
  32176. var fields []string
  32177. if m.adduser_id != nil {
  32178. fields = append(fields, wxcardvisit.FieldUserID)
  32179. }
  32180. if m.addbot_id != nil {
  32181. fields = append(fields, wxcardvisit.FieldBotID)
  32182. }
  32183. if m.addbot_type != nil {
  32184. fields = append(fields, wxcardvisit.FieldBotType)
  32185. }
  32186. return fields
  32187. }
  32188. // AddedField returns the numeric value that was incremented/decremented on a field
  32189. // with the given name. The second boolean return value indicates that this field
  32190. // was not set, or was not defined in the schema.
  32191. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  32192. switch name {
  32193. case wxcardvisit.FieldUserID:
  32194. return m.AddedUserID()
  32195. case wxcardvisit.FieldBotID:
  32196. return m.AddedBotID()
  32197. case wxcardvisit.FieldBotType:
  32198. return m.AddedBotType()
  32199. }
  32200. return nil, false
  32201. }
  32202. // AddField adds the value to the field with the given name. It returns an error if
  32203. // the field is not defined in the schema, or if the type mismatched the field
  32204. // type.
  32205. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  32206. switch name {
  32207. case wxcardvisit.FieldUserID:
  32208. v, ok := value.(int64)
  32209. if !ok {
  32210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32211. }
  32212. m.AddUserID(v)
  32213. return nil
  32214. case wxcardvisit.FieldBotID:
  32215. v, ok := value.(int64)
  32216. if !ok {
  32217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32218. }
  32219. m.AddBotID(v)
  32220. return nil
  32221. case wxcardvisit.FieldBotType:
  32222. v, ok := value.(int8)
  32223. if !ok {
  32224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32225. }
  32226. m.AddBotType(v)
  32227. return nil
  32228. }
  32229. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  32230. }
  32231. // ClearedFields returns all nullable fields that were cleared during this
  32232. // mutation.
  32233. func (m *WxCardVisitMutation) ClearedFields() []string {
  32234. var fields []string
  32235. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  32236. fields = append(fields, wxcardvisit.FieldDeletedAt)
  32237. }
  32238. if m.FieldCleared(wxcardvisit.FieldUserID) {
  32239. fields = append(fields, wxcardvisit.FieldUserID)
  32240. }
  32241. return fields
  32242. }
  32243. // FieldCleared returns a boolean indicating if a field with the given name was
  32244. // cleared in this mutation.
  32245. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  32246. _, ok := m.clearedFields[name]
  32247. return ok
  32248. }
  32249. // ClearField clears the value of the field with the given name. It returns an
  32250. // error if the field is not defined in the schema.
  32251. func (m *WxCardVisitMutation) ClearField(name string) error {
  32252. switch name {
  32253. case wxcardvisit.FieldDeletedAt:
  32254. m.ClearDeletedAt()
  32255. return nil
  32256. case wxcardvisit.FieldUserID:
  32257. m.ClearUserID()
  32258. return nil
  32259. }
  32260. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  32261. }
  32262. // ResetField resets all changes in the mutation for the field with the given name.
  32263. // It returns an error if the field is not defined in the schema.
  32264. func (m *WxCardVisitMutation) ResetField(name string) error {
  32265. switch name {
  32266. case wxcardvisit.FieldCreatedAt:
  32267. m.ResetCreatedAt()
  32268. return nil
  32269. case wxcardvisit.FieldUpdatedAt:
  32270. m.ResetUpdatedAt()
  32271. return nil
  32272. case wxcardvisit.FieldDeletedAt:
  32273. m.ResetDeletedAt()
  32274. return nil
  32275. case wxcardvisit.FieldUserID:
  32276. m.ResetUserID()
  32277. return nil
  32278. case wxcardvisit.FieldBotID:
  32279. m.ResetBotID()
  32280. return nil
  32281. case wxcardvisit.FieldBotType:
  32282. m.ResetBotType()
  32283. return nil
  32284. }
  32285. return fmt.Errorf("unknown WxCardVisit field %s", name)
  32286. }
  32287. // AddedEdges returns all edge names that were set/added in this mutation.
  32288. func (m *WxCardVisitMutation) AddedEdges() []string {
  32289. edges := make([]string, 0, 0)
  32290. return edges
  32291. }
  32292. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32293. // name in this mutation.
  32294. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  32295. return nil
  32296. }
  32297. // RemovedEdges returns all edge names that were removed in this mutation.
  32298. func (m *WxCardVisitMutation) RemovedEdges() []string {
  32299. edges := make([]string, 0, 0)
  32300. return edges
  32301. }
  32302. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32303. // the given name in this mutation.
  32304. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  32305. return nil
  32306. }
  32307. // ClearedEdges returns all edge names that were cleared in this mutation.
  32308. func (m *WxCardVisitMutation) ClearedEdges() []string {
  32309. edges := make([]string, 0, 0)
  32310. return edges
  32311. }
  32312. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32313. // was cleared in this mutation.
  32314. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  32315. return false
  32316. }
  32317. // ClearEdge clears the value of the edge with the given name. It returns an error
  32318. // if that edge is not defined in the schema.
  32319. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  32320. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  32321. }
  32322. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32323. // It returns an error if the edge is not defined in the schema.
  32324. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  32325. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  32326. }