mutation.go 1.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504
  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. appendconditions []string
  12793. action_label_add *[]uint64
  12794. appendaction_label_add []uint64
  12795. action_label_del *[]uint64
  12796. appendaction_label_del []uint64
  12797. clearedFields map[string]struct{}
  12798. done bool
  12799. oldValue func(context.Context) (*LabelTagging, error)
  12800. predicates []predicate.LabelTagging
  12801. }
  12802. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  12803. // labeltaggingOption allows management of the mutation configuration using functional options.
  12804. type labeltaggingOption func(*LabelTaggingMutation)
  12805. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  12806. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  12807. m := &LabelTaggingMutation{
  12808. config: c,
  12809. op: op,
  12810. typ: TypeLabelTagging,
  12811. clearedFields: make(map[string]struct{}),
  12812. }
  12813. for _, opt := range opts {
  12814. opt(m)
  12815. }
  12816. return m
  12817. }
  12818. // withLabelTaggingID sets the ID field of the mutation.
  12819. func withLabelTaggingID(id uint64) labeltaggingOption {
  12820. return func(m *LabelTaggingMutation) {
  12821. var (
  12822. err error
  12823. once sync.Once
  12824. value *LabelTagging
  12825. )
  12826. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  12827. once.Do(func() {
  12828. if m.done {
  12829. err = errors.New("querying old values post mutation is not allowed")
  12830. } else {
  12831. value, err = m.Client().LabelTagging.Get(ctx, id)
  12832. }
  12833. })
  12834. return value, err
  12835. }
  12836. m.id = &id
  12837. }
  12838. }
  12839. // withLabelTagging sets the old LabelTagging of the mutation.
  12840. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  12841. return func(m *LabelTaggingMutation) {
  12842. m.oldValue = func(context.Context) (*LabelTagging, error) {
  12843. return node, nil
  12844. }
  12845. m.id = &node.ID
  12846. }
  12847. }
  12848. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12849. // executed in a transaction (ent.Tx), a transactional client is returned.
  12850. func (m LabelTaggingMutation) Client() *Client {
  12851. client := &Client{config: m.config}
  12852. client.init()
  12853. return client
  12854. }
  12855. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12856. // it returns an error otherwise.
  12857. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  12858. if _, ok := m.driver.(*txDriver); !ok {
  12859. return nil, errors.New("ent: mutation is not running in a transaction")
  12860. }
  12861. tx := &Tx{config: m.config}
  12862. tx.init()
  12863. return tx, nil
  12864. }
  12865. // SetID sets the value of the id field. Note that this
  12866. // operation is only accepted on creation of LabelTagging entities.
  12867. func (m *LabelTaggingMutation) SetID(id uint64) {
  12868. m.id = &id
  12869. }
  12870. // ID returns the ID value in the mutation. Note that the ID is only available
  12871. // if it was provided to the builder or after it was returned from the database.
  12872. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  12873. if m.id == nil {
  12874. return
  12875. }
  12876. return *m.id, true
  12877. }
  12878. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12879. // That means, if the mutation is applied within a transaction with an isolation level such
  12880. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12881. // or updated by the mutation.
  12882. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  12883. switch {
  12884. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12885. id, exists := m.ID()
  12886. if exists {
  12887. return []uint64{id}, nil
  12888. }
  12889. fallthrough
  12890. case m.op.Is(OpUpdate | OpDelete):
  12891. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  12892. default:
  12893. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12894. }
  12895. }
  12896. // SetCreatedAt sets the "created_at" field.
  12897. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  12898. m.created_at = &t
  12899. }
  12900. // CreatedAt returns the value of the "created_at" field in the mutation.
  12901. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  12902. v := m.created_at
  12903. if v == nil {
  12904. return
  12905. }
  12906. return *v, true
  12907. }
  12908. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  12909. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  12910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12911. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12912. if !m.op.Is(OpUpdateOne) {
  12913. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12914. }
  12915. if m.id == nil || m.oldValue == nil {
  12916. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12917. }
  12918. oldValue, err := m.oldValue(ctx)
  12919. if err != nil {
  12920. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12921. }
  12922. return oldValue.CreatedAt, nil
  12923. }
  12924. // ResetCreatedAt resets all changes to the "created_at" field.
  12925. func (m *LabelTaggingMutation) ResetCreatedAt() {
  12926. m.created_at = nil
  12927. }
  12928. // SetUpdatedAt sets the "updated_at" field.
  12929. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  12930. m.updated_at = &t
  12931. }
  12932. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12933. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  12934. v := m.updated_at
  12935. if v == nil {
  12936. return
  12937. }
  12938. return *v, true
  12939. }
  12940. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  12941. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  12942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12943. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12944. if !m.op.Is(OpUpdateOne) {
  12945. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12946. }
  12947. if m.id == nil || m.oldValue == nil {
  12948. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12949. }
  12950. oldValue, err := m.oldValue(ctx)
  12951. if err != nil {
  12952. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12953. }
  12954. return oldValue.UpdatedAt, nil
  12955. }
  12956. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12957. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  12958. m.updated_at = nil
  12959. }
  12960. // SetStatus sets the "status" field.
  12961. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  12962. m.status = &u
  12963. m.addstatus = nil
  12964. }
  12965. // Status returns the value of the "status" field in the mutation.
  12966. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  12967. v := m.status
  12968. if v == nil {
  12969. return
  12970. }
  12971. return *v, true
  12972. }
  12973. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  12974. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  12975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12976. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12977. if !m.op.Is(OpUpdateOne) {
  12978. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12979. }
  12980. if m.id == nil || m.oldValue == nil {
  12981. return v, errors.New("OldStatus requires an ID field in the mutation")
  12982. }
  12983. oldValue, err := m.oldValue(ctx)
  12984. if err != nil {
  12985. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12986. }
  12987. return oldValue.Status, nil
  12988. }
  12989. // AddStatus adds u to the "status" field.
  12990. func (m *LabelTaggingMutation) AddStatus(u int8) {
  12991. if m.addstatus != nil {
  12992. *m.addstatus += u
  12993. } else {
  12994. m.addstatus = &u
  12995. }
  12996. }
  12997. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12998. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  12999. v := m.addstatus
  13000. if v == nil {
  13001. return
  13002. }
  13003. return *v, true
  13004. }
  13005. // ClearStatus clears the value of the "status" field.
  13006. func (m *LabelTaggingMutation) ClearStatus() {
  13007. m.status = nil
  13008. m.addstatus = nil
  13009. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  13010. }
  13011. // StatusCleared returns if the "status" field was cleared in this mutation.
  13012. func (m *LabelTaggingMutation) StatusCleared() bool {
  13013. _, ok := m.clearedFields[labeltagging.FieldStatus]
  13014. return ok
  13015. }
  13016. // ResetStatus resets all changes to the "status" field.
  13017. func (m *LabelTaggingMutation) ResetStatus() {
  13018. m.status = nil
  13019. m.addstatus = nil
  13020. delete(m.clearedFields, labeltagging.FieldStatus)
  13021. }
  13022. // SetDeletedAt sets the "deleted_at" field.
  13023. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  13024. m.deleted_at = &t
  13025. }
  13026. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13027. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  13028. v := m.deleted_at
  13029. if v == nil {
  13030. return
  13031. }
  13032. return *v, true
  13033. }
  13034. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  13035. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13037. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13038. if !m.op.Is(OpUpdateOne) {
  13039. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13040. }
  13041. if m.id == nil || m.oldValue == nil {
  13042. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13043. }
  13044. oldValue, err := m.oldValue(ctx)
  13045. if err != nil {
  13046. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13047. }
  13048. return oldValue.DeletedAt, nil
  13049. }
  13050. // ClearDeletedAt clears the value of the "deleted_at" field.
  13051. func (m *LabelTaggingMutation) ClearDeletedAt() {
  13052. m.deleted_at = nil
  13053. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  13054. }
  13055. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13056. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  13057. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  13058. return ok
  13059. }
  13060. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13061. func (m *LabelTaggingMutation) ResetDeletedAt() {
  13062. m.deleted_at = nil
  13063. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  13064. }
  13065. // SetOrganizationID sets the "organization_id" field.
  13066. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  13067. m.organization_id = &u
  13068. m.addorganization_id = nil
  13069. }
  13070. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13071. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  13072. v := m.organization_id
  13073. if v == nil {
  13074. return
  13075. }
  13076. return *v, true
  13077. }
  13078. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  13079. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13081. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13082. if !m.op.Is(OpUpdateOne) {
  13083. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13084. }
  13085. if m.id == nil || m.oldValue == nil {
  13086. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13087. }
  13088. oldValue, err := m.oldValue(ctx)
  13089. if err != nil {
  13090. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13091. }
  13092. return oldValue.OrganizationID, nil
  13093. }
  13094. // AddOrganizationID adds u to the "organization_id" field.
  13095. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  13096. if m.addorganization_id != nil {
  13097. *m.addorganization_id += u
  13098. } else {
  13099. m.addorganization_id = &u
  13100. }
  13101. }
  13102. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13103. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  13104. v := m.addorganization_id
  13105. if v == nil {
  13106. return
  13107. }
  13108. return *v, true
  13109. }
  13110. // ClearOrganizationID clears the value of the "organization_id" field.
  13111. func (m *LabelTaggingMutation) ClearOrganizationID() {
  13112. m.organization_id = nil
  13113. m.addorganization_id = nil
  13114. m.clearedFields[labeltagging.FieldOrganizationID] = struct{}{}
  13115. }
  13116. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13117. func (m *LabelTaggingMutation) OrganizationIDCleared() bool {
  13118. _, ok := m.clearedFields[labeltagging.FieldOrganizationID]
  13119. return ok
  13120. }
  13121. // ResetOrganizationID resets all changes to the "organization_id" field.
  13122. func (m *LabelTaggingMutation) ResetOrganizationID() {
  13123. m.organization_id = nil
  13124. m.addorganization_id = nil
  13125. delete(m.clearedFields, labeltagging.FieldOrganizationID)
  13126. }
  13127. // SetType sets the "type" field.
  13128. func (m *LabelTaggingMutation) SetType(i int) {
  13129. m._type = &i
  13130. m.add_type = nil
  13131. }
  13132. // GetType returns the value of the "type" field in the mutation.
  13133. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  13134. v := m._type
  13135. if v == nil {
  13136. return
  13137. }
  13138. return *v, true
  13139. }
  13140. // OldType returns the old "type" field's value of the LabelTagging entity.
  13141. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13143. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  13144. if !m.op.Is(OpUpdateOne) {
  13145. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13146. }
  13147. if m.id == nil || m.oldValue == nil {
  13148. return v, errors.New("OldType requires an ID field in the mutation")
  13149. }
  13150. oldValue, err := m.oldValue(ctx)
  13151. if err != nil {
  13152. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13153. }
  13154. return oldValue.Type, nil
  13155. }
  13156. // AddType adds i to the "type" field.
  13157. func (m *LabelTaggingMutation) AddType(i int) {
  13158. if m.add_type != nil {
  13159. *m.add_type += i
  13160. } else {
  13161. m.add_type = &i
  13162. }
  13163. }
  13164. // AddedType returns the value that was added to the "type" field in this mutation.
  13165. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  13166. v := m.add_type
  13167. if v == nil {
  13168. return
  13169. }
  13170. return *v, true
  13171. }
  13172. // ResetType resets all changes to the "type" field.
  13173. func (m *LabelTaggingMutation) ResetType() {
  13174. m._type = nil
  13175. m.add_type = nil
  13176. }
  13177. // SetConditions sets the "conditions" field.
  13178. func (m *LabelTaggingMutation) SetConditions(s []string) {
  13179. m.conditions = &s
  13180. m.appendconditions = nil
  13181. }
  13182. // Conditions returns the value of the "conditions" field in the mutation.
  13183. func (m *LabelTaggingMutation) Conditions() (r []string, exists bool) {
  13184. v := m.conditions
  13185. if v == nil {
  13186. return
  13187. }
  13188. return *v, true
  13189. }
  13190. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  13191. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13193. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v []string, err error) {
  13194. if !m.op.Is(OpUpdateOne) {
  13195. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  13196. }
  13197. if m.id == nil || m.oldValue == nil {
  13198. return v, errors.New("OldConditions requires an ID field in the mutation")
  13199. }
  13200. oldValue, err := m.oldValue(ctx)
  13201. if err != nil {
  13202. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  13203. }
  13204. return oldValue.Conditions, nil
  13205. }
  13206. // AppendConditions adds s to the "conditions" field.
  13207. func (m *LabelTaggingMutation) AppendConditions(s []string) {
  13208. m.appendconditions = append(m.appendconditions, s...)
  13209. }
  13210. // AppendedConditions returns the list of values that were appended to the "conditions" field in this mutation.
  13211. func (m *LabelTaggingMutation) AppendedConditions() ([]string, bool) {
  13212. if len(m.appendconditions) == 0 {
  13213. return nil, false
  13214. }
  13215. return m.appendconditions, true
  13216. }
  13217. // ClearConditions clears the value of the "conditions" field.
  13218. func (m *LabelTaggingMutation) ClearConditions() {
  13219. m.conditions = nil
  13220. m.appendconditions = nil
  13221. m.clearedFields[labeltagging.FieldConditions] = struct{}{}
  13222. }
  13223. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  13224. func (m *LabelTaggingMutation) ConditionsCleared() bool {
  13225. _, ok := m.clearedFields[labeltagging.FieldConditions]
  13226. return ok
  13227. }
  13228. // ResetConditions resets all changes to the "conditions" field.
  13229. func (m *LabelTaggingMutation) ResetConditions() {
  13230. m.conditions = nil
  13231. m.appendconditions = nil
  13232. delete(m.clearedFields, labeltagging.FieldConditions)
  13233. }
  13234. // SetActionLabelAdd sets the "action_label_add" field.
  13235. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  13236. m.action_label_add = &u
  13237. m.appendaction_label_add = nil
  13238. }
  13239. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  13240. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  13241. v := m.action_label_add
  13242. if v == nil {
  13243. return
  13244. }
  13245. return *v, true
  13246. }
  13247. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  13248. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13250. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  13251. if !m.op.Is(OpUpdateOne) {
  13252. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  13253. }
  13254. if m.id == nil || m.oldValue == nil {
  13255. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  13256. }
  13257. oldValue, err := m.oldValue(ctx)
  13258. if err != nil {
  13259. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  13260. }
  13261. return oldValue.ActionLabelAdd, nil
  13262. }
  13263. // AppendActionLabelAdd adds u to the "action_label_add" field.
  13264. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  13265. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  13266. }
  13267. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  13268. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  13269. if len(m.appendaction_label_add) == 0 {
  13270. return nil, false
  13271. }
  13272. return m.appendaction_label_add, true
  13273. }
  13274. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  13275. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  13276. m.action_label_add = nil
  13277. m.appendaction_label_add = nil
  13278. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  13279. }
  13280. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  13281. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  13282. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  13283. return ok
  13284. }
  13285. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  13286. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  13287. m.action_label_add = nil
  13288. m.appendaction_label_add = nil
  13289. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  13290. }
  13291. // SetActionLabelDel sets the "action_label_del" field.
  13292. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  13293. m.action_label_del = &u
  13294. m.appendaction_label_del = nil
  13295. }
  13296. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  13297. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  13298. v := m.action_label_del
  13299. if v == nil {
  13300. return
  13301. }
  13302. return *v, true
  13303. }
  13304. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  13305. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13307. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  13308. if !m.op.Is(OpUpdateOne) {
  13309. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  13310. }
  13311. if m.id == nil || m.oldValue == nil {
  13312. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  13313. }
  13314. oldValue, err := m.oldValue(ctx)
  13315. if err != nil {
  13316. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  13317. }
  13318. return oldValue.ActionLabelDel, nil
  13319. }
  13320. // AppendActionLabelDel adds u to the "action_label_del" field.
  13321. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  13322. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  13323. }
  13324. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  13325. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  13326. if len(m.appendaction_label_del) == 0 {
  13327. return nil, false
  13328. }
  13329. return m.appendaction_label_del, true
  13330. }
  13331. // ClearActionLabelDel clears the value of the "action_label_del" field.
  13332. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  13333. m.action_label_del = nil
  13334. m.appendaction_label_del = nil
  13335. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  13336. }
  13337. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  13338. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  13339. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  13340. return ok
  13341. }
  13342. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  13343. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  13344. m.action_label_del = nil
  13345. m.appendaction_label_del = nil
  13346. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  13347. }
  13348. // Where appends a list predicates to the LabelTaggingMutation builder.
  13349. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  13350. m.predicates = append(m.predicates, ps...)
  13351. }
  13352. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  13353. // users can use type-assertion to append predicates that do not depend on any generated package.
  13354. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  13355. p := make([]predicate.LabelTagging, len(ps))
  13356. for i := range ps {
  13357. p[i] = ps[i]
  13358. }
  13359. m.Where(p...)
  13360. }
  13361. // Op returns the operation name.
  13362. func (m *LabelTaggingMutation) Op() Op {
  13363. return m.op
  13364. }
  13365. // SetOp allows setting the mutation operation.
  13366. func (m *LabelTaggingMutation) SetOp(op Op) {
  13367. m.op = op
  13368. }
  13369. // Type returns the node type of this mutation (LabelTagging).
  13370. func (m *LabelTaggingMutation) Type() string {
  13371. return m.typ
  13372. }
  13373. // Fields returns all fields that were changed during this mutation. Note that in
  13374. // order to get all numeric fields that were incremented/decremented, call
  13375. // AddedFields().
  13376. func (m *LabelTaggingMutation) Fields() []string {
  13377. fields := make([]string, 0, 9)
  13378. if m.created_at != nil {
  13379. fields = append(fields, labeltagging.FieldCreatedAt)
  13380. }
  13381. if m.updated_at != nil {
  13382. fields = append(fields, labeltagging.FieldUpdatedAt)
  13383. }
  13384. if m.status != nil {
  13385. fields = append(fields, labeltagging.FieldStatus)
  13386. }
  13387. if m.deleted_at != nil {
  13388. fields = append(fields, labeltagging.FieldDeletedAt)
  13389. }
  13390. if m.organization_id != nil {
  13391. fields = append(fields, labeltagging.FieldOrganizationID)
  13392. }
  13393. if m._type != nil {
  13394. fields = append(fields, labeltagging.FieldType)
  13395. }
  13396. if m.conditions != nil {
  13397. fields = append(fields, labeltagging.FieldConditions)
  13398. }
  13399. if m.action_label_add != nil {
  13400. fields = append(fields, labeltagging.FieldActionLabelAdd)
  13401. }
  13402. if m.action_label_del != nil {
  13403. fields = append(fields, labeltagging.FieldActionLabelDel)
  13404. }
  13405. return fields
  13406. }
  13407. // Field returns the value of a field with the given name. The second boolean
  13408. // return value indicates that this field was not set, or was not defined in the
  13409. // schema.
  13410. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  13411. switch name {
  13412. case labeltagging.FieldCreatedAt:
  13413. return m.CreatedAt()
  13414. case labeltagging.FieldUpdatedAt:
  13415. return m.UpdatedAt()
  13416. case labeltagging.FieldStatus:
  13417. return m.Status()
  13418. case labeltagging.FieldDeletedAt:
  13419. return m.DeletedAt()
  13420. case labeltagging.FieldOrganizationID:
  13421. return m.OrganizationID()
  13422. case labeltagging.FieldType:
  13423. return m.GetType()
  13424. case labeltagging.FieldConditions:
  13425. return m.Conditions()
  13426. case labeltagging.FieldActionLabelAdd:
  13427. return m.ActionLabelAdd()
  13428. case labeltagging.FieldActionLabelDel:
  13429. return m.ActionLabelDel()
  13430. }
  13431. return nil, false
  13432. }
  13433. // OldField returns the old value of the field from the database. An error is
  13434. // returned if the mutation operation is not UpdateOne, or the query to the
  13435. // database failed.
  13436. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13437. switch name {
  13438. case labeltagging.FieldCreatedAt:
  13439. return m.OldCreatedAt(ctx)
  13440. case labeltagging.FieldUpdatedAt:
  13441. return m.OldUpdatedAt(ctx)
  13442. case labeltagging.FieldStatus:
  13443. return m.OldStatus(ctx)
  13444. case labeltagging.FieldDeletedAt:
  13445. return m.OldDeletedAt(ctx)
  13446. case labeltagging.FieldOrganizationID:
  13447. return m.OldOrganizationID(ctx)
  13448. case labeltagging.FieldType:
  13449. return m.OldType(ctx)
  13450. case labeltagging.FieldConditions:
  13451. return m.OldConditions(ctx)
  13452. case labeltagging.FieldActionLabelAdd:
  13453. return m.OldActionLabelAdd(ctx)
  13454. case labeltagging.FieldActionLabelDel:
  13455. return m.OldActionLabelDel(ctx)
  13456. }
  13457. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  13458. }
  13459. // SetField sets the value of a field with the given name. It returns an error if
  13460. // the field is not defined in the schema, or if the type mismatched the field
  13461. // type.
  13462. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  13463. switch name {
  13464. case labeltagging.FieldCreatedAt:
  13465. v, ok := value.(time.Time)
  13466. if !ok {
  13467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13468. }
  13469. m.SetCreatedAt(v)
  13470. return nil
  13471. case labeltagging.FieldUpdatedAt:
  13472. v, ok := value.(time.Time)
  13473. if !ok {
  13474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13475. }
  13476. m.SetUpdatedAt(v)
  13477. return nil
  13478. case labeltagging.FieldStatus:
  13479. v, ok := value.(uint8)
  13480. if !ok {
  13481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13482. }
  13483. m.SetStatus(v)
  13484. return nil
  13485. case labeltagging.FieldDeletedAt:
  13486. v, ok := value.(time.Time)
  13487. if !ok {
  13488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13489. }
  13490. m.SetDeletedAt(v)
  13491. return nil
  13492. case labeltagging.FieldOrganizationID:
  13493. v, ok := value.(uint64)
  13494. if !ok {
  13495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13496. }
  13497. m.SetOrganizationID(v)
  13498. return nil
  13499. case labeltagging.FieldType:
  13500. v, ok := value.(int)
  13501. if !ok {
  13502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13503. }
  13504. m.SetType(v)
  13505. return nil
  13506. case labeltagging.FieldConditions:
  13507. v, ok := value.([]string)
  13508. if !ok {
  13509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13510. }
  13511. m.SetConditions(v)
  13512. return nil
  13513. case labeltagging.FieldActionLabelAdd:
  13514. v, ok := value.([]uint64)
  13515. if !ok {
  13516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13517. }
  13518. m.SetActionLabelAdd(v)
  13519. return nil
  13520. case labeltagging.FieldActionLabelDel:
  13521. v, ok := value.([]uint64)
  13522. if !ok {
  13523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13524. }
  13525. m.SetActionLabelDel(v)
  13526. return nil
  13527. }
  13528. return fmt.Errorf("unknown LabelTagging field %s", name)
  13529. }
  13530. // AddedFields returns all numeric fields that were incremented/decremented during
  13531. // this mutation.
  13532. func (m *LabelTaggingMutation) AddedFields() []string {
  13533. var fields []string
  13534. if m.addstatus != nil {
  13535. fields = append(fields, labeltagging.FieldStatus)
  13536. }
  13537. if m.addorganization_id != nil {
  13538. fields = append(fields, labeltagging.FieldOrganizationID)
  13539. }
  13540. if m.add_type != nil {
  13541. fields = append(fields, labeltagging.FieldType)
  13542. }
  13543. return fields
  13544. }
  13545. // AddedField returns the numeric value that was incremented/decremented on a field
  13546. // with the given name. The second boolean return value indicates that this field
  13547. // was not set, or was not defined in the schema.
  13548. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  13549. switch name {
  13550. case labeltagging.FieldStatus:
  13551. return m.AddedStatus()
  13552. case labeltagging.FieldOrganizationID:
  13553. return m.AddedOrganizationID()
  13554. case labeltagging.FieldType:
  13555. return m.AddedType()
  13556. }
  13557. return nil, false
  13558. }
  13559. // AddField adds the value to the field with the given name. It returns an error if
  13560. // the field is not defined in the schema, or if the type mismatched the field
  13561. // type.
  13562. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  13563. switch name {
  13564. case labeltagging.FieldStatus:
  13565. v, ok := value.(int8)
  13566. if !ok {
  13567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13568. }
  13569. m.AddStatus(v)
  13570. return nil
  13571. case labeltagging.FieldOrganizationID:
  13572. v, ok := value.(int64)
  13573. if !ok {
  13574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13575. }
  13576. m.AddOrganizationID(v)
  13577. return nil
  13578. case labeltagging.FieldType:
  13579. v, ok := value.(int)
  13580. if !ok {
  13581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13582. }
  13583. m.AddType(v)
  13584. return nil
  13585. }
  13586. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  13587. }
  13588. // ClearedFields returns all nullable fields that were cleared during this
  13589. // mutation.
  13590. func (m *LabelTaggingMutation) ClearedFields() []string {
  13591. var fields []string
  13592. if m.FieldCleared(labeltagging.FieldStatus) {
  13593. fields = append(fields, labeltagging.FieldStatus)
  13594. }
  13595. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  13596. fields = append(fields, labeltagging.FieldDeletedAt)
  13597. }
  13598. if m.FieldCleared(labeltagging.FieldOrganizationID) {
  13599. fields = append(fields, labeltagging.FieldOrganizationID)
  13600. }
  13601. if m.FieldCleared(labeltagging.FieldConditions) {
  13602. fields = append(fields, labeltagging.FieldConditions)
  13603. }
  13604. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  13605. fields = append(fields, labeltagging.FieldActionLabelAdd)
  13606. }
  13607. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  13608. fields = append(fields, labeltagging.FieldActionLabelDel)
  13609. }
  13610. return fields
  13611. }
  13612. // FieldCleared returns a boolean indicating if a field with the given name was
  13613. // cleared in this mutation.
  13614. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  13615. _, ok := m.clearedFields[name]
  13616. return ok
  13617. }
  13618. // ClearField clears the value of the field with the given name. It returns an
  13619. // error if the field is not defined in the schema.
  13620. func (m *LabelTaggingMutation) ClearField(name string) error {
  13621. switch name {
  13622. case labeltagging.FieldStatus:
  13623. m.ClearStatus()
  13624. return nil
  13625. case labeltagging.FieldDeletedAt:
  13626. m.ClearDeletedAt()
  13627. return nil
  13628. case labeltagging.FieldOrganizationID:
  13629. m.ClearOrganizationID()
  13630. return nil
  13631. case labeltagging.FieldConditions:
  13632. m.ClearConditions()
  13633. return nil
  13634. case labeltagging.FieldActionLabelAdd:
  13635. m.ClearActionLabelAdd()
  13636. return nil
  13637. case labeltagging.FieldActionLabelDel:
  13638. m.ClearActionLabelDel()
  13639. return nil
  13640. }
  13641. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  13642. }
  13643. // ResetField resets all changes in the mutation for the field with the given name.
  13644. // It returns an error if the field is not defined in the schema.
  13645. func (m *LabelTaggingMutation) ResetField(name string) error {
  13646. switch name {
  13647. case labeltagging.FieldCreatedAt:
  13648. m.ResetCreatedAt()
  13649. return nil
  13650. case labeltagging.FieldUpdatedAt:
  13651. m.ResetUpdatedAt()
  13652. return nil
  13653. case labeltagging.FieldStatus:
  13654. m.ResetStatus()
  13655. return nil
  13656. case labeltagging.FieldDeletedAt:
  13657. m.ResetDeletedAt()
  13658. return nil
  13659. case labeltagging.FieldOrganizationID:
  13660. m.ResetOrganizationID()
  13661. return nil
  13662. case labeltagging.FieldType:
  13663. m.ResetType()
  13664. return nil
  13665. case labeltagging.FieldConditions:
  13666. m.ResetConditions()
  13667. return nil
  13668. case labeltagging.FieldActionLabelAdd:
  13669. m.ResetActionLabelAdd()
  13670. return nil
  13671. case labeltagging.FieldActionLabelDel:
  13672. m.ResetActionLabelDel()
  13673. return nil
  13674. }
  13675. return fmt.Errorf("unknown LabelTagging field %s", name)
  13676. }
  13677. // AddedEdges returns all edge names that were set/added in this mutation.
  13678. func (m *LabelTaggingMutation) AddedEdges() []string {
  13679. edges := make([]string, 0, 0)
  13680. return edges
  13681. }
  13682. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13683. // name in this mutation.
  13684. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  13685. return nil
  13686. }
  13687. // RemovedEdges returns all edge names that were removed in this mutation.
  13688. func (m *LabelTaggingMutation) RemovedEdges() []string {
  13689. edges := make([]string, 0, 0)
  13690. return edges
  13691. }
  13692. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13693. // the given name in this mutation.
  13694. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  13695. return nil
  13696. }
  13697. // ClearedEdges returns all edge names that were cleared in this mutation.
  13698. func (m *LabelTaggingMutation) ClearedEdges() []string {
  13699. edges := make([]string, 0, 0)
  13700. return edges
  13701. }
  13702. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13703. // was cleared in this mutation.
  13704. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  13705. return false
  13706. }
  13707. // ClearEdge clears the value of the edge with the given name. It returns an error
  13708. // if that edge is not defined in the schema.
  13709. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  13710. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  13711. }
  13712. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13713. // It returns an error if the edge is not defined in the schema.
  13714. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  13715. return fmt.Errorf("unknown LabelTagging edge %s", name)
  13716. }
  13717. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  13718. type MessageMutation struct {
  13719. config
  13720. op Op
  13721. typ string
  13722. id *int
  13723. wx_wxid *string
  13724. wxid *string
  13725. content *string
  13726. clearedFields map[string]struct{}
  13727. done bool
  13728. oldValue func(context.Context) (*Message, error)
  13729. predicates []predicate.Message
  13730. }
  13731. var _ ent.Mutation = (*MessageMutation)(nil)
  13732. // messageOption allows management of the mutation configuration using functional options.
  13733. type messageOption func(*MessageMutation)
  13734. // newMessageMutation creates new mutation for the Message entity.
  13735. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  13736. m := &MessageMutation{
  13737. config: c,
  13738. op: op,
  13739. typ: TypeMessage,
  13740. clearedFields: make(map[string]struct{}),
  13741. }
  13742. for _, opt := range opts {
  13743. opt(m)
  13744. }
  13745. return m
  13746. }
  13747. // withMessageID sets the ID field of the mutation.
  13748. func withMessageID(id int) messageOption {
  13749. return func(m *MessageMutation) {
  13750. var (
  13751. err error
  13752. once sync.Once
  13753. value *Message
  13754. )
  13755. m.oldValue = func(ctx context.Context) (*Message, error) {
  13756. once.Do(func() {
  13757. if m.done {
  13758. err = errors.New("querying old values post mutation is not allowed")
  13759. } else {
  13760. value, err = m.Client().Message.Get(ctx, id)
  13761. }
  13762. })
  13763. return value, err
  13764. }
  13765. m.id = &id
  13766. }
  13767. }
  13768. // withMessage sets the old Message of the mutation.
  13769. func withMessage(node *Message) messageOption {
  13770. return func(m *MessageMutation) {
  13771. m.oldValue = func(context.Context) (*Message, error) {
  13772. return node, nil
  13773. }
  13774. m.id = &node.ID
  13775. }
  13776. }
  13777. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13778. // executed in a transaction (ent.Tx), a transactional client is returned.
  13779. func (m MessageMutation) Client() *Client {
  13780. client := &Client{config: m.config}
  13781. client.init()
  13782. return client
  13783. }
  13784. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13785. // it returns an error otherwise.
  13786. func (m MessageMutation) Tx() (*Tx, error) {
  13787. if _, ok := m.driver.(*txDriver); !ok {
  13788. return nil, errors.New("ent: mutation is not running in a transaction")
  13789. }
  13790. tx := &Tx{config: m.config}
  13791. tx.init()
  13792. return tx, nil
  13793. }
  13794. // ID returns the ID value in the mutation. Note that the ID is only available
  13795. // if it was provided to the builder or after it was returned from the database.
  13796. func (m *MessageMutation) ID() (id int, exists bool) {
  13797. if m.id == nil {
  13798. return
  13799. }
  13800. return *m.id, true
  13801. }
  13802. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13803. // That means, if the mutation is applied within a transaction with an isolation level such
  13804. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13805. // or updated by the mutation.
  13806. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  13807. switch {
  13808. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13809. id, exists := m.ID()
  13810. if exists {
  13811. return []int{id}, nil
  13812. }
  13813. fallthrough
  13814. case m.op.Is(OpUpdate | OpDelete):
  13815. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  13816. default:
  13817. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13818. }
  13819. }
  13820. // SetWxWxid sets the "wx_wxid" field.
  13821. func (m *MessageMutation) SetWxWxid(s string) {
  13822. m.wx_wxid = &s
  13823. }
  13824. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  13825. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  13826. v := m.wx_wxid
  13827. if v == nil {
  13828. return
  13829. }
  13830. return *v, true
  13831. }
  13832. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  13833. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13835. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  13836. if !m.op.Is(OpUpdateOne) {
  13837. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  13838. }
  13839. if m.id == nil || m.oldValue == nil {
  13840. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  13841. }
  13842. oldValue, err := m.oldValue(ctx)
  13843. if err != nil {
  13844. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  13845. }
  13846. return oldValue.WxWxid, nil
  13847. }
  13848. // ClearWxWxid clears the value of the "wx_wxid" field.
  13849. func (m *MessageMutation) ClearWxWxid() {
  13850. m.wx_wxid = nil
  13851. m.clearedFields[message.FieldWxWxid] = struct{}{}
  13852. }
  13853. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  13854. func (m *MessageMutation) WxWxidCleared() bool {
  13855. _, ok := m.clearedFields[message.FieldWxWxid]
  13856. return ok
  13857. }
  13858. // ResetWxWxid resets all changes to the "wx_wxid" field.
  13859. func (m *MessageMutation) ResetWxWxid() {
  13860. m.wx_wxid = nil
  13861. delete(m.clearedFields, message.FieldWxWxid)
  13862. }
  13863. // SetWxid sets the "wxid" field.
  13864. func (m *MessageMutation) SetWxid(s string) {
  13865. m.wxid = &s
  13866. }
  13867. // Wxid returns the value of the "wxid" field in the mutation.
  13868. func (m *MessageMutation) Wxid() (r string, exists bool) {
  13869. v := m.wxid
  13870. if v == nil {
  13871. return
  13872. }
  13873. return *v, true
  13874. }
  13875. // OldWxid returns the old "wxid" field's value of the Message entity.
  13876. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13878. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  13879. if !m.op.Is(OpUpdateOne) {
  13880. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  13881. }
  13882. if m.id == nil || m.oldValue == nil {
  13883. return v, errors.New("OldWxid requires an ID field in the mutation")
  13884. }
  13885. oldValue, err := m.oldValue(ctx)
  13886. if err != nil {
  13887. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  13888. }
  13889. return oldValue.Wxid, nil
  13890. }
  13891. // ResetWxid resets all changes to the "wxid" field.
  13892. func (m *MessageMutation) ResetWxid() {
  13893. m.wxid = nil
  13894. }
  13895. // SetContent sets the "content" field.
  13896. func (m *MessageMutation) SetContent(s string) {
  13897. m.content = &s
  13898. }
  13899. // Content returns the value of the "content" field in the mutation.
  13900. func (m *MessageMutation) Content() (r string, exists bool) {
  13901. v := m.content
  13902. if v == nil {
  13903. return
  13904. }
  13905. return *v, true
  13906. }
  13907. // OldContent returns the old "content" field's value of the Message entity.
  13908. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13910. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  13911. if !m.op.Is(OpUpdateOne) {
  13912. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  13913. }
  13914. if m.id == nil || m.oldValue == nil {
  13915. return v, errors.New("OldContent requires an ID field in the mutation")
  13916. }
  13917. oldValue, err := m.oldValue(ctx)
  13918. if err != nil {
  13919. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  13920. }
  13921. return oldValue.Content, nil
  13922. }
  13923. // ResetContent resets all changes to the "content" field.
  13924. func (m *MessageMutation) ResetContent() {
  13925. m.content = nil
  13926. }
  13927. // Where appends a list predicates to the MessageMutation builder.
  13928. func (m *MessageMutation) Where(ps ...predicate.Message) {
  13929. m.predicates = append(m.predicates, ps...)
  13930. }
  13931. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  13932. // users can use type-assertion to append predicates that do not depend on any generated package.
  13933. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  13934. p := make([]predicate.Message, len(ps))
  13935. for i := range ps {
  13936. p[i] = ps[i]
  13937. }
  13938. m.Where(p...)
  13939. }
  13940. // Op returns the operation name.
  13941. func (m *MessageMutation) Op() Op {
  13942. return m.op
  13943. }
  13944. // SetOp allows setting the mutation operation.
  13945. func (m *MessageMutation) SetOp(op Op) {
  13946. m.op = op
  13947. }
  13948. // Type returns the node type of this mutation (Message).
  13949. func (m *MessageMutation) Type() string {
  13950. return m.typ
  13951. }
  13952. // Fields returns all fields that were changed during this mutation. Note that in
  13953. // order to get all numeric fields that were incremented/decremented, call
  13954. // AddedFields().
  13955. func (m *MessageMutation) Fields() []string {
  13956. fields := make([]string, 0, 3)
  13957. if m.wx_wxid != nil {
  13958. fields = append(fields, message.FieldWxWxid)
  13959. }
  13960. if m.wxid != nil {
  13961. fields = append(fields, message.FieldWxid)
  13962. }
  13963. if m.content != nil {
  13964. fields = append(fields, message.FieldContent)
  13965. }
  13966. return fields
  13967. }
  13968. // Field returns the value of a field with the given name. The second boolean
  13969. // return value indicates that this field was not set, or was not defined in the
  13970. // schema.
  13971. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  13972. switch name {
  13973. case message.FieldWxWxid:
  13974. return m.WxWxid()
  13975. case message.FieldWxid:
  13976. return m.Wxid()
  13977. case message.FieldContent:
  13978. return m.Content()
  13979. }
  13980. return nil, false
  13981. }
  13982. // OldField returns the old value of the field from the database. An error is
  13983. // returned if the mutation operation is not UpdateOne, or the query to the
  13984. // database failed.
  13985. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13986. switch name {
  13987. case message.FieldWxWxid:
  13988. return m.OldWxWxid(ctx)
  13989. case message.FieldWxid:
  13990. return m.OldWxid(ctx)
  13991. case message.FieldContent:
  13992. return m.OldContent(ctx)
  13993. }
  13994. return nil, fmt.Errorf("unknown Message field %s", name)
  13995. }
  13996. // SetField sets the value of a field with the given name. It returns an error if
  13997. // the field is not defined in the schema, or if the type mismatched the field
  13998. // type.
  13999. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  14000. switch name {
  14001. case message.FieldWxWxid:
  14002. v, ok := value.(string)
  14003. if !ok {
  14004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14005. }
  14006. m.SetWxWxid(v)
  14007. return nil
  14008. case message.FieldWxid:
  14009. v, ok := value.(string)
  14010. if !ok {
  14011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14012. }
  14013. m.SetWxid(v)
  14014. return nil
  14015. case message.FieldContent:
  14016. v, ok := value.(string)
  14017. if !ok {
  14018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14019. }
  14020. m.SetContent(v)
  14021. return nil
  14022. }
  14023. return fmt.Errorf("unknown Message field %s", name)
  14024. }
  14025. // AddedFields returns all numeric fields that were incremented/decremented during
  14026. // this mutation.
  14027. func (m *MessageMutation) AddedFields() []string {
  14028. return nil
  14029. }
  14030. // AddedField returns the numeric value that was incremented/decremented on a field
  14031. // with the given name. The second boolean return value indicates that this field
  14032. // was not set, or was not defined in the schema.
  14033. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  14034. return nil, false
  14035. }
  14036. // AddField adds the value to the field with the given name. It returns an error if
  14037. // the field is not defined in the schema, or if the type mismatched the field
  14038. // type.
  14039. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  14040. switch name {
  14041. }
  14042. return fmt.Errorf("unknown Message numeric field %s", name)
  14043. }
  14044. // ClearedFields returns all nullable fields that were cleared during this
  14045. // mutation.
  14046. func (m *MessageMutation) ClearedFields() []string {
  14047. var fields []string
  14048. if m.FieldCleared(message.FieldWxWxid) {
  14049. fields = append(fields, message.FieldWxWxid)
  14050. }
  14051. return fields
  14052. }
  14053. // FieldCleared returns a boolean indicating if a field with the given name was
  14054. // cleared in this mutation.
  14055. func (m *MessageMutation) FieldCleared(name string) bool {
  14056. _, ok := m.clearedFields[name]
  14057. return ok
  14058. }
  14059. // ClearField clears the value of the field with the given name. It returns an
  14060. // error if the field is not defined in the schema.
  14061. func (m *MessageMutation) ClearField(name string) error {
  14062. switch name {
  14063. case message.FieldWxWxid:
  14064. m.ClearWxWxid()
  14065. return nil
  14066. }
  14067. return fmt.Errorf("unknown Message nullable field %s", name)
  14068. }
  14069. // ResetField resets all changes in the mutation for the field with the given name.
  14070. // It returns an error if the field is not defined in the schema.
  14071. func (m *MessageMutation) ResetField(name string) error {
  14072. switch name {
  14073. case message.FieldWxWxid:
  14074. m.ResetWxWxid()
  14075. return nil
  14076. case message.FieldWxid:
  14077. m.ResetWxid()
  14078. return nil
  14079. case message.FieldContent:
  14080. m.ResetContent()
  14081. return nil
  14082. }
  14083. return fmt.Errorf("unknown Message field %s", name)
  14084. }
  14085. // AddedEdges returns all edge names that were set/added in this mutation.
  14086. func (m *MessageMutation) AddedEdges() []string {
  14087. edges := make([]string, 0, 0)
  14088. return edges
  14089. }
  14090. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14091. // name in this mutation.
  14092. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  14093. return nil
  14094. }
  14095. // RemovedEdges returns all edge names that were removed in this mutation.
  14096. func (m *MessageMutation) RemovedEdges() []string {
  14097. edges := make([]string, 0, 0)
  14098. return edges
  14099. }
  14100. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14101. // the given name in this mutation.
  14102. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  14103. return nil
  14104. }
  14105. // ClearedEdges returns all edge names that were cleared in this mutation.
  14106. func (m *MessageMutation) ClearedEdges() []string {
  14107. edges := make([]string, 0, 0)
  14108. return edges
  14109. }
  14110. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14111. // was cleared in this mutation.
  14112. func (m *MessageMutation) EdgeCleared(name string) bool {
  14113. return false
  14114. }
  14115. // ClearEdge clears the value of the edge with the given name. It returns an error
  14116. // if that edge is not defined in the schema.
  14117. func (m *MessageMutation) ClearEdge(name string) error {
  14118. return fmt.Errorf("unknown Message unique edge %s", name)
  14119. }
  14120. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14121. // It returns an error if the edge is not defined in the schema.
  14122. func (m *MessageMutation) ResetEdge(name string) error {
  14123. return fmt.Errorf("unknown Message edge %s", name)
  14124. }
  14125. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  14126. type MessageRecordsMutation struct {
  14127. config
  14128. op Op
  14129. typ string
  14130. id *uint64
  14131. created_at *time.Time
  14132. updated_at *time.Time
  14133. status *uint8
  14134. addstatus *int8
  14135. bot_wxid *string
  14136. contact_type *int
  14137. addcontact_type *int
  14138. contact_wxid *string
  14139. content_type *int
  14140. addcontent_type *int
  14141. content *string
  14142. meta *custom_types.Meta
  14143. error_detail *string
  14144. send_time *time.Time
  14145. source_type *int
  14146. addsource_type *int
  14147. organization_id *uint64
  14148. addorganization_id *int64
  14149. clearedFields map[string]struct{}
  14150. sop_stage *uint64
  14151. clearedsop_stage bool
  14152. sop_node *uint64
  14153. clearedsop_node bool
  14154. message_contact *uint64
  14155. clearedmessage_contact bool
  14156. done bool
  14157. oldValue func(context.Context) (*MessageRecords, error)
  14158. predicates []predicate.MessageRecords
  14159. }
  14160. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  14161. // messagerecordsOption allows management of the mutation configuration using functional options.
  14162. type messagerecordsOption func(*MessageRecordsMutation)
  14163. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  14164. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  14165. m := &MessageRecordsMutation{
  14166. config: c,
  14167. op: op,
  14168. typ: TypeMessageRecords,
  14169. clearedFields: make(map[string]struct{}),
  14170. }
  14171. for _, opt := range opts {
  14172. opt(m)
  14173. }
  14174. return m
  14175. }
  14176. // withMessageRecordsID sets the ID field of the mutation.
  14177. func withMessageRecordsID(id uint64) messagerecordsOption {
  14178. return func(m *MessageRecordsMutation) {
  14179. var (
  14180. err error
  14181. once sync.Once
  14182. value *MessageRecords
  14183. )
  14184. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  14185. once.Do(func() {
  14186. if m.done {
  14187. err = errors.New("querying old values post mutation is not allowed")
  14188. } else {
  14189. value, err = m.Client().MessageRecords.Get(ctx, id)
  14190. }
  14191. })
  14192. return value, err
  14193. }
  14194. m.id = &id
  14195. }
  14196. }
  14197. // withMessageRecords sets the old MessageRecords of the mutation.
  14198. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  14199. return func(m *MessageRecordsMutation) {
  14200. m.oldValue = func(context.Context) (*MessageRecords, error) {
  14201. return node, nil
  14202. }
  14203. m.id = &node.ID
  14204. }
  14205. }
  14206. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14207. // executed in a transaction (ent.Tx), a transactional client is returned.
  14208. func (m MessageRecordsMutation) Client() *Client {
  14209. client := &Client{config: m.config}
  14210. client.init()
  14211. return client
  14212. }
  14213. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14214. // it returns an error otherwise.
  14215. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  14216. if _, ok := m.driver.(*txDriver); !ok {
  14217. return nil, errors.New("ent: mutation is not running in a transaction")
  14218. }
  14219. tx := &Tx{config: m.config}
  14220. tx.init()
  14221. return tx, nil
  14222. }
  14223. // SetID sets the value of the id field. Note that this
  14224. // operation is only accepted on creation of MessageRecords entities.
  14225. func (m *MessageRecordsMutation) SetID(id uint64) {
  14226. m.id = &id
  14227. }
  14228. // ID returns the ID value in the mutation. Note that the ID is only available
  14229. // if it was provided to the builder or after it was returned from the database.
  14230. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  14231. if m.id == nil {
  14232. return
  14233. }
  14234. return *m.id, true
  14235. }
  14236. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14237. // That means, if the mutation is applied within a transaction with an isolation level such
  14238. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14239. // or updated by the mutation.
  14240. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  14241. switch {
  14242. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14243. id, exists := m.ID()
  14244. if exists {
  14245. return []uint64{id}, nil
  14246. }
  14247. fallthrough
  14248. case m.op.Is(OpUpdate | OpDelete):
  14249. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  14250. default:
  14251. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14252. }
  14253. }
  14254. // SetCreatedAt sets the "created_at" field.
  14255. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  14256. m.created_at = &t
  14257. }
  14258. // CreatedAt returns the value of the "created_at" field in the mutation.
  14259. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  14260. v := m.created_at
  14261. if v == nil {
  14262. return
  14263. }
  14264. return *v, true
  14265. }
  14266. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  14267. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14269. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14270. if !m.op.Is(OpUpdateOne) {
  14271. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14272. }
  14273. if m.id == nil || m.oldValue == nil {
  14274. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14275. }
  14276. oldValue, err := m.oldValue(ctx)
  14277. if err != nil {
  14278. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14279. }
  14280. return oldValue.CreatedAt, nil
  14281. }
  14282. // ResetCreatedAt resets all changes to the "created_at" field.
  14283. func (m *MessageRecordsMutation) ResetCreatedAt() {
  14284. m.created_at = nil
  14285. }
  14286. // SetUpdatedAt sets the "updated_at" field.
  14287. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  14288. m.updated_at = &t
  14289. }
  14290. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14291. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  14292. v := m.updated_at
  14293. if v == nil {
  14294. return
  14295. }
  14296. return *v, true
  14297. }
  14298. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  14299. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14301. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14302. if !m.op.Is(OpUpdateOne) {
  14303. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14304. }
  14305. if m.id == nil || m.oldValue == nil {
  14306. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14307. }
  14308. oldValue, err := m.oldValue(ctx)
  14309. if err != nil {
  14310. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14311. }
  14312. return oldValue.UpdatedAt, nil
  14313. }
  14314. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14315. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  14316. m.updated_at = nil
  14317. }
  14318. // SetStatus sets the "status" field.
  14319. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  14320. m.status = &u
  14321. m.addstatus = nil
  14322. }
  14323. // Status returns the value of the "status" field in the mutation.
  14324. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  14325. v := m.status
  14326. if v == nil {
  14327. return
  14328. }
  14329. return *v, true
  14330. }
  14331. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  14332. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14334. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14335. if !m.op.Is(OpUpdateOne) {
  14336. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14337. }
  14338. if m.id == nil || m.oldValue == nil {
  14339. return v, errors.New("OldStatus requires an ID field in the mutation")
  14340. }
  14341. oldValue, err := m.oldValue(ctx)
  14342. if err != nil {
  14343. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14344. }
  14345. return oldValue.Status, nil
  14346. }
  14347. // AddStatus adds u to the "status" field.
  14348. func (m *MessageRecordsMutation) AddStatus(u int8) {
  14349. if m.addstatus != nil {
  14350. *m.addstatus += u
  14351. } else {
  14352. m.addstatus = &u
  14353. }
  14354. }
  14355. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14356. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  14357. v := m.addstatus
  14358. if v == nil {
  14359. return
  14360. }
  14361. return *v, true
  14362. }
  14363. // ClearStatus clears the value of the "status" field.
  14364. func (m *MessageRecordsMutation) ClearStatus() {
  14365. m.status = nil
  14366. m.addstatus = nil
  14367. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  14368. }
  14369. // StatusCleared returns if the "status" field was cleared in this mutation.
  14370. func (m *MessageRecordsMutation) StatusCleared() bool {
  14371. _, ok := m.clearedFields[messagerecords.FieldStatus]
  14372. return ok
  14373. }
  14374. // ResetStatus resets all changes to the "status" field.
  14375. func (m *MessageRecordsMutation) ResetStatus() {
  14376. m.status = nil
  14377. m.addstatus = nil
  14378. delete(m.clearedFields, messagerecords.FieldStatus)
  14379. }
  14380. // SetBotWxid sets the "bot_wxid" field.
  14381. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  14382. m.bot_wxid = &s
  14383. }
  14384. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  14385. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  14386. v := m.bot_wxid
  14387. if v == nil {
  14388. return
  14389. }
  14390. return *v, true
  14391. }
  14392. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  14393. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14395. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  14396. if !m.op.Is(OpUpdateOne) {
  14397. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  14398. }
  14399. if m.id == nil || m.oldValue == nil {
  14400. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  14401. }
  14402. oldValue, err := m.oldValue(ctx)
  14403. if err != nil {
  14404. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  14405. }
  14406. return oldValue.BotWxid, nil
  14407. }
  14408. // ResetBotWxid resets all changes to the "bot_wxid" field.
  14409. func (m *MessageRecordsMutation) ResetBotWxid() {
  14410. m.bot_wxid = nil
  14411. }
  14412. // SetContactID sets the "contact_id" field.
  14413. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  14414. m.message_contact = &u
  14415. }
  14416. // ContactID returns the value of the "contact_id" field in the mutation.
  14417. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  14418. v := m.message_contact
  14419. if v == nil {
  14420. return
  14421. }
  14422. return *v, true
  14423. }
  14424. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  14425. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14427. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14428. if !m.op.Is(OpUpdateOne) {
  14429. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14430. }
  14431. if m.id == nil || m.oldValue == nil {
  14432. return v, errors.New("OldContactID requires an ID field in the mutation")
  14433. }
  14434. oldValue, err := m.oldValue(ctx)
  14435. if err != nil {
  14436. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14437. }
  14438. return oldValue.ContactID, nil
  14439. }
  14440. // ClearContactID clears the value of the "contact_id" field.
  14441. func (m *MessageRecordsMutation) ClearContactID() {
  14442. m.message_contact = nil
  14443. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  14444. }
  14445. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  14446. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  14447. _, ok := m.clearedFields[messagerecords.FieldContactID]
  14448. return ok
  14449. }
  14450. // ResetContactID resets all changes to the "contact_id" field.
  14451. func (m *MessageRecordsMutation) ResetContactID() {
  14452. m.message_contact = nil
  14453. delete(m.clearedFields, messagerecords.FieldContactID)
  14454. }
  14455. // SetContactType sets the "contact_type" field.
  14456. func (m *MessageRecordsMutation) SetContactType(i int) {
  14457. m.contact_type = &i
  14458. m.addcontact_type = nil
  14459. }
  14460. // ContactType returns the value of the "contact_type" field in the mutation.
  14461. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  14462. v := m.contact_type
  14463. if v == nil {
  14464. return
  14465. }
  14466. return *v, true
  14467. }
  14468. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  14469. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14471. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  14472. if !m.op.Is(OpUpdateOne) {
  14473. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  14474. }
  14475. if m.id == nil || m.oldValue == nil {
  14476. return v, errors.New("OldContactType requires an ID field in the mutation")
  14477. }
  14478. oldValue, err := m.oldValue(ctx)
  14479. if err != nil {
  14480. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  14481. }
  14482. return oldValue.ContactType, nil
  14483. }
  14484. // AddContactType adds i to the "contact_type" field.
  14485. func (m *MessageRecordsMutation) AddContactType(i int) {
  14486. if m.addcontact_type != nil {
  14487. *m.addcontact_type += i
  14488. } else {
  14489. m.addcontact_type = &i
  14490. }
  14491. }
  14492. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  14493. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  14494. v := m.addcontact_type
  14495. if v == nil {
  14496. return
  14497. }
  14498. return *v, true
  14499. }
  14500. // ResetContactType resets all changes to the "contact_type" field.
  14501. func (m *MessageRecordsMutation) ResetContactType() {
  14502. m.contact_type = nil
  14503. m.addcontact_type = nil
  14504. }
  14505. // SetContactWxid sets the "contact_wxid" field.
  14506. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  14507. m.contact_wxid = &s
  14508. }
  14509. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  14510. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  14511. v := m.contact_wxid
  14512. if v == nil {
  14513. return
  14514. }
  14515. return *v, true
  14516. }
  14517. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  14518. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14520. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  14521. if !m.op.Is(OpUpdateOne) {
  14522. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  14523. }
  14524. if m.id == nil || m.oldValue == nil {
  14525. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  14526. }
  14527. oldValue, err := m.oldValue(ctx)
  14528. if err != nil {
  14529. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  14530. }
  14531. return oldValue.ContactWxid, nil
  14532. }
  14533. // ResetContactWxid resets all changes to the "contact_wxid" field.
  14534. func (m *MessageRecordsMutation) ResetContactWxid() {
  14535. m.contact_wxid = nil
  14536. }
  14537. // SetContentType sets the "content_type" field.
  14538. func (m *MessageRecordsMutation) SetContentType(i int) {
  14539. m.content_type = &i
  14540. m.addcontent_type = nil
  14541. }
  14542. // ContentType returns the value of the "content_type" field in the mutation.
  14543. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  14544. v := m.content_type
  14545. if v == nil {
  14546. return
  14547. }
  14548. return *v, true
  14549. }
  14550. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  14551. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14553. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  14554. if !m.op.Is(OpUpdateOne) {
  14555. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  14556. }
  14557. if m.id == nil || m.oldValue == nil {
  14558. return v, errors.New("OldContentType requires an ID field in the mutation")
  14559. }
  14560. oldValue, err := m.oldValue(ctx)
  14561. if err != nil {
  14562. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  14563. }
  14564. return oldValue.ContentType, nil
  14565. }
  14566. // AddContentType adds i to the "content_type" field.
  14567. func (m *MessageRecordsMutation) AddContentType(i int) {
  14568. if m.addcontent_type != nil {
  14569. *m.addcontent_type += i
  14570. } else {
  14571. m.addcontent_type = &i
  14572. }
  14573. }
  14574. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  14575. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  14576. v := m.addcontent_type
  14577. if v == nil {
  14578. return
  14579. }
  14580. return *v, true
  14581. }
  14582. // ResetContentType resets all changes to the "content_type" field.
  14583. func (m *MessageRecordsMutation) ResetContentType() {
  14584. m.content_type = nil
  14585. m.addcontent_type = nil
  14586. }
  14587. // SetContent sets the "content" field.
  14588. func (m *MessageRecordsMutation) SetContent(s string) {
  14589. m.content = &s
  14590. }
  14591. // Content returns the value of the "content" field in the mutation.
  14592. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  14593. v := m.content
  14594. if v == nil {
  14595. return
  14596. }
  14597. return *v, true
  14598. }
  14599. // OldContent returns the old "content" field's value of the MessageRecords entity.
  14600. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14602. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  14603. if !m.op.Is(OpUpdateOne) {
  14604. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  14605. }
  14606. if m.id == nil || m.oldValue == nil {
  14607. return v, errors.New("OldContent requires an ID field in the mutation")
  14608. }
  14609. oldValue, err := m.oldValue(ctx)
  14610. if err != nil {
  14611. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  14612. }
  14613. return oldValue.Content, nil
  14614. }
  14615. // ResetContent resets all changes to the "content" field.
  14616. func (m *MessageRecordsMutation) ResetContent() {
  14617. m.content = nil
  14618. }
  14619. // SetMeta sets the "meta" field.
  14620. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  14621. m.meta = &ct
  14622. }
  14623. // Meta returns the value of the "meta" field in the mutation.
  14624. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  14625. v := m.meta
  14626. if v == nil {
  14627. return
  14628. }
  14629. return *v, true
  14630. }
  14631. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  14632. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14634. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  14635. if !m.op.Is(OpUpdateOne) {
  14636. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  14637. }
  14638. if m.id == nil || m.oldValue == nil {
  14639. return v, errors.New("OldMeta requires an ID field in the mutation")
  14640. }
  14641. oldValue, err := m.oldValue(ctx)
  14642. if err != nil {
  14643. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  14644. }
  14645. return oldValue.Meta, nil
  14646. }
  14647. // ClearMeta clears the value of the "meta" field.
  14648. func (m *MessageRecordsMutation) ClearMeta() {
  14649. m.meta = nil
  14650. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  14651. }
  14652. // MetaCleared returns if the "meta" field was cleared in this mutation.
  14653. func (m *MessageRecordsMutation) MetaCleared() bool {
  14654. _, ok := m.clearedFields[messagerecords.FieldMeta]
  14655. return ok
  14656. }
  14657. // ResetMeta resets all changes to the "meta" field.
  14658. func (m *MessageRecordsMutation) ResetMeta() {
  14659. m.meta = nil
  14660. delete(m.clearedFields, messagerecords.FieldMeta)
  14661. }
  14662. // SetErrorDetail sets the "error_detail" field.
  14663. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  14664. m.error_detail = &s
  14665. }
  14666. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  14667. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  14668. v := m.error_detail
  14669. if v == nil {
  14670. return
  14671. }
  14672. return *v, true
  14673. }
  14674. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  14675. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14677. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  14678. if !m.op.Is(OpUpdateOne) {
  14679. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  14680. }
  14681. if m.id == nil || m.oldValue == nil {
  14682. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  14683. }
  14684. oldValue, err := m.oldValue(ctx)
  14685. if err != nil {
  14686. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  14687. }
  14688. return oldValue.ErrorDetail, nil
  14689. }
  14690. // ResetErrorDetail resets all changes to the "error_detail" field.
  14691. func (m *MessageRecordsMutation) ResetErrorDetail() {
  14692. m.error_detail = nil
  14693. }
  14694. // SetSendTime sets the "send_time" field.
  14695. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  14696. m.send_time = &t
  14697. }
  14698. // SendTime returns the value of the "send_time" field in the mutation.
  14699. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  14700. v := m.send_time
  14701. if v == nil {
  14702. return
  14703. }
  14704. return *v, true
  14705. }
  14706. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  14707. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14709. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  14710. if !m.op.Is(OpUpdateOne) {
  14711. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  14712. }
  14713. if m.id == nil || m.oldValue == nil {
  14714. return v, errors.New("OldSendTime requires an ID field in the mutation")
  14715. }
  14716. oldValue, err := m.oldValue(ctx)
  14717. if err != nil {
  14718. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  14719. }
  14720. return oldValue.SendTime, nil
  14721. }
  14722. // ClearSendTime clears the value of the "send_time" field.
  14723. func (m *MessageRecordsMutation) ClearSendTime() {
  14724. m.send_time = nil
  14725. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  14726. }
  14727. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  14728. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  14729. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  14730. return ok
  14731. }
  14732. // ResetSendTime resets all changes to the "send_time" field.
  14733. func (m *MessageRecordsMutation) ResetSendTime() {
  14734. m.send_time = nil
  14735. delete(m.clearedFields, messagerecords.FieldSendTime)
  14736. }
  14737. // SetSourceType sets the "source_type" field.
  14738. func (m *MessageRecordsMutation) SetSourceType(i int) {
  14739. m.source_type = &i
  14740. m.addsource_type = nil
  14741. }
  14742. // SourceType returns the value of the "source_type" field in the mutation.
  14743. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  14744. v := m.source_type
  14745. if v == nil {
  14746. return
  14747. }
  14748. return *v, true
  14749. }
  14750. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  14751. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14753. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  14754. if !m.op.Is(OpUpdateOne) {
  14755. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  14756. }
  14757. if m.id == nil || m.oldValue == nil {
  14758. return v, errors.New("OldSourceType requires an ID field in the mutation")
  14759. }
  14760. oldValue, err := m.oldValue(ctx)
  14761. if err != nil {
  14762. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  14763. }
  14764. return oldValue.SourceType, nil
  14765. }
  14766. // AddSourceType adds i to the "source_type" field.
  14767. func (m *MessageRecordsMutation) AddSourceType(i int) {
  14768. if m.addsource_type != nil {
  14769. *m.addsource_type += i
  14770. } else {
  14771. m.addsource_type = &i
  14772. }
  14773. }
  14774. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  14775. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  14776. v := m.addsource_type
  14777. if v == nil {
  14778. return
  14779. }
  14780. return *v, true
  14781. }
  14782. // ResetSourceType resets all changes to the "source_type" field.
  14783. func (m *MessageRecordsMutation) ResetSourceType() {
  14784. m.source_type = nil
  14785. m.addsource_type = nil
  14786. }
  14787. // SetSourceID sets the "source_id" field.
  14788. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  14789. m.sop_stage = &u
  14790. }
  14791. // SourceID returns the value of the "source_id" field in the mutation.
  14792. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  14793. v := m.sop_stage
  14794. if v == nil {
  14795. return
  14796. }
  14797. return *v, true
  14798. }
  14799. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  14800. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14802. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  14803. if !m.op.Is(OpUpdateOne) {
  14804. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  14805. }
  14806. if m.id == nil || m.oldValue == nil {
  14807. return v, errors.New("OldSourceID requires an ID field in the mutation")
  14808. }
  14809. oldValue, err := m.oldValue(ctx)
  14810. if err != nil {
  14811. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  14812. }
  14813. return oldValue.SourceID, nil
  14814. }
  14815. // ClearSourceID clears the value of the "source_id" field.
  14816. func (m *MessageRecordsMutation) ClearSourceID() {
  14817. m.sop_stage = nil
  14818. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  14819. }
  14820. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  14821. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  14822. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  14823. return ok
  14824. }
  14825. // ResetSourceID resets all changes to the "source_id" field.
  14826. func (m *MessageRecordsMutation) ResetSourceID() {
  14827. m.sop_stage = nil
  14828. delete(m.clearedFields, messagerecords.FieldSourceID)
  14829. }
  14830. // SetSubSourceID sets the "sub_source_id" field.
  14831. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  14832. m.sop_node = &u
  14833. }
  14834. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  14835. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  14836. v := m.sop_node
  14837. if v == nil {
  14838. return
  14839. }
  14840. return *v, true
  14841. }
  14842. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  14843. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14845. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  14846. if !m.op.Is(OpUpdateOne) {
  14847. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  14848. }
  14849. if m.id == nil || m.oldValue == nil {
  14850. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  14851. }
  14852. oldValue, err := m.oldValue(ctx)
  14853. if err != nil {
  14854. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  14855. }
  14856. return oldValue.SubSourceID, nil
  14857. }
  14858. // ClearSubSourceID clears the value of the "sub_source_id" field.
  14859. func (m *MessageRecordsMutation) ClearSubSourceID() {
  14860. m.sop_node = nil
  14861. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  14862. }
  14863. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  14864. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  14865. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  14866. return ok
  14867. }
  14868. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  14869. func (m *MessageRecordsMutation) ResetSubSourceID() {
  14870. m.sop_node = nil
  14871. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  14872. }
  14873. // SetOrganizationID sets the "organization_id" field.
  14874. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  14875. m.organization_id = &u
  14876. m.addorganization_id = nil
  14877. }
  14878. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14879. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  14880. v := m.organization_id
  14881. if v == nil {
  14882. return
  14883. }
  14884. return *v, true
  14885. }
  14886. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  14887. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14889. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14890. if !m.op.Is(OpUpdateOne) {
  14891. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14892. }
  14893. if m.id == nil || m.oldValue == nil {
  14894. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14895. }
  14896. oldValue, err := m.oldValue(ctx)
  14897. if err != nil {
  14898. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14899. }
  14900. return oldValue.OrganizationID, nil
  14901. }
  14902. // AddOrganizationID adds u to the "organization_id" field.
  14903. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  14904. if m.addorganization_id != nil {
  14905. *m.addorganization_id += u
  14906. } else {
  14907. m.addorganization_id = &u
  14908. }
  14909. }
  14910. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14911. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  14912. v := m.addorganization_id
  14913. if v == nil {
  14914. return
  14915. }
  14916. return *v, true
  14917. }
  14918. // ClearOrganizationID clears the value of the "organization_id" field.
  14919. func (m *MessageRecordsMutation) ClearOrganizationID() {
  14920. m.organization_id = nil
  14921. m.addorganization_id = nil
  14922. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  14923. }
  14924. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14925. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  14926. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  14927. return ok
  14928. }
  14929. // ResetOrganizationID resets all changes to the "organization_id" field.
  14930. func (m *MessageRecordsMutation) ResetOrganizationID() {
  14931. m.organization_id = nil
  14932. m.addorganization_id = nil
  14933. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  14934. }
  14935. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  14936. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  14937. m.sop_stage = &id
  14938. }
  14939. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  14940. func (m *MessageRecordsMutation) ClearSopStage() {
  14941. m.clearedsop_stage = true
  14942. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  14943. }
  14944. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  14945. func (m *MessageRecordsMutation) SopStageCleared() bool {
  14946. return m.SourceIDCleared() || m.clearedsop_stage
  14947. }
  14948. // SopStageID returns the "sop_stage" edge ID in the mutation.
  14949. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  14950. if m.sop_stage != nil {
  14951. return *m.sop_stage, true
  14952. }
  14953. return
  14954. }
  14955. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  14956. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14957. // SopStageID instead. It exists only for internal usage by the builders.
  14958. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  14959. if id := m.sop_stage; id != nil {
  14960. ids = append(ids, *id)
  14961. }
  14962. return
  14963. }
  14964. // ResetSopStage resets all changes to the "sop_stage" edge.
  14965. func (m *MessageRecordsMutation) ResetSopStage() {
  14966. m.sop_stage = nil
  14967. m.clearedsop_stage = false
  14968. }
  14969. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  14970. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  14971. m.sop_node = &id
  14972. }
  14973. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  14974. func (m *MessageRecordsMutation) ClearSopNode() {
  14975. m.clearedsop_node = true
  14976. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  14977. }
  14978. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  14979. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  14980. return m.SubSourceIDCleared() || m.clearedsop_node
  14981. }
  14982. // SopNodeID returns the "sop_node" edge ID in the mutation.
  14983. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  14984. if m.sop_node != nil {
  14985. return *m.sop_node, true
  14986. }
  14987. return
  14988. }
  14989. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  14990. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14991. // SopNodeID instead. It exists only for internal usage by the builders.
  14992. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  14993. if id := m.sop_node; id != nil {
  14994. ids = append(ids, *id)
  14995. }
  14996. return
  14997. }
  14998. // ResetSopNode resets all changes to the "sop_node" edge.
  14999. func (m *MessageRecordsMutation) ResetSopNode() {
  15000. m.sop_node = nil
  15001. m.clearedsop_node = false
  15002. }
  15003. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  15004. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  15005. m.message_contact = &id
  15006. }
  15007. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  15008. func (m *MessageRecordsMutation) ClearMessageContact() {
  15009. m.clearedmessage_contact = true
  15010. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  15011. }
  15012. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  15013. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  15014. return m.ContactIDCleared() || m.clearedmessage_contact
  15015. }
  15016. // MessageContactID returns the "message_contact" edge ID in the mutation.
  15017. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  15018. if m.message_contact != nil {
  15019. return *m.message_contact, true
  15020. }
  15021. return
  15022. }
  15023. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  15024. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15025. // MessageContactID instead. It exists only for internal usage by the builders.
  15026. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  15027. if id := m.message_contact; id != nil {
  15028. ids = append(ids, *id)
  15029. }
  15030. return
  15031. }
  15032. // ResetMessageContact resets all changes to the "message_contact" edge.
  15033. func (m *MessageRecordsMutation) ResetMessageContact() {
  15034. m.message_contact = nil
  15035. m.clearedmessage_contact = false
  15036. }
  15037. // Where appends a list predicates to the MessageRecordsMutation builder.
  15038. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  15039. m.predicates = append(m.predicates, ps...)
  15040. }
  15041. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  15042. // users can use type-assertion to append predicates that do not depend on any generated package.
  15043. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  15044. p := make([]predicate.MessageRecords, len(ps))
  15045. for i := range ps {
  15046. p[i] = ps[i]
  15047. }
  15048. m.Where(p...)
  15049. }
  15050. // Op returns the operation name.
  15051. func (m *MessageRecordsMutation) Op() Op {
  15052. return m.op
  15053. }
  15054. // SetOp allows setting the mutation operation.
  15055. func (m *MessageRecordsMutation) SetOp(op Op) {
  15056. m.op = op
  15057. }
  15058. // Type returns the node type of this mutation (MessageRecords).
  15059. func (m *MessageRecordsMutation) Type() string {
  15060. return m.typ
  15061. }
  15062. // Fields returns all fields that were changed during this mutation. Note that in
  15063. // order to get all numeric fields that were incremented/decremented, call
  15064. // AddedFields().
  15065. func (m *MessageRecordsMutation) Fields() []string {
  15066. fields := make([]string, 0, 16)
  15067. if m.created_at != nil {
  15068. fields = append(fields, messagerecords.FieldCreatedAt)
  15069. }
  15070. if m.updated_at != nil {
  15071. fields = append(fields, messagerecords.FieldUpdatedAt)
  15072. }
  15073. if m.status != nil {
  15074. fields = append(fields, messagerecords.FieldStatus)
  15075. }
  15076. if m.bot_wxid != nil {
  15077. fields = append(fields, messagerecords.FieldBotWxid)
  15078. }
  15079. if m.message_contact != nil {
  15080. fields = append(fields, messagerecords.FieldContactID)
  15081. }
  15082. if m.contact_type != nil {
  15083. fields = append(fields, messagerecords.FieldContactType)
  15084. }
  15085. if m.contact_wxid != nil {
  15086. fields = append(fields, messagerecords.FieldContactWxid)
  15087. }
  15088. if m.content_type != nil {
  15089. fields = append(fields, messagerecords.FieldContentType)
  15090. }
  15091. if m.content != nil {
  15092. fields = append(fields, messagerecords.FieldContent)
  15093. }
  15094. if m.meta != nil {
  15095. fields = append(fields, messagerecords.FieldMeta)
  15096. }
  15097. if m.error_detail != nil {
  15098. fields = append(fields, messagerecords.FieldErrorDetail)
  15099. }
  15100. if m.send_time != nil {
  15101. fields = append(fields, messagerecords.FieldSendTime)
  15102. }
  15103. if m.source_type != nil {
  15104. fields = append(fields, messagerecords.FieldSourceType)
  15105. }
  15106. if m.sop_stage != nil {
  15107. fields = append(fields, messagerecords.FieldSourceID)
  15108. }
  15109. if m.sop_node != nil {
  15110. fields = append(fields, messagerecords.FieldSubSourceID)
  15111. }
  15112. if m.organization_id != nil {
  15113. fields = append(fields, messagerecords.FieldOrganizationID)
  15114. }
  15115. return fields
  15116. }
  15117. // Field returns the value of a field with the given name. The second boolean
  15118. // return value indicates that this field was not set, or was not defined in the
  15119. // schema.
  15120. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  15121. switch name {
  15122. case messagerecords.FieldCreatedAt:
  15123. return m.CreatedAt()
  15124. case messagerecords.FieldUpdatedAt:
  15125. return m.UpdatedAt()
  15126. case messagerecords.FieldStatus:
  15127. return m.Status()
  15128. case messagerecords.FieldBotWxid:
  15129. return m.BotWxid()
  15130. case messagerecords.FieldContactID:
  15131. return m.ContactID()
  15132. case messagerecords.FieldContactType:
  15133. return m.ContactType()
  15134. case messagerecords.FieldContactWxid:
  15135. return m.ContactWxid()
  15136. case messagerecords.FieldContentType:
  15137. return m.ContentType()
  15138. case messagerecords.FieldContent:
  15139. return m.Content()
  15140. case messagerecords.FieldMeta:
  15141. return m.Meta()
  15142. case messagerecords.FieldErrorDetail:
  15143. return m.ErrorDetail()
  15144. case messagerecords.FieldSendTime:
  15145. return m.SendTime()
  15146. case messagerecords.FieldSourceType:
  15147. return m.SourceType()
  15148. case messagerecords.FieldSourceID:
  15149. return m.SourceID()
  15150. case messagerecords.FieldSubSourceID:
  15151. return m.SubSourceID()
  15152. case messagerecords.FieldOrganizationID:
  15153. return m.OrganizationID()
  15154. }
  15155. return nil, false
  15156. }
  15157. // OldField returns the old value of the field from the database. An error is
  15158. // returned if the mutation operation is not UpdateOne, or the query to the
  15159. // database failed.
  15160. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15161. switch name {
  15162. case messagerecords.FieldCreatedAt:
  15163. return m.OldCreatedAt(ctx)
  15164. case messagerecords.FieldUpdatedAt:
  15165. return m.OldUpdatedAt(ctx)
  15166. case messagerecords.FieldStatus:
  15167. return m.OldStatus(ctx)
  15168. case messagerecords.FieldBotWxid:
  15169. return m.OldBotWxid(ctx)
  15170. case messagerecords.FieldContactID:
  15171. return m.OldContactID(ctx)
  15172. case messagerecords.FieldContactType:
  15173. return m.OldContactType(ctx)
  15174. case messagerecords.FieldContactWxid:
  15175. return m.OldContactWxid(ctx)
  15176. case messagerecords.FieldContentType:
  15177. return m.OldContentType(ctx)
  15178. case messagerecords.FieldContent:
  15179. return m.OldContent(ctx)
  15180. case messagerecords.FieldMeta:
  15181. return m.OldMeta(ctx)
  15182. case messagerecords.FieldErrorDetail:
  15183. return m.OldErrorDetail(ctx)
  15184. case messagerecords.FieldSendTime:
  15185. return m.OldSendTime(ctx)
  15186. case messagerecords.FieldSourceType:
  15187. return m.OldSourceType(ctx)
  15188. case messagerecords.FieldSourceID:
  15189. return m.OldSourceID(ctx)
  15190. case messagerecords.FieldSubSourceID:
  15191. return m.OldSubSourceID(ctx)
  15192. case messagerecords.FieldOrganizationID:
  15193. return m.OldOrganizationID(ctx)
  15194. }
  15195. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  15196. }
  15197. // SetField sets the value of a field with the given name. It returns an error if
  15198. // the field is not defined in the schema, or if the type mismatched the field
  15199. // type.
  15200. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  15201. switch name {
  15202. case messagerecords.FieldCreatedAt:
  15203. v, ok := value.(time.Time)
  15204. if !ok {
  15205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15206. }
  15207. m.SetCreatedAt(v)
  15208. return nil
  15209. case messagerecords.FieldUpdatedAt:
  15210. v, ok := value.(time.Time)
  15211. if !ok {
  15212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15213. }
  15214. m.SetUpdatedAt(v)
  15215. return nil
  15216. case messagerecords.FieldStatus:
  15217. v, ok := value.(uint8)
  15218. if !ok {
  15219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15220. }
  15221. m.SetStatus(v)
  15222. return nil
  15223. case messagerecords.FieldBotWxid:
  15224. v, ok := value.(string)
  15225. if !ok {
  15226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15227. }
  15228. m.SetBotWxid(v)
  15229. return nil
  15230. case messagerecords.FieldContactID:
  15231. v, ok := value.(uint64)
  15232. if !ok {
  15233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15234. }
  15235. m.SetContactID(v)
  15236. return nil
  15237. case messagerecords.FieldContactType:
  15238. v, ok := value.(int)
  15239. if !ok {
  15240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15241. }
  15242. m.SetContactType(v)
  15243. return nil
  15244. case messagerecords.FieldContactWxid:
  15245. v, ok := value.(string)
  15246. if !ok {
  15247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15248. }
  15249. m.SetContactWxid(v)
  15250. return nil
  15251. case messagerecords.FieldContentType:
  15252. v, ok := value.(int)
  15253. if !ok {
  15254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15255. }
  15256. m.SetContentType(v)
  15257. return nil
  15258. case messagerecords.FieldContent:
  15259. v, ok := value.(string)
  15260. if !ok {
  15261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15262. }
  15263. m.SetContent(v)
  15264. return nil
  15265. case messagerecords.FieldMeta:
  15266. v, ok := value.(custom_types.Meta)
  15267. if !ok {
  15268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15269. }
  15270. m.SetMeta(v)
  15271. return nil
  15272. case messagerecords.FieldErrorDetail:
  15273. v, ok := value.(string)
  15274. if !ok {
  15275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15276. }
  15277. m.SetErrorDetail(v)
  15278. return nil
  15279. case messagerecords.FieldSendTime:
  15280. v, ok := value.(time.Time)
  15281. if !ok {
  15282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15283. }
  15284. m.SetSendTime(v)
  15285. return nil
  15286. case messagerecords.FieldSourceType:
  15287. v, ok := value.(int)
  15288. if !ok {
  15289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15290. }
  15291. m.SetSourceType(v)
  15292. return nil
  15293. case messagerecords.FieldSourceID:
  15294. v, ok := value.(uint64)
  15295. if !ok {
  15296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15297. }
  15298. m.SetSourceID(v)
  15299. return nil
  15300. case messagerecords.FieldSubSourceID:
  15301. v, ok := value.(uint64)
  15302. if !ok {
  15303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15304. }
  15305. m.SetSubSourceID(v)
  15306. return nil
  15307. case messagerecords.FieldOrganizationID:
  15308. v, ok := value.(uint64)
  15309. if !ok {
  15310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15311. }
  15312. m.SetOrganizationID(v)
  15313. return nil
  15314. }
  15315. return fmt.Errorf("unknown MessageRecords field %s", name)
  15316. }
  15317. // AddedFields returns all numeric fields that were incremented/decremented during
  15318. // this mutation.
  15319. func (m *MessageRecordsMutation) AddedFields() []string {
  15320. var fields []string
  15321. if m.addstatus != nil {
  15322. fields = append(fields, messagerecords.FieldStatus)
  15323. }
  15324. if m.addcontact_type != nil {
  15325. fields = append(fields, messagerecords.FieldContactType)
  15326. }
  15327. if m.addcontent_type != nil {
  15328. fields = append(fields, messagerecords.FieldContentType)
  15329. }
  15330. if m.addsource_type != nil {
  15331. fields = append(fields, messagerecords.FieldSourceType)
  15332. }
  15333. if m.addorganization_id != nil {
  15334. fields = append(fields, messagerecords.FieldOrganizationID)
  15335. }
  15336. return fields
  15337. }
  15338. // AddedField returns the numeric value that was incremented/decremented on a field
  15339. // with the given name. The second boolean return value indicates that this field
  15340. // was not set, or was not defined in the schema.
  15341. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  15342. switch name {
  15343. case messagerecords.FieldStatus:
  15344. return m.AddedStatus()
  15345. case messagerecords.FieldContactType:
  15346. return m.AddedContactType()
  15347. case messagerecords.FieldContentType:
  15348. return m.AddedContentType()
  15349. case messagerecords.FieldSourceType:
  15350. return m.AddedSourceType()
  15351. case messagerecords.FieldOrganizationID:
  15352. return m.AddedOrganizationID()
  15353. }
  15354. return nil, false
  15355. }
  15356. // AddField adds the value to the field with the given name. It returns an error if
  15357. // the field is not defined in the schema, or if the type mismatched the field
  15358. // type.
  15359. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  15360. switch name {
  15361. case messagerecords.FieldStatus:
  15362. v, ok := value.(int8)
  15363. if !ok {
  15364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15365. }
  15366. m.AddStatus(v)
  15367. return nil
  15368. case messagerecords.FieldContactType:
  15369. v, ok := value.(int)
  15370. if !ok {
  15371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15372. }
  15373. m.AddContactType(v)
  15374. return nil
  15375. case messagerecords.FieldContentType:
  15376. v, ok := value.(int)
  15377. if !ok {
  15378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15379. }
  15380. m.AddContentType(v)
  15381. return nil
  15382. case messagerecords.FieldSourceType:
  15383. v, ok := value.(int)
  15384. if !ok {
  15385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15386. }
  15387. m.AddSourceType(v)
  15388. return nil
  15389. case messagerecords.FieldOrganizationID:
  15390. v, ok := value.(int64)
  15391. if !ok {
  15392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15393. }
  15394. m.AddOrganizationID(v)
  15395. return nil
  15396. }
  15397. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  15398. }
  15399. // ClearedFields returns all nullable fields that were cleared during this
  15400. // mutation.
  15401. func (m *MessageRecordsMutation) ClearedFields() []string {
  15402. var fields []string
  15403. if m.FieldCleared(messagerecords.FieldStatus) {
  15404. fields = append(fields, messagerecords.FieldStatus)
  15405. }
  15406. if m.FieldCleared(messagerecords.FieldContactID) {
  15407. fields = append(fields, messagerecords.FieldContactID)
  15408. }
  15409. if m.FieldCleared(messagerecords.FieldMeta) {
  15410. fields = append(fields, messagerecords.FieldMeta)
  15411. }
  15412. if m.FieldCleared(messagerecords.FieldSendTime) {
  15413. fields = append(fields, messagerecords.FieldSendTime)
  15414. }
  15415. if m.FieldCleared(messagerecords.FieldSourceID) {
  15416. fields = append(fields, messagerecords.FieldSourceID)
  15417. }
  15418. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  15419. fields = append(fields, messagerecords.FieldSubSourceID)
  15420. }
  15421. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  15422. fields = append(fields, messagerecords.FieldOrganizationID)
  15423. }
  15424. return fields
  15425. }
  15426. // FieldCleared returns a boolean indicating if a field with the given name was
  15427. // cleared in this mutation.
  15428. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  15429. _, ok := m.clearedFields[name]
  15430. return ok
  15431. }
  15432. // ClearField clears the value of the field with the given name. It returns an
  15433. // error if the field is not defined in the schema.
  15434. func (m *MessageRecordsMutation) ClearField(name string) error {
  15435. switch name {
  15436. case messagerecords.FieldStatus:
  15437. m.ClearStatus()
  15438. return nil
  15439. case messagerecords.FieldContactID:
  15440. m.ClearContactID()
  15441. return nil
  15442. case messagerecords.FieldMeta:
  15443. m.ClearMeta()
  15444. return nil
  15445. case messagerecords.FieldSendTime:
  15446. m.ClearSendTime()
  15447. return nil
  15448. case messagerecords.FieldSourceID:
  15449. m.ClearSourceID()
  15450. return nil
  15451. case messagerecords.FieldSubSourceID:
  15452. m.ClearSubSourceID()
  15453. return nil
  15454. case messagerecords.FieldOrganizationID:
  15455. m.ClearOrganizationID()
  15456. return nil
  15457. }
  15458. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  15459. }
  15460. // ResetField resets all changes in the mutation for the field with the given name.
  15461. // It returns an error if the field is not defined in the schema.
  15462. func (m *MessageRecordsMutation) ResetField(name string) error {
  15463. switch name {
  15464. case messagerecords.FieldCreatedAt:
  15465. m.ResetCreatedAt()
  15466. return nil
  15467. case messagerecords.FieldUpdatedAt:
  15468. m.ResetUpdatedAt()
  15469. return nil
  15470. case messagerecords.FieldStatus:
  15471. m.ResetStatus()
  15472. return nil
  15473. case messagerecords.FieldBotWxid:
  15474. m.ResetBotWxid()
  15475. return nil
  15476. case messagerecords.FieldContactID:
  15477. m.ResetContactID()
  15478. return nil
  15479. case messagerecords.FieldContactType:
  15480. m.ResetContactType()
  15481. return nil
  15482. case messagerecords.FieldContactWxid:
  15483. m.ResetContactWxid()
  15484. return nil
  15485. case messagerecords.FieldContentType:
  15486. m.ResetContentType()
  15487. return nil
  15488. case messagerecords.FieldContent:
  15489. m.ResetContent()
  15490. return nil
  15491. case messagerecords.FieldMeta:
  15492. m.ResetMeta()
  15493. return nil
  15494. case messagerecords.FieldErrorDetail:
  15495. m.ResetErrorDetail()
  15496. return nil
  15497. case messagerecords.FieldSendTime:
  15498. m.ResetSendTime()
  15499. return nil
  15500. case messagerecords.FieldSourceType:
  15501. m.ResetSourceType()
  15502. return nil
  15503. case messagerecords.FieldSourceID:
  15504. m.ResetSourceID()
  15505. return nil
  15506. case messagerecords.FieldSubSourceID:
  15507. m.ResetSubSourceID()
  15508. return nil
  15509. case messagerecords.FieldOrganizationID:
  15510. m.ResetOrganizationID()
  15511. return nil
  15512. }
  15513. return fmt.Errorf("unknown MessageRecords field %s", name)
  15514. }
  15515. // AddedEdges returns all edge names that were set/added in this mutation.
  15516. func (m *MessageRecordsMutation) AddedEdges() []string {
  15517. edges := make([]string, 0, 3)
  15518. if m.sop_stage != nil {
  15519. edges = append(edges, messagerecords.EdgeSopStage)
  15520. }
  15521. if m.sop_node != nil {
  15522. edges = append(edges, messagerecords.EdgeSopNode)
  15523. }
  15524. if m.message_contact != nil {
  15525. edges = append(edges, messagerecords.EdgeMessageContact)
  15526. }
  15527. return edges
  15528. }
  15529. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15530. // name in this mutation.
  15531. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  15532. switch name {
  15533. case messagerecords.EdgeSopStage:
  15534. if id := m.sop_stage; id != nil {
  15535. return []ent.Value{*id}
  15536. }
  15537. case messagerecords.EdgeSopNode:
  15538. if id := m.sop_node; id != nil {
  15539. return []ent.Value{*id}
  15540. }
  15541. case messagerecords.EdgeMessageContact:
  15542. if id := m.message_contact; id != nil {
  15543. return []ent.Value{*id}
  15544. }
  15545. }
  15546. return nil
  15547. }
  15548. // RemovedEdges returns all edge names that were removed in this mutation.
  15549. func (m *MessageRecordsMutation) RemovedEdges() []string {
  15550. edges := make([]string, 0, 3)
  15551. return edges
  15552. }
  15553. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15554. // the given name in this mutation.
  15555. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  15556. return nil
  15557. }
  15558. // ClearedEdges returns all edge names that were cleared in this mutation.
  15559. func (m *MessageRecordsMutation) ClearedEdges() []string {
  15560. edges := make([]string, 0, 3)
  15561. if m.clearedsop_stage {
  15562. edges = append(edges, messagerecords.EdgeSopStage)
  15563. }
  15564. if m.clearedsop_node {
  15565. edges = append(edges, messagerecords.EdgeSopNode)
  15566. }
  15567. if m.clearedmessage_contact {
  15568. edges = append(edges, messagerecords.EdgeMessageContact)
  15569. }
  15570. return edges
  15571. }
  15572. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15573. // was cleared in this mutation.
  15574. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  15575. switch name {
  15576. case messagerecords.EdgeSopStage:
  15577. return m.clearedsop_stage
  15578. case messagerecords.EdgeSopNode:
  15579. return m.clearedsop_node
  15580. case messagerecords.EdgeMessageContact:
  15581. return m.clearedmessage_contact
  15582. }
  15583. return false
  15584. }
  15585. // ClearEdge clears the value of the edge with the given name. It returns an error
  15586. // if that edge is not defined in the schema.
  15587. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  15588. switch name {
  15589. case messagerecords.EdgeSopStage:
  15590. m.ClearSopStage()
  15591. return nil
  15592. case messagerecords.EdgeSopNode:
  15593. m.ClearSopNode()
  15594. return nil
  15595. case messagerecords.EdgeMessageContact:
  15596. m.ClearMessageContact()
  15597. return nil
  15598. }
  15599. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  15600. }
  15601. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15602. // It returns an error if the edge is not defined in the schema.
  15603. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  15604. switch name {
  15605. case messagerecords.EdgeSopStage:
  15606. m.ResetSopStage()
  15607. return nil
  15608. case messagerecords.EdgeSopNode:
  15609. m.ResetSopNode()
  15610. return nil
  15611. case messagerecords.EdgeMessageContact:
  15612. m.ResetMessageContact()
  15613. return nil
  15614. }
  15615. return fmt.Errorf("unknown MessageRecords edge %s", name)
  15616. }
  15617. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  15618. type MsgMutation struct {
  15619. config
  15620. op Op
  15621. typ string
  15622. id *uint64
  15623. created_at *time.Time
  15624. updated_at *time.Time
  15625. deleted_at *time.Time
  15626. status *uint8
  15627. addstatus *int8
  15628. fromwxid *string
  15629. toid *string
  15630. msgtype *int32
  15631. addmsgtype *int32
  15632. msg *string
  15633. batch_no *string
  15634. clearedFields map[string]struct{}
  15635. done bool
  15636. oldValue func(context.Context) (*Msg, error)
  15637. predicates []predicate.Msg
  15638. }
  15639. var _ ent.Mutation = (*MsgMutation)(nil)
  15640. // msgOption allows management of the mutation configuration using functional options.
  15641. type msgOption func(*MsgMutation)
  15642. // newMsgMutation creates new mutation for the Msg entity.
  15643. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  15644. m := &MsgMutation{
  15645. config: c,
  15646. op: op,
  15647. typ: TypeMsg,
  15648. clearedFields: make(map[string]struct{}),
  15649. }
  15650. for _, opt := range opts {
  15651. opt(m)
  15652. }
  15653. return m
  15654. }
  15655. // withMsgID sets the ID field of the mutation.
  15656. func withMsgID(id uint64) msgOption {
  15657. return func(m *MsgMutation) {
  15658. var (
  15659. err error
  15660. once sync.Once
  15661. value *Msg
  15662. )
  15663. m.oldValue = func(ctx context.Context) (*Msg, error) {
  15664. once.Do(func() {
  15665. if m.done {
  15666. err = errors.New("querying old values post mutation is not allowed")
  15667. } else {
  15668. value, err = m.Client().Msg.Get(ctx, id)
  15669. }
  15670. })
  15671. return value, err
  15672. }
  15673. m.id = &id
  15674. }
  15675. }
  15676. // withMsg sets the old Msg of the mutation.
  15677. func withMsg(node *Msg) msgOption {
  15678. return func(m *MsgMutation) {
  15679. m.oldValue = func(context.Context) (*Msg, error) {
  15680. return node, nil
  15681. }
  15682. m.id = &node.ID
  15683. }
  15684. }
  15685. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15686. // executed in a transaction (ent.Tx), a transactional client is returned.
  15687. func (m MsgMutation) Client() *Client {
  15688. client := &Client{config: m.config}
  15689. client.init()
  15690. return client
  15691. }
  15692. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15693. // it returns an error otherwise.
  15694. func (m MsgMutation) Tx() (*Tx, error) {
  15695. if _, ok := m.driver.(*txDriver); !ok {
  15696. return nil, errors.New("ent: mutation is not running in a transaction")
  15697. }
  15698. tx := &Tx{config: m.config}
  15699. tx.init()
  15700. return tx, nil
  15701. }
  15702. // SetID sets the value of the id field. Note that this
  15703. // operation is only accepted on creation of Msg entities.
  15704. func (m *MsgMutation) SetID(id uint64) {
  15705. m.id = &id
  15706. }
  15707. // ID returns the ID value in the mutation. Note that the ID is only available
  15708. // if it was provided to the builder or after it was returned from the database.
  15709. func (m *MsgMutation) ID() (id uint64, exists bool) {
  15710. if m.id == nil {
  15711. return
  15712. }
  15713. return *m.id, true
  15714. }
  15715. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15716. // That means, if the mutation is applied within a transaction with an isolation level such
  15717. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15718. // or updated by the mutation.
  15719. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  15720. switch {
  15721. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15722. id, exists := m.ID()
  15723. if exists {
  15724. return []uint64{id}, nil
  15725. }
  15726. fallthrough
  15727. case m.op.Is(OpUpdate | OpDelete):
  15728. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  15729. default:
  15730. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15731. }
  15732. }
  15733. // SetCreatedAt sets the "created_at" field.
  15734. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  15735. m.created_at = &t
  15736. }
  15737. // CreatedAt returns the value of the "created_at" field in the mutation.
  15738. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  15739. v := m.created_at
  15740. if v == nil {
  15741. return
  15742. }
  15743. return *v, true
  15744. }
  15745. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  15746. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15748. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15749. if !m.op.Is(OpUpdateOne) {
  15750. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15751. }
  15752. if m.id == nil || m.oldValue == nil {
  15753. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15754. }
  15755. oldValue, err := m.oldValue(ctx)
  15756. if err != nil {
  15757. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15758. }
  15759. return oldValue.CreatedAt, nil
  15760. }
  15761. // ResetCreatedAt resets all changes to the "created_at" field.
  15762. func (m *MsgMutation) ResetCreatedAt() {
  15763. m.created_at = nil
  15764. }
  15765. // SetUpdatedAt sets the "updated_at" field.
  15766. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  15767. m.updated_at = &t
  15768. }
  15769. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15770. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  15771. v := m.updated_at
  15772. if v == nil {
  15773. return
  15774. }
  15775. return *v, true
  15776. }
  15777. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  15778. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15780. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15781. if !m.op.Is(OpUpdateOne) {
  15782. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15783. }
  15784. if m.id == nil || m.oldValue == nil {
  15785. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15786. }
  15787. oldValue, err := m.oldValue(ctx)
  15788. if err != nil {
  15789. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15790. }
  15791. return oldValue.UpdatedAt, nil
  15792. }
  15793. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15794. func (m *MsgMutation) ResetUpdatedAt() {
  15795. m.updated_at = nil
  15796. }
  15797. // SetDeletedAt sets the "deleted_at" field.
  15798. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  15799. m.deleted_at = &t
  15800. }
  15801. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15802. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  15803. v := m.deleted_at
  15804. if v == nil {
  15805. return
  15806. }
  15807. return *v, true
  15808. }
  15809. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  15810. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15812. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15813. if !m.op.Is(OpUpdateOne) {
  15814. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15815. }
  15816. if m.id == nil || m.oldValue == nil {
  15817. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15818. }
  15819. oldValue, err := m.oldValue(ctx)
  15820. if err != nil {
  15821. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15822. }
  15823. return oldValue.DeletedAt, nil
  15824. }
  15825. // ClearDeletedAt clears the value of the "deleted_at" field.
  15826. func (m *MsgMutation) ClearDeletedAt() {
  15827. m.deleted_at = nil
  15828. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  15829. }
  15830. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15831. func (m *MsgMutation) DeletedAtCleared() bool {
  15832. _, ok := m.clearedFields[msg.FieldDeletedAt]
  15833. return ok
  15834. }
  15835. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15836. func (m *MsgMutation) ResetDeletedAt() {
  15837. m.deleted_at = nil
  15838. delete(m.clearedFields, msg.FieldDeletedAt)
  15839. }
  15840. // SetStatus sets the "status" field.
  15841. func (m *MsgMutation) SetStatus(u uint8) {
  15842. m.status = &u
  15843. m.addstatus = nil
  15844. }
  15845. // Status returns the value of the "status" field in the mutation.
  15846. func (m *MsgMutation) Status() (r uint8, exists bool) {
  15847. v := m.status
  15848. if v == nil {
  15849. return
  15850. }
  15851. return *v, true
  15852. }
  15853. // OldStatus returns the old "status" field's value of the Msg entity.
  15854. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15856. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15857. if !m.op.Is(OpUpdateOne) {
  15858. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15859. }
  15860. if m.id == nil || m.oldValue == nil {
  15861. return v, errors.New("OldStatus requires an ID field in the mutation")
  15862. }
  15863. oldValue, err := m.oldValue(ctx)
  15864. if err != nil {
  15865. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15866. }
  15867. return oldValue.Status, nil
  15868. }
  15869. // AddStatus adds u to the "status" field.
  15870. func (m *MsgMutation) AddStatus(u int8) {
  15871. if m.addstatus != nil {
  15872. *m.addstatus += u
  15873. } else {
  15874. m.addstatus = &u
  15875. }
  15876. }
  15877. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15878. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  15879. v := m.addstatus
  15880. if v == nil {
  15881. return
  15882. }
  15883. return *v, true
  15884. }
  15885. // ClearStatus clears the value of the "status" field.
  15886. func (m *MsgMutation) ClearStatus() {
  15887. m.status = nil
  15888. m.addstatus = nil
  15889. m.clearedFields[msg.FieldStatus] = struct{}{}
  15890. }
  15891. // StatusCleared returns if the "status" field was cleared in this mutation.
  15892. func (m *MsgMutation) StatusCleared() bool {
  15893. _, ok := m.clearedFields[msg.FieldStatus]
  15894. return ok
  15895. }
  15896. // ResetStatus resets all changes to the "status" field.
  15897. func (m *MsgMutation) ResetStatus() {
  15898. m.status = nil
  15899. m.addstatus = nil
  15900. delete(m.clearedFields, msg.FieldStatus)
  15901. }
  15902. // SetFromwxid sets the "fromwxid" field.
  15903. func (m *MsgMutation) SetFromwxid(s string) {
  15904. m.fromwxid = &s
  15905. }
  15906. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  15907. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  15908. v := m.fromwxid
  15909. if v == nil {
  15910. return
  15911. }
  15912. return *v, true
  15913. }
  15914. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  15915. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15917. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  15918. if !m.op.Is(OpUpdateOne) {
  15919. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  15920. }
  15921. if m.id == nil || m.oldValue == nil {
  15922. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  15923. }
  15924. oldValue, err := m.oldValue(ctx)
  15925. if err != nil {
  15926. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  15927. }
  15928. return oldValue.Fromwxid, nil
  15929. }
  15930. // ClearFromwxid clears the value of the "fromwxid" field.
  15931. func (m *MsgMutation) ClearFromwxid() {
  15932. m.fromwxid = nil
  15933. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  15934. }
  15935. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  15936. func (m *MsgMutation) FromwxidCleared() bool {
  15937. _, ok := m.clearedFields[msg.FieldFromwxid]
  15938. return ok
  15939. }
  15940. // ResetFromwxid resets all changes to the "fromwxid" field.
  15941. func (m *MsgMutation) ResetFromwxid() {
  15942. m.fromwxid = nil
  15943. delete(m.clearedFields, msg.FieldFromwxid)
  15944. }
  15945. // SetToid sets the "toid" field.
  15946. func (m *MsgMutation) SetToid(s string) {
  15947. m.toid = &s
  15948. }
  15949. // Toid returns the value of the "toid" field in the mutation.
  15950. func (m *MsgMutation) Toid() (r string, exists bool) {
  15951. v := m.toid
  15952. if v == nil {
  15953. return
  15954. }
  15955. return *v, true
  15956. }
  15957. // OldToid returns the old "toid" field's value of the Msg entity.
  15958. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15960. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  15961. if !m.op.Is(OpUpdateOne) {
  15962. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  15963. }
  15964. if m.id == nil || m.oldValue == nil {
  15965. return v, errors.New("OldToid requires an ID field in the mutation")
  15966. }
  15967. oldValue, err := m.oldValue(ctx)
  15968. if err != nil {
  15969. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  15970. }
  15971. return oldValue.Toid, nil
  15972. }
  15973. // ClearToid clears the value of the "toid" field.
  15974. func (m *MsgMutation) ClearToid() {
  15975. m.toid = nil
  15976. m.clearedFields[msg.FieldToid] = struct{}{}
  15977. }
  15978. // ToidCleared returns if the "toid" field was cleared in this mutation.
  15979. func (m *MsgMutation) ToidCleared() bool {
  15980. _, ok := m.clearedFields[msg.FieldToid]
  15981. return ok
  15982. }
  15983. // ResetToid resets all changes to the "toid" field.
  15984. func (m *MsgMutation) ResetToid() {
  15985. m.toid = nil
  15986. delete(m.clearedFields, msg.FieldToid)
  15987. }
  15988. // SetMsgtype sets the "msgtype" field.
  15989. func (m *MsgMutation) SetMsgtype(i int32) {
  15990. m.msgtype = &i
  15991. m.addmsgtype = nil
  15992. }
  15993. // Msgtype returns the value of the "msgtype" field in the mutation.
  15994. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  15995. v := m.msgtype
  15996. if v == nil {
  15997. return
  15998. }
  15999. return *v, true
  16000. }
  16001. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  16002. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16004. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  16005. if !m.op.Is(OpUpdateOne) {
  16006. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  16007. }
  16008. if m.id == nil || m.oldValue == nil {
  16009. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  16010. }
  16011. oldValue, err := m.oldValue(ctx)
  16012. if err != nil {
  16013. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  16014. }
  16015. return oldValue.Msgtype, nil
  16016. }
  16017. // AddMsgtype adds i to the "msgtype" field.
  16018. func (m *MsgMutation) AddMsgtype(i int32) {
  16019. if m.addmsgtype != nil {
  16020. *m.addmsgtype += i
  16021. } else {
  16022. m.addmsgtype = &i
  16023. }
  16024. }
  16025. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  16026. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  16027. v := m.addmsgtype
  16028. if v == nil {
  16029. return
  16030. }
  16031. return *v, true
  16032. }
  16033. // ClearMsgtype clears the value of the "msgtype" field.
  16034. func (m *MsgMutation) ClearMsgtype() {
  16035. m.msgtype = nil
  16036. m.addmsgtype = nil
  16037. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  16038. }
  16039. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  16040. func (m *MsgMutation) MsgtypeCleared() bool {
  16041. _, ok := m.clearedFields[msg.FieldMsgtype]
  16042. return ok
  16043. }
  16044. // ResetMsgtype resets all changes to the "msgtype" field.
  16045. func (m *MsgMutation) ResetMsgtype() {
  16046. m.msgtype = nil
  16047. m.addmsgtype = nil
  16048. delete(m.clearedFields, msg.FieldMsgtype)
  16049. }
  16050. // SetMsg sets the "msg" field.
  16051. func (m *MsgMutation) SetMsg(s string) {
  16052. m.msg = &s
  16053. }
  16054. // Msg returns the value of the "msg" field in the mutation.
  16055. func (m *MsgMutation) Msg() (r string, exists bool) {
  16056. v := m.msg
  16057. if v == nil {
  16058. return
  16059. }
  16060. return *v, true
  16061. }
  16062. // OldMsg returns the old "msg" field's value of the Msg entity.
  16063. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16065. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  16066. if !m.op.Is(OpUpdateOne) {
  16067. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  16068. }
  16069. if m.id == nil || m.oldValue == nil {
  16070. return v, errors.New("OldMsg requires an ID field in the mutation")
  16071. }
  16072. oldValue, err := m.oldValue(ctx)
  16073. if err != nil {
  16074. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  16075. }
  16076. return oldValue.Msg, nil
  16077. }
  16078. // ClearMsg clears the value of the "msg" field.
  16079. func (m *MsgMutation) ClearMsg() {
  16080. m.msg = nil
  16081. m.clearedFields[msg.FieldMsg] = struct{}{}
  16082. }
  16083. // MsgCleared returns if the "msg" field was cleared in this mutation.
  16084. func (m *MsgMutation) MsgCleared() bool {
  16085. _, ok := m.clearedFields[msg.FieldMsg]
  16086. return ok
  16087. }
  16088. // ResetMsg resets all changes to the "msg" field.
  16089. func (m *MsgMutation) ResetMsg() {
  16090. m.msg = nil
  16091. delete(m.clearedFields, msg.FieldMsg)
  16092. }
  16093. // SetBatchNo sets the "batch_no" field.
  16094. func (m *MsgMutation) SetBatchNo(s string) {
  16095. m.batch_no = &s
  16096. }
  16097. // BatchNo returns the value of the "batch_no" field in the mutation.
  16098. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  16099. v := m.batch_no
  16100. if v == nil {
  16101. return
  16102. }
  16103. return *v, true
  16104. }
  16105. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  16106. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16108. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  16109. if !m.op.Is(OpUpdateOne) {
  16110. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  16111. }
  16112. if m.id == nil || m.oldValue == nil {
  16113. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  16114. }
  16115. oldValue, err := m.oldValue(ctx)
  16116. if err != nil {
  16117. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  16118. }
  16119. return oldValue.BatchNo, nil
  16120. }
  16121. // ClearBatchNo clears the value of the "batch_no" field.
  16122. func (m *MsgMutation) ClearBatchNo() {
  16123. m.batch_no = nil
  16124. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  16125. }
  16126. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  16127. func (m *MsgMutation) BatchNoCleared() bool {
  16128. _, ok := m.clearedFields[msg.FieldBatchNo]
  16129. return ok
  16130. }
  16131. // ResetBatchNo resets all changes to the "batch_no" field.
  16132. func (m *MsgMutation) ResetBatchNo() {
  16133. m.batch_no = nil
  16134. delete(m.clearedFields, msg.FieldBatchNo)
  16135. }
  16136. // Where appends a list predicates to the MsgMutation builder.
  16137. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  16138. m.predicates = append(m.predicates, ps...)
  16139. }
  16140. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  16141. // users can use type-assertion to append predicates that do not depend on any generated package.
  16142. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  16143. p := make([]predicate.Msg, len(ps))
  16144. for i := range ps {
  16145. p[i] = ps[i]
  16146. }
  16147. m.Where(p...)
  16148. }
  16149. // Op returns the operation name.
  16150. func (m *MsgMutation) Op() Op {
  16151. return m.op
  16152. }
  16153. // SetOp allows setting the mutation operation.
  16154. func (m *MsgMutation) SetOp(op Op) {
  16155. m.op = op
  16156. }
  16157. // Type returns the node type of this mutation (Msg).
  16158. func (m *MsgMutation) Type() string {
  16159. return m.typ
  16160. }
  16161. // Fields returns all fields that were changed during this mutation. Note that in
  16162. // order to get all numeric fields that were incremented/decremented, call
  16163. // AddedFields().
  16164. func (m *MsgMutation) Fields() []string {
  16165. fields := make([]string, 0, 9)
  16166. if m.created_at != nil {
  16167. fields = append(fields, msg.FieldCreatedAt)
  16168. }
  16169. if m.updated_at != nil {
  16170. fields = append(fields, msg.FieldUpdatedAt)
  16171. }
  16172. if m.deleted_at != nil {
  16173. fields = append(fields, msg.FieldDeletedAt)
  16174. }
  16175. if m.status != nil {
  16176. fields = append(fields, msg.FieldStatus)
  16177. }
  16178. if m.fromwxid != nil {
  16179. fields = append(fields, msg.FieldFromwxid)
  16180. }
  16181. if m.toid != nil {
  16182. fields = append(fields, msg.FieldToid)
  16183. }
  16184. if m.msgtype != nil {
  16185. fields = append(fields, msg.FieldMsgtype)
  16186. }
  16187. if m.msg != nil {
  16188. fields = append(fields, msg.FieldMsg)
  16189. }
  16190. if m.batch_no != nil {
  16191. fields = append(fields, msg.FieldBatchNo)
  16192. }
  16193. return fields
  16194. }
  16195. // Field returns the value of a field with the given name. The second boolean
  16196. // return value indicates that this field was not set, or was not defined in the
  16197. // schema.
  16198. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  16199. switch name {
  16200. case msg.FieldCreatedAt:
  16201. return m.CreatedAt()
  16202. case msg.FieldUpdatedAt:
  16203. return m.UpdatedAt()
  16204. case msg.FieldDeletedAt:
  16205. return m.DeletedAt()
  16206. case msg.FieldStatus:
  16207. return m.Status()
  16208. case msg.FieldFromwxid:
  16209. return m.Fromwxid()
  16210. case msg.FieldToid:
  16211. return m.Toid()
  16212. case msg.FieldMsgtype:
  16213. return m.Msgtype()
  16214. case msg.FieldMsg:
  16215. return m.Msg()
  16216. case msg.FieldBatchNo:
  16217. return m.BatchNo()
  16218. }
  16219. return nil, false
  16220. }
  16221. // OldField returns the old value of the field from the database. An error is
  16222. // returned if the mutation operation is not UpdateOne, or the query to the
  16223. // database failed.
  16224. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16225. switch name {
  16226. case msg.FieldCreatedAt:
  16227. return m.OldCreatedAt(ctx)
  16228. case msg.FieldUpdatedAt:
  16229. return m.OldUpdatedAt(ctx)
  16230. case msg.FieldDeletedAt:
  16231. return m.OldDeletedAt(ctx)
  16232. case msg.FieldStatus:
  16233. return m.OldStatus(ctx)
  16234. case msg.FieldFromwxid:
  16235. return m.OldFromwxid(ctx)
  16236. case msg.FieldToid:
  16237. return m.OldToid(ctx)
  16238. case msg.FieldMsgtype:
  16239. return m.OldMsgtype(ctx)
  16240. case msg.FieldMsg:
  16241. return m.OldMsg(ctx)
  16242. case msg.FieldBatchNo:
  16243. return m.OldBatchNo(ctx)
  16244. }
  16245. return nil, fmt.Errorf("unknown Msg field %s", name)
  16246. }
  16247. // SetField sets the value of a field with the given name. It returns an error if
  16248. // the field is not defined in the schema, or if the type mismatched the field
  16249. // type.
  16250. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  16251. switch name {
  16252. case msg.FieldCreatedAt:
  16253. v, ok := value.(time.Time)
  16254. if !ok {
  16255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16256. }
  16257. m.SetCreatedAt(v)
  16258. return nil
  16259. case msg.FieldUpdatedAt:
  16260. v, ok := value.(time.Time)
  16261. if !ok {
  16262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16263. }
  16264. m.SetUpdatedAt(v)
  16265. return nil
  16266. case msg.FieldDeletedAt:
  16267. v, ok := value.(time.Time)
  16268. if !ok {
  16269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16270. }
  16271. m.SetDeletedAt(v)
  16272. return nil
  16273. case msg.FieldStatus:
  16274. v, ok := value.(uint8)
  16275. if !ok {
  16276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16277. }
  16278. m.SetStatus(v)
  16279. return nil
  16280. case msg.FieldFromwxid:
  16281. v, ok := value.(string)
  16282. if !ok {
  16283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16284. }
  16285. m.SetFromwxid(v)
  16286. return nil
  16287. case msg.FieldToid:
  16288. v, ok := value.(string)
  16289. if !ok {
  16290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16291. }
  16292. m.SetToid(v)
  16293. return nil
  16294. case msg.FieldMsgtype:
  16295. v, ok := value.(int32)
  16296. if !ok {
  16297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16298. }
  16299. m.SetMsgtype(v)
  16300. return nil
  16301. case msg.FieldMsg:
  16302. v, ok := value.(string)
  16303. if !ok {
  16304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16305. }
  16306. m.SetMsg(v)
  16307. return nil
  16308. case msg.FieldBatchNo:
  16309. v, ok := value.(string)
  16310. if !ok {
  16311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16312. }
  16313. m.SetBatchNo(v)
  16314. return nil
  16315. }
  16316. return fmt.Errorf("unknown Msg field %s", name)
  16317. }
  16318. // AddedFields returns all numeric fields that were incremented/decremented during
  16319. // this mutation.
  16320. func (m *MsgMutation) AddedFields() []string {
  16321. var fields []string
  16322. if m.addstatus != nil {
  16323. fields = append(fields, msg.FieldStatus)
  16324. }
  16325. if m.addmsgtype != nil {
  16326. fields = append(fields, msg.FieldMsgtype)
  16327. }
  16328. return fields
  16329. }
  16330. // AddedField returns the numeric value that was incremented/decremented on a field
  16331. // with the given name. The second boolean return value indicates that this field
  16332. // was not set, or was not defined in the schema.
  16333. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  16334. switch name {
  16335. case msg.FieldStatus:
  16336. return m.AddedStatus()
  16337. case msg.FieldMsgtype:
  16338. return m.AddedMsgtype()
  16339. }
  16340. return nil, false
  16341. }
  16342. // AddField adds the value to the field with the given name. It returns an error if
  16343. // the field is not defined in the schema, or if the type mismatched the field
  16344. // type.
  16345. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  16346. switch name {
  16347. case msg.FieldStatus:
  16348. v, ok := value.(int8)
  16349. if !ok {
  16350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16351. }
  16352. m.AddStatus(v)
  16353. return nil
  16354. case msg.FieldMsgtype:
  16355. v, ok := value.(int32)
  16356. if !ok {
  16357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16358. }
  16359. m.AddMsgtype(v)
  16360. return nil
  16361. }
  16362. return fmt.Errorf("unknown Msg numeric field %s", name)
  16363. }
  16364. // ClearedFields returns all nullable fields that were cleared during this
  16365. // mutation.
  16366. func (m *MsgMutation) ClearedFields() []string {
  16367. var fields []string
  16368. if m.FieldCleared(msg.FieldDeletedAt) {
  16369. fields = append(fields, msg.FieldDeletedAt)
  16370. }
  16371. if m.FieldCleared(msg.FieldStatus) {
  16372. fields = append(fields, msg.FieldStatus)
  16373. }
  16374. if m.FieldCleared(msg.FieldFromwxid) {
  16375. fields = append(fields, msg.FieldFromwxid)
  16376. }
  16377. if m.FieldCleared(msg.FieldToid) {
  16378. fields = append(fields, msg.FieldToid)
  16379. }
  16380. if m.FieldCleared(msg.FieldMsgtype) {
  16381. fields = append(fields, msg.FieldMsgtype)
  16382. }
  16383. if m.FieldCleared(msg.FieldMsg) {
  16384. fields = append(fields, msg.FieldMsg)
  16385. }
  16386. if m.FieldCleared(msg.FieldBatchNo) {
  16387. fields = append(fields, msg.FieldBatchNo)
  16388. }
  16389. return fields
  16390. }
  16391. // FieldCleared returns a boolean indicating if a field with the given name was
  16392. // cleared in this mutation.
  16393. func (m *MsgMutation) FieldCleared(name string) bool {
  16394. _, ok := m.clearedFields[name]
  16395. return ok
  16396. }
  16397. // ClearField clears the value of the field with the given name. It returns an
  16398. // error if the field is not defined in the schema.
  16399. func (m *MsgMutation) ClearField(name string) error {
  16400. switch name {
  16401. case msg.FieldDeletedAt:
  16402. m.ClearDeletedAt()
  16403. return nil
  16404. case msg.FieldStatus:
  16405. m.ClearStatus()
  16406. return nil
  16407. case msg.FieldFromwxid:
  16408. m.ClearFromwxid()
  16409. return nil
  16410. case msg.FieldToid:
  16411. m.ClearToid()
  16412. return nil
  16413. case msg.FieldMsgtype:
  16414. m.ClearMsgtype()
  16415. return nil
  16416. case msg.FieldMsg:
  16417. m.ClearMsg()
  16418. return nil
  16419. case msg.FieldBatchNo:
  16420. m.ClearBatchNo()
  16421. return nil
  16422. }
  16423. return fmt.Errorf("unknown Msg nullable field %s", name)
  16424. }
  16425. // ResetField resets all changes in the mutation for the field with the given name.
  16426. // It returns an error if the field is not defined in the schema.
  16427. func (m *MsgMutation) ResetField(name string) error {
  16428. switch name {
  16429. case msg.FieldCreatedAt:
  16430. m.ResetCreatedAt()
  16431. return nil
  16432. case msg.FieldUpdatedAt:
  16433. m.ResetUpdatedAt()
  16434. return nil
  16435. case msg.FieldDeletedAt:
  16436. m.ResetDeletedAt()
  16437. return nil
  16438. case msg.FieldStatus:
  16439. m.ResetStatus()
  16440. return nil
  16441. case msg.FieldFromwxid:
  16442. m.ResetFromwxid()
  16443. return nil
  16444. case msg.FieldToid:
  16445. m.ResetToid()
  16446. return nil
  16447. case msg.FieldMsgtype:
  16448. m.ResetMsgtype()
  16449. return nil
  16450. case msg.FieldMsg:
  16451. m.ResetMsg()
  16452. return nil
  16453. case msg.FieldBatchNo:
  16454. m.ResetBatchNo()
  16455. return nil
  16456. }
  16457. return fmt.Errorf("unknown Msg field %s", name)
  16458. }
  16459. // AddedEdges returns all edge names that were set/added in this mutation.
  16460. func (m *MsgMutation) AddedEdges() []string {
  16461. edges := make([]string, 0, 0)
  16462. return edges
  16463. }
  16464. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16465. // name in this mutation.
  16466. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  16467. return nil
  16468. }
  16469. // RemovedEdges returns all edge names that were removed in this mutation.
  16470. func (m *MsgMutation) RemovedEdges() []string {
  16471. edges := make([]string, 0, 0)
  16472. return edges
  16473. }
  16474. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16475. // the given name in this mutation.
  16476. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  16477. return nil
  16478. }
  16479. // ClearedEdges returns all edge names that were cleared in this mutation.
  16480. func (m *MsgMutation) ClearedEdges() []string {
  16481. edges := make([]string, 0, 0)
  16482. return edges
  16483. }
  16484. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16485. // was cleared in this mutation.
  16486. func (m *MsgMutation) EdgeCleared(name string) bool {
  16487. return false
  16488. }
  16489. // ClearEdge clears the value of the edge with the given name. It returns an error
  16490. // if that edge is not defined in the schema.
  16491. func (m *MsgMutation) ClearEdge(name string) error {
  16492. return fmt.Errorf("unknown Msg unique edge %s", name)
  16493. }
  16494. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16495. // It returns an error if the edge is not defined in the schema.
  16496. func (m *MsgMutation) ResetEdge(name string) error {
  16497. return fmt.Errorf("unknown Msg edge %s", name)
  16498. }
  16499. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  16500. type ServerMutation struct {
  16501. config
  16502. op Op
  16503. typ string
  16504. id *uint64
  16505. created_at *time.Time
  16506. updated_at *time.Time
  16507. status *uint8
  16508. addstatus *int8
  16509. deleted_at *time.Time
  16510. name *string
  16511. public_ip *string
  16512. private_ip *string
  16513. admin_port *string
  16514. clearedFields map[string]struct{}
  16515. wxs map[uint64]struct{}
  16516. removedwxs map[uint64]struct{}
  16517. clearedwxs bool
  16518. done bool
  16519. oldValue func(context.Context) (*Server, error)
  16520. predicates []predicate.Server
  16521. }
  16522. var _ ent.Mutation = (*ServerMutation)(nil)
  16523. // serverOption allows management of the mutation configuration using functional options.
  16524. type serverOption func(*ServerMutation)
  16525. // newServerMutation creates new mutation for the Server entity.
  16526. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  16527. m := &ServerMutation{
  16528. config: c,
  16529. op: op,
  16530. typ: TypeServer,
  16531. clearedFields: make(map[string]struct{}),
  16532. }
  16533. for _, opt := range opts {
  16534. opt(m)
  16535. }
  16536. return m
  16537. }
  16538. // withServerID sets the ID field of the mutation.
  16539. func withServerID(id uint64) serverOption {
  16540. return func(m *ServerMutation) {
  16541. var (
  16542. err error
  16543. once sync.Once
  16544. value *Server
  16545. )
  16546. m.oldValue = func(ctx context.Context) (*Server, error) {
  16547. once.Do(func() {
  16548. if m.done {
  16549. err = errors.New("querying old values post mutation is not allowed")
  16550. } else {
  16551. value, err = m.Client().Server.Get(ctx, id)
  16552. }
  16553. })
  16554. return value, err
  16555. }
  16556. m.id = &id
  16557. }
  16558. }
  16559. // withServer sets the old Server of the mutation.
  16560. func withServer(node *Server) serverOption {
  16561. return func(m *ServerMutation) {
  16562. m.oldValue = func(context.Context) (*Server, error) {
  16563. return node, nil
  16564. }
  16565. m.id = &node.ID
  16566. }
  16567. }
  16568. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16569. // executed in a transaction (ent.Tx), a transactional client is returned.
  16570. func (m ServerMutation) Client() *Client {
  16571. client := &Client{config: m.config}
  16572. client.init()
  16573. return client
  16574. }
  16575. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16576. // it returns an error otherwise.
  16577. func (m ServerMutation) Tx() (*Tx, error) {
  16578. if _, ok := m.driver.(*txDriver); !ok {
  16579. return nil, errors.New("ent: mutation is not running in a transaction")
  16580. }
  16581. tx := &Tx{config: m.config}
  16582. tx.init()
  16583. return tx, nil
  16584. }
  16585. // SetID sets the value of the id field. Note that this
  16586. // operation is only accepted on creation of Server entities.
  16587. func (m *ServerMutation) SetID(id uint64) {
  16588. m.id = &id
  16589. }
  16590. // ID returns the ID value in the mutation. Note that the ID is only available
  16591. // if it was provided to the builder or after it was returned from the database.
  16592. func (m *ServerMutation) ID() (id uint64, exists bool) {
  16593. if m.id == nil {
  16594. return
  16595. }
  16596. return *m.id, true
  16597. }
  16598. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16599. // That means, if the mutation is applied within a transaction with an isolation level such
  16600. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16601. // or updated by the mutation.
  16602. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  16603. switch {
  16604. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16605. id, exists := m.ID()
  16606. if exists {
  16607. return []uint64{id}, nil
  16608. }
  16609. fallthrough
  16610. case m.op.Is(OpUpdate | OpDelete):
  16611. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  16612. default:
  16613. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16614. }
  16615. }
  16616. // SetCreatedAt sets the "created_at" field.
  16617. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  16618. m.created_at = &t
  16619. }
  16620. // CreatedAt returns the value of the "created_at" field in the mutation.
  16621. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  16622. v := m.created_at
  16623. if v == nil {
  16624. return
  16625. }
  16626. return *v, true
  16627. }
  16628. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  16629. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16631. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16632. if !m.op.Is(OpUpdateOne) {
  16633. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16634. }
  16635. if m.id == nil || m.oldValue == nil {
  16636. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16637. }
  16638. oldValue, err := m.oldValue(ctx)
  16639. if err != nil {
  16640. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16641. }
  16642. return oldValue.CreatedAt, nil
  16643. }
  16644. // ResetCreatedAt resets all changes to the "created_at" field.
  16645. func (m *ServerMutation) ResetCreatedAt() {
  16646. m.created_at = nil
  16647. }
  16648. // SetUpdatedAt sets the "updated_at" field.
  16649. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  16650. m.updated_at = &t
  16651. }
  16652. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16653. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  16654. v := m.updated_at
  16655. if v == nil {
  16656. return
  16657. }
  16658. return *v, true
  16659. }
  16660. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  16661. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16663. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16664. if !m.op.Is(OpUpdateOne) {
  16665. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16666. }
  16667. if m.id == nil || m.oldValue == nil {
  16668. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16669. }
  16670. oldValue, err := m.oldValue(ctx)
  16671. if err != nil {
  16672. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16673. }
  16674. return oldValue.UpdatedAt, nil
  16675. }
  16676. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16677. func (m *ServerMutation) ResetUpdatedAt() {
  16678. m.updated_at = nil
  16679. }
  16680. // SetStatus sets the "status" field.
  16681. func (m *ServerMutation) SetStatus(u uint8) {
  16682. m.status = &u
  16683. m.addstatus = nil
  16684. }
  16685. // Status returns the value of the "status" field in the mutation.
  16686. func (m *ServerMutation) Status() (r uint8, exists bool) {
  16687. v := m.status
  16688. if v == nil {
  16689. return
  16690. }
  16691. return *v, true
  16692. }
  16693. // OldStatus returns the old "status" field's value of the Server entity.
  16694. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16696. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16697. if !m.op.Is(OpUpdateOne) {
  16698. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16699. }
  16700. if m.id == nil || m.oldValue == nil {
  16701. return v, errors.New("OldStatus requires an ID field in the mutation")
  16702. }
  16703. oldValue, err := m.oldValue(ctx)
  16704. if err != nil {
  16705. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16706. }
  16707. return oldValue.Status, nil
  16708. }
  16709. // AddStatus adds u to the "status" field.
  16710. func (m *ServerMutation) AddStatus(u int8) {
  16711. if m.addstatus != nil {
  16712. *m.addstatus += u
  16713. } else {
  16714. m.addstatus = &u
  16715. }
  16716. }
  16717. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16718. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  16719. v := m.addstatus
  16720. if v == nil {
  16721. return
  16722. }
  16723. return *v, true
  16724. }
  16725. // ClearStatus clears the value of the "status" field.
  16726. func (m *ServerMutation) ClearStatus() {
  16727. m.status = nil
  16728. m.addstatus = nil
  16729. m.clearedFields[server.FieldStatus] = struct{}{}
  16730. }
  16731. // StatusCleared returns if the "status" field was cleared in this mutation.
  16732. func (m *ServerMutation) StatusCleared() bool {
  16733. _, ok := m.clearedFields[server.FieldStatus]
  16734. return ok
  16735. }
  16736. // ResetStatus resets all changes to the "status" field.
  16737. func (m *ServerMutation) ResetStatus() {
  16738. m.status = nil
  16739. m.addstatus = nil
  16740. delete(m.clearedFields, server.FieldStatus)
  16741. }
  16742. // SetDeletedAt sets the "deleted_at" field.
  16743. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  16744. m.deleted_at = &t
  16745. }
  16746. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16747. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  16748. v := m.deleted_at
  16749. if v == nil {
  16750. return
  16751. }
  16752. return *v, true
  16753. }
  16754. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  16755. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16757. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16758. if !m.op.Is(OpUpdateOne) {
  16759. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16760. }
  16761. if m.id == nil || m.oldValue == nil {
  16762. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16763. }
  16764. oldValue, err := m.oldValue(ctx)
  16765. if err != nil {
  16766. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16767. }
  16768. return oldValue.DeletedAt, nil
  16769. }
  16770. // ClearDeletedAt clears the value of the "deleted_at" field.
  16771. func (m *ServerMutation) ClearDeletedAt() {
  16772. m.deleted_at = nil
  16773. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  16774. }
  16775. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16776. func (m *ServerMutation) DeletedAtCleared() bool {
  16777. _, ok := m.clearedFields[server.FieldDeletedAt]
  16778. return ok
  16779. }
  16780. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16781. func (m *ServerMutation) ResetDeletedAt() {
  16782. m.deleted_at = nil
  16783. delete(m.clearedFields, server.FieldDeletedAt)
  16784. }
  16785. // SetName sets the "name" field.
  16786. func (m *ServerMutation) SetName(s string) {
  16787. m.name = &s
  16788. }
  16789. // Name returns the value of the "name" field in the mutation.
  16790. func (m *ServerMutation) Name() (r string, exists bool) {
  16791. v := m.name
  16792. if v == nil {
  16793. return
  16794. }
  16795. return *v, true
  16796. }
  16797. // OldName returns the old "name" field's value of the Server entity.
  16798. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16800. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  16801. if !m.op.Is(OpUpdateOne) {
  16802. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16803. }
  16804. if m.id == nil || m.oldValue == nil {
  16805. return v, errors.New("OldName requires an ID field in the mutation")
  16806. }
  16807. oldValue, err := m.oldValue(ctx)
  16808. if err != nil {
  16809. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16810. }
  16811. return oldValue.Name, nil
  16812. }
  16813. // ResetName resets all changes to the "name" field.
  16814. func (m *ServerMutation) ResetName() {
  16815. m.name = nil
  16816. }
  16817. // SetPublicIP sets the "public_ip" field.
  16818. func (m *ServerMutation) SetPublicIP(s string) {
  16819. m.public_ip = &s
  16820. }
  16821. // PublicIP returns the value of the "public_ip" field in the mutation.
  16822. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  16823. v := m.public_ip
  16824. if v == nil {
  16825. return
  16826. }
  16827. return *v, true
  16828. }
  16829. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  16830. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16832. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  16833. if !m.op.Is(OpUpdateOne) {
  16834. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  16835. }
  16836. if m.id == nil || m.oldValue == nil {
  16837. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  16838. }
  16839. oldValue, err := m.oldValue(ctx)
  16840. if err != nil {
  16841. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  16842. }
  16843. return oldValue.PublicIP, nil
  16844. }
  16845. // ResetPublicIP resets all changes to the "public_ip" field.
  16846. func (m *ServerMutation) ResetPublicIP() {
  16847. m.public_ip = nil
  16848. }
  16849. // SetPrivateIP sets the "private_ip" field.
  16850. func (m *ServerMutation) SetPrivateIP(s string) {
  16851. m.private_ip = &s
  16852. }
  16853. // PrivateIP returns the value of the "private_ip" field in the mutation.
  16854. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  16855. v := m.private_ip
  16856. if v == nil {
  16857. return
  16858. }
  16859. return *v, true
  16860. }
  16861. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  16862. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16864. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  16865. if !m.op.Is(OpUpdateOne) {
  16866. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  16867. }
  16868. if m.id == nil || m.oldValue == nil {
  16869. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  16870. }
  16871. oldValue, err := m.oldValue(ctx)
  16872. if err != nil {
  16873. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  16874. }
  16875. return oldValue.PrivateIP, nil
  16876. }
  16877. // ResetPrivateIP resets all changes to the "private_ip" field.
  16878. func (m *ServerMutation) ResetPrivateIP() {
  16879. m.private_ip = nil
  16880. }
  16881. // SetAdminPort sets the "admin_port" field.
  16882. func (m *ServerMutation) SetAdminPort(s string) {
  16883. m.admin_port = &s
  16884. }
  16885. // AdminPort returns the value of the "admin_port" field in the mutation.
  16886. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  16887. v := m.admin_port
  16888. if v == nil {
  16889. return
  16890. }
  16891. return *v, true
  16892. }
  16893. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  16894. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16896. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  16897. if !m.op.Is(OpUpdateOne) {
  16898. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  16899. }
  16900. if m.id == nil || m.oldValue == nil {
  16901. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  16902. }
  16903. oldValue, err := m.oldValue(ctx)
  16904. if err != nil {
  16905. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  16906. }
  16907. return oldValue.AdminPort, nil
  16908. }
  16909. // ResetAdminPort resets all changes to the "admin_port" field.
  16910. func (m *ServerMutation) ResetAdminPort() {
  16911. m.admin_port = nil
  16912. }
  16913. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  16914. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  16915. if m.wxs == nil {
  16916. m.wxs = make(map[uint64]struct{})
  16917. }
  16918. for i := range ids {
  16919. m.wxs[ids[i]] = struct{}{}
  16920. }
  16921. }
  16922. // ClearWxs clears the "wxs" edge to the Wx entity.
  16923. func (m *ServerMutation) ClearWxs() {
  16924. m.clearedwxs = true
  16925. }
  16926. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  16927. func (m *ServerMutation) WxsCleared() bool {
  16928. return m.clearedwxs
  16929. }
  16930. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  16931. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  16932. if m.removedwxs == nil {
  16933. m.removedwxs = make(map[uint64]struct{})
  16934. }
  16935. for i := range ids {
  16936. delete(m.wxs, ids[i])
  16937. m.removedwxs[ids[i]] = struct{}{}
  16938. }
  16939. }
  16940. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  16941. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  16942. for id := range m.removedwxs {
  16943. ids = append(ids, id)
  16944. }
  16945. return
  16946. }
  16947. // WxsIDs returns the "wxs" edge IDs in the mutation.
  16948. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  16949. for id := range m.wxs {
  16950. ids = append(ids, id)
  16951. }
  16952. return
  16953. }
  16954. // ResetWxs resets all changes to the "wxs" edge.
  16955. func (m *ServerMutation) ResetWxs() {
  16956. m.wxs = nil
  16957. m.clearedwxs = false
  16958. m.removedwxs = nil
  16959. }
  16960. // Where appends a list predicates to the ServerMutation builder.
  16961. func (m *ServerMutation) Where(ps ...predicate.Server) {
  16962. m.predicates = append(m.predicates, ps...)
  16963. }
  16964. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  16965. // users can use type-assertion to append predicates that do not depend on any generated package.
  16966. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  16967. p := make([]predicate.Server, len(ps))
  16968. for i := range ps {
  16969. p[i] = ps[i]
  16970. }
  16971. m.Where(p...)
  16972. }
  16973. // Op returns the operation name.
  16974. func (m *ServerMutation) Op() Op {
  16975. return m.op
  16976. }
  16977. // SetOp allows setting the mutation operation.
  16978. func (m *ServerMutation) SetOp(op Op) {
  16979. m.op = op
  16980. }
  16981. // Type returns the node type of this mutation (Server).
  16982. func (m *ServerMutation) Type() string {
  16983. return m.typ
  16984. }
  16985. // Fields returns all fields that were changed during this mutation. Note that in
  16986. // order to get all numeric fields that were incremented/decremented, call
  16987. // AddedFields().
  16988. func (m *ServerMutation) Fields() []string {
  16989. fields := make([]string, 0, 8)
  16990. if m.created_at != nil {
  16991. fields = append(fields, server.FieldCreatedAt)
  16992. }
  16993. if m.updated_at != nil {
  16994. fields = append(fields, server.FieldUpdatedAt)
  16995. }
  16996. if m.status != nil {
  16997. fields = append(fields, server.FieldStatus)
  16998. }
  16999. if m.deleted_at != nil {
  17000. fields = append(fields, server.FieldDeletedAt)
  17001. }
  17002. if m.name != nil {
  17003. fields = append(fields, server.FieldName)
  17004. }
  17005. if m.public_ip != nil {
  17006. fields = append(fields, server.FieldPublicIP)
  17007. }
  17008. if m.private_ip != nil {
  17009. fields = append(fields, server.FieldPrivateIP)
  17010. }
  17011. if m.admin_port != nil {
  17012. fields = append(fields, server.FieldAdminPort)
  17013. }
  17014. return fields
  17015. }
  17016. // Field returns the value of a field with the given name. The second boolean
  17017. // return value indicates that this field was not set, or was not defined in the
  17018. // schema.
  17019. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  17020. switch name {
  17021. case server.FieldCreatedAt:
  17022. return m.CreatedAt()
  17023. case server.FieldUpdatedAt:
  17024. return m.UpdatedAt()
  17025. case server.FieldStatus:
  17026. return m.Status()
  17027. case server.FieldDeletedAt:
  17028. return m.DeletedAt()
  17029. case server.FieldName:
  17030. return m.Name()
  17031. case server.FieldPublicIP:
  17032. return m.PublicIP()
  17033. case server.FieldPrivateIP:
  17034. return m.PrivateIP()
  17035. case server.FieldAdminPort:
  17036. return m.AdminPort()
  17037. }
  17038. return nil, false
  17039. }
  17040. // OldField returns the old value of the field from the database. An error is
  17041. // returned if the mutation operation is not UpdateOne, or the query to the
  17042. // database failed.
  17043. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17044. switch name {
  17045. case server.FieldCreatedAt:
  17046. return m.OldCreatedAt(ctx)
  17047. case server.FieldUpdatedAt:
  17048. return m.OldUpdatedAt(ctx)
  17049. case server.FieldStatus:
  17050. return m.OldStatus(ctx)
  17051. case server.FieldDeletedAt:
  17052. return m.OldDeletedAt(ctx)
  17053. case server.FieldName:
  17054. return m.OldName(ctx)
  17055. case server.FieldPublicIP:
  17056. return m.OldPublicIP(ctx)
  17057. case server.FieldPrivateIP:
  17058. return m.OldPrivateIP(ctx)
  17059. case server.FieldAdminPort:
  17060. return m.OldAdminPort(ctx)
  17061. }
  17062. return nil, fmt.Errorf("unknown Server field %s", name)
  17063. }
  17064. // SetField sets the value of a field with the given name. It returns an error if
  17065. // the field is not defined in the schema, or if the type mismatched the field
  17066. // type.
  17067. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  17068. switch name {
  17069. case server.FieldCreatedAt:
  17070. v, ok := value.(time.Time)
  17071. if !ok {
  17072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17073. }
  17074. m.SetCreatedAt(v)
  17075. return nil
  17076. case server.FieldUpdatedAt:
  17077. v, ok := value.(time.Time)
  17078. if !ok {
  17079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17080. }
  17081. m.SetUpdatedAt(v)
  17082. return nil
  17083. case server.FieldStatus:
  17084. v, ok := value.(uint8)
  17085. if !ok {
  17086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17087. }
  17088. m.SetStatus(v)
  17089. return nil
  17090. case server.FieldDeletedAt:
  17091. v, ok := value.(time.Time)
  17092. if !ok {
  17093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17094. }
  17095. m.SetDeletedAt(v)
  17096. return nil
  17097. case server.FieldName:
  17098. v, ok := value.(string)
  17099. if !ok {
  17100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17101. }
  17102. m.SetName(v)
  17103. return nil
  17104. case server.FieldPublicIP:
  17105. v, ok := value.(string)
  17106. if !ok {
  17107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17108. }
  17109. m.SetPublicIP(v)
  17110. return nil
  17111. case server.FieldPrivateIP:
  17112. v, ok := value.(string)
  17113. if !ok {
  17114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17115. }
  17116. m.SetPrivateIP(v)
  17117. return nil
  17118. case server.FieldAdminPort:
  17119. v, ok := value.(string)
  17120. if !ok {
  17121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17122. }
  17123. m.SetAdminPort(v)
  17124. return nil
  17125. }
  17126. return fmt.Errorf("unknown Server field %s", name)
  17127. }
  17128. // AddedFields returns all numeric fields that were incremented/decremented during
  17129. // this mutation.
  17130. func (m *ServerMutation) AddedFields() []string {
  17131. var fields []string
  17132. if m.addstatus != nil {
  17133. fields = append(fields, server.FieldStatus)
  17134. }
  17135. return fields
  17136. }
  17137. // AddedField returns the numeric value that was incremented/decremented on a field
  17138. // with the given name. The second boolean return value indicates that this field
  17139. // was not set, or was not defined in the schema.
  17140. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  17141. switch name {
  17142. case server.FieldStatus:
  17143. return m.AddedStatus()
  17144. }
  17145. return nil, false
  17146. }
  17147. // AddField adds the value to the field with the given name. It returns an error if
  17148. // the field is not defined in the schema, or if the type mismatched the field
  17149. // type.
  17150. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  17151. switch name {
  17152. case server.FieldStatus:
  17153. v, ok := value.(int8)
  17154. if !ok {
  17155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17156. }
  17157. m.AddStatus(v)
  17158. return nil
  17159. }
  17160. return fmt.Errorf("unknown Server numeric field %s", name)
  17161. }
  17162. // ClearedFields returns all nullable fields that were cleared during this
  17163. // mutation.
  17164. func (m *ServerMutation) ClearedFields() []string {
  17165. var fields []string
  17166. if m.FieldCleared(server.FieldStatus) {
  17167. fields = append(fields, server.FieldStatus)
  17168. }
  17169. if m.FieldCleared(server.FieldDeletedAt) {
  17170. fields = append(fields, server.FieldDeletedAt)
  17171. }
  17172. return fields
  17173. }
  17174. // FieldCleared returns a boolean indicating if a field with the given name was
  17175. // cleared in this mutation.
  17176. func (m *ServerMutation) FieldCleared(name string) bool {
  17177. _, ok := m.clearedFields[name]
  17178. return ok
  17179. }
  17180. // ClearField clears the value of the field with the given name. It returns an
  17181. // error if the field is not defined in the schema.
  17182. func (m *ServerMutation) ClearField(name string) error {
  17183. switch name {
  17184. case server.FieldStatus:
  17185. m.ClearStatus()
  17186. return nil
  17187. case server.FieldDeletedAt:
  17188. m.ClearDeletedAt()
  17189. return nil
  17190. }
  17191. return fmt.Errorf("unknown Server nullable field %s", name)
  17192. }
  17193. // ResetField resets all changes in the mutation for the field with the given name.
  17194. // It returns an error if the field is not defined in the schema.
  17195. func (m *ServerMutation) ResetField(name string) error {
  17196. switch name {
  17197. case server.FieldCreatedAt:
  17198. m.ResetCreatedAt()
  17199. return nil
  17200. case server.FieldUpdatedAt:
  17201. m.ResetUpdatedAt()
  17202. return nil
  17203. case server.FieldStatus:
  17204. m.ResetStatus()
  17205. return nil
  17206. case server.FieldDeletedAt:
  17207. m.ResetDeletedAt()
  17208. return nil
  17209. case server.FieldName:
  17210. m.ResetName()
  17211. return nil
  17212. case server.FieldPublicIP:
  17213. m.ResetPublicIP()
  17214. return nil
  17215. case server.FieldPrivateIP:
  17216. m.ResetPrivateIP()
  17217. return nil
  17218. case server.FieldAdminPort:
  17219. m.ResetAdminPort()
  17220. return nil
  17221. }
  17222. return fmt.Errorf("unknown Server field %s", name)
  17223. }
  17224. // AddedEdges returns all edge names that were set/added in this mutation.
  17225. func (m *ServerMutation) AddedEdges() []string {
  17226. edges := make([]string, 0, 1)
  17227. if m.wxs != nil {
  17228. edges = append(edges, server.EdgeWxs)
  17229. }
  17230. return edges
  17231. }
  17232. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17233. // name in this mutation.
  17234. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  17235. switch name {
  17236. case server.EdgeWxs:
  17237. ids := make([]ent.Value, 0, len(m.wxs))
  17238. for id := range m.wxs {
  17239. ids = append(ids, id)
  17240. }
  17241. return ids
  17242. }
  17243. return nil
  17244. }
  17245. // RemovedEdges returns all edge names that were removed in this mutation.
  17246. func (m *ServerMutation) RemovedEdges() []string {
  17247. edges := make([]string, 0, 1)
  17248. if m.removedwxs != nil {
  17249. edges = append(edges, server.EdgeWxs)
  17250. }
  17251. return edges
  17252. }
  17253. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17254. // the given name in this mutation.
  17255. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  17256. switch name {
  17257. case server.EdgeWxs:
  17258. ids := make([]ent.Value, 0, len(m.removedwxs))
  17259. for id := range m.removedwxs {
  17260. ids = append(ids, id)
  17261. }
  17262. return ids
  17263. }
  17264. return nil
  17265. }
  17266. // ClearedEdges returns all edge names that were cleared in this mutation.
  17267. func (m *ServerMutation) ClearedEdges() []string {
  17268. edges := make([]string, 0, 1)
  17269. if m.clearedwxs {
  17270. edges = append(edges, server.EdgeWxs)
  17271. }
  17272. return edges
  17273. }
  17274. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17275. // was cleared in this mutation.
  17276. func (m *ServerMutation) EdgeCleared(name string) bool {
  17277. switch name {
  17278. case server.EdgeWxs:
  17279. return m.clearedwxs
  17280. }
  17281. return false
  17282. }
  17283. // ClearEdge clears the value of the edge with the given name. It returns an error
  17284. // if that edge is not defined in the schema.
  17285. func (m *ServerMutation) ClearEdge(name string) error {
  17286. switch name {
  17287. }
  17288. return fmt.Errorf("unknown Server unique edge %s", name)
  17289. }
  17290. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17291. // It returns an error if the edge is not defined in the schema.
  17292. func (m *ServerMutation) ResetEdge(name string) error {
  17293. switch name {
  17294. case server.EdgeWxs:
  17295. m.ResetWxs()
  17296. return nil
  17297. }
  17298. return fmt.Errorf("unknown Server edge %s", name)
  17299. }
  17300. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  17301. type SopNodeMutation struct {
  17302. config
  17303. op Op
  17304. typ string
  17305. id *uint64
  17306. created_at *time.Time
  17307. updated_at *time.Time
  17308. status *uint8
  17309. addstatus *int8
  17310. deleted_at *time.Time
  17311. parent_id *uint64
  17312. addparent_id *int64
  17313. name *string
  17314. condition_type *int
  17315. addcondition_type *int
  17316. condition_list *[]string
  17317. appendcondition_list []string
  17318. no_reply_condition *uint64
  17319. addno_reply_condition *int64
  17320. no_reply_unit *string
  17321. action_message *[]custom_types.Action
  17322. appendaction_message []custom_types.Action
  17323. action_label_add *[]uint64
  17324. appendaction_label_add []uint64
  17325. action_label_del *[]uint64
  17326. appendaction_label_del []uint64
  17327. action_forward **custom_types.ActionForward
  17328. clearedFields map[string]struct{}
  17329. sop_stage *uint64
  17330. clearedsop_stage bool
  17331. node_messages map[uint64]struct{}
  17332. removednode_messages map[uint64]struct{}
  17333. clearednode_messages bool
  17334. done bool
  17335. oldValue func(context.Context) (*SopNode, error)
  17336. predicates []predicate.SopNode
  17337. }
  17338. var _ ent.Mutation = (*SopNodeMutation)(nil)
  17339. // sopnodeOption allows management of the mutation configuration using functional options.
  17340. type sopnodeOption func(*SopNodeMutation)
  17341. // newSopNodeMutation creates new mutation for the SopNode entity.
  17342. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  17343. m := &SopNodeMutation{
  17344. config: c,
  17345. op: op,
  17346. typ: TypeSopNode,
  17347. clearedFields: make(map[string]struct{}),
  17348. }
  17349. for _, opt := range opts {
  17350. opt(m)
  17351. }
  17352. return m
  17353. }
  17354. // withSopNodeID sets the ID field of the mutation.
  17355. func withSopNodeID(id uint64) sopnodeOption {
  17356. return func(m *SopNodeMutation) {
  17357. var (
  17358. err error
  17359. once sync.Once
  17360. value *SopNode
  17361. )
  17362. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  17363. once.Do(func() {
  17364. if m.done {
  17365. err = errors.New("querying old values post mutation is not allowed")
  17366. } else {
  17367. value, err = m.Client().SopNode.Get(ctx, id)
  17368. }
  17369. })
  17370. return value, err
  17371. }
  17372. m.id = &id
  17373. }
  17374. }
  17375. // withSopNode sets the old SopNode of the mutation.
  17376. func withSopNode(node *SopNode) sopnodeOption {
  17377. return func(m *SopNodeMutation) {
  17378. m.oldValue = func(context.Context) (*SopNode, error) {
  17379. return node, nil
  17380. }
  17381. m.id = &node.ID
  17382. }
  17383. }
  17384. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17385. // executed in a transaction (ent.Tx), a transactional client is returned.
  17386. func (m SopNodeMutation) Client() *Client {
  17387. client := &Client{config: m.config}
  17388. client.init()
  17389. return client
  17390. }
  17391. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17392. // it returns an error otherwise.
  17393. func (m SopNodeMutation) Tx() (*Tx, error) {
  17394. if _, ok := m.driver.(*txDriver); !ok {
  17395. return nil, errors.New("ent: mutation is not running in a transaction")
  17396. }
  17397. tx := &Tx{config: m.config}
  17398. tx.init()
  17399. return tx, nil
  17400. }
  17401. // SetID sets the value of the id field. Note that this
  17402. // operation is only accepted on creation of SopNode entities.
  17403. func (m *SopNodeMutation) SetID(id uint64) {
  17404. m.id = &id
  17405. }
  17406. // ID returns the ID value in the mutation. Note that the ID is only available
  17407. // if it was provided to the builder or after it was returned from the database.
  17408. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  17409. if m.id == nil {
  17410. return
  17411. }
  17412. return *m.id, true
  17413. }
  17414. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17415. // That means, if the mutation is applied within a transaction with an isolation level such
  17416. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17417. // or updated by the mutation.
  17418. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  17419. switch {
  17420. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17421. id, exists := m.ID()
  17422. if exists {
  17423. return []uint64{id}, nil
  17424. }
  17425. fallthrough
  17426. case m.op.Is(OpUpdate | OpDelete):
  17427. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  17428. default:
  17429. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17430. }
  17431. }
  17432. // SetCreatedAt sets the "created_at" field.
  17433. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  17434. m.created_at = &t
  17435. }
  17436. // CreatedAt returns the value of the "created_at" field in the mutation.
  17437. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  17438. v := m.created_at
  17439. if v == nil {
  17440. return
  17441. }
  17442. return *v, true
  17443. }
  17444. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  17445. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17447. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17448. if !m.op.Is(OpUpdateOne) {
  17449. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17450. }
  17451. if m.id == nil || m.oldValue == nil {
  17452. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17453. }
  17454. oldValue, err := m.oldValue(ctx)
  17455. if err != nil {
  17456. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17457. }
  17458. return oldValue.CreatedAt, nil
  17459. }
  17460. // ResetCreatedAt resets all changes to the "created_at" field.
  17461. func (m *SopNodeMutation) ResetCreatedAt() {
  17462. m.created_at = nil
  17463. }
  17464. // SetUpdatedAt sets the "updated_at" field.
  17465. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  17466. m.updated_at = &t
  17467. }
  17468. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17469. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  17470. v := m.updated_at
  17471. if v == nil {
  17472. return
  17473. }
  17474. return *v, true
  17475. }
  17476. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  17477. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17479. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17480. if !m.op.Is(OpUpdateOne) {
  17481. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17482. }
  17483. if m.id == nil || m.oldValue == nil {
  17484. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17485. }
  17486. oldValue, err := m.oldValue(ctx)
  17487. if err != nil {
  17488. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17489. }
  17490. return oldValue.UpdatedAt, nil
  17491. }
  17492. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17493. func (m *SopNodeMutation) ResetUpdatedAt() {
  17494. m.updated_at = nil
  17495. }
  17496. // SetStatus sets the "status" field.
  17497. func (m *SopNodeMutation) SetStatus(u uint8) {
  17498. m.status = &u
  17499. m.addstatus = nil
  17500. }
  17501. // Status returns the value of the "status" field in the mutation.
  17502. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  17503. v := m.status
  17504. if v == nil {
  17505. return
  17506. }
  17507. return *v, true
  17508. }
  17509. // OldStatus returns the old "status" field's value of the SopNode entity.
  17510. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17512. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17513. if !m.op.Is(OpUpdateOne) {
  17514. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17515. }
  17516. if m.id == nil || m.oldValue == nil {
  17517. return v, errors.New("OldStatus requires an ID field in the mutation")
  17518. }
  17519. oldValue, err := m.oldValue(ctx)
  17520. if err != nil {
  17521. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17522. }
  17523. return oldValue.Status, nil
  17524. }
  17525. // AddStatus adds u to the "status" field.
  17526. func (m *SopNodeMutation) AddStatus(u int8) {
  17527. if m.addstatus != nil {
  17528. *m.addstatus += u
  17529. } else {
  17530. m.addstatus = &u
  17531. }
  17532. }
  17533. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17534. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  17535. v := m.addstatus
  17536. if v == nil {
  17537. return
  17538. }
  17539. return *v, true
  17540. }
  17541. // ClearStatus clears the value of the "status" field.
  17542. func (m *SopNodeMutation) ClearStatus() {
  17543. m.status = nil
  17544. m.addstatus = nil
  17545. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  17546. }
  17547. // StatusCleared returns if the "status" field was cleared in this mutation.
  17548. func (m *SopNodeMutation) StatusCleared() bool {
  17549. _, ok := m.clearedFields[sopnode.FieldStatus]
  17550. return ok
  17551. }
  17552. // ResetStatus resets all changes to the "status" field.
  17553. func (m *SopNodeMutation) ResetStatus() {
  17554. m.status = nil
  17555. m.addstatus = nil
  17556. delete(m.clearedFields, sopnode.FieldStatus)
  17557. }
  17558. // SetDeletedAt sets the "deleted_at" field.
  17559. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  17560. m.deleted_at = &t
  17561. }
  17562. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17563. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  17564. v := m.deleted_at
  17565. if v == nil {
  17566. return
  17567. }
  17568. return *v, true
  17569. }
  17570. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  17571. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17573. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17574. if !m.op.Is(OpUpdateOne) {
  17575. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17576. }
  17577. if m.id == nil || m.oldValue == nil {
  17578. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17579. }
  17580. oldValue, err := m.oldValue(ctx)
  17581. if err != nil {
  17582. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17583. }
  17584. return oldValue.DeletedAt, nil
  17585. }
  17586. // ClearDeletedAt clears the value of the "deleted_at" field.
  17587. func (m *SopNodeMutation) ClearDeletedAt() {
  17588. m.deleted_at = nil
  17589. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  17590. }
  17591. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17592. func (m *SopNodeMutation) DeletedAtCleared() bool {
  17593. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  17594. return ok
  17595. }
  17596. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17597. func (m *SopNodeMutation) ResetDeletedAt() {
  17598. m.deleted_at = nil
  17599. delete(m.clearedFields, sopnode.FieldDeletedAt)
  17600. }
  17601. // SetStageID sets the "stage_id" field.
  17602. func (m *SopNodeMutation) SetStageID(u uint64) {
  17603. m.sop_stage = &u
  17604. }
  17605. // StageID returns the value of the "stage_id" field in the mutation.
  17606. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  17607. v := m.sop_stage
  17608. if v == nil {
  17609. return
  17610. }
  17611. return *v, true
  17612. }
  17613. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  17614. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17616. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  17617. if !m.op.Is(OpUpdateOne) {
  17618. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  17619. }
  17620. if m.id == nil || m.oldValue == nil {
  17621. return v, errors.New("OldStageID requires an ID field in the mutation")
  17622. }
  17623. oldValue, err := m.oldValue(ctx)
  17624. if err != nil {
  17625. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  17626. }
  17627. return oldValue.StageID, nil
  17628. }
  17629. // ResetStageID resets all changes to the "stage_id" field.
  17630. func (m *SopNodeMutation) ResetStageID() {
  17631. m.sop_stage = nil
  17632. }
  17633. // SetParentID sets the "parent_id" field.
  17634. func (m *SopNodeMutation) SetParentID(u uint64) {
  17635. m.parent_id = &u
  17636. m.addparent_id = nil
  17637. }
  17638. // ParentID returns the value of the "parent_id" field in the mutation.
  17639. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  17640. v := m.parent_id
  17641. if v == nil {
  17642. return
  17643. }
  17644. return *v, true
  17645. }
  17646. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  17647. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17649. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  17650. if !m.op.Is(OpUpdateOne) {
  17651. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  17652. }
  17653. if m.id == nil || m.oldValue == nil {
  17654. return v, errors.New("OldParentID requires an ID field in the mutation")
  17655. }
  17656. oldValue, err := m.oldValue(ctx)
  17657. if err != nil {
  17658. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  17659. }
  17660. return oldValue.ParentID, nil
  17661. }
  17662. // AddParentID adds u to the "parent_id" field.
  17663. func (m *SopNodeMutation) AddParentID(u int64) {
  17664. if m.addparent_id != nil {
  17665. *m.addparent_id += u
  17666. } else {
  17667. m.addparent_id = &u
  17668. }
  17669. }
  17670. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  17671. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  17672. v := m.addparent_id
  17673. if v == nil {
  17674. return
  17675. }
  17676. return *v, true
  17677. }
  17678. // ResetParentID resets all changes to the "parent_id" field.
  17679. func (m *SopNodeMutation) ResetParentID() {
  17680. m.parent_id = nil
  17681. m.addparent_id = nil
  17682. }
  17683. // SetName sets the "name" field.
  17684. func (m *SopNodeMutation) SetName(s string) {
  17685. m.name = &s
  17686. }
  17687. // Name returns the value of the "name" field in the mutation.
  17688. func (m *SopNodeMutation) Name() (r string, exists bool) {
  17689. v := m.name
  17690. if v == nil {
  17691. return
  17692. }
  17693. return *v, true
  17694. }
  17695. // OldName returns the old "name" field's value of the SopNode entity.
  17696. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17698. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  17699. if !m.op.Is(OpUpdateOne) {
  17700. return v, errors.New("OldName is only allowed on UpdateOne operations")
  17701. }
  17702. if m.id == nil || m.oldValue == nil {
  17703. return v, errors.New("OldName requires an ID field in the mutation")
  17704. }
  17705. oldValue, err := m.oldValue(ctx)
  17706. if err != nil {
  17707. return v, fmt.Errorf("querying old value for OldName: %w", err)
  17708. }
  17709. return oldValue.Name, nil
  17710. }
  17711. // ResetName resets all changes to the "name" field.
  17712. func (m *SopNodeMutation) ResetName() {
  17713. m.name = nil
  17714. }
  17715. // SetConditionType sets the "condition_type" field.
  17716. func (m *SopNodeMutation) SetConditionType(i int) {
  17717. m.condition_type = &i
  17718. m.addcondition_type = nil
  17719. }
  17720. // ConditionType returns the value of the "condition_type" field in the mutation.
  17721. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  17722. v := m.condition_type
  17723. if v == nil {
  17724. return
  17725. }
  17726. return *v, true
  17727. }
  17728. // OldConditionType returns the old "condition_type" 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) OldConditionType(ctx context.Context) (v int, err error) {
  17732. if !m.op.Is(OpUpdateOne) {
  17733. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  17734. }
  17735. if m.id == nil || m.oldValue == nil {
  17736. return v, errors.New("OldConditionType 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 OldConditionType: %w", err)
  17741. }
  17742. return oldValue.ConditionType, nil
  17743. }
  17744. // AddConditionType adds i to the "condition_type" field.
  17745. func (m *SopNodeMutation) AddConditionType(i int) {
  17746. if m.addcondition_type != nil {
  17747. *m.addcondition_type += i
  17748. } else {
  17749. m.addcondition_type = &i
  17750. }
  17751. }
  17752. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  17753. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  17754. v := m.addcondition_type
  17755. if v == nil {
  17756. return
  17757. }
  17758. return *v, true
  17759. }
  17760. // ResetConditionType resets all changes to the "condition_type" field.
  17761. func (m *SopNodeMutation) ResetConditionType() {
  17762. m.condition_type = nil
  17763. m.addcondition_type = nil
  17764. }
  17765. // SetConditionList sets the "condition_list" field.
  17766. func (m *SopNodeMutation) SetConditionList(s []string) {
  17767. m.condition_list = &s
  17768. m.appendcondition_list = nil
  17769. }
  17770. // ConditionList returns the value of the "condition_list" field in the mutation.
  17771. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  17772. v := m.condition_list
  17773. if v == nil {
  17774. return
  17775. }
  17776. return *v, true
  17777. }
  17778. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  17779. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17781. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  17782. if !m.op.Is(OpUpdateOne) {
  17783. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  17784. }
  17785. if m.id == nil || m.oldValue == nil {
  17786. return v, errors.New("OldConditionList requires an ID field in the mutation")
  17787. }
  17788. oldValue, err := m.oldValue(ctx)
  17789. if err != nil {
  17790. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  17791. }
  17792. return oldValue.ConditionList, nil
  17793. }
  17794. // AppendConditionList adds s to the "condition_list" field.
  17795. func (m *SopNodeMutation) AppendConditionList(s []string) {
  17796. m.appendcondition_list = append(m.appendcondition_list, s...)
  17797. }
  17798. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  17799. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  17800. if len(m.appendcondition_list) == 0 {
  17801. return nil, false
  17802. }
  17803. return m.appendcondition_list, true
  17804. }
  17805. // ClearConditionList clears the value of the "condition_list" field.
  17806. func (m *SopNodeMutation) ClearConditionList() {
  17807. m.condition_list = nil
  17808. m.appendcondition_list = nil
  17809. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  17810. }
  17811. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  17812. func (m *SopNodeMutation) ConditionListCleared() bool {
  17813. _, ok := m.clearedFields[sopnode.FieldConditionList]
  17814. return ok
  17815. }
  17816. // ResetConditionList resets all changes to the "condition_list" field.
  17817. func (m *SopNodeMutation) ResetConditionList() {
  17818. m.condition_list = nil
  17819. m.appendcondition_list = nil
  17820. delete(m.clearedFields, sopnode.FieldConditionList)
  17821. }
  17822. // SetNoReplyCondition sets the "no_reply_condition" field.
  17823. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  17824. m.no_reply_condition = &u
  17825. m.addno_reply_condition = nil
  17826. }
  17827. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  17828. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  17829. v := m.no_reply_condition
  17830. if v == nil {
  17831. return
  17832. }
  17833. return *v, true
  17834. }
  17835. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  17836. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17838. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  17839. if !m.op.Is(OpUpdateOne) {
  17840. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  17841. }
  17842. if m.id == nil || m.oldValue == nil {
  17843. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  17844. }
  17845. oldValue, err := m.oldValue(ctx)
  17846. if err != nil {
  17847. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  17848. }
  17849. return oldValue.NoReplyCondition, nil
  17850. }
  17851. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  17852. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  17853. if m.addno_reply_condition != nil {
  17854. *m.addno_reply_condition += u
  17855. } else {
  17856. m.addno_reply_condition = &u
  17857. }
  17858. }
  17859. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  17860. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  17861. v := m.addno_reply_condition
  17862. if v == nil {
  17863. return
  17864. }
  17865. return *v, true
  17866. }
  17867. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  17868. func (m *SopNodeMutation) ResetNoReplyCondition() {
  17869. m.no_reply_condition = nil
  17870. m.addno_reply_condition = nil
  17871. }
  17872. // SetNoReplyUnit sets the "no_reply_unit" field.
  17873. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  17874. m.no_reply_unit = &s
  17875. }
  17876. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  17877. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  17878. v := m.no_reply_unit
  17879. if v == nil {
  17880. return
  17881. }
  17882. return *v, true
  17883. }
  17884. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  17885. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17887. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  17888. if !m.op.Is(OpUpdateOne) {
  17889. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  17890. }
  17891. if m.id == nil || m.oldValue == nil {
  17892. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  17893. }
  17894. oldValue, err := m.oldValue(ctx)
  17895. if err != nil {
  17896. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  17897. }
  17898. return oldValue.NoReplyUnit, nil
  17899. }
  17900. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  17901. func (m *SopNodeMutation) ResetNoReplyUnit() {
  17902. m.no_reply_unit = nil
  17903. }
  17904. // SetActionMessage sets the "action_message" field.
  17905. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  17906. m.action_message = &ct
  17907. m.appendaction_message = nil
  17908. }
  17909. // ActionMessage returns the value of the "action_message" field in the mutation.
  17910. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  17911. v := m.action_message
  17912. if v == nil {
  17913. return
  17914. }
  17915. return *v, true
  17916. }
  17917. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  17918. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17920. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  17921. if !m.op.Is(OpUpdateOne) {
  17922. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  17923. }
  17924. if m.id == nil || m.oldValue == nil {
  17925. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  17926. }
  17927. oldValue, err := m.oldValue(ctx)
  17928. if err != nil {
  17929. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  17930. }
  17931. return oldValue.ActionMessage, nil
  17932. }
  17933. // AppendActionMessage adds ct to the "action_message" field.
  17934. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  17935. m.appendaction_message = append(m.appendaction_message, ct...)
  17936. }
  17937. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  17938. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  17939. if len(m.appendaction_message) == 0 {
  17940. return nil, false
  17941. }
  17942. return m.appendaction_message, true
  17943. }
  17944. // ClearActionMessage clears the value of the "action_message" field.
  17945. func (m *SopNodeMutation) ClearActionMessage() {
  17946. m.action_message = nil
  17947. m.appendaction_message = nil
  17948. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  17949. }
  17950. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  17951. func (m *SopNodeMutation) ActionMessageCleared() bool {
  17952. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  17953. return ok
  17954. }
  17955. // ResetActionMessage resets all changes to the "action_message" field.
  17956. func (m *SopNodeMutation) ResetActionMessage() {
  17957. m.action_message = nil
  17958. m.appendaction_message = nil
  17959. delete(m.clearedFields, sopnode.FieldActionMessage)
  17960. }
  17961. // SetActionLabelAdd sets the "action_label_add" field.
  17962. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  17963. m.action_label_add = &u
  17964. m.appendaction_label_add = nil
  17965. }
  17966. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17967. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17968. v := m.action_label_add
  17969. if v == nil {
  17970. return
  17971. }
  17972. return *v, true
  17973. }
  17974. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  17975. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17977. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17978. if !m.op.Is(OpUpdateOne) {
  17979. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17980. }
  17981. if m.id == nil || m.oldValue == nil {
  17982. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17983. }
  17984. oldValue, err := m.oldValue(ctx)
  17985. if err != nil {
  17986. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17987. }
  17988. return oldValue.ActionLabelAdd, nil
  17989. }
  17990. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17991. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  17992. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17993. }
  17994. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17995. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17996. if len(m.appendaction_label_add) == 0 {
  17997. return nil, false
  17998. }
  17999. return m.appendaction_label_add, true
  18000. }
  18001. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  18002. func (m *SopNodeMutation) ClearActionLabelAdd() {
  18003. m.action_label_add = nil
  18004. m.appendaction_label_add = nil
  18005. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  18006. }
  18007. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  18008. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  18009. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  18010. return ok
  18011. }
  18012. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  18013. func (m *SopNodeMutation) ResetActionLabelAdd() {
  18014. m.action_label_add = nil
  18015. m.appendaction_label_add = nil
  18016. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  18017. }
  18018. // SetActionLabelDel sets the "action_label_del" field.
  18019. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  18020. m.action_label_del = &u
  18021. m.appendaction_label_del = nil
  18022. }
  18023. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18024. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  18025. v := m.action_label_del
  18026. if v == nil {
  18027. return
  18028. }
  18029. return *v, true
  18030. }
  18031. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  18032. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18034. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18035. if !m.op.Is(OpUpdateOne) {
  18036. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18037. }
  18038. if m.id == nil || m.oldValue == nil {
  18039. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18040. }
  18041. oldValue, err := m.oldValue(ctx)
  18042. if err != nil {
  18043. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18044. }
  18045. return oldValue.ActionLabelDel, nil
  18046. }
  18047. // AppendActionLabelDel adds u to the "action_label_del" field.
  18048. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  18049. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18050. }
  18051. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18052. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18053. if len(m.appendaction_label_del) == 0 {
  18054. return nil, false
  18055. }
  18056. return m.appendaction_label_del, true
  18057. }
  18058. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18059. func (m *SopNodeMutation) ClearActionLabelDel() {
  18060. m.action_label_del = nil
  18061. m.appendaction_label_del = nil
  18062. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  18063. }
  18064. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18065. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  18066. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  18067. return ok
  18068. }
  18069. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18070. func (m *SopNodeMutation) ResetActionLabelDel() {
  18071. m.action_label_del = nil
  18072. m.appendaction_label_del = nil
  18073. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  18074. }
  18075. // SetActionForward sets the "action_forward" field.
  18076. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  18077. m.action_forward = &ctf
  18078. }
  18079. // ActionForward returns the value of the "action_forward" field in the mutation.
  18080. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  18081. v := m.action_forward
  18082. if v == nil {
  18083. return
  18084. }
  18085. return *v, true
  18086. }
  18087. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  18088. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18090. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  18091. if !m.op.Is(OpUpdateOne) {
  18092. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  18093. }
  18094. if m.id == nil || m.oldValue == nil {
  18095. return v, errors.New("OldActionForward requires an ID field in the mutation")
  18096. }
  18097. oldValue, err := m.oldValue(ctx)
  18098. if err != nil {
  18099. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  18100. }
  18101. return oldValue.ActionForward, nil
  18102. }
  18103. // ClearActionForward clears the value of the "action_forward" field.
  18104. func (m *SopNodeMutation) ClearActionForward() {
  18105. m.action_forward = nil
  18106. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  18107. }
  18108. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  18109. func (m *SopNodeMutation) ActionForwardCleared() bool {
  18110. _, ok := m.clearedFields[sopnode.FieldActionForward]
  18111. return ok
  18112. }
  18113. // ResetActionForward resets all changes to the "action_forward" field.
  18114. func (m *SopNodeMutation) ResetActionForward() {
  18115. m.action_forward = nil
  18116. delete(m.clearedFields, sopnode.FieldActionForward)
  18117. }
  18118. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  18119. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  18120. m.sop_stage = &id
  18121. }
  18122. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  18123. func (m *SopNodeMutation) ClearSopStage() {
  18124. m.clearedsop_stage = true
  18125. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  18126. }
  18127. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  18128. func (m *SopNodeMutation) SopStageCleared() bool {
  18129. return m.clearedsop_stage
  18130. }
  18131. // SopStageID returns the "sop_stage" edge ID in the mutation.
  18132. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  18133. if m.sop_stage != nil {
  18134. return *m.sop_stage, true
  18135. }
  18136. return
  18137. }
  18138. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  18139. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18140. // SopStageID instead. It exists only for internal usage by the builders.
  18141. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  18142. if id := m.sop_stage; id != nil {
  18143. ids = append(ids, *id)
  18144. }
  18145. return
  18146. }
  18147. // ResetSopStage resets all changes to the "sop_stage" edge.
  18148. func (m *SopNodeMutation) ResetSopStage() {
  18149. m.sop_stage = nil
  18150. m.clearedsop_stage = false
  18151. }
  18152. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  18153. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  18154. if m.node_messages == nil {
  18155. m.node_messages = make(map[uint64]struct{})
  18156. }
  18157. for i := range ids {
  18158. m.node_messages[ids[i]] = struct{}{}
  18159. }
  18160. }
  18161. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  18162. func (m *SopNodeMutation) ClearNodeMessages() {
  18163. m.clearednode_messages = true
  18164. }
  18165. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  18166. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  18167. return m.clearednode_messages
  18168. }
  18169. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  18170. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  18171. if m.removednode_messages == nil {
  18172. m.removednode_messages = make(map[uint64]struct{})
  18173. }
  18174. for i := range ids {
  18175. delete(m.node_messages, ids[i])
  18176. m.removednode_messages[ids[i]] = struct{}{}
  18177. }
  18178. }
  18179. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  18180. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  18181. for id := range m.removednode_messages {
  18182. ids = append(ids, id)
  18183. }
  18184. return
  18185. }
  18186. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  18187. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  18188. for id := range m.node_messages {
  18189. ids = append(ids, id)
  18190. }
  18191. return
  18192. }
  18193. // ResetNodeMessages resets all changes to the "node_messages" edge.
  18194. func (m *SopNodeMutation) ResetNodeMessages() {
  18195. m.node_messages = nil
  18196. m.clearednode_messages = false
  18197. m.removednode_messages = nil
  18198. }
  18199. // Where appends a list predicates to the SopNodeMutation builder.
  18200. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  18201. m.predicates = append(m.predicates, ps...)
  18202. }
  18203. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  18204. // users can use type-assertion to append predicates that do not depend on any generated package.
  18205. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  18206. p := make([]predicate.SopNode, len(ps))
  18207. for i := range ps {
  18208. p[i] = ps[i]
  18209. }
  18210. m.Where(p...)
  18211. }
  18212. // Op returns the operation name.
  18213. func (m *SopNodeMutation) Op() Op {
  18214. return m.op
  18215. }
  18216. // SetOp allows setting the mutation operation.
  18217. func (m *SopNodeMutation) SetOp(op Op) {
  18218. m.op = op
  18219. }
  18220. // Type returns the node type of this mutation (SopNode).
  18221. func (m *SopNodeMutation) Type() string {
  18222. return m.typ
  18223. }
  18224. // Fields returns all fields that were changed during this mutation. Note that in
  18225. // order to get all numeric fields that were incremented/decremented, call
  18226. // AddedFields().
  18227. func (m *SopNodeMutation) Fields() []string {
  18228. fields := make([]string, 0, 15)
  18229. if m.created_at != nil {
  18230. fields = append(fields, sopnode.FieldCreatedAt)
  18231. }
  18232. if m.updated_at != nil {
  18233. fields = append(fields, sopnode.FieldUpdatedAt)
  18234. }
  18235. if m.status != nil {
  18236. fields = append(fields, sopnode.FieldStatus)
  18237. }
  18238. if m.deleted_at != nil {
  18239. fields = append(fields, sopnode.FieldDeletedAt)
  18240. }
  18241. if m.sop_stage != nil {
  18242. fields = append(fields, sopnode.FieldStageID)
  18243. }
  18244. if m.parent_id != nil {
  18245. fields = append(fields, sopnode.FieldParentID)
  18246. }
  18247. if m.name != nil {
  18248. fields = append(fields, sopnode.FieldName)
  18249. }
  18250. if m.condition_type != nil {
  18251. fields = append(fields, sopnode.FieldConditionType)
  18252. }
  18253. if m.condition_list != nil {
  18254. fields = append(fields, sopnode.FieldConditionList)
  18255. }
  18256. if m.no_reply_condition != nil {
  18257. fields = append(fields, sopnode.FieldNoReplyCondition)
  18258. }
  18259. if m.no_reply_unit != nil {
  18260. fields = append(fields, sopnode.FieldNoReplyUnit)
  18261. }
  18262. if m.action_message != nil {
  18263. fields = append(fields, sopnode.FieldActionMessage)
  18264. }
  18265. if m.action_label_add != nil {
  18266. fields = append(fields, sopnode.FieldActionLabelAdd)
  18267. }
  18268. if m.action_label_del != nil {
  18269. fields = append(fields, sopnode.FieldActionLabelDel)
  18270. }
  18271. if m.action_forward != nil {
  18272. fields = append(fields, sopnode.FieldActionForward)
  18273. }
  18274. return fields
  18275. }
  18276. // Field returns the value of a field with the given name. The second boolean
  18277. // return value indicates that this field was not set, or was not defined in the
  18278. // schema.
  18279. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  18280. switch name {
  18281. case sopnode.FieldCreatedAt:
  18282. return m.CreatedAt()
  18283. case sopnode.FieldUpdatedAt:
  18284. return m.UpdatedAt()
  18285. case sopnode.FieldStatus:
  18286. return m.Status()
  18287. case sopnode.FieldDeletedAt:
  18288. return m.DeletedAt()
  18289. case sopnode.FieldStageID:
  18290. return m.StageID()
  18291. case sopnode.FieldParentID:
  18292. return m.ParentID()
  18293. case sopnode.FieldName:
  18294. return m.Name()
  18295. case sopnode.FieldConditionType:
  18296. return m.ConditionType()
  18297. case sopnode.FieldConditionList:
  18298. return m.ConditionList()
  18299. case sopnode.FieldNoReplyCondition:
  18300. return m.NoReplyCondition()
  18301. case sopnode.FieldNoReplyUnit:
  18302. return m.NoReplyUnit()
  18303. case sopnode.FieldActionMessage:
  18304. return m.ActionMessage()
  18305. case sopnode.FieldActionLabelAdd:
  18306. return m.ActionLabelAdd()
  18307. case sopnode.FieldActionLabelDel:
  18308. return m.ActionLabelDel()
  18309. case sopnode.FieldActionForward:
  18310. return m.ActionForward()
  18311. }
  18312. return nil, false
  18313. }
  18314. // OldField returns the old value of the field from the database. An error is
  18315. // returned if the mutation operation is not UpdateOne, or the query to the
  18316. // database failed.
  18317. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18318. switch name {
  18319. case sopnode.FieldCreatedAt:
  18320. return m.OldCreatedAt(ctx)
  18321. case sopnode.FieldUpdatedAt:
  18322. return m.OldUpdatedAt(ctx)
  18323. case sopnode.FieldStatus:
  18324. return m.OldStatus(ctx)
  18325. case sopnode.FieldDeletedAt:
  18326. return m.OldDeletedAt(ctx)
  18327. case sopnode.FieldStageID:
  18328. return m.OldStageID(ctx)
  18329. case sopnode.FieldParentID:
  18330. return m.OldParentID(ctx)
  18331. case sopnode.FieldName:
  18332. return m.OldName(ctx)
  18333. case sopnode.FieldConditionType:
  18334. return m.OldConditionType(ctx)
  18335. case sopnode.FieldConditionList:
  18336. return m.OldConditionList(ctx)
  18337. case sopnode.FieldNoReplyCondition:
  18338. return m.OldNoReplyCondition(ctx)
  18339. case sopnode.FieldNoReplyUnit:
  18340. return m.OldNoReplyUnit(ctx)
  18341. case sopnode.FieldActionMessage:
  18342. return m.OldActionMessage(ctx)
  18343. case sopnode.FieldActionLabelAdd:
  18344. return m.OldActionLabelAdd(ctx)
  18345. case sopnode.FieldActionLabelDel:
  18346. return m.OldActionLabelDel(ctx)
  18347. case sopnode.FieldActionForward:
  18348. return m.OldActionForward(ctx)
  18349. }
  18350. return nil, fmt.Errorf("unknown SopNode field %s", name)
  18351. }
  18352. // SetField sets the value of a field with the given name. It returns an error if
  18353. // the field is not defined in the schema, or if the type mismatched the field
  18354. // type.
  18355. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  18356. switch name {
  18357. case sopnode.FieldCreatedAt:
  18358. v, ok := value.(time.Time)
  18359. if !ok {
  18360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18361. }
  18362. m.SetCreatedAt(v)
  18363. return nil
  18364. case sopnode.FieldUpdatedAt:
  18365. v, ok := value.(time.Time)
  18366. if !ok {
  18367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18368. }
  18369. m.SetUpdatedAt(v)
  18370. return nil
  18371. case sopnode.FieldStatus:
  18372. v, ok := value.(uint8)
  18373. if !ok {
  18374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18375. }
  18376. m.SetStatus(v)
  18377. return nil
  18378. case sopnode.FieldDeletedAt:
  18379. v, ok := value.(time.Time)
  18380. if !ok {
  18381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18382. }
  18383. m.SetDeletedAt(v)
  18384. return nil
  18385. case sopnode.FieldStageID:
  18386. v, ok := value.(uint64)
  18387. if !ok {
  18388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18389. }
  18390. m.SetStageID(v)
  18391. return nil
  18392. case sopnode.FieldParentID:
  18393. v, ok := value.(uint64)
  18394. if !ok {
  18395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18396. }
  18397. m.SetParentID(v)
  18398. return nil
  18399. case sopnode.FieldName:
  18400. v, ok := value.(string)
  18401. if !ok {
  18402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18403. }
  18404. m.SetName(v)
  18405. return nil
  18406. case sopnode.FieldConditionType:
  18407. v, ok := value.(int)
  18408. if !ok {
  18409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18410. }
  18411. m.SetConditionType(v)
  18412. return nil
  18413. case sopnode.FieldConditionList:
  18414. v, ok := value.([]string)
  18415. if !ok {
  18416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18417. }
  18418. m.SetConditionList(v)
  18419. return nil
  18420. case sopnode.FieldNoReplyCondition:
  18421. v, ok := value.(uint64)
  18422. if !ok {
  18423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18424. }
  18425. m.SetNoReplyCondition(v)
  18426. return nil
  18427. case sopnode.FieldNoReplyUnit:
  18428. v, ok := value.(string)
  18429. if !ok {
  18430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18431. }
  18432. m.SetNoReplyUnit(v)
  18433. return nil
  18434. case sopnode.FieldActionMessage:
  18435. v, ok := value.([]custom_types.Action)
  18436. if !ok {
  18437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18438. }
  18439. m.SetActionMessage(v)
  18440. return nil
  18441. case sopnode.FieldActionLabelAdd:
  18442. v, ok := value.([]uint64)
  18443. if !ok {
  18444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18445. }
  18446. m.SetActionLabelAdd(v)
  18447. return nil
  18448. case sopnode.FieldActionLabelDel:
  18449. v, ok := value.([]uint64)
  18450. if !ok {
  18451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18452. }
  18453. m.SetActionLabelDel(v)
  18454. return nil
  18455. case sopnode.FieldActionForward:
  18456. v, ok := value.(*custom_types.ActionForward)
  18457. if !ok {
  18458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18459. }
  18460. m.SetActionForward(v)
  18461. return nil
  18462. }
  18463. return fmt.Errorf("unknown SopNode field %s", name)
  18464. }
  18465. // AddedFields returns all numeric fields that were incremented/decremented during
  18466. // this mutation.
  18467. func (m *SopNodeMutation) AddedFields() []string {
  18468. var fields []string
  18469. if m.addstatus != nil {
  18470. fields = append(fields, sopnode.FieldStatus)
  18471. }
  18472. if m.addparent_id != nil {
  18473. fields = append(fields, sopnode.FieldParentID)
  18474. }
  18475. if m.addcondition_type != nil {
  18476. fields = append(fields, sopnode.FieldConditionType)
  18477. }
  18478. if m.addno_reply_condition != nil {
  18479. fields = append(fields, sopnode.FieldNoReplyCondition)
  18480. }
  18481. return fields
  18482. }
  18483. // AddedField returns the numeric value that was incremented/decremented on a field
  18484. // with the given name. The second boolean return value indicates that this field
  18485. // was not set, or was not defined in the schema.
  18486. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  18487. switch name {
  18488. case sopnode.FieldStatus:
  18489. return m.AddedStatus()
  18490. case sopnode.FieldParentID:
  18491. return m.AddedParentID()
  18492. case sopnode.FieldConditionType:
  18493. return m.AddedConditionType()
  18494. case sopnode.FieldNoReplyCondition:
  18495. return m.AddedNoReplyCondition()
  18496. }
  18497. return nil, false
  18498. }
  18499. // AddField adds the value to the field with the given name. It returns an error if
  18500. // the field is not defined in the schema, or if the type mismatched the field
  18501. // type.
  18502. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  18503. switch name {
  18504. case sopnode.FieldStatus:
  18505. v, ok := value.(int8)
  18506. if !ok {
  18507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18508. }
  18509. m.AddStatus(v)
  18510. return nil
  18511. case sopnode.FieldParentID:
  18512. v, ok := value.(int64)
  18513. if !ok {
  18514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18515. }
  18516. m.AddParentID(v)
  18517. return nil
  18518. case sopnode.FieldConditionType:
  18519. v, ok := value.(int)
  18520. if !ok {
  18521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18522. }
  18523. m.AddConditionType(v)
  18524. return nil
  18525. case sopnode.FieldNoReplyCondition:
  18526. v, ok := value.(int64)
  18527. if !ok {
  18528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18529. }
  18530. m.AddNoReplyCondition(v)
  18531. return nil
  18532. }
  18533. return fmt.Errorf("unknown SopNode numeric field %s", name)
  18534. }
  18535. // ClearedFields returns all nullable fields that were cleared during this
  18536. // mutation.
  18537. func (m *SopNodeMutation) ClearedFields() []string {
  18538. var fields []string
  18539. if m.FieldCleared(sopnode.FieldStatus) {
  18540. fields = append(fields, sopnode.FieldStatus)
  18541. }
  18542. if m.FieldCleared(sopnode.FieldDeletedAt) {
  18543. fields = append(fields, sopnode.FieldDeletedAt)
  18544. }
  18545. if m.FieldCleared(sopnode.FieldConditionList) {
  18546. fields = append(fields, sopnode.FieldConditionList)
  18547. }
  18548. if m.FieldCleared(sopnode.FieldActionMessage) {
  18549. fields = append(fields, sopnode.FieldActionMessage)
  18550. }
  18551. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  18552. fields = append(fields, sopnode.FieldActionLabelAdd)
  18553. }
  18554. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  18555. fields = append(fields, sopnode.FieldActionLabelDel)
  18556. }
  18557. if m.FieldCleared(sopnode.FieldActionForward) {
  18558. fields = append(fields, sopnode.FieldActionForward)
  18559. }
  18560. return fields
  18561. }
  18562. // FieldCleared returns a boolean indicating if a field with the given name was
  18563. // cleared in this mutation.
  18564. func (m *SopNodeMutation) FieldCleared(name string) bool {
  18565. _, ok := m.clearedFields[name]
  18566. return ok
  18567. }
  18568. // ClearField clears the value of the field with the given name. It returns an
  18569. // error if the field is not defined in the schema.
  18570. func (m *SopNodeMutation) ClearField(name string) error {
  18571. switch name {
  18572. case sopnode.FieldStatus:
  18573. m.ClearStatus()
  18574. return nil
  18575. case sopnode.FieldDeletedAt:
  18576. m.ClearDeletedAt()
  18577. return nil
  18578. case sopnode.FieldConditionList:
  18579. m.ClearConditionList()
  18580. return nil
  18581. case sopnode.FieldActionMessage:
  18582. m.ClearActionMessage()
  18583. return nil
  18584. case sopnode.FieldActionLabelAdd:
  18585. m.ClearActionLabelAdd()
  18586. return nil
  18587. case sopnode.FieldActionLabelDel:
  18588. m.ClearActionLabelDel()
  18589. return nil
  18590. case sopnode.FieldActionForward:
  18591. m.ClearActionForward()
  18592. return nil
  18593. }
  18594. return fmt.Errorf("unknown SopNode nullable field %s", name)
  18595. }
  18596. // ResetField resets all changes in the mutation for the field with the given name.
  18597. // It returns an error if the field is not defined in the schema.
  18598. func (m *SopNodeMutation) ResetField(name string) error {
  18599. switch name {
  18600. case sopnode.FieldCreatedAt:
  18601. m.ResetCreatedAt()
  18602. return nil
  18603. case sopnode.FieldUpdatedAt:
  18604. m.ResetUpdatedAt()
  18605. return nil
  18606. case sopnode.FieldStatus:
  18607. m.ResetStatus()
  18608. return nil
  18609. case sopnode.FieldDeletedAt:
  18610. m.ResetDeletedAt()
  18611. return nil
  18612. case sopnode.FieldStageID:
  18613. m.ResetStageID()
  18614. return nil
  18615. case sopnode.FieldParentID:
  18616. m.ResetParentID()
  18617. return nil
  18618. case sopnode.FieldName:
  18619. m.ResetName()
  18620. return nil
  18621. case sopnode.FieldConditionType:
  18622. m.ResetConditionType()
  18623. return nil
  18624. case sopnode.FieldConditionList:
  18625. m.ResetConditionList()
  18626. return nil
  18627. case sopnode.FieldNoReplyCondition:
  18628. m.ResetNoReplyCondition()
  18629. return nil
  18630. case sopnode.FieldNoReplyUnit:
  18631. m.ResetNoReplyUnit()
  18632. return nil
  18633. case sopnode.FieldActionMessage:
  18634. m.ResetActionMessage()
  18635. return nil
  18636. case sopnode.FieldActionLabelAdd:
  18637. m.ResetActionLabelAdd()
  18638. return nil
  18639. case sopnode.FieldActionLabelDel:
  18640. m.ResetActionLabelDel()
  18641. return nil
  18642. case sopnode.FieldActionForward:
  18643. m.ResetActionForward()
  18644. return nil
  18645. }
  18646. return fmt.Errorf("unknown SopNode field %s", name)
  18647. }
  18648. // AddedEdges returns all edge names that were set/added in this mutation.
  18649. func (m *SopNodeMutation) AddedEdges() []string {
  18650. edges := make([]string, 0, 2)
  18651. if m.sop_stage != nil {
  18652. edges = append(edges, sopnode.EdgeSopStage)
  18653. }
  18654. if m.node_messages != nil {
  18655. edges = append(edges, sopnode.EdgeNodeMessages)
  18656. }
  18657. return edges
  18658. }
  18659. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18660. // name in this mutation.
  18661. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  18662. switch name {
  18663. case sopnode.EdgeSopStage:
  18664. if id := m.sop_stage; id != nil {
  18665. return []ent.Value{*id}
  18666. }
  18667. case sopnode.EdgeNodeMessages:
  18668. ids := make([]ent.Value, 0, len(m.node_messages))
  18669. for id := range m.node_messages {
  18670. ids = append(ids, id)
  18671. }
  18672. return ids
  18673. }
  18674. return nil
  18675. }
  18676. // RemovedEdges returns all edge names that were removed in this mutation.
  18677. func (m *SopNodeMutation) RemovedEdges() []string {
  18678. edges := make([]string, 0, 2)
  18679. if m.removednode_messages != nil {
  18680. edges = append(edges, sopnode.EdgeNodeMessages)
  18681. }
  18682. return edges
  18683. }
  18684. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18685. // the given name in this mutation.
  18686. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  18687. switch name {
  18688. case sopnode.EdgeNodeMessages:
  18689. ids := make([]ent.Value, 0, len(m.removednode_messages))
  18690. for id := range m.removednode_messages {
  18691. ids = append(ids, id)
  18692. }
  18693. return ids
  18694. }
  18695. return nil
  18696. }
  18697. // ClearedEdges returns all edge names that were cleared in this mutation.
  18698. func (m *SopNodeMutation) ClearedEdges() []string {
  18699. edges := make([]string, 0, 2)
  18700. if m.clearedsop_stage {
  18701. edges = append(edges, sopnode.EdgeSopStage)
  18702. }
  18703. if m.clearednode_messages {
  18704. edges = append(edges, sopnode.EdgeNodeMessages)
  18705. }
  18706. return edges
  18707. }
  18708. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18709. // was cleared in this mutation.
  18710. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  18711. switch name {
  18712. case sopnode.EdgeSopStage:
  18713. return m.clearedsop_stage
  18714. case sopnode.EdgeNodeMessages:
  18715. return m.clearednode_messages
  18716. }
  18717. return false
  18718. }
  18719. // ClearEdge clears the value of the edge with the given name. It returns an error
  18720. // if that edge is not defined in the schema.
  18721. func (m *SopNodeMutation) ClearEdge(name string) error {
  18722. switch name {
  18723. case sopnode.EdgeSopStage:
  18724. m.ClearSopStage()
  18725. return nil
  18726. }
  18727. return fmt.Errorf("unknown SopNode unique edge %s", name)
  18728. }
  18729. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18730. // It returns an error if the edge is not defined in the schema.
  18731. func (m *SopNodeMutation) ResetEdge(name string) error {
  18732. switch name {
  18733. case sopnode.EdgeSopStage:
  18734. m.ResetSopStage()
  18735. return nil
  18736. case sopnode.EdgeNodeMessages:
  18737. m.ResetNodeMessages()
  18738. return nil
  18739. }
  18740. return fmt.Errorf("unknown SopNode edge %s", name)
  18741. }
  18742. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  18743. type SopStageMutation struct {
  18744. config
  18745. op Op
  18746. typ string
  18747. id *uint64
  18748. created_at *time.Time
  18749. updated_at *time.Time
  18750. status *uint8
  18751. addstatus *int8
  18752. deleted_at *time.Time
  18753. name *string
  18754. condition_type *int
  18755. addcondition_type *int
  18756. condition_operator *int
  18757. addcondition_operator *int
  18758. condition_list *[]custom_types.Condition
  18759. appendcondition_list []custom_types.Condition
  18760. action_message *[]custom_types.Action
  18761. appendaction_message []custom_types.Action
  18762. action_label_add *[]uint64
  18763. appendaction_label_add []uint64
  18764. action_label_del *[]uint64
  18765. appendaction_label_del []uint64
  18766. action_forward **custom_types.ActionForward
  18767. index_sort *int
  18768. addindex_sort *int
  18769. clearedFields map[string]struct{}
  18770. sop_task *uint64
  18771. clearedsop_task bool
  18772. stage_nodes map[uint64]struct{}
  18773. removedstage_nodes map[uint64]struct{}
  18774. clearedstage_nodes bool
  18775. stage_messages map[uint64]struct{}
  18776. removedstage_messages map[uint64]struct{}
  18777. clearedstage_messages bool
  18778. done bool
  18779. oldValue func(context.Context) (*SopStage, error)
  18780. predicates []predicate.SopStage
  18781. }
  18782. var _ ent.Mutation = (*SopStageMutation)(nil)
  18783. // sopstageOption allows management of the mutation configuration using functional options.
  18784. type sopstageOption func(*SopStageMutation)
  18785. // newSopStageMutation creates new mutation for the SopStage entity.
  18786. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  18787. m := &SopStageMutation{
  18788. config: c,
  18789. op: op,
  18790. typ: TypeSopStage,
  18791. clearedFields: make(map[string]struct{}),
  18792. }
  18793. for _, opt := range opts {
  18794. opt(m)
  18795. }
  18796. return m
  18797. }
  18798. // withSopStageID sets the ID field of the mutation.
  18799. func withSopStageID(id uint64) sopstageOption {
  18800. return func(m *SopStageMutation) {
  18801. var (
  18802. err error
  18803. once sync.Once
  18804. value *SopStage
  18805. )
  18806. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  18807. once.Do(func() {
  18808. if m.done {
  18809. err = errors.New("querying old values post mutation is not allowed")
  18810. } else {
  18811. value, err = m.Client().SopStage.Get(ctx, id)
  18812. }
  18813. })
  18814. return value, err
  18815. }
  18816. m.id = &id
  18817. }
  18818. }
  18819. // withSopStage sets the old SopStage of the mutation.
  18820. func withSopStage(node *SopStage) sopstageOption {
  18821. return func(m *SopStageMutation) {
  18822. m.oldValue = func(context.Context) (*SopStage, error) {
  18823. return node, nil
  18824. }
  18825. m.id = &node.ID
  18826. }
  18827. }
  18828. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18829. // executed in a transaction (ent.Tx), a transactional client is returned.
  18830. func (m SopStageMutation) Client() *Client {
  18831. client := &Client{config: m.config}
  18832. client.init()
  18833. return client
  18834. }
  18835. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18836. // it returns an error otherwise.
  18837. func (m SopStageMutation) Tx() (*Tx, error) {
  18838. if _, ok := m.driver.(*txDriver); !ok {
  18839. return nil, errors.New("ent: mutation is not running in a transaction")
  18840. }
  18841. tx := &Tx{config: m.config}
  18842. tx.init()
  18843. return tx, nil
  18844. }
  18845. // SetID sets the value of the id field. Note that this
  18846. // operation is only accepted on creation of SopStage entities.
  18847. func (m *SopStageMutation) SetID(id uint64) {
  18848. m.id = &id
  18849. }
  18850. // ID returns the ID value in the mutation. Note that the ID is only available
  18851. // if it was provided to the builder or after it was returned from the database.
  18852. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  18853. if m.id == nil {
  18854. return
  18855. }
  18856. return *m.id, true
  18857. }
  18858. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18859. // That means, if the mutation is applied within a transaction with an isolation level such
  18860. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18861. // or updated by the mutation.
  18862. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  18863. switch {
  18864. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18865. id, exists := m.ID()
  18866. if exists {
  18867. return []uint64{id}, nil
  18868. }
  18869. fallthrough
  18870. case m.op.Is(OpUpdate | OpDelete):
  18871. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  18872. default:
  18873. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18874. }
  18875. }
  18876. // SetCreatedAt sets the "created_at" field.
  18877. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  18878. m.created_at = &t
  18879. }
  18880. // CreatedAt returns the value of the "created_at" field in the mutation.
  18881. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  18882. v := m.created_at
  18883. if v == nil {
  18884. return
  18885. }
  18886. return *v, true
  18887. }
  18888. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  18889. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18891. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18892. if !m.op.Is(OpUpdateOne) {
  18893. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18894. }
  18895. if m.id == nil || m.oldValue == nil {
  18896. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18897. }
  18898. oldValue, err := m.oldValue(ctx)
  18899. if err != nil {
  18900. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18901. }
  18902. return oldValue.CreatedAt, nil
  18903. }
  18904. // ResetCreatedAt resets all changes to the "created_at" field.
  18905. func (m *SopStageMutation) ResetCreatedAt() {
  18906. m.created_at = nil
  18907. }
  18908. // SetUpdatedAt sets the "updated_at" field.
  18909. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  18910. m.updated_at = &t
  18911. }
  18912. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18913. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  18914. v := m.updated_at
  18915. if v == nil {
  18916. return
  18917. }
  18918. return *v, true
  18919. }
  18920. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  18921. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18923. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18924. if !m.op.Is(OpUpdateOne) {
  18925. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18926. }
  18927. if m.id == nil || m.oldValue == nil {
  18928. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18929. }
  18930. oldValue, err := m.oldValue(ctx)
  18931. if err != nil {
  18932. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18933. }
  18934. return oldValue.UpdatedAt, nil
  18935. }
  18936. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18937. func (m *SopStageMutation) ResetUpdatedAt() {
  18938. m.updated_at = nil
  18939. }
  18940. // SetStatus sets the "status" field.
  18941. func (m *SopStageMutation) SetStatus(u uint8) {
  18942. m.status = &u
  18943. m.addstatus = nil
  18944. }
  18945. // Status returns the value of the "status" field in the mutation.
  18946. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  18947. v := m.status
  18948. if v == nil {
  18949. return
  18950. }
  18951. return *v, true
  18952. }
  18953. // OldStatus returns the old "status" field's value of the SopStage entity.
  18954. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18956. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18957. if !m.op.Is(OpUpdateOne) {
  18958. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18959. }
  18960. if m.id == nil || m.oldValue == nil {
  18961. return v, errors.New("OldStatus requires an ID field in the mutation")
  18962. }
  18963. oldValue, err := m.oldValue(ctx)
  18964. if err != nil {
  18965. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18966. }
  18967. return oldValue.Status, nil
  18968. }
  18969. // AddStatus adds u to the "status" field.
  18970. func (m *SopStageMutation) AddStatus(u int8) {
  18971. if m.addstatus != nil {
  18972. *m.addstatus += u
  18973. } else {
  18974. m.addstatus = &u
  18975. }
  18976. }
  18977. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18978. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  18979. v := m.addstatus
  18980. if v == nil {
  18981. return
  18982. }
  18983. return *v, true
  18984. }
  18985. // ClearStatus clears the value of the "status" field.
  18986. func (m *SopStageMutation) ClearStatus() {
  18987. m.status = nil
  18988. m.addstatus = nil
  18989. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  18990. }
  18991. // StatusCleared returns if the "status" field was cleared in this mutation.
  18992. func (m *SopStageMutation) StatusCleared() bool {
  18993. _, ok := m.clearedFields[sopstage.FieldStatus]
  18994. return ok
  18995. }
  18996. // ResetStatus resets all changes to the "status" field.
  18997. func (m *SopStageMutation) ResetStatus() {
  18998. m.status = nil
  18999. m.addstatus = nil
  19000. delete(m.clearedFields, sopstage.FieldStatus)
  19001. }
  19002. // SetDeletedAt sets the "deleted_at" field.
  19003. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  19004. m.deleted_at = &t
  19005. }
  19006. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19007. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  19008. v := m.deleted_at
  19009. if v == nil {
  19010. return
  19011. }
  19012. return *v, true
  19013. }
  19014. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  19015. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19017. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19018. if !m.op.Is(OpUpdateOne) {
  19019. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19020. }
  19021. if m.id == nil || m.oldValue == nil {
  19022. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19023. }
  19024. oldValue, err := m.oldValue(ctx)
  19025. if err != nil {
  19026. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19027. }
  19028. return oldValue.DeletedAt, nil
  19029. }
  19030. // ClearDeletedAt clears the value of the "deleted_at" field.
  19031. func (m *SopStageMutation) ClearDeletedAt() {
  19032. m.deleted_at = nil
  19033. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  19034. }
  19035. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19036. func (m *SopStageMutation) DeletedAtCleared() bool {
  19037. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  19038. return ok
  19039. }
  19040. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19041. func (m *SopStageMutation) ResetDeletedAt() {
  19042. m.deleted_at = nil
  19043. delete(m.clearedFields, sopstage.FieldDeletedAt)
  19044. }
  19045. // SetTaskID sets the "task_id" field.
  19046. func (m *SopStageMutation) SetTaskID(u uint64) {
  19047. m.sop_task = &u
  19048. }
  19049. // TaskID returns the value of the "task_id" field in the mutation.
  19050. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  19051. v := m.sop_task
  19052. if v == nil {
  19053. return
  19054. }
  19055. return *v, true
  19056. }
  19057. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  19058. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19060. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  19061. if !m.op.Is(OpUpdateOne) {
  19062. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  19063. }
  19064. if m.id == nil || m.oldValue == nil {
  19065. return v, errors.New("OldTaskID requires an ID field in the mutation")
  19066. }
  19067. oldValue, err := m.oldValue(ctx)
  19068. if err != nil {
  19069. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  19070. }
  19071. return oldValue.TaskID, nil
  19072. }
  19073. // ResetTaskID resets all changes to the "task_id" field.
  19074. func (m *SopStageMutation) ResetTaskID() {
  19075. m.sop_task = nil
  19076. }
  19077. // SetName sets the "name" field.
  19078. func (m *SopStageMutation) SetName(s string) {
  19079. m.name = &s
  19080. }
  19081. // Name returns the value of the "name" field in the mutation.
  19082. func (m *SopStageMutation) Name() (r string, exists bool) {
  19083. v := m.name
  19084. if v == nil {
  19085. return
  19086. }
  19087. return *v, true
  19088. }
  19089. // OldName returns the old "name" field's value of the SopStage entity.
  19090. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19092. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  19093. if !m.op.Is(OpUpdateOne) {
  19094. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19095. }
  19096. if m.id == nil || m.oldValue == nil {
  19097. return v, errors.New("OldName requires an ID field in the mutation")
  19098. }
  19099. oldValue, err := m.oldValue(ctx)
  19100. if err != nil {
  19101. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19102. }
  19103. return oldValue.Name, nil
  19104. }
  19105. // ResetName resets all changes to the "name" field.
  19106. func (m *SopStageMutation) ResetName() {
  19107. m.name = nil
  19108. }
  19109. // SetConditionType sets the "condition_type" field.
  19110. func (m *SopStageMutation) SetConditionType(i int) {
  19111. m.condition_type = &i
  19112. m.addcondition_type = nil
  19113. }
  19114. // ConditionType returns the value of the "condition_type" field in the mutation.
  19115. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  19116. v := m.condition_type
  19117. if v == nil {
  19118. return
  19119. }
  19120. return *v, true
  19121. }
  19122. // OldConditionType returns the old "condition_type" 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) OldConditionType(ctx context.Context) (v int, err error) {
  19126. if !m.op.Is(OpUpdateOne) {
  19127. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  19128. }
  19129. if m.id == nil || m.oldValue == nil {
  19130. return v, errors.New("OldConditionType 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 OldConditionType: %w", err)
  19135. }
  19136. return oldValue.ConditionType, nil
  19137. }
  19138. // AddConditionType adds i to the "condition_type" field.
  19139. func (m *SopStageMutation) AddConditionType(i int) {
  19140. if m.addcondition_type != nil {
  19141. *m.addcondition_type += i
  19142. } else {
  19143. m.addcondition_type = &i
  19144. }
  19145. }
  19146. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  19147. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  19148. v := m.addcondition_type
  19149. if v == nil {
  19150. return
  19151. }
  19152. return *v, true
  19153. }
  19154. // ResetConditionType resets all changes to the "condition_type" field.
  19155. func (m *SopStageMutation) ResetConditionType() {
  19156. m.condition_type = nil
  19157. m.addcondition_type = nil
  19158. }
  19159. // SetConditionOperator sets the "condition_operator" field.
  19160. func (m *SopStageMutation) SetConditionOperator(i int) {
  19161. m.condition_operator = &i
  19162. m.addcondition_operator = nil
  19163. }
  19164. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  19165. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  19166. v := m.condition_operator
  19167. if v == nil {
  19168. return
  19169. }
  19170. return *v, true
  19171. }
  19172. // OldConditionOperator returns the old "condition_operator" 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) OldConditionOperator(ctx context.Context) (v int, err error) {
  19176. if !m.op.Is(OpUpdateOne) {
  19177. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  19178. }
  19179. if m.id == nil || m.oldValue == nil {
  19180. return v, errors.New("OldConditionOperator 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 OldConditionOperator: %w", err)
  19185. }
  19186. return oldValue.ConditionOperator, nil
  19187. }
  19188. // AddConditionOperator adds i to the "condition_operator" field.
  19189. func (m *SopStageMutation) AddConditionOperator(i int) {
  19190. if m.addcondition_operator != nil {
  19191. *m.addcondition_operator += i
  19192. } else {
  19193. m.addcondition_operator = &i
  19194. }
  19195. }
  19196. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  19197. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  19198. v := m.addcondition_operator
  19199. if v == nil {
  19200. return
  19201. }
  19202. return *v, true
  19203. }
  19204. // ResetConditionOperator resets all changes to the "condition_operator" field.
  19205. func (m *SopStageMutation) ResetConditionOperator() {
  19206. m.condition_operator = nil
  19207. m.addcondition_operator = nil
  19208. }
  19209. // SetConditionList sets the "condition_list" field.
  19210. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  19211. m.condition_list = &ct
  19212. m.appendcondition_list = nil
  19213. }
  19214. // ConditionList returns the value of the "condition_list" field in the mutation.
  19215. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  19216. v := m.condition_list
  19217. if v == nil {
  19218. return
  19219. }
  19220. return *v, true
  19221. }
  19222. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  19223. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19225. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  19226. if !m.op.Is(OpUpdateOne) {
  19227. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  19228. }
  19229. if m.id == nil || m.oldValue == nil {
  19230. return v, errors.New("OldConditionList requires an ID field in the mutation")
  19231. }
  19232. oldValue, err := m.oldValue(ctx)
  19233. if err != nil {
  19234. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  19235. }
  19236. return oldValue.ConditionList, nil
  19237. }
  19238. // AppendConditionList adds ct to the "condition_list" field.
  19239. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  19240. m.appendcondition_list = append(m.appendcondition_list, ct...)
  19241. }
  19242. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  19243. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  19244. if len(m.appendcondition_list) == 0 {
  19245. return nil, false
  19246. }
  19247. return m.appendcondition_list, true
  19248. }
  19249. // ResetConditionList resets all changes to the "condition_list" field.
  19250. func (m *SopStageMutation) ResetConditionList() {
  19251. m.condition_list = nil
  19252. m.appendcondition_list = nil
  19253. }
  19254. // SetActionMessage sets the "action_message" field.
  19255. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  19256. m.action_message = &ct
  19257. m.appendaction_message = nil
  19258. }
  19259. // ActionMessage returns the value of the "action_message" field in the mutation.
  19260. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  19261. v := m.action_message
  19262. if v == nil {
  19263. return
  19264. }
  19265. return *v, true
  19266. }
  19267. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  19268. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19270. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  19271. if !m.op.Is(OpUpdateOne) {
  19272. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  19273. }
  19274. if m.id == nil || m.oldValue == nil {
  19275. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  19276. }
  19277. oldValue, err := m.oldValue(ctx)
  19278. if err != nil {
  19279. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  19280. }
  19281. return oldValue.ActionMessage, nil
  19282. }
  19283. // AppendActionMessage adds ct to the "action_message" field.
  19284. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  19285. m.appendaction_message = append(m.appendaction_message, ct...)
  19286. }
  19287. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  19288. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  19289. if len(m.appendaction_message) == 0 {
  19290. return nil, false
  19291. }
  19292. return m.appendaction_message, true
  19293. }
  19294. // ClearActionMessage clears the value of the "action_message" field.
  19295. func (m *SopStageMutation) ClearActionMessage() {
  19296. m.action_message = nil
  19297. m.appendaction_message = nil
  19298. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  19299. }
  19300. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  19301. func (m *SopStageMutation) ActionMessageCleared() bool {
  19302. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  19303. return ok
  19304. }
  19305. // ResetActionMessage resets all changes to the "action_message" field.
  19306. func (m *SopStageMutation) ResetActionMessage() {
  19307. m.action_message = nil
  19308. m.appendaction_message = nil
  19309. delete(m.clearedFields, sopstage.FieldActionMessage)
  19310. }
  19311. // SetActionLabelAdd sets the "action_label_add" field.
  19312. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  19313. m.action_label_add = &u
  19314. m.appendaction_label_add = nil
  19315. }
  19316. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  19317. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  19318. v := m.action_label_add
  19319. if v == nil {
  19320. return
  19321. }
  19322. return *v, true
  19323. }
  19324. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  19325. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19327. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  19328. if !m.op.Is(OpUpdateOne) {
  19329. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  19330. }
  19331. if m.id == nil || m.oldValue == nil {
  19332. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  19333. }
  19334. oldValue, err := m.oldValue(ctx)
  19335. if err != nil {
  19336. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  19337. }
  19338. return oldValue.ActionLabelAdd, nil
  19339. }
  19340. // AppendActionLabelAdd adds u to the "action_label_add" field.
  19341. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  19342. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  19343. }
  19344. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  19345. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  19346. if len(m.appendaction_label_add) == 0 {
  19347. return nil, false
  19348. }
  19349. return m.appendaction_label_add, true
  19350. }
  19351. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  19352. func (m *SopStageMutation) ClearActionLabelAdd() {
  19353. m.action_label_add = nil
  19354. m.appendaction_label_add = nil
  19355. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  19356. }
  19357. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  19358. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  19359. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  19360. return ok
  19361. }
  19362. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  19363. func (m *SopStageMutation) ResetActionLabelAdd() {
  19364. m.action_label_add = nil
  19365. m.appendaction_label_add = nil
  19366. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  19367. }
  19368. // SetActionLabelDel sets the "action_label_del" field.
  19369. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  19370. m.action_label_del = &u
  19371. m.appendaction_label_del = nil
  19372. }
  19373. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  19374. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  19375. v := m.action_label_del
  19376. if v == nil {
  19377. return
  19378. }
  19379. return *v, true
  19380. }
  19381. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  19382. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19384. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  19385. if !m.op.Is(OpUpdateOne) {
  19386. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  19387. }
  19388. if m.id == nil || m.oldValue == nil {
  19389. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  19390. }
  19391. oldValue, err := m.oldValue(ctx)
  19392. if err != nil {
  19393. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  19394. }
  19395. return oldValue.ActionLabelDel, nil
  19396. }
  19397. // AppendActionLabelDel adds u to the "action_label_del" field.
  19398. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  19399. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  19400. }
  19401. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  19402. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  19403. if len(m.appendaction_label_del) == 0 {
  19404. return nil, false
  19405. }
  19406. return m.appendaction_label_del, true
  19407. }
  19408. // ClearActionLabelDel clears the value of the "action_label_del" field.
  19409. func (m *SopStageMutation) ClearActionLabelDel() {
  19410. m.action_label_del = nil
  19411. m.appendaction_label_del = nil
  19412. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  19413. }
  19414. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  19415. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  19416. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  19417. return ok
  19418. }
  19419. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  19420. func (m *SopStageMutation) ResetActionLabelDel() {
  19421. m.action_label_del = nil
  19422. m.appendaction_label_del = nil
  19423. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  19424. }
  19425. // SetActionForward sets the "action_forward" field.
  19426. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  19427. m.action_forward = &ctf
  19428. }
  19429. // ActionForward returns the value of the "action_forward" field in the mutation.
  19430. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  19431. v := m.action_forward
  19432. if v == nil {
  19433. return
  19434. }
  19435. return *v, true
  19436. }
  19437. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  19438. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19440. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  19441. if !m.op.Is(OpUpdateOne) {
  19442. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  19443. }
  19444. if m.id == nil || m.oldValue == nil {
  19445. return v, errors.New("OldActionForward requires an ID field in the mutation")
  19446. }
  19447. oldValue, err := m.oldValue(ctx)
  19448. if err != nil {
  19449. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  19450. }
  19451. return oldValue.ActionForward, nil
  19452. }
  19453. // ClearActionForward clears the value of the "action_forward" field.
  19454. func (m *SopStageMutation) ClearActionForward() {
  19455. m.action_forward = nil
  19456. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  19457. }
  19458. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  19459. func (m *SopStageMutation) ActionForwardCleared() bool {
  19460. _, ok := m.clearedFields[sopstage.FieldActionForward]
  19461. return ok
  19462. }
  19463. // ResetActionForward resets all changes to the "action_forward" field.
  19464. func (m *SopStageMutation) ResetActionForward() {
  19465. m.action_forward = nil
  19466. delete(m.clearedFields, sopstage.FieldActionForward)
  19467. }
  19468. // SetIndexSort sets the "index_sort" field.
  19469. func (m *SopStageMutation) SetIndexSort(i int) {
  19470. m.index_sort = &i
  19471. m.addindex_sort = nil
  19472. }
  19473. // IndexSort returns the value of the "index_sort" field in the mutation.
  19474. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  19475. v := m.index_sort
  19476. if v == nil {
  19477. return
  19478. }
  19479. return *v, true
  19480. }
  19481. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  19482. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19484. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  19485. if !m.op.Is(OpUpdateOne) {
  19486. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  19487. }
  19488. if m.id == nil || m.oldValue == nil {
  19489. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  19490. }
  19491. oldValue, err := m.oldValue(ctx)
  19492. if err != nil {
  19493. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  19494. }
  19495. return oldValue.IndexSort, nil
  19496. }
  19497. // AddIndexSort adds i to the "index_sort" field.
  19498. func (m *SopStageMutation) AddIndexSort(i int) {
  19499. if m.addindex_sort != nil {
  19500. *m.addindex_sort += i
  19501. } else {
  19502. m.addindex_sort = &i
  19503. }
  19504. }
  19505. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  19506. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  19507. v := m.addindex_sort
  19508. if v == nil {
  19509. return
  19510. }
  19511. return *v, true
  19512. }
  19513. // ClearIndexSort clears the value of the "index_sort" field.
  19514. func (m *SopStageMutation) ClearIndexSort() {
  19515. m.index_sort = nil
  19516. m.addindex_sort = nil
  19517. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  19518. }
  19519. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  19520. func (m *SopStageMutation) IndexSortCleared() bool {
  19521. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  19522. return ok
  19523. }
  19524. // ResetIndexSort resets all changes to the "index_sort" field.
  19525. func (m *SopStageMutation) ResetIndexSort() {
  19526. m.index_sort = nil
  19527. m.addindex_sort = nil
  19528. delete(m.clearedFields, sopstage.FieldIndexSort)
  19529. }
  19530. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  19531. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  19532. m.sop_task = &id
  19533. }
  19534. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  19535. func (m *SopStageMutation) ClearSopTask() {
  19536. m.clearedsop_task = true
  19537. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  19538. }
  19539. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  19540. func (m *SopStageMutation) SopTaskCleared() bool {
  19541. return m.clearedsop_task
  19542. }
  19543. // SopTaskID returns the "sop_task" edge ID in the mutation.
  19544. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  19545. if m.sop_task != nil {
  19546. return *m.sop_task, true
  19547. }
  19548. return
  19549. }
  19550. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  19551. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19552. // SopTaskID instead. It exists only for internal usage by the builders.
  19553. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  19554. if id := m.sop_task; id != nil {
  19555. ids = append(ids, *id)
  19556. }
  19557. return
  19558. }
  19559. // ResetSopTask resets all changes to the "sop_task" edge.
  19560. func (m *SopStageMutation) ResetSopTask() {
  19561. m.sop_task = nil
  19562. m.clearedsop_task = false
  19563. }
  19564. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  19565. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  19566. if m.stage_nodes == nil {
  19567. m.stage_nodes = make(map[uint64]struct{})
  19568. }
  19569. for i := range ids {
  19570. m.stage_nodes[ids[i]] = struct{}{}
  19571. }
  19572. }
  19573. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  19574. func (m *SopStageMutation) ClearStageNodes() {
  19575. m.clearedstage_nodes = true
  19576. }
  19577. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  19578. func (m *SopStageMutation) StageNodesCleared() bool {
  19579. return m.clearedstage_nodes
  19580. }
  19581. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  19582. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  19583. if m.removedstage_nodes == nil {
  19584. m.removedstage_nodes = make(map[uint64]struct{})
  19585. }
  19586. for i := range ids {
  19587. delete(m.stage_nodes, ids[i])
  19588. m.removedstage_nodes[ids[i]] = struct{}{}
  19589. }
  19590. }
  19591. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  19592. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  19593. for id := range m.removedstage_nodes {
  19594. ids = append(ids, id)
  19595. }
  19596. return
  19597. }
  19598. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  19599. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  19600. for id := range m.stage_nodes {
  19601. ids = append(ids, id)
  19602. }
  19603. return
  19604. }
  19605. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  19606. func (m *SopStageMutation) ResetStageNodes() {
  19607. m.stage_nodes = nil
  19608. m.clearedstage_nodes = false
  19609. m.removedstage_nodes = nil
  19610. }
  19611. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  19612. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  19613. if m.stage_messages == nil {
  19614. m.stage_messages = make(map[uint64]struct{})
  19615. }
  19616. for i := range ids {
  19617. m.stage_messages[ids[i]] = struct{}{}
  19618. }
  19619. }
  19620. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  19621. func (m *SopStageMutation) ClearStageMessages() {
  19622. m.clearedstage_messages = true
  19623. }
  19624. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  19625. func (m *SopStageMutation) StageMessagesCleared() bool {
  19626. return m.clearedstage_messages
  19627. }
  19628. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  19629. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  19630. if m.removedstage_messages == nil {
  19631. m.removedstage_messages = make(map[uint64]struct{})
  19632. }
  19633. for i := range ids {
  19634. delete(m.stage_messages, ids[i])
  19635. m.removedstage_messages[ids[i]] = struct{}{}
  19636. }
  19637. }
  19638. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  19639. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  19640. for id := range m.removedstage_messages {
  19641. ids = append(ids, id)
  19642. }
  19643. return
  19644. }
  19645. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  19646. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  19647. for id := range m.stage_messages {
  19648. ids = append(ids, id)
  19649. }
  19650. return
  19651. }
  19652. // ResetStageMessages resets all changes to the "stage_messages" edge.
  19653. func (m *SopStageMutation) ResetStageMessages() {
  19654. m.stage_messages = nil
  19655. m.clearedstage_messages = false
  19656. m.removedstage_messages = nil
  19657. }
  19658. // Where appends a list predicates to the SopStageMutation builder.
  19659. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  19660. m.predicates = append(m.predicates, ps...)
  19661. }
  19662. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  19663. // users can use type-assertion to append predicates that do not depend on any generated package.
  19664. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  19665. p := make([]predicate.SopStage, len(ps))
  19666. for i := range ps {
  19667. p[i] = ps[i]
  19668. }
  19669. m.Where(p...)
  19670. }
  19671. // Op returns the operation name.
  19672. func (m *SopStageMutation) Op() Op {
  19673. return m.op
  19674. }
  19675. // SetOp allows setting the mutation operation.
  19676. func (m *SopStageMutation) SetOp(op Op) {
  19677. m.op = op
  19678. }
  19679. // Type returns the node type of this mutation (SopStage).
  19680. func (m *SopStageMutation) Type() string {
  19681. return m.typ
  19682. }
  19683. // Fields returns all fields that were changed during this mutation. Note that in
  19684. // order to get all numeric fields that were incremented/decremented, call
  19685. // AddedFields().
  19686. func (m *SopStageMutation) Fields() []string {
  19687. fields := make([]string, 0, 14)
  19688. if m.created_at != nil {
  19689. fields = append(fields, sopstage.FieldCreatedAt)
  19690. }
  19691. if m.updated_at != nil {
  19692. fields = append(fields, sopstage.FieldUpdatedAt)
  19693. }
  19694. if m.status != nil {
  19695. fields = append(fields, sopstage.FieldStatus)
  19696. }
  19697. if m.deleted_at != nil {
  19698. fields = append(fields, sopstage.FieldDeletedAt)
  19699. }
  19700. if m.sop_task != nil {
  19701. fields = append(fields, sopstage.FieldTaskID)
  19702. }
  19703. if m.name != nil {
  19704. fields = append(fields, sopstage.FieldName)
  19705. }
  19706. if m.condition_type != nil {
  19707. fields = append(fields, sopstage.FieldConditionType)
  19708. }
  19709. if m.condition_operator != nil {
  19710. fields = append(fields, sopstage.FieldConditionOperator)
  19711. }
  19712. if m.condition_list != nil {
  19713. fields = append(fields, sopstage.FieldConditionList)
  19714. }
  19715. if m.action_message != nil {
  19716. fields = append(fields, sopstage.FieldActionMessage)
  19717. }
  19718. if m.action_label_add != nil {
  19719. fields = append(fields, sopstage.FieldActionLabelAdd)
  19720. }
  19721. if m.action_label_del != nil {
  19722. fields = append(fields, sopstage.FieldActionLabelDel)
  19723. }
  19724. if m.action_forward != nil {
  19725. fields = append(fields, sopstage.FieldActionForward)
  19726. }
  19727. if m.index_sort != nil {
  19728. fields = append(fields, sopstage.FieldIndexSort)
  19729. }
  19730. return fields
  19731. }
  19732. // Field returns the value of a field with the given name. The second boolean
  19733. // return value indicates that this field was not set, or was not defined in the
  19734. // schema.
  19735. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  19736. switch name {
  19737. case sopstage.FieldCreatedAt:
  19738. return m.CreatedAt()
  19739. case sopstage.FieldUpdatedAt:
  19740. return m.UpdatedAt()
  19741. case sopstage.FieldStatus:
  19742. return m.Status()
  19743. case sopstage.FieldDeletedAt:
  19744. return m.DeletedAt()
  19745. case sopstage.FieldTaskID:
  19746. return m.TaskID()
  19747. case sopstage.FieldName:
  19748. return m.Name()
  19749. case sopstage.FieldConditionType:
  19750. return m.ConditionType()
  19751. case sopstage.FieldConditionOperator:
  19752. return m.ConditionOperator()
  19753. case sopstage.FieldConditionList:
  19754. return m.ConditionList()
  19755. case sopstage.FieldActionMessage:
  19756. return m.ActionMessage()
  19757. case sopstage.FieldActionLabelAdd:
  19758. return m.ActionLabelAdd()
  19759. case sopstage.FieldActionLabelDel:
  19760. return m.ActionLabelDel()
  19761. case sopstage.FieldActionForward:
  19762. return m.ActionForward()
  19763. case sopstage.FieldIndexSort:
  19764. return m.IndexSort()
  19765. }
  19766. return nil, false
  19767. }
  19768. // OldField returns the old value of the field from the database. An error is
  19769. // returned if the mutation operation is not UpdateOne, or the query to the
  19770. // database failed.
  19771. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19772. switch name {
  19773. case sopstage.FieldCreatedAt:
  19774. return m.OldCreatedAt(ctx)
  19775. case sopstage.FieldUpdatedAt:
  19776. return m.OldUpdatedAt(ctx)
  19777. case sopstage.FieldStatus:
  19778. return m.OldStatus(ctx)
  19779. case sopstage.FieldDeletedAt:
  19780. return m.OldDeletedAt(ctx)
  19781. case sopstage.FieldTaskID:
  19782. return m.OldTaskID(ctx)
  19783. case sopstage.FieldName:
  19784. return m.OldName(ctx)
  19785. case sopstage.FieldConditionType:
  19786. return m.OldConditionType(ctx)
  19787. case sopstage.FieldConditionOperator:
  19788. return m.OldConditionOperator(ctx)
  19789. case sopstage.FieldConditionList:
  19790. return m.OldConditionList(ctx)
  19791. case sopstage.FieldActionMessage:
  19792. return m.OldActionMessage(ctx)
  19793. case sopstage.FieldActionLabelAdd:
  19794. return m.OldActionLabelAdd(ctx)
  19795. case sopstage.FieldActionLabelDel:
  19796. return m.OldActionLabelDel(ctx)
  19797. case sopstage.FieldActionForward:
  19798. return m.OldActionForward(ctx)
  19799. case sopstage.FieldIndexSort:
  19800. return m.OldIndexSort(ctx)
  19801. }
  19802. return nil, fmt.Errorf("unknown SopStage field %s", name)
  19803. }
  19804. // SetField sets the value of a field with the given name. It returns an error if
  19805. // the field is not defined in the schema, or if the type mismatched the field
  19806. // type.
  19807. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  19808. switch name {
  19809. case sopstage.FieldCreatedAt:
  19810. v, ok := value.(time.Time)
  19811. if !ok {
  19812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19813. }
  19814. m.SetCreatedAt(v)
  19815. return nil
  19816. case sopstage.FieldUpdatedAt:
  19817. v, ok := value.(time.Time)
  19818. if !ok {
  19819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19820. }
  19821. m.SetUpdatedAt(v)
  19822. return nil
  19823. case sopstage.FieldStatus:
  19824. v, ok := value.(uint8)
  19825. if !ok {
  19826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19827. }
  19828. m.SetStatus(v)
  19829. return nil
  19830. case sopstage.FieldDeletedAt:
  19831. v, ok := value.(time.Time)
  19832. if !ok {
  19833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19834. }
  19835. m.SetDeletedAt(v)
  19836. return nil
  19837. case sopstage.FieldTaskID:
  19838. v, ok := value.(uint64)
  19839. if !ok {
  19840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19841. }
  19842. m.SetTaskID(v)
  19843. return nil
  19844. case sopstage.FieldName:
  19845. v, ok := value.(string)
  19846. if !ok {
  19847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19848. }
  19849. m.SetName(v)
  19850. return nil
  19851. case sopstage.FieldConditionType:
  19852. v, ok := value.(int)
  19853. if !ok {
  19854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19855. }
  19856. m.SetConditionType(v)
  19857. return nil
  19858. case sopstage.FieldConditionOperator:
  19859. v, ok := value.(int)
  19860. if !ok {
  19861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19862. }
  19863. m.SetConditionOperator(v)
  19864. return nil
  19865. case sopstage.FieldConditionList:
  19866. v, ok := value.([]custom_types.Condition)
  19867. if !ok {
  19868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19869. }
  19870. m.SetConditionList(v)
  19871. return nil
  19872. case sopstage.FieldActionMessage:
  19873. v, ok := value.([]custom_types.Action)
  19874. if !ok {
  19875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19876. }
  19877. m.SetActionMessage(v)
  19878. return nil
  19879. case sopstage.FieldActionLabelAdd:
  19880. v, ok := value.([]uint64)
  19881. if !ok {
  19882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19883. }
  19884. m.SetActionLabelAdd(v)
  19885. return nil
  19886. case sopstage.FieldActionLabelDel:
  19887. v, ok := value.([]uint64)
  19888. if !ok {
  19889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19890. }
  19891. m.SetActionLabelDel(v)
  19892. return nil
  19893. case sopstage.FieldActionForward:
  19894. v, ok := value.(*custom_types.ActionForward)
  19895. if !ok {
  19896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19897. }
  19898. m.SetActionForward(v)
  19899. return nil
  19900. case sopstage.FieldIndexSort:
  19901. v, ok := value.(int)
  19902. if !ok {
  19903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19904. }
  19905. m.SetIndexSort(v)
  19906. return nil
  19907. }
  19908. return fmt.Errorf("unknown SopStage field %s", name)
  19909. }
  19910. // AddedFields returns all numeric fields that were incremented/decremented during
  19911. // this mutation.
  19912. func (m *SopStageMutation) AddedFields() []string {
  19913. var fields []string
  19914. if m.addstatus != nil {
  19915. fields = append(fields, sopstage.FieldStatus)
  19916. }
  19917. if m.addcondition_type != nil {
  19918. fields = append(fields, sopstage.FieldConditionType)
  19919. }
  19920. if m.addcondition_operator != nil {
  19921. fields = append(fields, sopstage.FieldConditionOperator)
  19922. }
  19923. if m.addindex_sort != nil {
  19924. fields = append(fields, sopstage.FieldIndexSort)
  19925. }
  19926. return fields
  19927. }
  19928. // AddedField returns the numeric value that was incremented/decremented on a field
  19929. // with the given name. The second boolean return value indicates that this field
  19930. // was not set, or was not defined in the schema.
  19931. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  19932. switch name {
  19933. case sopstage.FieldStatus:
  19934. return m.AddedStatus()
  19935. case sopstage.FieldConditionType:
  19936. return m.AddedConditionType()
  19937. case sopstage.FieldConditionOperator:
  19938. return m.AddedConditionOperator()
  19939. case sopstage.FieldIndexSort:
  19940. return m.AddedIndexSort()
  19941. }
  19942. return nil, false
  19943. }
  19944. // AddField adds the value to the field with the given name. It returns an error if
  19945. // the field is not defined in the schema, or if the type mismatched the field
  19946. // type.
  19947. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  19948. switch name {
  19949. case sopstage.FieldStatus:
  19950. v, ok := value.(int8)
  19951. if !ok {
  19952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19953. }
  19954. m.AddStatus(v)
  19955. return nil
  19956. case sopstage.FieldConditionType:
  19957. v, ok := value.(int)
  19958. if !ok {
  19959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19960. }
  19961. m.AddConditionType(v)
  19962. return nil
  19963. case sopstage.FieldConditionOperator:
  19964. v, ok := value.(int)
  19965. if !ok {
  19966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19967. }
  19968. m.AddConditionOperator(v)
  19969. return nil
  19970. case sopstage.FieldIndexSort:
  19971. v, ok := value.(int)
  19972. if !ok {
  19973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19974. }
  19975. m.AddIndexSort(v)
  19976. return nil
  19977. }
  19978. return fmt.Errorf("unknown SopStage numeric field %s", name)
  19979. }
  19980. // ClearedFields returns all nullable fields that were cleared during this
  19981. // mutation.
  19982. func (m *SopStageMutation) ClearedFields() []string {
  19983. var fields []string
  19984. if m.FieldCleared(sopstage.FieldStatus) {
  19985. fields = append(fields, sopstage.FieldStatus)
  19986. }
  19987. if m.FieldCleared(sopstage.FieldDeletedAt) {
  19988. fields = append(fields, sopstage.FieldDeletedAt)
  19989. }
  19990. if m.FieldCleared(sopstage.FieldActionMessage) {
  19991. fields = append(fields, sopstage.FieldActionMessage)
  19992. }
  19993. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  19994. fields = append(fields, sopstage.FieldActionLabelAdd)
  19995. }
  19996. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  19997. fields = append(fields, sopstage.FieldActionLabelDel)
  19998. }
  19999. if m.FieldCleared(sopstage.FieldActionForward) {
  20000. fields = append(fields, sopstage.FieldActionForward)
  20001. }
  20002. if m.FieldCleared(sopstage.FieldIndexSort) {
  20003. fields = append(fields, sopstage.FieldIndexSort)
  20004. }
  20005. return fields
  20006. }
  20007. // FieldCleared returns a boolean indicating if a field with the given name was
  20008. // cleared in this mutation.
  20009. func (m *SopStageMutation) FieldCleared(name string) bool {
  20010. _, ok := m.clearedFields[name]
  20011. return ok
  20012. }
  20013. // ClearField clears the value of the field with the given name. It returns an
  20014. // error if the field is not defined in the schema.
  20015. func (m *SopStageMutation) ClearField(name string) error {
  20016. switch name {
  20017. case sopstage.FieldStatus:
  20018. m.ClearStatus()
  20019. return nil
  20020. case sopstage.FieldDeletedAt:
  20021. m.ClearDeletedAt()
  20022. return nil
  20023. case sopstage.FieldActionMessage:
  20024. m.ClearActionMessage()
  20025. return nil
  20026. case sopstage.FieldActionLabelAdd:
  20027. m.ClearActionLabelAdd()
  20028. return nil
  20029. case sopstage.FieldActionLabelDel:
  20030. m.ClearActionLabelDel()
  20031. return nil
  20032. case sopstage.FieldActionForward:
  20033. m.ClearActionForward()
  20034. return nil
  20035. case sopstage.FieldIndexSort:
  20036. m.ClearIndexSort()
  20037. return nil
  20038. }
  20039. return fmt.Errorf("unknown SopStage nullable field %s", name)
  20040. }
  20041. // ResetField resets all changes in the mutation for the field with the given name.
  20042. // It returns an error if the field is not defined in the schema.
  20043. func (m *SopStageMutation) ResetField(name string) error {
  20044. switch name {
  20045. case sopstage.FieldCreatedAt:
  20046. m.ResetCreatedAt()
  20047. return nil
  20048. case sopstage.FieldUpdatedAt:
  20049. m.ResetUpdatedAt()
  20050. return nil
  20051. case sopstage.FieldStatus:
  20052. m.ResetStatus()
  20053. return nil
  20054. case sopstage.FieldDeletedAt:
  20055. m.ResetDeletedAt()
  20056. return nil
  20057. case sopstage.FieldTaskID:
  20058. m.ResetTaskID()
  20059. return nil
  20060. case sopstage.FieldName:
  20061. m.ResetName()
  20062. return nil
  20063. case sopstage.FieldConditionType:
  20064. m.ResetConditionType()
  20065. return nil
  20066. case sopstage.FieldConditionOperator:
  20067. m.ResetConditionOperator()
  20068. return nil
  20069. case sopstage.FieldConditionList:
  20070. m.ResetConditionList()
  20071. return nil
  20072. case sopstage.FieldActionMessage:
  20073. m.ResetActionMessage()
  20074. return nil
  20075. case sopstage.FieldActionLabelAdd:
  20076. m.ResetActionLabelAdd()
  20077. return nil
  20078. case sopstage.FieldActionLabelDel:
  20079. m.ResetActionLabelDel()
  20080. return nil
  20081. case sopstage.FieldActionForward:
  20082. m.ResetActionForward()
  20083. return nil
  20084. case sopstage.FieldIndexSort:
  20085. m.ResetIndexSort()
  20086. return nil
  20087. }
  20088. return fmt.Errorf("unknown SopStage field %s", name)
  20089. }
  20090. // AddedEdges returns all edge names that were set/added in this mutation.
  20091. func (m *SopStageMutation) AddedEdges() []string {
  20092. edges := make([]string, 0, 3)
  20093. if m.sop_task != nil {
  20094. edges = append(edges, sopstage.EdgeSopTask)
  20095. }
  20096. if m.stage_nodes != nil {
  20097. edges = append(edges, sopstage.EdgeStageNodes)
  20098. }
  20099. if m.stage_messages != nil {
  20100. edges = append(edges, sopstage.EdgeStageMessages)
  20101. }
  20102. return edges
  20103. }
  20104. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20105. // name in this mutation.
  20106. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  20107. switch name {
  20108. case sopstage.EdgeSopTask:
  20109. if id := m.sop_task; id != nil {
  20110. return []ent.Value{*id}
  20111. }
  20112. case sopstage.EdgeStageNodes:
  20113. ids := make([]ent.Value, 0, len(m.stage_nodes))
  20114. for id := range m.stage_nodes {
  20115. ids = append(ids, id)
  20116. }
  20117. return ids
  20118. case sopstage.EdgeStageMessages:
  20119. ids := make([]ent.Value, 0, len(m.stage_messages))
  20120. for id := range m.stage_messages {
  20121. ids = append(ids, id)
  20122. }
  20123. return ids
  20124. }
  20125. return nil
  20126. }
  20127. // RemovedEdges returns all edge names that were removed in this mutation.
  20128. func (m *SopStageMutation) RemovedEdges() []string {
  20129. edges := make([]string, 0, 3)
  20130. if m.removedstage_nodes != nil {
  20131. edges = append(edges, sopstage.EdgeStageNodes)
  20132. }
  20133. if m.removedstage_messages != nil {
  20134. edges = append(edges, sopstage.EdgeStageMessages)
  20135. }
  20136. return edges
  20137. }
  20138. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20139. // the given name in this mutation.
  20140. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  20141. switch name {
  20142. case sopstage.EdgeStageNodes:
  20143. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  20144. for id := range m.removedstage_nodes {
  20145. ids = append(ids, id)
  20146. }
  20147. return ids
  20148. case sopstage.EdgeStageMessages:
  20149. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  20150. for id := range m.removedstage_messages {
  20151. ids = append(ids, id)
  20152. }
  20153. return ids
  20154. }
  20155. return nil
  20156. }
  20157. // ClearedEdges returns all edge names that were cleared in this mutation.
  20158. func (m *SopStageMutation) ClearedEdges() []string {
  20159. edges := make([]string, 0, 3)
  20160. if m.clearedsop_task {
  20161. edges = append(edges, sopstage.EdgeSopTask)
  20162. }
  20163. if m.clearedstage_nodes {
  20164. edges = append(edges, sopstage.EdgeStageNodes)
  20165. }
  20166. if m.clearedstage_messages {
  20167. edges = append(edges, sopstage.EdgeStageMessages)
  20168. }
  20169. return edges
  20170. }
  20171. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20172. // was cleared in this mutation.
  20173. func (m *SopStageMutation) EdgeCleared(name string) bool {
  20174. switch name {
  20175. case sopstage.EdgeSopTask:
  20176. return m.clearedsop_task
  20177. case sopstage.EdgeStageNodes:
  20178. return m.clearedstage_nodes
  20179. case sopstage.EdgeStageMessages:
  20180. return m.clearedstage_messages
  20181. }
  20182. return false
  20183. }
  20184. // ClearEdge clears the value of the edge with the given name. It returns an error
  20185. // if that edge is not defined in the schema.
  20186. func (m *SopStageMutation) ClearEdge(name string) error {
  20187. switch name {
  20188. case sopstage.EdgeSopTask:
  20189. m.ClearSopTask()
  20190. return nil
  20191. }
  20192. return fmt.Errorf("unknown SopStage unique edge %s", name)
  20193. }
  20194. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20195. // It returns an error if the edge is not defined in the schema.
  20196. func (m *SopStageMutation) ResetEdge(name string) error {
  20197. switch name {
  20198. case sopstage.EdgeSopTask:
  20199. m.ResetSopTask()
  20200. return nil
  20201. case sopstage.EdgeStageNodes:
  20202. m.ResetStageNodes()
  20203. return nil
  20204. case sopstage.EdgeStageMessages:
  20205. m.ResetStageMessages()
  20206. return nil
  20207. }
  20208. return fmt.Errorf("unknown SopStage edge %s", name)
  20209. }
  20210. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  20211. type SopTaskMutation struct {
  20212. config
  20213. op Op
  20214. typ string
  20215. id *uint64
  20216. created_at *time.Time
  20217. updated_at *time.Time
  20218. status *uint8
  20219. addstatus *int8
  20220. deleted_at *time.Time
  20221. name *string
  20222. bot_wxid_list *[]string
  20223. appendbot_wxid_list []string
  20224. _type *int
  20225. add_type *int
  20226. plan_start_time *time.Time
  20227. plan_end_time *time.Time
  20228. creator_id *string
  20229. organization_id *uint64
  20230. addorganization_id *int64
  20231. token *[]string
  20232. appendtoken []string
  20233. clearedFields map[string]struct{}
  20234. task_stages map[uint64]struct{}
  20235. removedtask_stages map[uint64]struct{}
  20236. clearedtask_stages bool
  20237. done bool
  20238. oldValue func(context.Context) (*SopTask, error)
  20239. predicates []predicate.SopTask
  20240. }
  20241. var _ ent.Mutation = (*SopTaskMutation)(nil)
  20242. // soptaskOption allows management of the mutation configuration using functional options.
  20243. type soptaskOption func(*SopTaskMutation)
  20244. // newSopTaskMutation creates new mutation for the SopTask entity.
  20245. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  20246. m := &SopTaskMutation{
  20247. config: c,
  20248. op: op,
  20249. typ: TypeSopTask,
  20250. clearedFields: make(map[string]struct{}),
  20251. }
  20252. for _, opt := range opts {
  20253. opt(m)
  20254. }
  20255. return m
  20256. }
  20257. // withSopTaskID sets the ID field of the mutation.
  20258. func withSopTaskID(id uint64) soptaskOption {
  20259. return func(m *SopTaskMutation) {
  20260. var (
  20261. err error
  20262. once sync.Once
  20263. value *SopTask
  20264. )
  20265. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  20266. once.Do(func() {
  20267. if m.done {
  20268. err = errors.New("querying old values post mutation is not allowed")
  20269. } else {
  20270. value, err = m.Client().SopTask.Get(ctx, id)
  20271. }
  20272. })
  20273. return value, err
  20274. }
  20275. m.id = &id
  20276. }
  20277. }
  20278. // withSopTask sets the old SopTask of the mutation.
  20279. func withSopTask(node *SopTask) soptaskOption {
  20280. return func(m *SopTaskMutation) {
  20281. m.oldValue = func(context.Context) (*SopTask, error) {
  20282. return node, nil
  20283. }
  20284. m.id = &node.ID
  20285. }
  20286. }
  20287. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20288. // executed in a transaction (ent.Tx), a transactional client is returned.
  20289. func (m SopTaskMutation) Client() *Client {
  20290. client := &Client{config: m.config}
  20291. client.init()
  20292. return client
  20293. }
  20294. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20295. // it returns an error otherwise.
  20296. func (m SopTaskMutation) Tx() (*Tx, error) {
  20297. if _, ok := m.driver.(*txDriver); !ok {
  20298. return nil, errors.New("ent: mutation is not running in a transaction")
  20299. }
  20300. tx := &Tx{config: m.config}
  20301. tx.init()
  20302. return tx, nil
  20303. }
  20304. // SetID sets the value of the id field. Note that this
  20305. // operation is only accepted on creation of SopTask entities.
  20306. func (m *SopTaskMutation) SetID(id uint64) {
  20307. m.id = &id
  20308. }
  20309. // ID returns the ID value in the mutation. Note that the ID is only available
  20310. // if it was provided to the builder or after it was returned from the database.
  20311. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  20312. if m.id == nil {
  20313. return
  20314. }
  20315. return *m.id, true
  20316. }
  20317. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20318. // That means, if the mutation is applied within a transaction with an isolation level such
  20319. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20320. // or updated by the mutation.
  20321. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  20322. switch {
  20323. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20324. id, exists := m.ID()
  20325. if exists {
  20326. return []uint64{id}, nil
  20327. }
  20328. fallthrough
  20329. case m.op.Is(OpUpdate | OpDelete):
  20330. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  20331. default:
  20332. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20333. }
  20334. }
  20335. // SetCreatedAt sets the "created_at" field.
  20336. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  20337. m.created_at = &t
  20338. }
  20339. // CreatedAt returns the value of the "created_at" field in the mutation.
  20340. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  20341. v := m.created_at
  20342. if v == nil {
  20343. return
  20344. }
  20345. return *v, true
  20346. }
  20347. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  20348. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20350. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20351. if !m.op.Is(OpUpdateOne) {
  20352. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20353. }
  20354. if m.id == nil || m.oldValue == nil {
  20355. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20356. }
  20357. oldValue, err := m.oldValue(ctx)
  20358. if err != nil {
  20359. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20360. }
  20361. return oldValue.CreatedAt, nil
  20362. }
  20363. // ResetCreatedAt resets all changes to the "created_at" field.
  20364. func (m *SopTaskMutation) ResetCreatedAt() {
  20365. m.created_at = nil
  20366. }
  20367. // SetUpdatedAt sets the "updated_at" field.
  20368. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  20369. m.updated_at = &t
  20370. }
  20371. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20372. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  20373. v := m.updated_at
  20374. if v == nil {
  20375. return
  20376. }
  20377. return *v, true
  20378. }
  20379. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  20380. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20382. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20383. if !m.op.Is(OpUpdateOne) {
  20384. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20385. }
  20386. if m.id == nil || m.oldValue == nil {
  20387. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20388. }
  20389. oldValue, err := m.oldValue(ctx)
  20390. if err != nil {
  20391. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20392. }
  20393. return oldValue.UpdatedAt, nil
  20394. }
  20395. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20396. func (m *SopTaskMutation) ResetUpdatedAt() {
  20397. m.updated_at = nil
  20398. }
  20399. // SetStatus sets the "status" field.
  20400. func (m *SopTaskMutation) SetStatus(u uint8) {
  20401. m.status = &u
  20402. m.addstatus = nil
  20403. }
  20404. // Status returns the value of the "status" field in the mutation.
  20405. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  20406. v := m.status
  20407. if v == nil {
  20408. return
  20409. }
  20410. return *v, true
  20411. }
  20412. // OldStatus returns the old "status" field's value of the SopTask entity.
  20413. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20415. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20416. if !m.op.Is(OpUpdateOne) {
  20417. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20418. }
  20419. if m.id == nil || m.oldValue == nil {
  20420. return v, errors.New("OldStatus requires an ID field in the mutation")
  20421. }
  20422. oldValue, err := m.oldValue(ctx)
  20423. if err != nil {
  20424. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20425. }
  20426. return oldValue.Status, nil
  20427. }
  20428. // AddStatus adds u to the "status" field.
  20429. func (m *SopTaskMutation) AddStatus(u int8) {
  20430. if m.addstatus != nil {
  20431. *m.addstatus += u
  20432. } else {
  20433. m.addstatus = &u
  20434. }
  20435. }
  20436. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20437. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  20438. v := m.addstatus
  20439. if v == nil {
  20440. return
  20441. }
  20442. return *v, true
  20443. }
  20444. // ClearStatus clears the value of the "status" field.
  20445. func (m *SopTaskMutation) ClearStatus() {
  20446. m.status = nil
  20447. m.addstatus = nil
  20448. m.clearedFields[soptask.FieldStatus] = struct{}{}
  20449. }
  20450. // StatusCleared returns if the "status" field was cleared in this mutation.
  20451. func (m *SopTaskMutation) StatusCleared() bool {
  20452. _, ok := m.clearedFields[soptask.FieldStatus]
  20453. return ok
  20454. }
  20455. // ResetStatus resets all changes to the "status" field.
  20456. func (m *SopTaskMutation) ResetStatus() {
  20457. m.status = nil
  20458. m.addstatus = nil
  20459. delete(m.clearedFields, soptask.FieldStatus)
  20460. }
  20461. // SetDeletedAt sets the "deleted_at" field.
  20462. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  20463. m.deleted_at = &t
  20464. }
  20465. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20466. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  20467. v := m.deleted_at
  20468. if v == nil {
  20469. return
  20470. }
  20471. return *v, true
  20472. }
  20473. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  20474. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20476. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20477. if !m.op.Is(OpUpdateOne) {
  20478. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20479. }
  20480. if m.id == nil || m.oldValue == nil {
  20481. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20482. }
  20483. oldValue, err := m.oldValue(ctx)
  20484. if err != nil {
  20485. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20486. }
  20487. return oldValue.DeletedAt, nil
  20488. }
  20489. // ClearDeletedAt clears the value of the "deleted_at" field.
  20490. func (m *SopTaskMutation) ClearDeletedAt() {
  20491. m.deleted_at = nil
  20492. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  20493. }
  20494. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20495. func (m *SopTaskMutation) DeletedAtCleared() bool {
  20496. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  20497. return ok
  20498. }
  20499. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20500. func (m *SopTaskMutation) ResetDeletedAt() {
  20501. m.deleted_at = nil
  20502. delete(m.clearedFields, soptask.FieldDeletedAt)
  20503. }
  20504. // SetName sets the "name" field.
  20505. func (m *SopTaskMutation) SetName(s string) {
  20506. m.name = &s
  20507. }
  20508. // Name returns the value of the "name" field in the mutation.
  20509. func (m *SopTaskMutation) Name() (r string, exists bool) {
  20510. v := m.name
  20511. if v == nil {
  20512. return
  20513. }
  20514. return *v, true
  20515. }
  20516. // OldName returns the old "name" field's value of the SopTask entity.
  20517. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20519. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  20520. if !m.op.Is(OpUpdateOne) {
  20521. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20522. }
  20523. if m.id == nil || m.oldValue == nil {
  20524. return v, errors.New("OldName requires an ID field in the mutation")
  20525. }
  20526. oldValue, err := m.oldValue(ctx)
  20527. if err != nil {
  20528. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20529. }
  20530. return oldValue.Name, nil
  20531. }
  20532. // ResetName resets all changes to the "name" field.
  20533. func (m *SopTaskMutation) ResetName() {
  20534. m.name = nil
  20535. }
  20536. // SetBotWxidList sets the "bot_wxid_list" field.
  20537. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  20538. m.bot_wxid_list = &s
  20539. m.appendbot_wxid_list = nil
  20540. }
  20541. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  20542. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  20543. v := m.bot_wxid_list
  20544. if v == nil {
  20545. return
  20546. }
  20547. return *v, true
  20548. }
  20549. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  20550. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20552. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  20553. if !m.op.Is(OpUpdateOne) {
  20554. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  20555. }
  20556. if m.id == nil || m.oldValue == nil {
  20557. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  20558. }
  20559. oldValue, err := m.oldValue(ctx)
  20560. if err != nil {
  20561. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  20562. }
  20563. return oldValue.BotWxidList, nil
  20564. }
  20565. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  20566. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  20567. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  20568. }
  20569. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  20570. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  20571. if len(m.appendbot_wxid_list) == 0 {
  20572. return nil, false
  20573. }
  20574. return m.appendbot_wxid_list, true
  20575. }
  20576. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  20577. func (m *SopTaskMutation) ClearBotWxidList() {
  20578. m.bot_wxid_list = nil
  20579. m.appendbot_wxid_list = nil
  20580. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  20581. }
  20582. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  20583. func (m *SopTaskMutation) BotWxidListCleared() bool {
  20584. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  20585. return ok
  20586. }
  20587. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  20588. func (m *SopTaskMutation) ResetBotWxidList() {
  20589. m.bot_wxid_list = nil
  20590. m.appendbot_wxid_list = nil
  20591. delete(m.clearedFields, soptask.FieldBotWxidList)
  20592. }
  20593. // SetType sets the "type" field.
  20594. func (m *SopTaskMutation) SetType(i int) {
  20595. m._type = &i
  20596. m.add_type = nil
  20597. }
  20598. // GetType returns the value of the "type" field in the mutation.
  20599. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  20600. v := m._type
  20601. if v == nil {
  20602. return
  20603. }
  20604. return *v, true
  20605. }
  20606. // OldType returns the old "type" field's value of the SopTask entity.
  20607. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20609. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  20610. if !m.op.Is(OpUpdateOne) {
  20611. return v, errors.New("OldType is only allowed on UpdateOne operations")
  20612. }
  20613. if m.id == nil || m.oldValue == nil {
  20614. return v, errors.New("OldType requires an ID field in the mutation")
  20615. }
  20616. oldValue, err := m.oldValue(ctx)
  20617. if err != nil {
  20618. return v, fmt.Errorf("querying old value for OldType: %w", err)
  20619. }
  20620. return oldValue.Type, nil
  20621. }
  20622. // AddType adds i to the "type" field.
  20623. func (m *SopTaskMutation) AddType(i int) {
  20624. if m.add_type != nil {
  20625. *m.add_type += i
  20626. } else {
  20627. m.add_type = &i
  20628. }
  20629. }
  20630. // AddedType returns the value that was added to the "type" field in this mutation.
  20631. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  20632. v := m.add_type
  20633. if v == nil {
  20634. return
  20635. }
  20636. return *v, true
  20637. }
  20638. // ResetType resets all changes to the "type" field.
  20639. func (m *SopTaskMutation) ResetType() {
  20640. m._type = nil
  20641. m.add_type = nil
  20642. }
  20643. // SetPlanStartTime sets the "plan_start_time" field.
  20644. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  20645. m.plan_start_time = &t
  20646. }
  20647. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  20648. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  20649. v := m.plan_start_time
  20650. if v == nil {
  20651. return
  20652. }
  20653. return *v, true
  20654. }
  20655. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  20656. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20658. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  20659. if !m.op.Is(OpUpdateOne) {
  20660. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  20661. }
  20662. if m.id == nil || m.oldValue == nil {
  20663. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  20664. }
  20665. oldValue, err := m.oldValue(ctx)
  20666. if err != nil {
  20667. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  20668. }
  20669. return oldValue.PlanStartTime, nil
  20670. }
  20671. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  20672. func (m *SopTaskMutation) ClearPlanStartTime() {
  20673. m.plan_start_time = nil
  20674. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  20675. }
  20676. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  20677. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  20678. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  20679. return ok
  20680. }
  20681. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  20682. func (m *SopTaskMutation) ResetPlanStartTime() {
  20683. m.plan_start_time = nil
  20684. delete(m.clearedFields, soptask.FieldPlanStartTime)
  20685. }
  20686. // SetPlanEndTime sets the "plan_end_time" field.
  20687. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  20688. m.plan_end_time = &t
  20689. }
  20690. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  20691. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  20692. v := m.plan_end_time
  20693. if v == nil {
  20694. return
  20695. }
  20696. return *v, true
  20697. }
  20698. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  20699. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20701. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  20702. if !m.op.Is(OpUpdateOne) {
  20703. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  20704. }
  20705. if m.id == nil || m.oldValue == nil {
  20706. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  20707. }
  20708. oldValue, err := m.oldValue(ctx)
  20709. if err != nil {
  20710. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  20711. }
  20712. return oldValue.PlanEndTime, nil
  20713. }
  20714. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  20715. func (m *SopTaskMutation) ClearPlanEndTime() {
  20716. m.plan_end_time = nil
  20717. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  20718. }
  20719. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  20720. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  20721. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  20722. return ok
  20723. }
  20724. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  20725. func (m *SopTaskMutation) ResetPlanEndTime() {
  20726. m.plan_end_time = nil
  20727. delete(m.clearedFields, soptask.FieldPlanEndTime)
  20728. }
  20729. // SetCreatorID sets the "creator_id" field.
  20730. func (m *SopTaskMutation) SetCreatorID(s string) {
  20731. m.creator_id = &s
  20732. }
  20733. // CreatorID returns the value of the "creator_id" field in the mutation.
  20734. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  20735. v := m.creator_id
  20736. if v == nil {
  20737. return
  20738. }
  20739. return *v, true
  20740. }
  20741. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  20742. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20744. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  20745. if !m.op.Is(OpUpdateOne) {
  20746. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  20747. }
  20748. if m.id == nil || m.oldValue == nil {
  20749. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  20750. }
  20751. oldValue, err := m.oldValue(ctx)
  20752. if err != nil {
  20753. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  20754. }
  20755. return oldValue.CreatorID, nil
  20756. }
  20757. // ClearCreatorID clears the value of the "creator_id" field.
  20758. func (m *SopTaskMutation) ClearCreatorID() {
  20759. m.creator_id = nil
  20760. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  20761. }
  20762. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  20763. func (m *SopTaskMutation) CreatorIDCleared() bool {
  20764. _, ok := m.clearedFields[soptask.FieldCreatorID]
  20765. return ok
  20766. }
  20767. // ResetCreatorID resets all changes to the "creator_id" field.
  20768. func (m *SopTaskMutation) ResetCreatorID() {
  20769. m.creator_id = nil
  20770. delete(m.clearedFields, soptask.FieldCreatorID)
  20771. }
  20772. // SetOrganizationID sets the "organization_id" field.
  20773. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  20774. m.organization_id = &u
  20775. m.addorganization_id = nil
  20776. }
  20777. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20778. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  20779. v := m.organization_id
  20780. if v == nil {
  20781. return
  20782. }
  20783. return *v, true
  20784. }
  20785. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  20786. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20788. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20789. if !m.op.Is(OpUpdateOne) {
  20790. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20791. }
  20792. if m.id == nil || m.oldValue == nil {
  20793. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20794. }
  20795. oldValue, err := m.oldValue(ctx)
  20796. if err != nil {
  20797. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20798. }
  20799. return oldValue.OrganizationID, nil
  20800. }
  20801. // AddOrganizationID adds u to the "organization_id" field.
  20802. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  20803. if m.addorganization_id != nil {
  20804. *m.addorganization_id += u
  20805. } else {
  20806. m.addorganization_id = &u
  20807. }
  20808. }
  20809. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20810. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  20811. v := m.addorganization_id
  20812. if v == nil {
  20813. return
  20814. }
  20815. return *v, true
  20816. }
  20817. // ClearOrganizationID clears the value of the "organization_id" field.
  20818. func (m *SopTaskMutation) ClearOrganizationID() {
  20819. m.organization_id = nil
  20820. m.addorganization_id = nil
  20821. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  20822. }
  20823. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20824. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  20825. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  20826. return ok
  20827. }
  20828. // ResetOrganizationID resets all changes to the "organization_id" field.
  20829. func (m *SopTaskMutation) ResetOrganizationID() {
  20830. m.organization_id = nil
  20831. m.addorganization_id = nil
  20832. delete(m.clearedFields, soptask.FieldOrganizationID)
  20833. }
  20834. // SetToken sets the "token" field.
  20835. func (m *SopTaskMutation) SetToken(s []string) {
  20836. m.token = &s
  20837. m.appendtoken = nil
  20838. }
  20839. // Token returns the value of the "token" field in the mutation.
  20840. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  20841. v := m.token
  20842. if v == nil {
  20843. return
  20844. }
  20845. return *v, true
  20846. }
  20847. // OldToken returns the old "token" field's value of the SopTask entity.
  20848. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20850. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  20851. if !m.op.Is(OpUpdateOne) {
  20852. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  20853. }
  20854. if m.id == nil || m.oldValue == nil {
  20855. return v, errors.New("OldToken requires an ID field in the mutation")
  20856. }
  20857. oldValue, err := m.oldValue(ctx)
  20858. if err != nil {
  20859. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  20860. }
  20861. return oldValue.Token, nil
  20862. }
  20863. // AppendToken adds s to the "token" field.
  20864. func (m *SopTaskMutation) AppendToken(s []string) {
  20865. m.appendtoken = append(m.appendtoken, s...)
  20866. }
  20867. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  20868. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  20869. if len(m.appendtoken) == 0 {
  20870. return nil, false
  20871. }
  20872. return m.appendtoken, true
  20873. }
  20874. // ClearToken clears the value of the "token" field.
  20875. func (m *SopTaskMutation) ClearToken() {
  20876. m.token = nil
  20877. m.appendtoken = nil
  20878. m.clearedFields[soptask.FieldToken] = struct{}{}
  20879. }
  20880. // TokenCleared returns if the "token" field was cleared in this mutation.
  20881. func (m *SopTaskMutation) TokenCleared() bool {
  20882. _, ok := m.clearedFields[soptask.FieldToken]
  20883. return ok
  20884. }
  20885. // ResetToken resets all changes to the "token" field.
  20886. func (m *SopTaskMutation) ResetToken() {
  20887. m.token = nil
  20888. m.appendtoken = nil
  20889. delete(m.clearedFields, soptask.FieldToken)
  20890. }
  20891. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  20892. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  20893. if m.task_stages == nil {
  20894. m.task_stages = make(map[uint64]struct{})
  20895. }
  20896. for i := range ids {
  20897. m.task_stages[ids[i]] = struct{}{}
  20898. }
  20899. }
  20900. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  20901. func (m *SopTaskMutation) ClearTaskStages() {
  20902. m.clearedtask_stages = true
  20903. }
  20904. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  20905. func (m *SopTaskMutation) TaskStagesCleared() bool {
  20906. return m.clearedtask_stages
  20907. }
  20908. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  20909. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  20910. if m.removedtask_stages == nil {
  20911. m.removedtask_stages = make(map[uint64]struct{})
  20912. }
  20913. for i := range ids {
  20914. delete(m.task_stages, ids[i])
  20915. m.removedtask_stages[ids[i]] = struct{}{}
  20916. }
  20917. }
  20918. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  20919. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  20920. for id := range m.removedtask_stages {
  20921. ids = append(ids, id)
  20922. }
  20923. return
  20924. }
  20925. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  20926. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  20927. for id := range m.task_stages {
  20928. ids = append(ids, id)
  20929. }
  20930. return
  20931. }
  20932. // ResetTaskStages resets all changes to the "task_stages" edge.
  20933. func (m *SopTaskMutation) ResetTaskStages() {
  20934. m.task_stages = nil
  20935. m.clearedtask_stages = false
  20936. m.removedtask_stages = nil
  20937. }
  20938. // Where appends a list predicates to the SopTaskMutation builder.
  20939. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  20940. m.predicates = append(m.predicates, ps...)
  20941. }
  20942. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  20943. // users can use type-assertion to append predicates that do not depend on any generated package.
  20944. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  20945. p := make([]predicate.SopTask, len(ps))
  20946. for i := range ps {
  20947. p[i] = ps[i]
  20948. }
  20949. m.Where(p...)
  20950. }
  20951. // Op returns the operation name.
  20952. func (m *SopTaskMutation) Op() Op {
  20953. return m.op
  20954. }
  20955. // SetOp allows setting the mutation operation.
  20956. func (m *SopTaskMutation) SetOp(op Op) {
  20957. m.op = op
  20958. }
  20959. // Type returns the node type of this mutation (SopTask).
  20960. func (m *SopTaskMutation) Type() string {
  20961. return m.typ
  20962. }
  20963. // Fields returns all fields that were changed during this mutation. Note that in
  20964. // order to get all numeric fields that were incremented/decremented, call
  20965. // AddedFields().
  20966. func (m *SopTaskMutation) Fields() []string {
  20967. fields := make([]string, 0, 12)
  20968. if m.created_at != nil {
  20969. fields = append(fields, soptask.FieldCreatedAt)
  20970. }
  20971. if m.updated_at != nil {
  20972. fields = append(fields, soptask.FieldUpdatedAt)
  20973. }
  20974. if m.status != nil {
  20975. fields = append(fields, soptask.FieldStatus)
  20976. }
  20977. if m.deleted_at != nil {
  20978. fields = append(fields, soptask.FieldDeletedAt)
  20979. }
  20980. if m.name != nil {
  20981. fields = append(fields, soptask.FieldName)
  20982. }
  20983. if m.bot_wxid_list != nil {
  20984. fields = append(fields, soptask.FieldBotWxidList)
  20985. }
  20986. if m._type != nil {
  20987. fields = append(fields, soptask.FieldType)
  20988. }
  20989. if m.plan_start_time != nil {
  20990. fields = append(fields, soptask.FieldPlanStartTime)
  20991. }
  20992. if m.plan_end_time != nil {
  20993. fields = append(fields, soptask.FieldPlanEndTime)
  20994. }
  20995. if m.creator_id != nil {
  20996. fields = append(fields, soptask.FieldCreatorID)
  20997. }
  20998. if m.organization_id != nil {
  20999. fields = append(fields, soptask.FieldOrganizationID)
  21000. }
  21001. if m.token != nil {
  21002. fields = append(fields, soptask.FieldToken)
  21003. }
  21004. return fields
  21005. }
  21006. // Field returns the value of a field with the given name. The second boolean
  21007. // return value indicates that this field was not set, or was not defined in the
  21008. // schema.
  21009. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  21010. switch name {
  21011. case soptask.FieldCreatedAt:
  21012. return m.CreatedAt()
  21013. case soptask.FieldUpdatedAt:
  21014. return m.UpdatedAt()
  21015. case soptask.FieldStatus:
  21016. return m.Status()
  21017. case soptask.FieldDeletedAt:
  21018. return m.DeletedAt()
  21019. case soptask.FieldName:
  21020. return m.Name()
  21021. case soptask.FieldBotWxidList:
  21022. return m.BotWxidList()
  21023. case soptask.FieldType:
  21024. return m.GetType()
  21025. case soptask.FieldPlanStartTime:
  21026. return m.PlanStartTime()
  21027. case soptask.FieldPlanEndTime:
  21028. return m.PlanEndTime()
  21029. case soptask.FieldCreatorID:
  21030. return m.CreatorID()
  21031. case soptask.FieldOrganizationID:
  21032. return m.OrganizationID()
  21033. case soptask.FieldToken:
  21034. return m.Token()
  21035. }
  21036. return nil, false
  21037. }
  21038. // OldField returns the old value of the field from the database. An error is
  21039. // returned if the mutation operation is not UpdateOne, or the query to the
  21040. // database failed.
  21041. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21042. switch name {
  21043. case soptask.FieldCreatedAt:
  21044. return m.OldCreatedAt(ctx)
  21045. case soptask.FieldUpdatedAt:
  21046. return m.OldUpdatedAt(ctx)
  21047. case soptask.FieldStatus:
  21048. return m.OldStatus(ctx)
  21049. case soptask.FieldDeletedAt:
  21050. return m.OldDeletedAt(ctx)
  21051. case soptask.FieldName:
  21052. return m.OldName(ctx)
  21053. case soptask.FieldBotWxidList:
  21054. return m.OldBotWxidList(ctx)
  21055. case soptask.FieldType:
  21056. return m.OldType(ctx)
  21057. case soptask.FieldPlanStartTime:
  21058. return m.OldPlanStartTime(ctx)
  21059. case soptask.FieldPlanEndTime:
  21060. return m.OldPlanEndTime(ctx)
  21061. case soptask.FieldCreatorID:
  21062. return m.OldCreatorID(ctx)
  21063. case soptask.FieldOrganizationID:
  21064. return m.OldOrganizationID(ctx)
  21065. case soptask.FieldToken:
  21066. return m.OldToken(ctx)
  21067. }
  21068. return nil, fmt.Errorf("unknown SopTask field %s", name)
  21069. }
  21070. // SetField sets the value of a field with the given name. It returns an error if
  21071. // the field is not defined in the schema, or if the type mismatched the field
  21072. // type.
  21073. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  21074. switch name {
  21075. case soptask.FieldCreatedAt:
  21076. v, ok := value.(time.Time)
  21077. if !ok {
  21078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21079. }
  21080. m.SetCreatedAt(v)
  21081. return nil
  21082. case soptask.FieldUpdatedAt:
  21083. v, ok := value.(time.Time)
  21084. if !ok {
  21085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21086. }
  21087. m.SetUpdatedAt(v)
  21088. return nil
  21089. case soptask.FieldStatus:
  21090. v, ok := value.(uint8)
  21091. if !ok {
  21092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21093. }
  21094. m.SetStatus(v)
  21095. return nil
  21096. case soptask.FieldDeletedAt:
  21097. v, ok := value.(time.Time)
  21098. if !ok {
  21099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21100. }
  21101. m.SetDeletedAt(v)
  21102. return nil
  21103. case soptask.FieldName:
  21104. v, ok := value.(string)
  21105. if !ok {
  21106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21107. }
  21108. m.SetName(v)
  21109. return nil
  21110. case soptask.FieldBotWxidList:
  21111. v, ok := value.([]string)
  21112. if !ok {
  21113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21114. }
  21115. m.SetBotWxidList(v)
  21116. return nil
  21117. case soptask.FieldType:
  21118. v, ok := value.(int)
  21119. if !ok {
  21120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21121. }
  21122. m.SetType(v)
  21123. return nil
  21124. case soptask.FieldPlanStartTime:
  21125. v, ok := value.(time.Time)
  21126. if !ok {
  21127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21128. }
  21129. m.SetPlanStartTime(v)
  21130. return nil
  21131. case soptask.FieldPlanEndTime:
  21132. v, ok := value.(time.Time)
  21133. if !ok {
  21134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21135. }
  21136. m.SetPlanEndTime(v)
  21137. return nil
  21138. case soptask.FieldCreatorID:
  21139. v, ok := value.(string)
  21140. if !ok {
  21141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21142. }
  21143. m.SetCreatorID(v)
  21144. return nil
  21145. case soptask.FieldOrganizationID:
  21146. v, ok := value.(uint64)
  21147. if !ok {
  21148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21149. }
  21150. m.SetOrganizationID(v)
  21151. return nil
  21152. case soptask.FieldToken:
  21153. v, ok := value.([]string)
  21154. if !ok {
  21155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21156. }
  21157. m.SetToken(v)
  21158. return nil
  21159. }
  21160. return fmt.Errorf("unknown SopTask field %s", name)
  21161. }
  21162. // AddedFields returns all numeric fields that were incremented/decremented during
  21163. // this mutation.
  21164. func (m *SopTaskMutation) AddedFields() []string {
  21165. var fields []string
  21166. if m.addstatus != nil {
  21167. fields = append(fields, soptask.FieldStatus)
  21168. }
  21169. if m.add_type != nil {
  21170. fields = append(fields, soptask.FieldType)
  21171. }
  21172. if m.addorganization_id != nil {
  21173. fields = append(fields, soptask.FieldOrganizationID)
  21174. }
  21175. return fields
  21176. }
  21177. // AddedField returns the numeric value that was incremented/decremented on a field
  21178. // with the given name. The second boolean return value indicates that this field
  21179. // was not set, or was not defined in the schema.
  21180. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  21181. switch name {
  21182. case soptask.FieldStatus:
  21183. return m.AddedStatus()
  21184. case soptask.FieldType:
  21185. return m.AddedType()
  21186. case soptask.FieldOrganizationID:
  21187. return m.AddedOrganizationID()
  21188. }
  21189. return nil, false
  21190. }
  21191. // AddField adds the value to the field with the given name. It returns an error if
  21192. // the field is not defined in the schema, or if the type mismatched the field
  21193. // type.
  21194. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  21195. switch name {
  21196. case soptask.FieldStatus:
  21197. v, ok := value.(int8)
  21198. if !ok {
  21199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21200. }
  21201. m.AddStatus(v)
  21202. return nil
  21203. case soptask.FieldType:
  21204. v, ok := value.(int)
  21205. if !ok {
  21206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21207. }
  21208. m.AddType(v)
  21209. return nil
  21210. case soptask.FieldOrganizationID:
  21211. v, ok := value.(int64)
  21212. if !ok {
  21213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21214. }
  21215. m.AddOrganizationID(v)
  21216. return nil
  21217. }
  21218. return fmt.Errorf("unknown SopTask numeric field %s", name)
  21219. }
  21220. // ClearedFields returns all nullable fields that were cleared during this
  21221. // mutation.
  21222. func (m *SopTaskMutation) ClearedFields() []string {
  21223. var fields []string
  21224. if m.FieldCleared(soptask.FieldStatus) {
  21225. fields = append(fields, soptask.FieldStatus)
  21226. }
  21227. if m.FieldCleared(soptask.FieldDeletedAt) {
  21228. fields = append(fields, soptask.FieldDeletedAt)
  21229. }
  21230. if m.FieldCleared(soptask.FieldBotWxidList) {
  21231. fields = append(fields, soptask.FieldBotWxidList)
  21232. }
  21233. if m.FieldCleared(soptask.FieldPlanStartTime) {
  21234. fields = append(fields, soptask.FieldPlanStartTime)
  21235. }
  21236. if m.FieldCleared(soptask.FieldPlanEndTime) {
  21237. fields = append(fields, soptask.FieldPlanEndTime)
  21238. }
  21239. if m.FieldCleared(soptask.FieldCreatorID) {
  21240. fields = append(fields, soptask.FieldCreatorID)
  21241. }
  21242. if m.FieldCleared(soptask.FieldOrganizationID) {
  21243. fields = append(fields, soptask.FieldOrganizationID)
  21244. }
  21245. if m.FieldCleared(soptask.FieldToken) {
  21246. fields = append(fields, soptask.FieldToken)
  21247. }
  21248. return fields
  21249. }
  21250. // FieldCleared returns a boolean indicating if a field with the given name was
  21251. // cleared in this mutation.
  21252. func (m *SopTaskMutation) FieldCleared(name string) bool {
  21253. _, ok := m.clearedFields[name]
  21254. return ok
  21255. }
  21256. // ClearField clears the value of the field with the given name. It returns an
  21257. // error if the field is not defined in the schema.
  21258. func (m *SopTaskMutation) ClearField(name string) error {
  21259. switch name {
  21260. case soptask.FieldStatus:
  21261. m.ClearStatus()
  21262. return nil
  21263. case soptask.FieldDeletedAt:
  21264. m.ClearDeletedAt()
  21265. return nil
  21266. case soptask.FieldBotWxidList:
  21267. m.ClearBotWxidList()
  21268. return nil
  21269. case soptask.FieldPlanStartTime:
  21270. m.ClearPlanStartTime()
  21271. return nil
  21272. case soptask.FieldPlanEndTime:
  21273. m.ClearPlanEndTime()
  21274. return nil
  21275. case soptask.FieldCreatorID:
  21276. m.ClearCreatorID()
  21277. return nil
  21278. case soptask.FieldOrganizationID:
  21279. m.ClearOrganizationID()
  21280. return nil
  21281. case soptask.FieldToken:
  21282. m.ClearToken()
  21283. return nil
  21284. }
  21285. return fmt.Errorf("unknown SopTask nullable field %s", name)
  21286. }
  21287. // ResetField resets all changes in the mutation for the field with the given name.
  21288. // It returns an error if the field is not defined in the schema.
  21289. func (m *SopTaskMutation) ResetField(name string) error {
  21290. switch name {
  21291. case soptask.FieldCreatedAt:
  21292. m.ResetCreatedAt()
  21293. return nil
  21294. case soptask.FieldUpdatedAt:
  21295. m.ResetUpdatedAt()
  21296. return nil
  21297. case soptask.FieldStatus:
  21298. m.ResetStatus()
  21299. return nil
  21300. case soptask.FieldDeletedAt:
  21301. m.ResetDeletedAt()
  21302. return nil
  21303. case soptask.FieldName:
  21304. m.ResetName()
  21305. return nil
  21306. case soptask.FieldBotWxidList:
  21307. m.ResetBotWxidList()
  21308. return nil
  21309. case soptask.FieldType:
  21310. m.ResetType()
  21311. return nil
  21312. case soptask.FieldPlanStartTime:
  21313. m.ResetPlanStartTime()
  21314. return nil
  21315. case soptask.FieldPlanEndTime:
  21316. m.ResetPlanEndTime()
  21317. return nil
  21318. case soptask.FieldCreatorID:
  21319. m.ResetCreatorID()
  21320. return nil
  21321. case soptask.FieldOrganizationID:
  21322. m.ResetOrganizationID()
  21323. return nil
  21324. case soptask.FieldToken:
  21325. m.ResetToken()
  21326. return nil
  21327. }
  21328. return fmt.Errorf("unknown SopTask field %s", name)
  21329. }
  21330. // AddedEdges returns all edge names that were set/added in this mutation.
  21331. func (m *SopTaskMutation) AddedEdges() []string {
  21332. edges := make([]string, 0, 1)
  21333. if m.task_stages != nil {
  21334. edges = append(edges, soptask.EdgeTaskStages)
  21335. }
  21336. return edges
  21337. }
  21338. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21339. // name in this mutation.
  21340. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  21341. switch name {
  21342. case soptask.EdgeTaskStages:
  21343. ids := make([]ent.Value, 0, len(m.task_stages))
  21344. for id := range m.task_stages {
  21345. ids = append(ids, id)
  21346. }
  21347. return ids
  21348. }
  21349. return nil
  21350. }
  21351. // RemovedEdges returns all edge names that were removed in this mutation.
  21352. func (m *SopTaskMutation) RemovedEdges() []string {
  21353. edges := make([]string, 0, 1)
  21354. if m.removedtask_stages != nil {
  21355. edges = append(edges, soptask.EdgeTaskStages)
  21356. }
  21357. return edges
  21358. }
  21359. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21360. // the given name in this mutation.
  21361. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  21362. switch name {
  21363. case soptask.EdgeTaskStages:
  21364. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  21365. for id := range m.removedtask_stages {
  21366. ids = append(ids, id)
  21367. }
  21368. return ids
  21369. }
  21370. return nil
  21371. }
  21372. // ClearedEdges returns all edge names that were cleared in this mutation.
  21373. func (m *SopTaskMutation) ClearedEdges() []string {
  21374. edges := make([]string, 0, 1)
  21375. if m.clearedtask_stages {
  21376. edges = append(edges, soptask.EdgeTaskStages)
  21377. }
  21378. return edges
  21379. }
  21380. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21381. // was cleared in this mutation.
  21382. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  21383. switch name {
  21384. case soptask.EdgeTaskStages:
  21385. return m.clearedtask_stages
  21386. }
  21387. return false
  21388. }
  21389. // ClearEdge clears the value of the edge with the given name. It returns an error
  21390. // if that edge is not defined in the schema.
  21391. func (m *SopTaskMutation) ClearEdge(name string) error {
  21392. switch name {
  21393. }
  21394. return fmt.Errorf("unknown SopTask unique edge %s", name)
  21395. }
  21396. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21397. // It returns an error if the edge is not defined in the schema.
  21398. func (m *SopTaskMutation) ResetEdge(name string) error {
  21399. switch name {
  21400. case soptask.EdgeTaskStages:
  21401. m.ResetTaskStages()
  21402. return nil
  21403. }
  21404. return fmt.Errorf("unknown SopTask edge %s", name)
  21405. }
  21406. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  21407. type TokenMutation struct {
  21408. config
  21409. op Op
  21410. typ string
  21411. id *uint64
  21412. created_at *time.Time
  21413. updated_at *time.Time
  21414. deleted_at *time.Time
  21415. expire_at *time.Time
  21416. token *string
  21417. mac *string
  21418. organization_id *uint64
  21419. addorganization_id *int64
  21420. custom_agent_base *string
  21421. custom_agent_key *string
  21422. openai_base *string
  21423. openai_key *string
  21424. clearedFields map[string]struct{}
  21425. agent *uint64
  21426. clearedagent bool
  21427. done bool
  21428. oldValue func(context.Context) (*Token, error)
  21429. predicates []predicate.Token
  21430. }
  21431. var _ ent.Mutation = (*TokenMutation)(nil)
  21432. // tokenOption allows management of the mutation configuration using functional options.
  21433. type tokenOption func(*TokenMutation)
  21434. // newTokenMutation creates new mutation for the Token entity.
  21435. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  21436. m := &TokenMutation{
  21437. config: c,
  21438. op: op,
  21439. typ: TypeToken,
  21440. clearedFields: make(map[string]struct{}),
  21441. }
  21442. for _, opt := range opts {
  21443. opt(m)
  21444. }
  21445. return m
  21446. }
  21447. // withTokenID sets the ID field of the mutation.
  21448. func withTokenID(id uint64) tokenOption {
  21449. return func(m *TokenMutation) {
  21450. var (
  21451. err error
  21452. once sync.Once
  21453. value *Token
  21454. )
  21455. m.oldValue = func(ctx context.Context) (*Token, error) {
  21456. once.Do(func() {
  21457. if m.done {
  21458. err = errors.New("querying old values post mutation is not allowed")
  21459. } else {
  21460. value, err = m.Client().Token.Get(ctx, id)
  21461. }
  21462. })
  21463. return value, err
  21464. }
  21465. m.id = &id
  21466. }
  21467. }
  21468. // withToken sets the old Token of the mutation.
  21469. func withToken(node *Token) tokenOption {
  21470. return func(m *TokenMutation) {
  21471. m.oldValue = func(context.Context) (*Token, error) {
  21472. return node, nil
  21473. }
  21474. m.id = &node.ID
  21475. }
  21476. }
  21477. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21478. // executed in a transaction (ent.Tx), a transactional client is returned.
  21479. func (m TokenMutation) Client() *Client {
  21480. client := &Client{config: m.config}
  21481. client.init()
  21482. return client
  21483. }
  21484. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21485. // it returns an error otherwise.
  21486. func (m TokenMutation) Tx() (*Tx, error) {
  21487. if _, ok := m.driver.(*txDriver); !ok {
  21488. return nil, errors.New("ent: mutation is not running in a transaction")
  21489. }
  21490. tx := &Tx{config: m.config}
  21491. tx.init()
  21492. return tx, nil
  21493. }
  21494. // SetID sets the value of the id field. Note that this
  21495. // operation is only accepted on creation of Token entities.
  21496. func (m *TokenMutation) SetID(id uint64) {
  21497. m.id = &id
  21498. }
  21499. // ID returns the ID value in the mutation. Note that the ID is only available
  21500. // if it was provided to the builder or after it was returned from the database.
  21501. func (m *TokenMutation) ID() (id uint64, exists bool) {
  21502. if m.id == nil {
  21503. return
  21504. }
  21505. return *m.id, true
  21506. }
  21507. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21508. // That means, if the mutation is applied within a transaction with an isolation level such
  21509. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21510. // or updated by the mutation.
  21511. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  21512. switch {
  21513. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21514. id, exists := m.ID()
  21515. if exists {
  21516. return []uint64{id}, nil
  21517. }
  21518. fallthrough
  21519. case m.op.Is(OpUpdate | OpDelete):
  21520. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  21521. default:
  21522. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21523. }
  21524. }
  21525. // SetCreatedAt sets the "created_at" field.
  21526. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  21527. m.created_at = &t
  21528. }
  21529. // CreatedAt returns the value of the "created_at" field in the mutation.
  21530. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  21531. v := m.created_at
  21532. if v == nil {
  21533. return
  21534. }
  21535. return *v, true
  21536. }
  21537. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  21538. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21540. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21541. if !m.op.Is(OpUpdateOne) {
  21542. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21543. }
  21544. if m.id == nil || m.oldValue == nil {
  21545. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21546. }
  21547. oldValue, err := m.oldValue(ctx)
  21548. if err != nil {
  21549. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21550. }
  21551. return oldValue.CreatedAt, nil
  21552. }
  21553. // ResetCreatedAt resets all changes to the "created_at" field.
  21554. func (m *TokenMutation) ResetCreatedAt() {
  21555. m.created_at = nil
  21556. }
  21557. // SetUpdatedAt sets the "updated_at" field.
  21558. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  21559. m.updated_at = &t
  21560. }
  21561. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21562. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  21563. v := m.updated_at
  21564. if v == nil {
  21565. return
  21566. }
  21567. return *v, true
  21568. }
  21569. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  21570. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21572. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21573. if !m.op.Is(OpUpdateOne) {
  21574. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21575. }
  21576. if m.id == nil || m.oldValue == nil {
  21577. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21578. }
  21579. oldValue, err := m.oldValue(ctx)
  21580. if err != nil {
  21581. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21582. }
  21583. return oldValue.UpdatedAt, nil
  21584. }
  21585. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21586. func (m *TokenMutation) ResetUpdatedAt() {
  21587. m.updated_at = nil
  21588. }
  21589. // SetDeletedAt sets the "deleted_at" field.
  21590. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  21591. m.deleted_at = &t
  21592. }
  21593. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21594. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  21595. v := m.deleted_at
  21596. if v == nil {
  21597. return
  21598. }
  21599. return *v, true
  21600. }
  21601. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  21602. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21604. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21605. if !m.op.Is(OpUpdateOne) {
  21606. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21607. }
  21608. if m.id == nil || m.oldValue == nil {
  21609. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21610. }
  21611. oldValue, err := m.oldValue(ctx)
  21612. if err != nil {
  21613. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21614. }
  21615. return oldValue.DeletedAt, nil
  21616. }
  21617. // ClearDeletedAt clears the value of the "deleted_at" field.
  21618. func (m *TokenMutation) ClearDeletedAt() {
  21619. m.deleted_at = nil
  21620. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  21621. }
  21622. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21623. func (m *TokenMutation) DeletedAtCleared() bool {
  21624. _, ok := m.clearedFields[token.FieldDeletedAt]
  21625. return ok
  21626. }
  21627. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21628. func (m *TokenMutation) ResetDeletedAt() {
  21629. m.deleted_at = nil
  21630. delete(m.clearedFields, token.FieldDeletedAt)
  21631. }
  21632. // SetExpireAt sets the "expire_at" field.
  21633. func (m *TokenMutation) SetExpireAt(t time.Time) {
  21634. m.expire_at = &t
  21635. }
  21636. // ExpireAt returns the value of the "expire_at" field in the mutation.
  21637. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  21638. v := m.expire_at
  21639. if v == nil {
  21640. return
  21641. }
  21642. return *v, true
  21643. }
  21644. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  21645. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21647. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  21648. if !m.op.Is(OpUpdateOne) {
  21649. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  21650. }
  21651. if m.id == nil || m.oldValue == nil {
  21652. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  21653. }
  21654. oldValue, err := m.oldValue(ctx)
  21655. if err != nil {
  21656. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  21657. }
  21658. return oldValue.ExpireAt, nil
  21659. }
  21660. // ClearExpireAt clears the value of the "expire_at" field.
  21661. func (m *TokenMutation) ClearExpireAt() {
  21662. m.expire_at = nil
  21663. m.clearedFields[token.FieldExpireAt] = struct{}{}
  21664. }
  21665. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  21666. func (m *TokenMutation) ExpireAtCleared() bool {
  21667. _, ok := m.clearedFields[token.FieldExpireAt]
  21668. return ok
  21669. }
  21670. // ResetExpireAt resets all changes to the "expire_at" field.
  21671. func (m *TokenMutation) ResetExpireAt() {
  21672. m.expire_at = nil
  21673. delete(m.clearedFields, token.FieldExpireAt)
  21674. }
  21675. // SetToken sets the "token" field.
  21676. func (m *TokenMutation) SetToken(s string) {
  21677. m.token = &s
  21678. }
  21679. // Token returns the value of the "token" field in the mutation.
  21680. func (m *TokenMutation) Token() (r string, exists bool) {
  21681. v := m.token
  21682. if v == nil {
  21683. return
  21684. }
  21685. return *v, true
  21686. }
  21687. // OldToken returns the old "token" field's value of the Token entity.
  21688. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21690. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  21691. if !m.op.Is(OpUpdateOne) {
  21692. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  21693. }
  21694. if m.id == nil || m.oldValue == nil {
  21695. return v, errors.New("OldToken requires an ID field in the mutation")
  21696. }
  21697. oldValue, err := m.oldValue(ctx)
  21698. if err != nil {
  21699. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  21700. }
  21701. return oldValue.Token, nil
  21702. }
  21703. // ClearToken clears the value of the "token" field.
  21704. func (m *TokenMutation) ClearToken() {
  21705. m.token = nil
  21706. m.clearedFields[token.FieldToken] = struct{}{}
  21707. }
  21708. // TokenCleared returns if the "token" field was cleared in this mutation.
  21709. func (m *TokenMutation) TokenCleared() bool {
  21710. _, ok := m.clearedFields[token.FieldToken]
  21711. return ok
  21712. }
  21713. // ResetToken resets all changes to the "token" field.
  21714. func (m *TokenMutation) ResetToken() {
  21715. m.token = nil
  21716. delete(m.clearedFields, token.FieldToken)
  21717. }
  21718. // SetMAC sets the "mac" field.
  21719. func (m *TokenMutation) SetMAC(s string) {
  21720. m.mac = &s
  21721. }
  21722. // MAC returns the value of the "mac" field in the mutation.
  21723. func (m *TokenMutation) MAC() (r string, exists bool) {
  21724. v := m.mac
  21725. if v == nil {
  21726. return
  21727. }
  21728. return *v, true
  21729. }
  21730. // OldMAC returns the old "mac" field's value of the Token entity.
  21731. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21733. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  21734. if !m.op.Is(OpUpdateOne) {
  21735. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  21736. }
  21737. if m.id == nil || m.oldValue == nil {
  21738. return v, errors.New("OldMAC requires an ID field in the mutation")
  21739. }
  21740. oldValue, err := m.oldValue(ctx)
  21741. if err != nil {
  21742. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  21743. }
  21744. return oldValue.MAC, nil
  21745. }
  21746. // ClearMAC clears the value of the "mac" field.
  21747. func (m *TokenMutation) ClearMAC() {
  21748. m.mac = nil
  21749. m.clearedFields[token.FieldMAC] = struct{}{}
  21750. }
  21751. // MACCleared returns if the "mac" field was cleared in this mutation.
  21752. func (m *TokenMutation) MACCleared() bool {
  21753. _, ok := m.clearedFields[token.FieldMAC]
  21754. return ok
  21755. }
  21756. // ResetMAC resets all changes to the "mac" field.
  21757. func (m *TokenMutation) ResetMAC() {
  21758. m.mac = nil
  21759. delete(m.clearedFields, token.FieldMAC)
  21760. }
  21761. // SetOrganizationID sets the "organization_id" field.
  21762. func (m *TokenMutation) SetOrganizationID(u uint64) {
  21763. m.organization_id = &u
  21764. m.addorganization_id = nil
  21765. }
  21766. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21767. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  21768. v := m.organization_id
  21769. if v == nil {
  21770. return
  21771. }
  21772. return *v, true
  21773. }
  21774. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  21775. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21777. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21778. if !m.op.Is(OpUpdateOne) {
  21779. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21780. }
  21781. if m.id == nil || m.oldValue == nil {
  21782. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21783. }
  21784. oldValue, err := m.oldValue(ctx)
  21785. if err != nil {
  21786. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21787. }
  21788. return oldValue.OrganizationID, nil
  21789. }
  21790. // AddOrganizationID adds u to the "organization_id" field.
  21791. func (m *TokenMutation) AddOrganizationID(u int64) {
  21792. if m.addorganization_id != nil {
  21793. *m.addorganization_id += u
  21794. } else {
  21795. m.addorganization_id = &u
  21796. }
  21797. }
  21798. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21799. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  21800. v := m.addorganization_id
  21801. if v == nil {
  21802. return
  21803. }
  21804. return *v, true
  21805. }
  21806. // ResetOrganizationID resets all changes to the "organization_id" field.
  21807. func (m *TokenMutation) ResetOrganizationID() {
  21808. m.organization_id = nil
  21809. m.addorganization_id = nil
  21810. }
  21811. // SetAgentID sets the "agent_id" field.
  21812. func (m *TokenMutation) SetAgentID(u uint64) {
  21813. m.agent = &u
  21814. }
  21815. // AgentID returns the value of the "agent_id" field in the mutation.
  21816. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  21817. v := m.agent
  21818. if v == nil {
  21819. return
  21820. }
  21821. return *v, true
  21822. }
  21823. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  21824. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21826. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  21827. if !m.op.Is(OpUpdateOne) {
  21828. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  21829. }
  21830. if m.id == nil || m.oldValue == nil {
  21831. return v, errors.New("OldAgentID requires an ID field in the mutation")
  21832. }
  21833. oldValue, err := m.oldValue(ctx)
  21834. if err != nil {
  21835. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  21836. }
  21837. return oldValue.AgentID, nil
  21838. }
  21839. // ResetAgentID resets all changes to the "agent_id" field.
  21840. func (m *TokenMutation) ResetAgentID() {
  21841. m.agent = nil
  21842. }
  21843. // SetCustomAgentBase sets the "custom_agent_base" field.
  21844. func (m *TokenMutation) SetCustomAgentBase(s string) {
  21845. m.custom_agent_base = &s
  21846. }
  21847. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  21848. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  21849. v := m.custom_agent_base
  21850. if v == nil {
  21851. return
  21852. }
  21853. return *v, true
  21854. }
  21855. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  21856. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21858. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  21859. if !m.op.Is(OpUpdateOne) {
  21860. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  21861. }
  21862. if m.id == nil || m.oldValue == nil {
  21863. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  21864. }
  21865. oldValue, err := m.oldValue(ctx)
  21866. if err != nil {
  21867. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  21868. }
  21869. return oldValue.CustomAgentBase, nil
  21870. }
  21871. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  21872. func (m *TokenMutation) ClearCustomAgentBase() {
  21873. m.custom_agent_base = nil
  21874. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  21875. }
  21876. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  21877. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  21878. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  21879. return ok
  21880. }
  21881. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  21882. func (m *TokenMutation) ResetCustomAgentBase() {
  21883. m.custom_agent_base = nil
  21884. delete(m.clearedFields, token.FieldCustomAgentBase)
  21885. }
  21886. // SetCustomAgentKey sets the "custom_agent_key" field.
  21887. func (m *TokenMutation) SetCustomAgentKey(s string) {
  21888. m.custom_agent_key = &s
  21889. }
  21890. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  21891. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  21892. v := m.custom_agent_key
  21893. if v == nil {
  21894. return
  21895. }
  21896. return *v, true
  21897. }
  21898. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  21899. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21901. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  21902. if !m.op.Is(OpUpdateOne) {
  21903. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  21904. }
  21905. if m.id == nil || m.oldValue == nil {
  21906. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  21907. }
  21908. oldValue, err := m.oldValue(ctx)
  21909. if err != nil {
  21910. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  21911. }
  21912. return oldValue.CustomAgentKey, nil
  21913. }
  21914. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  21915. func (m *TokenMutation) ClearCustomAgentKey() {
  21916. m.custom_agent_key = nil
  21917. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  21918. }
  21919. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  21920. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  21921. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  21922. return ok
  21923. }
  21924. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  21925. func (m *TokenMutation) ResetCustomAgentKey() {
  21926. m.custom_agent_key = nil
  21927. delete(m.clearedFields, token.FieldCustomAgentKey)
  21928. }
  21929. // SetOpenaiBase sets the "openai_base" field.
  21930. func (m *TokenMutation) SetOpenaiBase(s string) {
  21931. m.openai_base = &s
  21932. }
  21933. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  21934. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  21935. v := m.openai_base
  21936. if v == nil {
  21937. return
  21938. }
  21939. return *v, true
  21940. }
  21941. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  21942. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21944. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  21945. if !m.op.Is(OpUpdateOne) {
  21946. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  21947. }
  21948. if m.id == nil || m.oldValue == nil {
  21949. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  21950. }
  21951. oldValue, err := m.oldValue(ctx)
  21952. if err != nil {
  21953. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  21954. }
  21955. return oldValue.OpenaiBase, nil
  21956. }
  21957. // ClearOpenaiBase clears the value of the "openai_base" field.
  21958. func (m *TokenMutation) ClearOpenaiBase() {
  21959. m.openai_base = nil
  21960. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  21961. }
  21962. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  21963. func (m *TokenMutation) OpenaiBaseCleared() bool {
  21964. _, ok := m.clearedFields[token.FieldOpenaiBase]
  21965. return ok
  21966. }
  21967. // ResetOpenaiBase resets all changes to the "openai_base" field.
  21968. func (m *TokenMutation) ResetOpenaiBase() {
  21969. m.openai_base = nil
  21970. delete(m.clearedFields, token.FieldOpenaiBase)
  21971. }
  21972. // SetOpenaiKey sets the "openai_key" field.
  21973. func (m *TokenMutation) SetOpenaiKey(s string) {
  21974. m.openai_key = &s
  21975. }
  21976. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  21977. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  21978. v := m.openai_key
  21979. if v == nil {
  21980. return
  21981. }
  21982. return *v, true
  21983. }
  21984. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  21985. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21987. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  21988. if !m.op.Is(OpUpdateOne) {
  21989. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  21990. }
  21991. if m.id == nil || m.oldValue == nil {
  21992. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  21993. }
  21994. oldValue, err := m.oldValue(ctx)
  21995. if err != nil {
  21996. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  21997. }
  21998. return oldValue.OpenaiKey, nil
  21999. }
  22000. // ClearOpenaiKey clears the value of the "openai_key" field.
  22001. func (m *TokenMutation) ClearOpenaiKey() {
  22002. m.openai_key = nil
  22003. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  22004. }
  22005. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  22006. func (m *TokenMutation) OpenaiKeyCleared() bool {
  22007. _, ok := m.clearedFields[token.FieldOpenaiKey]
  22008. return ok
  22009. }
  22010. // ResetOpenaiKey resets all changes to the "openai_key" field.
  22011. func (m *TokenMutation) ResetOpenaiKey() {
  22012. m.openai_key = nil
  22013. delete(m.clearedFields, token.FieldOpenaiKey)
  22014. }
  22015. // ClearAgent clears the "agent" edge to the Agent entity.
  22016. func (m *TokenMutation) ClearAgent() {
  22017. m.clearedagent = true
  22018. m.clearedFields[token.FieldAgentID] = struct{}{}
  22019. }
  22020. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  22021. func (m *TokenMutation) AgentCleared() bool {
  22022. return m.clearedagent
  22023. }
  22024. // AgentIDs returns the "agent" edge IDs in the mutation.
  22025. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22026. // AgentID instead. It exists only for internal usage by the builders.
  22027. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  22028. if id := m.agent; id != nil {
  22029. ids = append(ids, *id)
  22030. }
  22031. return
  22032. }
  22033. // ResetAgent resets all changes to the "agent" edge.
  22034. func (m *TokenMutation) ResetAgent() {
  22035. m.agent = nil
  22036. m.clearedagent = false
  22037. }
  22038. // Where appends a list predicates to the TokenMutation builder.
  22039. func (m *TokenMutation) Where(ps ...predicate.Token) {
  22040. m.predicates = append(m.predicates, ps...)
  22041. }
  22042. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  22043. // users can use type-assertion to append predicates that do not depend on any generated package.
  22044. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  22045. p := make([]predicate.Token, len(ps))
  22046. for i := range ps {
  22047. p[i] = ps[i]
  22048. }
  22049. m.Where(p...)
  22050. }
  22051. // Op returns the operation name.
  22052. func (m *TokenMutation) Op() Op {
  22053. return m.op
  22054. }
  22055. // SetOp allows setting the mutation operation.
  22056. func (m *TokenMutation) SetOp(op Op) {
  22057. m.op = op
  22058. }
  22059. // Type returns the node type of this mutation (Token).
  22060. func (m *TokenMutation) Type() string {
  22061. return m.typ
  22062. }
  22063. // Fields returns all fields that were changed during this mutation. Note that in
  22064. // order to get all numeric fields that were incremented/decremented, call
  22065. // AddedFields().
  22066. func (m *TokenMutation) Fields() []string {
  22067. fields := make([]string, 0, 12)
  22068. if m.created_at != nil {
  22069. fields = append(fields, token.FieldCreatedAt)
  22070. }
  22071. if m.updated_at != nil {
  22072. fields = append(fields, token.FieldUpdatedAt)
  22073. }
  22074. if m.deleted_at != nil {
  22075. fields = append(fields, token.FieldDeletedAt)
  22076. }
  22077. if m.expire_at != nil {
  22078. fields = append(fields, token.FieldExpireAt)
  22079. }
  22080. if m.token != nil {
  22081. fields = append(fields, token.FieldToken)
  22082. }
  22083. if m.mac != nil {
  22084. fields = append(fields, token.FieldMAC)
  22085. }
  22086. if m.organization_id != nil {
  22087. fields = append(fields, token.FieldOrganizationID)
  22088. }
  22089. if m.agent != nil {
  22090. fields = append(fields, token.FieldAgentID)
  22091. }
  22092. if m.custom_agent_base != nil {
  22093. fields = append(fields, token.FieldCustomAgentBase)
  22094. }
  22095. if m.custom_agent_key != nil {
  22096. fields = append(fields, token.FieldCustomAgentKey)
  22097. }
  22098. if m.openai_base != nil {
  22099. fields = append(fields, token.FieldOpenaiBase)
  22100. }
  22101. if m.openai_key != nil {
  22102. fields = append(fields, token.FieldOpenaiKey)
  22103. }
  22104. return fields
  22105. }
  22106. // Field returns the value of a field with the given name. The second boolean
  22107. // return value indicates that this field was not set, or was not defined in the
  22108. // schema.
  22109. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  22110. switch name {
  22111. case token.FieldCreatedAt:
  22112. return m.CreatedAt()
  22113. case token.FieldUpdatedAt:
  22114. return m.UpdatedAt()
  22115. case token.FieldDeletedAt:
  22116. return m.DeletedAt()
  22117. case token.FieldExpireAt:
  22118. return m.ExpireAt()
  22119. case token.FieldToken:
  22120. return m.Token()
  22121. case token.FieldMAC:
  22122. return m.MAC()
  22123. case token.FieldOrganizationID:
  22124. return m.OrganizationID()
  22125. case token.FieldAgentID:
  22126. return m.AgentID()
  22127. case token.FieldCustomAgentBase:
  22128. return m.CustomAgentBase()
  22129. case token.FieldCustomAgentKey:
  22130. return m.CustomAgentKey()
  22131. case token.FieldOpenaiBase:
  22132. return m.OpenaiBase()
  22133. case token.FieldOpenaiKey:
  22134. return m.OpenaiKey()
  22135. }
  22136. return nil, false
  22137. }
  22138. // OldField returns the old value of the field from the database. An error is
  22139. // returned if the mutation operation is not UpdateOne, or the query to the
  22140. // database failed.
  22141. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22142. switch name {
  22143. case token.FieldCreatedAt:
  22144. return m.OldCreatedAt(ctx)
  22145. case token.FieldUpdatedAt:
  22146. return m.OldUpdatedAt(ctx)
  22147. case token.FieldDeletedAt:
  22148. return m.OldDeletedAt(ctx)
  22149. case token.FieldExpireAt:
  22150. return m.OldExpireAt(ctx)
  22151. case token.FieldToken:
  22152. return m.OldToken(ctx)
  22153. case token.FieldMAC:
  22154. return m.OldMAC(ctx)
  22155. case token.FieldOrganizationID:
  22156. return m.OldOrganizationID(ctx)
  22157. case token.FieldAgentID:
  22158. return m.OldAgentID(ctx)
  22159. case token.FieldCustomAgentBase:
  22160. return m.OldCustomAgentBase(ctx)
  22161. case token.FieldCustomAgentKey:
  22162. return m.OldCustomAgentKey(ctx)
  22163. case token.FieldOpenaiBase:
  22164. return m.OldOpenaiBase(ctx)
  22165. case token.FieldOpenaiKey:
  22166. return m.OldOpenaiKey(ctx)
  22167. }
  22168. return nil, fmt.Errorf("unknown Token field %s", name)
  22169. }
  22170. // SetField sets the value of a field with the given name. It returns an error if
  22171. // the field is not defined in the schema, or if the type mismatched the field
  22172. // type.
  22173. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  22174. switch name {
  22175. case token.FieldCreatedAt:
  22176. v, ok := value.(time.Time)
  22177. if !ok {
  22178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22179. }
  22180. m.SetCreatedAt(v)
  22181. return nil
  22182. case token.FieldUpdatedAt:
  22183. v, ok := value.(time.Time)
  22184. if !ok {
  22185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22186. }
  22187. m.SetUpdatedAt(v)
  22188. return nil
  22189. case token.FieldDeletedAt:
  22190. v, ok := value.(time.Time)
  22191. if !ok {
  22192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22193. }
  22194. m.SetDeletedAt(v)
  22195. return nil
  22196. case token.FieldExpireAt:
  22197. v, ok := value.(time.Time)
  22198. if !ok {
  22199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22200. }
  22201. m.SetExpireAt(v)
  22202. return nil
  22203. case token.FieldToken:
  22204. v, ok := value.(string)
  22205. if !ok {
  22206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22207. }
  22208. m.SetToken(v)
  22209. return nil
  22210. case token.FieldMAC:
  22211. v, ok := value.(string)
  22212. if !ok {
  22213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22214. }
  22215. m.SetMAC(v)
  22216. return nil
  22217. case token.FieldOrganizationID:
  22218. v, ok := value.(uint64)
  22219. if !ok {
  22220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22221. }
  22222. m.SetOrganizationID(v)
  22223. return nil
  22224. case token.FieldAgentID:
  22225. v, ok := value.(uint64)
  22226. if !ok {
  22227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22228. }
  22229. m.SetAgentID(v)
  22230. return nil
  22231. case token.FieldCustomAgentBase:
  22232. v, ok := value.(string)
  22233. if !ok {
  22234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22235. }
  22236. m.SetCustomAgentBase(v)
  22237. return nil
  22238. case token.FieldCustomAgentKey:
  22239. v, ok := value.(string)
  22240. if !ok {
  22241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22242. }
  22243. m.SetCustomAgentKey(v)
  22244. return nil
  22245. case token.FieldOpenaiBase:
  22246. v, ok := value.(string)
  22247. if !ok {
  22248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22249. }
  22250. m.SetOpenaiBase(v)
  22251. return nil
  22252. case token.FieldOpenaiKey:
  22253. v, ok := value.(string)
  22254. if !ok {
  22255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22256. }
  22257. m.SetOpenaiKey(v)
  22258. return nil
  22259. }
  22260. return fmt.Errorf("unknown Token field %s", name)
  22261. }
  22262. // AddedFields returns all numeric fields that were incremented/decremented during
  22263. // this mutation.
  22264. func (m *TokenMutation) AddedFields() []string {
  22265. var fields []string
  22266. if m.addorganization_id != nil {
  22267. fields = append(fields, token.FieldOrganizationID)
  22268. }
  22269. return fields
  22270. }
  22271. // AddedField returns the numeric value that was incremented/decremented on a field
  22272. // with the given name. The second boolean return value indicates that this field
  22273. // was not set, or was not defined in the schema.
  22274. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  22275. switch name {
  22276. case token.FieldOrganizationID:
  22277. return m.AddedOrganizationID()
  22278. }
  22279. return nil, false
  22280. }
  22281. // AddField adds the value to the field with the given name. It returns an error if
  22282. // the field is not defined in the schema, or if the type mismatched the field
  22283. // type.
  22284. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  22285. switch name {
  22286. case token.FieldOrganizationID:
  22287. v, ok := value.(int64)
  22288. if !ok {
  22289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22290. }
  22291. m.AddOrganizationID(v)
  22292. return nil
  22293. }
  22294. return fmt.Errorf("unknown Token numeric field %s", name)
  22295. }
  22296. // ClearedFields returns all nullable fields that were cleared during this
  22297. // mutation.
  22298. func (m *TokenMutation) ClearedFields() []string {
  22299. var fields []string
  22300. if m.FieldCleared(token.FieldDeletedAt) {
  22301. fields = append(fields, token.FieldDeletedAt)
  22302. }
  22303. if m.FieldCleared(token.FieldExpireAt) {
  22304. fields = append(fields, token.FieldExpireAt)
  22305. }
  22306. if m.FieldCleared(token.FieldToken) {
  22307. fields = append(fields, token.FieldToken)
  22308. }
  22309. if m.FieldCleared(token.FieldMAC) {
  22310. fields = append(fields, token.FieldMAC)
  22311. }
  22312. if m.FieldCleared(token.FieldCustomAgentBase) {
  22313. fields = append(fields, token.FieldCustomAgentBase)
  22314. }
  22315. if m.FieldCleared(token.FieldCustomAgentKey) {
  22316. fields = append(fields, token.FieldCustomAgentKey)
  22317. }
  22318. if m.FieldCleared(token.FieldOpenaiBase) {
  22319. fields = append(fields, token.FieldOpenaiBase)
  22320. }
  22321. if m.FieldCleared(token.FieldOpenaiKey) {
  22322. fields = append(fields, token.FieldOpenaiKey)
  22323. }
  22324. return fields
  22325. }
  22326. // FieldCleared returns a boolean indicating if a field with the given name was
  22327. // cleared in this mutation.
  22328. func (m *TokenMutation) FieldCleared(name string) bool {
  22329. _, ok := m.clearedFields[name]
  22330. return ok
  22331. }
  22332. // ClearField clears the value of the field with the given name. It returns an
  22333. // error if the field is not defined in the schema.
  22334. func (m *TokenMutation) ClearField(name string) error {
  22335. switch name {
  22336. case token.FieldDeletedAt:
  22337. m.ClearDeletedAt()
  22338. return nil
  22339. case token.FieldExpireAt:
  22340. m.ClearExpireAt()
  22341. return nil
  22342. case token.FieldToken:
  22343. m.ClearToken()
  22344. return nil
  22345. case token.FieldMAC:
  22346. m.ClearMAC()
  22347. return nil
  22348. case token.FieldCustomAgentBase:
  22349. m.ClearCustomAgentBase()
  22350. return nil
  22351. case token.FieldCustomAgentKey:
  22352. m.ClearCustomAgentKey()
  22353. return nil
  22354. case token.FieldOpenaiBase:
  22355. m.ClearOpenaiBase()
  22356. return nil
  22357. case token.FieldOpenaiKey:
  22358. m.ClearOpenaiKey()
  22359. return nil
  22360. }
  22361. return fmt.Errorf("unknown Token nullable field %s", name)
  22362. }
  22363. // ResetField resets all changes in the mutation for the field with the given name.
  22364. // It returns an error if the field is not defined in the schema.
  22365. func (m *TokenMutation) ResetField(name string) error {
  22366. switch name {
  22367. case token.FieldCreatedAt:
  22368. m.ResetCreatedAt()
  22369. return nil
  22370. case token.FieldUpdatedAt:
  22371. m.ResetUpdatedAt()
  22372. return nil
  22373. case token.FieldDeletedAt:
  22374. m.ResetDeletedAt()
  22375. return nil
  22376. case token.FieldExpireAt:
  22377. m.ResetExpireAt()
  22378. return nil
  22379. case token.FieldToken:
  22380. m.ResetToken()
  22381. return nil
  22382. case token.FieldMAC:
  22383. m.ResetMAC()
  22384. return nil
  22385. case token.FieldOrganizationID:
  22386. m.ResetOrganizationID()
  22387. return nil
  22388. case token.FieldAgentID:
  22389. m.ResetAgentID()
  22390. return nil
  22391. case token.FieldCustomAgentBase:
  22392. m.ResetCustomAgentBase()
  22393. return nil
  22394. case token.FieldCustomAgentKey:
  22395. m.ResetCustomAgentKey()
  22396. return nil
  22397. case token.FieldOpenaiBase:
  22398. m.ResetOpenaiBase()
  22399. return nil
  22400. case token.FieldOpenaiKey:
  22401. m.ResetOpenaiKey()
  22402. return nil
  22403. }
  22404. return fmt.Errorf("unknown Token field %s", name)
  22405. }
  22406. // AddedEdges returns all edge names that were set/added in this mutation.
  22407. func (m *TokenMutation) AddedEdges() []string {
  22408. edges := make([]string, 0, 1)
  22409. if m.agent != nil {
  22410. edges = append(edges, token.EdgeAgent)
  22411. }
  22412. return edges
  22413. }
  22414. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22415. // name in this mutation.
  22416. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  22417. switch name {
  22418. case token.EdgeAgent:
  22419. if id := m.agent; id != nil {
  22420. return []ent.Value{*id}
  22421. }
  22422. }
  22423. return nil
  22424. }
  22425. // RemovedEdges returns all edge names that were removed in this mutation.
  22426. func (m *TokenMutation) RemovedEdges() []string {
  22427. edges := make([]string, 0, 1)
  22428. return edges
  22429. }
  22430. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22431. // the given name in this mutation.
  22432. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  22433. return nil
  22434. }
  22435. // ClearedEdges returns all edge names that were cleared in this mutation.
  22436. func (m *TokenMutation) ClearedEdges() []string {
  22437. edges := make([]string, 0, 1)
  22438. if m.clearedagent {
  22439. edges = append(edges, token.EdgeAgent)
  22440. }
  22441. return edges
  22442. }
  22443. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22444. // was cleared in this mutation.
  22445. func (m *TokenMutation) EdgeCleared(name string) bool {
  22446. switch name {
  22447. case token.EdgeAgent:
  22448. return m.clearedagent
  22449. }
  22450. return false
  22451. }
  22452. // ClearEdge clears the value of the edge with the given name. It returns an error
  22453. // if that edge is not defined in the schema.
  22454. func (m *TokenMutation) ClearEdge(name string) error {
  22455. switch name {
  22456. case token.EdgeAgent:
  22457. m.ClearAgent()
  22458. return nil
  22459. }
  22460. return fmt.Errorf("unknown Token unique edge %s", name)
  22461. }
  22462. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22463. // It returns an error if the edge is not defined in the schema.
  22464. func (m *TokenMutation) ResetEdge(name string) error {
  22465. switch name {
  22466. case token.EdgeAgent:
  22467. m.ResetAgent()
  22468. return nil
  22469. }
  22470. return fmt.Errorf("unknown Token edge %s", name)
  22471. }
  22472. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  22473. type TutorialMutation struct {
  22474. config
  22475. op Op
  22476. typ string
  22477. id *uint64
  22478. created_at *time.Time
  22479. updated_at *time.Time
  22480. deleted_at *time.Time
  22481. index *int
  22482. addindex *int
  22483. title *string
  22484. content *string
  22485. organization_id *uint64
  22486. addorganization_id *int64
  22487. clearedFields map[string]struct{}
  22488. employee *uint64
  22489. clearedemployee bool
  22490. done bool
  22491. oldValue func(context.Context) (*Tutorial, error)
  22492. predicates []predicate.Tutorial
  22493. }
  22494. var _ ent.Mutation = (*TutorialMutation)(nil)
  22495. // tutorialOption allows management of the mutation configuration using functional options.
  22496. type tutorialOption func(*TutorialMutation)
  22497. // newTutorialMutation creates new mutation for the Tutorial entity.
  22498. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  22499. m := &TutorialMutation{
  22500. config: c,
  22501. op: op,
  22502. typ: TypeTutorial,
  22503. clearedFields: make(map[string]struct{}),
  22504. }
  22505. for _, opt := range opts {
  22506. opt(m)
  22507. }
  22508. return m
  22509. }
  22510. // withTutorialID sets the ID field of the mutation.
  22511. func withTutorialID(id uint64) tutorialOption {
  22512. return func(m *TutorialMutation) {
  22513. var (
  22514. err error
  22515. once sync.Once
  22516. value *Tutorial
  22517. )
  22518. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  22519. once.Do(func() {
  22520. if m.done {
  22521. err = errors.New("querying old values post mutation is not allowed")
  22522. } else {
  22523. value, err = m.Client().Tutorial.Get(ctx, id)
  22524. }
  22525. })
  22526. return value, err
  22527. }
  22528. m.id = &id
  22529. }
  22530. }
  22531. // withTutorial sets the old Tutorial of the mutation.
  22532. func withTutorial(node *Tutorial) tutorialOption {
  22533. return func(m *TutorialMutation) {
  22534. m.oldValue = func(context.Context) (*Tutorial, error) {
  22535. return node, nil
  22536. }
  22537. m.id = &node.ID
  22538. }
  22539. }
  22540. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22541. // executed in a transaction (ent.Tx), a transactional client is returned.
  22542. func (m TutorialMutation) Client() *Client {
  22543. client := &Client{config: m.config}
  22544. client.init()
  22545. return client
  22546. }
  22547. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22548. // it returns an error otherwise.
  22549. func (m TutorialMutation) Tx() (*Tx, error) {
  22550. if _, ok := m.driver.(*txDriver); !ok {
  22551. return nil, errors.New("ent: mutation is not running in a transaction")
  22552. }
  22553. tx := &Tx{config: m.config}
  22554. tx.init()
  22555. return tx, nil
  22556. }
  22557. // SetID sets the value of the id field. Note that this
  22558. // operation is only accepted on creation of Tutorial entities.
  22559. func (m *TutorialMutation) SetID(id uint64) {
  22560. m.id = &id
  22561. }
  22562. // ID returns the ID value in the mutation. Note that the ID is only available
  22563. // if it was provided to the builder or after it was returned from the database.
  22564. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  22565. if m.id == nil {
  22566. return
  22567. }
  22568. return *m.id, true
  22569. }
  22570. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22571. // That means, if the mutation is applied within a transaction with an isolation level such
  22572. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22573. // or updated by the mutation.
  22574. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  22575. switch {
  22576. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22577. id, exists := m.ID()
  22578. if exists {
  22579. return []uint64{id}, nil
  22580. }
  22581. fallthrough
  22582. case m.op.Is(OpUpdate | OpDelete):
  22583. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  22584. default:
  22585. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22586. }
  22587. }
  22588. // SetCreatedAt sets the "created_at" field.
  22589. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  22590. m.created_at = &t
  22591. }
  22592. // CreatedAt returns the value of the "created_at" field in the mutation.
  22593. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  22594. v := m.created_at
  22595. if v == nil {
  22596. return
  22597. }
  22598. return *v, true
  22599. }
  22600. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  22601. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22603. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22604. if !m.op.Is(OpUpdateOne) {
  22605. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22606. }
  22607. if m.id == nil || m.oldValue == nil {
  22608. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22609. }
  22610. oldValue, err := m.oldValue(ctx)
  22611. if err != nil {
  22612. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22613. }
  22614. return oldValue.CreatedAt, nil
  22615. }
  22616. // ResetCreatedAt resets all changes to the "created_at" field.
  22617. func (m *TutorialMutation) ResetCreatedAt() {
  22618. m.created_at = nil
  22619. }
  22620. // SetUpdatedAt sets the "updated_at" field.
  22621. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  22622. m.updated_at = &t
  22623. }
  22624. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22625. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  22626. v := m.updated_at
  22627. if v == nil {
  22628. return
  22629. }
  22630. return *v, true
  22631. }
  22632. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  22633. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22635. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22636. if !m.op.Is(OpUpdateOne) {
  22637. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22638. }
  22639. if m.id == nil || m.oldValue == nil {
  22640. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22641. }
  22642. oldValue, err := m.oldValue(ctx)
  22643. if err != nil {
  22644. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22645. }
  22646. return oldValue.UpdatedAt, nil
  22647. }
  22648. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22649. func (m *TutorialMutation) ResetUpdatedAt() {
  22650. m.updated_at = nil
  22651. }
  22652. // SetDeletedAt sets the "deleted_at" field.
  22653. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  22654. m.deleted_at = &t
  22655. }
  22656. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22657. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  22658. v := m.deleted_at
  22659. if v == nil {
  22660. return
  22661. }
  22662. return *v, true
  22663. }
  22664. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  22665. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22667. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22668. if !m.op.Is(OpUpdateOne) {
  22669. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22670. }
  22671. if m.id == nil || m.oldValue == nil {
  22672. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22673. }
  22674. oldValue, err := m.oldValue(ctx)
  22675. if err != nil {
  22676. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22677. }
  22678. return oldValue.DeletedAt, nil
  22679. }
  22680. // ClearDeletedAt clears the value of the "deleted_at" field.
  22681. func (m *TutorialMutation) ClearDeletedAt() {
  22682. m.deleted_at = nil
  22683. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  22684. }
  22685. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22686. func (m *TutorialMutation) DeletedAtCleared() bool {
  22687. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  22688. return ok
  22689. }
  22690. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22691. func (m *TutorialMutation) ResetDeletedAt() {
  22692. m.deleted_at = nil
  22693. delete(m.clearedFields, tutorial.FieldDeletedAt)
  22694. }
  22695. // SetEmployeeID sets the "employee_id" field.
  22696. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  22697. m.employee = &u
  22698. }
  22699. // EmployeeID returns the value of the "employee_id" field in the mutation.
  22700. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  22701. v := m.employee
  22702. if v == nil {
  22703. return
  22704. }
  22705. return *v, true
  22706. }
  22707. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  22708. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22710. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  22711. if !m.op.Is(OpUpdateOne) {
  22712. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  22713. }
  22714. if m.id == nil || m.oldValue == nil {
  22715. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  22716. }
  22717. oldValue, err := m.oldValue(ctx)
  22718. if err != nil {
  22719. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  22720. }
  22721. return oldValue.EmployeeID, nil
  22722. }
  22723. // ResetEmployeeID resets all changes to the "employee_id" field.
  22724. func (m *TutorialMutation) ResetEmployeeID() {
  22725. m.employee = nil
  22726. }
  22727. // SetIndex sets the "index" field.
  22728. func (m *TutorialMutation) SetIndex(i int) {
  22729. m.index = &i
  22730. m.addindex = nil
  22731. }
  22732. // Index returns the value of the "index" field in the mutation.
  22733. func (m *TutorialMutation) Index() (r int, exists bool) {
  22734. v := m.index
  22735. if v == nil {
  22736. return
  22737. }
  22738. return *v, true
  22739. }
  22740. // OldIndex returns the old "index" field's value of the Tutorial entity.
  22741. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22743. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  22744. if !m.op.Is(OpUpdateOne) {
  22745. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  22746. }
  22747. if m.id == nil || m.oldValue == nil {
  22748. return v, errors.New("OldIndex requires an ID field in the mutation")
  22749. }
  22750. oldValue, err := m.oldValue(ctx)
  22751. if err != nil {
  22752. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  22753. }
  22754. return oldValue.Index, nil
  22755. }
  22756. // AddIndex adds i to the "index" field.
  22757. func (m *TutorialMutation) AddIndex(i int) {
  22758. if m.addindex != nil {
  22759. *m.addindex += i
  22760. } else {
  22761. m.addindex = &i
  22762. }
  22763. }
  22764. // AddedIndex returns the value that was added to the "index" field in this mutation.
  22765. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  22766. v := m.addindex
  22767. if v == nil {
  22768. return
  22769. }
  22770. return *v, true
  22771. }
  22772. // ResetIndex resets all changes to the "index" field.
  22773. func (m *TutorialMutation) ResetIndex() {
  22774. m.index = nil
  22775. m.addindex = nil
  22776. }
  22777. // SetTitle sets the "title" field.
  22778. func (m *TutorialMutation) SetTitle(s string) {
  22779. m.title = &s
  22780. }
  22781. // Title returns the value of the "title" field in the mutation.
  22782. func (m *TutorialMutation) Title() (r string, exists bool) {
  22783. v := m.title
  22784. if v == nil {
  22785. return
  22786. }
  22787. return *v, true
  22788. }
  22789. // OldTitle returns the old "title" field's value of the Tutorial entity.
  22790. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22792. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  22793. if !m.op.Is(OpUpdateOne) {
  22794. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  22795. }
  22796. if m.id == nil || m.oldValue == nil {
  22797. return v, errors.New("OldTitle requires an ID field in the mutation")
  22798. }
  22799. oldValue, err := m.oldValue(ctx)
  22800. if err != nil {
  22801. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  22802. }
  22803. return oldValue.Title, nil
  22804. }
  22805. // ResetTitle resets all changes to the "title" field.
  22806. func (m *TutorialMutation) ResetTitle() {
  22807. m.title = nil
  22808. }
  22809. // SetContent sets the "content" field.
  22810. func (m *TutorialMutation) SetContent(s string) {
  22811. m.content = &s
  22812. }
  22813. // Content returns the value of the "content" field in the mutation.
  22814. func (m *TutorialMutation) Content() (r string, exists bool) {
  22815. v := m.content
  22816. if v == nil {
  22817. return
  22818. }
  22819. return *v, true
  22820. }
  22821. // OldContent returns the old "content" field's value of the Tutorial entity.
  22822. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22824. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  22825. if !m.op.Is(OpUpdateOne) {
  22826. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  22827. }
  22828. if m.id == nil || m.oldValue == nil {
  22829. return v, errors.New("OldContent requires an ID field in the mutation")
  22830. }
  22831. oldValue, err := m.oldValue(ctx)
  22832. if err != nil {
  22833. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  22834. }
  22835. return oldValue.Content, nil
  22836. }
  22837. // ResetContent resets all changes to the "content" field.
  22838. func (m *TutorialMutation) ResetContent() {
  22839. m.content = nil
  22840. }
  22841. // SetOrganizationID sets the "organization_id" field.
  22842. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  22843. m.organization_id = &u
  22844. m.addorganization_id = nil
  22845. }
  22846. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22847. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  22848. v := m.organization_id
  22849. if v == nil {
  22850. return
  22851. }
  22852. return *v, true
  22853. }
  22854. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  22855. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22857. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22858. if !m.op.Is(OpUpdateOne) {
  22859. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22860. }
  22861. if m.id == nil || m.oldValue == nil {
  22862. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22863. }
  22864. oldValue, err := m.oldValue(ctx)
  22865. if err != nil {
  22866. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22867. }
  22868. return oldValue.OrganizationID, nil
  22869. }
  22870. // AddOrganizationID adds u to the "organization_id" field.
  22871. func (m *TutorialMutation) AddOrganizationID(u int64) {
  22872. if m.addorganization_id != nil {
  22873. *m.addorganization_id += u
  22874. } else {
  22875. m.addorganization_id = &u
  22876. }
  22877. }
  22878. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22879. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  22880. v := m.addorganization_id
  22881. if v == nil {
  22882. return
  22883. }
  22884. return *v, true
  22885. }
  22886. // ResetOrganizationID resets all changes to the "organization_id" field.
  22887. func (m *TutorialMutation) ResetOrganizationID() {
  22888. m.organization_id = nil
  22889. m.addorganization_id = nil
  22890. }
  22891. // ClearEmployee clears the "employee" edge to the Employee entity.
  22892. func (m *TutorialMutation) ClearEmployee() {
  22893. m.clearedemployee = true
  22894. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  22895. }
  22896. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  22897. func (m *TutorialMutation) EmployeeCleared() bool {
  22898. return m.clearedemployee
  22899. }
  22900. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  22901. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22902. // EmployeeID instead. It exists only for internal usage by the builders.
  22903. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  22904. if id := m.employee; id != nil {
  22905. ids = append(ids, *id)
  22906. }
  22907. return
  22908. }
  22909. // ResetEmployee resets all changes to the "employee" edge.
  22910. func (m *TutorialMutation) ResetEmployee() {
  22911. m.employee = nil
  22912. m.clearedemployee = false
  22913. }
  22914. // Where appends a list predicates to the TutorialMutation builder.
  22915. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  22916. m.predicates = append(m.predicates, ps...)
  22917. }
  22918. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  22919. // users can use type-assertion to append predicates that do not depend on any generated package.
  22920. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  22921. p := make([]predicate.Tutorial, len(ps))
  22922. for i := range ps {
  22923. p[i] = ps[i]
  22924. }
  22925. m.Where(p...)
  22926. }
  22927. // Op returns the operation name.
  22928. func (m *TutorialMutation) Op() Op {
  22929. return m.op
  22930. }
  22931. // SetOp allows setting the mutation operation.
  22932. func (m *TutorialMutation) SetOp(op Op) {
  22933. m.op = op
  22934. }
  22935. // Type returns the node type of this mutation (Tutorial).
  22936. func (m *TutorialMutation) Type() string {
  22937. return m.typ
  22938. }
  22939. // Fields returns all fields that were changed during this mutation. Note that in
  22940. // order to get all numeric fields that were incremented/decremented, call
  22941. // AddedFields().
  22942. func (m *TutorialMutation) Fields() []string {
  22943. fields := make([]string, 0, 8)
  22944. if m.created_at != nil {
  22945. fields = append(fields, tutorial.FieldCreatedAt)
  22946. }
  22947. if m.updated_at != nil {
  22948. fields = append(fields, tutorial.FieldUpdatedAt)
  22949. }
  22950. if m.deleted_at != nil {
  22951. fields = append(fields, tutorial.FieldDeletedAt)
  22952. }
  22953. if m.employee != nil {
  22954. fields = append(fields, tutorial.FieldEmployeeID)
  22955. }
  22956. if m.index != nil {
  22957. fields = append(fields, tutorial.FieldIndex)
  22958. }
  22959. if m.title != nil {
  22960. fields = append(fields, tutorial.FieldTitle)
  22961. }
  22962. if m.content != nil {
  22963. fields = append(fields, tutorial.FieldContent)
  22964. }
  22965. if m.organization_id != nil {
  22966. fields = append(fields, tutorial.FieldOrganizationID)
  22967. }
  22968. return fields
  22969. }
  22970. // Field returns the value of a field with the given name. The second boolean
  22971. // return value indicates that this field was not set, or was not defined in the
  22972. // schema.
  22973. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  22974. switch name {
  22975. case tutorial.FieldCreatedAt:
  22976. return m.CreatedAt()
  22977. case tutorial.FieldUpdatedAt:
  22978. return m.UpdatedAt()
  22979. case tutorial.FieldDeletedAt:
  22980. return m.DeletedAt()
  22981. case tutorial.FieldEmployeeID:
  22982. return m.EmployeeID()
  22983. case tutorial.FieldIndex:
  22984. return m.Index()
  22985. case tutorial.FieldTitle:
  22986. return m.Title()
  22987. case tutorial.FieldContent:
  22988. return m.Content()
  22989. case tutorial.FieldOrganizationID:
  22990. return m.OrganizationID()
  22991. }
  22992. return nil, false
  22993. }
  22994. // OldField returns the old value of the field from the database. An error is
  22995. // returned if the mutation operation is not UpdateOne, or the query to the
  22996. // database failed.
  22997. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22998. switch name {
  22999. case tutorial.FieldCreatedAt:
  23000. return m.OldCreatedAt(ctx)
  23001. case tutorial.FieldUpdatedAt:
  23002. return m.OldUpdatedAt(ctx)
  23003. case tutorial.FieldDeletedAt:
  23004. return m.OldDeletedAt(ctx)
  23005. case tutorial.FieldEmployeeID:
  23006. return m.OldEmployeeID(ctx)
  23007. case tutorial.FieldIndex:
  23008. return m.OldIndex(ctx)
  23009. case tutorial.FieldTitle:
  23010. return m.OldTitle(ctx)
  23011. case tutorial.FieldContent:
  23012. return m.OldContent(ctx)
  23013. case tutorial.FieldOrganizationID:
  23014. return m.OldOrganizationID(ctx)
  23015. }
  23016. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  23017. }
  23018. // SetField sets the value of a field with the given name. It returns an error if
  23019. // the field is not defined in the schema, or if the type mismatched the field
  23020. // type.
  23021. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  23022. switch name {
  23023. case tutorial.FieldCreatedAt:
  23024. v, ok := value.(time.Time)
  23025. if !ok {
  23026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23027. }
  23028. m.SetCreatedAt(v)
  23029. return nil
  23030. case tutorial.FieldUpdatedAt:
  23031. v, ok := value.(time.Time)
  23032. if !ok {
  23033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23034. }
  23035. m.SetUpdatedAt(v)
  23036. return nil
  23037. case tutorial.FieldDeletedAt:
  23038. v, ok := value.(time.Time)
  23039. if !ok {
  23040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23041. }
  23042. m.SetDeletedAt(v)
  23043. return nil
  23044. case tutorial.FieldEmployeeID:
  23045. v, ok := value.(uint64)
  23046. if !ok {
  23047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23048. }
  23049. m.SetEmployeeID(v)
  23050. return nil
  23051. case tutorial.FieldIndex:
  23052. v, ok := value.(int)
  23053. if !ok {
  23054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23055. }
  23056. m.SetIndex(v)
  23057. return nil
  23058. case tutorial.FieldTitle:
  23059. v, ok := value.(string)
  23060. if !ok {
  23061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23062. }
  23063. m.SetTitle(v)
  23064. return nil
  23065. case tutorial.FieldContent:
  23066. v, ok := value.(string)
  23067. if !ok {
  23068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23069. }
  23070. m.SetContent(v)
  23071. return nil
  23072. case tutorial.FieldOrganizationID:
  23073. v, ok := value.(uint64)
  23074. if !ok {
  23075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23076. }
  23077. m.SetOrganizationID(v)
  23078. return nil
  23079. }
  23080. return fmt.Errorf("unknown Tutorial field %s", name)
  23081. }
  23082. // AddedFields returns all numeric fields that were incremented/decremented during
  23083. // this mutation.
  23084. func (m *TutorialMutation) AddedFields() []string {
  23085. var fields []string
  23086. if m.addindex != nil {
  23087. fields = append(fields, tutorial.FieldIndex)
  23088. }
  23089. if m.addorganization_id != nil {
  23090. fields = append(fields, tutorial.FieldOrganizationID)
  23091. }
  23092. return fields
  23093. }
  23094. // AddedField returns the numeric value that was incremented/decremented on a field
  23095. // with the given name. The second boolean return value indicates that this field
  23096. // was not set, or was not defined in the schema.
  23097. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  23098. switch name {
  23099. case tutorial.FieldIndex:
  23100. return m.AddedIndex()
  23101. case tutorial.FieldOrganizationID:
  23102. return m.AddedOrganizationID()
  23103. }
  23104. return nil, false
  23105. }
  23106. // AddField adds the value to the field with the given name. It returns an error if
  23107. // the field is not defined in the schema, or if the type mismatched the field
  23108. // type.
  23109. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  23110. switch name {
  23111. case tutorial.FieldIndex:
  23112. v, ok := value.(int)
  23113. if !ok {
  23114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23115. }
  23116. m.AddIndex(v)
  23117. return nil
  23118. case tutorial.FieldOrganizationID:
  23119. v, ok := value.(int64)
  23120. if !ok {
  23121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23122. }
  23123. m.AddOrganizationID(v)
  23124. return nil
  23125. }
  23126. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  23127. }
  23128. // ClearedFields returns all nullable fields that were cleared during this
  23129. // mutation.
  23130. func (m *TutorialMutation) ClearedFields() []string {
  23131. var fields []string
  23132. if m.FieldCleared(tutorial.FieldDeletedAt) {
  23133. fields = append(fields, tutorial.FieldDeletedAt)
  23134. }
  23135. return fields
  23136. }
  23137. // FieldCleared returns a boolean indicating if a field with the given name was
  23138. // cleared in this mutation.
  23139. func (m *TutorialMutation) FieldCleared(name string) bool {
  23140. _, ok := m.clearedFields[name]
  23141. return ok
  23142. }
  23143. // ClearField clears the value of the field with the given name. It returns an
  23144. // error if the field is not defined in the schema.
  23145. func (m *TutorialMutation) ClearField(name string) error {
  23146. switch name {
  23147. case tutorial.FieldDeletedAt:
  23148. m.ClearDeletedAt()
  23149. return nil
  23150. }
  23151. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  23152. }
  23153. // ResetField resets all changes in the mutation for the field with the given name.
  23154. // It returns an error if the field is not defined in the schema.
  23155. func (m *TutorialMutation) ResetField(name string) error {
  23156. switch name {
  23157. case tutorial.FieldCreatedAt:
  23158. m.ResetCreatedAt()
  23159. return nil
  23160. case tutorial.FieldUpdatedAt:
  23161. m.ResetUpdatedAt()
  23162. return nil
  23163. case tutorial.FieldDeletedAt:
  23164. m.ResetDeletedAt()
  23165. return nil
  23166. case tutorial.FieldEmployeeID:
  23167. m.ResetEmployeeID()
  23168. return nil
  23169. case tutorial.FieldIndex:
  23170. m.ResetIndex()
  23171. return nil
  23172. case tutorial.FieldTitle:
  23173. m.ResetTitle()
  23174. return nil
  23175. case tutorial.FieldContent:
  23176. m.ResetContent()
  23177. return nil
  23178. case tutorial.FieldOrganizationID:
  23179. m.ResetOrganizationID()
  23180. return nil
  23181. }
  23182. return fmt.Errorf("unknown Tutorial field %s", name)
  23183. }
  23184. // AddedEdges returns all edge names that were set/added in this mutation.
  23185. func (m *TutorialMutation) AddedEdges() []string {
  23186. edges := make([]string, 0, 1)
  23187. if m.employee != nil {
  23188. edges = append(edges, tutorial.EdgeEmployee)
  23189. }
  23190. return edges
  23191. }
  23192. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23193. // name in this mutation.
  23194. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  23195. switch name {
  23196. case tutorial.EdgeEmployee:
  23197. if id := m.employee; id != nil {
  23198. return []ent.Value{*id}
  23199. }
  23200. }
  23201. return nil
  23202. }
  23203. // RemovedEdges returns all edge names that were removed in this mutation.
  23204. func (m *TutorialMutation) RemovedEdges() []string {
  23205. edges := make([]string, 0, 1)
  23206. return edges
  23207. }
  23208. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23209. // the given name in this mutation.
  23210. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  23211. return nil
  23212. }
  23213. // ClearedEdges returns all edge names that were cleared in this mutation.
  23214. func (m *TutorialMutation) ClearedEdges() []string {
  23215. edges := make([]string, 0, 1)
  23216. if m.clearedemployee {
  23217. edges = append(edges, tutorial.EdgeEmployee)
  23218. }
  23219. return edges
  23220. }
  23221. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23222. // was cleared in this mutation.
  23223. func (m *TutorialMutation) EdgeCleared(name string) bool {
  23224. switch name {
  23225. case tutorial.EdgeEmployee:
  23226. return m.clearedemployee
  23227. }
  23228. return false
  23229. }
  23230. // ClearEdge clears the value of the edge with the given name. It returns an error
  23231. // if that edge is not defined in the schema.
  23232. func (m *TutorialMutation) ClearEdge(name string) error {
  23233. switch name {
  23234. case tutorial.EdgeEmployee:
  23235. m.ClearEmployee()
  23236. return nil
  23237. }
  23238. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  23239. }
  23240. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23241. // It returns an error if the edge is not defined in the schema.
  23242. func (m *TutorialMutation) ResetEdge(name string) error {
  23243. switch name {
  23244. case tutorial.EdgeEmployee:
  23245. m.ResetEmployee()
  23246. return nil
  23247. }
  23248. return fmt.Errorf("unknown Tutorial edge %s", name)
  23249. }
  23250. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  23251. type UsageDetailMutation struct {
  23252. config
  23253. op Op
  23254. typ string
  23255. id *uint64
  23256. created_at *time.Time
  23257. updated_at *time.Time
  23258. status *uint8
  23259. addstatus *int8
  23260. _type *int
  23261. add_type *int
  23262. bot_id *string
  23263. receiver_id *string
  23264. app *int
  23265. addapp *int
  23266. session_id *uint64
  23267. addsession_id *int64
  23268. request *string
  23269. response *string
  23270. total_tokens *uint64
  23271. addtotal_tokens *int64
  23272. prompt_tokens *uint64
  23273. addprompt_tokens *int64
  23274. completion_tokens *uint64
  23275. addcompletion_tokens *int64
  23276. organization_id *uint64
  23277. addorganization_id *int64
  23278. clearedFields map[string]struct{}
  23279. done bool
  23280. oldValue func(context.Context) (*UsageDetail, error)
  23281. predicates []predicate.UsageDetail
  23282. }
  23283. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  23284. // usagedetailOption allows management of the mutation configuration using functional options.
  23285. type usagedetailOption func(*UsageDetailMutation)
  23286. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  23287. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  23288. m := &UsageDetailMutation{
  23289. config: c,
  23290. op: op,
  23291. typ: TypeUsageDetail,
  23292. clearedFields: make(map[string]struct{}),
  23293. }
  23294. for _, opt := range opts {
  23295. opt(m)
  23296. }
  23297. return m
  23298. }
  23299. // withUsageDetailID sets the ID field of the mutation.
  23300. func withUsageDetailID(id uint64) usagedetailOption {
  23301. return func(m *UsageDetailMutation) {
  23302. var (
  23303. err error
  23304. once sync.Once
  23305. value *UsageDetail
  23306. )
  23307. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  23308. once.Do(func() {
  23309. if m.done {
  23310. err = errors.New("querying old values post mutation is not allowed")
  23311. } else {
  23312. value, err = m.Client().UsageDetail.Get(ctx, id)
  23313. }
  23314. })
  23315. return value, err
  23316. }
  23317. m.id = &id
  23318. }
  23319. }
  23320. // withUsageDetail sets the old UsageDetail of the mutation.
  23321. func withUsageDetail(node *UsageDetail) usagedetailOption {
  23322. return func(m *UsageDetailMutation) {
  23323. m.oldValue = func(context.Context) (*UsageDetail, error) {
  23324. return node, nil
  23325. }
  23326. m.id = &node.ID
  23327. }
  23328. }
  23329. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23330. // executed in a transaction (ent.Tx), a transactional client is returned.
  23331. func (m UsageDetailMutation) Client() *Client {
  23332. client := &Client{config: m.config}
  23333. client.init()
  23334. return client
  23335. }
  23336. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23337. // it returns an error otherwise.
  23338. func (m UsageDetailMutation) Tx() (*Tx, error) {
  23339. if _, ok := m.driver.(*txDriver); !ok {
  23340. return nil, errors.New("ent: mutation is not running in a transaction")
  23341. }
  23342. tx := &Tx{config: m.config}
  23343. tx.init()
  23344. return tx, nil
  23345. }
  23346. // SetID sets the value of the id field. Note that this
  23347. // operation is only accepted on creation of UsageDetail entities.
  23348. func (m *UsageDetailMutation) SetID(id uint64) {
  23349. m.id = &id
  23350. }
  23351. // ID returns the ID value in the mutation. Note that the ID is only available
  23352. // if it was provided to the builder or after it was returned from the database.
  23353. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  23354. if m.id == nil {
  23355. return
  23356. }
  23357. return *m.id, true
  23358. }
  23359. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23360. // That means, if the mutation is applied within a transaction with an isolation level such
  23361. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23362. // or updated by the mutation.
  23363. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  23364. switch {
  23365. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23366. id, exists := m.ID()
  23367. if exists {
  23368. return []uint64{id}, nil
  23369. }
  23370. fallthrough
  23371. case m.op.Is(OpUpdate | OpDelete):
  23372. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  23373. default:
  23374. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23375. }
  23376. }
  23377. // SetCreatedAt sets the "created_at" field.
  23378. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  23379. m.created_at = &t
  23380. }
  23381. // CreatedAt returns the value of the "created_at" field in the mutation.
  23382. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  23383. v := m.created_at
  23384. if v == nil {
  23385. return
  23386. }
  23387. return *v, true
  23388. }
  23389. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  23390. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23392. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23393. if !m.op.Is(OpUpdateOne) {
  23394. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23395. }
  23396. if m.id == nil || m.oldValue == nil {
  23397. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23398. }
  23399. oldValue, err := m.oldValue(ctx)
  23400. if err != nil {
  23401. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23402. }
  23403. return oldValue.CreatedAt, nil
  23404. }
  23405. // ResetCreatedAt resets all changes to the "created_at" field.
  23406. func (m *UsageDetailMutation) ResetCreatedAt() {
  23407. m.created_at = nil
  23408. }
  23409. // SetUpdatedAt sets the "updated_at" field.
  23410. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  23411. m.updated_at = &t
  23412. }
  23413. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23414. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  23415. v := m.updated_at
  23416. if v == nil {
  23417. return
  23418. }
  23419. return *v, true
  23420. }
  23421. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  23422. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23424. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23425. if !m.op.Is(OpUpdateOne) {
  23426. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23427. }
  23428. if m.id == nil || m.oldValue == nil {
  23429. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23430. }
  23431. oldValue, err := m.oldValue(ctx)
  23432. if err != nil {
  23433. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23434. }
  23435. return oldValue.UpdatedAt, nil
  23436. }
  23437. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23438. func (m *UsageDetailMutation) ResetUpdatedAt() {
  23439. m.updated_at = nil
  23440. }
  23441. // SetStatus sets the "status" field.
  23442. func (m *UsageDetailMutation) SetStatus(u uint8) {
  23443. m.status = &u
  23444. m.addstatus = nil
  23445. }
  23446. // Status returns the value of the "status" field in the mutation.
  23447. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  23448. v := m.status
  23449. if v == nil {
  23450. return
  23451. }
  23452. return *v, true
  23453. }
  23454. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  23455. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23457. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23458. if !m.op.Is(OpUpdateOne) {
  23459. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23460. }
  23461. if m.id == nil || m.oldValue == nil {
  23462. return v, errors.New("OldStatus requires an ID field in the mutation")
  23463. }
  23464. oldValue, err := m.oldValue(ctx)
  23465. if err != nil {
  23466. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23467. }
  23468. return oldValue.Status, nil
  23469. }
  23470. // AddStatus adds u to the "status" field.
  23471. func (m *UsageDetailMutation) AddStatus(u int8) {
  23472. if m.addstatus != nil {
  23473. *m.addstatus += u
  23474. } else {
  23475. m.addstatus = &u
  23476. }
  23477. }
  23478. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23479. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  23480. v := m.addstatus
  23481. if v == nil {
  23482. return
  23483. }
  23484. return *v, true
  23485. }
  23486. // ClearStatus clears the value of the "status" field.
  23487. func (m *UsageDetailMutation) ClearStatus() {
  23488. m.status = nil
  23489. m.addstatus = nil
  23490. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  23491. }
  23492. // StatusCleared returns if the "status" field was cleared in this mutation.
  23493. func (m *UsageDetailMutation) StatusCleared() bool {
  23494. _, ok := m.clearedFields[usagedetail.FieldStatus]
  23495. return ok
  23496. }
  23497. // ResetStatus resets all changes to the "status" field.
  23498. func (m *UsageDetailMutation) ResetStatus() {
  23499. m.status = nil
  23500. m.addstatus = nil
  23501. delete(m.clearedFields, usagedetail.FieldStatus)
  23502. }
  23503. // SetType sets the "type" field.
  23504. func (m *UsageDetailMutation) SetType(i int) {
  23505. m._type = &i
  23506. m.add_type = nil
  23507. }
  23508. // GetType returns the value of the "type" field in the mutation.
  23509. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  23510. v := m._type
  23511. if v == nil {
  23512. return
  23513. }
  23514. return *v, true
  23515. }
  23516. // OldType returns the old "type" field's value of the UsageDetail entity.
  23517. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23519. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  23520. if !m.op.Is(OpUpdateOne) {
  23521. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23522. }
  23523. if m.id == nil || m.oldValue == nil {
  23524. return v, errors.New("OldType requires an ID field in the mutation")
  23525. }
  23526. oldValue, err := m.oldValue(ctx)
  23527. if err != nil {
  23528. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23529. }
  23530. return oldValue.Type, nil
  23531. }
  23532. // AddType adds i to the "type" field.
  23533. func (m *UsageDetailMutation) AddType(i int) {
  23534. if m.add_type != nil {
  23535. *m.add_type += i
  23536. } else {
  23537. m.add_type = &i
  23538. }
  23539. }
  23540. // AddedType returns the value that was added to the "type" field in this mutation.
  23541. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  23542. v := m.add_type
  23543. if v == nil {
  23544. return
  23545. }
  23546. return *v, true
  23547. }
  23548. // ClearType clears the value of the "type" field.
  23549. func (m *UsageDetailMutation) ClearType() {
  23550. m._type = nil
  23551. m.add_type = nil
  23552. m.clearedFields[usagedetail.FieldType] = struct{}{}
  23553. }
  23554. // TypeCleared returns if the "type" field was cleared in this mutation.
  23555. func (m *UsageDetailMutation) TypeCleared() bool {
  23556. _, ok := m.clearedFields[usagedetail.FieldType]
  23557. return ok
  23558. }
  23559. // ResetType resets all changes to the "type" field.
  23560. func (m *UsageDetailMutation) ResetType() {
  23561. m._type = nil
  23562. m.add_type = nil
  23563. delete(m.clearedFields, usagedetail.FieldType)
  23564. }
  23565. // SetBotID sets the "bot_id" field.
  23566. func (m *UsageDetailMutation) SetBotID(s string) {
  23567. m.bot_id = &s
  23568. }
  23569. // BotID returns the value of the "bot_id" field in the mutation.
  23570. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  23571. v := m.bot_id
  23572. if v == nil {
  23573. return
  23574. }
  23575. return *v, true
  23576. }
  23577. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  23578. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23580. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  23581. if !m.op.Is(OpUpdateOne) {
  23582. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  23583. }
  23584. if m.id == nil || m.oldValue == nil {
  23585. return v, errors.New("OldBotID requires an ID field in the mutation")
  23586. }
  23587. oldValue, err := m.oldValue(ctx)
  23588. if err != nil {
  23589. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  23590. }
  23591. return oldValue.BotID, nil
  23592. }
  23593. // ResetBotID resets all changes to the "bot_id" field.
  23594. func (m *UsageDetailMutation) ResetBotID() {
  23595. m.bot_id = nil
  23596. }
  23597. // SetReceiverID sets the "receiver_id" field.
  23598. func (m *UsageDetailMutation) SetReceiverID(s string) {
  23599. m.receiver_id = &s
  23600. }
  23601. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  23602. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  23603. v := m.receiver_id
  23604. if v == nil {
  23605. return
  23606. }
  23607. return *v, true
  23608. }
  23609. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  23610. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23612. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  23613. if !m.op.Is(OpUpdateOne) {
  23614. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  23615. }
  23616. if m.id == nil || m.oldValue == nil {
  23617. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  23618. }
  23619. oldValue, err := m.oldValue(ctx)
  23620. if err != nil {
  23621. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  23622. }
  23623. return oldValue.ReceiverID, nil
  23624. }
  23625. // ResetReceiverID resets all changes to the "receiver_id" field.
  23626. func (m *UsageDetailMutation) ResetReceiverID() {
  23627. m.receiver_id = nil
  23628. }
  23629. // SetApp sets the "app" field.
  23630. func (m *UsageDetailMutation) SetApp(i int) {
  23631. m.app = &i
  23632. m.addapp = nil
  23633. }
  23634. // App returns the value of the "app" field in the mutation.
  23635. func (m *UsageDetailMutation) App() (r int, exists bool) {
  23636. v := m.app
  23637. if v == nil {
  23638. return
  23639. }
  23640. return *v, true
  23641. }
  23642. // OldApp returns the old "app" field's value of the UsageDetail entity.
  23643. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23645. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  23646. if !m.op.Is(OpUpdateOne) {
  23647. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  23648. }
  23649. if m.id == nil || m.oldValue == nil {
  23650. return v, errors.New("OldApp requires an ID field in the mutation")
  23651. }
  23652. oldValue, err := m.oldValue(ctx)
  23653. if err != nil {
  23654. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  23655. }
  23656. return oldValue.App, nil
  23657. }
  23658. // AddApp adds i to the "app" field.
  23659. func (m *UsageDetailMutation) AddApp(i int) {
  23660. if m.addapp != nil {
  23661. *m.addapp += i
  23662. } else {
  23663. m.addapp = &i
  23664. }
  23665. }
  23666. // AddedApp returns the value that was added to the "app" field in this mutation.
  23667. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  23668. v := m.addapp
  23669. if v == nil {
  23670. return
  23671. }
  23672. return *v, true
  23673. }
  23674. // ClearApp clears the value of the "app" field.
  23675. func (m *UsageDetailMutation) ClearApp() {
  23676. m.app = nil
  23677. m.addapp = nil
  23678. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  23679. }
  23680. // AppCleared returns if the "app" field was cleared in this mutation.
  23681. func (m *UsageDetailMutation) AppCleared() bool {
  23682. _, ok := m.clearedFields[usagedetail.FieldApp]
  23683. return ok
  23684. }
  23685. // ResetApp resets all changes to the "app" field.
  23686. func (m *UsageDetailMutation) ResetApp() {
  23687. m.app = nil
  23688. m.addapp = nil
  23689. delete(m.clearedFields, usagedetail.FieldApp)
  23690. }
  23691. // SetSessionID sets the "session_id" field.
  23692. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  23693. m.session_id = &u
  23694. m.addsession_id = nil
  23695. }
  23696. // SessionID returns the value of the "session_id" field in the mutation.
  23697. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  23698. v := m.session_id
  23699. if v == nil {
  23700. return
  23701. }
  23702. return *v, true
  23703. }
  23704. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  23705. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23707. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  23708. if !m.op.Is(OpUpdateOne) {
  23709. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  23710. }
  23711. if m.id == nil || m.oldValue == nil {
  23712. return v, errors.New("OldSessionID requires an ID field in the mutation")
  23713. }
  23714. oldValue, err := m.oldValue(ctx)
  23715. if err != nil {
  23716. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  23717. }
  23718. return oldValue.SessionID, nil
  23719. }
  23720. // AddSessionID adds u to the "session_id" field.
  23721. func (m *UsageDetailMutation) AddSessionID(u int64) {
  23722. if m.addsession_id != nil {
  23723. *m.addsession_id += u
  23724. } else {
  23725. m.addsession_id = &u
  23726. }
  23727. }
  23728. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  23729. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  23730. v := m.addsession_id
  23731. if v == nil {
  23732. return
  23733. }
  23734. return *v, true
  23735. }
  23736. // ClearSessionID clears the value of the "session_id" field.
  23737. func (m *UsageDetailMutation) ClearSessionID() {
  23738. m.session_id = nil
  23739. m.addsession_id = nil
  23740. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  23741. }
  23742. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  23743. func (m *UsageDetailMutation) SessionIDCleared() bool {
  23744. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  23745. return ok
  23746. }
  23747. // ResetSessionID resets all changes to the "session_id" field.
  23748. func (m *UsageDetailMutation) ResetSessionID() {
  23749. m.session_id = nil
  23750. m.addsession_id = nil
  23751. delete(m.clearedFields, usagedetail.FieldSessionID)
  23752. }
  23753. // SetRequest sets the "request" field.
  23754. func (m *UsageDetailMutation) SetRequest(s string) {
  23755. m.request = &s
  23756. }
  23757. // Request returns the value of the "request" field in the mutation.
  23758. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  23759. v := m.request
  23760. if v == nil {
  23761. return
  23762. }
  23763. return *v, true
  23764. }
  23765. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  23766. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23768. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  23769. if !m.op.Is(OpUpdateOne) {
  23770. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  23771. }
  23772. if m.id == nil || m.oldValue == nil {
  23773. return v, errors.New("OldRequest requires an ID field in the mutation")
  23774. }
  23775. oldValue, err := m.oldValue(ctx)
  23776. if err != nil {
  23777. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  23778. }
  23779. return oldValue.Request, nil
  23780. }
  23781. // ResetRequest resets all changes to the "request" field.
  23782. func (m *UsageDetailMutation) ResetRequest() {
  23783. m.request = nil
  23784. }
  23785. // SetResponse sets the "response" field.
  23786. func (m *UsageDetailMutation) SetResponse(s string) {
  23787. m.response = &s
  23788. }
  23789. // Response returns the value of the "response" field in the mutation.
  23790. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  23791. v := m.response
  23792. if v == nil {
  23793. return
  23794. }
  23795. return *v, true
  23796. }
  23797. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  23798. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23800. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  23801. if !m.op.Is(OpUpdateOne) {
  23802. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  23803. }
  23804. if m.id == nil || m.oldValue == nil {
  23805. return v, errors.New("OldResponse requires an ID field in the mutation")
  23806. }
  23807. oldValue, err := m.oldValue(ctx)
  23808. if err != nil {
  23809. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  23810. }
  23811. return oldValue.Response, nil
  23812. }
  23813. // ResetResponse resets all changes to the "response" field.
  23814. func (m *UsageDetailMutation) ResetResponse() {
  23815. m.response = nil
  23816. }
  23817. // SetTotalTokens sets the "total_tokens" field.
  23818. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  23819. m.total_tokens = &u
  23820. m.addtotal_tokens = nil
  23821. }
  23822. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  23823. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  23824. v := m.total_tokens
  23825. if v == nil {
  23826. return
  23827. }
  23828. return *v, true
  23829. }
  23830. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  23831. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23833. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  23834. if !m.op.Is(OpUpdateOne) {
  23835. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  23836. }
  23837. if m.id == nil || m.oldValue == nil {
  23838. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  23839. }
  23840. oldValue, err := m.oldValue(ctx)
  23841. if err != nil {
  23842. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  23843. }
  23844. return oldValue.TotalTokens, nil
  23845. }
  23846. // AddTotalTokens adds u to the "total_tokens" field.
  23847. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  23848. if m.addtotal_tokens != nil {
  23849. *m.addtotal_tokens += u
  23850. } else {
  23851. m.addtotal_tokens = &u
  23852. }
  23853. }
  23854. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  23855. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  23856. v := m.addtotal_tokens
  23857. if v == nil {
  23858. return
  23859. }
  23860. return *v, true
  23861. }
  23862. // ClearTotalTokens clears the value of the "total_tokens" field.
  23863. func (m *UsageDetailMutation) ClearTotalTokens() {
  23864. m.total_tokens = nil
  23865. m.addtotal_tokens = nil
  23866. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  23867. }
  23868. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  23869. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  23870. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  23871. return ok
  23872. }
  23873. // ResetTotalTokens resets all changes to the "total_tokens" field.
  23874. func (m *UsageDetailMutation) ResetTotalTokens() {
  23875. m.total_tokens = nil
  23876. m.addtotal_tokens = nil
  23877. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  23878. }
  23879. // SetPromptTokens sets the "prompt_tokens" field.
  23880. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  23881. m.prompt_tokens = &u
  23882. m.addprompt_tokens = nil
  23883. }
  23884. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  23885. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  23886. v := m.prompt_tokens
  23887. if v == nil {
  23888. return
  23889. }
  23890. return *v, true
  23891. }
  23892. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  23893. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23895. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  23896. if !m.op.Is(OpUpdateOne) {
  23897. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  23898. }
  23899. if m.id == nil || m.oldValue == nil {
  23900. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  23901. }
  23902. oldValue, err := m.oldValue(ctx)
  23903. if err != nil {
  23904. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  23905. }
  23906. return oldValue.PromptTokens, nil
  23907. }
  23908. // AddPromptTokens adds u to the "prompt_tokens" field.
  23909. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  23910. if m.addprompt_tokens != nil {
  23911. *m.addprompt_tokens += u
  23912. } else {
  23913. m.addprompt_tokens = &u
  23914. }
  23915. }
  23916. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  23917. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  23918. v := m.addprompt_tokens
  23919. if v == nil {
  23920. return
  23921. }
  23922. return *v, true
  23923. }
  23924. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  23925. func (m *UsageDetailMutation) ClearPromptTokens() {
  23926. m.prompt_tokens = nil
  23927. m.addprompt_tokens = nil
  23928. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  23929. }
  23930. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  23931. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  23932. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  23933. return ok
  23934. }
  23935. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  23936. func (m *UsageDetailMutation) ResetPromptTokens() {
  23937. m.prompt_tokens = nil
  23938. m.addprompt_tokens = nil
  23939. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  23940. }
  23941. // SetCompletionTokens sets the "completion_tokens" field.
  23942. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  23943. m.completion_tokens = &u
  23944. m.addcompletion_tokens = nil
  23945. }
  23946. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  23947. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  23948. v := m.completion_tokens
  23949. if v == nil {
  23950. return
  23951. }
  23952. return *v, true
  23953. }
  23954. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  23955. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23957. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  23958. if !m.op.Is(OpUpdateOne) {
  23959. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  23960. }
  23961. if m.id == nil || m.oldValue == nil {
  23962. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  23963. }
  23964. oldValue, err := m.oldValue(ctx)
  23965. if err != nil {
  23966. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  23967. }
  23968. return oldValue.CompletionTokens, nil
  23969. }
  23970. // AddCompletionTokens adds u to the "completion_tokens" field.
  23971. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  23972. if m.addcompletion_tokens != nil {
  23973. *m.addcompletion_tokens += u
  23974. } else {
  23975. m.addcompletion_tokens = &u
  23976. }
  23977. }
  23978. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  23979. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  23980. v := m.addcompletion_tokens
  23981. if v == nil {
  23982. return
  23983. }
  23984. return *v, true
  23985. }
  23986. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  23987. func (m *UsageDetailMutation) ClearCompletionTokens() {
  23988. m.completion_tokens = nil
  23989. m.addcompletion_tokens = nil
  23990. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  23991. }
  23992. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  23993. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  23994. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  23995. return ok
  23996. }
  23997. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  23998. func (m *UsageDetailMutation) ResetCompletionTokens() {
  23999. m.completion_tokens = nil
  24000. m.addcompletion_tokens = nil
  24001. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  24002. }
  24003. // SetOrganizationID sets the "organization_id" field.
  24004. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  24005. m.organization_id = &u
  24006. m.addorganization_id = nil
  24007. }
  24008. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24009. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  24010. v := m.organization_id
  24011. if v == nil {
  24012. return
  24013. }
  24014. return *v, true
  24015. }
  24016. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  24017. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24019. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24020. if !m.op.Is(OpUpdateOne) {
  24021. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24022. }
  24023. if m.id == nil || m.oldValue == nil {
  24024. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24025. }
  24026. oldValue, err := m.oldValue(ctx)
  24027. if err != nil {
  24028. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24029. }
  24030. return oldValue.OrganizationID, nil
  24031. }
  24032. // AddOrganizationID adds u to the "organization_id" field.
  24033. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  24034. if m.addorganization_id != nil {
  24035. *m.addorganization_id += u
  24036. } else {
  24037. m.addorganization_id = &u
  24038. }
  24039. }
  24040. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24041. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  24042. v := m.addorganization_id
  24043. if v == nil {
  24044. return
  24045. }
  24046. return *v, true
  24047. }
  24048. // ClearOrganizationID clears the value of the "organization_id" field.
  24049. func (m *UsageDetailMutation) ClearOrganizationID() {
  24050. m.organization_id = nil
  24051. m.addorganization_id = nil
  24052. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  24053. }
  24054. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24055. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  24056. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  24057. return ok
  24058. }
  24059. // ResetOrganizationID resets all changes to the "organization_id" field.
  24060. func (m *UsageDetailMutation) ResetOrganizationID() {
  24061. m.organization_id = nil
  24062. m.addorganization_id = nil
  24063. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  24064. }
  24065. // Where appends a list predicates to the UsageDetailMutation builder.
  24066. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  24067. m.predicates = append(m.predicates, ps...)
  24068. }
  24069. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  24070. // users can use type-assertion to append predicates that do not depend on any generated package.
  24071. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  24072. p := make([]predicate.UsageDetail, len(ps))
  24073. for i := range ps {
  24074. p[i] = ps[i]
  24075. }
  24076. m.Where(p...)
  24077. }
  24078. // Op returns the operation name.
  24079. func (m *UsageDetailMutation) Op() Op {
  24080. return m.op
  24081. }
  24082. // SetOp allows setting the mutation operation.
  24083. func (m *UsageDetailMutation) SetOp(op Op) {
  24084. m.op = op
  24085. }
  24086. // Type returns the node type of this mutation (UsageDetail).
  24087. func (m *UsageDetailMutation) Type() string {
  24088. return m.typ
  24089. }
  24090. // Fields returns all fields that were changed during this mutation. Note that in
  24091. // order to get all numeric fields that were incremented/decremented, call
  24092. // AddedFields().
  24093. func (m *UsageDetailMutation) Fields() []string {
  24094. fields := make([]string, 0, 14)
  24095. if m.created_at != nil {
  24096. fields = append(fields, usagedetail.FieldCreatedAt)
  24097. }
  24098. if m.updated_at != nil {
  24099. fields = append(fields, usagedetail.FieldUpdatedAt)
  24100. }
  24101. if m.status != nil {
  24102. fields = append(fields, usagedetail.FieldStatus)
  24103. }
  24104. if m._type != nil {
  24105. fields = append(fields, usagedetail.FieldType)
  24106. }
  24107. if m.bot_id != nil {
  24108. fields = append(fields, usagedetail.FieldBotID)
  24109. }
  24110. if m.receiver_id != nil {
  24111. fields = append(fields, usagedetail.FieldReceiverID)
  24112. }
  24113. if m.app != nil {
  24114. fields = append(fields, usagedetail.FieldApp)
  24115. }
  24116. if m.session_id != nil {
  24117. fields = append(fields, usagedetail.FieldSessionID)
  24118. }
  24119. if m.request != nil {
  24120. fields = append(fields, usagedetail.FieldRequest)
  24121. }
  24122. if m.response != nil {
  24123. fields = append(fields, usagedetail.FieldResponse)
  24124. }
  24125. if m.total_tokens != nil {
  24126. fields = append(fields, usagedetail.FieldTotalTokens)
  24127. }
  24128. if m.prompt_tokens != nil {
  24129. fields = append(fields, usagedetail.FieldPromptTokens)
  24130. }
  24131. if m.completion_tokens != nil {
  24132. fields = append(fields, usagedetail.FieldCompletionTokens)
  24133. }
  24134. if m.organization_id != nil {
  24135. fields = append(fields, usagedetail.FieldOrganizationID)
  24136. }
  24137. return fields
  24138. }
  24139. // Field returns the value of a field with the given name. The second boolean
  24140. // return value indicates that this field was not set, or was not defined in the
  24141. // schema.
  24142. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  24143. switch name {
  24144. case usagedetail.FieldCreatedAt:
  24145. return m.CreatedAt()
  24146. case usagedetail.FieldUpdatedAt:
  24147. return m.UpdatedAt()
  24148. case usagedetail.FieldStatus:
  24149. return m.Status()
  24150. case usagedetail.FieldType:
  24151. return m.GetType()
  24152. case usagedetail.FieldBotID:
  24153. return m.BotID()
  24154. case usagedetail.FieldReceiverID:
  24155. return m.ReceiverID()
  24156. case usagedetail.FieldApp:
  24157. return m.App()
  24158. case usagedetail.FieldSessionID:
  24159. return m.SessionID()
  24160. case usagedetail.FieldRequest:
  24161. return m.Request()
  24162. case usagedetail.FieldResponse:
  24163. return m.Response()
  24164. case usagedetail.FieldTotalTokens:
  24165. return m.TotalTokens()
  24166. case usagedetail.FieldPromptTokens:
  24167. return m.PromptTokens()
  24168. case usagedetail.FieldCompletionTokens:
  24169. return m.CompletionTokens()
  24170. case usagedetail.FieldOrganizationID:
  24171. return m.OrganizationID()
  24172. }
  24173. return nil, false
  24174. }
  24175. // OldField returns the old value of the field from the database. An error is
  24176. // returned if the mutation operation is not UpdateOne, or the query to the
  24177. // database failed.
  24178. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24179. switch name {
  24180. case usagedetail.FieldCreatedAt:
  24181. return m.OldCreatedAt(ctx)
  24182. case usagedetail.FieldUpdatedAt:
  24183. return m.OldUpdatedAt(ctx)
  24184. case usagedetail.FieldStatus:
  24185. return m.OldStatus(ctx)
  24186. case usagedetail.FieldType:
  24187. return m.OldType(ctx)
  24188. case usagedetail.FieldBotID:
  24189. return m.OldBotID(ctx)
  24190. case usagedetail.FieldReceiverID:
  24191. return m.OldReceiverID(ctx)
  24192. case usagedetail.FieldApp:
  24193. return m.OldApp(ctx)
  24194. case usagedetail.FieldSessionID:
  24195. return m.OldSessionID(ctx)
  24196. case usagedetail.FieldRequest:
  24197. return m.OldRequest(ctx)
  24198. case usagedetail.FieldResponse:
  24199. return m.OldResponse(ctx)
  24200. case usagedetail.FieldTotalTokens:
  24201. return m.OldTotalTokens(ctx)
  24202. case usagedetail.FieldPromptTokens:
  24203. return m.OldPromptTokens(ctx)
  24204. case usagedetail.FieldCompletionTokens:
  24205. return m.OldCompletionTokens(ctx)
  24206. case usagedetail.FieldOrganizationID:
  24207. return m.OldOrganizationID(ctx)
  24208. }
  24209. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  24210. }
  24211. // SetField sets the value of a field with the given name. It returns an error if
  24212. // the field is not defined in the schema, or if the type mismatched the field
  24213. // type.
  24214. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  24215. switch name {
  24216. case usagedetail.FieldCreatedAt:
  24217. v, ok := value.(time.Time)
  24218. if !ok {
  24219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24220. }
  24221. m.SetCreatedAt(v)
  24222. return nil
  24223. case usagedetail.FieldUpdatedAt:
  24224. v, ok := value.(time.Time)
  24225. if !ok {
  24226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24227. }
  24228. m.SetUpdatedAt(v)
  24229. return nil
  24230. case usagedetail.FieldStatus:
  24231. v, ok := value.(uint8)
  24232. if !ok {
  24233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24234. }
  24235. m.SetStatus(v)
  24236. return nil
  24237. case usagedetail.FieldType:
  24238. v, ok := value.(int)
  24239. if !ok {
  24240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24241. }
  24242. m.SetType(v)
  24243. return nil
  24244. case usagedetail.FieldBotID:
  24245. v, ok := value.(string)
  24246. if !ok {
  24247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24248. }
  24249. m.SetBotID(v)
  24250. return nil
  24251. case usagedetail.FieldReceiverID:
  24252. v, ok := value.(string)
  24253. if !ok {
  24254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24255. }
  24256. m.SetReceiverID(v)
  24257. return nil
  24258. case usagedetail.FieldApp:
  24259. v, ok := value.(int)
  24260. if !ok {
  24261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24262. }
  24263. m.SetApp(v)
  24264. return nil
  24265. case usagedetail.FieldSessionID:
  24266. v, ok := value.(uint64)
  24267. if !ok {
  24268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24269. }
  24270. m.SetSessionID(v)
  24271. return nil
  24272. case usagedetail.FieldRequest:
  24273. v, ok := value.(string)
  24274. if !ok {
  24275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24276. }
  24277. m.SetRequest(v)
  24278. return nil
  24279. case usagedetail.FieldResponse:
  24280. v, ok := value.(string)
  24281. if !ok {
  24282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24283. }
  24284. m.SetResponse(v)
  24285. return nil
  24286. case usagedetail.FieldTotalTokens:
  24287. v, ok := value.(uint64)
  24288. if !ok {
  24289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24290. }
  24291. m.SetTotalTokens(v)
  24292. return nil
  24293. case usagedetail.FieldPromptTokens:
  24294. v, ok := value.(uint64)
  24295. if !ok {
  24296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24297. }
  24298. m.SetPromptTokens(v)
  24299. return nil
  24300. case usagedetail.FieldCompletionTokens:
  24301. v, ok := value.(uint64)
  24302. if !ok {
  24303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24304. }
  24305. m.SetCompletionTokens(v)
  24306. return nil
  24307. case usagedetail.FieldOrganizationID:
  24308. v, ok := value.(uint64)
  24309. if !ok {
  24310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24311. }
  24312. m.SetOrganizationID(v)
  24313. return nil
  24314. }
  24315. return fmt.Errorf("unknown UsageDetail field %s", name)
  24316. }
  24317. // AddedFields returns all numeric fields that were incremented/decremented during
  24318. // this mutation.
  24319. func (m *UsageDetailMutation) AddedFields() []string {
  24320. var fields []string
  24321. if m.addstatus != nil {
  24322. fields = append(fields, usagedetail.FieldStatus)
  24323. }
  24324. if m.add_type != nil {
  24325. fields = append(fields, usagedetail.FieldType)
  24326. }
  24327. if m.addapp != nil {
  24328. fields = append(fields, usagedetail.FieldApp)
  24329. }
  24330. if m.addsession_id != nil {
  24331. fields = append(fields, usagedetail.FieldSessionID)
  24332. }
  24333. if m.addtotal_tokens != nil {
  24334. fields = append(fields, usagedetail.FieldTotalTokens)
  24335. }
  24336. if m.addprompt_tokens != nil {
  24337. fields = append(fields, usagedetail.FieldPromptTokens)
  24338. }
  24339. if m.addcompletion_tokens != nil {
  24340. fields = append(fields, usagedetail.FieldCompletionTokens)
  24341. }
  24342. if m.addorganization_id != nil {
  24343. fields = append(fields, usagedetail.FieldOrganizationID)
  24344. }
  24345. return fields
  24346. }
  24347. // AddedField returns the numeric value that was incremented/decremented on a field
  24348. // with the given name. The second boolean return value indicates that this field
  24349. // was not set, or was not defined in the schema.
  24350. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  24351. switch name {
  24352. case usagedetail.FieldStatus:
  24353. return m.AddedStatus()
  24354. case usagedetail.FieldType:
  24355. return m.AddedType()
  24356. case usagedetail.FieldApp:
  24357. return m.AddedApp()
  24358. case usagedetail.FieldSessionID:
  24359. return m.AddedSessionID()
  24360. case usagedetail.FieldTotalTokens:
  24361. return m.AddedTotalTokens()
  24362. case usagedetail.FieldPromptTokens:
  24363. return m.AddedPromptTokens()
  24364. case usagedetail.FieldCompletionTokens:
  24365. return m.AddedCompletionTokens()
  24366. case usagedetail.FieldOrganizationID:
  24367. return m.AddedOrganizationID()
  24368. }
  24369. return nil, false
  24370. }
  24371. // AddField adds the value to the field with the given name. It returns an error if
  24372. // the field is not defined in the schema, or if the type mismatched the field
  24373. // type.
  24374. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  24375. switch name {
  24376. case usagedetail.FieldStatus:
  24377. v, ok := value.(int8)
  24378. if !ok {
  24379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24380. }
  24381. m.AddStatus(v)
  24382. return nil
  24383. case usagedetail.FieldType:
  24384. v, ok := value.(int)
  24385. if !ok {
  24386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24387. }
  24388. m.AddType(v)
  24389. return nil
  24390. case usagedetail.FieldApp:
  24391. v, ok := value.(int)
  24392. if !ok {
  24393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24394. }
  24395. m.AddApp(v)
  24396. return nil
  24397. case usagedetail.FieldSessionID:
  24398. v, ok := value.(int64)
  24399. if !ok {
  24400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24401. }
  24402. m.AddSessionID(v)
  24403. return nil
  24404. case usagedetail.FieldTotalTokens:
  24405. v, ok := value.(int64)
  24406. if !ok {
  24407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24408. }
  24409. m.AddTotalTokens(v)
  24410. return nil
  24411. case usagedetail.FieldPromptTokens:
  24412. v, ok := value.(int64)
  24413. if !ok {
  24414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24415. }
  24416. m.AddPromptTokens(v)
  24417. return nil
  24418. case usagedetail.FieldCompletionTokens:
  24419. v, ok := value.(int64)
  24420. if !ok {
  24421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24422. }
  24423. m.AddCompletionTokens(v)
  24424. return nil
  24425. case usagedetail.FieldOrganizationID:
  24426. v, ok := value.(int64)
  24427. if !ok {
  24428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24429. }
  24430. m.AddOrganizationID(v)
  24431. return nil
  24432. }
  24433. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  24434. }
  24435. // ClearedFields returns all nullable fields that were cleared during this
  24436. // mutation.
  24437. func (m *UsageDetailMutation) ClearedFields() []string {
  24438. var fields []string
  24439. if m.FieldCleared(usagedetail.FieldStatus) {
  24440. fields = append(fields, usagedetail.FieldStatus)
  24441. }
  24442. if m.FieldCleared(usagedetail.FieldType) {
  24443. fields = append(fields, usagedetail.FieldType)
  24444. }
  24445. if m.FieldCleared(usagedetail.FieldApp) {
  24446. fields = append(fields, usagedetail.FieldApp)
  24447. }
  24448. if m.FieldCleared(usagedetail.FieldSessionID) {
  24449. fields = append(fields, usagedetail.FieldSessionID)
  24450. }
  24451. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  24452. fields = append(fields, usagedetail.FieldTotalTokens)
  24453. }
  24454. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  24455. fields = append(fields, usagedetail.FieldPromptTokens)
  24456. }
  24457. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  24458. fields = append(fields, usagedetail.FieldCompletionTokens)
  24459. }
  24460. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  24461. fields = append(fields, usagedetail.FieldOrganizationID)
  24462. }
  24463. return fields
  24464. }
  24465. // FieldCleared returns a boolean indicating if a field with the given name was
  24466. // cleared in this mutation.
  24467. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  24468. _, ok := m.clearedFields[name]
  24469. return ok
  24470. }
  24471. // ClearField clears the value of the field with the given name. It returns an
  24472. // error if the field is not defined in the schema.
  24473. func (m *UsageDetailMutation) ClearField(name string) error {
  24474. switch name {
  24475. case usagedetail.FieldStatus:
  24476. m.ClearStatus()
  24477. return nil
  24478. case usagedetail.FieldType:
  24479. m.ClearType()
  24480. return nil
  24481. case usagedetail.FieldApp:
  24482. m.ClearApp()
  24483. return nil
  24484. case usagedetail.FieldSessionID:
  24485. m.ClearSessionID()
  24486. return nil
  24487. case usagedetail.FieldTotalTokens:
  24488. m.ClearTotalTokens()
  24489. return nil
  24490. case usagedetail.FieldPromptTokens:
  24491. m.ClearPromptTokens()
  24492. return nil
  24493. case usagedetail.FieldCompletionTokens:
  24494. m.ClearCompletionTokens()
  24495. return nil
  24496. case usagedetail.FieldOrganizationID:
  24497. m.ClearOrganizationID()
  24498. return nil
  24499. }
  24500. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  24501. }
  24502. // ResetField resets all changes in the mutation for the field with the given name.
  24503. // It returns an error if the field is not defined in the schema.
  24504. func (m *UsageDetailMutation) ResetField(name string) error {
  24505. switch name {
  24506. case usagedetail.FieldCreatedAt:
  24507. m.ResetCreatedAt()
  24508. return nil
  24509. case usagedetail.FieldUpdatedAt:
  24510. m.ResetUpdatedAt()
  24511. return nil
  24512. case usagedetail.FieldStatus:
  24513. m.ResetStatus()
  24514. return nil
  24515. case usagedetail.FieldType:
  24516. m.ResetType()
  24517. return nil
  24518. case usagedetail.FieldBotID:
  24519. m.ResetBotID()
  24520. return nil
  24521. case usagedetail.FieldReceiverID:
  24522. m.ResetReceiverID()
  24523. return nil
  24524. case usagedetail.FieldApp:
  24525. m.ResetApp()
  24526. return nil
  24527. case usagedetail.FieldSessionID:
  24528. m.ResetSessionID()
  24529. return nil
  24530. case usagedetail.FieldRequest:
  24531. m.ResetRequest()
  24532. return nil
  24533. case usagedetail.FieldResponse:
  24534. m.ResetResponse()
  24535. return nil
  24536. case usagedetail.FieldTotalTokens:
  24537. m.ResetTotalTokens()
  24538. return nil
  24539. case usagedetail.FieldPromptTokens:
  24540. m.ResetPromptTokens()
  24541. return nil
  24542. case usagedetail.FieldCompletionTokens:
  24543. m.ResetCompletionTokens()
  24544. return nil
  24545. case usagedetail.FieldOrganizationID:
  24546. m.ResetOrganizationID()
  24547. return nil
  24548. }
  24549. return fmt.Errorf("unknown UsageDetail field %s", name)
  24550. }
  24551. // AddedEdges returns all edge names that were set/added in this mutation.
  24552. func (m *UsageDetailMutation) AddedEdges() []string {
  24553. edges := make([]string, 0, 0)
  24554. return edges
  24555. }
  24556. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24557. // name in this mutation.
  24558. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  24559. return nil
  24560. }
  24561. // RemovedEdges returns all edge names that were removed in this mutation.
  24562. func (m *UsageDetailMutation) RemovedEdges() []string {
  24563. edges := make([]string, 0, 0)
  24564. return edges
  24565. }
  24566. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24567. // the given name in this mutation.
  24568. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  24569. return nil
  24570. }
  24571. // ClearedEdges returns all edge names that were cleared in this mutation.
  24572. func (m *UsageDetailMutation) ClearedEdges() []string {
  24573. edges := make([]string, 0, 0)
  24574. return edges
  24575. }
  24576. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24577. // was cleared in this mutation.
  24578. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  24579. return false
  24580. }
  24581. // ClearEdge clears the value of the edge with the given name. It returns an error
  24582. // if that edge is not defined in the schema.
  24583. func (m *UsageDetailMutation) ClearEdge(name string) error {
  24584. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  24585. }
  24586. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24587. // It returns an error if the edge is not defined in the schema.
  24588. func (m *UsageDetailMutation) ResetEdge(name string) error {
  24589. return fmt.Errorf("unknown UsageDetail edge %s", name)
  24590. }
  24591. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  24592. type UsageTotalMutation struct {
  24593. config
  24594. op Op
  24595. typ string
  24596. id *uint64
  24597. created_at *time.Time
  24598. updated_at *time.Time
  24599. status *uint8
  24600. addstatus *int8
  24601. _type *int
  24602. add_type *int
  24603. bot_id *string
  24604. total_tokens *uint64
  24605. addtotal_tokens *int64
  24606. start_index *uint64
  24607. addstart_index *int64
  24608. end_index *uint64
  24609. addend_index *int64
  24610. organization_id *uint64
  24611. addorganization_id *int64
  24612. clearedFields map[string]struct{}
  24613. done bool
  24614. oldValue func(context.Context) (*UsageTotal, error)
  24615. predicates []predicate.UsageTotal
  24616. }
  24617. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  24618. // usagetotalOption allows management of the mutation configuration using functional options.
  24619. type usagetotalOption func(*UsageTotalMutation)
  24620. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  24621. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  24622. m := &UsageTotalMutation{
  24623. config: c,
  24624. op: op,
  24625. typ: TypeUsageTotal,
  24626. clearedFields: make(map[string]struct{}),
  24627. }
  24628. for _, opt := range opts {
  24629. opt(m)
  24630. }
  24631. return m
  24632. }
  24633. // withUsageTotalID sets the ID field of the mutation.
  24634. func withUsageTotalID(id uint64) usagetotalOption {
  24635. return func(m *UsageTotalMutation) {
  24636. var (
  24637. err error
  24638. once sync.Once
  24639. value *UsageTotal
  24640. )
  24641. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  24642. once.Do(func() {
  24643. if m.done {
  24644. err = errors.New("querying old values post mutation is not allowed")
  24645. } else {
  24646. value, err = m.Client().UsageTotal.Get(ctx, id)
  24647. }
  24648. })
  24649. return value, err
  24650. }
  24651. m.id = &id
  24652. }
  24653. }
  24654. // withUsageTotal sets the old UsageTotal of the mutation.
  24655. func withUsageTotal(node *UsageTotal) usagetotalOption {
  24656. return func(m *UsageTotalMutation) {
  24657. m.oldValue = func(context.Context) (*UsageTotal, error) {
  24658. return node, nil
  24659. }
  24660. m.id = &node.ID
  24661. }
  24662. }
  24663. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24664. // executed in a transaction (ent.Tx), a transactional client is returned.
  24665. func (m UsageTotalMutation) Client() *Client {
  24666. client := &Client{config: m.config}
  24667. client.init()
  24668. return client
  24669. }
  24670. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24671. // it returns an error otherwise.
  24672. func (m UsageTotalMutation) Tx() (*Tx, error) {
  24673. if _, ok := m.driver.(*txDriver); !ok {
  24674. return nil, errors.New("ent: mutation is not running in a transaction")
  24675. }
  24676. tx := &Tx{config: m.config}
  24677. tx.init()
  24678. return tx, nil
  24679. }
  24680. // SetID sets the value of the id field. Note that this
  24681. // operation is only accepted on creation of UsageTotal entities.
  24682. func (m *UsageTotalMutation) SetID(id uint64) {
  24683. m.id = &id
  24684. }
  24685. // ID returns the ID value in the mutation. Note that the ID is only available
  24686. // if it was provided to the builder or after it was returned from the database.
  24687. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  24688. if m.id == nil {
  24689. return
  24690. }
  24691. return *m.id, true
  24692. }
  24693. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24694. // That means, if the mutation is applied within a transaction with an isolation level such
  24695. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24696. // or updated by the mutation.
  24697. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  24698. switch {
  24699. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24700. id, exists := m.ID()
  24701. if exists {
  24702. return []uint64{id}, nil
  24703. }
  24704. fallthrough
  24705. case m.op.Is(OpUpdate | OpDelete):
  24706. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  24707. default:
  24708. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24709. }
  24710. }
  24711. // SetCreatedAt sets the "created_at" field.
  24712. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  24713. m.created_at = &t
  24714. }
  24715. // CreatedAt returns the value of the "created_at" field in the mutation.
  24716. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  24717. v := m.created_at
  24718. if v == nil {
  24719. return
  24720. }
  24721. return *v, true
  24722. }
  24723. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  24724. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24726. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24727. if !m.op.Is(OpUpdateOne) {
  24728. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24729. }
  24730. if m.id == nil || m.oldValue == nil {
  24731. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24732. }
  24733. oldValue, err := m.oldValue(ctx)
  24734. if err != nil {
  24735. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24736. }
  24737. return oldValue.CreatedAt, nil
  24738. }
  24739. // ResetCreatedAt resets all changes to the "created_at" field.
  24740. func (m *UsageTotalMutation) ResetCreatedAt() {
  24741. m.created_at = nil
  24742. }
  24743. // SetUpdatedAt sets the "updated_at" field.
  24744. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  24745. m.updated_at = &t
  24746. }
  24747. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24748. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  24749. v := m.updated_at
  24750. if v == nil {
  24751. return
  24752. }
  24753. return *v, true
  24754. }
  24755. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  24756. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24758. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24759. if !m.op.Is(OpUpdateOne) {
  24760. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24761. }
  24762. if m.id == nil || m.oldValue == nil {
  24763. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24764. }
  24765. oldValue, err := m.oldValue(ctx)
  24766. if err != nil {
  24767. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24768. }
  24769. return oldValue.UpdatedAt, nil
  24770. }
  24771. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24772. func (m *UsageTotalMutation) ResetUpdatedAt() {
  24773. m.updated_at = nil
  24774. }
  24775. // SetStatus sets the "status" field.
  24776. func (m *UsageTotalMutation) SetStatus(u uint8) {
  24777. m.status = &u
  24778. m.addstatus = nil
  24779. }
  24780. // Status returns the value of the "status" field in the mutation.
  24781. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  24782. v := m.status
  24783. if v == nil {
  24784. return
  24785. }
  24786. return *v, true
  24787. }
  24788. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  24789. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24791. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24792. if !m.op.Is(OpUpdateOne) {
  24793. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24794. }
  24795. if m.id == nil || m.oldValue == nil {
  24796. return v, errors.New("OldStatus requires an ID field in the mutation")
  24797. }
  24798. oldValue, err := m.oldValue(ctx)
  24799. if err != nil {
  24800. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24801. }
  24802. return oldValue.Status, nil
  24803. }
  24804. // AddStatus adds u to the "status" field.
  24805. func (m *UsageTotalMutation) AddStatus(u int8) {
  24806. if m.addstatus != nil {
  24807. *m.addstatus += u
  24808. } else {
  24809. m.addstatus = &u
  24810. }
  24811. }
  24812. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24813. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  24814. v := m.addstatus
  24815. if v == nil {
  24816. return
  24817. }
  24818. return *v, true
  24819. }
  24820. // ClearStatus clears the value of the "status" field.
  24821. func (m *UsageTotalMutation) ClearStatus() {
  24822. m.status = nil
  24823. m.addstatus = nil
  24824. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  24825. }
  24826. // StatusCleared returns if the "status" field was cleared in this mutation.
  24827. func (m *UsageTotalMutation) StatusCleared() bool {
  24828. _, ok := m.clearedFields[usagetotal.FieldStatus]
  24829. return ok
  24830. }
  24831. // ResetStatus resets all changes to the "status" field.
  24832. func (m *UsageTotalMutation) ResetStatus() {
  24833. m.status = nil
  24834. m.addstatus = nil
  24835. delete(m.clearedFields, usagetotal.FieldStatus)
  24836. }
  24837. // SetType sets the "type" field.
  24838. func (m *UsageTotalMutation) SetType(i int) {
  24839. m._type = &i
  24840. m.add_type = nil
  24841. }
  24842. // GetType returns the value of the "type" field in the mutation.
  24843. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  24844. v := m._type
  24845. if v == nil {
  24846. return
  24847. }
  24848. return *v, true
  24849. }
  24850. // OldType returns the old "type" field's value of the UsageTotal entity.
  24851. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24853. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  24854. if !m.op.Is(OpUpdateOne) {
  24855. return v, errors.New("OldType is only allowed on UpdateOne operations")
  24856. }
  24857. if m.id == nil || m.oldValue == nil {
  24858. return v, errors.New("OldType requires an ID field in the mutation")
  24859. }
  24860. oldValue, err := m.oldValue(ctx)
  24861. if err != nil {
  24862. return v, fmt.Errorf("querying old value for OldType: %w", err)
  24863. }
  24864. return oldValue.Type, nil
  24865. }
  24866. // AddType adds i to the "type" field.
  24867. func (m *UsageTotalMutation) AddType(i int) {
  24868. if m.add_type != nil {
  24869. *m.add_type += i
  24870. } else {
  24871. m.add_type = &i
  24872. }
  24873. }
  24874. // AddedType returns the value that was added to the "type" field in this mutation.
  24875. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  24876. v := m.add_type
  24877. if v == nil {
  24878. return
  24879. }
  24880. return *v, true
  24881. }
  24882. // ClearType clears the value of the "type" field.
  24883. func (m *UsageTotalMutation) ClearType() {
  24884. m._type = nil
  24885. m.add_type = nil
  24886. m.clearedFields[usagetotal.FieldType] = struct{}{}
  24887. }
  24888. // TypeCleared returns if the "type" field was cleared in this mutation.
  24889. func (m *UsageTotalMutation) TypeCleared() bool {
  24890. _, ok := m.clearedFields[usagetotal.FieldType]
  24891. return ok
  24892. }
  24893. // ResetType resets all changes to the "type" field.
  24894. func (m *UsageTotalMutation) ResetType() {
  24895. m._type = nil
  24896. m.add_type = nil
  24897. delete(m.clearedFields, usagetotal.FieldType)
  24898. }
  24899. // SetBotID sets the "bot_id" field.
  24900. func (m *UsageTotalMutation) SetBotID(s string) {
  24901. m.bot_id = &s
  24902. }
  24903. // BotID returns the value of the "bot_id" field in the mutation.
  24904. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  24905. v := m.bot_id
  24906. if v == nil {
  24907. return
  24908. }
  24909. return *v, true
  24910. }
  24911. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  24912. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24914. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  24915. if !m.op.Is(OpUpdateOne) {
  24916. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  24917. }
  24918. if m.id == nil || m.oldValue == nil {
  24919. return v, errors.New("OldBotID requires an ID field in the mutation")
  24920. }
  24921. oldValue, err := m.oldValue(ctx)
  24922. if err != nil {
  24923. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  24924. }
  24925. return oldValue.BotID, nil
  24926. }
  24927. // ResetBotID resets all changes to the "bot_id" field.
  24928. func (m *UsageTotalMutation) ResetBotID() {
  24929. m.bot_id = nil
  24930. }
  24931. // SetTotalTokens sets the "total_tokens" field.
  24932. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  24933. m.total_tokens = &u
  24934. m.addtotal_tokens = nil
  24935. }
  24936. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  24937. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  24938. v := m.total_tokens
  24939. if v == nil {
  24940. return
  24941. }
  24942. return *v, true
  24943. }
  24944. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  24945. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24947. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  24948. if !m.op.Is(OpUpdateOne) {
  24949. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  24950. }
  24951. if m.id == nil || m.oldValue == nil {
  24952. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  24953. }
  24954. oldValue, err := m.oldValue(ctx)
  24955. if err != nil {
  24956. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  24957. }
  24958. return oldValue.TotalTokens, nil
  24959. }
  24960. // AddTotalTokens adds u to the "total_tokens" field.
  24961. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  24962. if m.addtotal_tokens != nil {
  24963. *m.addtotal_tokens += u
  24964. } else {
  24965. m.addtotal_tokens = &u
  24966. }
  24967. }
  24968. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  24969. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  24970. v := m.addtotal_tokens
  24971. if v == nil {
  24972. return
  24973. }
  24974. return *v, true
  24975. }
  24976. // ClearTotalTokens clears the value of the "total_tokens" field.
  24977. func (m *UsageTotalMutation) ClearTotalTokens() {
  24978. m.total_tokens = nil
  24979. m.addtotal_tokens = nil
  24980. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  24981. }
  24982. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  24983. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  24984. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  24985. return ok
  24986. }
  24987. // ResetTotalTokens resets all changes to the "total_tokens" field.
  24988. func (m *UsageTotalMutation) ResetTotalTokens() {
  24989. m.total_tokens = nil
  24990. m.addtotal_tokens = nil
  24991. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  24992. }
  24993. // SetStartIndex sets the "start_index" field.
  24994. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  24995. m.start_index = &u
  24996. m.addstart_index = nil
  24997. }
  24998. // StartIndex returns the value of the "start_index" field in the mutation.
  24999. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  25000. v := m.start_index
  25001. if v == nil {
  25002. return
  25003. }
  25004. return *v, true
  25005. }
  25006. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  25007. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  25008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25009. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  25010. if !m.op.Is(OpUpdateOne) {
  25011. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  25012. }
  25013. if m.id == nil || m.oldValue == nil {
  25014. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  25015. }
  25016. oldValue, err := m.oldValue(ctx)
  25017. if err != nil {
  25018. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  25019. }
  25020. return oldValue.StartIndex, nil
  25021. }
  25022. // AddStartIndex adds u to the "start_index" field.
  25023. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  25024. if m.addstart_index != nil {
  25025. *m.addstart_index += u
  25026. } else {
  25027. m.addstart_index = &u
  25028. }
  25029. }
  25030. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  25031. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  25032. v := m.addstart_index
  25033. if v == nil {
  25034. return
  25035. }
  25036. return *v, true
  25037. }
  25038. // ClearStartIndex clears the value of the "start_index" field.
  25039. func (m *UsageTotalMutation) ClearStartIndex() {
  25040. m.start_index = nil
  25041. m.addstart_index = nil
  25042. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  25043. }
  25044. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  25045. func (m *UsageTotalMutation) StartIndexCleared() bool {
  25046. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  25047. return ok
  25048. }
  25049. // ResetStartIndex resets all changes to the "start_index" field.
  25050. func (m *UsageTotalMutation) ResetStartIndex() {
  25051. m.start_index = nil
  25052. m.addstart_index = nil
  25053. delete(m.clearedFields, usagetotal.FieldStartIndex)
  25054. }
  25055. // SetEndIndex sets the "end_index" field.
  25056. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  25057. m.end_index = &u
  25058. m.addend_index = nil
  25059. }
  25060. // EndIndex returns the value of the "end_index" field in the mutation.
  25061. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  25062. v := m.end_index
  25063. if v == nil {
  25064. return
  25065. }
  25066. return *v, true
  25067. }
  25068. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  25069. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  25070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25071. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  25072. if !m.op.Is(OpUpdateOne) {
  25073. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  25074. }
  25075. if m.id == nil || m.oldValue == nil {
  25076. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  25077. }
  25078. oldValue, err := m.oldValue(ctx)
  25079. if err != nil {
  25080. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  25081. }
  25082. return oldValue.EndIndex, nil
  25083. }
  25084. // AddEndIndex adds u to the "end_index" field.
  25085. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  25086. if m.addend_index != nil {
  25087. *m.addend_index += u
  25088. } else {
  25089. m.addend_index = &u
  25090. }
  25091. }
  25092. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  25093. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  25094. v := m.addend_index
  25095. if v == nil {
  25096. return
  25097. }
  25098. return *v, true
  25099. }
  25100. // ClearEndIndex clears the value of the "end_index" field.
  25101. func (m *UsageTotalMutation) ClearEndIndex() {
  25102. m.end_index = nil
  25103. m.addend_index = nil
  25104. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  25105. }
  25106. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  25107. func (m *UsageTotalMutation) EndIndexCleared() bool {
  25108. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  25109. return ok
  25110. }
  25111. // ResetEndIndex resets all changes to the "end_index" field.
  25112. func (m *UsageTotalMutation) ResetEndIndex() {
  25113. m.end_index = nil
  25114. m.addend_index = nil
  25115. delete(m.clearedFields, usagetotal.FieldEndIndex)
  25116. }
  25117. // SetOrganizationID sets the "organization_id" field.
  25118. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  25119. m.organization_id = &u
  25120. m.addorganization_id = nil
  25121. }
  25122. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25123. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  25124. v := m.organization_id
  25125. if v == nil {
  25126. return
  25127. }
  25128. return *v, true
  25129. }
  25130. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  25131. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  25132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25133. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25134. if !m.op.Is(OpUpdateOne) {
  25135. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25136. }
  25137. if m.id == nil || m.oldValue == nil {
  25138. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25139. }
  25140. oldValue, err := m.oldValue(ctx)
  25141. if err != nil {
  25142. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25143. }
  25144. return oldValue.OrganizationID, nil
  25145. }
  25146. // AddOrganizationID adds u to the "organization_id" field.
  25147. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  25148. if m.addorganization_id != nil {
  25149. *m.addorganization_id += u
  25150. } else {
  25151. m.addorganization_id = &u
  25152. }
  25153. }
  25154. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25155. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  25156. v := m.addorganization_id
  25157. if v == nil {
  25158. return
  25159. }
  25160. return *v, true
  25161. }
  25162. // ClearOrganizationID clears the value of the "organization_id" field.
  25163. func (m *UsageTotalMutation) ClearOrganizationID() {
  25164. m.organization_id = nil
  25165. m.addorganization_id = nil
  25166. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  25167. }
  25168. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  25169. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  25170. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  25171. return ok
  25172. }
  25173. // ResetOrganizationID resets all changes to the "organization_id" field.
  25174. func (m *UsageTotalMutation) ResetOrganizationID() {
  25175. m.organization_id = nil
  25176. m.addorganization_id = nil
  25177. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  25178. }
  25179. // Where appends a list predicates to the UsageTotalMutation builder.
  25180. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  25181. m.predicates = append(m.predicates, ps...)
  25182. }
  25183. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  25184. // users can use type-assertion to append predicates that do not depend on any generated package.
  25185. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  25186. p := make([]predicate.UsageTotal, len(ps))
  25187. for i := range ps {
  25188. p[i] = ps[i]
  25189. }
  25190. m.Where(p...)
  25191. }
  25192. // Op returns the operation name.
  25193. func (m *UsageTotalMutation) Op() Op {
  25194. return m.op
  25195. }
  25196. // SetOp allows setting the mutation operation.
  25197. func (m *UsageTotalMutation) SetOp(op Op) {
  25198. m.op = op
  25199. }
  25200. // Type returns the node type of this mutation (UsageTotal).
  25201. func (m *UsageTotalMutation) Type() string {
  25202. return m.typ
  25203. }
  25204. // Fields returns all fields that were changed during this mutation. Note that in
  25205. // order to get all numeric fields that were incremented/decremented, call
  25206. // AddedFields().
  25207. func (m *UsageTotalMutation) Fields() []string {
  25208. fields := make([]string, 0, 9)
  25209. if m.created_at != nil {
  25210. fields = append(fields, usagetotal.FieldCreatedAt)
  25211. }
  25212. if m.updated_at != nil {
  25213. fields = append(fields, usagetotal.FieldUpdatedAt)
  25214. }
  25215. if m.status != nil {
  25216. fields = append(fields, usagetotal.FieldStatus)
  25217. }
  25218. if m._type != nil {
  25219. fields = append(fields, usagetotal.FieldType)
  25220. }
  25221. if m.bot_id != nil {
  25222. fields = append(fields, usagetotal.FieldBotID)
  25223. }
  25224. if m.total_tokens != nil {
  25225. fields = append(fields, usagetotal.FieldTotalTokens)
  25226. }
  25227. if m.start_index != nil {
  25228. fields = append(fields, usagetotal.FieldStartIndex)
  25229. }
  25230. if m.end_index != nil {
  25231. fields = append(fields, usagetotal.FieldEndIndex)
  25232. }
  25233. if m.organization_id != nil {
  25234. fields = append(fields, usagetotal.FieldOrganizationID)
  25235. }
  25236. return fields
  25237. }
  25238. // Field returns the value of a field with the given name. The second boolean
  25239. // return value indicates that this field was not set, or was not defined in the
  25240. // schema.
  25241. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  25242. switch name {
  25243. case usagetotal.FieldCreatedAt:
  25244. return m.CreatedAt()
  25245. case usagetotal.FieldUpdatedAt:
  25246. return m.UpdatedAt()
  25247. case usagetotal.FieldStatus:
  25248. return m.Status()
  25249. case usagetotal.FieldType:
  25250. return m.GetType()
  25251. case usagetotal.FieldBotID:
  25252. return m.BotID()
  25253. case usagetotal.FieldTotalTokens:
  25254. return m.TotalTokens()
  25255. case usagetotal.FieldStartIndex:
  25256. return m.StartIndex()
  25257. case usagetotal.FieldEndIndex:
  25258. return m.EndIndex()
  25259. case usagetotal.FieldOrganizationID:
  25260. return m.OrganizationID()
  25261. }
  25262. return nil, false
  25263. }
  25264. // OldField returns the old value of the field from the database. An error is
  25265. // returned if the mutation operation is not UpdateOne, or the query to the
  25266. // database failed.
  25267. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25268. switch name {
  25269. case usagetotal.FieldCreatedAt:
  25270. return m.OldCreatedAt(ctx)
  25271. case usagetotal.FieldUpdatedAt:
  25272. return m.OldUpdatedAt(ctx)
  25273. case usagetotal.FieldStatus:
  25274. return m.OldStatus(ctx)
  25275. case usagetotal.FieldType:
  25276. return m.OldType(ctx)
  25277. case usagetotal.FieldBotID:
  25278. return m.OldBotID(ctx)
  25279. case usagetotal.FieldTotalTokens:
  25280. return m.OldTotalTokens(ctx)
  25281. case usagetotal.FieldStartIndex:
  25282. return m.OldStartIndex(ctx)
  25283. case usagetotal.FieldEndIndex:
  25284. return m.OldEndIndex(ctx)
  25285. case usagetotal.FieldOrganizationID:
  25286. return m.OldOrganizationID(ctx)
  25287. }
  25288. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  25289. }
  25290. // SetField sets the value of a field with the given name. It returns an error if
  25291. // the field is not defined in the schema, or if the type mismatched the field
  25292. // type.
  25293. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  25294. switch name {
  25295. case usagetotal.FieldCreatedAt:
  25296. v, ok := value.(time.Time)
  25297. if !ok {
  25298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25299. }
  25300. m.SetCreatedAt(v)
  25301. return nil
  25302. case usagetotal.FieldUpdatedAt:
  25303. v, ok := value.(time.Time)
  25304. if !ok {
  25305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25306. }
  25307. m.SetUpdatedAt(v)
  25308. return nil
  25309. case usagetotal.FieldStatus:
  25310. v, ok := value.(uint8)
  25311. if !ok {
  25312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25313. }
  25314. m.SetStatus(v)
  25315. return nil
  25316. case usagetotal.FieldType:
  25317. v, ok := value.(int)
  25318. if !ok {
  25319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25320. }
  25321. m.SetType(v)
  25322. return nil
  25323. case usagetotal.FieldBotID:
  25324. v, ok := value.(string)
  25325. if !ok {
  25326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25327. }
  25328. m.SetBotID(v)
  25329. return nil
  25330. case usagetotal.FieldTotalTokens:
  25331. v, ok := value.(uint64)
  25332. if !ok {
  25333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25334. }
  25335. m.SetTotalTokens(v)
  25336. return nil
  25337. case usagetotal.FieldStartIndex:
  25338. v, ok := value.(uint64)
  25339. if !ok {
  25340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25341. }
  25342. m.SetStartIndex(v)
  25343. return nil
  25344. case usagetotal.FieldEndIndex:
  25345. v, ok := value.(uint64)
  25346. if !ok {
  25347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25348. }
  25349. m.SetEndIndex(v)
  25350. return nil
  25351. case usagetotal.FieldOrganizationID:
  25352. v, ok := value.(uint64)
  25353. if !ok {
  25354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25355. }
  25356. m.SetOrganizationID(v)
  25357. return nil
  25358. }
  25359. return fmt.Errorf("unknown UsageTotal field %s", name)
  25360. }
  25361. // AddedFields returns all numeric fields that were incremented/decremented during
  25362. // this mutation.
  25363. func (m *UsageTotalMutation) AddedFields() []string {
  25364. var fields []string
  25365. if m.addstatus != nil {
  25366. fields = append(fields, usagetotal.FieldStatus)
  25367. }
  25368. if m.add_type != nil {
  25369. fields = append(fields, usagetotal.FieldType)
  25370. }
  25371. if m.addtotal_tokens != nil {
  25372. fields = append(fields, usagetotal.FieldTotalTokens)
  25373. }
  25374. if m.addstart_index != nil {
  25375. fields = append(fields, usagetotal.FieldStartIndex)
  25376. }
  25377. if m.addend_index != nil {
  25378. fields = append(fields, usagetotal.FieldEndIndex)
  25379. }
  25380. if m.addorganization_id != nil {
  25381. fields = append(fields, usagetotal.FieldOrganizationID)
  25382. }
  25383. return fields
  25384. }
  25385. // AddedField returns the numeric value that was incremented/decremented on a field
  25386. // with the given name. The second boolean return value indicates that this field
  25387. // was not set, or was not defined in the schema.
  25388. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  25389. switch name {
  25390. case usagetotal.FieldStatus:
  25391. return m.AddedStatus()
  25392. case usagetotal.FieldType:
  25393. return m.AddedType()
  25394. case usagetotal.FieldTotalTokens:
  25395. return m.AddedTotalTokens()
  25396. case usagetotal.FieldStartIndex:
  25397. return m.AddedStartIndex()
  25398. case usagetotal.FieldEndIndex:
  25399. return m.AddedEndIndex()
  25400. case usagetotal.FieldOrganizationID:
  25401. return m.AddedOrganizationID()
  25402. }
  25403. return nil, false
  25404. }
  25405. // AddField adds the value to the field with the given name. It returns an error if
  25406. // the field is not defined in the schema, or if the type mismatched the field
  25407. // type.
  25408. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  25409. switch name {
  25410. case usagetotal.FieldStatus:
  25411. v, ok := value.(int8)
  25412. if !ok {
  25413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25414. }
  25415. m.AddStatus(v)
  25416. return nil
  25417. case usagetotal.FieldType:
  25418. v, ok := value.(int)
  25419. if !ok {
  25420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25421. }
  25422. m.AddType(v)
  25423. return nil
  25424. case usagetotal.FieldTotalTokens:
  25425. v, ok := value.(int64)
  25426. if !ok {
  25427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25428. }
  25429. m.AddTotalTokens(v)
  25430. return nil
  25431. case usagetotal.FieldStartIndex:
  25432. v, ok := value.(int64)
  25433. if !ok {
  25434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25435. }
  25436. m.AddStartIndex(v)
  25437. return nil
  25438. case usagetotal.FieldEndIndex:
  25439. v, ok := value.(int64)
  25440. if !ok {
  25441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25442. }
  25443. m.AddEndIndex(v)
  25444. return nil
  25445. case usagetotal.FieldOrganizationID:
  25446. v, ok := value.(int64)
  25447. if !ok {
  25448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25449. }
  25450. m.AddOrganizationID(v)
  25451. return nil
  25452. }
  25453. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  25454. }
  25455. // ClearedFields returns all nullable fields that were cleared during this
  25456. // mutation.
  25457. func (m *UsageTotalMutation) ClearedFields() []string {
  25458. var fields []string
  25459. if m.FieldCleared(usagetotal.FieldStatus) {
  25460. fields = append(fields, usagetotal.FieldStatus)
  25461. }
  25462. if m.FieldCleared(usagetotal.FieldType) {
  25463. fields = append(fields, usagetotal.FieldType)
  25464. }
  25465. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  25466. fields = append(fields, usagetotal.FieldTotalTokens)
  25467. }
  25468. if m.FieldCleared(usagetotal.FieldStartIndex) {
  25469. fields = append(fields, usagetotal.FieldStartIndex)
  25470. }
  25471. if m.FieldCleared(usagetotal.FieldEndIndex) {
  25472. fields = append(fields, usagetotal.FieldEndIndex)
  25473. }
  25474. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  25475. fields = append(fields, usagetotal.FieldOrganizationID)
  25476. }
  25477. return fields
  25478. }
  25479. // FieldCleared returns a boolean indicating if a field with the given name was
  25480. // cleared in this mutation.
  25481. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  25482. _, ok := m.clearedFields[name]
  25483. return ok
  25484. }
  25485. // ClearField clears the value of the field with the given name. It returns an
  25486. // error if the field is not defined in the schema.
  25487. func (m *UsageTotalMutation) ClearField(name string) error {
  25488. switch name {
  25489. case usagetotal.FieldStatus:
  25490. m.ClearStatus()
  25491. return nil
  25492. case usagetotal.FieldType:
  25493. m.ClearType()
  25494. return nil
  25495. case usagetotal.FieldTotalTokens:
  25496. m.ClearTotalTokens()
  25497. return nil
  25498. case usagetotal.FieldStartIndex:
  25499. m.ClearStartIndex()
  25500. return nil
  25501. case usagetotal.FieldEndIndex:
  25502. m.ClearEndIndex()
  25503. return nil
  25504. case usagetotal.FieldOrganizationID:
  25505. m.ClearOrganizationID()
  25506. return nil
  25507. }
  25508. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  25509. }
  25510. // ResetField resets all changes in the mutation for the field with the given name.
  25511. // It returns an error if the field is not defined in the schema.
  25512. func (m *UsageTotalMutation) ResetField(name string) error {
  25513. switch name {
  25514. case usagetotal.FieldCreatedAt:
  25515. m.ResetCreatedAt()
  25516. return nil
  25517. case usagetotal.FieldUpdatedAt:
  25518. m.ResetUpdatedAt()
  25519. return nil
  25520. case usagetotal.FieldStatus:
  25521. m.ResetStatus()
  25522. return nil
  25523. case usagetotal.FieldType:
  25524. m.ResetType()
  25525. return nil
  25526. case usagetotal.FieldBotID:
  25527. m.ResetBotID()
  25528. return nil
  25529. case usagetotal.FieldTotalTokens:
  25530. m.ResetTotalTokens()
  25531. return nil
  25532. case usagetotal.FieldStartIndex:
  25533. m.ResetStartIndex()
  25534. return nil
  25535. case usagetotal.FieldEndIndex:
  25536. m.ResetEndIndex()
  25537. return nil
  25538. case usagetotal.FieldOrganizationID:
  25539. m.ResetOrganizationID()
  25540. return nil
  25541. }
  25542. return fmt.Errorf("unknown UsageTotal field %s", name)
  25543. }
  25544. // AddedEdges returns all edge names that were set/added in this mutation.
  25545. func (m *UsageTotalMutation) AddedEdges() []string {
  25546. edges := make([]string, 0, 0)
  25547. return edges
  25548. }
  25549. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25550. // name in this mutation.
  25551. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  25552. return nil
  25553. }
  25554. // RemovedEdges returns all edge names that were removed in this mutation.
  25555. func (m *UsageTotalMutation) RemovedEdges() []string {
  25556. edges := make([]string, 0, 0)
  25557. return edges
  25558. }
  25559. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25560. // the given name in this mutation.
  25561. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  25562. return nil
  25563. }
  25564. // ClearedEdges returns all edge names that were cleared in this mutation.
  25565. func (m *UsageTotalMutation) ClearedEdges() []string {
  25566. edges := make([]string, 0, 0)
  25567. return edges
  25568. }
  25569. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25570. // was cleared in this mutation.
  25571. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  25572. return false
  25573. }
  25574. // ClearEdge clears the value of the edge with the given name. It returns an error
  25575. // if that edge is not defined in the schema.
  25576. func (m *UsageTotalMutation) ClearEdge(name string) error {
  25577. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  25578. }
  25579. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25580. // It returns an error if the edge is not defined in the schema.
  25581. func (m *UsageTotalMutation) ResetEdge(name string) error {
  25582. return fmt.Errorf("unknown UsageTotal edge %s", name)
  25583. }
  25584. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  25585. type WorkExperienceMutation struct {
  25586. config
  25587. op Op
  25588. typ string
  25589. id *uint64
  25590. created_at *time.Time
  25591. updated_at *time.Time
  25592. deleted_at *time.Time
  25593. start_date *time.Time
  25594. end_date *time.Time
  25595. company *string
  25596. experience *string
  25597. organization_id *uint64
  25598. addorganization_id *int64
  25599. clearedFields map[string]struct{}
  25600. employee *uint64
  25601. clearedemployee bool
  25602. done bool
  25603. oldValue func(context.Context) (*WorkExperience, error)
  25604. predicates []predicate.WorkExperience
  25605. }
  25606. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  25607. // workexperienceOption allows management of the mutation configuration using functional options.
  25608. type workexperienceOption func(*WorkExperienceMutation)
  25609. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  25610. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  25611. m := &WorkExperienceMutation{
  25612. config: c,
  25613. op: op,
  25614. typ: TypeWorkExperience,
  25615. clearedFields: make(map[string]struct{}),
  25616. }
  25617. for _, opt := range opts {
  25618. opt(m)
  25619. }
  25620. return m
  25621. }
  25622. // withWorkExperienceID sets the ID field of the mutation.
  25623. func withWorkExperienceID(id uint64) workexperienceOption {
  25624. return func(m *WorkExperienceMutation) {
  25625. var (
  25626. err error
  25627. once sync.Once
  25628. value *WorkExperience
  25629. )
  25630. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  25631. once.Do(func() {
  25632. if m.done {
  25633. err = errors.New("querying old values post mutation is not allowed")
  25634. } else {
  25635. value, err = m.Client().WorkExperience.Get(ctx, id)
  25636. }
  25637. })
  25638. return value, err
  25639. }
  25640. m.id = &id
  25641. }
  25642. }
  25643. // withWorkExperience sets the old WorkExperience of the mutation.
  25644. func withWorkExperience(node *WorkExperience) workexperienceOption {
  25645. return func(m *WorkExperienceMutation) {
  25646. m.oldValue = func(context.Context) (*WorkExperience, error) {
  25647. return node, nil
  25648. }
  25649. m.id = &node.ID
  25650. }
  25651. }
  25652. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25653. // executed in a transaction (ent.Tx), a transactional client is returned.
  25654. func (m WorkExperienceMutation) Client() *Client {
  25655. client := &Client{config: m.config}
  25656. client.init()
  25657. return client
  25658. }
  25659. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25660. // it returns an error otherwise.
  25661. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  25662. if _, ok := m.driver.(*txDriver); !ok {
  25663. return nil, errors.New("ent: mutation is not running in a transaction")
  25664. }
  25665. tx := &Tx{config: m.config}
  25666. tx.init()
  25667. return tx, nil
  25668. }
  25669. // SetID sets the value of the id field. Note that this
  25670. // operation is only accepted on creation of WorkExperience entities.
  25671. func (m *WorkExperienceMutation) SetID(id uint64) {
  25672. m.id = &id
  25673. }
  25674. // ID returns the ID value in the mutation. Note that the ID is only available
  25675. // if it was provided to the builder or after it was returned from the database.
  25676. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  25677. if m.id == nil {
  25678. return
  25679. }
  25680. return *m.id, true
  25681. }
  25682. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25683. // That means, if the mutation is applied within a transaction with an isolation level such
  25684. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25685. // or updated by the mutation.
  25686. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  25687. switch {
  25688. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25689. id, exists := m.ID()
  25690. if exists {
  25691. return []uint64{id}, nil
  25692. }
  25693. fallthrough
  25694. case m.op.Is(OpUpdate | OpDelete):
  25695. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  25696. default:
  25697. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25698. }
  25699. }
  25700. // SetCreatedAt sets the "created_at" field.
  25701. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  25702. m.created_at = &t
  25703. }
  25704. // CreatedAt returns the value of the "created_at" field in the mutation.
  25705. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  25706. v := m.created_at
  25707. if v == nil {
  25708. return
  25709. }
  25710. return *v, true
  25711. }
  25712. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  25713. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25715. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25716. if !m.op.Is(OpUpdateOne) {
  25717. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25718. }
  25719. if m.id == nil || m.oldValue == nil {
  25720. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25721. }
  25722. oldValue, err := m.oldValue(ctx)
  25723. if err != nil {
  25724. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25725. }
  25726. return oldValue.CreatedAt, nil
  25727. }
  25728. // ResetCreatedAt resets all changes to the "created_at" field.
  25729. func (m *WorkExperienceMutation) ResetCreatedAt() {
  25730. m.created_at = nil
  25731. }
  25732. // SetUpdatedAt sets the "updated_at" field.
  25733. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  25734. m.updated_at = &t
  25735. }
  25736. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25737. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  25738. v := m.updated_at
  25739. if v == nil {
  25740. return
  25741. }
  25742. return *v, true
  25743. }
  25744. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  25745. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25747. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25748. if !m.op.Is(OpUpdateOne) {
  25749. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25750. }
  25751. if m.id == nil || m.oldValue == nil {
  25752. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25753. }
  25754. oldValue, err := m.oldValue(ctx)
  25755. if err != nil {
  25756. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25757. }
  25758. return oldValue.UpdatedAt, nil
  25759. }
  25760. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25761. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  25762. m.updated_at = nil
  25763. }
  25764. // SetDeletedAt sets the "deleted_at" field.
  25765. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  25766. m.deleted_at = &t
  25767. }
  25768. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25769. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  25770. v := m.deleted_at
  25771. if v == nil {
  25772. return
  25773. }
  25774. return *v, true
  25775. }
  25776. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  25777. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25779. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25780. if !m.op.Is(OpUpdateOne) {
  25781. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25782. }
  25783. if m.id == nil || m.oldValue == nil {
  25784. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25785. }
  25786. oldValue, err := m.oldValue(ctx)
  25787. if err != nil {
  25788. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25789. }
  25790. return oldValue.DeletedAt, nil
  25791. }
  25792. // ClearDeletedAt clears the value of the "deleted_at" field.
  25793. func (m *WorkExperienceMutation) ClearDeletedAt() {
  25794. m.deleted_at = nil
  25795. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  25796. }
  25797. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25798. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  25799. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  25800. return ok
  25801. }
  25802. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25803. func (m *WorkExperienceMutation) ResetDeletedAt() {
  25804. m.deleted_at = nil
  25805. delete(m.clearedFields, workexperience.FieldDeletedAt)
  25806. }
  25807. // SetEmployeeID sets the "employee_id" field.
  25808. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  25809. m.employee = &u
  25810. }
  25811. // EmployeeID returns the value of the "employee_id" field in the mutation.
  25812. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  25813. v := m.employee
  25814. if v == nil {
  25815. return
  25816. }
  25817. return *v, true
  25818. }
  25819. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  25820. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25822. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  25823. if !m.op.Is(OpUpdateOne) {
  25824. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  25825. }
  25826. if m.id == nil || m.oldValue == nil {
  25827. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  25828. }
  25829. oldValue, err := m.oldValue(ctx)
  25830. if err != nil {
  25831. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  25832. }
  25833. return oldValue.EmployeeID, nil
  25834. }
  25835. // ResetEmployeeID resets all changes to the "employee_id" field.
  25836. func (m *WorkExperienceMutation) ResetEmployeeID() {
  25837. m.employee = nil
  25838. }
  25839. // SetStartDate sets the "start_date" field.
  25840. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  25841. m.start_date = &t
  25842. }
  25843. // StartDate returns the value of the "start_date" field in the mutation.
  25844. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  25845. v := m.start_date
  25846. if v == nil {
  25847. return
  25848. }
  25849. return *v, true
  25850. }
  25851. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  25852. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25854. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  25855. if !m.op.Is(OpUpdateOne) {
  25856. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  25857. }
  25858. if m.id == nil || m.oldValue == nil {
  25859. return v, errors.New("OldStartDate requires an ID field in the mutation")
  25860. }
  25861. oldValue, err := m.oldValue(ctx)
  25862. if err != nil {
  25863. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  25864. }
  25865. return oldValue.StartDate, nil
  25866. }
  25867. // ResetStartDate resets all changes to the "start_date" field.
  25868. func (m *WorkExperienceMutation) ResetStartDate() {
  25869. m.start_date = nil
  25870. }
  25871. // SetEndDate sets the "end_date" field.
  25872. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  25873. m.end_date = &t
  25874. }
  25875. // EndDate returns the value of the "end_date" field in the mutation.
  25876. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  25877. v := m.end_date
  25878. if v == nil {
  25879. return
  25880. }
  25881. return *v, true
  25882. }
  25883. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  25884. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25886. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  25887. if !m.op.Is(OpUpdateOne) {
  25888. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  25889. }
  25890. if m.id == nil || m.oldValue == nil {
  25891. return v, errors.New("OldEndDate requires an ID field in the mutation")
  25892. }
  25893. oldValue, err := m.oldValue(ctx)
  25894. if err != nil {
  25895. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  25896. }
  25897. return oldValue.EndDate, nil
  25898. }
  25899. // ResetEndDate resets all changes to the "end_date" field.
  25900. func (m *WorkExperienceMutation) ResetEndDate() {
  25901. m.end_date = nil
  25902. }
  25903. // SetCompany sets the "company" field.
  25904. func (m *WorkExperienceMutation) SetCompany(s string) {
  25905. m.company = &s
  25906. }
  25907. // Company returns the value of the "company" field in the mutation.
  25908. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  25909. v := m.company
  25910. if v == nil {
  25911. return
  25912. }
  25913. return *v, true
  25914. }
  25915. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  25916. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25918. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  25919. if !m.op.Is(OpUpdateOne) {
  25920. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  25921. }
  25922. if m.id == nil || m.oldValue == nil {
  25923. return v, errors.New("OldCompany requires an ID field in the mutation")
  25924. }
  25925. oldValue, err := m.oldValue(ctx)
  25926. if err != nil {
  25927. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  25928. }
  25929. return oldValue.Company, nil
  25930. }
  25931. // ResetCompany resets all changes to the "company" field.
  25932. func (m *WorkExperienceMutation) ResetCompany() {
  25933. m.company = nil
  25934. }
  25935. // SetExperience sets the "experience" field.
  25936. func (m *WorkExperienceMutation) SetExperience(s string) {
  25937. m.experience = &s
  25938. }
  25939. // Experience returns the value of the "experience" field in the mutation.
  25940. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  25941. v := m.experience
  25942. if v == nil {
  25943. return
  25944. }
  25945. return *v, true
  25946. }
  25947. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  25948. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25950. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  25951. if !m.op.Is(OpUpdateOne) {
  25952. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  25953. }
  25954. if m.id == nil || m.oldValue == nil {
  25955. return v, errors.New("OldExperience requires an ID field in the mutation")
  25956. }
  25957. oldValue, err := m.oldValue(ctx)
  25958. if err != nil {
  25959. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  25960. }
  25961. return oldValue.Experience, nil
  25962. }
  25963. // ResetExperience resets all changes to the "experience" field.
  25964. func (m *WorkExperienceMutation) ResetExperience() {
  25965. m.experience = nil
  25966. }
  25967. // SetOrganizationID sets the "organization_id" field.
  25968. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  25969. m.organization_id = &u
  25970. m.addorganization_id = nil
  25971. }
  25972. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25973. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  25974. v := m.organization_id
  25975. if v == nil {
  25976. return
  25977. }
  25978. return *v, true
  25979. }
  25980. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  25981. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25983. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25984. if !m.op.Is(OpUpdateOne) {
  25985. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25986. }
  25987. if m.id == nil || m.oldValue == nil {
  25988. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25989. }
  25990. oldValue, err := m.oldValue(ctx)
  25991. if err != nil {
  25992. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25993. }
  25994. return oldValue.OrganizationID, nil
  25995. }
  25996. // AddOrganizationID adds u to the "organization_id" field.
  25997. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  25998. if m.addorganization_id != nil {
  25999. *m.addorganization_id += u
  26000. } else {
  26001. m.addorganization_id = &u
  26002. }
  26003. }
  26004. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26005. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  26006. v := m.addorganization_id
  26007. if v == nil {
  26008. return
  26009. }
  26010. return *v, true
  26011. }
  26012. // ResetOrganizationID resets all changes to the "organization_id" field.
  26013. func (m *WorkExperienceMutation) ResetOrganizationID() {
  26014. m.organization_id = nil
  26015. m.addorganization_id = nil
  26016. }
  26017. // ClearEmployee clears the "employee" edge to the Employee entity.
  26018. func (m *WorkExperienceMutation) ClearEmployee() {
  26019. m.clearedemployee = true
  26020. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  26021. }
  26022. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  26023. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  26024. return m.clearedemployee
  26025. }
  26026. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  26027. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26028. // EmployeeID instead. It exists only for internal usage by the builders.
  26029. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  26030. if id := m.employee; id != nil {
  26031. ids = append(ids, *id)
  26032. }
  26033. return
  26034. }
  26035. // ResetEmployee resets all changes to the "employee" edge.
  26036. func (m *WorkExperienceMutation) ResetEmployee() {
  26037. m.employee = nil
  26038. m.clearedemployee = false
  26039. }
  26040. // Where appends a list predicates to the WorkExperienceMutation builder.
  26041. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  26042. m.predicates = append(m.predicates, ps...)
  26043. }
  26044. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  26045. // users can use type-assertion to append predicates that do not depend on any generated package.
  26046. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  26047. p := make([]predicate.WorkExperience, len(ps))
  26048. for i := range ps {
  26049. p[i] = ps[i]
  26050. }
  26051. m.Where(p...)
  26052. }
  26053. // Op returns the operation name.
  26054. func (m *WorkExperienceMutation) Op() Op {
  26055. return m.op
  26056. }
  26057. // SetOp allows setting the mutation operation.
  26058. func (m *WorkExperienceMutation) SetOp(op Op) {
  26059. m.op = op
  26060. }
  26061. // Type returns the node type of this mutation (WorkExperience).
  26062. func (m *WorkExperienceMutation) Type() string {
  26063. return m.typ
  26064. }
  26065. // Fields returns all fields that were changed during this mutation. Note that in
  26066. // order to get all numeric fields that were incremented/decremented, call
  26067. // AddedFields().
  26068. func (m *WorkExperienceMutation) Fields() []string {
  26069. fields := make([]string, 0, 9)
  26070. if m.created_at != nil {
  26071. fields = append(fields, workexperience.FieldCreatedAt)
  26072. }
  26073. if m.updated_at != nil {
  26074. fields = append(fields, workexperience.FieldUpdatedAt)
  26075. }
  26076. if m.deleted_at != nil {
  26077. fields = append(fields, workexperience.FieldDeletedAt)
  26078. }
  26079. if m.employee != nil {
  26080. fields = append(fields, workexperience.FieldEmployeeID)
  26081. }
  26082. if m.start_date != nil {
  26083. fields = append(fields, workexperience.FieldStartDate)
  26084. }
  26085. if m.end_date != nil {
  26086. fields = append(fields, workexperience.FieldEndDate)
  26087. }
  26088. if m.company != nil {
  26089. fields = append(fields, workexperience.FieldCompany)
  26090. }
  26091. if m.experience != nil {
  26092. fields = append(fields, workexperience.FieldExperience)
  26093. }
  26094. if m.organization_id != nil {
  26095. fields = append(fields, workexperience.FieldOrganizationID)
  26096. }
  26097. return fields
  26098. }
  26099. // Field returns the value of a field with the given name. The second boolean
  26100. // return value indicates that this field was not set, or was not defined in the
  26101. // schema.
  26102. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  26103. switch name {
  26104. case workexperience.FieldCreatedAt:
  26105. return m.CreatedAt()
  26106. case workexperience.FieldUpdatedAt:
  26107. return m.UpdatedAt()
  26108. case workexperience.FieldDeletedAt:
  26109. return m.DeletedAt()
  26110. case workexperience.FieldEmployeeID:
  26111. return m.EmployeeID()
  26112. case workexperience.FieldStartDate:
  26113. return m.StartDate()
  26114. case workexperience.FieldEndDate:
  26115. return m.EndDate()
  26116. case workexperience.FieldCompany:
  26117. return m.Company()
  26118. case workexperience.FieldExperience:
  26119. return m.Experience()
  26120. case workexperience.FieldOrganizationID:
  26121. return m.OrganizationID()
  26122. }
  26123. return nil, false
  26124. }
  26125. // OldField returns the old value of the field from the database. An error is
  26126. // returned if the mutation operation is not UpdateOne, or the query to the
  26127. // database failed.
  26128. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26129. switch name {
  26130. case workexperience.FieldCreatedAt:
  26131. return m.OldCreatedAt(ctx)
  26132. case workexperience.FieldUpdatedAt:
  26133. return m.OldUpdatedAt(ctx)
  26134. case workexperience.FieldDeletedAt:
  26135. return m.OldDeletedAt(ctx)
  26136. case workexperience.FieldEmployeeID:
  26137. return m.OldEmployeeID(ctx)
  26138. case workexperience.FieldStartDate:
  26139. return m.OldStartDate(ctx)
  26140. case workexperience.FieldEndDate:
  26141. return m.OldEndDate(ctx)
  26142. case workexperience.FieldCompany:
  26143. return m.OldCompany(ctx)
  26144. case workexperience.FieldExperience:
  26145. return m.OldExperience(ctx)
  26146. case workexperience.FieldOrganizationID:
  26147. return m.OldOrganizationID(ctx)
  26148. }
  26149. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  26150. }
  26151. // SetField sets the value of a field with the given name. It returns an error if
  26152. // the field is not defined in the schema, or if the type mismatched the field
  26153. // type.
  26154. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  26155. switch name {
  26156. case workexperience.FieldCreatedAt:
  26157. v, ok := value.(time.Time)
  26158. if !ok {
  26159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26160. }
  26161. m.SetCreatedAt(v)
  26162. return nil
  26163. case workexperience.FieldUpdatedAt:
  26164. v, ok := value.(time.Time)
  26165. if !ok {
  26166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26167. }
  26168. m.SetUpdatedAt(v)
  26169. return nil
  26170. case workexperience.FieldDeletedAt:
  26171. v, ok := value.(time.Time)
  26172. if !ok {
  26173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26174. }
  26175. m.SetDeletedAt(v)
  26176. return nil
  26177. case workexperience.FieldEmployeeID:
  26178. v, ok := value.(uint64)
  26179. if !ok {
  26180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26181. }
  26182. m.SetEmployeeID(v)
  26183. return nil
  26184. case workexperience.FieldStartDate:
  26185. v, ok := value.(time.Time)
  26186. if !ok {
  26187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26188. }
  26189. m.SetStartDate(v)
  26190. return nil
  26191. case workexperience.FieldEndDate:
  26192. v, ok := value.(time.Time)
  26193. if !ok {
  26194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26195. }
  26196. m.SetEndDate(v)
  26197. return nil
  26198. case workexperience.FieldCompany:
  26199. v, ok := value.(string)
  26200. if !ok {
  26201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26202. }
  26203. m.SetCompany(v)
  26204. return nil
  26205. case workexperience.FieldExperience:
  26206. v, ok := value.(string)
  26207. if !ok {
  26208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26209. }
  26210. m.SetExperience(v)
  26211. return nil
  26212. case workexperience.FieldOrganizationID:
  26213. v, ok := value.(uint64)
  26214. if !ok {
  26215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26216. }
  26217. m.SetOrganizationID(v)
  26218. return nil
  26219. }
  26220. return fmt.Errorf("unknown WorkExperience field %s", name)
  26221. }
  26222. // AddedFields returns all numeric fields that were incremented/decremented during
  26223. // this mutation.
  26224. func (m *WorkExperienceMutation) AddedFields() []string {
  26225. var fields []string
  26226. if m.addorganization_id != nil {
  26227. fields = append(fields, workexperience.FieldOrganizationID)
  26228. }
  26229. return fields
  26230. }
  26231. // AddedField returns the numeric value that was incremented/decremented on a field
  26232. // with the given name. The second boolean return value indicates that this field
  26233. // was not set, or was not defined in the schema.
  26234. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  26235. switch name {
  26236. case workexperience.FieldOrganizationID:
  26237. return m.AddedOrganizationID()
  26238. }
  26239. return nil, false
  26240. }
  26241. // AddField adds the value to the field with the given name. It returns an error if
  26242. // the field is not defined in the schema, or if the type mismatched the field
  26243. // type.
  26244. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  26245. switch name {
  26246. case workexperience.FieldOrganizationID:
  26247. v, ok := value.(int64)
  26248. if !ok {
  26249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26250. }
  26251. m.AddOrganizationID(v)
  26252. return nil
  26253. }
  26254. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  26255. }
  26256. // ClearedFields returns all nullable fields that were cleared during this
  26257. // mutation.
  26258. func (m *WorkExperienceMutation) ClearedFields() []string {
  26259. var fields []string
  26260. if m.FieldCleared(workexperience.FieldDeletedAt) {
  26261. fields = append(fields, workexperience.FieldDeletedAt)
  26262. }
  26263. return fields
  26264. }
  26265. // FieldCleared returns a boolean indicating if a field with the given name was
  26266. // cleared in this mutation.
  26267. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  26268. _, ok := m.clearedFields[name]
  26269. return ok
  26270. }
  26271. // ClearField clears the value of the field with the given name. It returns an
  26272. // error if the field is not defined in the schema.
  26273. func (m *WorkExperienceMutation) ClearField(name string) error {
  26274. switch name {
  26275. case workexperience.FieldDeletedAt:
  26276. m.ClearDeletedAt()
  26277. return nil
  26278. }
  26279. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  26280. }
  26281. // ResetField resets all changes in the mutation for the field with the given name.
  26282. // It returns an error if the field is not defined in the schema.
  26283. func (m *WorkExperienceMutation) ResetField(name string) error {
  26284. switch name {
  26285. case workexperience.FieldCreatedAt:
  26286. m.ResetCreatedAt()
  26287. return nil
  26288. case workexperience.FieldUpdatedAt:
  26289. m.ResetUpdatedAt()
  26290. return nil
  26291. case workexperience.FieldDeletedAt:
  26292. m.ResetDeletedAt()
  26293. return nil
  26294. case workexperience.FieldEmployeeID:
  26295. m.ResetEmployeeID()
  26296. return nil
  26297. case workexperience.FieldStartDate:
  26298. m.ResetStartDate()
  26299. return nil
  26300. case workexperience.FieldEndDate:
  26301. m.ResetEndDate()
  26302. return nil
  26303. case workexperience.FieldCompany:
  26304. m.ResetCompany()
  26305. return nil
  26306. case workexperience.FieldExperience:
  26307. m.ResetExperience()
  26308. return nil
  26309. case workexperience.FieldOrganizationID:
  26310. m.ResetOrganizationID()
  26311. return nil
  26312. }
  26313. return fmt.Errorf("unknown WorkExperience field %s", name)
  26314. }
  26315. // AddedEdges returns all edge names that were set/added in this mutation.
  26316. func (m *WorkExperienceMutation) AddedEdges() []string {
  26317. edges := make([]string, 0, 1)
  26318. if m.employee != nil {
  26319. edges = append(edges, workexperience.EdgeEmployee)
  26320. }
  26321. return edges
  26322. }
  26323. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26324. // name in this mutation.
  26325. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  26326. switch name {
  26327. case workexperience.EdgeEmployee:
  26328. if id := m.employee; id != nil {
  26329. return []ent.Value{*id}
  26330. }
  26331. }
  26332. return nil
  26333. }
  26334. // RemovedEdges returns all edge names that were removed in this mutation.
  26335. func (m *WorkExperienceMutation) RemovedEdges() []string {
  26336. edges := make([]string, 0, 1)
  26337. return edges
  26338. }
  26339. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26340. // the given name in this mutation.
  26341. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  26342. return nil
  26343. }
  26344. // ClearedEdges returns all edge names that were cleared in this mutation.
  26345. func (m *WorkExperienceMutation) ClearedEdges() []string {
  26346. edges := make([]string, 0, 1)
  26347. if m.clearedemployee {
  26348. edges = append(edges, workexperience.EdgeEmployee)
  26349. }
  26350. return edges
  26351. }
  26352. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26353. // was cleared in this mutation.
  26354. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  26355. switch name {
  26356. case workexperience.EdgeEmployee:
  26357. return m.clearedemployee
  26358. }
  26359. return false
  26360. }
  26361. // ClearEdge clears the value of the edge with the given name. It returns an error
  26362. // if that edge is not defined in the schema.
  26363. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  26364. switch name {
  26365. case workexperience.EdgeEmployee:
  26366. m.ClearEmployee()
  26367. return nil
  26368. }
  26369. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  26370. }
  26371. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26372. // It returns an error if the edge is not defined in the schema.
  26373. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  26374. switch name {
  26375. case workexperience.EdgeEmployee:
  26376. m.ResetEmployee()
  26377. return nil
  26378. }
  26379. return fmt.Errorf("unknown WorkExperience edge %s", name)
  26380. }
  26381. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  26382. type WpChatroomMutation struct {
  26383. config
  26384. op Op
  26385. typ string
  26386. id *uint64
  26387. created_at *time.Time
  26388. updated_at *time.Time
  26389. status *uint8
  26390. addstatus *int8
  26391. wx_wxid *string
  26392. chatroom_id *string
  26393. nickname *string
  26394. owner *string
  26395. avatar *string
  26396. member_list *[]string
  26397. appendmember_list []string
  26398. clearedFields map[string]struct{}
  26399. done bool
  26400. oldValue func(context.Context) (*WpChatroom, error)
  26401. predicates []predicate.WpChatroom
  26402. }
  26403. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  26404. // wpchatroomOption allows management of the mutation configuration using functional options.
  26405. type wpchatroomOption func(*WpChatroomMutation)
  26406. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  26407. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  26408. m := &WpChatroomMutation{
  26409. config: c,
  26410. op: op,
  26411. typ: TypeWpChatroom,
  26412. clearedFields: make(map[string]struct{}),
  26413. }
  26414. for _, opt := range opts {
  26415. opt(m)
  26416. }
  26417. return m
  26418. }
  26419. // withWpChatroomID sets the ID field of the mutation.
  26420. func withWpChatroomID(id uint64) wpchatroomOption {
  26421. return func(m *WpChatroomMutation) {
  26422. var (
  26423. err error
  26424. once sync.Once
  26425. value *WpChatroom
  26426. )
  26427. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  26428. once.Do(func() {
  26429. if m.done {
  26430. err = errors.New("querying old values post mutation is not allowed")
  26431. } else {
  26432. value, err = m.Client().WpChatroom.Get(ctx, id)
  26433. }
  26434. })
  26435. return value, err
  26436. }
  26437. m.id = &id
  26438. }
  26439. }
  26440. // withWpChatroom sets the old WpChatroom of the mutation.
  26441. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  26442. return func(m *WpChatroomMutation) {
  26443. m.oldValue = func(context.Context) (*WpChatroom, error) {
  26444. return node, nil
  26445. }
  26446. m.id = &node.ID
  26447. }
  26448. }
  26449. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26450. // executed in a transaction (ent.Tx), a transactional client is returned.
  26451. func (m WpChatroomMutation) Client() *Client {
  26452. client := &Client{config: m.config}
  26453. client.init()
  26454. return client
  26455. }
  26456. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26457. // it returns an error otherwise.
  26458. func (m WpChatroomMutation) Tx() (*Tx, error) {
  26459. if _, ok := m.driver.(*txDriver); !ok {
  26460. return nil, errors.New("ent: mutation is not running in a transaction")
  26461. }
  26462. tx := &Tx{config: m.config}
  26463. tx.init()
  26464. return tx, nil
  26465. }
  26466. // SetID sets the value of the id field. Note that this
  26467. // operation is only accepted on creation of WpChatroom entities.
  26468. func (m *WpChatroomMutation) SetID(id uint64) {
  26469. m.id = &id
  26470. }
  26471. // ID returns the ID value in the mutation. Note that the ID is only available
  26472. // if it was provided to the builder or after it was returned from the database.
  26473. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  26474. if m.id == nil {
  26475. return
  26476. }
  26477. return *m.id, true
  26478. }
  26479. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26480. // That means, if the mutation is applied within a transaction with an isolation level such
  26481. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26482. // or updated by the mutation.
  26483. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  26484. switch {
  26485. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26486. id, exists := m.ID()
  26487. if exists {
  26488. return []uint64{id}, nil
  26489. }
  26490. fallthrough
  26491. case m.op.Is(OpUpdate | OpDelete):
  26492. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  26493. default:
  26494. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26495. }
  26496. }
  26497. // SetCreatedAt sets the "created_at" field.
  26498. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  26499. m.created_at = &t
  26500. }
  26501. // CreatedAt returns the value of the "created_at" field in the mutation.
  26502. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  26503. v := m.created_at
  26504. if v == nil {
  26505. return
  26506. }
  26507. return *v, true
  26508. }
  26509. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  26510. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26512. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26513. if !m.op.Is(OpUpdateOne) {
  26514. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26515. }
  26516. if m.id == nil || m.oldValue == nil {
  26517. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26518. }
  26519. oldValue, err := m.oldValue(ctx)
  26520. if err != nil {
  26521. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26522. }
  26523. return oldValue.CreatedAt, nil
  26524. }
  26525. // ResetCreatedAt resets all changes to the "created_at" field.
  26526. func (m *WpChatroomMutation) ResetCreatedAt() {
  26527. m.created_at = nil
  26528. }
  26529. // SetUpdatedAt sets the "updated_at" field.
  26530. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  26531. m.updated_at = &t
  26532. }
  26533. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26534. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  26535. v := m.updated_at
  26536. if v == nil {
  26537. return
  26538. }
  26539. return *v, true
  26540. }
  26541. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  26542. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26544. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26545. if !m.op.Is(OpUpdateOne) {
  26546. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26547. }
  26548. if m.id == nil || m.oldValue == nil {
  26549. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26550. }
  26551. oldValue, err := m.oldValue(ctx)
  26552. if err != nil {
  26553. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26554. }
  26555. return oldValue.UpdatedAt, nil
  26556. }
  26557. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26558. func (m *WpChatroomMutation) ResetUpdatedAt() {
  26559. m.updated_at = nil
  26560. }
  26561. // SetStatus sets the "status" field.
  26562. func (m *WpChatroomMutation) SetStatus(u uint8) {
  26563. m.status = &u
  26564. m.addstatus = nil
  26565. }
  26566. // Status returns the value of the "status" field in the mutation.
  26567. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  26568. v := m.status
  26569. if v == nil {
  26570. return
  26571. }
  26572. return *v, true
  26573. }
  26574. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  26575. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26577. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26578. if !m.op.Is(OpUpdateOne) {
  26579. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26580. }
  26581. if m.id == nil || m.oldValue == nil {
  26582. return v, errors.New("OldStatus requires an ID field in the mutation")
  26583. }
  26584. oldValue, err := m.oldValue(ctx)
  26585. if err != nil {
  26586. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26587. }
  26588. return oldValue.Status, nil
  26589. }
  26590. // AddStatus adds u to the "status" field.
  26591. func (m *WpChatroomMutation) AddStatus(u int8) {
  26592. if m.addstatus != nil {
  26593. *m.addstatus += u
  26594. } else {
  26595. m.addstatus = &u
  26596. }
  26597. }
  26598. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26599. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  26600. v := m.addstatus
  26601. if v == nil {
  26602. return
  26603. }
  26604. return *v, true
  26605. }
  26606. // ClearStatus clears the value of the "status" field.
  26607. func (m *WpChatroomMutation) ClearStatus() {
  26608. m.status = nil
  26609. m.addstatus = nil
  26610. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  26611. }
  26612. // StatusCleared returns if the "status" field was cleared in this mutation.
  26613. func (m *WpChatroomMutation) StatusCleared() bool {
  26614. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  26615. return ok
  26616. }
  26617. // ResetStatus resets all changes to the "status" field.
  26618. func (m *WpChatroomMutation) ResetStatus() {
  26619. m.status = nil
  26620. m.addstatus = nil
  26621. delete(m.clearedFields, wpchatroom.FieldStatus)
  26622. }
  26623. // SetWxWxid sets the "wx_wxid" field.
  26624. func (m *WpChatroomMutation) SetWxWxid(s string) {
  26625. m.wx_wxid = &s
  26626. }
  26627. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  26628. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  26629. v := m.wx_wxid
  26630. if v == nil {
  26631. return
  26632. }
  26633. return *v, true
  26634. }
  26635. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  26636. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26638. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  26639. if !m.op.Is(OpUpdateOne) {
  26640. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  26641. }
  26642. if m.id == nil || m.oldValue == nil {
  26643. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  26644. }
  26645. oldValue, err := m.oldValue(ctx)
  26646. if err != nil {
  26647. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  26648. }
  26649. return oldValue.WxWxid, nil
  26650. }
  26651. // ResetWxWxid resets all changes to the "wx_wxid" field.
  26652. func (m *WpChatroomMutation) ResetWxWxid() {
  26653. m.wx_wxid = nil
  26654. }
  26655. // SetChatroomID sets the "chatroom_id" field.
  26656. func (m *WpChatroomMutation) SetChatroomID(s string) {
  26657. m.chatroom_id = &s
  26658. }
  26659. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  26660. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  26661. v := m.chatroom_id
  26662. if v == nil {
  26663. return
  26664. }
  26665. return *v, true
  26666. }
  26667. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  26668. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26670. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  26671. if !m.op.Is(OpUpdateOne) {
  26672. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  26673. }
  26674. if m.id == nil || m.oldValue == nil {
  26675. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  26676. }
  26677. oldValue, err := m.oldValue(ctx)
  26678. if err != nil {
  26679. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  26680. }
  26681. return oldValue.ChatroomID, nil
  26682. }
  26683. // ResetChatroomID resets all changes to the "chatroom_id" field.
  26684. func (m *WpChatroomMutation) ResetChatroomID() {
  26685. m.chatroom_id = nil
  26686. }
  26687. // SetNickname sets the "nickname" field.
  26688. func (m *WpChatroomMutation) SetNickname(s string) {
  26689. m.nickname = &s
  26690. }
  26691. // Nickname returns the value of the "nickname" field in the mutation.
  26692. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  26693. v := m.nickname
  26694. if v == nil {
  26695. return
  26696. }
  26697. return *v, true
  26698. }
  26699. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  26700. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26702. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  26703. if !m.op.Is(OpUpdateOne) {
  26704. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  26705. }
  26706. if m.id == nil || m.oldValue == nil {
  26707. return v, errors.New("OldNickname requires an ID field in the mutation")
  26708. }
  26709. oldValue, err := m.oldValue(ctx)
  26710. if err != nil {
  26711. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  26712. }
  26713. return oldValue.Nickname, nil
  26714. }
  26715. // ResetNickname resets all changes to the "nickname" field.
  26716. func (m *WpChatroomMutation) ResetNickname() {
  26717. m.nickname = nil
  26718. }
  26719. // SetOwner sets the "owner" field.
  26720. func (m *WpChatroomMutation) SetOwner(s string) {
  26721. m.owner = &s
  26722. }
  26723. // Owner returns the value of the "owner" field in the mutation.
  26724. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  26725. v := m.owner
  26726. if v == nil {
  26727. return
  26728. }
  26729. return *v, true
  26730. }
  26731. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  26732. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26734. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  26735. if !m.op.Is(OpUpdateOne) {
  26736. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  26737. }
  26738. if m.id == nil || m.oldValue == nil {
  26739. return v, errors.New("OldOwner requires an ID field in the mutation")
  26740. }
  26741. oldValue, err := m.oldValue(ctx)
  26742. if err != nil {
  26743. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  26744. }
  26745. return oldValue.Owner, nil
  26746. }
  26747. // ResetOwner resets all changes to the "owner" field.
  26748. func (m *WpChatroomMutation) ResetOwner() {
  26749. m.owner = nil
  26750. }
  26751. // SetAvatar sets the "avatar" field.
  26752. func (m *WpChatroomMutation) SetAvatar(s string) {
  26753. m.avatar = &s
  26754. }
  26755. // Avatar returns the value of the "avatar" field in the mutation.
  26756. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  26757. v := m.avatar
  26758. if v == nil {
  26759. return
  26760. }
  26761. return *v, true
  26762. }
  26763. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  26764. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26766. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  26767. if !m.op.Is(OpUpdateOne) {
  26768. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  26769. }
  26770. if m.id == nil || m.oldValue == nil {
  26771. return v, errors.New("OldAvatar requires an ID field in the mutation")
  26772. }
  26773. oldValue, err := m.oldValue(ctx)
  26774. if err != nil {
  26775. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  26776. }
  26777. return oldValue.Avatar, nil
  26778. }
  26779. // ResetAvatar resets all changes to the "avatar" field.
  26780. func (m *WpChatroomMutation) ResetAvatar() {
  26781. m.avatar = nil
  26782. }
  26783. // SetMemberList sets the "member_list" field.
  26784. func (m *WpChatroomMutation) SetMemberList(s []string) {
  26785. m.member_list = &s
  26786. m.appendmember_list = nil
  26787. }
  26788. // MemberList returns the value of the "member_list" field in the mutation.
  26789. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  26790. v := m.member_list
  26791. if v == nil {
  26792. return
  26793. }
  26794. return *v, true
  26795. }
  26796. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  26797. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26799. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  26800. if !m.op.Is(OpUpdateOne) {
  26801. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  26802. }
  26803. if m.id == nil || m.oldValue == nil {
  26804. return v, errors.New("OldMemberList requires an ID field in the mutation")
  26805. }
  26806. oldValue, err := m.oldValue(ctx)
  26807. if err != nil {
  26808. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  26809. }
  26810. return oldValue.MemberList, nil
  26811. }
  26812. // AppendMemberList adds s to the "member_list" field.
  26813. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  26814. m.appendmember_list = append(m.appendmember_list, s...)
  26815. }
  26816. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  26817. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  26818. if len(m.appendmember_list) == 0 {
  26819. return nil, false
  26820. }
  26821. return m.appendmember_list, true
  26822. }
  26823. // ResetMemberList resets all changes to the "member_list" field.
  26824. func (m *WpChatroomMutation) ResetMemberList() {
  26825. m.member_list = nil
  26826. m.appendmember_list = nil
  26827. }
  26828. // Where appends a list predicates to the WpChatroomMutation builder.
  26829. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  26830. m.predicates = append(m.predicates, ps...)
  26831. }
  26832. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  26833. // users can use type-assertion to append predicates that do not depend on any generated package.
  26834. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  26835. p := make([]predicate.WpChatroom, len(ps))
  26836. for i := range ps {
  26837. p[i] = ps[i]
  26838. }
  26839. m.Where(p...)
  26840. }
  26841. // Op returns the operation name.
  26842. func (m *WpChatroomMutation) Op() Op {
  26843. return m.op
  26844. }
  26845. // SetOp allows setting the mutation operation.
  26846. func (m *WpChatroomMutation) SetOp(op Op) {
  26847. m.op = op
  26848. }
  26849. // Type returns the node type of this mutation (WpChatroom).
  26850. func (m *WpChatroomMutation) Type() string {
  26851. return m.typ
  26852. }
  26853. // Fields returns all fields that were changed during this mutation. Note that in
  26854. // order to get all numeric fields that were incremented/decremented, call
  26855. // AddedFields().
  26856. func (m *WpChatroomMutation) Fields() []string {
  26857. fields := make([]string, 0, 9)
  26858. if m.created_at != nil {
  26859. fields = append(fields, wpchatroom.FieldCreatedAt)
  26860. }
  26861. if m.updated_at != nil {
  26862. fields = append(fields, wpchatroom.FieldUpdatedAt)
  26863. }
  26864. if m.status != nil {
  26865. fields = append(fields, wpchatroom.FieldStatus)
  26866. }
  26867. if m.wx_wxid != nil {
  26868. fields = append(fields, wpchatroom.FieldWxWxid)
  26869. }
  26870. if m.chatroom_id != nil {
  26871. fields = append(fields, wpchatroom.FieldChatroomID)
  26872. }
  26873. if m.nickname != nil {
  26874. fields = append(fields, wpchatroom.FieldNickname)
  26875. }
  26876. if m.owner != nil {
  26877. fields = append(fields, wpchatroom.FieldOwner)
  26878. }
  26879. if m.avatar != nil {
  26880. fields = append(fields, wpchatroom.FieldAvatar)
  26881. }
  26882. if m.member_list != nil {
  26883. fields = append(fields, wpchatroom.FieldMemberList)
  26884. }
  26885. return fields
  26886. }
  26887. // Field returns the value of a field with the given name. The second boolean
  26888. // return value indicates that this field was not set, or was not defined in the
  26889. // schema.
  26890. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  26891. switch name {
  26892. case wpchatroom.FieldCreatedAt:
  26893. return m.CreatedAt()
  26894. case wpchatroom.FieldUpdatedAt:
  26895. return m.UpdatedAt()
  26896. case wpchatroom.FieldStatus:
  26897. return m.Status()
  26898. case wpchatroom.FieldWxWxid:
  26899. return m.WxWxid()
  26900. case wpchatroom.FieldChatroomID:
  26901. return m.ChatroomID()
  26902. case wpchatroom.FieldNickname:
  26903. return m.Nickname()
  26904. case wpchatroom.FieldOwner:
  26905. return m.Owner()
  26906. case wpchatroom.FieldAvatar:
  26907. return m.Avatar()
  26908. case wpchatroom.FieldMemberList:
  26909. return m.MemberList()
  26910. }
  26911. return nil, false
  26912. }
  26913. // OldField returns the old value of the field from the database. An error is
  26914. // returned if the mutation operation is not UpdateOne, or the query to the
  26915. // database failed.
  26916. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26917. switch name {
  26918. case wpchatroom.FieldCreatedAt:
  26919. return m.OldCreatedAt(ctx)
  26920. case wpchatroom.FieldUpdatedAt:
  26921. return m.OldUpdatedAt(ctx)
  26922. case wpchatroom.FieldStatus:
  26923. return m.OldStatus(ctx)
  26924. case wpchatroom.FieldWxWxid:
  26925. return m.OldWxWxid(ctx)
  26926. case wpchatroom.FieldChatroomID:
  26927. return m.OldChatroomID(ctx)
  26928. case wpchatroom.FieldNickname:
  26929. return m.OldNickname(ctx)
  26930. case wpchatroom.FieldOwner:
  26931. return m.OldOwner(ctx)
  26932. case wpchatroom.FieldAvatar:
  26933. return m.OldAvatar(ctx)
  26934. case wpchatroom.FieldMemberList:
  26935. return m.OldMemberList(ctx)
  26936. }
  26937. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  26938. }
  26939. // SetField sets the value of a field with the given name. It returns an error if
  26940. // the field is not defined in the schema, or if the type mismatched the field
  26941. // type.
  26942. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  26943. switch name {
  26944. case wpchatroom.FieldCreatedAt:
  26945. v, ok := value.(time.Time)
  26946. if !ok {
  26947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26948. }
  26949. m.SetCreatedAt(v)
  26950. return nil
  26951. case wpchatroom.FieldUpdatedAt:
  26952. v, ok := value.(time.Time)
  26953. if !ok {
  26954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26955. }
  26956. m.SetUpdatedAt(v)
  26957. return nil
  26958. case wpchatroom.FieldStatus:
  26959. v, ok := value.(uint8)
  26960. if !ok {
  26961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26962. }
  26963. m.SetStatus(v)
  26964. return nil
  26965. case wpchatroom.FieldWxWxid:
  26966. v, ok := value.(string)
  26967. if !ok {
  26968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26969. }
  26970. m.SetWxWxid(v)
  26971. return nil
  26972. case wpchatroom.FieldChatroomID:
  26973. v, ok := value.(string)
  26974. if !ok {
  26975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26976. }
  26977. m.SetChatroomID(v)
  26978. return nil
  26979. case wpchatroom.FieldNickname:
  26980. v, ok := value.(string)
  26981. if !ok {
  26982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26983. }
  26984. m.SetNickname(v)
  26985. return nil
  26986. case wpchatroom.FieldOwner:
  26987. v, ok := value.(string)
  26988. if !ok {
  26989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26990. }
  26991. m.SetOwner(v)
  26992. return nil
  26993. case wpchatroom.FieldAvatar:
  26994. v, ok := value.(string)
  26995. if !ok {
  26996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26997. }
  26998. m.SetAvatar(v)
  26999. return nil
  27000. case wpchatroom.FieldMemberList:
  27001. v, ok := value.([]string)
  27002. if !ok {
  27003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27004. }
  27005. m.SetMemberList(v)
  27006. return nil
  27007. }
  27008. return fmt.Errorf("unknown WpChatroom field %s", name)
  27009. }
  27010. // AddedFields returns all numeric fields that were incremented/decremented during
  27011. // this mutation.
  27012. func (m *WpChatroomMutation) AddedFields() []string {
  27013. var fields []string
  27014. if m.addstatus != nil {
  27015. fields = append(fields, wpchatroom.FieldStatus)
  27016. }
  27017. return fields
  27018. }
  27019. // AddedField returns the numeric value that was incremented/decremented on a field
  27020. // with the given name. The second boolean return value indicates that this field
  27021. // was not set, or was not defined in the schema.
  27022. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  27023. switch name {
  27024. case wpchatroom.FieldStatus:
  27025. return m.AddedStatus()
  27026. }
  27027. return nil, false
  27028. }
  27029. // AddField adds the value to the field with the given name. It returns an error if
  27030. // the field is not defined in the schema, or if the type mismatched the field
  27031. // type.
  27032. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  27033. switch name {
  27034. case wpchatroom.FieldStatus:
  27035. v, ok := value.(int8)
  27036. if !ok {
  27037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27038. }
  27039. m.AddStatus(v)
  27040. return nil
  27041. }
  27042. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  27043. }
  27044. // ClearedFields returns all nullable fields that were cleared during this
  27045. // mutation.
  27046. func (m *WpChatroomMutation) ClearedFields() []string {
  27047. var fields []string
  27048. if m.FieldCleared(wpchatroom.FieldStatus) {
  27049. fields = append(fields, wpchatroom.FieldStatus)
  27050. }
  27051. return fields
  27052. }
  27053. // FieldCleared returns a boolean indicating if a field with the given name was
  27054. // cleared in this mutation.
  27055. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  27056. _, ok := m.clearedFields[name]
  27057. return ok
  27058. }
  27059. // ClearField clears the value of the field with the given name. It returns an
  27060. // error if the field is not defined in the schema.
  27061. func (m *WpChatroomMutation) ClearField(name string) error {
  27062. switch name {
  27063. case wpchatroom.FieldStatus:
  27064. m.ClearStatus()
  27065. return nil
  27066. }
  27067. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  27068. }
  27069. // ResetField resets all changes in the mutation for the field with the given name.
  27070. // It returns an error if the field is not defined in the schema.
  27071. func (m *WpChatroomMutation) ResetField(name string) error {
  27072. switch name {
  27073. case wpchatroom.FieldCreatedAt:
  27074. m.ResetCreatedAt()
  27075. return nil
  27076. case wpchatroom.FieldUpdatedAt:
  27077. m.ResetUpdatedAt()
  27078. return nil
  27079. case wpchatroom.FieldStatus:
  27080. m.ResetStatus()
  27081. return nil
  27082. case wpchatroom.FieldWxWxid:
  27083. m.ResetWxWxid()
  27084. return nil
  27085. case wpchatroom.FieldChatroomID:
  27086. m.ResetChatroomID()
  27087. return nil
  27088. case wpchatroom.FieldNickname:
  27089. m.ResetNickname()
  27090. return nil
  27091. case wpchatroom.FieldOwner:
  27092. m.ResetOwner()
  27093. return nil
  27094. case wpchatroom.FieldAvatar:
  27095. m.ResetAvatar()
  27096. return nil
  27097. case wpchatroom.FieldMemberList:
  27098. m.ResetMemberList()
  27099. return nil
  27100. }
  27101. return fmt.Errorf("unknown WpChatroom field %s", name)
  27102. }
  27103. // AddedEdges returns all edge names that were set/added in this mutation.
  27104. func (m *WpChatroomMutation) AddedEdges() []string {
  27105. edges := make([]string, 0, 0)
  27106. return edges
  27107. }
  27108. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27109. // name in this mutation.
  27110. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  27111. return nil
  27112. }
  27113. // RemovedEdges returns all edge names that were removed in this mutation.
  27114. func (m *WpChatroomMutation) RemovedEdges() []string {
  27115. edges := make([]string, 0, 0)
  27116. return edges
  27117. }
  27118. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27119. // the given name in this mutation.
  27120. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  27121. return nil
  27122. }
  27123. // ClearedEdges returns all edge names that were cleared in this mutation.
  27124. func (m *WpChatroomMutation) ClearedEdges() []string {
  27125. edges := make([]string, 0, 0)
  27126. return edges
  27127. }
  27128. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27129. // was cleared in this mutation.
  27130. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  27131. return false
  27132. }
  27133. // ClearEdge clears the value of the edge with the given name. It returns an error
  27134. // if that edge is not defined in the schema.
  27135. func (m *WpChatroomMutation) ClearEdge(name string) error {
  27136. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  27137. }
  27138. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27139. // It returns an error if the edge is not defined in the schema.
  27140. func (m *WpChatroomMutation) ResetEdge(name string) error {
  27141. return fmt.Errorf("unknown WpChatroom edge %s", name)
  27142. }
  27143. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  27144. type WpChatroomMemberMutation struct {
  27145. config
  27146. op Op
  27147. typ string
  27148. id *uint64
  27149. created_at *time.Time
  27150. updated_at *time.Time
  27151. status *uint8
  27152. addstatus *int8
  27153. wx_wxid *string
  27154. wxid *string
  27155. nickname *string
  27156. avatar *string
  27157. clearedFields map[string]struct{}
  27158. done bool
  27159. oldValue func(context.Context) (*WpChatroomMember, error)
  27160. predicates []predicate.WpChatroomMember
  27161. }
  27162. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  27163. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  27164. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  27165. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  27166. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  27167. m := &WpChatroomMemberMutation{
  27168. config: c,
  27169. op: op,
  27170. typ: TypeWpChatroomMember,
  27171. clearedFields: make(map[string]struct{}),
  27172. }
  27173. for _, opt := range opts {
  27174. opt(m)
  27175. }
  27176. return m
  27177. }
  27178. // withWpChatroomMemberID sets the ID field of the mutation.
  27179. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  27180. return func(m *WpChatroomMemberMutation) {
  27181. var (
  27182. err error
  27183. once sync.Once
  27184. value *WpChatroomMember
  27185. )
  27186. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  27187. once.Do(func() {
  27188. if m.done {
  27189. err = errors.New("querying old values post mutation is not allowed")
  27190. } else {
  27191. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  27192. }
  27193. })
  27194. return value, err
  27195. }
  27196. m.id = &id
  27197. }
  27198. }
  27199. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  27200. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  27201. return func(m *WpChatroomMemberMutation) {
  27202. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  27203. return node, nil
  27204. }
  27205. m.id = &node.ID
  27206. }
  27207. }
  27208. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27209. // executed in a transaction (ent.Tx), a transactional client is returned.
  27210. func (m WpChatroomMemberMutation) Client() *Client {
  27211. client := &Client{config: m.config}
  27212. client.init()
  27213. return client
  27214. }
  27215. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27216. // it returns an error otherwise.
  27217. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  27218. if _, ok := m.driver.(*txDriver); !ok {
  27219. return nil, errors.New("ent: mutation is not running in a transaction")
  27220. }
  27221. tx := &Tx{config: m.config}
  27222. tx.init()
  27223. return tx, nil
  27224. }
  27225. // SetID sets the value of the id field. Note that this
  27226. // operation is only accepted on creation of WpChatroomMember entities.
  27227. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  27228. m.id = &id
  27229. }
  27230. // ID returns the ID value in the mutation. Note that the ID is only available
  27231. // if it was provided to the builder or after it was returned from the database.
  27232. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  27233. if m.id == nil {
  27234. return
  27235. }
  27236. return *m.id, true
  27237. }
  27238. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27239. // That means, if the mutation is applied within a transaction with an isolation level such
  27240. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27241. // or updated by the mutation.
  27242. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  27243. switch {
  27244. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27245. id, exists := m.ID()
  27246. if exists {
  27247. return []uint64{id}, nil
  27248. }
  27249. fallthrough
  27250. case m.op.Is(OpUpdate | OpDelete):
  27251. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  27252. default:
  27253. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27254. }
  27255. }
  27256. // SetCreatedAt sets the "created_at" field.
  27257. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  27258. m.created_at = &t
  27259. }
  27260. // CreatedAt returns the value of the "created_at" field in the mutation.
  27261. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  27262. v := m.created_at
  27263. if v == nil {
  27264. return
  27265. }
  27266. return *v, true
  27267. }
  27268. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  27269. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27271. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27272. if !m.op.Is(OpUpdateOne) {
  27273. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27274. }
  27275. if m.id == nil || m.oldValue == nil {
  27276. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27277. }
  27278. oldValue, err := m.oldValue(ctx)
  27279. if err != nil {
  27280. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27281. }
  27282. return oldValue.CreatedAt, nil
  27283. }
  27284. // ResetCreatedAt resets all changes to the "created_at" field.
  27285. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  27286. m.created_at = nil
  27287. }
  27288. // SetUpdatedAt sets the "updated_at" field.
  27289. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  27290. m.updated_at = &t
  27291. }
  27292. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27293. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  27294. v := m.updated_at
  27295. if v == nil {
  27296. return
  27297. }
  27298. return *v, true
  27299. }
  27300. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  27301. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27303. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27304. if !m.op.Is(OpUpdateOne) {
  27305. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27306. }
  27307. if m.id == nil || m.oldValue == nil {
  27308. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27309. }
  27310. oldValue, err := m.oldValue(ctx)
  27311. if err != nil {
  27312. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27313. }
  27314. return oldValue.UpdatedAt, nil
  27315. }
  27316. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27317. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  27318. m.updated_at = nil
  27319. }
  27320. // SetStatus sets the "status" field.
  27321. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  27322. m.status = &u
  27323. m.addstatus = nil
  27324. }
  27325. // Status returns the value of the "status" field in the mutation.
  27326. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  27327. v := m.status
  27328. if v == nil {
  27329. return
  27330. }
  27331. return *v, true
  27332. }
  27333. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  27334. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27336. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27337. if !m.op.Is(OpUpdateOne) {
  27338. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27339. }
  27340. if m.id == nil || m.oldValue == nil {
  27341. return v, errors.New("OldStatus requires an ID field in the mutation")
  27342. }
  27343. oldValue, err := m.oldValue(ctx)
  27344. if err != nil {
  27345. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27346. }
  27347. return oldValue.Status, nil
  27348. }
  27349. // AddStatus adds u to the "status" field.
  27350. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  27351. if m.addstatus != nil {
  27352. *m.addstatus += u
  27353. } else {
  27354. m.addstatus = &u
  27355. }
  27356. }
  27357. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27358. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  27359. v := m.addstatus
  27360. if v == nil {
  27361. return
  27362. }
  27363. return *v, true
  27364. }
  27365. // ClearStatus clears the value of the "status" field.
  27366. func (m *WpChatroomMemberMutation) ClearStatus() {
  27367. m.status = nil
  27368. m.addstatus = nil
  27369. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  27370. }
  27371. // StatusCleared returns if the "status" field was cleared in this mutation.
  27372. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  27373. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  27374. return ok
  27375. }
  27376. // ResetStatus resets all changes to the "status" field.
  27377. func (m *WpChatroomMemberMutation) ResetStatus() {
  27378. m.status = nil
  27379. m.addstatus = nil
  27380. delete(m.clearedFields, wpchatroommember.FieldStatus)
  27381. }
  27382. // SetWxWxid sets the "wx_wxid" field.
  27383. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  27384. m.wx_wxid = &s
  27385. }
  27386. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  27387. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  27388. v := m.wx_wxid
  27389. if v == nil {
  27390. return
  27391. }
  27392. return *v, true
  27393. }
  27394. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  27395. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27397. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  27398. if !m.op.Is(OpUpdateOne) {
  27399. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  27400. }
  27401. if m.id == nil || m.oldValue == nil {
  27402. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  27403. }
  27404. oldValue, err := m.oldValue(ctx)
  27405. if err != nil {
  27406. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  27407. }
  27408. return oldValue.WxWxid, nil
  27409. }
  27410. // ResetWxWxid resets all changes to the "wx_wxid" field.
  27411. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  27412. m.wx_wxid = nil
  27413. }
  27414. // SetWxid sets the "wxid" field.
  27415. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  27416. m.wxid = &s
  27417. }
  27418. // Wxid returns the value of the "wxid" field in the mutation.
  27419. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  27420. v := m.wxid
  27421. if v == nil {
  27422. return
  27423. }
  27424. return *v, true
  27425. }
  27426. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  27427. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27429. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  27430. if !m.op.Is(OpUpdateOne) {
  27431. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  27432. }
  27433. if m.id == nil || m.oldValue == nil {
  27434. return v, errors.New("OldWxid requires an ID field in the mutation")
  27435. }
  27436. oldValue, err := m.oldValue(ctx)
  27437. if err != nil {
  27438. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  27439. }
  27440. return oldValue.Wxid, nil
  27441. }
  27442. // ResetWxid resets all changes to the "wxid" field.
  27443. func (m *WpChatroomMemberMutation) ResetWxid() {
  27444. m.wxid = nil
  27445. }
  27446. // SetNickname sets the "nickname" field.
  27447. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  27448. m.nickname = &s
  27449. }
  27450. // Nickname returns the value of the "nickname" field in the mutation.
  27451. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  27452. v := m.nickname
  27453. if v == nil {
  27454. return
  27455. }
  27456. return *v, true
  27457. }
  27458. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  27459. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27461. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  27462. if !m.op.Is(OpUpdateOne) {
  27463. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  27464. }
  27465. if m.id == nil || m.oldValue == nil {
  27466. return v, errors.New("OldNickname requires an ID field in the mutation")
  27467. }
  27468. oldValue, err := m.oldValue(ctx)
  27469. if err != nil {
  27470. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  27471. }
  27472. return oldValue.Nickname, nil
  27473. }
  27474. // ResetNickname resets all changes to the "nickname" field.
  27475. func (m *WpChatroomMemberMutation) ResetNickname() {
  27476. m.nickname = nil
  27477. }
  27478. // SetAvatar sets the "avatar" field.
  27479. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  27480. m.avatar = &s
  27481. }
  27482. // Avatar returns the value of the "avatar" field in the mutation.
  27483. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  27484. v := m.avatar
  27485. if v == nil {
  27486. return
  27487. }
  27488. return *v, true
  27489. }
  27490. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  27491. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27493. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  27494. if !m.op.Is(OpUpdateOne) {
  27495. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  27496. }
  27497. if m.id == nil || m.oldValue == nil {
  27498. return v, errors.New("OldAvatar requires an ID field in the mutation")
  27499. }
  27500. oldValue, err := m.oldValue(ctx)
  27501. if err != nil {
  27502. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  27503. }
  27504. return oldValue.Avatar, nil
  27505. }
  27506. // ResetAvatar resets all changes to the "avatar" field.
  27507. func (m *WpChatroomMemberMutation) ResetAvatar() {
  27508. m.avatar = nil
  27509. }
  27510. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  27511. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  27512. m.predicates = append(m.predicates, ps...)
  27513. }
  27514. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  27515. // users can use type-assertion to append predicates that do not depend on any generated package.
  27516. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  27517. p := make([]predicate.WpChatroomMember, len(ps))
  27518. for i := range ps {
  27519. p[i] = ps[i]
  27520. }
  27521. m.Where(p...)
  27522. }
  27523. // Op returns the operation name.
  27524. func (m *WpChatroomMemberMutation) Op() Op {
  27525. return m.op
  27526. }
  27527. // SetOp allows setting the mutation operation.
  27528. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  27529. m.op = op
  27530. }
  27531. // Type returns the node type of this mutation (WpChatroomMember).
  27532. func (m *WpChatroomMemberMutation) Type() string {
  27533. return m.typ
  27534. }
  27535. // Fields returns all fields that were changed during this mutation. Note that in
  27536. // order to get all numeric fields that were incremented/decremented, call
  27537. // AddedFields().
  27538. func (m *WpChatroomMemberMutation) Fields() []string {
  27539. fields := make([]string, 0, 7)
  27540. if m.created_at != nil {
  27541. fields = append(fields, wpchatroommember.FieldCreatedAt)
  27542. }
  27543. if m.updated_at != nil {
  27544. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  27545. }
  27546. if m.status != nil {
  27547. fields = append(fields, wpchatroommember.FieldStatus)
  27548. }
  27549. if m.wx_wxid != nil {
  27550. fields = append(fields, wpchatroommember.FieldWxWxid)
  27551. }
  27552. if m.wxid != nil {
  27553. fields = append(fields, wpchatroommember.FieldWxid)
  27554. }
  27555. if m.nickname != nil {
  27556. fields = append(fields, wpchatroommember.FieldNickname)
  27557. }
  27558. if m.avatar != nil {
  27559. fields = append(fields, wpchatroommember.FieldAvatar)
  27560. }
  27561. return fields
  27562. }
  27563. // Field returns the value of a field with the given name. The second boolean
  27564. // return value indicates that this field was not set, or was not defined in the
  27565. // schema.
  27566. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  27567. switch name {
  27568. case wpchatroommember.FieldCreatedAt:
  27569. return m.CreatedAt()
  27570. case wpchatroommember.FieldUpdatedAt:
  27571. return m.UpdatedAt()
  27572. case wpchatroommember.FieldStatus:
  27573. return m.Status()
  27574. case wpchatroommember.FieldWxWxid:
  27575. return m.WxWxid()
  27576. case wpchatroommember.FieldWxid:
  27577. return m.Wxid()
  27578. case wpchatroommember.FieldNickname:
  27579. return m.Nickname()
  27580. case wpchatroommember.FieldAvatar:
  27581. return m.Avatar()
  27582. }
  27583. return nil, false
  27584. }
  27585. // OldField returns the old value of the field from the database. An error is
  27586. // returned if the mutation operation is not UpdateOne, or the query to the
  27587. // database failed.
  27588. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27589. switch name {
  27590. case wpchatroommember.FieldCreatedAt:
  27591. return m.OldCreatedAt(ctx)
  27592. case wpchatroommember.FieldUpdatedAt:
  27593. return m.OldUpdatedAt(ctx)
  27594. case wpchatroommember.FieldStatus:
  27595. return m.OldStatus(ctx)
  27596. case wpchatroommember.FieldWxWxid:
  27597. return m.OldWxWxid(ctx)
  27598. case wpchatroommember.FieldWxid:
  27599. return m.OldWxid(ctx)
  27600. case wpchatroommember.FieldNickname:
  27601. return m.OldNickname(ctx)
  27602. case wpchatroommember.FieldAvatar:
  27603. return m.OldAvatar(ctx)
  27604. }
  27605. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  27606. }
  27607. // SetField sets the value of a field with the given name. It returns an error if
  27608. // the field is not defined in the schema, or if the type mismatched the field
  27609. // type.
  27610. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  27611. switch name {
  27612. case wpchatroommember.FieldCreatedAt:
  27613. v, ok := value.(time.Time)
  27614. if !ok {
  27615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27616. }
  27617. m.SetCreatedAt(v)
  27618. return nil
  27619. case wpchatroommember.FieldUpdatedAt:
  27620. v, ok := value.(time.Time)
  27621. if !ok {
  27622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27623. }
  27624. m.SetUpdatedAt(v)
  27625. return nil
  27626. case wpchatroommember.FieldStatus:
  27627. v, ok := value.(uint8)
  27628. if !ok {
  27629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27630. }
  27631. m.SetStatus(v)
  27632. return nil
  27633. case wpchatroommember.FieldWxWxid:
  27634. v, ok := value.(string)
  27635. if !ok {
  27636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27637. }
  27638. m.SetWxWxid(v)
  27639. return nil
  27640. case wpchatroommember.FieldWxid:
  27641. v, ok := value.(string)
  27642. if !ok {
  27643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27644. }
  27645. m.SetWxid(v)
  27646. return nil
  27647. case wpchatroommember.FieldNickname:
  27648. v, ok := value.(string)
  27649. if !ok {
  27650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27651. }
  27652. m.SetNickname(v)
  27653. return nil
  27654. case wpchatroommember.FieldAvatar:
  27655. v, ok := value.(string)
  27656. if !ok {
  27657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27658. }
  27659. m.SetAvatar(v)
  27660. return nil
  27661. }
  27662. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  27663. }
  27664. // AddedFields returns all numeric fields that were incremented/decremented during
  27665. // this mutation.
  27666. func (m *WpChatroomMemberMutation) AddedFields() []string {
  27667. var fields []string
  27668. if m.addstatus != nil {
  27669. fields = append(fields, wpchatroommember.FieldStatus)
  27670. }
  27671. return fields
  27672. }
  27673. // AddedField returns the numeric value that was incremented/decremented on a field
  27674. // with the given name. The second boolean return value indicates that this field
  27675. // was not set, or was not defined in the schema.
  27676. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  27677. switch name {
  27678. case wpchatroommember.FieldStatus:
  27679. return m.AddedStatus()
  27680. }
  27681. return nil, false
  27682. }
  27683. // AddField adds the value to the field with the given name. It returns an error if
  27684. // the field is not defined in the schema, or if the type mismatched the field
  27685. // type.
  27686. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  27687. switch name {
  27688. case wpchatroommember.FieldStatus:
  27689. v, ok := value.(int8)
  27690. if !ok {
  27691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27692. }
  27693. m.AddStatus(v)
  27694. return nil
  27695. }
  27696. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  27697. }
  27698. // ClearedFields returns all nullable fields that were cleared during this
  27699. // mutation.
  27700. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  27701. var fields []string
  27702. if m.FieldCleared(wpchatroommember.FieldStatus) {
  27703. fields = append(fields, wpchatroommember.FieldStatus)
  27704. }
  27705. return fields
  27706. }
  27707. // FieldCleared returns a boolean indicating if a field with the given name was
  27708. // cleared in this mutation.
  27709. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  27710. _, ok := m.clearedFields[name]
  27711. return ok
  27712. }
  27713. // ClearField clears the value of the field with the given name. It returns an
  27714. // error if the field is not defined in the schema.
  27715. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  27716. switch name {
  27717. case wpchatroommember.FieldStatus:
  27718. m.ClearStatus()
  27719. return nil
  27720. }
  27721. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  27722. }
  27723. // ResetField resets all changes in the mutation for the field with the given name.
  27724. // It returns an error if the field is not defined in the schema.
  27725. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  27726. switch name {
  27727. case wpchatroommember.FieldCreatedAt:
  27728. m.ResetCreatedAt()
  27729. return nil
  27730. case wpchatroommember.FieldUpdatedAt:
  27731. m.ResetUpdatedAt()
  27732. return nil
  27733. case wpchatroommember.FieldStatus:
  27734. m.ResetStatus()
  27735. return nil
  27736. case wpchatroommember.FieldWxWxid:
  27737. m.ResetWxWxid()
  27738. return nil
  27739. case wpchatroommember.FieldWxid:
  27740. m.ResetWxid()
  27741. return nil
  27742. case wpchatroommember.FieldNickname:
  27743. m.ResetNickname()
  27744. return nil
  27745. case wpchatroommember.FieldAvatar:
  27746. m.ResetAvatar()
  27747. return nil
  27748. }
  27749. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  27750. }
  27751. // AddedEdges returns all edge names that were set/added in this mutation.
  27752. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  27753. edges := make([]string, 0, 0)
  27754. return edges
  27755. }
  27756. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27757. // name in this mutation.
  27758. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  27759. return nil
  27760. }
  27761. // RemovedEdges returns all edge names that were removed in this mutation.
  27762. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  27763. edges := make([]string, 0, 0)
  27764. return edges
  27765. }
  27766. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27767. // the given name in this mutation.
  27768. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  27769. return nil
  27770. }
  27771. // ClearedEdges returns all edge names that were cleared in this mutation.
  27772. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  27773. edges := make([]string, 0, 0)
  27774. return edges
  27775. }
  27776. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27777. // was cleared in this mutation.
  27778. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  27779. return false
  27780. }
  27781. // ClearEdge clears the value of the edge with the given name. It returns an error
  27782. // if that edge is not defined in the schema.
  27783. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  27784. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  27785. }
  27786. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27787. // It returns an error if the edge is not defined in the schema.
  27788. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  27789. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  27790. }
  27791. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  27792. type WxMutation struct {
  27793. config
  27794. op Op
  27795. typ string
  27796. id *uint64
  27797. created_at *time.Time
  27798. updated_at *time.Time
  27799. status *uint8
  27800. addstatus *int8
  27801. deleted_at *time.Time
  27802. port *string
  27803. process_id *string
  27804. callback *string
  27805. wxid *string
  27806. account *string
  27807. nickname *string
  27808. tel *string
  27809. head_big *string
  27810. organization_id *uint64
  27811. addorganization_id *int64
  27812. api_base *string
  27813. api_key *string
  27814. allow_list *[]string
  27815. appendallow_list []string
  27816. group_allow_list *[]string
  27817. appendgroup_allow_list []string
  27818. block_list *[]string
  27819. appendblock_list []string
  27820. group_block_list *[]string
  27821. appendgroup_block_list []string
  27822. clearedFields map[string]struct{}
  27823. server *uint64
  27824. clearedserver bool
  27825. agent *uint64
  27826. clearedagent bool
  27827. done bool
  27828. oldValue func(context.Context) (*Wx, error)
  27829. predicates []predicate.Wx
  27830. }
  27831. var _ ent.Mutation = (*WxMutation)(nil)
  27832. // wxOption allows management of the mutation configuration using functional options.
  27833. type wxOption func(*WxMutation)
  27834. // newWxMutation creates new mutation for the Wx entity.
  27835. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  27836. m := &WxMutation{
  27837. config: c,
  27838. op: op,
  27839. typ: TypeWx,
  27840. clearedFields: make(map[string]struct{}),
  27841. }
  27842. for _, opt := range opts {
  27843. opt(m)
  27844. }
  27845. return m
  27846. }
  27847. // withWxID sets the ID field of the mutation.
  27848. func withWxID(id uint64) wxOption {
  27849. return func(m *WxMutation) {
  27850. var (
  27851. err error
  27852. once sync.Once
  27853. value *Wx
  27854. )
  27855. m.oldValue = func(ctx context.Context) (*Wx, error) {
  27856. once.Do(func() {
  27857. if m.done {
  27858. err = errors.New("querying old values post mutation is not allowed")
  27859. } else {
  27860. value, err = m.Client().Wx.Get(ctx, id)
  27861. }
  27862. })
  27863. return value, err
  27864. }
  27865. m.id = &id
  27866. }
  27867. }
  27868. // withWx sets the old Wx of the mutation.
  27869. func withWx(node *Wx) wxOption {
  27870. return func(m *WxMutation) {
  27871. m.oldValue = func(context.Context) (*Wx, error) {
  27872. return node, nil
  27873. }
  27874. m.id = &node.ID
  27875. }
  27876. }
  27877. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27878. // executed in a transaction (ent.Tx), a transactional client is returned.
  27879. func (m WxMutation) Client() *Client {
  27880. client := &Client{config: m.config}
  27881. client.init()
  27882. return client
  27883. }
  27884. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27885. // it returns an error otherwise.
  27886. func (m WxMutation) Tx() (*Tx, error) {
  27887. if _, ok := m.driver.(*txDriver); !ok {
  27888. return nil, errors.New("ent: mutation is not running in a transaction")
  27889. }
  27890. tx := &Tx{config: m.config}
  27891. tx.init()
  27892. return tx, nil
  27893. }
  27894. // SetID sets the value of the id field. Note that this
  27895. // operation is only accepted on creation of Wx entities.
  27896. func (m *WxMutation) SetID(id uint64) {
  27897. m.id = &id
  27898. }
  27899. // ID returns the ID value in the mutation. Note that the ID is only available
  27900. // if it was provided to the builder or after it was returned from the database.
  27901. func (m *WxMutation) ID() (id uint64, exists bool) {
  27902. if m.id == nil {
  27903. return
  27904. }
  27905. return *m.id, true
  27906. }
  27907. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27908. // That means, if the mutation is applied within a transaction with an isolation level such
  27909. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27910. // or updated by the mutation.
  27911. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  27912. switch {
  27913. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27914. id, exists := m.ID()
  27915. if exists {
  27916. return []uint64{id}, nil
  27917. }
  27918. fallthrough
  27919. case m.op.Is(OpUpdate | OpDelete):
  27920. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  27921. default:
  27922. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27923. }
  27924. }
  27925. // SetCreatedAt sets the "created_at" field.
  27926. func (m *WxMutation) SetCreatedAt(t time.Time) {
  27927. m.created_at = &t
  27928. }
  27929. // CreatedAt returns the value of the "created_at" field in the mutation.
  27930. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  27931. v := m.created_at
  27932. if v == nil {
  27933. return
  27934. }
  27935. return *v, true
  27936. }
  27937. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  27938. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27940. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27941. if !m.op.Is(OpUpdateOne) {
  27942. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27943. }
  27944. if m.id == nil || m.oldValue == nil {
  27945. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27946. }
  27947. oldValue, err := m.oldValue(ctx)
  27948. if err != nil {
  27949. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27950. }
  27951. return oldValue.CreatedAt, nil
  27952. }
  27953. // ResetCreatedAt resets all changes to the "created_at" field.
  27954. func (m *WxMutation) ResetCreatedAt() {
  27955. m.created_at = nil
  27956. }
  27957. // SetUpdatedAt sets the "updated_at" field.
  27958. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  27959. m.updated_at = &t
  27960. }
  27961. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27962. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  27963. v := m.updated_at
  27964. if v == nil {
  27965. return
  27966. }
  27967. return *v, true
  27968. }
  27969. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  27970. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27972. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27973. if !m.op.Is(OpUpdateOne) {
  27974. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27975. }
  27976. if m.id == nil || m.oldValue == nil {
  27977. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27978. }
  27979. oldValue, err := m.oldValue(ctx)
  27980. if err != nil {
  27981. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27982. }
  27983. return oldValue.UpdatedAt, nil
  27984. }
  27985. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27986. func (m *WxMutation) ResetUpdatedAt() {
  27987. m.updated_at = nil
  27988. }
  27989. // SetStatus sets the "status" field.
  27990. func (m *WxMutation) SetStatus(u uint8) {
  27991. m.status = &u
  27992. m.addstatus = nil
  27993. }
  27994. // Status returns the value of the "status" field in the mutation.
  27995. func (m *WxMutation) Status() (r uint8, exists bool) {
  27996. v := m.status
  27997. if v == nil {
  27998. return
  27999. }
  28000. return *v, true
  28001. }
  28002. // OldStatus returns the old "status" field's value of the Wx entity.
  28003. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28005. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28006. if !m.op.Is(OpUpdateOne) {
  28007. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28008. }
  28009. if m.id == nil || m.oldValue == nil {
  28010. return v, errors.New("OldStatus requires an ID field in the mutation")
  28011. }
  28012. oldValue, err := m.oldValue(ctx)
  28013. if err != nil {
  28014. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28015. }
  28016. return oldValue.Status, nil
  28017. }
  28018. // AddStatus adds u to the "status" field.
  28019. func (m *WxMutation) AddStatus(u int8) {
  28020. if m.addstatus != nil {
  28021. *m.addstatus += u
  28022. } else {
  28023. m.addstatus = &u
  28024. }
  28025. }
  28026. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28027. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  28028. v := m.addstatus
  28029. if v == nil {
  28030. return
  28031. }
  28032. return *v, true
  28033. }
  28034. // ClearStatus clears the value of the "status" field.
  28035. func (m *WxMutation) ClearStatus() {
  28036. m.status = nil
  28037. m.addstatus = nil
  28038. m.clearedFields[wx.FieldStatus] = struct{}{}
  28039. }
  28040. // StatusCleared returns if the "status" field was cleared in this mutation.
  28041. func (m *WxMutation) StatusCleared() bool {
  28042. _, ok := m.clearedFields[wx.FieldStatus]
  28043. return ok
  28044. }
  28045. // ResetStatus resets all changes to the "status" field.
  28046. func (m *WxMutation) ResetStatus() {
  28047. m.status = nil
  28048. m.addstatus = nil
  28049. delete(m.clearedFields, wx.FieldStatus)
  28050. }
  28051. // SetDeletedAt sets the "deleted_at" field.
  28052. func (m *WxMutation) SetDeletedAt(t time.Time) {
  28053. m.deleted_at = &t
  28054. }
  28055. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28056. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  28057. v := m.deleted_at
  28058. if v == nil {
  28059. return
  28060. }
  28061. return *v, true
  28062. }
  28063. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  28064. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28066. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28067. if !m.op.Is(OpUpdateOne) {
  28068. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28069. }
  28070. if m.id == nil || m.oldValue == nil {
  28071. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28072. }
  28073. oldValue, err := m.oldValue(ctx)
  28074. if err != nil {
  28075. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28076. }
  28077. return oldValue.DeletedAt, nil
  28078. }
  28079. // ClearDeletedAt clears the value of the "deleted_at" field.
  28080. func (m *WxMutation) ClearDeletedAt() {
  28081. m.deleted_at = nil
  28082. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  28083. }
  28084. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28085. func (m *WxMutation) DeletedAtCleared() bool {
  28086. _, ok := m.clearedFields[wx.FieldDeletedAt]
  28087. return ok
  28088. }
  28089. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28090. func (m *WxMutation) ResetDeletedAt() {
  28091. m.deleted_at = nil
  28092. delete(m.clearedFields, wx.FieldDeletedAt)
  28093. }
  28094. // SetServerID sets the "server_id" field.
  28095. func (m *WxMutation) SetServerID(u uint64) {
  28096. m.server = &u
  28097. }
  28098. // ServerID returns the value of the "server_id" field in the mutation.
  28099. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  28100. v := m.server
  28101. if v == nil {
  28102. return
  28103. }
  28104. return *v, true
  28105. }
  28106. // OldServerID returns the old "server_id" field's value of the Wx entity.
  28107. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28109. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  28110. if !m.op.Is(OpUpdateOne) {
  28111. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  28112. }
  28113. if m.id == nil || m.oldValue == nil {
  28114. return v, errors.New("OldServerID requires an ID field in the mutation")
  28115. }
  28116. oldValue, err := m.oldValue(ctx)
  28117. if err != nil {
  28118. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  28119. }
  28120. return oldValue.ServerID, nil
  28121. }
  28122. // ClearServerID clears the value of the "server_id" field.
  28123. func (m *WxMutation) ClearServerID() {
  28124. m.server = nil
  28125. m.clearedFields[wx.FieldServerID] = struct{}{}
  28126. }
  28127. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  28128. func (m *WxMutation) ServerIDCleared() bool {
  28129. _, ok := m.clearedFields[wx.FieldServerID]
  28130. return ok
  28131. }
  28132. // ResetServerID resets all changes to the "server_id" field.
  28133. func (m *WxMutation) ResetServerID() {
  28134. m.server = nil
  28135. delete(m.clearedFields, wx.FieldServerID)
  28136. }
  28137. // SetPort sets the "port" field.
  28138. func (m *WxMutation) SetPort(s string) {
  28139. m.port = &s
  28140. }
  28141. // Port returns the value of the "port" field in the mutation.
  28142. func (m *WxMutation) Port() (r string, exists bool) {
  28143. v := m.port
  28144. if v == nil {
  28145. return
  28146. }
  28147. return *v, true
  28148. }
  28149. // OldPort returns the old "port" field's value of the Wx entity.
  28150. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28152. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  28153. if !m.op.Is(OpUpdateOne) {
  28154. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  28155. }
  28156. if m.id == nil || m.oldValue == nil {
  28157. return v, errors.New("OldPort requires an ID field in the mutation")
  28158. }
  28159. oldValue, err := m.oldValue(ctx)
  28160. if err != nil {
  28161. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  28162. }
  28163. return oldValue.Port, nil
  28164. }
  28165. // ResetPort resets all changes to the "port" field.
  28166. func (m *WxMutation) ResetPort() {
  28167. m.port = nil
  28168. }
  28169. // SetProcessID sets the "process_id" field.
  28170. func (m *WxMutation) SetProcessID(s string) {
  28171. m.process_id = &s
  28172. }
  28173. // ProcessID returns the value of the "process_id" field in the mutation.
  28174. func (m *WxMutation) ProcessID() (r string, exists bool) {
  28175. v := m.process_id
  28176. if v == nil {
  28177. return
  28178. }
  28179. return *v, true
  28180. }
  28181. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  28182. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28184. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  28185. if !m.op.Is(OpUpdateOne) {
  28186. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  28187. }
  28188. if m.id == nil || m.oldValue == nil {
  28189. return v, errors.New("OldProcessID requires an ID field in the mutation")
  28190. }
  28191. oldValue, err := m.oldValue(ctx)
  28192. if err != nil {
  28193. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  28194. }
  28195. return oldValue.ProcessID, nil
  28196. }
  28197. // ResetProcessID resets all changes to the "process_id" field.
  28198. func (m *WxMutation) ResetProcessID() {
  28199. m.process_id = nil
  28200. }
  28201. // SetCallback sets the "callback" field.
  28202. func (m *WxMutation) SetCallback(s string) {
  28203. m.callback = &s
  28204. }
  28205. // Callback returns the value of the "callback" field in the mutation.
  28206. func (m *WxMutation) Callback() (r string, exists bool) {
  28207. v := m.callback
  28208. if v == nil {
  28209. return
  28210. }
  28211. return *v, true
  28212. }
  28213. // OldCallback returns the old "callback" field's value of the Wx entity.
  28214. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28216. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  28217. if !m.op.Is(OpUpdateOne) {
  28218. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  28219. }
  28220. if m.id == nil || m.oldValue == nil {
  28221. return v, errors.New("OldCallback requires an ID field in the mutation")
  28222. }
  28223. oldValue, err := m.oldValue(ctx)
  28224. if err != nil {
  28225. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  28226. }
  28227. return oldValue.Callback, nil
  28228. }
  28229. // ResetCallback resets all changes to the "callback" field.
  28230. func (m *WxMutation) ResetCallback() {
  28231. m.callback = nil
  28232. }
  28233. // SetWxid sets the "wxid" field.
  28234. func (m *WxMutation) SetWxid(s string) {
  28235. m.wxid = &s
  28236. }
  28237. // Wxid returns the value of the "wxid" field in the mutation.
  28238. func (m *WxMutation) Wxid() (r string, exists bool) {
  28239. v := m.wxid
  28240. if v == nil {
  28241. return
  28242. }
  28243. return *v, true
  28244. }
  28245. // OldWxid returns the old "wxid" field's value of the Wx entity.
  28246. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28248. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  28249. if !m.op.Is(OpUpdateOne) {
  28250. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  28251. }
  28252. if m.id == nil || m.oldValue == nil {
  28253. return v, errors.New("OldWxid requires an ID field in the mutation")
  28254. }
  28255. oldValue, err := m.oldValue(ctx)
  28256. if err != nil {
  28257. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  28258. }
  28259. return oldValue.Wxid, nil
  28260. }
  28261. // ResetWxid resets all changes to the "wxid" field.
  28262. func (m *WxMutation) ResetWxid() {
  28263. m.wxid = nil
  28264. }
  28265. // SetAccount sets the "account" field.
  28266. func (m *WxMutation) SetAccount(s string) {
  28267. m.account = &s
  28268. }
  28269. // Account returns the value of the "account" field in the mutation.
  28270. func (m *WxMutation) Account() (r string, exists bool) {
  28271. v := m.account
  28272. if v == nil {
  28273. return
  28274. }
  28275. return *v, true
  28276. }
  28277. // OldAccount returns the old "account" field's value of the Wx entity.
  28278. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28280. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  28281. if !m.op.Is(OpUpdateOne) {
  28282. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  28283. }
  28284. if m.id == nil || m.oldValue == nil {
  28285. return v, errors.New("OldAccount requires an ID field in the mutation")
  28286. }
  28287. oldValue, err := m.oldValue(ctx)
  28288. if err != nil {
  28289. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  28290. }
  28291. return oldValue.Account, nil
  28292. }
  28293. // ResetAccount resets all changes to the "account" field.
  28294. func (m *WxMutation) ResetAccount() {
  28295. m.account = nil
  28296. }
  28297. // SetNickname sets the "nickname" field.
  28298. func (m *WxMutation) SetNickname(s string) {
  28299. m.nickname = &s
  28300. }
  28301. // Nickname returns the value of the "nickname" field in the mutation.
  28302. func (m *WxMutation) Nickname() (r string, exists bool) {
  28303. v := m.nickname
  28304. if v == nil {
  28305. return
  28306. }
  28307. return *v, true
  28308. }
  28309. // OldNickname returns the old "nickname" field's value of the Wx entity.
  28310. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28312. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  28313. if !m.op.Is(OpUpdateOne) {
  28314. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  28315. }
  28316. if m.id == nil || m.oldValue == nil {
  28317. return v, errors.New("OldNickname requires an ID field in the mutation")
  28318. }
  28319. oldValue, err := m.oldValue(ctx)
  28320. if err != nil {
  28321. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  28322. }
  28323. return oldValue.Nickname, nil
  28324. }
  28325. // ResetNickname resets all changes to the "nickname" field.
  28326. func (m *WxMutation) ResetNickname() {
  28327. m.nickname = nil
  28328. }
  28329. // SetTel sets the "tel" field.
  28330. func (m *WxMutation) SetTel(s string) {
  28331. m.tel = &s
  28332. }
  28333. // Tel returns the value of the "tel" field in the mutation.
  28334. func (m *WxMutation) Tel() (r string, exists bool) {
  28335. v := m.tel
  28336. if v == nil {
  28337. return
  28338. }
  28339. return *v, true
  28340. }
  28341. // OldTel returns the old "tel" field's value of the Wx entity.
  28342. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28344. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  28345. if !m.op.Is(OpUpdateOne) {
  28346. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  28347. }
  28348. if m.id == nil || m.oldValue == nil {
  28349. return v, errors.New("OldTel requires an ID field in the mutation")
  28350. }
  28351. oldValue, err := m.oldValue(ctx)
  28352. if err != nil {
  28353. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  28354. }
  28355. return oldValue.Tel, nil
  28356. }
  28357. // ResetTel resets all changes to the "tel" field.
  28358. func (m *WxMutation) ResetTel() {
  28359. m.tel = nil
  28360. }
  28361. // SetHeadBig sets the "head_big" field.
  28362. func (m *WxMutation) SetHeadBig(s string) {
  28363. m.head_big = &s
  28364. }
  28365. // HeadBig returns the value of the "head_big" field in the mutation.
  28366. func (m *WxMutation) HeadBig() (r string, exists bool) {
  28367. v := m.head_big
  28368. if v == nil {
  28369. return
  28370. }
  28371. return *v, true
  28372. }
  28373. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  28374. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28376. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  28377. if !m.op.Is(OpUpdateOne) {
  28378. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  28379. }
  28380. if m.id == nil || m.oldValue == nil {
  28381. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  28382. }
  28383. oldValue, err := m.oldValue(ctx)
  28384. if err != nil {
  28385. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  28386. }
  28387. return oldValue.HeadBig, nil
  28388. }
  28389. // ResetHeadBig resets all changes to the "head_big" field.
  28390. func (m *WxMutation) ResetHeadBig() {
  28391. m.head_big = nil
  28392. }
  28393. // SetOrganizationID sets the "organization_id" field.
  28394. func (m *WxMutation) SetOrganizationID(u uint64) {
  28395. m.organization_id = &u
  28396. m.addorganization_id = nil
  28397. }
  28398. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28399. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  28400. v := m.organization_id
  28401. if v == nil {
  28402. return
  28403. }
  28404. return *v, true
  28405. }
  28406. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  28407. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28409. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28410. if !m.op.Is(OpUpdateOne) {
  28411. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28412. }
  28413. if m.id == nil || m.oldValue == nil {
  28414. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28415. }
  28416. oldValue, err := m.oldValue(ctx)
  28417. if err != nil {
  28418. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28419. }
  28420. return oldValue.OrganizationID, nil
  28421. }
  28422. // AddOrganizationID adds u to the "organization_id" field.
  28423. func (m *WxMutation) AddOrganizationID(u int64) {
  28424. if m.addorganization_id != nil {
  28425. *m.addorganization_id += u
  28426. } else {
  28427. m.addorganization_id = &u
  28428. }
  28429. }
  28430. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28431. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  28432. v := m.addorganization_id
  28433. if v == nil {
  28434. return
  28435. }
  28436. return *v, true
  28437. }
  28438. // ClearOrganizationID clears the value of the "organization_id" field.
  28439. func (m *WxMutation) ClearOrganizationID() {
  28440. m.organization_id = nil
  28441. m.addorganization_id = nil
  28442. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  28443. }
  28444. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28445. func (m *WxMutation) OrganizationIDCleared() bool {
  28446. _, ok := m.clearedFields[wx.FieldOrganizationID]
  28447. return ok
  28448. }
  28449. // ResetOrganizationID resets all changes to the "organization_id" field.
  28450. func (m *WxMutation) ResetOrganizationID() {
  28451. m.organization_id = nil
  28452. m.addorganization_id = nil
  28453. delete(m.clearedFields, wx.FieldOrganizationID)
  28454. }
  28455. // SetAgentID sets the "agent_id" field.
  28456. func (m *WxMutation) SetAgentID(u uint64) {
  28457. m.agent = &u
  28458. }
  28459. // AgentID returns the value of the "agent_id" field in the mutation.
  28460. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  28461. v := m.agent
  28462. if v == nil {
  28463. return
  28464. }
  28465. return *v, true
  28466. }
  28467. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  28468. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28470. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  28471. if !m.op.Is(OpUpdateOne) {
  28472. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  28473. }
  28474. if m.id == nil || m.oldValue == nil {
  28475. return v, errors.New("OldAgentID requires an ID field in the mutation")
  28476. }
  28477. oldValue, err := m.oldValue(ctx)
  28478. if err != nil {
  28479. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  28480. }
  28481. return oldValue.AgentID, nil
  28482. }
  28483. // ResetAgentID resets all changes to the "agent_id" field.
  28484. func (m *WxMutation) ResetAgentID() {
  28485. m.agent = nil
  28486. }
  28487. // SetAPIBase sets the "api_base" field.
  28488. func (m *WxMutation) SetAPIBase(s string) {
  28489. m.api_base = &s
  28490. }
  28491. // APIBase returns the value of the "api_base" field in the mutation.
  28492. func (m *WxMutation) APIBase() (r string, exists bool) {
  28493. v := m.api_base
  28494. if v == nil {
  28495. return
  28496. }
  28497. return *v, true
  28498. }
  28499. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  28500. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28502. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  28503. if !m.op.Is(OpUpdateOne) {
  28504. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  28505. }
  28506. if m.id == nil || m.oldValue == nil {
  28507. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  28508. }
  28509. oldValue, err := m.oldValue(ctx)
  28510. if err != nil {
  28511. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  28512. }
  28513. return oldValue.APIBase, nil
  28514. }
  28515. // ClearAPIBase clears the value of the "api_base" field.
  28516. func (m *WxMutation) ClearAPIBase() {
  28517. m.api_base = nil
  28518. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  28519. }
  28520. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  28521. func (m *WxMutation) APIBaseCleared() bool {
  28522. _, ok := m.clearedFields[wx.FieldAPIBase]
  28523. return ok
  28524. }
  28525. // ResetAPIBase resets all changes to the "api_base" field.
  28526. func (m *WxMutation) ResetAPIBase() {
  28527. m.api_base = nil
  28528. delete(m.clearedFields, wx.FieldAPIBase)
  28529. }
  28530. // SetAPIKey sets the "api_key" field.
  28531. func (m *WxMutation) SetAPIKey(s string) {
  28532. m.api_key = &s
  28533. }
  28534. // APIKey returns the value of the "api_key" field in the mutation.
  28535. func (m *WxMutation) APIKey() (r string, exists bool) {
  28536. v := m.api_key
  28537. if v == nil {
  28538. return
  28539. }
  28540. return *v, true
  28541. }
  28542. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  28543. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28545. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  28546. if !m.op.Is(OpUpdateOne) {
  28547. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  28548. }
  28549. if m.id == nil || m.oldValue == nil {
  28550. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  28551. }
  28552. oldValue, err := m.oldValue(ctx)
  28553. if err != nil {
  28554. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  28555. }
  28556. return oldValue.APIKey, nil
  28557. }
  28558. // ClearAPIKey clears the value of the "api_key" field.
  28559. func (m *WxMutation) ClearAPIKey() {
  28560. m.api_key = nil
  28561. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  28562. }
  28563. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  28564. func (m *WxMutation) APIKeyCleared() bool {
  28565. _, ok := m.clearedFields[wx.FieldAPIKey]
  28566. return ok
  28567. }
  28568. // ResetAPIKey resets all changes to the "api_key" field.
  28569. func (m *WxMutation) ResetAPIKey() {
  28570. m.api_key = nil
  28571. delete(m.clearedFields, wx.FieldAPIKey)
  28572. }
  28573. // SetAllowList sets the "allow_list" field.
  28574. func (m *WxMutation) SetAllowList(s []string) {
  28575. m.allow_list = &s
  28576. m.appendallow_list = nil
  28577. }
  28578. // AllowList returns the value of the "allow_list" field in the mutation.
  28579. func (m *WxMutation) AllowList() (r []string, exists bool) {
  28580. v := m.allow_list
  28581. if v == nil {
  28582. return
  28583. }
  28584. return *v, true
  28585. }
  28586. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  28587. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28589. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  28590. if !m.op.Is(OpUpdateOne) {
  28591. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  28592. }
  28593. if m.id == nil || m.oldValue == nil {
  28594. return v, errors.New("OldAllowList requires an ID field in the mutation")
  28595. }
  28596. oldValue, err := m.oldValue(ctx)
  28597. if err != nil {
  28598. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  28599. }
  28600. return oldValue.AllowList, nil
  28601. }
  28602. // AppendAllowList adds s to the "allow_list" field.
  28603. func (m *WxMutation) AppendAllowList(s []string) {
  28604. m.appendallow_list = append(m.appendallow_list, s...)
  28605. }
  28606. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  28607. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  28608. if len(m.appendallow_list) == 0 {
  28609. return nil, false
  28610. }
  28611. return m.appendallow_list, true
  28612. }
  28613. // ResetAllowList resets all changes to the "allow_list" field.
  28614. func (m *WxMutation) ResetAllowList() {
  28615. m.allow_list = nil
  28616. m.appendallow_list = nil
  28617. }
  28618. // SetGroupAllowList sets the "group_allow_list" field.
  28619. func (m *WxMutation) SetGroupAllowList(s []string) {
  28620. m.group_allow_list = &s
  28621. m.appendgroup_allow_list = nil
  28622. }
  28623. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  28624. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  28625. v := m.group_allow_list
  28626. if v == nil {
  28627. return
  28628. }
  28629. return *v, true
  28630. }
  28631. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  28632. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28634. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  28635. if !m.op.Is(OpUpdateOne) {
  28636. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  28637. }
  28638. if m.id == nil || m.oldValue == nil {
  28639. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  28640. }
  28641. oldValue, err := m.oldValue(ctx)
  28642. if err != nil {
  28643. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  28644. }
  28645. return oldValue.GroupAllowList, nil
  28646. }
  28647. // AppendGroupAllowList adds s to the "group_allow_list" field.
  28648. func (m *WxMutation) AppendGroupAllowList(s []string) {
  28649. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  28650. }
  28651. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  28652. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  28653. if len(m.appendgroup_allow_list) == 0 {
  28654. return nil, false
  28655. }
  28656. return m.appendgroup_allow_list, true
  28657. }
  28658. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  28659. func (m *WxMutation) ResetGroupAllowList() {
  28660. m.group_allow_list = nil
  28661. m.appendgroup_allow_list = nil
  28662. }
  28663. // SetBlockList sets the "block_list" field.
  28664. func (m *WxMutation) SetBlockList(s []string) {
  28665. m.block_list = &s
  28666. m.appendblock_list = nil
  28667. }
  28668. // BlockList returns the value of the "block_list" field in the mutation.
  28669. func (m *WxMutation) BlockList() (r []string, exists bool) {
  28670. v := m.block_list
  28671. if v == nil {
  28672. return
  28673. }
  28674. return *v, true
  28675. }
  28676. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  28677. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28679. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  28680. if !m.op.Is(OpUpdateOne) {
  28681. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  28682. }
  28683. if m.id == nil || m.oldValue == nil {
  28684. return v, errors.New("OldBlockList requires an ID field in the mutation")
  28685. }
  28686. oldValue, err := m.oldValue(ctx)
  28687. if err != nil {
  28688. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  28689. }
  28690. return oldValue.BlockList, nil
  28691. }
  28692. // AppendBlockList adds s to the "block_list" field.
  28693. func (m *WxMutation) AppendBlockList(s []string) {
  28694. m.appendblock_list = append(m.appendblock_list, s...)
  28695. }
  28696. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  28697. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  28698. if len(m.appendblock_list) == 0 {
  28699. return nil, false
  28700. }
  28701. return m.appendblock_list, true
  28702. }
  28703. // ResetBlockList resets all changes to the "block_list" field.
  28704. func (m *WxMutation) ResetBlockList() {
  28705. m.block_list = nil
  28706. m.appendblock_list = nil
  28707. }
  28708. // SetGroupBlockList sets the "group_block_list" field.
  28709. func (m *WxMutation) SetGroupBlockList(s []string) {
  28710. m.group_block_list = &s
  28711. m.appendgroup_block_list = nil
  28712. }
  28713. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  28714. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  28715. v := m.group_block_list
  28716. if v == nil {
  28717. return
  28718. }
  28719. return *v, true
  28720. }
  28721. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  28722. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28724. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  28725. if !m.op.Is(OpUpdateOne) {
  28726. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  28727. }
  28728. if m.id == nil || m.oldValue == nil {
  28729. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  28730. }
  28731. oldValue, err := m.oldValue(ctx)
  28732. if err != nil {
  28733. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  28734. }
  28735. return oldValue.GroupBlockList, nil
  28736. }
  28737. // AppendGroupBlockList adds s to the "group_block_list" field.
  28738. func (m *WxMutation) AppendGroupBlockList(s []string) {
  28739. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  28740. }
  28741. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  28742. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  28743. if len(m.appendgroup_block_list) == 0 {
  28744. return nil, false
  28745. }
  28746. return m.appendgroup_block_list, true
  28747. }
  28748. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  28749. func (m *WxMutation) ResetGroupBlockList() {
  28750. m.group_block_list = nil
  28751. m.appendgroup_block_list = nil
  28752. }
  28753. // ClearServer clears the "server" edge to the Server entity.
  28754. func (m *WxMutation) ClearServer() {
  28755. m.clearedserver = true
  28756. m.clearedFields[wx.FieldServerID] = struct{}{}
  28757. }
  28758. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  28759. func (m *WxMutation) ServerCleared() bool {
  28760. return m.ServerIDCleared() || m.clearedserver
  28761. }
  28762. // ServerIDs returns the "server" edge IDs in the mutation.
  28763. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28764. // ServerID instead. It exists only for internal usage by the builders.
  28765. func (m *WxMutation) ServerIDs() (ids []uint64) {
  28766. if id := m.server; id != nil {
  28767. ids = append(ids, *id)
  28768. }
  28769. return
  28770. }
  28771. // ResetServer resets all changes to the "server" edge.
  28772. func (m *WxMutation) ResetServer() {
  28773. m.server = nil
  28774. m.clearedserver = false
  28775. }
  28776. // ClearAgent clears the "agent" edge to the Agent entity.
  28777. func (m *WxMutation) ClearAgent() {
  28778. m.clearedagent = true
  28779. m.clearedFields[wx.FieldAgentID] = struct{}{}
  28780. }
  28781. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  28782. func (m *WxMutation) AgentCleared() bool {
  28783. return m.clearedagent
  28784. }
  28785. // AgentIDs returns the "agent" edge IDs in the mutation.
  28786. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28787. // AgentID instead. It exists only for internal usage by the builders.
  28788. func (m *WxMutation) AgentIDs() (ids []uint64) {
  28789. if id := m.agent; id != nil {
  28790. ids = append(ids, *id)
  28791. }
  28792. return
  28793. }
  28794. // ResetAgent resets all changes to the "agent" edge.
  28795. func (m *WxMutation) ResetAgent() {
  28796. m.agent = nil
  28797. m.clearedagent = false
  28798. }
  28799. // Where appends a list predicates to the WxMutation builder.
  28800. func (m *WxMutation) Where(ps ...predicate.Wx) {
  28801. m.predicates = append(m.predicates, ps...)
  28802. }
  28803. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  28804. // users can use type-assertion to append predicates that do not depend on any generated package.
  28805. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  28806. p := make([]predicate.Wx, len(ps))
  28807. for i := range ps {
  28808. p[i] = ps[i]
  28809. }
  28810. m.Where(p...)
  28811. }
  28812. // Op returns the operation name.
  28813. func (m *WxMutation) Op() Op {
  28814. return m.op
  28815. }
  28816. // SetOp allows setting the mutation operation.
  28817. func (m *WxMutation) SetOp(op Op) {
  28818. m.op = op
  28819. }
  28820. // Type returns the node type of this mutation (Wx).
  28821. func (m *WxMutation) Type() string {
  28822. return m.typ
  28823. }
  28824. // Fields returns all fields that were changed during this mutation. Note that in
  28825. // order to get all numeric fields that were incremented/decremented, call
  28826. // AddedFields().
  28827. func (m *WxMutation) Fields() []string {
  28828. fields := make([]string, 0, 21)
  28829. if m.created_at != nil {
  28830. fields = append(fields, wx.FieldCreatedAt)
  28831. }
  28832. if m.updated_at != nil {
  28833. fields = append(fields, wx.FieldUpdatedAt)
  28834. }
  28835. if m.status != nil {
  28836. fields = append(fields, wx.FieldStatus)
  28837. }
  28838. if m.deleted_at != nil {
  28839. fields = append(fields, wx.FieldDeletedAt)
  28840. }
  28841. if m.server != nil {
  28842. fields = append(fields, wx.FieldServerID)
  28843. }
  28844. if m.port != nil {
  28845. fields = append(fields, wx.FieldPort)
  28846. }
  28847. if m.process_id != nil {
  28848. fields = append(fields, wx.FieldProcessID)
  28849. }
  28850. if m.callback != nil {
  28851. fields = append(fields, wx.FieldCallback)
  28852. }
  28853. if m.wxid != nil {
  28854. fields = append(fields, wx.FieldWxid)
  28855. }
  28856. if m.account != nil {
  28857. fields = append(fields, wx.FieldAccount)
  28858. }
  28859. if m.nickname != nil {
  28860. fields = append(fields, wx.FieldNickname)
  28861. }
  28862. if m.tel != nil {
  28863. fields = append(fields, wx.FieldTel)
  28864. }
  28865. if m.head_big != nil {
  28866. fields = append(fields, wx.FieldHeadBig)
  28867. }
  28868. if m.organization_id != nil {
  28869. fields = append(fields, wx.FieldOrganizationID)
  28870. }
  28871. if m.agent != nil {
  28872. fields = append(fields, wx.FieldAgentID)
  28873. }
  28874. if m.api_base != nil {
  28875. fields = append(fields, wx.FieldAPIBase)
  28876. }
  28877. if m.api_key != nil {
  28878. fields = append(fields, wx.FieldAPIKey)
  28879. }
  28880. if m.allow_list != nil {
  28881. fields = append(fields, wx.FieldAllowList)
  28882. }
  28883. if m.group_allow_list != nil {
  28884. fields = append(fields, wx.FieldGroupAllowList)
  28885. }
  28886. if m.block_list != nil {
  28887. fields = append(fields, wx.FieldBlockList)
  28888. }
  28889. if m.group_block_list != nil {
  28890. fields = append(fields, wx.FieldGroupBlockList)
  28891. }
  28892. return fields
  28893. }
  28894. // Field returns the value of a field with the given name. The second boolean
  28895. // return value indicates that this field was not set, or was not defined in the
  28896. // schema.
  28897. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  28898. switch name {
  28899. case wx.FieldCreatedAt:
  28900. return m.CreatedAt()
  28901. case wx.FieldUpdatedAt:
  28902. return m.UpdatedAt()
  28903. case wx.FieldStatus:
  28904. return m.Status()
  28905. case wx.FieldDeletedAt:
  28906. return m.DeletedAt()
  28907. case wx.FieldServerID:
  28908. return m.ServerID()
  28909. case wx.FieldPort:
  28910. return m.Port()
  28911. case wx.FieldProcessID:
  28912. return m.ProcessID()
  28913. case wx.FieldCallback:
  28914. return m.Callback()
  28915. case wx.FieldWxid:
  28916. return m.Wxid()
  28917. case wx.FieldAccount:
  28918. return m.Account()
  28919. case wx.FieldNickname:
  28920. return m.Nickname()
  28921. case wx.FieldTel:
  28922. return m.Tel()
  28923. case wx.FieldHeadBig:
  28924. return m.HeadBig()
  28925. case wx.FieldOrganizationID:
  28926. return m.OrganizationID()
  28927. case wx.FieldAgentID:
  28928. return m.AgentID()
  28929. case wx.FieldAPIBase:
  28930. return m.APIBase()
  28931. case wx.FieldAPIKey:
  28932. return m.APIKey()
  28933. case wx.FieldAllowList:
  28934. return m.AllowList()
  28935. case wx.FieldGroupAllowList:
  28936. return m.GroupAllowList()
  28937. case wx.FieldBlockList:
  28938. return m.BlockList()
  28939. case wx.FieldGroupBlockList:
  28940. return m.GroupBlockList()
  28941. }
  28942. return nil, false
  28943. }
  28944. // OldField returns the old value of the field from the database. An error is
  28945. // returned if the mutation operation is not UpdateOne, or the query to the
  28946. // database failed.
  28947. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28948. switch name {
  28949. case wx.FieldCreatedAt:
  28950. return m.OldCreatedAt(ctx)
  28951. case wx.FieldUpdatedAt:
  28952. return m.OldUpdatedAt(ctx)
  28953. case wx.FieldStatus:
  28954. return m.OldStatus(ctx)
  28955. case wx.FieldDeletedAt:
  28956. return m.OldDeletedAt(ctx)
  28957. case wx.FieldServerID:
  28958. return m.OldServerID(ctx)
  28959. case wx.FieldPort:
  28960. return m.OldPort(ctx)
  28961. case wx.FieldProcessID:
  28962. return m.OldProcessID(ctx)
  28963. case wx.FieldCallback:
  28964. return m.OldCallback(ctx)
  28965. case wx.FieldWxid:
  28966. return m.OldWxid(ctx)
  28967. case wx.FieldAccount:
  28968. return m.OldAccount(ctx)
  28969. case wx.FieldNickname:
  28970. return m.OldNickname(ctx)
  28971. case wx.FieldTel:
  28972. return m.OldTel(ctx)
  28973. case wx.FieldHeadBig:
  28974. return m.OldHeadBig(ctx)
  28975. case wx.FieldOrganizationID:
  28976. return m.OldOrganizationID(ctx)
  28977. case wx.FieldAgentID:
  28978. return m.OldAgentID(ctx)
  28979. case wx.FieldAPIBase:
  28980. return m.OldAPIBase(ctx)
  28981. case wx.FieldAPIKey:
  28982. return m.OldAPIKey(ctx)
  28983. case wx.FieldAllowList:
  28984. return m.OldAllowList(ctx)
  28985. case wx.FieldGroupAllowList:
  28986. return m.OldGroupAllowList(ctx)
  28987. case wx.FieldBlockList:
  28988. return m.OldBlockList(ctx)
  28989. case wx.FieldGroupBlockList:
  28990. return m.OldGroupBlockList(ctx)
  28991. }
  28992. return nil, fmt.Errorf("unknown Wx field %s", name)
  28993. }
  28994. // SetField sets the value of a field with the given name. It returns an error if
  28995. // the field is not defined in the schema, or if the type mismatched the field
  28996. // type.
  28997. func (m *WxMutation) SetField(name string, value ent.Value) error {
  28998. switch name {
  28999. case wx.FieldCreatedAt:
  29000. v, ok := value.(time.Time)
  29001. if !ok {
  29002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29003. }
  29004. m.SetCreatedAt(v)
  29005. return nil
  29006. case wx.FieldUpdatedAt:
  29007. v, ok := value.(time.Time)
  29008. if !ok {
  29009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29010. }
  29011. m.SetUpdatedAt(v)
  29012. return nil
  29013. case wx.FieldStatus:
  29014. v, ok := value.(uint8)
  29015. if !ok {
  29016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29017. }
  29018. m.SetStatus(v)
  29019. return nil
  29020. case wx.FieldDeletedAt:
  29021. v, ok := value.(time.Time)
  29022. if !ok {
  29023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29024. }
  29025. m.SetDeletedAt(v)
  29026. return nil
  29027. case wx.FieldServerID:
  29028. v, ok := value.(uint64)
  29029. if !ok {
  29030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29031. }
  29032. m.SetServerID(v)
  29033. return nil
  29034. case wx.FieldPort:
  29035. v, ok := value.(string)
  29036. if !ok {
  29037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29038. }
  29039. m.SetPort(v)
  29040. return nil
  29041. case wx.FieldProcessID:
  29042. v, ok := value.(string)
  29043. if !ok {
  29044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29045. }
  29046. m.SetProcessID(v)
  29047. return nil
  29048. case wx.FieldCallback:
  29049. v, ok := value.(string)
  29050. if !ok {
  29051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29052. }
  29053. m.SetCallback(v)
  29054. return nil
  29055. case wx.FieldWxid:
  29056. v, ok := value.(string)
  29057. if !ok {
  29058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29059. }
  29060. m.SetWxid(v)
  29061. return nil
  29062. case wx.FieldAccount:
  29063. v, ok := value.(string)
  29064. if !ok {
  29065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29066. }
  29067. m.SetAccount(v)
  29068. return nil
  29069. case wx.FieldNickname:
  29070. v, ok := value.(string)
  29071. if !ok {
  29072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29073. }
  29074. m.SetNickname(v)
  29075. return nil
  29076. case wx.FieldTel:
  29077. v, ok := value.(string)
  29078. if !ok {
  29079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29080. }
  29081. m.SetTel(v)
  29082. return nil
  29083. case wx.FieldHeadBig:
  29084. v, ok := value.(string)
  29085. if !ok {
  29086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29087. }
  29088. m.SetHeadBig(v)
  29089. return nil
  29090. case wx.FieldOrganizationID:
  29091. v, ok := value.(uint64)
  29092. if !ok {
  29093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29094. }
  29095. m.SetOrganizationID(v)
  29096. return nil
  29097. case wx.FieldAgentID:
  29098. v, ok := value.(uint64)
  29099. if !ok {
  29100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29101. }
  29102. m.SetAgentID(v)
  29103. return nil
  29104. case wx.FieldAPIBase:
  29105. v, ok := value.(string)
  29106. if !ok {
  29107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29108. }
  29109. m.SetAPIBase(v)
  29110. return nil
  29111. case wx.FieldAPIKey:
  29112. v, ok := value.(string)
  29113. if !ok {
  29114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29115. }
  29116. m.SetAPIKey(v)
  29117. return nil
  29118. case wx.FieldAllowList:
  29119. v, ok := value.([]string)
  29120. if !ok {
  29121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29122. }
  29123. m.SetAllowList(v)
  29124. return nil
  29125. case wx.FieldGroupAllowList:
  29126. v, ok := value.([]string)
  29127. if !ok {
  29128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29129. }
  29130. m.SetGroupAllowList(v)
  29131. return nil
  29132. case wx.FieldBlockList:
  29133. v, ok := value.([]string)
  29134. if !ok {
  29135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29136. }
  29137. m.SetBlockList(v)
  29138. return nil
  29139. case wx.FieldGroupBlockList:
  29140. v, ok := value.([]string)
  29141. if !ok {
  29142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29143. }
  29144. m.SetGroupBlockList(v)
  29145. return nil
  29146. }
  29147. return fmt.Errorf("unknown Wx field %s", name)
  29148. }
  29149. // AddedFields returns all numeric fields that were incremented/decremented during
  29150. // this mutation.
  29151. func (m *WxMutation) AddedFields() []string {
  29152. var fields []string
  29153. if m.addstatus != nil {
  29154. fields = append(fields, wx.FieldStatus)
  29155. }
  29156. if m.addorganization_id != nil {
  29157. fields = append(fields, wx.FieldOrganizationID)
  29158. }
  29159. return fields
  29160. }
  29161. // AddedField returns the numeric value that was incremented/decremented on a field
  29162. // with the given name. The second boolean return value indicates that this field
  29163. // was not set, or was not defined in the schema.
  29164. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  29165. switch name {
  29166. case wx.FieldStatus:
  29167. return m.AddedStatus()
  29168. case wx.FieldOrganizationID:
  29169. return m.AddedOrganizationID()
  29170. }
  29171. return nil, false
  29172. }
  29173. // AddField adds the value to the field with the given name. It returns an error if
  29174. // the field is not defined in the schema, or if the type mismatched the field
  29175. // type.
  29176. func (m *WxMutation) AddField(name string, value ent.Value) error {
  29177. switch name {
  29178. case wx.FieldStatus:
  29179. v, ok := value.(int8)
  29180. if !ok {
  29181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29182. }
  29183. m.AddStatus(v)
  29184. return nil
  29185. case wx.FieldOrganizationID:
  29186. v, ok := value.(int64)
  29187. if !ok {
  29188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29189. }
  29190. m.AddOrganizationID(v)
  29191. return nil
  29192. }
  29193. return fmt.Errorf("unknown Wx numeric field %s", name)
  29194. }
  29195. // ClearedFields returns all nullable fields that were cleared during this
  29196. // mutation.
  29197. func (m *WxMutation) ClearedFields() []string {
  29198. var fields []string
  29199. if m.FieldCleared(wx.FieldStatus) {
  29200. fields = append(fields, wx.FieldStatus)
  29201. }
  29202. if m.FieldCleared(wx.FieldDeletedAt) {
  29203. fields = append(fields, wx.FieldDeletedAt)
  29204. }
  29205. if m.FieldCleared(wx.FieldServerID) {
  29206. fields = append(fields, wx.FieldServerID)
  29207. }
  29208. if m.FieldCleared(wx.FieldOrganizationID) {
  29209. fields = append(fields, wx.FieldOrganizationID)
  29210. }
  29211. if m.FieldCleared(wx.FieldAPIBase) {
  29212. fields = append(fields, wx.FieldAPIBase)
  29213. }
  29214. if m.FieldCleared(wx.FieldAPIKey) {
  29215. fields = append(fields, wx.FieldAPIKey)
  29216. }
  29217. return fields
  29218. }
  29219. // FieldCleared returns a boolean indicating if a field with the given name was
  29220. // cleared in this mutation.
  29221. func (m *WxMutation) FieldCleared(name string) bool {
  29222. _, ok := m.clearedFields[name]
  29223. return ok
  29224. }
  29225. // ClearField clears the value of the field with the given name. It returns an
  29226. // error if the field is not defined in the schema.
  29227. func (m *WxMutation) ClearField(name string) error {
  29228. switch name {
  29229. case wx.FieldStatus:
  29230. m.ClearStatus()
  29231. return nil
  29232. case wx.FieldDeletedAt:
  29233. m.ClearDeletedAt()
  29234. return nil
  29235. case wx.FieldServerID:
  29236. m.ClearServerID()
  29237. return nil
  29238. case wx.FieldOrganizationID:
  29239. m.ClearOrganizationID()
  29240. return nil
  29241. case wx.FieldAPIBase:
  29242. m.ClearAPIBase()
  29243. return nil
  29244. case wx.FieldAPIKey:
  29245. m.ClearAPIKey()
  29246. return nil
  29247. }
  29248. return fmt.Errorf("unknown Wx nullable field %s", name)
  29249. }
  29250. // ResetField resets all changes in the mutation for the field with the given name.
  29251. // It returns an error if the field is not defined in the schema.
  29252. func (m *WxMutation) ResetField(name string) error {
  29253. switch name {
  29254. case wx.FieldCreatedAt:
  29255. m.ResetCreatedAt()
  29256. return nil
  29257. case wx.FieldUpdatedAt:
  29258. m.ResetUpdatedAt()
  29259. return nil
  29260. case wx.FieldStatus:
  29261. m.ResetStatus()
  29262. return nil
  29263. case wx.FieldDeletedAt:
  29264. m.ResetDeletedAt()
  29265. return nil
  29266. case wx.FieldServerID:
  29267. m.ResetServerID()
  29268. return nil
  29269. case wx.FieldPort:
  29270. m.ResetPort()
  29271. return nil
  29272. case wx.FieldProcessID:
  29273. m.ResetProcessID()
  29274. return nil
  29275. case wx.FieldCallback:
  29276. m.ResetCallback()
  29277. return nil
  29278. case wx.FieldWxid:
  29279. m.ResetWxid()
  29280. return nil
  29281. case wx.FieldAccount:
  29282. m.ResetAccount()
  29283. return nil
  29284. case wx.FieldNickname:
  29285. m.ResetNickname()
  29286. return nil
  29287. case wx.FieldTel:
  29288. m.ResetTel()
  29289. return nil
  29290. case wx.FieldHeadBig:
  29291. m.ResetHeadBig()
  29292. return nil
  29293. case wx.FieldOrganizationID:
  29294. m.ResetOrganizationID()
  29295. return nil
  29296. case wx.FieldAgentID:
  29297. m.ResetAgentID()
  29298. return nil
  29299. case wx.FieldAPIBase:
  29300. m.ResetAPIBase()
  29301. return nil
  29302. case wx.FieldAPIKey:
  29303. m.ResetAPIKey()
  29304. return nil
  29305. case wx.FieldAllowList:
  29306. m.ResetAllowList()
  29307. return nil
  29308. case wx.FieldGroupAllowList:
  29309. m.ResetGroupAllowList()
  29310. return nil
  29311. case wx.FieldBlockList:
  29312. m.ResetBlockList()
  29313. return nil
  29314. case wx.FieldGroupBlockList:
  29315. m.ResetGroupBlockList()
  29316. return nil
  29317. }
  29318. return fmt.Errorf("unknown Wx field %s", name)
  29319. }
  29320. // AddedEdges returns all edge names that were set/added in this mutation.
  29321. func (m *WxMutation) AddedEdges() []string {
  29322. edges := make([]string, 0, 2)
  29323. if m.server != nil {
  29324. edges = append(edges, wx.EdgeServer)
  29325. }
  29326. if m.agent != nil {
  29327. edges = append(edges, wx.EdgeAgent)
  29328. }
  29329. return edges
  29330. }
  29331. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29332. // name in this mutation.
  29333. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  29334. switch name {
  29335. case wx.EdgeServer:
  29336. if id := m.server; id != nil {
  29337. return []ent.Value{*id}
  29338. }
  29339. case wx.EdgeAgent:
  29340. if id := m.agent; id != nil {
  29341. return []ent.Value{*id}
  29342. }
  29343. }
  29344. return nil
  29345. }
  29346. // RemovedEdges returns all edge names that were removed in this mutation.
  29347. func (m *WxMutation) RemovedEdges() []string {
  29348. edges := make([]string, 0, 2)
  29349. return edges
  29350. }
  29351. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29352. // the given name in this mutation.
  29353. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  29354. return nil
  29355. }
  29356. // ClearedEdges returns all edge names that were cleared in this mutation.
  29357. func (m *WxMutation) ClearedEdges() []string {
  29358. edges := make([]string, 0, 2)
  29359. if m.clearedserver {
  29360. edges = append(edges, wx.EdgeServer)
  29361. }
  29362. if m.clearedagent {
  29363. edges = append(edges, wx.EdgeAgent)
  29364. }
  29365. return edges
  29366. }
  29367. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29368. // was cleared in this mutation.
  29369. func (m *WxMutation) EdgeCleared(name string) bool {
  29370. switch name {
  29371. case wx.EdgeServer:
  29372. return m.clearedserver
  29373. case wx.EdgeAgent:
  29374. return m.clearedagent
  29375. }
  29376. return false
  29377. }
  29378. // ClearEdge clears the value of the edge with the given name. It returns an error
  29379. // if that edge is not defined in the schema.
  29380. func (m *WxMutation) ClearEdge(name string) error {
  29381. switch name {
  29382. case wx.EdgeServer:
  29383. m.ClearServer()
  29384. return nil
  29385. case wx.EdgeAgent:
  29386. m.ClearAgent()
  29387. return nil
  29388. }
  29389. return fmt.Errorf("unknown Wx unique edge %s", name)
  29390. }
  29391. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29392. // It returns an error if the edge is not defined in the schema.
  29393. func (m *WxMutation) ResetEdge(name string) error {
  29394. switch name {
  29395. case wx.EdgeServer:
  29396. m.ResetServer()
  29397. return nil
  29398. case wx.EdgeAgent:
  29399. m.ResetAgent()
  29400. return nil
  29401. }
  29402. return fmt.Errorf("unknown Wx edge %s", name)
  29403. }
  29404. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  29405. type WxCardMutation struct {
  29406. config
  29407. op Op
  29408. typ string
  29409. id *uint64
  29410. created_at *time.Time
  29411. updated_at *time.Time
  29412. deleted_at *time.Time
  29413. user_id *uint64
  29414. adduser_id *int64
  29415. wx_user_id *uint64
  29416. addwx_user_id *int64
  29417. avatar *string
  29418. logo *string
  29419. name *string
  29420. company *string
  29421. address *string
  29422. phone *string
  29423. official_account *string
  29424. wechat_account *string
  29425. email *string
  29426. api_base *string
  29427. api_key *string
  29428. ai_info *string
  29429. intro *string
  29430. clearedFields map[string]struct{}
  29431. done bool
  29432. oldValue func(context.Context) (*WxCard, error)
  29433. predicates []predicate.WxCard
  29434. }
  29435. var _ ent.Mutation = (*WxCardMutation)(nil)
  29436. // wxcardOption allows management of the mutation configuration using functional options.
  29437. type wxcardOption func(*WxCardMutation)
  29438. // newWxCardMutation creates new mutation for the WxCard entity.
  29439. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  29440. m := &WxCardMutation{
  29441. config: c,
  29442. op: op,
  29443. typ: TypeWxCard,
  29444. clearedFields: make(map[string]struct{}),
  29445. }
  29446. for _, opt := range opts {
  29447. opt(m)
  29448. }
  29449. return m
  29450. }
  29451. // withWxCardID sets the ID field of the mutation.
  29452. func withWxCardID(id uint64) wxcardOption {
  29453. return func(m *WxCardMutation) {
  29454. var (
  29455. err error
  29456. once sync.Once
  29457. value *WxCard
  29458. )
  29459. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  29460. once.Do(func() {
  29461. if m.done {
  29462. err = errors.New("querying old values post mutation is not allowed")
  29463. } else {
  29464. value, err = m.Client().WxCard.Get(ctx, id)
  29465. }
  29466. })
  29467. return value, err
  29468. }
  29469. m.id = &id
  29470. }
  29471. }
  29472. // withWxCard sets the old WxCard of the mutation.
  29473. func withWxCard(node *WxCard) wxcardOption {
  29474. return func(m *WxCardMutation) {
  29475. m.oldValue = func(context.Context) (*WxCard, error) {
  29476. return node, nil
  29477. }
  29478. m.id = &node.ID
  29479. }
  29480. }
  29481. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29482. // executed in a transaction (ent.Tx), a transactional client is returned.
  29483. func (m WxCardMutation) Client() *Client {
  29484. client := &Client{config: m.config}
  29485. client.init()
  29486. return client
  29487. }
  29488. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29489. // it returns an error otherwise.
  29490. func (m WxCardMutation) Tx() (*Tx, error) {
  29491. if _, ok := m.driver.(*txDriver); !ok {
  29492. return nil, errors.New("ent: mutation is not running in a transaction")
  29493. }
  29494. tx := &Tx{config: m.config}
  29495. tx.init()
  29496. return tx, nil
  29497. }
  29498. // SetID sets the value of the id field. Note that this
  29499. // operation is only accepted on creation of WxCard entities.
  29500. func (m *WxCardMutation) SetID(id uint64) {
  29501. m.id = &id
  29502. }
  29503. // ID returns the ID value in the mutation. Note that the ID is only available
  29504. // if it was provided to the builder or after it was returned from the database.
  29505. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  29506. if m.id == nil {
  29507. return
  29508. }
  29509. return *m.id, true
  29510. }
  29511. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29512. // That means, if the mutation is applied within a transaction with an isolation level such
  29513. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29514. // or updated by the mutation.
  29515. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  29516. switch {
  29517. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29518. id, exists := m.ID()
  29519. if exists {
  29520. return []uint64{id}, nil
  29521. }
  29522. fallthrough
  29523. case m.op.Is(OpUpdate | OpDelete):
  29524. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  29525. default:
  29526. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29527. }
  29528. }
  29529. // SetCreatedAt sets the "created_at" field.
  29530. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  29531. m.created_at = &t
  29532. }
  29533. // CreatedAt returns the value of the "created_at" field in the mutation.
  29534. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  29535. v := m.created_at
  29536. if v == nil {
  29537. return
  29538. }
  29539. return *v, true
  29540. }
  29541. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  29542. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29544. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29545. if !m.op.Is(OpUpdateOne) {
  29546. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29547. }
  29548. if m.id == nil || m.oldValue == nil {
  29549. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29550. }
  29551. oldValue, err := m.oldValue(ctx)
  29552. if err != nil {
  29553. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29554. }
  29555. return oldValue.CreatedAt, nil
  29556. }
  29557. // ResetCreatedAt resets all changes to the "created_at" field.
  29558. func (m *WxCardMutation) ResetCreatedAt() {
  29559. m.created_at = nil
  29560. }
  29561. // SetUpdatedAt sets the "updated_at" field.
  29562. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  29563. m.updated_at = &t
  29564. }
  29565. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29566. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  29567. v := m.updated_at
  29568. if v == nil {
  29569. return
  29570. }
  29571. return *v, true
  29572. }
  29573. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  29574. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29576. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29577. if !m.op.Is(OpUpdateOne) {
  29578. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29579. }
  29580. if m.id == nil || m.oldValue == nil {
  29581. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29582. }
  29583. oldValue, err := m.oldValue(ctx)
  29584. if err != nil {
  29585. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29586. }
  29587. return oldValue.UpdatedAt, nil
  29588. }
  29589. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29590. func (m *WxCardMutation) ResetUpdatedAt() {
  29591. m.updated_at = nil
  29592. }
  29593. // SetDeletedAt sets the "deleted_at" field.
  29594. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  29595. m.deleted_at = &t
  29596. }
  29597. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29598. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  29599. v := m.deleted_at
  29600. if v == nil {
  29601. return
  29602. }
  29603. return *v, true
  29604. }
  29605. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  29606. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29608. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29609. if !m.op.Is(OpUpdateOne) {
  29610. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29611. }
  29612. if m.id == nil || m.oldValue == nil {
  29613. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29614. }
  29615. oldValue, err := m.oldValue(ctx)
  29616. if err != nil {
  29617. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29618. }
  29619. return oldValue.DeletedAt, nil
  29620. }
  29621. // ClearDeletedAt clears the value of the "deleted_at" field.
  29622. func (m *WxCardMutation) ClearDeletedAt() {
  29623. m.deleted_at = nil
  29624. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  29625. }
  29626. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29627. func (m *WxCardMutation) DeletedAtCleared() bool {
  29628. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  29629. return ok
  29630. }
  29631. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29632. func (m *WxCardMutation) ResetDeletedAt() {
  29633. m.deleted_at = nil
  29634. delete(m.clearedFields, wxcard.FieldDeletedAt)
  29635. }
  29636. // SetUserID sets the "user_id" field.
  29637. func (m *WxCardMutation) SetUserID(u uint64) {
  29638. m.user_id = &u
  29639. m.adduser_id = nil
  29640. }
  29641. // UserID returns the value of the "user_id" field in the mutation.
  29642. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  29643. v := m.user_id
  29644. if v == nil {
  29645. return
  29646. }
  29647. return *v, true
  29648. }
  29649. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  29650. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29652. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  29653. if !m.op.Is(OpUpdateOne) {
  29654. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  29655. }
  29656. if m.id == nil || m.oldValue == nil {
  29657. return v, errors.New("OldUserID requires an ID field in the mutation")
  29658. }
  29659. oldValue, err := m.oldValue(ctx)
  29660. if err != nil {
  29661. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  29662. }
  29663. return oldValue.UserID, nil
  29664. }
  29665. // AddUserID adds u to the "user_id" field.
  29666. func (m *WxCardMutation) AddUserID(u int64) {
  29667. if m.adduser_id != nil {
  29668. *m.adduser_id += u
  29669. } else {
  29670. m.adduser_id = &u
  29671. }
  29672. }
  29673. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  29674. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  29675. v := m.adduser_id
  29676. if v == nil {
  29677. return
  29678. }
  29679. return *v, true
  29680. }
  29681. // ClearUserID clears the value of the "user_id" field.
  29682. func (m *WxCardMutation) ClearUserID() {
  29683. m.user_id = nil
  29684. m.adduser_id = nil
  29685. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  29686. }
  29687. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  29688. func (m *WxCardMutation) UserIDCleared() bool {
  29689. _, ok := m.clearedFields[wxcard.FieldUserID]
  29690. return ok
  29691. }
  29692. // ResetUserID resets all changes to the "user_id" field.
  29693. func (m *WxCardMutation) ResetUserID() {
  29694. m.user_id = nil
  29695. m.adduser_id = nil
  29696. delete(m.clearedFields, wxcard.FieldUserID)
  29697. }
  29698. // SetWxUserID sets the "wx_user_id" field.
  29699. func (m *WxCardMutation) SetWxUserID(u uint64) {
  29700. m.wx_user_id = &u
  29701. m.addwx_user_id = nil
  29702. }
  29703. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  29704. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  29705. v := m.wx_user_id
  29706. if v == nil {
  29707. return
  29708. }
  29709. return *v, true
  29710. }
  29711. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  29712. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29714. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  29715. if !m.op.Is(OpUpdateOne) {
  29716. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  29717. }
  29718. if m.id == nil || m.oldValue == nil {
  29719. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  29720. }
  29721. oldValue, err := m.oldValue(ctx)
  29722. if err != nil {
  29723. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  29724. }
  29725. return oldValue.WxUserID, nil
  29726. }
  29727. // AddWxUserID adds u to the "wx_user_id" field.
  29728. func (m *WxCardMutation) AddWxUserID(u int64) {
  29729. if m.addwx_user_id != nil {
  29730. *m.addwx_user_id += u
  29731. } else {
  29732. m.addwx_user_id = &u
  29733. }
  29734. }
  29735. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  29736. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  29737. v := m.addwx_user_id
  29738. if v == nil {
  29739. return
  29740. }
  29741. return *v, true
  29742. }
  29743. // ClearWxUserID clears the value of the "wx_user_id" field.
  29744. func (m *WxCardMutation) ClearWxUserID() {
  29745. m.wx_user_id = nil
  29746. m.addwx_user_id = nil
  29747. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  29748. }
  29749. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  29750. func (m *WxCardMutation) WxUserIDCleared() bool {
  29751. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  29752. return ok
  29753. }
  29754. // ResetWxUserID resets all changes to the "wx_user_id" field.
  29755. func (m *WxCardMutation) ResetWxUserID() {
  29756. m.wx_user_id = nil
  29757. m.addwx_user_id = nil
  29758. delete(m.clearedFields, wxcard.FieldWxUserID)
  29759. }
  29760. // SetAvatar sets the "avatar" field.
  29761. func (m *WxCardMutation) SetAvatar(s string) {
  29762. m.avatar = &s
  29763. }
  29764. // Avatar returns the value of the "avatar" field in the mutation.
  29765. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  29766. v := m.avatar
  29767. if v == nil {
  29768. return
  29769. }
  29770. return *v, true
  29771. }
  29772. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  29773. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29775. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  29776. if !m.op.Is(OpUpdateOne) {
  29777. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  29778. }
  29779. if m.id == nil || m.oldValue == nil {
  29780. return v, errors.New("OldAvatar requires an ID field in the mutation")
  29781. }
  29782. oldValue, err := m.oldValue(ctx)
  29783. if err != nil {
  29784. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  29785. }
  29786. return oldValue.Avatar, nil
  29787. }
  29788. // ResetAvatar resets all changes to the "avatar" field.
  29789. func (m *WxCardMutation) ResetAvatar() {
  29790. m.avatar = nil
  29791. }
  29792. // SetLogo sets the "logo" field.
  29793. func (m *WxCardMutation) SetLogo(s string) {
  29794. m.logo = &s
  29795. }
  29796. // Logo returns the value of the "logo" field in the mutation.
  29797. func (m *WxCardMutation) Logo() (r string, exists bool) {
  29798. v := m.logo
  29799. if v == nil {
  29800. return
  29801. }
  29802. return *v, true
  29803. }
  29804. // OldLogo returns the old "logo" field's value of the WxCard entity.
  29805. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29807. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  29808. if !m.op.Is(OpUpdateOne) {
  29809. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  29810. }
  29811. if m.id == nil || m.oldValue == nil {
  29812. return v, errors.New("OldLogo requires an ID field in the mutation")
  29813. }
  29814. oldValue, err := m.oldValue(ctx)
  29815. if err != nil {
  29816. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  29817. }
  29818. return oldValue.Logo, nil
  29819. }
  29820. // ResetLogo resets all changes to the "logo" field.
  29821. func (m *WxCardMutation) ResetLogo() {
  29822. m.logo = nil
  29823. }
  29824. // SetName sets the "name" field.
  29825. func (m *WxCardMutation) SetName(s string) {
  29826. m.name = &s
  29827. }
  29828. // Name returns the value of the "name" field in the mutation.
  29829. func (m *WxCardMutation) Name() (r string, exists bool) {
  29830. v := m.name
  29831. if v == nil {
  29832. return
  29833. }
  29834. return *v, true
  29835. }
  29836. // OldName returns the old "name" field's value of the WxCard entity.
  29837. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29839. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  29840. if !m.op.Is(OpUpdateOne) {
  29841. return v, errors.New("OldName is only allowed on UpdateOne operations")
  29842. }
  29843. if m.id == nil || m.oldValue == nil {
  29844. return v, errors.New("OldName requires an ID field in the mutation")
  29845. }
  29846. oldValue, err := m.oldValue(ctx)
  29847. if err != nil {
  29848. return v, fmt.Errorf("querying old value for OldName: %w", err)
  29849. }
  29850. return oldValue.Name, nil
  29851. }
  29852. // ResetName resets all changes to the "name" field.
  29853. func (m *WxCardMutation) ResetName() {
  29854. m.name = nil
  29855. }
  29856. // SetCompany sets the "company" field.
  29857. func (m *WxCardMutation) SetCompany(s string) {
  29858. m.company = &s
  29859. }
  29860. // Company returns the value of the "company" field in the mutation.
  29861. func (m *WxCardMutation) Company() (r string, exists bool) {
  29862. v := m.company
  29863. if v == nil {
  29864. return
  29865. }
  29866. return *v, true
  29867. }
  29868. // OldCompany returns the old "company" field's value of the WxCard entity.
  29869. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29871. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  29872. if !m.op.Is(OpUpdateOne) {
  29873. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  29874. }
  29875. if m.id == nil || m.oldValue == nil {
  29876. return v, errors.New("OldCompany requires an ID field in the mutation")
  29877. }
  29878. oldValue, err := m.oldValue(ctx)
  29879. if err != nil {
  29880. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  29881. }
  29882. return oldValue.Company, nil
  29883. }
  29884. // ResetCompany resets all changes to the "company" field.
  29885. func (m *WxCardMutation) ResetCompany() {
  29886. m.company = nil
  29887. }
  29888. // SetAddress sets the "address" field.
  29889. func (m *WxCardMutation) SetAddress(s string) {
  29890. m.address = &s
  29891. }
  29892. // Address returns the value of the "address" field in the mutation.
  29893. func (m *WxCardMutation) Address() (r string, exists bool) {
  29894. v := m.address
  29895. if v == nil {
  29896. return
  29897. }
  29898. return *v, true
  29899. }
  29900. // OldAddress returns the old "address" field's value of the WxCard entity.
  29901. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29903. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  29904. if !m.op.Is(OpUpdateOne) {
  29905. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  29906. }
  29907. if m.id == nil || m.oldValue == nil {
  29908. return v, errors.New("OldAddress requires an ID field in the mutation")
  29909. }
  29910. oldValue, err := m.oldValue(ctx)
  29911. if err != nil {
  29912. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  29913. }
  29914. return oldValue.Address, nil
  29915. }
  29916. // ResetAddress resets all changes to the "address" field.
  29917. func (m *WxCardMutation) ResetAddress() {
  29918. m.address = nil
  29919. }
  29920. // SetPhone sets the "phone" field.
  29921. func (m *WxCardMutation) SetPhone(s string) {
  29922. m.phone = &s
  29923. }
  29924. // Phone returns the value of the "phone" field in the mutation.
  29925. func (m *WxCardMutation) Phone() (r string, exists bool) {
  29926. v := m.phone
  29927. if v == nil {
  29928. return
  29929. }
  29930. return *v, true
  29931. }
  29932. // OldPhone returns the old "phone" field's value of the WxCard entity.
  29933. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29935. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  29936. if !m.op.Is(OpUpdateOne) {
  29937. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  29938. }
  29939. if m.id == nil || m.oldValue == nil {
  29940. return v, errors.New("OldPhone requires an ID field in the mutation")
  29941. }
  29942. oldValue, err := m.oldValue(ctx)
  29943. if err != nil {
  29944. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  29945. }
  29946. return oldValue.Phone, nil
  29947. }
  29948. // ResetPhone resets all changes to the "phone" field.
  29949. func (m *WxCardMutation) ResetPhone() {
  29950. m.phone = nil
  29951. }
  29952. // SetOfficialAccount sets the "official_account" field.
  29953. func (m *WxCardMutation) SetOfficialAccount(s string) {
  29954. m.official_account = &s
  29955. }
  29956. // OfficialAccount returns the value of the "official_account" field in the mutation.
  29957. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  29958. v := m.official_account
  29959. if v == nil {
  29960. return
  29961. }
  29962. return *v, true
  29963. }
  29964. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  29965. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29967. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  29968. if !m.op.Is(OpUpdateOne) {
  29969. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  29970. }
  29971. if m.id == nil || m.oldValue == nil {
  29972. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  29973. }
  29974. oldValue, err := m.oldValue(ctx)
  29975. if err != nil {
  29976. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  29977. }
  29978. return oldValue.OfficialAccount, nil
  29979. }
  29980. // ResetOfficialAccount resets all changes to the "official_account" field.
  29981. func (m *WxCardMutation) ResetOfficialAccount() {
  29982. m.official_account = nil
  29983. }
  29984. // SetWechatAccount sets the "wechat_account" field.
  29985. func (m *WxCardMutation) SetWechatAccount(s string) {
  29986. m.wechat_account = &s
  29987. }
  29988. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  29989. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  29990. v := m.wechat_account
  29991. if v == nil {
  29992. return
  29993. }
  29994. return *v, true
  29995. }
  29996. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  29997. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29999. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  30000. if !m.op.Is(OpUpdateOne) {
  30001. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  30002. }
  30003. if m.id == nil || m.oldValue == nil {
  30004. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  30005. }
  30006. oldValue, err := m.oldValue(ctx)
  30007. if err != nil {
  30008. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  30009. }
  30010. return oldValue.WechatAccount, nil
  30011. }
  30012. // ResetWechatAccount resets all changes to the "wechat_account" field.
  30013. func (m *WxCardMutation) ResetWechatAccount() {
  30014. m.wechat_account = nil
  30015. }
  30016. // SetEmail sets the "email" field.
  30017. func (m *WxCardMutation) SetEmail(s string) {
  30018. m.email = &s
  30019. }
  30020. // Email returns the value of the "email" field in the mutation.
  30021. func (m *WxCardMutation) Email() (r string, exists bool) {
  30022. v := m.email
  30023. if v == nil {
  30024. return
  30025. }
  30026. return *v, true
  30027. }
  30028. // OldEmail returns the old "email" field's value of the WxCard entity.
  30029. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  30030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30031. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  30032. if !m.op.Is(OpUpdateOne) {
  30033. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  30034. }
  30035. if m.id == nil || m.oldValue == nil {
  30036. return v, errors.New("OldEmail requires an ID field in the mutation")
  30037. }
  30038. oldValue, err := m.oldValue(ctx)
  30039. if err != nil {
  30040. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  30041. }
  30042. return oldValue.Email, nil
  30043. }
  30044. // ClearEmail clears the value of the "email" field.
  30045. func (m *WxCardMutation) ClearEmail() {
  30046. m.email = nil
  30047. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  30048. }
  30049. // EmailCleared returns if the "email" field was cleared in this mutation.
  30050. func (m *WxCardMutation) EmailCleared() bool {
  30051. _, ok := m.clearedFields[wxcard.FieldEmail]
  30052. return ok
  30053. }
  30054. // ResetEmail resets all changes to the "email" field.
  30055. func (m *WxCardMutation) ResetEmail() {
  30056. m.email = nil
  30057. delete(m.clearedFields, wxcard.FieldEmail)
  30058. }
  30059. // SetAPIBase sets the "api_base" field.
  30060. func (m *WxCardMutation) SetAPIBase(s string) {
  30061. m.api_base = &s
  30062. }
  30063. // APIBase returns the value of the "api_base" field in the mutation.
  30064. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  30065. v := m.api_base
  30066. if v == nil {
  30067. return
  30068. }
  30069. return *v, true
  30070. }
  30071. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  30072. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  30073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30074. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  30075. if !m.op.Is(OpUpdateOne) {
  30076. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  30077. }
  30078. if m.id == nil || m.oldValue == nil {
  30079. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  30080. }
  30081. oldValue, err := m.oldValue(ctx)
  30082. if err != nil {
  30083. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  30084. }
  30085. return oldValue.APIBase, nil
  30086. }
  30087. // ClearAPIBase clears the value of the "api_base" field.
  30088. func (m *WxCardMutation) ClearAPIBase() {
  30089. m.api_base = nil
  30090. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  30091. }
  30092. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  30093. func (m *WxCardMutation) APIBaseCleared() bool {
  30094. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  30095. return ok
  30096. }
  30097. // ResetAPIBase resets all changes to the "api_base" field.
  30098. func (m *WxCardMutation) ResetAPIBase() {
  30099. m.api_base = nil
  30100. delete(m.clearedFields, wxcard.FieldAPIBase)
  30101. }
  30102. // SetAPIKey sets the "api_key" field.
  30103. func (m *WxCardMutation) SetAPIKey(s string) {
  30104. m.api_key = &s
  30105. }
  30106. // APIKey returns the value of the "api_key" field in the mutation.
  30107. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  30108. v := m.api_key
  30109. if v == nil {
  30110. return
  30111. }
  30112. return *v, true
  30113. }
  30114. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  30115. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  30116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30117. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  30118. if !m.op.Is(OpUpdateOne) {
  30119. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  30120. }
  30121. if m.id == nil || m.oldValue == nil {
  30122. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  30123. }
  30124. oldValue, err := m.oldValue(ctx)
  30125. if err != nil {
  30126. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  30127. }
  30128. return oldValue.APIKey, nil
  30129. }
  30130. // ClearAPIKey clears the value of the "api_key" field.
  30131. func (m *WxCardMutation) ClearAPIKey() {
  30132. m.api_key = nil
  30133. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  30134. }
  30135. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  30136. func (m *WxCardMutation) APIKeyCleared() bool {
  30137. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  30138. return ok
  30139. }
  30140. // ResetAPIKey resets all changes to the "api_key" field.
  30141. func (m *WxCardMutation) ResetAPIKey() {
  30142. m.api_key = nil
  30143. delete(m.clearedFields, wxcard.FieldAPIKey)
  30144. }
  30145. // SetAiInfo sets the "ai_info" field.
  30146. func (m *WxCardMutation) SetAiInfo(s string) {
  30147. m.ai_info = &s
  30148. }
  30149. // AiInfo returns the value of the "ai_info" field in the mutation.
  30150. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  30151. v := m.ai_info
  30152. if v == nil {
  30153. return
  30154. }
  30155. return *v, true
  30156. }
  30157. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  30158. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  30159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30160. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  30161. if !m.op.Is(OpUpdateOne) {
  30162. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  30163. }
  30164. if m.id == nil || m.oldValue == nil {
  30165. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  30166. }
  30167. oldValue, err := m.oldValue(ctx)
  30168. if err != nil {
  30169. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  30170. }
  30171. return oldValue.AiInfo, nil
  30172. }
  30173. // ClearAiInfo clears the value of the "ai_info" field.
  30174. func (m *WxCardMutation) ClearAiInfo() {
  30175. m.ai_info = nil
  30176. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  30177. }
  30178. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  30179. func (m *WxCardMutation) AiInfoCleared() bool {
  30180. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  30181. return ok
  30182. }
  30183. // ResetAiInfo resets all changes to the "ai_info" field.
  30184. func (m *WxCardMutation) ResetAiInfo() {
  30185. m.ai_info = nil
  30186. delete(m.clearedFields, wxcard.FieldAiInfo)
  30187. }
  30188. // SetIntro sets the "intro" field.
  30189. func (m *WxCardMutation) SetIntro(s string) {
  30190. m.intro = &s
  30191. }
  30192. // Intro returns the value of the "intro" field in the mutation.
  30193. func (m *WxCardMutation) Intro() (r string, exists bool) {
  30194. v := m.intro
  30195. if v == nil {
  30196. return
  30197. }
  30198. return *v, true
  30199. }
  30200. // OldIntro returns the old "intro" field's value of the WxCard entity.
  30201. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  30202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30203. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  30204. if !m.op.Is(OpUpdateOne) {
  30205. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  30206. }
  30207. if m.id == nil || m.oldValue == nil {
  30208. return v, errors.New("OldIntro requires an ID field in the mutation")
  30209. }
  30210. oldValue, err := m.oldValue(ctx)
  30211. if err != nil {
  30212. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  30213. }
  30214. return oldValue.Intro, nil
  30215. }
  30216. // ClearIntro clears the value of the "intro" field.
  30217. func (m *WxCardMutation) ClearIntro() {
  30218. m.intro = nil
  30219. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  30220. }
  30221. // IntroCleared returns if the "intro" field was cleared in this mutation.
  30222. func (m *WxCardMutation) IntroCleared() bool {
  30223. _, ok := m.clearedFields[wxcard.FieldIntro]
  30224. return ok
  30225. }
  30226. // ResetIntro resets all changes to the "intro" field.
  30227. func (m *WxCardMutation) ResetIntro() {
  30228. m.intro = nil
  30229. delete(m.clearedFields, wxcard.FieldIntro)
  30230. }
  30231. // Where appends a list predicates to the WxCardMutation builder.
  30232. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  30233. m.predicates = append(m.predicates, ps...)
  30234. }
  30235. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  30236. // users can use type-assertion to append predicates that do not depend on any generated package.
  30237. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  30238. p := make([]predicate.WxCard, len(ps))
  30239. for i := range ps {
  30240. p[i] = ps[i]
  30241. }
  30242. m.Where(p...)
  30243. }
  30244. // Op returns the operation name.
  30245. func (m *WxCardMutation) Op() Op {
  30246. return m.op
  30247. }
  30248. // SetOp allows setting the mutation operation.
  30249. func (m *WxCardMutation) SetOp(op Op) {
  30250. m.op = op
  30251. }
  30252. // Type returns the node type of this mutation (WxCard).
  30253. func (m *WxCardMutation) Type() string {
  30254. return m.typ
  30255. }
  30256. // Fields returns all fields that were changed during this mutation. Note that in
  30257. // order to get all numeric fields that were incremented/decremented, call
  30258. // AddedFields().
  30259. func (m *WxCardMutation) Fields() []string {
  30260. fields := make([]string, 0, 18)
  30261. if m.created_at != nil {
  30262. fields = append(fields, wxcard.FieldCreatedAt)
  30263. }
  30264. if m.updated_at != nil {
  30265. fields = append(fields, wxcard.FieldUpdatedAt)
  30266. }
  30267. if m.deleted_at != nil {
  30268. fields = append(fields, wxcard.FieldDeletedAt)
  30269. }
  30270. if m.user_id != nil {
  30271. fields = append(fields, wxcard.FieldUserID)
  30272. }
  30273. if m.wx_user_id != nil {
  30274. fields = append(fields, wxcard.FieldWxUserID)
  30275. }
  30276. if m.avatar != nil {
  30277. fields = append(fields, wxcard.FieldAvatar)
  30278. }
  30279. if m.logo != nil {
  30280. fields = append(fields, wxcard.FieldLogo)
  30281. }
  30282. if m.name != nil {
  30283. fields = append(fields, wxcard.FieldName)
  30284. }
  30285. if m.company != nil {
  30286. fields = append(fields, wxcard.FieldCompany)
  30287. }
  30288. if m.address != nil {
  30289. fields = append(fields, wxcard.FieldAddress)
  30290. }
  30291. if m.phone != nil {
  30292. fields = append(fields, wxcard.FieldPhone)
  30293. }
  30294. if m.official_account != nil {
  30295. fields = append(fields, wxcard.FieldOfficialAccount)
  30296. }
  30297. if m.wechat_account != nil {
  30298. fields = append(fields, wxcard.FieldWechatAccount)
  30299. }
  30300. if m.email != nil {
  30301. fields = append(fields, wxcard.FieldEmail)
  30302. }
  30303. if m.api_base != nil {
  30304. fields = append(fields, wxcard.FieldAPIBase)
  30305. }
  30306. if m.api_key != nil {
  30307. fields = append(fields, wxcard.FieldAPIKey)
  30308. }
  30309. if m.ai_info != nil {
  30310. fields = append(fields, wxcard.FieldAiInfo)
  30311. }
  30312. if m.intro != nil {
  30313. fields = append(fields, wxcard.FieldIntro)
  30314. }
  30315. return fields
  30316. }
  30317. // Field returns the value of a field with the given name. The second boolean
  30318. // return value indicates that this field was not set, or was not defined in the
  30319. // schema.
  30320. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  30321. switch name {
  30322. case wxcard.FieldCreatedAt:
  30323. return m.CreatedAt()
  30324. case wxcard.FieldUpdatedAt:
  30325. return m.UpdatedAt()
  30326. case wxcard.FieldDeletedAt:
  30327. return m.DeletedAt()
  30328. case wxcard.FieldUserID:
  30329. return m.UserID()
  30330. case wxcard.FieldWxUserID:
  30331. return m.WxUserID()
  30332. case wxcard.FieldAvatar:
  30333. return m.Avatar()
  30334. case wxcard.FieldLogo:
  30335. return m.Logo()
  30336. case wxcard.FieldName:
  30337. return m.Name()
  30338. case wxcard.FieldCompany:
  30339. return m.Company()
  30340. case wxcard.FieldAddress:
  30341. return m.Address()
  30342. case wxcard.FieldPhone:
  30343. return m.Phone()
  30344. case wxcard.FieldOfficialAccount:
  30345. return m.OfficialAccount()
  30346. case wxcard.FieldWechatAccount:
  30347. return m.WechatAccount()
  30348. case wxcard.FieldEmail:
  30349. return m.Email()
  30350. case wxcard.FieldAPIBase:
  30351. return m.APIBase()
  30352. case wxcard.FieldAPIKey:
  30353. return m.APIKey()
  30354. case wxcard.FieldAiInfo:
  30355. return m.AiInfo()
  30356. case wxcard.FieldIntro:
  30357. return m.Intro()
  30358. }
  30359. return nil, false
  30360. }
  30361. // OldField returns the old value of the field from the database. An error is
  30362. // returned if the mutation operation is not UpdateOne, or the query to the
  30363. // database failed.
  30364. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30365. switch name {
  30366. case wxcard.FieldCreatedAt:
  30367. return m.OldCreatedAt(ctx)
  30368. case wxcard.FieldUpdatedAt:
  30369. return m.OldUpdatedAt(ctx)
  30370. case wxcard.FieldDeletedAt:
  30371. return m.OldDeletedAt(ctx)
  30372. case wxcard.FieldUserID:
  30373. return m.OldUserID(ctx)
  30374. case wxcard.FieldWxUserID:
  30375. return m.OldWxUserID(ctx)
  30376. case wxcard.FieldAvatar:
  30377. return m.OldAvatar(ctx)
  30378. case wxcard.FieldLogo:
  30379. return m.OldLogo(ctx)
  30380. case wxcard.FieldName:
  30381. return m.OldName(ctx)
  30382. case wxcard.FieldCompany:
  30383. return m.OldCompany(ctx)
  30384. case wxcard.FieldAddress:
  30385. return m.OldAddress(ctx)
  30386. case wxcard.FieldPhone:
  30387. return m.OldPhone(ctx)
  30388. case wxcard.FieldOfficialAccount:
  30389. return m.OldOfficialAccount(ctx)
  30390. case wxcard.FieldWechatAccount:
  30391. return m.OldWechatAccount(ctx)
  30392. case wxcard.FieldEmail:
  30393. return m.OldEmail(ctx)
  30394. case wxcard.FieldAPIBase:
  30395. return m.OldAPIBase(ctx)
  30396. case wxcard.FieldAPIKey:
  30397. return m.OldAPIKey(ctx)
  30398. case wxcard.FieldAiInfo:
  30399. return m.OldAiInfo(ctx)
  30400. case wxcard.FieldIntro:
  30401. return m.OldIntro(ctx)
  30402. }
  30403. return nil, fmt.Errorf("unknown WxCard field %s", name)
  30404. }
  30405. // SetField sets the value of a field with the given name. It returns an error if
  30406. // the field is not defined in the schema, or if the type mismatched the field
  30407. // type.
  30408. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  30409. switch name {
  30410. case wxcard.FieldCreatedAt:
  30411. v, ok := value.(time.Time)
  30412. if !ok {
  30413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30414. }
  30415. m.SetCreatedAt(v)
  30416. return nil
  30417. case wxcard.FieldUpdatedAt:
  30418. v, ok := value.(time.Time)
  30419. if !ok {
  30420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30421. }
  30422. m.SetUpdatedAt(v)
  30423. return nil
  30424. case wxcard.FieldDeletedAt:
  30425. v, ok := value.(time.Time)
  30426. if !ok {
  30427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30428. }
  30429. m.SetDeletedAt(v)
  30430. return nil
  30431. case wxcard.FieldUserID:
  30432. v, ok := value.(uint64)
  30433. if !ok {
  30434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30435. }
  30436. m.SetUserID(v)
  30437. return nil
  30438. case wxcard.FieldWxUserID:
  30439. v, ok := value.(uint64)
  30440. if !ok {
  30441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30442. }
  30443. m.SetWxUserID(v)
  30444. return nil
  30445. case wxcard.FieldAvatar:
  30446. v, ok := value.(string)
  30447. if !ok {
  30448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30449. }
  30450. m.SetAvatar(v)
  30451. return nil
  30452. case wxcard.FieldLogo:
  30453. v, ok := value.(string)
  30454. if !ok {
  30455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30456. }
  30457. m.SetLogo(v)
  30458. return nil
  30459. case wxcard.FieldName:
  30460. v, ok := value.(string)
  30461. if !ok {
  30462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30463. }
  30464. m.SetName(v)
  30465. return nil
  30466. case wxcard.FieldCompany:
  30467. v, ok := value.(string)
  30468. if !ok {
  30469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30470. }
  30471. m.SetCompany(v)
  30472. return nil
  30473. case wxcard.FieldAddress:
  30474. v, ok := value.(string)
  30475. if !ok {
  30476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30477. }
  30478. m.SetAddress(v)
  30479. return nil
  30480. case wxcard.FieldPhone:
  30481. v, ok := value.(string)
  30482. if !ok {
  30483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30484. }
  30485. m.SetPhone(v)
  30486. return nil
  30487. case wxcard.FieldOfficialAccount:
  30488. v, ok := value.(string)
  30489. if !ok {
  30490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30491. }
  30492. m.SetOfficialAccount(v)
  30493. return nil
  30494. case wxcard.FieldWechatAccount:
  30495. v, ok := value.(string)
  30496. if !ok {
  30497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30498. }
  30499. m.SetWechatAccount(v)
  30500. return nil
  30501. case wxcard.FieldEmail:
  30502. v, ok := value.(string)
  30503. if !ok {
  30504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30505. }
  30506. m.SetEmail(v)
  30507. return nil
  30508. case wxcard.FieldAPIBase:
  30509. v, ok := value.(string)
  30510. if !ok {
  30511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30512. }
  30513. m.SetAPIBase(v)
  30514. return nil
  30515. case wxcard.FieldAPIKey:
  30516. v, ok := value.(string)
  30517. if !ok {
  30518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30519. }
  30520. m.SetAPIKey(v)
  30521. return nil
  30522. case wxcard.FieldAiInfo:
  30523. v, ok := value.(string)
  30524. if !ok {
  30525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30526. }
  30527. m.SetAiInfo(v)
  30528. return nil
  30529. case wxcard.FieldIntro:
  30530. v, ok := value.(string)
  30531. if !ok {
  30532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30533. }
  30534. m.SetIntro(v)
  30535. return nil
  30536. }
  30537. return fmt.Errorf("unknown WxCard field %s", name)
  30538. }
  30539. // AddedFields returns all numeric fields that were incremented/decremented during
  30540. // this mutation.
  30541. func (m *WxCardMutation) AddedFields() []string {
  30542. var fields []string
  30543. if m.adduser_id != nil {
  30544. fields = append(fields, wxcard.FieldUserID)
  30545. }
  30546. if m.addwx_user_id != nil {
  30547. fields = append(fields, wxcard.FieldWxUserID)
  30548. }
  30549. return fields
  30550. }
  30551. // AddedField returns the numeric value that was incremented/decremented on a field
  30552. // with the given name. The second boolean return value indicates that this field
  30553. // was not set, or was not defined in the schema.
  30554. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  30555. switch name {
  30556. case wxcard.FieldUserID:
  30557. return m.AddedUserID()
  30558. case wxcard.FieldWxUserID:
  30559. return m.AddedWxUserID()
  30560. }
  30561. return nil, false
  30562. }
  30563. // AddField adds the value to the field with the given name. It returns an error if
  30564. // the field is not defined in the schema, or if the type mismatched the field
  30565. // type.
  30566. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  30567. switch name {
  30568. case wxcard.FieldUserID:
  30569. v, ok := value.(int64)
  30570. if !ok {
  30571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30572. }
  30573. m.AddUserID(v)
  30574. return nil
  30575. case wxcard.FieldWxUserID:
  30576. v, ok := value.(int64)
  30577. if !ok {
  30578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30579. }
  30580. m.AddWxUserID(v)
  30581. return nil
  30582. }
  30583. return fmt.Errorf("unknown WxCard numeric field %s", name)
  30584. }
  30585. // ClearedFields returns all nullable fields that were cleared during this
  30586. // mutation.
  30587. func (m *WxCardMutation) ClearedFields() []string {
  30588. var fields []string
  30589. if m.FieldCleared(wxcard.FieldDeletedAt) {
  30590. fields = append(fields, wxcard.FieldDeletedAt)
  30591. }
  30592. if m.FieldCleared(wxcard.FieldUserID) {
  30593. fields = append(fields, wxcard.FieldUserID)
  30594. }
  30595. if m.FieldCleared(wxcard.FieldWxUserID) {
  30596. fields = append(fields, wxcard.FieldWxUserID)
  30597. }
  30598. if m.FieldCleared(wxcard.FieldEmail) {
  30599. fields = append(fields, wxcard.FieldEmail)
  30600. }
  30601. if m.FieldCleared(wxcard.FieldAPIBase) {
  30602. fields = append(fields, wxcard.FieldAPIBase)
  30603. }
  30604. if m.FieldCleared(wxcard.FieldAPIKey) {
  30605. fields = append(fields, wxcard.FieldAPIKey)
  30606. }
  30607. if m.FieldCleared(wxcard.FieldAiInfo) {
  30608. fields = append(fields, wxcard.FieldAiInfo)
  30609. }
  30610. if m.FieldCleared(wxcard.FieldIntro) {
  30611. fields = append(fields, wxcard.FieldIntro)
  30612. }
  30613. return fields
  30614. }
  30615. // FieldCleared returns a boolean indicating if a field with the given name was
  30616. // cleared in this mutation.
  30617. func (m *WxCardMutation) FieldCleared(name string) bool {
  30618. _, ok := m.clearedFields[name]
  30619. return ok
  30620. }
  30621. // ClearField clears the value of the field with the given name. It returns an
  30622. // error if the field is not defined in the schema.
  30623. func (m *WxCardMutation) ClearField(name string) error {
  30624. switch name {
  30625. case wxcard.FieldDeletedAt:
  30626. m.ClearDeletedAt()
  30627. return nil
  30628. case wxcard.FieldUserID:
  30629. m.ClearUserID()
  30630. return nil
  30631. case wxcard.FieldWxUserID:
  30632. m.ClearWxUserID()
  30633. return nil
  30634. case wxcard.FieldEmail:
  30635. m.ClearEmail()
  30636. return nil
  30637. case wxcard.FieldAPIBase:
  30638. m.ClearAPIBase()
  30639. return nil
  30640. case wxcard.FieldAPIKey:
  30641. m.ClearAPIKey()
  30642. return nil
  30643. case wxcard.FieldAiInfo:
  30644. m.ClearAiInfo()
  30645. return nil
  30646. case wxcard.FieldIntro:
  30647. m.ClearIntro()
  30648. return nil
  30649. }
  30650. return fmt.Errorf("unknown WxCard nullable field %s", name)
  30651. }
  30652. // ResetField resets all changes in the mutation for the field with the given name.
  30653. // It returns an error if the field is not defined in the schema.
  30654. func (m *WxCardMutation) ResetField(name string) error {
  30655. switch name {
  30656. case wxcard.FieldCreatedAt:
  30657. m.ResetCreatedAt()
  30658. return nil
  30659. case wxcard.FieldUpdatedAt:
  30660. m.ResetUpdatedAt()
  30661. return nil
  30662. case wxcard.FieldDeletedAt:
  30663. m.ResetDeletedAt()
  30664. return nil
  30665. case wxcard.FieldUserID:
  30666. m.ResetUserID()
  30667. return nil
  30668. case wxcard.FieldWxUserID:
  30669. m.ResetWxUserID()
  30670. return nil
  30671. case wxcard.FieldAvatar:
  30672. m.ResetAvatar()
  30673. return nil
  30674. case wxcard.FieldLogo:
  30675. m.ResetLogo()
  30676. return nil
  30677. case wxcard.FieldName:
  30678. m.ResetName()
  30679. return nil
  30680. case wxcard.FieldCompany:
  30681. m.ResetCompany()
  30682. return nil
  30683. case wxcard.FieldAddress:
  30684. m.ResetAddress()
  30685. return nil
  30686. case wxcard.FieldPhone:
  30687. m.ResetPhone()
  30688. return nil
  30689. case wxcard.FieldOfficialAccount:
  30690. m.ResetOfficialAccount()
  30691. return nil
  30692. case wxcard.FieldWechatAccount:
  30693. m.ResetWechatAccount()
  30694. return nil
  30695. case wxcard.FieldEmail:
  30696. m.ResetEmail()
  30697. return nil
  30698. case wxcard.FieldAPIBase:
  30699. m.ResetAPIBase()
  30700. return nil
  30701. case wxcard.FieldAPIKey:
  30702. m.ResetAPIKey()
  30703. return nil
  30704. case wxcard.FieldAiInfo:
  30705. m.ResetAiInfo()
  30706. return nil
  30707. case wxcard.FieldIntro:
  30708. m.ResetIntro()
  30709. return nil
  30710. }
  30711. return fmt.Errorf("unknown WxCard field %s", name)
  30712. }
  30713. // AddedEdges returns all edge names that were set/added in this mutation.
  30714. func (m *WxCardMutation) AddedEdges() []string {
  30715. edges := make([]string, 0, 0)
  30716. return edges
  30717. }
  30718. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30719. // name in this mutation.
  30720. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  30721. return nil
  30722. }
  30723. // RemovedEdges returns all edge names that were removed in this mutation.
  30724. func (m *WxCardMutation) RemovedEdges() []string {
  30725. edges := make([]string, 0, 0)
  30726. return edges
  30727. }
  30728. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30729. // the given name in this mutation.
  30730. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  30731. return nil
  30732. }
  30733. // ClearedEdges returns all edge names that were cleared in this mutation.
  30734. func (m *WxCardMutation) ClearedEdges() []string {
  30735. edges := make([]string, 0, 0)
  30736. return edges
  30737. }
  30738. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30739. // was cleared in this mutation.
  30740. func (m *WxCardMutation) EdgeCleared(name string) bool {
  30741. return false
  30742. }
  30743. // ClearEdge clears the value of the edge with the given name. It returns an error
  30744. // if that edge is not defined in the schema.
  30745. func (m *WxCardMutation) ClearEdge(name string) error {
  30746. return fmt.Errorf("unknown WxCard unique edge %s", name)
  30747. }
  30748. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30749. // It returns an error if the edge is not defined in the schema.
  30750. func (m *WxCardMutation) ResetEdge(name string) error {
  30751. return fmt.Errorf("unknown WxCard edge %s", name)
  30752. }
  30753. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  30754. type WxCardUserMutation struct {
  30755. config
  30756. op Op
  30757. typ string
  30758. id *uint64
  30759. created_at *time.Time
  30760. updated_at *time.Time
  30761. deleted_at *time.Time
  30762. wxid *string
  30763. account *string
  30764. avatar *string
  30765. nickname *string
  30766. remark *string
  30767. phone *string
  30768. open_id *string
  30769. union_id *string
  30770. session_key *string
  30771. is_vip *int
  30772. addis_vip *int
  30773. clearedFields map[string]struct{}
  30774. done bool
  30775. oldValue func(context.Context) (*WxCardUser, error)
  30776. predicates []predicate.WxCardUser
  30777. }
  30778. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  30779. // wxcarduserOption allows management of the mutation configuration using functional options.
  30780. type wxcarduserOption func(*WxCardUserMutation)
  30781. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  30782. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  30783. m := &WxCardUserMutation{
  30784. config: c,
  30785. op: op,
  30786. typ: TypeWxCardUser,
  30787. clearedFields: make(map[string]struct{}),
  30788. }
  30789. for _, opt := range opts {
  30790. opt(m)
  30791. }
  30792. return m
  30793. }
  30794. // withWxCardUserID sets the ID field of the mutation.
  30795. func withWxCardUserID(id uint64) wxcarduserOption {
  30796. return func(m *WxCardUserMutation) {
  30797. var (
  30798. err error
  30799. once sync.Once
  30800. value *WxCardUser
  30801. )
  30802. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  30803. once.Do(func() {
  30804. if m.done {
  30805. err = errors.New("querying old values post mutation is not allowed")
  30806. } else {
  30807. value, err = m.Client().WxCardUser.Get(ctx, id)
  30808. }
  30809. })
  30810. return value, err
  30811. }
  30812. m.id = &id
  30813. }
  30814. }
  30815. // withWxCardUser sets the old WxCardUser of the mutation.
  30816. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  30817. return func(m *WxCardUserMutation) {
  30818. m.oldValue = func(context.Context) (*WxCardUser, error) {
  30819. return node, nil
  30820. }
  30821. m.id = &node.ID
  30822. }
  30823. }
  30824. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30825. // executed in a transaction (ent.Tx), a transactional client is returned.
  30826. func (m WxCardUserMutation) Client() *Client {
  30827. client := &Client{config: m.config}
  30828. client.init()
  30829. return client
  30830. }
  30831. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30832. // it returns an error otherwise.
  30833. func (m WxCardUserMutation) Tx() (*Tx, error) {
  30834. if _, ok := m.driver.(*txDriver); !ok {
  30835. return nil, errors.New("ent: mutation is not running in a transaction")
  30836. }
  30837. tx := &Tx{config: m.config}
  30838. tx.init()
  30839. return tx, nil
  30840. }
  30841. // SetID sets the value of the id field. Note that this
  30842. // operation is only accepted on creation of WxCardUser entities.
  30843. func (m *WxCardUserMutation) SetID(id uint64) {
  30844. m.id = &id
  30845. }
  30846. // ID returns the ID value in the mutation. Note that the ID is only available
  30847. // if it was provided to the builder or after it was returned from the database.
  30848. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  30849. if m.id == nil {
  30850. return
  30851. }
  30852. return *m.id, true
  30853. }
  30854. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30855. // That means, if the mutation is applied within a transaction with an isolation level such
  30856. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30857. // or updated by the mutation.
  30858. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  30859. switch {
  30860. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30861. id, exists := m.ID()
  30862. if exists {
  30863. return []uint64{id}, nil
  30864. }
  30865. fallthrough
  30866. case m.op.Is(OpUpdate | OpDelete):
  30867. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  30868. default:
  30869. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30870. }
  30871. }
  30872. // SetCreatedAt sets the "created_at" field.
  30873. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  30874. m.created_at = &t
  30875. }
  30876. // CreatedAt returns the value of the "created_at" field in the mutation.
  30877. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  30878. v := m.created_at
  30879. if v == nil {
  30880. return
  30881. }
  30882. return *v, true
  30883. }
  30884. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  30885. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30887. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30888. if !m.op.Is(OpUpdateOne) {
  30889. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30890. }
  30891. if m.id == nil || m.oldValue == nil {
  30892. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30893. }
  30894. oldValue, err := m.oldValue(ctx)
  30895. if err != nil {
  30896. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30897. }
  30898. return oldValue.CreatedAt, nil
  30899. }
  30900. // ResetCreatedAt resets all changes to the "created_at" field.
  30901. func (m *WxCardUserMutation) ResetCreatedAt() {
  30902. m.created_at = nil
  30903. }
  30904. // SetUpdatedAt sets the "updated_at" field.
  30905. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  30906. m.updated_at = &t
  30907. }
  30908. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30909. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  30910. v := m.updated_at
  30911. if v == nil {
  30912. return
  30913. }
  30914. return *v, true
  30915. }
  30916. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  30917. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30919. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30920. if !m.op.Is(OpUpdateOne) {
  30921. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30922. }
  30923. if m.id == nil || m.oldValue == nil {
  30924. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30925. }
  30926. oldValue, err := m.oldValue(ctx)
  30927. if err != nil {
  30928. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30929. }
  30930. return oldValue.UpdatedAt, nil
  30931. }
  30932. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30933. func (m *WxCardUserMutation) ResetUpdatedAt() {
  30934. m.updated_at = nil
  30935. }
  30936. // SetDeletedAt sets the "deleted_at" field.
  30937. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  30938. m.deleted_at = &t
  30939. }
  30940. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30941. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  30942. v := m.deleted_at
  30943. if v == nil {
  30944. return
  30945. }
  30946. return *v, true
  30947. }
  30948. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  30949. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30951. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30952. if !m.op.Is(OpUpdateOne) {
  30953. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30954. }
  30955. if m.id == nil || m.oldValue == nil {
  30956. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30957. }
  30958. oldValue, err := m.oldValue(ctx)
  30959. if err != nil {
  30960. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30961. }
  30962. return oldValue.DeletedAt, nil
  30963. }
  30964. // ClearDeletedAt clears the value of the "deleted_at" field.
  30965. func (m *WxCardUserMutation) ClearDeletedAt() {
  30966. m.deleted_at = nil
  30967. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  30968. }
  30969. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30970. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  30971. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  30972. return ok
  30973. }
  30974. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30975. func (m *WxCardUserMutation) ResetDeletedAt() {
  30976. m.deleted_at = nil
  30977. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  30978. }
  30979. // SetWxid sets the "wxid" field.
  30980. func (m *WxCardUserMutation) SetWxid(s string) {
  30981. m.wxid = &s
  30982. }
  30983. // Wxid returns the value of the "wxid" field in the mutation.
  30984. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  30985. v := m.wxid
  30986. if v == nil {
  30987. return
  30988. }
  30989. return *v, true
  30990. }
  30991. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  30992. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30994. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  30995. if !m.op.Is(OpUpdateOne) {
  30996. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  30997. }
  30998. if m.id == nil || m.oldValue == nil {
  30999. return v, errors.New("OldWxid requires an ID field in the mutation")
  31000. }
  31001. oldValue, err := m.oldValue(ctx)
  31002. if err != nil {
  31003. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  31004. }
  31005. return oldValue.Wxid, nil
  31006. }
  31007. // ResetWxid resets all changes to the "wxid" field.
  31008. func (m *WxCardUserMutation) ResetWxid() {
  31009. m.wxid = nil
  31010. }
  31011. // SetAccount sets the "account" field.
  31012. func (m *WxCardUserMutation) SetAccount(s string) {
  31013. m.account = &s
  31014. }
  31015. // Account returns the value of the "account" field in the mutation.
  31016. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  31017. v := m.account
  31018. if v == nil {
  31019. return
  31020. }
  31021. return *v, true
  31022. }
  31023. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  31024. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31026. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  31027. if !m.op.Is(OpUpdateOne) {
  31028. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  31029. }
  31030. if m.id == nil || m.oldValue == nil {
  31031. return v, errors.New("OldAccount requires an ID field in the mutation")
  31032. }
  31033. oldValue, err := m.oldValue(ctx)
  31034. if err != nil {
  31035. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  31036. }
  31037. return oldValue.Account, nil
  31038. }
  31039. // ResetAccount resets all changes to the "account" field.
  31040. func (m *WxCardUserMutation) ResetAccount() {
  31041. m.account = nil
  31042. }
  31043. // SetAvatar sets the "avatar" field.
  31044. func (m *WxCardUserMutation) SetAvatar(s string) {
  31045. m.avatar = &s
  31046. }
  31047. // Avatar returns the value of the "avatar" field in the mutation.
  31048. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  31049. v := m.avatar
  31050. if v == nil {
  31051. return
  31052. }
  31053. return *v, true
  31054. }
  31055. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  31056. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31058. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  31059. if !m.op.Is(OpUpdateOne) {
  31060. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  31061. }
  31062. if m.id == nil || m.oldValue == nil {
  31063. return v, errors.New("OldAvatar requires an ID field in the mutation")
  31064. }
  31065. oldValue, err := m.oldValue(ctx)
  31066. if err != nil {
  31067. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  31068. }
  31069. return oldValue.Avatar, nil
  31070. }
  31071. // ResetAvatar resets all changes to the "avatar" field.
  31072. func (m *WxCardUserMutation) ResetAvatar() {
  31073. m.avatar = nil
  31074. }
  31075. // SetNickname sets the "nickname" field.
  31076. func (m *WxCardUserMutation) SetNickname(s string) {
  31077. m.nickname = &s
  31078. }
  31079. // Nickname returns the value of the "nickname" field in the mutation.
  31080. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  31081. v := m.nickname
  31082. if v == nil {
  31083. return
  31084. }
  31085. return *v, true
  31086. }
  31087. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  31088. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31090. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  31091. if !m.op.Is(OpUpdateOne) {
  31092. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  31093. }
  31094. if m.id == nil || m.oldValue == nil {
  31095. return v, errors.New("OldNickname requires an ID field in the mutation")
  31096. }
  31097. oldValue, err := m.oldValue(ctx)
  31098. if err != nil {
  31099. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  31100. }
  31101. return oldValue.Nickname, nil
  31102. }
  31103. // ResetNickname resets all changes to the "nickname" field.
  31104. func (m *WxCardUserMutation) ResetNickname() {
  31105. m.nickname = nil
  31106. }
  31107. // SetRemark sets the "remark" field.
  31108. func (m *WxCardUserMutation) SetRemark(s string) {
  31109. m.remark = &s
  31110. }
  31111. // Remark returns the value of the "remark" field in the mutation.
  31112. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  31113. v := m.remark
  31114. if v == nil {
  31115. return
  31116. }
  31117. return *v, true
  31118. }
  31119. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  31120. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31122. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  31123. if !m.op.Is(OpUpdateOne) {
  31124. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  31125. }
  31126. if m.id == nil || m.oldValue == nil {
  31127. return v, errors.New("OldRemark requires an ID field in the mutation")
  31128. }
  31129. oldValue, err := m.oldValue(ctx)
  31130. if err != nil {
  31131. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  31132. }
  31133. return oldValue.Remark, nil
  31134. }
  31135. // ResetRemark resets all changes to the "remark" field.
  31136. func (m *WxCardUserMutation) ResetRemark() {
  31137. m.remark = nil
  31138. }
  31139. // SetPhone sets the "phone" field.
  31140. func (m *WxCardUserMutation) SetPhone(s string) {
  31141. m.phone = &s
  31142. }
  31143. // Phone returns the value of the "phone" field in the mutation.
  31144. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  31145. v := m.phone
  31146. if v == nil {
  31147. return
  31148. }
  31149. return *v, true
  31150. }
  31151. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  31152. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31154. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  31155. if !m.op.Is(OpUpdateOne) {
  31156. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  31157. }
  31158. if m.id == nil || m.oldValue == nil {
  31159. return v, errors.New("OldPhone requires an ID field in the mutation")
  31160. }
  31161. oldValue, err := m.oldValue(ctx)
  31162. if err != nil {
  31163. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  31164. }
  31165. return oldValue.Phone, nil
  31166. }
  31167. // ResetPhone resets all changes to the "phone" field.
  31168. func (m *WxCardUserMutation) ResetPhone() {
  31169. m.phone = nil
  31170. }
  31171. // SetOpenID sets the "open_id" field.
  31172. func (m *WxCardUserMutation) SetOpenID(s string) {
  31173. m.open_id = &s
  31174. }
  31175. // OpenID returns the value of the "open_id" field in the mutation.
  31176. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  31177. v := m.open_id
  31178. if v == nil {
  31179. return
  31180. }
  31181. return *v, true
  31182. }
  31183. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  31184. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31186. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  31187. if !m.op.Is(OpUpdateOne) {
  31188. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  31189. }
  31190. if m.id == nil || m.oldValue == nil {
  31191. return v, errors.New("OldOpenID requires an ID field in the mutation")
  31192. }
  31193. oldValue, err := m.oldValue(ctx)
  31194. if err != nil {
  31195. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  31196. }
  31197. return oldValue.OpenID, nil
  31198. }
  31199. // ResetOpenID resets all changes to the "open_id" field.
  31200. func (m *WxCardUserMutation) ResetOpenID() {
  31201. m.open_id = nil
  31202. }
  31203. // SetUnionID sets the "union_id" field.
  31204. func (m *WxCardUserMutation) SetUnionID(s string) {
  31205. m.union_id = &s
  31206. }
  31207. // UnionID returns the value of the "union_id" field in the mutation.
  31208. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  31209. v := m.union_id
  31210. if v == nil {
  31211. return
  31212. }
  31213. return *v, true
  31214. }
  31215. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  31216. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31218. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  31219. if !m.op.Is(OpUpdateOne) {
  31220. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  31221. }
  31222. if m.id == nil || m.oldValue == nil {
  31223. return v, errors.New("OldUnionID requires an ID field in the mutation")
  31224. }
  31225. oldValue, err := m.oldValue(ctx)
  31226. if err != nil {
  31227. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  31228. }
  31229. return oldValue.UnionID, nil
  31230. }
  31231. // ResetUnionID resets all changes to the "union_id" field.
  31232. func (m *WxCardUserMutation) ResetUnionID() {
  31233. m.union_id = nil
  31234. }
  31235. // SetSessionKey sets the "session_key" field.
  31236. func (m *WxCardUserMutation) SetSessionKey(s string) {
  31237. m.session_key = &s
  31238. }
  31239. // SessionKey returns the value of the "session_key" field in the mutation.
  31240. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  31241. v := m.session_key
  31242. if v == nil {
  31243. return
  31244. }
  31245. return *v, true
  31246. }
  31247. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  31248. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31250. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  31251. if !m.op.Is(OpUpdateOne) {
  31252. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  31253. }
  31254. if m.id == nil || m.oldValue == nil {
  31255. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  31256. }
  31257. oldValue, err := m.oldValue(ctx)
  31258. if err != nil {
  31259. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  31260. }
  31261. return oldValue.SessionKey, nil
  31262. }
  31263. // ResetSessionKey resets all changes to the "session_key" field.
  31264. func (m *WxCardUserMutation) ResetSessionKey() {
  31265. m.session_key = nil
  31266. }
  31267. // SetIsVip sets the "is_vip" field.
  31268. func (m *WxCardUserMutation) SetIsVip(i int) {
  31269. m.is_vip = &i
  31270. m.addis_vip = nil
  31271. }
  31272. // IsVip returns the value of the "is_vip" field in the mutation.
  31273. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  31274. v := m.is_vip
  31275. if v == nil {
  31276. return
  31277. }
  31278. return *v, true
  31279. }
  31280. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  31281. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31283. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  31284. if !m.op.Is(OpUpdateOne) {
  31285. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  31286. }
  31287. if m.id == nil || m.oldValue == nil {
  31288. return v, errors.New("OldIsVip requires an ID field in the mutation")
  31289. }
  31290. oldValue, err := m.oldValue(ctx)
  31291. if err != nil {
  31292. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  31293. }
  31294. return oldValue.IsVip, nil
  31295. }
  31296. // AddIsVip adds i to the "is_vip" field.
  31297. func (m *WxCardUserMutation) AddIsVip(i int) {
  31298. if m.addis_vip != nil {
  31299. *m.addis_vip += i
  31300. } else {
  31301. m.addis_vip = &i
  31302. }
  31303. }
  31304. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  31305. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  31306. v := m.addis_vip
  31307. if v == nil {
  31308. return
  31309. }
  31310. return *v, true
  31311. }
  31312. // ResetIsVip resets all changes to the "is_vip" field.
  31313. func (m *WxCardUserMutation) ResetIsVip() {
  31314. m.is_vip = nil
  31315. m.addis_vip = nil
  31316. }
  31317. // Where appends a list predicates to the WxCardUserMutation builder.
  31318. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  31319. m.predicates = append(m.predicates, ps...)
  31320. }
  31321. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  31322. // users can use type-assertion to append predicates that do not depend on any generated package.
  31323. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  31324. p := make([]predicate.WxCardUser, len(ps))
  31325. for i := range ps {
  31326. p[i] = ps[i]
  31327. }
  31328. m.Where(p...)
  31329. }
  31330. // Op returns the operation name.
  31331. func (m *WxCardUserMutation) Op() Op {
  31332. return m.op
  31333. }
  31334. // SetOp allows setting the mutation operation.
  31335. func (m *WxCardUserMutation) SetOp(op Op) {
  31336. m.op = op
  31337. }
  31338. // Type returns the node type of this mutation (WxCardUser).
  31339. func (m *WxCardUserMutation) Type() string {
  31340. return m.typ
  31341. }
  31342. // Fields returns all fields that were changed during this mutation. Note that in
  31343. // order to get all numeric fields that were incremented/decremented, call
  31344. // AddedFields().
  31345. func (m *WxCardUserMutation) Fields() []string {
  31346. fields := make([]string, 0, 13)
  31347. if m.created_at != nil {
  31348. fields = append(fields, wxcarduser.FieldCreatedAt)
  31349. }
  31350. if m.updated_at != nil {
  31351. fields = append(fields, wxcarduser.FieldUpdatedAt)
  31352. }
  31353. if m.deleted_at != nil {
  31354. fields = append(fields, wxcarduser.FieldDeletedAt)
  31355. }
  31356. if m.wxid != nil {
  31357. fields = append(fields, wxcarduser.FieldWxid)
  31358. }
  31359. if m.account != nil {
  31360. fields = append(fields, wxcarduser.FieldAccount)
  31361. }
  31362. if m.avatar != nil {
  31363. fields = append(fields, wxcarduser.FieldAvatar)
  31364. }
  31365. if m.nickname != nil {
  31366. fields = append(fields, wxcarduser.FieldNickname)
  31367. }
  31368. if m.remark != nil {
  31369. fields = append(fields, wxcarduser.FieldRemark)
  31370. }
  31371. if m.phone != nil {
  31372. fields = append(fields, wxcarduser.FieldPhone)
  31373. }
  31374. if m.open_id != nil {
  31375. fields = append(fields, wxcarduser.FieldOpenID)
  31376. }
  31377. if m.union_id != nil {
  31378. fields = append(fields, wxcarduser.FieldUnionID)
  31379. }
  31380. if m.session_key != nil {
  31381. fields = append(fields, wxcarduser.FieldSessionKey)
  31382. }
  31383. if m.is_vip != nil {
  31384. fields = append(fields, wxcarduser.FieldIsVip)
  31385. }
  31386. return fields
  31387. }
  31388. // Field returns the value of a field with the given name. The second boolean
  31389. // return value indicates that this field was not set, or was not defined in the
  31390. // schema.
  31391. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  31392. switch name {
  31393. case wxcarduser.FieldCreatedAt:
  31394. return m.CreatedAt()
  31395. case wxcarduser.FieldUpdatedAt:
  31396. return m.UpdatedAt()
  31397. case wxcarduser.FieldDeletedAt:
  31398. return m.DeletedAt()
  31399. case wxcarduser.FieldWxid:
  31400. return m.Wxid()
  31401. case wxcarduser.FieldAccount:
  31402. return m.Account()
  31403. case wxcarduser.FieldAvatar:
  31404. return m.Avatar()
  31405. case wxcarduser.FieldNickname:
  31406. return m.Nickname()
  31407. case wxcarduser.FieldRemark:
  31408. return m.Remark()
  31409. case wxcarduser.FieldPhone:
  31410. return m.Phone()
  31411. case wxcarduser.FieldOpenID:
  31412. return m.OpenID()
  31413. case wxcarduser.FieldUnionID:
  31414. return m.UnionID()
  31415. case wxcarduser.FieldSessionKey:
  31416. return m.SessionKey()
  31417. case wxcarduser.FieldIsVip:
  31418. return m.IsVip()
  31419. }
  31420. return nil, false
  31421. }
  31422. // OldField returns the old value of the field from the database. An error is
  31423. // returned if the mutation operation is not UpdateOne, or the query to the
  31424. // database failed.
  31425. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31426. switch name {
  31427. case wxcarduser.FieldCreatedAt:
  31428. return m.OldCreatedAt(ctx)
  31429. case wxcarduser.FieldUpdatedAt:
  31430. return m.OldUpdatedAt(ctx)
  31431. case wxcarduser.FieldDeletedAt:
  31432. return m.OldDeletedAt(ctx)
  31433. case wxcarduser.FieldWxid:
  31434. return m.OldWxid(ctx)
  31435. case wxcarduser.FieldAccount:
  31436. return m.OldAccount(ctx)
  31437. case wxcarduser.FieldAvatar:
  31438. return m.OldAvatar(ctx)
  31439. case wxcarduser.FieldNickname:
  31440. return m.OldNickname(ctx)
  31441. case wxcarduser.FieldRemark:
  31442. return m.OldRemark(ctx)
  31443. case wxcarduser.FieldPhone:
  31444. return m.OldPhone(ctx)
  31445. case wxcarduser.FieldOpenID:
  31446. return m.OldOpenID(ctx)
  31447. case wxcarduser.FieldUnionID:
  31448. return m.OldUnionID(ctx)
  31449. case wxcarduser.FieldSessionKey:
  31450. return m.OldSessionKey(ctx)
  31451. case wxcarduser.FieldIsVip:
  31452. return m.OldIsVip(ctx)
  31453. }
  31454. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  31455. }
  31456. // SetField sets the value of a field with the given name. It returns an error if
  31457. // the field is not defined in the schema, or if the type mismatched the field
  31458. // type.
  31459. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  31460. switch name {
  31461. case wxcarduser.FieldCreatedAt:
  31462. v, ok := value.(time.Time)
  31463. if !ok {
  31464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31465. }
  31466. m.SetCreatedAt(v)
  31467. return nil
  31468. case wxcarduser.FieldUpdatedAt:
  31469. v, ok := value.(time.Time)
  31470. if !ok {
  31471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31472. }
  31473. m.SetUpdatedAt(v)
  31474. return nil
  31475. case wxcarduser.FieldDeletedAt:
  31476. v, ok := value.(time.Time)
  31477. if !ok {
  31478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31479. }
  31480. m.SetDeletedAt(v)
  31481. return nil
  31482. case wxcarduser.FieldWxid:
  31483. v, ok := value.(string)
  31484. if !ok {
  31485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31486. }
  31487. m.SetWxid(v)
  31488. return nil
  31489. case wxcarduser.FieldAccount:
  31490. v, ok := value.(string)
  31491. if !ok {
  31492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31493. }
  31494. m.SetAccount(v)
  31495. return nil
  31496. case wxcarduser.FieldAvatar:
  31497. v, ok := value.(string)
  31498. if !ok {
  31499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31500. }
  31501. m.SetAvatar(v)
  31502. return nil
  31503. case wxcarduser.FieldNickname:
  31504. v, ok := value.(string)
  31505. if !ok {
  31506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31507. }
  31508. m.SetNickname(v)
  31509. return nil
  31510. case wxcarduser.FieldRemark:
  31511. v, ok := value.(string)
  31512. if !ok {
  31513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31514. }
  31515. m.SetRemark(v)
  31516. return nil
  31517. case wxcarduser.FieldPhone:
  31518. v, ok := value.(string)
  31519. if !ok {
  31520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31521. }
  31522. m.SetPhone(v)
  31523. return nil
  31524. case wxcarduser.FieldOpenID:
  31525. v, ok := value.(string)
  31526. if !ok {
  31527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31528. }
  31529. m.SetOpenID(v)
  31530. return nil
  31531. case wxcarduser.FieldUnionID:
  31532. v, ok := value.(string)
  31533. if !ok {
  31534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31535. }
  31536. m.SetUnionID(v)
  31537. return nil
  31538. case wxcarduser.FieldSessionKey:
  31539. v, ok := value.(string)
  31540. if !ok {
  31541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31542. }
  31543. m.SetSessionKey(v)
  31544. return nil
  31545. case wxcarduser.FieldIsVip:
  31546. v, ok := value.(int)
  31547. if !ok {
  31548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31549. }
  31550. m.SetIsVip(v)
  31551. return nil
  31552. }
  31553. return fmt.Errorf("unknown WxCardUser field %s", name)
  31554. }
  31555. // AddedFields returns all numeric fields that were incremented/decremented during
  31556. // this mutation.
  31557. func (m *WxCardUserMutation) AddedFields() []string {
  31558. var fields []string
  31559. if m.addis_vip != nil {
  31560. fields = append(fields, wxcarduser.FieldIsVip)
  31561. }
  31562. return fields
  31563. }
  31564. // AddedField returns the numeric value that was incremented/decremented on a field
  31565. // with the given name. The second boolean return value indicates that this field
  31566. // was not set, or was not defined in the schema.
  31567. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  31568. switch name {
  31569. case wxcarduser.FieldIsVip:
  31570. return m.AddedIsVip()
  31571. }
  31572. return nil, false
  31573. }
  31574. // AddField adds the value to the field with the given name. It returns an error if
  31575. // the field is not defined in the schema, or if the type mismatched the field
  31576. // type.
  31577. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  31578. switch name {
  31579. case wxcarduser.FieldIsVip:
  31580. v, ok := value.(int)
  31581. if !ok {
  31582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31583. }
  31584. m.AddIsVip(v)
  31585. return nil
  31586. }
  31587. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  31588. }
  31589. // ClearedFields returns all nullable fields that were cleared during this
  31590. // mutation.
  31591. func (m *WxCardUserMutation) ClearedFields() []string {
  31592. var fields []string
  31593. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  31594. fields = append(fields, wxcarduser.FieldDeletedAt)
  31595. }
  31596. return fields
  31597. }
  31598. // FieldCleared returns a boolean indicating if a field with the given name was
  31599. // cleared in this mutation.
  31600. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  31601. _, ok := m.clearedFields[name]
  31602. return ok
  31603. }
  31604. // ClearField clears the value of the field with the given name. It returns an
  31605. // error if the field is not defined in the schema.
  31606. func (m *WxCardUserMutation) ClearField(name string) error {
  31607. switch name {
  31608. case wxcarduser.FieldDeletedAt:
  31609. m.ClearDeletedAt()
  31610. return nil
  31611. }
  31612. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  31613. }
  31614. // ResetField resets all changes in the mutation for the field with the given name.
  31615. // It returns an error if the field is not defined in the schema.
  31616. func (m *WxCardUserMutation) ResetField(name string) error {
  31617. switch name {
  31618. case wxcarduser.FieldCreatedAt:
  31619. m.ResetCreatedAt()
  31620. return nil
  31621. case wxcarduser.FieldUpdatedAt:
  31622. m.ResetUpdatedAt()
  31623. return nil
  31624. case wxcarduser.FieldDeletedAt:
  31625. m.ResetDeletedAt()
  31626. return nil
  31627. case wxcarduser.FieldWxid:
  31628. m.ResetWxid()
  31629. return nil
  31630. case wxcarduser.FieldAccount:
  31631. m.ResetAccount()
  31632. return nil
  31633. case wxcarduser.FieldAvatar:
  31634. m.ResetAvatar()
  31635. return nil
  31636. case wxcarduser.FieldNickname:
  31637. m.ResetNickname()
  31638. return nil
  31639. case wxcarduser.FieldRemark:
  31640. m.ResetRemark()
  31641. return nil
  31642. case wxcarduser.FieldPhone:
  31643. m.ResetPhone()
  31644. return nil
  31645. case wxcarduser.FieldOpenID:
  31646. m.ResetOpenID()
  31647. return nil
  31648. case wxcarduser.FieldUnionID:
  31649. m.ResetUnionID()
  31650. return nil
  31651. case wxcarduser.FieldSessionKey:
  31652. m.ResetSessionKey()
  31653. return nil
  31654. case wxcarduser.FieldIsVip:
  31655. m.ResetIsVip()
  31656. return nil
  31657. }
  31658. return fmt.Errorf("unknown WxCardUser field %s", name)
  31659. }
  31660. // AddedEdges returns all edge names that were set/added in this mutation.
  31661. func (m *WxCardUserMutation) AddedEdges() []string {
  31662. edges := make([]string, 0, 0)
  31663. return edges
  31664. }
  31665. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31666. // name in this mutation.
  31667. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  31668. return nil
  31669. }
  31670. // RemovedEdges returns all edge names that were removed in this mutation.
  31671. func (m *WxCardUserMutation) RemovedEdges() []string {
  31672. edges := make([]string, 0, 0)
  31673. return edges
  31674. }
  31675. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31676. // the given name in this mutation.
  31677. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  31678. return nil
  31679. }
  31680. // ClearedEdges returns all edge names that were cleared in this mutation.
  31681. func (m *WxCardUserMutation) ClearedEdges() []string {
  31682. edges := make([]string, 0, 0)
  31683. return edges
  31684. }
  31685. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31686. // was cleared in this mutation.
  31687. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  31688. return false
  31689. }
  31690. // ClearEdge clears the value of the edge with the given name. It returns an error
  31691. // if that edge is not defined in the schema.
  31692. func (m *WxCardUserMutation) ClearEdge(name string) error {
  31693. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  31694. }
  31695. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31696. // It returns an error if the edge is not defined in the schema.
  31697. func (m *WxCardUserMutation) ResetEdge(name string) error {
  31698. return fmt.Errorf("unknown WxCardUser edge %s", name)
  31699. }
  31700. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  31701. type WxCardVisitMutation struct {
  31702. config
  31703. op Op
  31704. typ string
  31705. id *uint64
  31706. created_at *time.Time
  31707. updated_at *time.Time
  31708. deleted_at *time.Time
  31709. user_id *uint64
  31710. adduser_id *int64
  31711. bot_id *uint64
  31712. addbot_id *int64
  31713. bot_type *uint8
  31714. addbot_type *int8
  31715. clearedFields map[string]struct{}
  31716. done bool
  31717. oldValue func(context.Context) (*WxCardVisit, error)
  31718. predicates []predicate.WxCardVisit
  31719. }
  31720. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  31721. // wxcardvisitOption allows management of the mutation configuration using functional options.
  31722. type wxcardvisitOption func(*WxCardVisitMutation)
  31723. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  31724. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  31725. m := &WxCardVisitMutation{
  31726. config: c,
  31727. op: op,
  31728. typ: TypeWxCardVisit,
  31729. clearedFields: make(map[string]struct{}),
  31730. }
  31731. for _, opt := range opts {
  31732. opt(m)
  31733. }
  31734. return m
  31735. }
  31736. // withWxCardVisitID sets the ID field of the mutation.
  31737. func withWxCardVisitID(id uint64) wxcardvisitOption {
  31738. return func(m *WxCardVisitMutation) {
  31739. var (
  31740. err error
  31741. once sync.Once
  31742. value *WxCardVisit
  31743. )
  31744. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  31745. once.Do(func() {
  31746. if m.done {
  31747. err = errors.New("querying old values post mutation is not allowed")
  31748. } else {
  31749. value, err = m.Client().WxCardVisit.Get(ctx, id)
  31750. }
  31751. })
  31752. return value, err
  31753. }
  31754. m.id = &id
  31755. }
  31756. }
  31757. // withWxCardVisit sets the old WxCardVisit of the mutation.
  31758. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  31759. return func(m *WxCardVisitMutation) {
  31760. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  31761. return node, nil
  31762. }
  31763. m.id = &node.ID
  31764. }
  31765. }
  31766. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31767. // executed in a transaction (ent.Tx), a transactional client is returned.
  31768. func (m WxCardVisitMutation) Client() *Client {
  31769. client := &Client{config: m.config}
  31770. client.init()
  31771. return client
  31772. }
  31773. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31774. // it returns an error otherwise.
  31775. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  31776. if _, ok := m.driver.(*txDriver); !ok {
  31777. return nil, errors.New("ent: mutation is not running in a transaction")
  31778. }
  31779. tx := &Tx{config: m.config}
  31780. tx.init()
  31781. return tx, nil
  31782. }
  31783. // SetID sets the value of the id field. Note that this
  31784. // operation is only accepted on creation of WxCardVisit entities.
  31785. func (m *WxCardVisitMutation) SetID(id uint64) {
  31786. m.id = &id
  31787. }
  31788. // ID returns the ID value in the mutation. Note that the ID is only available
  31789. // if it was provided to the builder or after it was returned from the database.
  31790. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  31791. if m.id == nil {
  31792. return
  31793. }
  31794. return *m.id, true
  31795. }
  31796. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31797. // That means, if the mutation is applied within a transaction with an isolation level such
  31798. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31799. // or updated by the mutation.
  31800. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  31801. switch {
  31802. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31803. id, exists := m.ID()
  31804. if exists {
  31805. return []uint64{id}, nil
  31806. }
  31807. fallthrough
  31808. case m.op.Is(OpUpdate | OpDelete):
  31809. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  31810. default:
  31811. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31812. }
  31813. }
  31814. // SetCreatedAt sets the "created_at" field.
  31815. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  31816. m.created_at = &t
  31817. }
  31818. // CreatedAt returns the value of the "created_at" field in the mutation.
  31819. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  31820. v := m.created_at
  31821. if v == nil {
  31822. return
  31823. }
  31824. return *v, true
  31825. }
  31826. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  31827. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31829. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31830. if !m.op.Is(OpUpdateOne) {
  31831. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31832. }
  31833. if m.id == nil || m.oldValue == nil {
  31834. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31835. }
  31836. oldValue, err := m.oldValue(ctx)
  31837. if err != nil {
  31838. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31839. }
  31840. return oldValue.CreatedAt, nil
  31841. }
  31842. // ResetCreatedAt resets all changes to the "created_at" field.
  31843. func (m *WxCardVisitMutation) ResetCreatedAt() {
  31844. m.created_at = nil
  31845. }
  31846. // SetUpdatedAt sets the "updated_at" field.
  31847. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  31848. m.updated_at = &t
  31849. }
  31850. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31851. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  31852. v := m.updated_at
  31853. if v == nil {
  31854. return
  31855. }
  31856. return *v, true
  31857. }
  31858. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  31859. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31861. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31862. if !m.op.Is(OpUpdateOne) {
  31863. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31864. }
  31865. if m.id == nil || m.oldValue == nil {
  31866. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31867. }
  31868. oldValue, err := m.oldValue(ctx)
  31869. if err != nil {
  31870. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31871. }
  31872. return oldValue.UpdatedAt, nil
  31873. }
  31874. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31875. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  31876. m.updated_at = nil
  31877. }
  31878. // SetDeletedAt sets the "deleted_at" field.
  31879. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  31880. m.deleted_at = &t
  31881. }
  31882. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31883. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  31884. v := m.deleted_at
  31885. if v == nil {
  31886. return
  31887. }
  31888. return *v, true
  31889. }
  31890. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  31891. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31893. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31894. if !m.op.Is(OpUpdateOne) {
  31895. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31896. }
  31897. if m.id == nil || m.oldValue == nil {
  31898. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31899. }
  31900. oldValue, err := m.oldValue(ctx)
  31901. if err != nil {
  31902. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31903. }
  31904. return oldValue.DeletedAt, nil
  31905. }
  31906. // ClearDeletedAt clears the value of the "deleted_at" field.
  31907. func (m *WxCardVisitMutation) ClearDeletedAt() {
  31908. m.deleted_at = nil
  31909. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  31910. }
  31911. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31912. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  31913. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  31914. return ok
  31915. }
  31916. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31917. func (m *WxCardVisitMutation) ResetDeletedAt() {
  31918. m.deleted_at = nil
  31919. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  31920. }
  31921. // SetUserID sets the "user_id" field.
  31922. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  31923. m.user_id = &u
  31924. m.adduser_id = nil
  31925. }
  31926. // UserID returns the value of the "user_id" field in the mutation.
  31927. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  31928. v := m.user_id
  31929. if v == nil {
  31930. return
  31931. }
  31932. return *v, true
  31933. }
  31934. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  31935. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31937. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  31938. if !m.op.Is(OpUpdateOne) {
  31939. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  31940. }
  31941. if m.id == nil || m.oldValue == nil {
  31942. return v, errors.New("OldUserID requires an ID field in the mutation")
  31943. }
  31944. oldValue, err := m.oldValue(ctx)
  31945. if err != nil {
  31946. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  31947. }
  31948. return oldValue.UserID, nil
  31949. }
  31950. // AddUserID adds u to the "user_id" field.
  31951. func (m *WxCardVisitMutation) AddUserID(u int64) {
  31952. if m.adduser_id != nil {
  31953. *m.adduser_id += u
  31954. } else {
  31955. m.adduser_id = &u
  31956. }
  31957. }
  31958. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  31959. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  31960. v := m.adduser_id
  31961. if v == nil {
  31962. return
  31963. }
  31964. return *v, true
  31965. }
  31966. // ClearUserID clears the value of the "user_id" field.
  31967. func (m *WxCardVisitMutation) ClearUserID() {
  31968. m.user_id = nil
  31969. m.adduser_id = nil
  31970. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  31971. }
  31972. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  31973. func (m *WxCardVisitMutation) UserIDCleared() bool {
  31974. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  31975. return ok
  31976. }
  31977. // ResetUserID resets all changes to the "user_id" field.
  31978. func (m *WxCardVisitMutation) ResetUserID() {
  31979. m.user_id = nil
  31980. m.adduser_id = nil
  31981. delete(m.clearedFields, wxcardvisit.FieldUserID)
  31982. }
  31983. // SetBotID sets the "bot_id" field.
  31984. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  31985. m.bot_id = &u
  31986. m.addbot_id = nil
  31987. }
  31988. // BotID returns the value of the "bot_id" field in the mutation.
  31989. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  31990. v := m.bot_id
  31991. if v == nil {
  31992. return
  31993. }
  31994. return *v, true
  31995. }
  31996. // OldBotID returns the old "bot_id" 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) OldBotID(ctx context.Context) (v uint64, err error) {
  32000. if !m.op.Is(OpUpdateOne) {
  32001. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32002. }
  32003. if m.id == nil || m.oldValue == nil {
  32004. return v, errors.New("OldBotID 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 OldBotID: %w", err)
  32009. }
  32010. return oldValue.BotID, nil
  32011. }
  32012. // AddBotID adds u to the "bot_id" field.
  32013. func (m *WxCardVisitMutation) AddBotID(u int64) {
  32014. if m.addbot_id != nil {
  32015. *m.addbot_id += u
  32016. } else {
  32017. m.addbot_id = &u
  32018. }
  32019. }
  32020. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  32021. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  32022. v := m.addbot_id
  32023. if v == nil {
  32024. return
  32025. }
  32026. return *v, true
  32027. }
  32028. // ResetBotID resets all changes to the "bot_id" field.
  32029. func (m *WxCardVisitMutation) ResetBotID() {
  32030. m.bot_id = nil
  32031. m.addbot_id = nil
  32032. }
  32033. // SetBotType sets the "bot_type" field.
  32034. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  32035. m.bot_type = &u
  32036. m.addbot_type = nil
  32037. }
  32038. // BotType returns the value of the "bot_type" field in the mutation.
  32039. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  32040. v := m.bot_type
  32041. if v == nil {
  32042. return
  32043. }
  32044. return *v, true
  32045. }
  32046. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  32047. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  32048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32049. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  32050. if !m.op.Is(OpUpdateOne) {
  32051. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  32052. }
  32053. if m.id == nil || m.oldValue == nil {
  32054. return v, errors.New("OldBotType requires an ID field in the mutation")
  32055. }
  32056. oldValue, err := m.oldValue(ctx)
  32057. if err != nil {
  32058. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  32059. }
  32060. return oldValue.BotType, nil
  32061. }
  32062. // AddBotType adds u to the "bot_type" field.
  32063. func (m *WxCardVisitMutation) AddBotType(u int8) {
  32064. if m.addbot_type != nil {
  32065. *m.addbot_type += u
  32066. } else {
  32067. m.addbot_type = &u
  32068. }
  32069. }
  32070. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  32071. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  32072. v := m.addbot_type
  32073. if v == nil {
  32074. return
  32075. }
  32076. return *v, true
  32077. }
  32078. // ResetBotType resets all changes to the "bot_type" field.
  32079. func (m *WxCardVisitMutation) ResetBotType() {
  32080. m.bot_type = nil
  32081. m.addbot_type = nil
  32082. }
  32083. // Where appends a list predicates to the WxCardVisitMutation builder.
  32084. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  32085. m.predicates = append(m.predicates, ps...)
  32086. }
  32087. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  32088. // users can use type-assertion to append predicates that do not depend on any generated package.
  32089. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  32090. p := make([]predicate.WxCardVisit, len(ps))
  32091. for i := range ps {
  32092. p[i] = ps[i]
  32093. }
  32094. m.Where(p...)
  32095. }
  32096. // Op returns the operation name.
  32097. func (m *WxCardVisitMutation) Op() Op {
  32098. return m.op
  32099. }
  32100. // SetOp allows setting the mutation operation.
  32101. func (m *WxCardVisitMutation) SetOp(op Op) {
  32102. m.op = op
  32103. }
  32104. // Type returns the node type of this mutation (WxCardVisit).
  32105. func (m *WxCardVisitMutation) Type() string {
  32106. return m.typ
  32107. }
  32108. // Fields returns all fields that were changed during this mutation. Note that in
  32109. // order to get all numeric fields that were incremented/decremented, call
  32110. // AddedFields().
  32111. func (m *WxCardVisitMutation) Fields() []string {
  32112. fields := make([]string, 0, 6)
  32113. if m.created_at != nil {
  32114. fields = append(fields, wxcardvisit.FieldCreatedAt)
  32115. }
  32116. if m.updated_at != nil {
  32117. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  32118. }
  32119. if m.deleted_at != nil {
  32120. fields = append(fields, wxcardvisit.FieldDeletedAt)
  32121. }
  32122. if m.user_id != nil {
  32123. fields = append(fields, wxcardvisit.FieldUserID)
  32124. }
  32125. if m.bot_id != nil {
  32126. fields = append(fields, wxcardvisit.FieldBotID)
  32127. }
  32128. if m.bot_type != nil {
  32129. fields = append(fields, wxcardvisit.FieldBotType)
  32130. }
  32131. return fields
  32132. }
  32133. // Field returns the value of a field with the given name. The second boolean
  32134. // return value indicates that this field was not set, or was not defined in the
  32135. // schema.
  32136. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  32137. switch name {
  32138. case wxcardvisit.FieldCreatedAt:
  32139. return m.CreatedAt()
  32140. case wxcardvisit.FieldUpdatedAt:
  32141. return m.UpdatedAt()
  32142. case wxcardvisit.FieldDeletedAt:
  32143. return m.DeletedAt()
  32144. case wxcardvisit.FieldUserID:
  32145. return m.UserID()
  32146. case wxcardvisit.FieldBotID:
  32147. return m.BotID()
  32148. case wxcardvisit.FieldBotType:
  32149. return m.BotType()
  32150. }
  32151. return nil, false
  32152. }
  32153. // OldField returns the old value of the field from the database. An error is
  32154. // returned if the mutation operation is not UpdateOne, or the query to the
  32155. // database failed.
  32156. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32157. switch name {
  32158. case wxcardvisit.FieldCreatedAt:
  32159. return m.OldCreatedAt(ctx)
  32160. case wxcardvisit.FieldUpdatedAt:
  32161. return m.OldUpdatedAt(ctx)
  32162. case wxcardvisit.FieldDeletedAt:
  32163. return m.OldDeletedAt(ctx)
  32164. case wxcardvisit.FieldUserID:
  32165. return m.OldUserID(ctx)
  32166. case wxcardvisit.FieldBotID:
  32167. return m.OldBotID(ctx)
  32168. case wxcardvisit.FieldBotType:
  32169. return m.OldBotType(ctx)
  32170. }
  32171. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  32172. }
  32173. // SetField sets the value of a field with the given name. It returns an error if
  32174. // the field is not defined in the schema, or if the type mismatched the field
  32175. // type.
  32176. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  32177. switch name {
  32178. case wxcardvisit.FieldCreatedAt:
  32179. v, ok := value.(time.Time)
  32180. if !ok {
  32181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32182. }
  32183. m.SetCreatedAt(v)
  32184. return nil
  32185. case wxcardvisit.FieldUpdatedAt:
  32186. v, ok := value.(time.Time)
  32187. if !ok {
  32188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32189. }
  32190. m.SetUpdatedAt(v)
  32191. return nil
  32192. case wxcardvisit.FieldDeletedAt:
  32193. v, ok := value.(time.Time)
  32194. if !ok {
  32195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32196. }
  32197. m.SetDeletedAt(v)
  32198. return nil
  32199. case wxcardvisit.FieldUserID:
  32200. v, ok := value.(uint64)
  32201. if !ok {
  32202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32203. }
  32204. m.SetUserID(v)
  32205. return nil
  32206. case wxcardvisit.FieldBotID:
  32207. v, ok := value.(uint64)
  32208. if !ok {
  32209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32210. }
  32211. m.SetBotID(v)
  32212. return nil
  32213. case wxcardvisit.FieldBotType:
  32214. v, ok := value.(uint8)
  32215. if !ok {
  32216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32217. }
  32218. m.SetBotType(v)
  32219. return nil
  32220. }
  32221. return fmt.Errorf("unknown WxCardVisit field %s", name)
  32222. }
  32223. // AddedFields returns all numeric fields that were incremented/decremented during
  32224. // this mutation.
  32225. func (m *WxCardVisitMutation) AddedFields() []string {
  32226. var fields []string
  32227. if m.adduser_id != nil {
  32228. fields = append(fields, wxcardvisit.FieldUserID)
  32229. }
  32230. if m.addbot_id != nil {
  32231. fields = append(fields, wxcardvisit.FieldBotID)
  32232. }
  32233. if m.addbot_type != nil {
  32234. fields = append(fields, wxcardvisit.FieldBotType)
  32235. }
  32236. return fields
  32237. }
  32238. // AddedField returns the numeric value that was incremented/decremented on a field
  32239. // with the given name. The second boolean return value indicates that this field
  32240. // was not set, or was not defined in the schema.
  32241. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  32242. switch name {
  32243. case wxcardvisit.FieldUserID:
  32244. return m.AddedUserID()
  32245. case wxcardvisit.FieldBotID:
  32246. return m.AddedBotID()
  32247. case wxcardvisit.FieldBotType:
  32248. return m.AddedBotType()
  32249. }
  32250. return nil, false
  32251. }
  32252. // AddField adds the value to the field with the given name. It returns an error if
  32253. // the field is not defined in the schema, or if the type mismatched the field
  32254. // type.
  32255. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  32256. switch name {
  32257. case wxcardvisit.FieldUserID:
  32258. v, ok := value.(int64)
  32259. if !ok {
  32260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32261. }
  32262. m.AddUserID(v)
  32263. return nil
  32264. case wxcardvisit.FieldBotID:
  32265. v, ok := value.(int64)
  32266. if !ok {
  32267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32268. }
  32269. m.AddBotID(v)
  32270. return nil
  32271. case wxcardvisit.FieldBotType:
  32272. v, ok := value.(int8)
  32273. if !ok {
  32274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32275. }
  32276. m.AddBotType(v)
  32277. return nil
  32278. }
  32279. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  32280. }
  32281. // ClearedFields returns all nullable fields that were cleared during this
  32282. // mutation.
  32283. func (m *WxCardVisitMutation) ClearedFields() []string {
  32284. var fields []string
  32285. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  32286. fields = append(fields, wxcardvisit.FieldDeletedAt)
  32287. }
  32288. if m.FieldCleared(wxcardvisit.FieldUserID) {
  32289. fields = append(fields, wxcardvisit.FieldUserID)
  32290. }
  32291. return fields
  32292. }
  32293. // FieldCleared returns a boolean indicating if a field with the given name was
  32294. // cleared in this mutation.
  32295. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  32296. _, ok := m.clearedFields[name]
  32297. return ok
  32298. }
  32299. // ClearField clears the value of the field with the given name. It returns an
  32300. // error if the field is not defined in the schema.
  32301. func (m *WxCardVisitMutation) ClearField(name string) error {
  32302. switch name {
  32303. case wxcardvisit.FieldDeletedAt:
  32304. m.ClearDeletedAt()
  32305. return nil
  32306. case wxcardvisit.FieldUserID:
  32307. m.ClearUserID()
  32308. return nil
  32309. }
  32310. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  32311. }
  32312. // ResetField resets all changes in the mutation for the field with the given name.
  32313. // It returns an error if the field is not defined in the schema.
  32314. func (m *WxCardVisitMutation) ResetField(name string) error {
  32315. switch name {
  32316. case wxcardvisit.FieldCreatedAt:
  32317. m.ResetCreatedAt()
  32318. return nil
  32319. case wxcardvisit.FieldUpdatedAt:
  32320. m.ResetUpdatedAt()
  32321. return nil
  32322. case wxcardvisit.FieldDeletedAt:
  32323. m.ResetDeletedAt()
  32324. return nil
  32325. case wxcardvisit.FieldUserID:
  32326. m.ResetUserID()
  32327. return nil
  32328. case wxcardvisit.FieldBotID:
  32329. m.ResetBotID()
  32330. return nil
  32331. case wxcardvisit.FieldBotType:
  32332. m.ResetBotType()
  32333. return nil
  32334. }
  32335. return fmt.Errorf("unknown WxCardVisit field %s", name)
  32336. }
  32337. // AddedEdges returns all edge names that were set/added in this mutation.
  32338. func (m *WxCardVisitMutation) AddedEdges() []string {
  32339. edges := make([]string, 0, 0)
  32340. return edges
  32341. }
  32342. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32343. // name in this mutation.
  32344. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  32345. return nil
  32346. }
  32347. // RemovedEdges returns all edge names that were removed in this mutation.
  32348. func (m *WxCardVisitMutation) RemovedEdges() []string {
  32349. edges := make([]string, 0, 0)
  32350. return edges
  32351. }
  32352. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32353. // the given name in this mutation.
  32354. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  32355. return nil
  32356. }
  32357. // ClearedEdges returns all edge names that were cleared in this mutation.
  32358. func (m *WxCardVisitMutation) ClearedEdges() []string {
  32359. edges := make([]string, 0, 0)
  32360. return edges
  32361. }
  32362. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32363. // was cleared in this mutation.
  32364. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  32365. return false
  32366. }
  32367. // ClearEdge clears the value of the edge with the given name. It returns an error
  32368. // if that edge is not defined in the schema.
  32369. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  32370. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  32371. }
  32372. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32373. // It returns an error if the edge is not defined in the schema.
  32374. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  32375. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  32376. }