mutation.go 895 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352
  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/message"
  23. "wechat-api/ent/messagerecords"
  24. "wechat-api/ent/msg"
  25. "wechat-api/ent/predicate"
  26. "wechat-api/ent/server"
  27. "wechat-api/ent/sopnode"
  28. "wechat-api/ent/sopstage"
  29. "wechat-api/ent/soptask"
  30. "wechat-api/ent/token"
  31. "wechat-api/ent/tutorial"
  32. "wechat-api/ent/workexperience"
  33. "wechat-api/ent/wx"
  34. "wechat-api/ent/wxcard"
  35. "wechat-api/ent/wxcarduser"
  36. "wechat-api/ent/wxcardvisit"
  37. "entgo.io/ent"
  38. "entgo.io/ent/dialect/sql"
  39. )
  40. const (
  41. // Operation types.
  42. OpCreate = ent.OpCreate
  43. OpDelete = ent.OpDelete
  44. OpDeleteOne = ent.OpDeleteOne
  45. OpUpdate = ent.OpUpdate
  46. OpUpdateOne = ent.OpUpdateOne
  47. // Node types.
  48. TypeAgent = "Agent"
  49. TypeAgentBase = "AgentBase"
  50. TypeAliyunAvatar = "AliyunAvatar"
  51. TypeBatchMsg = "BatchMsg"
  52. TypeCategory = "Category"
  53. TypeChatRecords = "ChatRecords"
  54. TypeChatSession = "ChatSession"
  55. TypeContact = "Contact"
  56. TypeEmployee = "Employee"
  57. TypeEmployeeConfig = "EmployeeConfig"
  58. TypeLabel = "Label"
  59. TypeLabelRelationship = "LabelRelationship"
  60. TypeMessage = "Message"
  61. TypeMessageRecords = "MessageRecords"
  62. TypeMsg = "Msg"
  63. TypeServer = "Server"
  64. TypeSopNode = "SopNode"
  65. TypeSopStage = "SopStage"
  66. TypeSopTask = "SopTask"
  67. TypeToken = "Token"
  68. TypeTutorial = "Tutorial"
  69. TypeWorkExperience = "WorkExperience"
  70. TypeWx = "Wx"
  71. TypeWxCard = "WxCard"
  72. TypeWxCardUser = "WxCardUser"
  73. TypeWxCardVisit = "WxCardVisit"
  74. )
  75. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  76. type AgentMutation struct {
  77. config
  78. op Op
  79. typ string
  80. id *uint64
  81. created_at *time.Time
  82. updated_at *time.Time
  83. deleted_at *time.Time
  84. name *string
  85. role *string
  86. status *int
  87. addstatus *int
  88. background *string
  89. examples *string
  90. organization_id *uint64
  91. addorganization_id *int64
  92. dataset_id *string
  93. collection_id *string
  94. clearedFields map[string]struct{}
  95. wx_agent map[uint64]struct{}
  96. removedwx_agent map[uint64]struct{}
  97. clearedwx_agent bool
  98. token_agent map[uint64]struct{}
  99. removedtoken_agent map[uint64]struct{}
  100. clearedtoken_agent bool
  101. done bool
  102. oldValue func(context.Context) (*Agent, error)
  103. predicates []predicate.Agent
  104. }
  105. var _ ent.Mutation = (*AgentMutation)(nil)
  106. // agentOption allows management of the mutation configuration using functional options.
  107. type agentOption func(*AgentMutation)
  108. // newAgentMutation creates new mutation for the Agent entity.
  109. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  110. m := &AgentMutation{
  111. config: c,
  112. op: op,
  113. typ: TypeAgent,
  114. clearedFields: make(map[string]struct{}),
  115. }
  116. for _, opt := range opts {
  117. opt(m)
  118. }
  119. return m
  120. }
  121. // withAgentID sets the ID field of the mutation.
  122. func withAgentID(id uint64) agentOption {
  123. return func(m *AgentMutation) {
  124. var (
  125. err error
  126. once sync.Once
  127. value *Agent
  128. )
  129. m.oldValue = func(ctx context.Context) (*Agent, error) {
  130. once.Do(func() {
  131. if m.done {
  132. err = errors.New("querying old values post mutation is not allowed")
  133. } else {
  134. value, err = m.Client().Agent.Get(ctx, id)
  135. }
  136. })
  137. return value, err
  138. }
  139. m.id = &id
  140. }
  141. }
  142. // withAgent sets the old Agent of the mutation.
  143. func withAgent(node *Agent) agentOption {
  144. return func(m *AgentMutation) {
  145. m.oldValue = func(context.Context) (*Agent, error) {
  146. return node, nil
  147. }
  148. m.id = &node.ID
  149. }
  150. }
  151. // Client returns a new `ent.Client` from the mutation. If the mutation was
  152. // executed in a transaction (ent.Tx), a transactional client is returned.
  153. func (m AgentMutation) Client() *Client {
  154. client := &Client{config: m.config}
  155. client.init()
  156. return client
  157. }
  158. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  159. // it returns an error otherwise.
  160. func (m AgentMutation) Tx() (*Tx, error) {
  161. if _, ok := m.driver.(*txDriver); !ok {
  162. return nil, errors.New("ent: mutation is not running in a transaction")
  163. }
  164. tx := &Tx{config: m.config}
  165. tx.init()
  166. return tx, nil
  167. }
  168. // SetID sets the value of the id field. Note that this
  169. // operation is only accepted on creation of Agent entities.
  170. func (m *AgentMutation) SetID(id uint64) {
  171. m.id = &id
  172. }
  173. // ID returns the ID value in the mutation. Note that the ID is only available
  174. // if it was provided to the builder or after it was returned from the database.
  175. func (m *AgentMutation) ID() (id uint64, exists bool) {
  176. if m.id == nil {
  177. return
  178. }
  179. return *m.id, true
  180. }
  181. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  182. // That means, if the mutation is applied within a transaction with an isolation level such
  183. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  184. // or updated by the mutation.
  185. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  186. switch {
  187. case m.op.Is(OpUpdateOne | OpDeleteOne):
  188. id, exists := m.ID()
  189. if exists {
  190. return []uint64{id}, nil
  191. }
  192. fallthrough
  193. case m.op.Is(OpUpdate | OpDelete):
  194. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  195. default:
  196. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  197. }
  198. }
  199. // SetCreatedAt sets the "created_at" field.
  200. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  201. m.created_at = &t
  202. }
  203. // CreatedAt returns the value of the "created_at" field in the mutation.
  204. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  205. v := m.created_at
  206. if v == nil {
  207. return
  208. }
  209. return *v, true
  210. }
  211. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  212. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  214. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  215. if !m.op.Is(OpUpdateOne) {
  216. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  217. }
  218. if m.id == nil || m.oldValue == nil {
  219. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  220. }
  221. oldValue, err := m.oldValue(ctx)
  222. if err != nil {
  223. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  224. }
  225. return oldValue.CreatedAt, nil
  226. }
  227. // ResetCreatedAt resets all changes to the "created_at" field.
  228. func (m *AgentMutation) ResetCreatedAt() {
  229. m.created_at = nil
  230. }
  231. // SetUpdatedAt sets the "updated_at" field.
  232. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  233. m.updated_at = &t
  234. }
  235. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  236. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  237. v := m.updated_at
  238. if v == nil {
  239. return
  240. }
  241. return *v, true
  242. }
  243. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  244. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  246. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  247. if !m.op.Is(OpUpdateOne) {
  248. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  249. }
  250. if m.id == nil || m.oldValue == nil {
  251. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  252. }
  253. oldValue, err := m.oldValue(ctx)
  254. if err != nil {
  255. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  256. }
  257. return oldValue.UpdatedAt, nil
  258. }
  259. // ResetUpdatedAt resets all changes to the "updated_at" field.
  260. func (m *AgentMutation) ResetUpdatedAt() {
  261. m.updated_at = nil
  262. }
  263. // SetDeletedAt sets the "deleted_at" field.
  264. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  265. m.deleted_at = &t
  266. }
  267. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  268. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  269. v := m.deleted_at
  270. if v == nil {
  271. return
  272. }
  273. return *v, true
  274. }
  275. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  276. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  278. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  279. if !m.op.Is(OpUpdateOne) {
  280. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  281. }
  282. if m.id == nil || m.oldValue == nil {
  283. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  284. }
  285. oldValue, err := m.oldValue(ctx)
  286. if err != nil {
  287. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  288. }
  289. return oldValue.DeletedAt, nil
  290. }
  291. // ClearDeletedAt clears the value of the "deleted_at" field.
  292. func (m *AgentMutation) ClearDeletedAt() {
  293. m.deleted_at = nil
  294. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  295. }
  296. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  297. func (m *AgentMutation) DeletedAtCleared() bool {
  298. _, ok := m.clearedFields[agent.FieldDeletedAt]
  299. return ok
  300. }
  301. // ResetDeletedAt resets all changes to the "deleted_at" field.
  302. func (m *AgentMutation) ResetDeletedAt() {
  303. m.deleted_at = nil
  304. delete(m.clearedFields, agent.FieldDeletedAt)
  305. }
  306. // SetName sets the "name" field.
  307. func (m *AgentMutation) SetName(s string) {
  308. m.name = &s
  309. }
  310. // Name returns the value of the "name" field in the mutation.
  311. func (m *AgentMutation) Name() (r string, exists bool) {
  312. v := m.name
  313. if v == nil {
  314. return
  315. }
  316. return *v, true
  317. }
  318. // OldName returns the old "name" field's value of the Agent entity.
  319. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  321. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  322. if !m.op.Is(OpUpdateOne) {
  323. return v, errors.New("OldName is only allowed on UpdateOne operations")
  324. }
  325. if m.id == nil || m.oldValue == nil {
  326. return v, errors.New("OldName requires an ID field in the mutation")
  327. }
  328. oldValue, err := m.oldValue(ctx)
  329. if err != nil {
  330. return v, fmt.Errorf("querying old value for OldName: %w", err)
  331. }
  332. return oldValue.Name, nil
  333. }
  334. // ResetName resets all changes to the "name" field.
  335. func (m *AgentMutation) ResetName() {
  336. m.name = nil
  337. }
  338. // SetRole sets the "role" field.
  339. func (m *AgentMutation) SetRole(s string) {
  340. m.role = &s
  341. }
  342. // Role returns the value of the "role" field in the mutation.
  343. func (m *AgentMutation) Role() (r string, exists bool) {
  344. v := m.role
  345. if v == nil {
  346. return
  347. }
  348. return *v, true
  349. }
  350. // OldRole returns the old "role" field's value of the Agent entity.
  351. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  353. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  354. if !m.op.Is(OpUpdateOne) {
  355. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  356. }
  357. if m.id == nil || m.oldValue == nil {
  358. return v, errors.New("OldRole requires an ID field in the mutation")
  359. }
  360. oldValue, err := m.oldValue(ctx)
  361. if err != nil {
  362. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  363. }
  364. return oldValue.Role, nil
  365. }
  366. // ResetRole resets all changes to the "role" field.
  367. func (m *AgentMutation) ResetRole() {
  368. m.role = nil
  369. }
  370. // SetStatus sets the "status" field.
  371. func (m *AgentMutation) SetStatus(i int) {
  372. m.status = &i
  373. m.addstatus = nil
  374. }
  375. // Status returns the value of the "status" field in the mutation.
  376. func (m *AgentMutation) Status() (r int, exists bool) {
  377. v := m.status
  378. if v == nil {
  379. return
  380. }
  381. return *v, true
  382. }
  383. // OldStatus returns the old "status" field's value of the Agent entity.
  384. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  386. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  387. if !m.op.Is(OpUpdateOne) {
  388. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  389. }
  390. if m.id == nil || m.oldValue == nil {
  391. return v, errors.New("OldStatus requires an ID field in the mutation")
  392. }
  393. oldValue, err := m.oldValue(ctx)
  394. if err != nil {
  395. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  396. }
  397. return oldValue.Status, nil
  398. }
  399. // AddStatus adds i to the "status" field.
  400. func (m *AgentMutation) AddStatus(i int) {
  401. if m.addstatus != nil {
  402. *m.addstatus += i
  403. } else {
  404. m.addstatus = &i
  405. }
  406. }
  407. // AddedStatus returns the value that was added to the "status" field in this mutation.
  408. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  409. v := m.addstatus
  410. if v == nil {
  411. return
  412. }
  413. return *v, true
  414. }
  415. // ClearStatus clears the value of the "status" field.
  416. func (m *AgentMutation) ClearStatus() {
  417. m.status = nil
  418. m.addstatus = nil
  419. m.clearedFields[agent.FieldStatus] = struct{}{}
  420. }
  421. // StatusCleared returns if the "status" field was cleared in this mutation.
  422. func (m *AgentMutation) StatusCleared() bool {
  423. _, ok := m.clearedFields[agent.FieldStatus]
  424. return ok
  425. }
  426. // ResetStatus resets all changes to the "status" field.
  427. func (m *AgentMutation) ResetStatus() {
  428. m.status = nil
  429. m.addstatus = nil
  430. delete(m.clearedFields, agent.FieldStatus)
  431. }
  432. // SetBackground sets the "background" field.
  433. func (m *AgentMutation) SetBackground(s string) {
  434. m.background = &s
  435. }
  436. // Background returns the value of the "background" field in the mutation.
  437. func (m *AgentMutation) Background() (r string, exists bool) {
  438. v := m.background
  439. if v == nil {
  440. return
  441. }
  442. return *v, true
  443. }
  444. // OldBackground returns the old "background" field's value of the Agent entity.
  445. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  447. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  448. if !m.op.Is(OpUpdateOne) {
  449. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  450. }
  451. if m.id == nil || m.oldValue == nil {
  452. return v, errors.New("OldBackground requires an ID field in the mutation")
  453. }
  454. oldValue, err := m.oldValue(ctx)
  455. if err != nil {
  456. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  457. }
  458. return oldValue.Background, nil
  459. }
  460. // ClearBackground clears the value of the "background" field.
  461. func (m *AgentMutation) ClearBackground() {
  462. m.background = nil
  463. m.clearedFields[agent.FieldBackground] = struct{}{}
  464. }
  465. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  466. func (m *AgentMutation) BackgroundCleared() bool {
  467. _, ok := m.clearedFields[agent.FieldBackground]
  468. return ok
  469. }
  470. // ResetBackground resets all changes to the "background" field.
  471. func (m *AgentMutation) ResetBackground() {
  472. m.background = nil
  473. delete(m.clearedFields, agent.FieldBackground)
  474. }
  475. // SetExamples sets the "examples" field.
  476. func (m *AgentMutation) SetExamples(s string) {
  477. m.examples = &s
  478. }
  479. // Examples returns the value of the "examples" field in the mutation.
  480. func (m *AgentMutation) Examples() (r string, exists bool) {
  481. v := m.examples
  482. if v == nil {
  483. return
  484. }
  485. return *v, true
  486. }
  487. // OldExamples returns the old "examples" field's value of the Agent entity.
  488. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  490. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  491. if !m.op.Is(OpUpdateOne) {
  492. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  493. }
  494. if m.id == nil || m.oldValue == nil {
  495. return v, errors.New("OldExamples requires an ID field in the mutation")
  496. }
  497. oldValue, err := m.oldValue(ctx)
  498. if err != nil {
  499. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  500. }
  501. return oldValue.Examples, nil
  502. }
  503. // ClearExamples clears the value of the "examples" field.
  504. func (m *AgentMutation) ClearExamples() {
  505. m.examples = nil
  506. m.clearedFields[agent.FieldExamples] = struct{}{}
  507. }
  508. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  509. func (m *AgentMutation) ExamplesCleared() bool {
  510. _, ok := m.clearedFields[agent.FieldExamples]
  511. return ok
  512. }
  513. // ResetExamples resets all changes to the "examples" field.
  514. func (m *AgentMutation) ResetExamples() {
  515. m.examples = nil
  516. delete(m.clearedFields, agent.FieldExamples)
  517. }
  518. // SetOrganizationID sets the "organization_id" field.
  519. func (m *AgentMutation) SetOrganizationID(u uint64) {
  520. m.organization_id = &u
  521. m.addorganization_id = nil
  522. }
  523. // OrganizationID returns the value of the "organization_id" field in the mutation.
  524. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  525. v := m.organization_id
  526. if v == nil {
  527. return
  528. }
  529. return *v, true
  530. }
  531. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  532. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  534. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  535. if !m.op.Is(OpUpdateOne) {
  536. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  537. }
  538. if m.id == nil || m.oldValue == nil {
  539. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  540. }
  541. oldValue, err := m.oldValue(ctx)
  542. if err != nil {
  543. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  544. }
  545. return oldValue.OrganizationID, nil
  546. }
  547. // AddOrganizationID adds u to the "organization_id" field.
  548. func (m *AgentMutation) AddOrganizationID(u int64) {
  549. if m.addorganization_id != nil {
  550. *m.addorganization_id += u
  551. } else {
  552. m.addorganization_id = &u
  553. }
  554. }
  555. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  556. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  557. v := m.addorganization_id
  558. if v == nil {
  559. return
  560. }
  561. return *v, true
  562. }
  563. // ResetOrganizationID resets all changes to the "organization_id" field.
  564. func (m *AgentMutation) ResetOrganizationID() {
  565. m.organization_id = nil
  566. m.addorganization_id = nil
  567. }
  568. // SetDatasetID sets the "dataset_id" field.
  569. func (m *AgentMutation) SetDatasetID(s string) {
  570. m.dataset_id = &s
  571. }
  572. // DatasetID returns the value of the "dataset_id" field in the mutation.
  573. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  574. v := m.dataset_id
  575. if v == nil {
  576. return
  577. }
  578. return *v, true
  579. }
  580. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  581. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  583. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  584. if !m.op.Is(OpUpdateOne) {
  585. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  586. }
  587. if m.id == nil || m.oldValue == nil {
  588. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  589. }
  590. oldValue, err := m.oldValue(ctx)
  591. if err != nil {
  592. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  593. }
  594. return oldValue.DatasetID, nil
  595. }
  596. // ResetDatasetID resets all changes to the "dataset_id" field.
  597. func (m *AgentMutation) ResetDatasetID() {
  598. m.dataset_id = nil
  599. }
  600. // SetCollectionID sets the "collection_id" field.
  601. func (m *AgentMutation) SetCollectionID(s string) {
  602. m.collection_id = &s
  603. }
  604. // CollectionID returns the value of the "collection_id" field in the mutation.
  605. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  606. v := m.collection_id
  607. if v == nil {
  608. return
  609. }
  610. return *v, true
  611. }
  612. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  613. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  615. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  616. if !m.op.Is(OpUpdateOne) {
  617. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  618. }
  619. if m.id == nil || m.oldValue == nil {
  620. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  621. }
  622. oldValue, err := m.oldValue(ctx)
  623. if err != nil {
  624. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  625. }
  626. return oldValue.CollectionID, nil
  627. }
  628. // ResetCollectionID resets all changes to the "collection_id" field.
  629. func (m *AgentMutation) ResetCollectionID() {
  630. m.collection_id = nil
  631. }
  632. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  633. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  634. if m.wx_agent == nil {
  635. m.wx_agent = make(map[uint64]struct{})
  636. }
  637. for i := range ids {
  638. m.wx_agent[ids[i]] = struct{}{}
  639. }
  640. }
  641. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  642. func (m *AgentMutation) ClearWxAgent() {
  643. m.clearedwx_agent = true
  644. }
  645. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  646. func (m *AgentMutation) WxAgentCleared() bool {
  647. return m.clearedwx_agent
  648. }
  649. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  650. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  651. if m.removedwx_agent == nil {
  652. m.removedwx_agent = make(map[uint64]struct{})
  653. }
  654. for i := range ids {
  655. delete(m.wx_agent, ids[i])
  656. m.removedwx_agent[ids[i]] = struct{}{}
  657. }
  658. }
  659. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  660. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  661. for id := range m.removedwx_agent {
  662. ids = append(ids, id)
  663. }
  664. return
  665. }
  666. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  667. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  668. for id := range m.wx_agent {
  669. ids = append(ids, id)
  670. }
  671. return
  672. }
  673. // ResetWxAgent resets all changes to the "wx_agent" edge.
  674. func (m *AgentMutation) ResetWxAgent() {
  675. m.wx_agent = nil
  676. m.clearedwx_agent = false
  677. m.removedwx_agent = nil
  678. }
  679. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  680. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  681. if m.token_agent == nil {
  682. m.token_agent = make(map[uint64]struct{})
  683. }
  684. for i := range ids {
  685. m.token_agent[ids[i]] = struct{}{}
  686. }
  687. }
  688. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  689. func (m *AgentMutation) ClearTokenAgent() {
  690. m.clearedtoken_agent = true
  691. }
  692. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  693. func (m *AgentMutation) TokenAgentCleared() bool {
  694. return m.clearedtoken_agent
  695. }
  696. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  697. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  698. if m.removedtoken_agent == nil {
  699. m.removedtoken_agent = make(map[uint64]struct{})
  700. }
  701. for i := range ids {
  702. delete(m.token_agent, ids[i])
  703. m.removedtoken_agent[ids[i]] = struct{}{}
  704. }
  705. }
  706. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  707. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  708. for id := range m.removedtoken_agent {
  709. ids = append(ids, id)
  710. }
  711. return
  712. }
  713. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  714. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  715. for id := range m.token_agent {
  716. ids = append(ids, id)
  717. }
  718. return
  719. }
  720. // ResetTokenAgent resets all changes to the "token_agent" edge.
  721. func (m *AgentMutation) ResetTokenAgent() {
  722. m.token_agent = nil
  723. m.clearedtoken_agent = false
  724. m.removedtoken_agent = nil
  725. }
  726. // Where appends a list predicates to the AgentMutation builder.
  727. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  728. m.predicates = append(m.predicates, ps...)
  729. }
  730. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  731. // users can use type-assertion to append predicates that do not depend on any generated package.
  732. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  733. p := make([]predicate.Agent, len(ps))
  734. for i := range ps {
  735. p[i] = ps[i]
  736. }
  737. m.Where(p...)
  738. }
  739. // Op returns the operation name.
  740. func (m *AgentMutation) Op() Op {
  741. return m.op
  742. }
  743. // SetOp allows setting the mutation operation.
  744. func (m *AgentMutation) SetOp(op Op) {
  745. m.op = op
  746. }
  747. // Type returns the node type of this mutation (Agent).
  748. func (m *AgentMutation) Type() string {
  749. return m.typ
  750. }
  751. // Fields returns all fields that were changed during this mutation. Note that in
  752. // order to get all numeric fields that were incremented/decremented, call
  753. // AddedFields().
  754. func (m *AgentMutation) Fields() []string {
  755. fields := make([]string, 0, 11)
  756. if m.created_at != nil {
  757. fields = append(fields, agent.FieldCreatedAt)
  758. }
  759. if m.updated_at != nil {
  760. fields = append(fields, agent.FieldUpdatedAt)
  761. }
  762. if m.deleted_at != nil {
  763. fields = append(fields, agent.FieldDeletedAt)
  764. }
  765. if m.name != nil {
  766. fields = append(fields, agent.FieldName)
  767. }
  768. if m.role != nil {
  769. fields = append(fields, agent.FieldRole)
  770. }
  771. if m.status != nil {
  772. fields = append(fields, agent.FieldStatus)
  773. }
  774. if m.background != nil {
  775. fields = append(fields, agent.FieldBackground)
  776. }
  777. if m.examples != nil {
  778. fields = append(fields, agent.FieldExamples)
  779. }
  780. if m.organization_id != nil {
  781. fields = append(fields, agent.FieldOrganizationID)
  782. }
  783. if m.dataset_id != nil {
  784. fields = append(fields, agent.FieldDatasetID)
  785. }
  786. if m.collection_id != nil {
  787. fields = append(fields, agent.FieldCollectionID)
  788. }
  789. return fields
  790. }
  791. // Field returns the value of a field with the given name. The second boolean
  792. // return value indicates that this field was not set, or was not defined in the
  793. // schema.
  794. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  795. switch name {
  796. case agent.FieldCreatedAt:
  797. return m.CreatedAt()
  798. case agent.FieldUpdatedAt:
  799. return m.UpdatedAt()
  800. case agent.FieldDeletedAt:
  801. return m.DeletedAt()
  802. case agent.FieldName:
  803. return m.Name()
  804. case agent.FieldRole:
  805. return m.Role()
  806. case agent.FieldStatus:
  807. return m.Status()
  808. case agent.FieldBackground:
  809. return m.Background()
  810. case agent.FieldExamples:
  811. return m.Examples()
  812. case agent.FieldOrganizationID:
  813. return m.OrganizationID()
  814. case agent.FieldDatasetID:
  815. return m.DatasetID()
  816. case agent.FieldCollectionID:
  817. return m.CollectionID()
  818. }
  819. return nil, false
  820. }
  821. // OldField returns the old value of the field from the database. An error is
  822. // returned if the mutation operation is not UpdateOne, or the query to the
  823. // database failed.
  824. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  825. switch name {
  826. case agent.FieldCreatedAt:
  827. return m.OldCreatedAt(ctx)
  828. case agent.FieldUpdatedAt:
  829. return m.OldUpdatedAt(ctx)
  830. case agent.FieldDeletedAt:
  831. return m.OldDeletedAt(ctx)
  832. case agent.FieldName:
  833. return m.OldName(ctx)
  834. case agent.FieldRole:
  835. return m.OldRole(ctx)
  836. case agent.FieldStatus:
  837. return m.OldStatus(ctx)
  838. case agent.FieldBackground:
  839. return m.OldBackground(ctx)
  840. case agent.FieldExamples:
  841. return m.OldExamples(ctx)
  842. case agent.FieldOrganizationID:
  843. return m.OldOrganizationID(ctx)
  844. case agent.FieldDatasetID:
  845. return m.OldDatasetID(ctx)
  846. case agent.FieldCollectionID:
  847. return m.OldCollectionID(ctx)
  848. }
  849. return nil, fmt.Errorf("unknown Agent field %s", name)
  850. }
  851. // SetField sets the value of a field with the given name. It returns an error if
  852. // the field is not defined in the schema, or if the type mismatched the field
  853. // type.
  854. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  855. switch name {
  856. case agent.FieldCreatedAt:
  857. v, ok := value.(time.Time)
  858. if !ok {
  859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  860. }
  861. m.SetCreatedAt(v)
  862. return nil
  863. case agent.FieldUpdatedAt:
  864. v, ok := value.(time.Time)
  865. if !ok {
  866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  867. }
  868. m.SetUpdatedAt(v)
  869. return nil
  870. case agent.FieldDeletedAt:
  871. v, ok := value.(time.Time)
  872. if !ok {
  873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  874. }
  875. m.SetDeletedAt(v)
  876. return nil
  877. case agent.FieldName:
  878. v, ok := value.(string)
  879. if !ok {
  880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  881. }
  882. m.SetName(v)
  883. return nil
  884. case agent.FieldRole:
  885. v, ok := value.(string)
  886. if !ok {
  887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  888. }
  889. m.SetRole(v)
  890. return nil
  891. case agent.FieldStatus:
  892. v, ok := value.(int)
  893. if !ok {
  894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  895. }
  896. m.SetStatus(v)
  897. return nil
  898. case agent.FieldBackground:
  899. v, ok := value.(string)
  900. if !ok {
  901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  902. }
  903. m.SetBackground(v)
  904. return nil
  905. case agent.FieldExamples:
  906. v, ok := value.(string)
  907. if !ok {
  908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  909. }
  910. m.SetExamples(v)
  911. return nil
  912. case agent.FieldOrganizationID:
  913. v, ok := value.(uint64)
  914. if !ok {
  915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  916. }
  917. m.SetOrganizationID(v)
  918. return nil
  919. case agent.FieldDatasetID:
  920. v, ok := value.(string)
  921. if !ok {
  922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  923. }
  924. m.SetDatasetID(v)
  925. return nil
  926. case agent.FieldCollectionID:
  927. v, ok := value.(string)
  928. if !ok {
  929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  930. }
  931. m.SetCollectionID(v)
  932. return nil
  933. }
  934. return fmt.Errorf("unknown Agent field %s", name)
  935. }
  936. // AddedFields returns all numeric fields that were incremented/decremented during
  937. // this mutation.
  938. func (m *AgentMutation) AddedFields() []string {
  939. var fields []string
  940. if m.addstatus != nil {
  941. fields = append(fields, agent.FieldStatus)
  942. }
  943. if m.addorganization_id != nil {
  944. fields = append(fields, agent.FieldOrganizationID)
  945. }
  946. return fields
  947. }
  948. // AddedField returns the numeric value that was incremented/decremented on a field
  949. // with the given name. The second boolean return value indicates that this field
  950. // was not set, or was not defined in the schema.
  951. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  952. switch name {
  953. case agent.FieldStatus:
  954. return m.AddedStatus()
  955. case agent.FieldOrganizationID:
  956. return m.AddedOrganizationID()
  957. }
  958. return nil, false
  959. }
  960. // AddField adds the value to the field with the given name. It returns an error if
  961. // the field is not defined in the schema, or if the type mismatched the field
  962. // type.
  963. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  964. switch name {
  965. case agent.FieldStatus:
  966. v, ok := value.(int)
  967. if !ok {
  968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  969. }
  970. m.AddStatus(v)
  971. return nil
  972. case agent.FieldOrganizationID:
  973. v, ok := value.(int64)
  974. if !ok {
  975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  976. }
  977. m.AddOrganizationID(v)
  978. return nil
  979. }
  980. return fmt.Errorf("unknown Agent numeric field %s", name)
  981. }
  982. // ClearedFields returns all nullable fields that were cleared during this
  983. // mutation.
  984. func (m *AgentMutation) ClearedFields() []string {
  985. var fields []string
  986. if m.FieldCleared(agent.FieldDeletedAt) {
  987. fields = append(fields, agent.FieldDeletedAt)
  988. }
  989. if m.FieldCleared(agent.FieldStatus) {
  990. fields = append(fields, agent.FieldStatus)
  991. }
  992. if m.FieldCleared(agent.FieldBackground) {
  993. fields = append(fields, agent.FieldBackground)
  994. }
  995. if m.FieldCleared(agent.FieldExamples) {
  996. fields = append(fields, agent.FieldExamples)
  997. }
  998. return fields
  999. }
  1000. // FieldCleared returns a boolean indicating if a field with the given name was
  1001. // cleared in this mutation.
  1002. func (m *AgentMutation) FieldCleared(name string) bool {
  1003. _, ok := m.clearedFields[name]
  1004. return ok
  1005. }
  1006. // ClearField clears the value of the field with the given name. It returns an
  1007. // error if the field is not defined in the schema.
  1008. func (m *AgentMutation) ClearField(name string) error {
  1009. switch name {
  1010. case agent.FieldDeletedAt:
  1011. m.ClearDeletedAt()
  1012. return nil
  1013. case agent.FieldStatus:
  1014. m.ClearStatus()
  1015. return nil
  1016. case agent.FieldBackground:
  1017. m.ClearBackground()
  1018. return nil
  1019. case agent.FieldExamples:
  1020. m.ClearExamples()
  1021. return nil
  1022. }
  1023. return fmt.Errorf("unknown Agent nullable field %s", name)
  1024. }
  1025. // ResetField resets all changes in the mutation for the field with the given name.
  1026. // It returns an error if the field is not defined in the schema.
  1027. func (m *AgentMutation) ResetField(name string) error {
  1028. switch name {
  1029. case agent.FieldCreatedAt:
  1030. m.ResetCreatedAt()
  1031. return nil
  1032. case agent.FieldUpdatedAt:
  1033. m.ResetUpdatedAt()
  1034. return nil
  1035. case agent.FieldDeletedAt:
  1036. m.ResetDeletedAt()
  1037. return nil
  1038. case agent.FieldName:
  1039. m.ResetName()
  1040. return nil
  1041. case agent.FieldRole:
  1042. m.ResetRole()
  1043. return nil
  1044. case agent.FieldStatus:
  1045. m.ResetStatus()
  1046. return nil
  1047. case agent.FieldBackground:
  1048. m.ResetBackground()
  1049. return nil
  1050. case agent.FieldExamples:
  1051. m.ResetExamples()
  1052. return nil
  1053. case agent.FieldOrganizationID:
  1054. m.ResetOrganizationID()
  1055. return nil
  1056. case agent.FieldDatasetID:
  1057. m.ResetDatasetID()
  1058. return nil
  1059. case agent.FieldCollectionID:
  1060. m.ResetCollectionID()
  1061. return nil
  1062. }
  1063. return fmt.Errorf("unknown Agent field %s", name)
  1064. }
  1065. // AddedEdges returns all edge names that were set/added in this mutation.
  1066. func (m *AgentMutation) AddedEdges() []string {
  1067. edges := make([]string, 0, 2)
  1068. if m.wx_agent != nil {
  1069. edges = append(edges, agent.EdgeWxAgent)
  1070. }
  1071. if m.token_agent != nil {
  1072. edges = append(edges, agent.EdgeTokenAgent)
  1073. }
  1074. return edges
  1075. }
  1076. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1077. // name in this mutation.
  1078. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1079. switch name {
  1080. case agent.EdgeWxAgent:
  1081. ids := make([]ent.Value, 0, len(m.wx_agent))
  1082. for id := range m.wx_agent {
  1083. ids = append(ids, id)
  1084. }
  1085. return ids
  1086. case agent.EdgeTokenAgent:
  1087. ids := make([]ent.Value, 0, len(m.token_agent))
  1088. for id := range m.token_agent {
  1089. ids = append(ids, id)
  1090. }
  1091. return ids
  1092. }
  1093. return nil
  1094. }
  1095. // RemovedEdges returns all edge names that were removed in this mutation.
  1096. func (m *AgentMutation) RemovedEdges() []string {
  1097. edges := make([]string, 0, 2)
  1098. if m.removedwx_agent != nil {
  1099. edges = append(edges, agent.EdgeWxAgent)
  1100. }
  1101. if m.removedtoken_agent != nil {
  1102. edges = append(edges, agent.EdgeTokenAgent)
  1103. }
  1104. return edges
  1105. }
  1106. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1107. // the given name in this mutation.
  1108. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1109. switch name {
  1110. case agent.EdgeWxAgent:
  1111. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1112. for id := range m.removedwx_agent {
  1113. ids = append(ids, id)
  1114. }
  1115. return ids
  1116. case agent.EdgeTokenAgent:
  1117. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1118. for id := range m.removedtoken_agent {
  1119. ids = append(ids, id)
  1120. }
  1121. return ids
  1122. }
  1123. return nil
  1124. }
  1125. // ClearedEdges returns all edge names that were cleared in this mutation.
  1126. func (m *AgentMutation) ClearedEdges() []string {
  1127. edges := make([]string, 0, 2)
  1128. if m.clearedwx_agent {
  1129. edges = append(edges, agent.EdgeWxAgent)
  1130. }
  1131. if m.clearedtoken_agent {
  1132. edges = append(edges, agent.EdgeTokenAgent)
  1133. }
  1134. return edges
  1135. }
  1136. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1137. // was cleared in this mutation.
  1138. func (m *AgentMutation) EdgeCleared(name string) bool {
  1139. switch name {
  1140. case agent.EdgeWxAgent:
  1141. return m.clearedwx_agent
  1142. case agent.EdgeTokenAgent:
  1143. return m.clearedtoken_agent
  1144. }
  1145. return false
  1146. }
  1147. // ClearEdge clears the value of the edge with the given name. It returns an error
  1148. // if that edge is not defined in the schema.
  1149. func (m *AgentMutation) ClearEdge(name string) error {
  1150. switch name {
  1151. }
  1152. return fmt.Errorf("unknown Agent unique edge %s", name)
  1153. }
  1154. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1155. // It returns an error if the edge is not defined in the schema.
  1156. func (m *AgentMutation) ResetEdge(name string) error {
  1157. switch name {
  1158. case agent.EdgeWxAgent:
  1159. m.ResetWxAgent()
  1160. return nil
  1161. case agent.EdgeTokenAgent:
  1162. m.ResetTokenAgent()
  1163. return nil
  1164. }
  1165. return fmt.Errorf("unknown Agent edge %s", name)
  1166. }
  1167. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1168. type AgentBaseMutation struct {
  1169. config
  1170. op Op
  1171. typ string
  1172. id *string
  1173. q *string
  1174. a *string
  1175. chunk_index *uint64
  1176. addchunk_index *int64
  1177. indexes *[]string
  1178. appendindexes []string
  1179. dataset_id *string
  1180. collection_id *string
  1181. source_name *string
  1182. can_write *[]bool
  1183. appendcan_write []bool
  1184. is_owner *[]bool
  1185. appendis_owner []bool
  1186. clearedFields map[string]struct{}
  1187. wx_agent map[uint64]struct{}
  1188. removedwx_agent map[uint64]struct{}
  1189. clearedwx_agent bool
  1190. done bool
  1191. oldValue func(context.Context) (*AgentBase, error)
  1192. predicates []predicate.AgentBase
  1193. }
  1194. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1195. // agentbaseOption allows management of the mutation configuration using functional options.
  1196. type agentbaseOption func(*AgentBaseMutation)
  1197. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1198. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1199. m := &AgentBaseMutation{
  1200. config: c,
  1201. op: op,
  1202. typ: TypeAgentBase,
  1203. clearedFields: make(map[string]struct{}),
  1204. }
  1205. for _, opt := range opts {
  1206. opt(m)
  1207. }
  1208. return m
  1209. }
  1210. // withAgentBaseID sets the ID field of the mutation.
  1211. func withAgentBaseID(id string) agentbaseOption {
  1212. return func(m *AgentBaseMutation) {
  1213. var (
  1214. err error
  1215. once sync.Once
  1216. value *AgentBase
  1217. )
  1218. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1219. once.Do(func() {
  1220. if m.done {
  1221. err = errors.New("querying old values post mutation is not allowed")
  1222. } else {
  1223. value, err = m.Client().AgentBase.Get(ctx, id)
  1224. }
  1225. })
  1226. return value, err
  1227. }
  1228. m.id = &id
  1229. }
  1230. }
  1231. // withAgentBase sets the old AgentBase of the mutation.
  1232. func withAgentBase(node *AgentBase) agentbaseOption {
  1233. return func(m *AgentBaseMutation) {
  1234. m.oldValue = func(context.Context) (*AgentBase, error) {
  1235. return node, nil
  1236. }
  1237. m.id = &node.ID
  1238. }
  1239. }
  1240. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1241. // executed in a transaction (ent.Tx), a transactional client is returned.
  1242. func (m AgentBaseMutation) Client() *Client {
  1243. client := &Client{config: m.config}
  1244. client.init()
  1245. return client
  1246. }
  1247. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1248. // it returns an error otherwise.
  1249. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1250. if _, ok := m.driver.(*txDriver); !ok {
  1251. return nil, errors.New("ent: mutation is not running in a transaction")
  1252. }
  1253. tx := &Tx{config: m.config}
  1254. tx.init()
  1255. return tx, nil
  1256. }
  1257. // SetID sets the value of the id field. Note that this
  1258. // operation is only accepted on creation of AgentBase entities.
  1259. func (m *AgentBaseMutation) SetID(id string) {
  1260. m.id = &id
  1261. }
  1262. // ID returns the ID value in the mutation. Note that the ID is only available
  1263. // if it was provided to the builder or after it was returned from the database.
  1264. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1265. if m.id == nil {
  1266. return
  1267. }
  1268. return *m.id, true
  1269. }
  1270. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1271. // That means, if the mutation is applied within a transaction with an isolation level such
  1272. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1273. // or updated by the mutation.
  1274. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1275. switch {
  1276. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1277. id, exists := m.ID()
  1278. if exists {
  1279. return []string{id}, nil
  1280. }
  1281. fallthrough
  1282. case m.op.Is(OpUpdate | OpDelete):
  1283. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1284. default:
  1285. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1286. }
  1287. }
  1288. // SetQ sets the "q" field.
  1289. func (m *AgentBaseMutation) SetQ(s string) {
  1290. m.q = &s
  1291. }
  1292. // Q returns the value of the "q" field in the mutation.
  1293. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1294. v := m.q
  1295. if v == nil {
  1296. return
  1297. }
  1298. return *v, true
  1299. }
  1300. // OldQ returns the old "q" field's value of the AgentBase entity.
  1301. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1303. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1304. if !m.op.Is(OpUpdateOne) {
  1305. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1306. }
  1307. if m.id == nil || m.oldValue == nil {
  1308. return v, errors.New("OldQ requires an ID field in the mutation")
  1309. }
  1310. oldValue, err := m.oldValue(ctx)
  1311. if err != nil {
  1312. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1313. }
  1314. return oldValue.Q, nil
  1315. }
  1316. // ClearQ clears the value of the "q" field.
  1317. func (m *AgentBaseMutation) ClearQ() {
  1318. m.q = nil
  1319. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1320. }
  1321. // QCleared returns if the "q" field was cleared in this mutation.
  1322. func (m *AgentBaseMutation) QCleared() bool {
  1323. _, ok := m.clearedFields[agentbase.FieldQ]
  1324. return ok
  1325. }
  1326. // ResetQ resets all changes to the "q" field.
  1327. func (m *AgentBaseMutation) ResetQ() {
  1328. m.q = nil
  1329. delete(m.clearedFields, agentbase.FieldQ)
  1330. }
  1331. // SetA sets the "a" field.
  1332. func (m *AgentBaseMutation) SetA(s string) {
  1333. m.a = &s
  1334. }
  1335. // A returns the value of the "a" field in the mutation.
  1336. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1337. v := m.a
  1338. if v == nil {
  1339. return
  1340. }
  1341. return *v, true
  1342. }
  1343. // OldA returns the old "a" field's value of the AgentBase entity.
  1344. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1346. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1347. if !m.op.Is(OpUpdateOne) {
  1348. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1349. }
  1350. if m.id == nil || m.oldValue == nil {
  1351. return v, errors.New("OldA requires an ID field in the mutation")
  1352. }
  1353. oldValue, err := m.oldValue(ctx)
  1354. if err != nil {
  1355. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1356. }
  1357. return oldValue.A, nil
  1358. }
  1359. // ClearA clears the value of the "a" field.
  1360. func (m *AgentBaseMutation) ClearA() {
  1361. m.a = nil
  1362. m.clearedFields[agentbase.FieldA] = struct{}{}
  1363. }
  1364. // ACleared returns if the "a" field was cleared in this mutation.
  1365. func (m *AgentBaseMutation) ACleared() bool {
  1366. _, ok := m.clearedFields[agentbase.FieldA]
  1367. return ok
  1368. }
  1369. // ResetA resets all changes to the "a" field.
  1370. func (m *AgentBaseMutation) ResetA() {
  1371. m.a = nil
  1372. delete(m.clearedFields, agentbase.FieldA)
  1373. }
  1374. // SetChunkIndex sets the "chunk_index" field.
  1375. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1376. m.chunk_index = &u
  1377. m.addchunk_index = nil
  1378. }
  1379. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1380. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1381. v := m.chunk_index
  1382. if v == nil {
  1383. return
  1384. }
  1385. return *v, true
  1386. }
  1387. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1388. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1390. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1391. if !m.op.Is(OpUpdateOne) {
  1392. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1393. }
  1394. if m.id == nil || m.oldValue == nil {
  1395. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1396. }
  1397. oldValue, err := m.oldValue(ctx)
  1398. if err != nil {
  1399. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1400. }
  1401. return oldValue.ChunkIndex, nil
  1402. }
  1403. // AddChunkIndex adds u to the "chunk_index" field.
  1404. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1405. if m.addchunk_index != nil {
  1406. *m.addchunk_index += u
  1407. } else {
  1408. m.addchunk_index = &u
  1409. }
  1410. }
  1411. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1412. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1413. v := m.addchunk_index
  1414. if v == nil {
  1415. return
  1416. }
  1417. return *v, true
  1418. }
  1419. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1420. func (m *AgentBaseMutation) ResetChunkIndex() {
  1421. m.chunk_index = nil
  1422. m.addchunk_index = nil
  1423. }
  1424. // SetIndexes sets the "indexes" field.
  1425. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1426. m.indexes = &s
  1427. m.appendindexes = nil
  1428. }
  1429. // Indexes returns the value of the "indexes" field in the mutation.
  1430. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1431. v := m.indexes
  1432. if v == nil {
  1433. return
  1434. }
  1435. return *v, true
  1436. }
  1437. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1438. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1440. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1441. if !m.op.Is(OpUpdateOne) {
  1442. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1443. }
  1444. if m.id == nil || m.oldValue == nil {
  1445. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1446. }
  1447. oldValue, err := m.oldValue(ctx)
  1448. if err != nil {
  1449. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1450. }
  1451. return oldValue.Indexes, nil
  1452. }
  1453. // AppendIndexes adds s to the "indexes" field.
  1454. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1455. m.appendindexes = append(m.appendindexes, s...)
  1456. }
  1457. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1458. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1459. if len(m.appendindexes) == 0 {
  1460. return nil, false
  1461. }
  1462. return m.appendindexes, true
  1463. }
  1464. // ClearIndexes clears the value of the "indexes" field.
  1465. func (m *AgentBaseMutation) ClearIndexes() {
  1466. m.indexes = nil
  1467. m.appendindexes = nil
  1468. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1469. }
  1470. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1471. func (m *AgentBaseMutation) IndexesCleared() bool {
  1472. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1473. return ok
  1474. }
  1475. // ResetIndexes resets all changes to the "indexes" field.
  1476. func (m *AgentBaseMutation) ResetIndexes() {
  1477. m.indexes = nil
  1478. m.appendindexes = nil
  1479. delete(m.clearedFields, agentbase.FieldIndexes)
  1480. }
  1481. // SetDatasetID sets the "dataset_id" field.
  1482. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1483. m.dataset_id = &s
  1484. }
  1485. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1486. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1487. v := m.dataset_id
  1488. if v == nil {
  1489. return
  1490. }
  1491. return *v, true
  1492. }
  1493. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1494. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1496. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1497. if !m.op.Is(OpUpdateOne) {
  1498. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1499. }
  1500. if m.id == nil || m.oldValue == nil {
  1501. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1502. }
  1503. oldValue, err := m.oldValue(ctx)
  1504. if err != nil {
  1505. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1506. }
  1507. return oldValue.DatasetID, nil
  1508. }
  1509. // ClearDatasetID clears the value of the "dataset_id" field.
  1510. func (m *AgentBaseMutation) ClearDatasetID() {
  1511. m.dataset_id = nil
  1512. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1513. }
  1514. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1515. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1516. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1517. return ok
  1518. }
  1519. // ResetDatasetID resets all changes to the "dataset_id" field.
  1520. func (m *AgentBaseMutation) ResetDatasetID() {
  1521. m.dataset_id = nil
  1522. delete(m.clearedFields, agentbase.FieldDatasetID)
  1523. }
  1524. // SetCollectionID sets the "collection_id" field.
  1525. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1526. m.collection_id = &s
  1527. }
  1528. // CollectionID returns the value of the "collection_id" field in the mutation.
  1529. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1530. v := m.collection_id
  1531. if v == nil {
  1532. return
  1533. }
  1534. return *v, true
  1535. }
  1536. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1537. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1539. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1540. if !m.op.Is(OpUpdateOne) {
  1541. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1542. }
  1543. if m.id == nil || m.oldValue == nil {
  1544. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1545. }
  1546. oldValue, err := m.oldValue(ctx)
  1547. if err != nil {
  1548. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1549. }
  1550. return oldValue.CollectionID, nil
  1551. }
  1552. // ClearCollectionID clears the value of the "collection_id" field.
  1553. func (m *AgentBaseMutation) ClearCollectionID() {
  1554. m.collection_id = nil
  1555. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1556. }
  1557. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1558. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1559. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1560. return ok
  1561. }
  1562. // ResetCollectionID resets all changes to the "collection_id" field.
  1563. func (m *AgentBaseMutation) ResetCollectionID() {
  1564. m.collection_id = nil
  1565. delete(m.clearedFields, agentbase.FieldCollectionID)
  1566. }
  1567. // SetSourceName sets the "source_name" field.
  1568. func (m *AgentBaseMutation) SetSourceName(s string) {
  1569. m.source_name = &s
  1570. }
  1571. // SourceName returns the value of the "source_name" field in the mutation.
  1572. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1573. v := m.source_name
  1574. if v == nil {
  1575. return
  1576. }
  1577. return *v, true
  1578. }
  1579. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1580. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1582. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1583. if !m.op.Is(OpUpdateOne) {
  1584. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1585. }
  1586. if m.id == nil || m.oldValue == nil {
  1587. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1588. }
  1589. oldValue, err := m.oldValue(ctx)
  1590. if err != nil {
  1591. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1592. }
  1593. return oldValue.SourceName, nil
  1594. }
  1595. // ClearSourceName clears the value of the "source_name" field.
  1596. func (m *AgentBaseMutation) ClearSourceName() {
  1597. m.source_name = nil
  1598. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1599. }
  1600. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1601. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1602. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1603. return ok
  1604. }
  1605. // ResetSourceName resets all changes to the "source_name" field.
  1606. func (m *AgentBaseMutation) ResetSourceName() {
  1607. m.source_name = nil
  1608. delete(m.clearedFields, agentbase.FieldSourceName)
  1609. }
  1610. // SetCanWrite sets the "can_write" field.
  1611. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1612. m.can_write = &b
  1613. m.appendcan_write = nil
  1614. }
  1615. // CanWrite returns the value of the "can_write" field in the mutation.
  1616. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1617. v := m.can_write
  1618. if v == nil {
  1619. return
  1620. }
  1621. return *v, true
  1622. }
  1623. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1624. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1626. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1627. if !m.op.Is(OpUpdateOne) {
  1628. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1629. }
  1630. if m.id == nil || m.oldValue == nil {
  1631. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1632. }
  1633. oldValue, err := m.oldValue(ctx)
  1634. if err != nil {
  1635. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1636. }
  1637. return oldValue.CanWrite, nil
  1638. }
  1639. // AppendCanWrite adds b to the "can_write" field.
  1640. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1641. m.appendcan_write = append(m.appendcan_write, b...)
  1642. }
  1643. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1644. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1645. if len(m.appendcan_write) == 0 {
  1646. return nil, false
  1647. }
  1648. return m.appendcan_write, true
  1649. }
  1650. // ClearCanWrite clears the value of the "can_write" field.
  1651. func (m *AgentBaseMutation) ClearCanWrite() {
  1652. m.can_write = nil
  1653. m.appendcan_write = nil
  1654. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1655. }
  1656. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1657. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1658. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1659. return ok
  1660. }
  1661. // ResetCanWrite resets all changes to the "can_write" field.
  1662. func (m *AgentBaseMutation) ResetCanWrite() {
  1663. m.can_write = nil
  1664. m.appendcan_write = nil
  1665. delete(m.clearedFields, agentbase.FieldCanWrite)
  1666. }
  1667. // SetIsOwner sets the "is_owner" field.
  1668. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1669. m.is_owner = &b
  1670. m.appendis_owner = nil
  1671. }
  1672. // IsOwner returns the value of the "is_owner" field in the mutation.
  1673. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1674. v := m.is_owner
  1675. if v == nil {
  1676. return
  1677. }
  1678. return *v, true
  1679. }
  1680. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1681. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1683. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1684. if !m.op.Is(OpUpdateOne) {
  1685. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1686. }
  1687. if m.id == nil || m.oldValue == nil {
  1688. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1689. }
  1690. oldValue, err := m.oldValue(ctx)
  1691. if err != nil {
  1692. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1693. }
  1694. return oldValue.IsOwner, nil
  1695. }
  1696. // AppendIsOwner adds b to the "is_owner" field.
  1697. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1698. m.appendis_owner = append(m.appendis_owner, b...)
  1699. }
  1700. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1701. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1702. if len(m.appendis_owner) == 0 {
  1703. return nil, false
  1704. }
  1705. return m.appendis_owner, true
  1706. }
  1707. // ClearIsOwner clears the value of the "is_owner" field.
  1708. func (m *AgentBaseMutation) ClearIsOwner() {
  1709. m.is_owner = nil
  1710. m.appendis_owner = nil
  1711. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1712. }
  1713. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1714. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1715. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1716. return ok
  1717. }
  1718. // ResetIsOwner resets all changes to the "is_owner" field.
  1719. func (m *AgentBaseMutation) ResetIsOwner() {
  1720. m.is_owner = nil
  1721. m.appendis_owner = nil
  1722. delete(m.clearedFields, agentbase.FieldIsOwner)
  1723. }
  1724. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1725. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1726. if m.wx_agent == nil {
  1727. m.wx_agent = make(map[uint64]struct{})
  1728. }
  1729. for i := range ids {
  1730. m.wx_agent[ids[i]] = struct{}{}
  1731. }
  1732. }
  1733. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1734. func (m *AgentBaseMutation) ClearWxAgent() {
  1735. m.clearedwx_agent = true
  1736. }
  1737. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1738. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1739. return m.clearedwx_agent
  1740. }
  1741. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1742. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1743. if m.removedwx_agent == nil {
  1744. m.removedwx_agent = make(map[uint64]struct{})
  1745. }
  1746. for i := range ids {
  1747. delete(m.wx_agent, ids[i])
  1748. m.removedwx_agent[ids[i]] = struct{}{}
  1749. }
  1750. }
  1751. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1752. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1753. for id := range m.removedwx_agent {
  1754. ids = append(ids, id)
  1755. }
  1756. return
  1757. }
  1758. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1759. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1760. for id := range m.wx_agent {
  1761. ids = append(ids, id)
  1762. }
  1763. return
  1764. }
  1765. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1766. func (m *AgentBaseMutation) ResetWxAgent() {
  1767. m.wx_agent = nil
  1768. m.clearedwx_agent = false
  1769. m.removedwx_agent = nil
  1770. }
  1771. // Where appends a list predicates to the AgentBaseMutation builder.
  1772. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1773. m.predicates = append(m.predicates, ps...)
  1774. }
  1775. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1776. // users can use type-assertion to append predicates that do not depend on any generated package.
  1777. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1778. p := make([]predicate.AgentBase, len(ps))
  1779. for i := range ps {
  1780. p[i] = ps[i]
  1781. }
  1782. m.Where(p...)
  1783. }
  1784. // Op returns the operation name.
  1785. func (m *AgentBaseMutation) Op() Op {
  1786. return m.op
  1787. }
  1788. // SetOp allows setting the mutation operation.
  1789. func (m *AgentBaseMutation) SetOp(op Op) {
  1790. m.op = op
  1791. }
  1792. // Type returns the node type of this mutation (AgentBase).
  1793. func (m *AgentBaseMutation) Type() string {
  1794. return m.typ
  1795. }
  1796. // Fields returns all fields that were changed during this mutation. Note that in
  1797. // order to get all numeric fields that were incremented/decremented, call
  1798. // AddedFields().
  1799. func (m *AgentBaseMutation) Fields() []string {
  1800. fields := make([]string, 0, 9)
  1801. if m.q != nil {
  1802. fields = append(fields, agentbase.FieldQ)
  1803. }
  1804. if m.a != nil {
  1805. fields = append(fields, agentbase.FieldA)
  1806. }
  1807. if m.chunk_index != nil {
  1808. fields = append(fields, agentbase.FieldChunkIndex)
  1809. }
  1810. if m.indexes != nil {
  1811. fields = append(fields, agentbase.FieldIndexes)
  1812. }
  1813. if m.dataset_id != nil {
  1814. fields = append(fields, agentbase.FieldDatasetID)
  1815. }
  1816. if m.collection_id != nil {
  1817. fields = append(fields, agentbase.FieldCollectionID)
  1818. }
  1819. if m.source_name != nil {
  1820. fields = append(fields, agentbase.FieldSourceName)
  1821. }
  1822. if m.can_write != nil {
  1823. fields = append(fields, agentbase.FieldCanWrite)
  1824. }
  1825. if m.is_owner != nil {
  1826. fields = append(fields, agentbase.FieldIsOwner)
  1827. }
  1828. return fields
  1829. }
  1830. // Field returns the value of a field with the given name. The second boolean
  1831. // return value indicates that this field was not set, or was not defined in the
  1832. // schema.
  1833. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1834. switch name {
  1835. case agentbase.FieldQ:
  1836. return m.Q()
  1837. case agentbase.FieldA:
  1838. return m.A()
  1839. case agentbase.FieldChunkIndex:
  1840. return m.ChunkIndex()
  1841. case agentbase.FieldIndexes:
  1842. return m.Indexes()
  1843. case agentbase.FieldDatasetID:
  1844. return m.DatasetID()
  1845. case agentbase.FieldCollectionID:
  1846. return m.CollectionID()
  1847. case agentbase.FieldSourceName:
  1848. return m.SourceName()
  1849. case agentbase.FieldCanWrite:
  1850. return m.CanWrite()
  1851. case agentbase.FieldIsOwner:
  1852. return m.IsOwner()
  1853. }
  1854. return nil, false
  1855. }
  1856. // OldField returns the old value of the field from the database. An error is
  1857. // returned if the mutation operation is not UpdateOne, or the query to the
  1858. // database failed.
  1859. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1860. switch name {
  1861. case agentbase.FieldQ:
  1862. return m.OldQ(ctx)
  1863. case agentbase.FieldA:
  1864. return m.OldA(ctx)
  1865. case agentbase.FieldChunkIndex:
  1866. return m.OldChunkIndex(ctx)
  1867. case agentbase.FieldIndexes:
  1868. return m.OldIndexes(ctx)
  1869. case agentbase.FieldDatasetID:
  1870. return m.OldDatasetID(ctx)
  1871. case agentbase.FieldCollectionID:
  1872. return m.OldCollectionID(ctx)
  1873. case agentbase.FieldSourceName:
  1874. return m.OldSourceName(ctx)
  1875. case agentbase.FieldCanWrite:
  1876. return m.OldCanWrite(ctx)
  1877. case agentbase.FieldIsOwner:
  1878. return m.OldIsOwner(ctx)
  1879. }
  1880. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1881. }
  1882. // SetField sets the value of a field with the given name. It returns an error if
  1883. // the field is not defined in the schema, or if the type mismatched the field
  1884. // type.
  1885. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1886. switch name {
  1887. case agentbase.FieldQ:
  1888. v, ok := value.(string)
  1889. if !ok {
  1890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1891. }
  1892. m.SetQ(v)
  1893. return nil
  1894. case agentbase.FieldA:
  1895. v, ok := value.(string)
  1896. if !ok {
  1897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1898. }
  1899. m.SetA(v)
  1900. return nil
  1901. case agentbase.FieldChunkIndex:
  1902. v, ok := value.(uint64)
  1903. if !ok {
  1904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1905. }
  1906. m.SetChunkIndex(v)
  1907. return nil
  1908. case agentbase.FieldIndexes:
  1909. v, ok := value.([]string)
  1910. if !ok {
  1911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1912. }
  1913. m.SetIndexes(v)
  1914. return nil
  1915. case agentbase.FieldDatasetID:
  1916. v, ok := value.(string)
  1917. if !ok {
  1918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1919. }
  1920. m.SetDatasetID(v)
  1921. return nil
  1922. case agentbase.FieldCollectionID:
  1923. v, ok := value.(string)
  1924. if !ok {
  1925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1926. }
  1927. m.SetCollectionID(v)
  1928. return nil
  1929. case agentbase.FieldSourceName:
  1930. v, ok := value.(string)
  1931. if !ok {
  1932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1933. }
  1934. m.SetSourceName(v)
  1935. return nil
  1936. case agentbase.FieldCanWrite:
  1937. v, ok := value.([]bool)
  1938. if !ok {
  1939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1940. }
  1941. m.SetCanWrite(v)
  1942. return nil
  1943. case agentbase.FieldIsOwner:
  1944. v, ok := value.([]bool)
  1945. if !ok {
  1946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1947. }
  1948. m.SetIsOwner(v)
  1949. return nil
  1950. }
  1951. return fmt.Errorf("unknown AgentBase field %s", name)
  1952. }
  1953. // AddedFields returns all numeric fields that were incremented/decremented during
  1954. // this mutation.
  1955. func (m *AgentBaseMutation) AddedFields() []string {
  1956. var fields []string
  1957. if m.addchunk_index != nil {
  1958. fields = append(fields, agentbase.FieldChunkIndex)
  1959. }
  1960. return fields
  1961. }
  1962. // AddedField returns the numeric value that was incremented/decremented on a field
  1963. // with the given name. The second boolean return value indicates that this field
  1964. // was not set, or was not defined in the schema.
  1965. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1966. switch name {
  1967. case agentbase.FieldChunkIndex:
  1968. return m.AddedChunkIndex()
  1969. }
  1970. return nil, false
  1971. }
  1972. // AddField adds the value to the field with the given name. It returns an error if
  1973. // the field is not defined in the schema, or if the type mismatched the field
  1974. // type.
  1975. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1976. switch name {
  1977. case agentbase.FieldChunkIndex:
  1978. v, ok := value.(int64)
  1979. if !ok {
  1980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1981. }
  1982. m.AddChunkIndex(v)
  1983. return nil
  1984. }
  1985. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  1986. }
  1987. // ClearedFields returns all nullable fields that were cleared during this
  1988. // mutation.
  1989. func (m *AgentBaseMutation) ClearedFields() []string {
  1990. var fields []string
  1991. if m.FieldCleared(agentbase.FieldQ) {
  1992. fields = append(fields, agentbase.FieldQ)
  1993. }
  1994. if m.FieldCleared(agentbase.FieldA) {
  1995. fields = append(fields, agentbase.FieldA)
  1996. }
  1997. if m.FieldCleared(agentbase.FieldIndexes) {
  1998. fields = append(fields, agentbase.FieldIndexes)
  1999. }
  2000. if m.FieldCleared(agentbase.FieldDatasetID) {
  2001. fields = append(fields, agentbase.FieldDatasetID)
  2002. }
  2003. if m.FieldCleared(agentbase.FieldCollectionID) {
  2004. fields = append(fields, agentbase.FieldCollectionID)
  2005. }
  2006. if m.FieldCleared(agentbase.FieldSourceName) {
  2007. fields = append(fields, agentbase.FieldSourceName)
  2008. }
  2009. if m.FieldCleared(agentbase.FieldCanWrite) {
  2010. fields = append(fields, agentbase.FieldCanWrite)
  2011. }
  2012. if m.FieldCleared(agentbase.FieldIsOwner) {
  2013. fields = append(fields, agentbase.FieldIsOwner)
  2014. }
  2015. return fields
  2016. }
  2017. // FieldCleared returns a boolean indicating if a field with the given name was
  2018. // cleared in this mutation.
  2019. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2020. _, ok := m.clearedFields[name]
  2021. return ok
  2022. }
  2023. // ClearField clears the value of the field with the given name. It returns an
  2024. // error if the field is not defined in the schema.
  2025. func (m *AgentBaseMutation) ClearField(name string) error {
  2026. switch name {
  2027. case agentbase.FieldQ:
  2028. m.ClearQ()
  2029. return nil
  2030. case agentbase.FieldA:
  2031. m.ClearA()
  2032. return nil
  2033. case agentbase.FieldIndexes:
  2034. m.ClearIndexes()
  2035. return nil
  2036. case agentbase.FieldDatasetID:
  2037. m.ClearDatasetID()
  2038. return nil
  2039. case agentbase.FieldCollectionID:
  2040. m.ClearCollectionID()
  2041. return nil
  2042. case agentbase.FieldSourceName:
  2043. m.ClearSourceName()
  2044. return nil
  2045. case agentbase.FieldCanWrite:
  2046. m.ClearCanWrite()
  2047. return nil
  2048. case agentbase.FieldIsOwner:
  2049. m.ClearIsOwner()
  2050. return nil
  2051. }
  2052. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2053. }
  2054. // ResetField resets all changes in the mutation for the field with the given name.
  2055. // It returns an error if the field is not defined in the schema.
  2056. func (m *AgentBaseMutation) ResetField(name string) error {
  2057. switch name {
  2058. case agentbase.FieldQ:
  2059. m.ResetQ()
  2060. return nil
  2061. case agentbase.FieldA:
  2062. m.ResetA()
  2063. return nil
  2064. case agentbase.FieldChunkIndex:
  2065. m.ResetChunkIndex()
  2066. return nil
  2067. case agentbase.FieldIndexes:
  2068. m.ResetIndexes()
  2069. return nil
  2070. case agentbase.FieldDatasetID:
  2071. m.ResetDatasetID()
  2072. return nil
  2073. case agentbase.FieldCollectionID:
  2074. m.ResetCollectionID()
  2075. return nil
  2076. case agentbase.FieldSourceName:
  2077. m.ResetSourceName()
  2078. return nil
  2079. case agentbase.FieldCanWrite:
  2080. m.ResetCanWrite()
  2081. return nil
  2082. case agentbase.FieldIsOwner:
  2083. m.ResetIsOwner()
  2084. return nil
  2085. }
  2086. return fmt.Errorf("unknown AgentBase field %s", name)
  2087. }
  2088. // AddedEdges returns all edge names that were set/added in this mutation.
  2089. func (m *AgentBaseMutation) AddedEdges() []string {
  2090. edges := make([]string, 0, 1)
  2091. if m.wx_agent != nil {
  2092. edges = append(edges, agentbase.EdgeWxAgent)
  2093. }
  2094. return edges
  2095. }
  2096. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2097. // name in this mutation.
  2098. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2099. switch name {
  2100. case agentbase.EdgeWxAgent:
  2101. ids := make([]ent.Value, 0, len(m.wx_agent))
  2102. for id := range m.wx_agent {
  2103. ids = append(ids, id)
  2104. }
  2105. return ids
  2106. }
  2107. return nil
  2108. }
  2109. // RemovedEdges returns all edge names that were removed in this mutation.
  2110. func (m *AgentBaseMutation) RemovedEdges() []string {
  2111. edges := make([]string, 0, 1)
  2112. if m.removedwx_agent != nil {
  2113. edges = append(edges, agentbase.EdgeWxAgent)
  2114. }
  2115. return edges
  2116. }
  2117. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2118. // the given name in this mutation.
  2119. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2120. switch name {
  2121. case agentbase.EdgeWxAgent:
  2122. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2123. for id := range m.removedwx_agent {
  2124. ids = append(ids, id)
  2125. }
  2126. return ids
  2127. }
  2128. return nil
  2129. }
  2130. // ClearedEdges returns all edge names that were cleared in this mutation.
  2131. func (m *AgentBaseMutation) ClearedEdges() []string {
  2132. edges := make([]string, 0, 1)
  2133. if m.clearedwx_agent {
  2134. edges = append(edges, agentbase.EdgeWxAgent)
  2135. }
  2136. return edges
  2137. }
  2138. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2139. // was cleared in this mutation.
  2140. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2141. switch name {
  2142. case agentbase.EdgeWxAgent:
  2143. return m.clearedwx_agent
  2144. }
  2145. return false
  2146. }
  2147. // ClearEdge clears the value of the edge with the given name. It returns an error
  2148. // if that edge is not defined in the schema.
  2149. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2150. switch name {
  2151. }
  2152. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2153. }
  2154. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2155. // It returns an error if the edge is not defined in the schema.
  2156. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2157. switch name {
  2158. case agentbase.EdgeWxAgent:
  2159. m.ResetWxAgent()
  2160. return nil
  2161. }
  2162. return fmt.Errorf("unknown AgentBase edge %s", name)
  2163. }
  2164. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2165. type AliyunAvatarMutation struct {
  2166. config
  2167. op Op
  2168. typ string
  2169. id *uint64
  2170. created_at *time.Time
  2171. updated_at *time.Time
  2172. deleted_at *time.Time
  2173. user_id *uint64
  2174. adduser_id *int64
  2175. biz_id *string
  2176. access_key_id *string
  2177. access_key_secret *string
  2178. app_id *string
  2179. tenant_id *uint64
  2180. addtenant_id *int64
  2181. response *string
  2182. token *string
  2183. session_id *string
  2184. clearedFields map[string]struct{}
  2185. done bool
  2186. oldValue func(context.Context) (*AliyunAvatar, error)
  2187. predicates []predicate.AliyunAvatar
  2188. }
  2189. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2190. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2191. type aliyunavatarOption func(*AliyunAvatarMutation)
  2192. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2193. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2194. m := &AliyunAvatarMutation{
  2195. config: c,
  2196. op: op,
  2197. typ: TypeAliyunAvatar,
  2198. clearedFields: make(map[string]struct{}),
  2199. }
  2200. for _, opt := range opts {
  2201. opt(m)
  2202. }
  2203. return m
  2204. }
  2205. // withAliyunAvatarID sets the ID field of the mutation.
  2206. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2207. return func(m *AliyunAvatarMutation) {
  2208. var (
  2209. err error
  2210. once sync.Once
  2211. value *AliyunAvatar
  2212. )
  2213. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2214. once.Do(func() {
  2215. if m.done {
  2216. err = errors.New("querying old values post mutation is not allowed")
  2217. } else {
  2218. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2219. }
  2220. })
  2221. return value, err
  2222. }
  2223. m.id = &id
  2224. }
  2225. }
  2226. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2227. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2228. return func(m *AliyunAvatarMutation) {
  2229. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2230. return node, nil
  2231. }
  2232. m.id = &node.ID
  2233. }
  2234. }
  2235. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2236. // executed in a transaction (ent.Tx), a transactional client is returned.
  2237. func (m AliyunAvatarMutation) Client() *Client {
  2238. client := &Client{config: m.config}
  2239. client.init()
  2240. return client
  2241. }
  2242. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2243. // it returns an error otherwise.
  2244. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2245. if _, ok := m.driver.(*txDriver); !ok {
  2246. return nil, errors.New("ent: mutation is not running in a transaction")
  2247. }
  2248. tx := &Tx{config: m.config}
  2249. tx.init()
  2250. return tx, nil
  2251. }
  2252. // SetID sets the value of the id field. Note that this
  2253. // operation is only accepted on creation of AliyunAvatar entities.
  2254. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2255. m.id = &id
  2256. }
  2257. // ID returns the ID value in the mutation. Note that the ID is only available
  2258. // if it was provided to the builder or after it was returned from the database.
  2259. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2260. if m.id == nil {
  2261. return
  2262. }
  2263. return *m.id, true
  2264. }
  2265. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2266. // That means, if the mutation is applied within a transaction with an isolation level such
  2267. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2268. // or updated by the mutation.
  2269. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2270. switch {
  2271. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2272. id, exists := m.ID()
  2273. if exists {
  2274. return []uint64{id}, nil
  2275. }
  2276. fallthrough
  2277. case m.op.Is(OpUpdate | OpDelete):
  2278. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2279. default:
  2280. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2281. }
  2282. }
  2283. // SetCreatedAt sets the "created_at" field.
  2284. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2285. m.created_at = &t
  2286. }
  2287. // CreatedAt returns the value of the "created_at" field in the mutation.
  2288. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2289. v := m.created_at
  2290. if v == nil {
  2291. return
  2292. }
  2293. return *v, true
  2294. }
  2295. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2296. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2298. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2299. if !m.op.Is(OpUpdateOne) {
  2300. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2301. }
  2302. if m.id == nil || m.oldValue == nil {
  2303. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2304. }
  2305. oldValue, err := m.oldValue(ctx)
  2306. if err != nil {
  2307. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2308. }
  2309. return oldValue.CreatedAt, nil
  2310. }
  2311. // ResetCreatedAt resets all changes to the "created_at" field.
  2312. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2313. m.created_at = nil
  2314. }
  2315. // SetUpdatedAt sets the "updated_at" field.
  2316. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2317. m.updated_at = &t
  2318. }
  2319. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2320. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2321. v := m.updated_at
  2322. if v == nil {
  2323. return
  2324. }
  2325. return *v, true
  2326. }
  2327. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2328. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2330. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2331. if !m.op.Is(OpUpdateOne) {
  2332. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2333. }
  2334. if m.id == nil || m.oldValue == nil {
  2335. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2336. }
  2337. oldValue, err := m.oldValue(ctx)
  2338. if err != nil {
  2339. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2340. }
  2341. return oldValue.UpdatedAt, nil
  2342. }
  2343. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2344. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2345. m.updated_at = nil
  2346. }
  2347. // SetDeletedAt sets the "deleted_at" field.
  2348. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2349. m.deleted_at = &t
  2350. }
  2351. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2352. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2353. v := m.deleted_at
  2354. if v == nil {
  2355. return
  2356. }
  2357. return *v, true
  2358. }
  2359. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2360. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2362. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2363. if !m.op.Is(OpUpdateOne) {
  2364. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2365. }
  2366. if m.id == nil || m.oldValue == nil {
  2367. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2368. }
  2369. oldValue, err := m.oldValue(ctx)
  2370. if err != nil {
  2371. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2372. }
  2373. return oldValue.DeletedAt, nil
  2374. }
  2375. // ClearDeletedAt clears the value of the "deleted_at" field.
  2376. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2377. m.deleted_at = nil
  2378. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2379. }
  2380. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2381. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2382. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2383. return ok
  2384. }
  2385. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2386. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2387. m.deleted_at = nil
  2388. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2389. }
  2390. // SetUserID sets the "user_id" field.
  2391. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2392. m.user_id = &u
  2393. m.adduser_id = nil
  2394. }
  2395. // UserID returns the value of the "user_id" field in the mutation.
  2396. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2397. v := m.user_id
  2398. if v == nil {
  2399. return
  2400. }
  2401. return *v, true
  2402. }
  2403. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2404. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2406. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2407. if !m.op.Is(OpUpdateOne) {
  2408. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2409. }
  2410. if m.id == nil || m.oldValue == nil {
  2411. return v, errors.New("OldUserID requires an ID field in the mutation")
  2412. }
  2413. oldValue, err := m.oldValue(ctx)
  2414. if err != nil {
  2415. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2416. }
  2417. return oldValue.UserID, nil
  2418. }
  2419. // AddUserID adds u to the "user_id" field.
  2420. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2421. if m.adduser_id != nil {
  2422. *m.adduser_id += u
  2423. } else {
  2424. m.adduser_id = &u
  2425. }
  2426. }
  2427. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2428. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2429. v := m.adduser_id
  2430. if v == nil {
  2431. return
  2432. }
  2433. return *v, true
  2434. }
  2435. // ResetUserID resets all changes to the "user_id" field.
  2436. func (m *AliyunAvatarMutation) ResetUserID() {
  2437. m.user_id = nil
  2438. m.adduser_id = nil
  2439. }
  2440. // SetBizID sets the "biz_id" field.
  2441. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2442. m.biz_id = &s
  2443. }
  2444. // BizID returns the value of the "biz_id" field in the mutation.
  2445. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2446. v := m.biz_id
  2447. if v == nil {
  2448. return
  2449. }
  2450. return *v, true
  2451. }
  2452. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2453. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2455. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2456. if !m.op.Is(OpUpdateOne) {
  2457. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2458. }
  2459. if m.id == nil || m.oldValue == nil {
  2460. return v, errors.New("OldBizID requires an ID field in the mutation")
  2461. }
  2462. oldValue, err := m.oldValue(ctx)
  2463. if err != nil {
  2464. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2465. }
  2466. return oldValue.BizID, nil
  2467. }
  2468. // ResetBizID resets all changes to the "biz_id" field.
  2469. func (m *AliyunAvatarMutation) ResetBizID() {
  2470. m.biz_id = nil
  2471. }
  2472. // SetAccessKeyID sets the "access_key_id" field.
  2473. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2474. m.access_key_id = &s
  2475. }
  2476. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2477. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2478. v := m.access_key_id
  2479. if v == nil {
  2480. return
  2481. }
  2482. return *v, true
  2483. }
  2484. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2485. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2487. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2488. if !m.op.Is(OpUpdateOne) {
  2489. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2490. }
  2491. if m.id == nil || m.oldValue == nil {
  2492. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2493. }
  2494. oldValue, err := m.oldValue(ctx)
  2495. if err != nil {
  2496. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2497. }
  2498. return oldValue.AccessKeyID, nil
  2499. }
  2500. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2501. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2502. m.access_key_id = nil
  2503. }
  2504. // SetAccessKeySecret sets the "access_key_secret" field.
  2505. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2506. m.access_key_secret = &s
  2507. }
  2508. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2509. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2510. v := m.access_key_secret
  2511. if v == nil {
  2512. return
  2513. }
  2514. return *v, true
  2515. }
  2516. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2517. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2519. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2520. if !m.op.Is(OpUpdateOne) {
  2521. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2522. }
  2523. if m.id == nil || m.oldValue == nil {
  2524. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2525. }
  2526. oldValue, err := m.oldValue(ctx)
  2527. if err != nil {
  2528. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2529. }
  2530. return oldValue.AccessKeySecret, nil
  2531. }
  2532. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2533. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2534. m.access_key_secret = nil
  2535. }
  2536. // SetAppID sets the "app_id" field.
  2537. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2538. m.app_id = &s
  2539. }
  2540. // AppID returns the value of the "app_id" field in the mutation.
  2541. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2542. v := m.app_id
  2543. if v == nil {
  2544. return
  2545. }
  2546. return *v, true
  2547. }
  2548. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2549. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2551. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2552. if !m.op.Is(OpUpdateOne) {
  2553. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2554. }
  2555. if m.id == nil || m.oldValue == nil {
  2556. return v, errors.New("OldAppID requires an ID field in the mutation")
  2557. }
  2558. oldValue, err := m.oldValue(ctx)
  2559. if err != nil {
  2560. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2561. }
  2562. return oldValue.AppID, nil
  2563. }
  2564. // ClearAppID clears the value of the "app_id" field.
  2565. func (m *AliyunAvatarMutation) ClearAppID() {
  2566. m.app_id = nil
  2567. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2568. }
  2569. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2570. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2571. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2572. return ok
  2573. }
  2574. // ResetAppID resets all changes to the "app_id" field.
  2575. func (m *AliyunAvatarMutation) ResetAppID() {
  2576. m.app_id = nil
  2577. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2578. }
  2579. // SetTenantID sets the "tenant_id" field.
  2580. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2581. m.tenant_id = &u
  2582. m.addtenant_id = nil
  2583. }
  2584. // TenantID returns the value of the "tenant_id" field in the mutation.
  2585. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2586. v := m.tenant_id
  2587. if v == nil {
  2588. return
  2589. }
  2590. return *v, true
  2591. }
  2592. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2593. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2595. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2596. if !m.op.Is(OpUpdateOne) {
  2597. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2598. }
  2599. if m.id == nil || m.oldValue == nil {
  2600. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2601. }
  2602. oldValue, err := m.oldValue(ctx)
  2603. if err != nil {
  2604. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2605. }
  2606. return oldValue.TenantID, nil
  2607. }
  2608. // AddTenantID adds u to the "tenant_id" field.
  2609. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2610. if m.addtenant_id != nil {
  2611. *m.addtenant_id += u
  2612. } else {
  2613. m.addtenant_id = &u
  2614. }
  2615. }
  2616. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2617. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2618. v := m.addtenant_id
  2619. if v == nil {
  2620. return
  2621. }
  2622. return *v, true
  2623. }
  2624. // ResetTenantID resets all changes to the "tenant_id" field.
  2625. func (m *AliyunAvatarMutation) ResetTenantID() {
  2626. m.tenant_id = nil
  2627. m.addtenant_id = nil
  2628. }
  2629. // SetResponse sets the "response" field.
  2630. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2631. m.response = &s
  2632. }
  2633. // Response returns the value of the "response" field in the mutation.
  2634. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2635. v := m.response
  2636. if v == nil {
  2637. return
  2638. }
  2639. return *v, true
  2640. }
  2641. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2642. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2644. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2645. if !m.op.Is(OpUpdateOne) {
  2646. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2647. }
  2648. if m.id == nil || m.oldValue == nil {
  2649. return v, errors.New("OldResponse requires an ID field in the mutation")
  2650. }
  2651. oldValue, err := m.oldValue(ctx)
  2652. if err != nil {
  2653. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2654. }
  2655. return oldValue.Response, nil
  2656. }
  2657. // ResetResponse resets all changes to the "response" field.
  2658. func (m *AliyunAvatarMutation) ResetResponse() {
  2659. m.response = nil
  2660. }
  2661. // SetToken sets the "token" field.
  2662. func (m *AliyunAvatarMutation) SetToken(s string) {
  2663. m.token = &s
  2664. }
  2665. // Token returns the value of the "token" field in the mutation.
  2666. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2667. v := m.token
  2668. if v == nil {
  2669. return
  2670. }
  2671. return *v, true
  2672. }
  2673. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2674. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2676. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2677. if !m.op.Is(OpUpdateOne) {
  2678. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2679. }
  2680. if m.id == nil || m.oldValue == nil {
  2681. return v, errors.New("OldToken requires an ID field in the mutation")
  2682. }
  2683. oldValue, err := m.oldValue(ctx)
  2684. if err != nil {
  2685. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2686. }
  2687. return oldValue.Token, nil
  2688. }
  2689. // ResetToken resets all changes to the "token" field.
  2690. func (m *AliyunAvatarMutation) ResetToken() {
  2691. m.token = nil
  2692. }
  2693. // SetSessionID sets the "session_id" field.
  2694. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2695. m.session_id = &s
  2696. }
  2697. // SessionID returns the value of the "session_id" field in the mutation.
  2698. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2699. v := m.session_id
  2700. if v == nil {
  2701. return
  2702. }
  2703. return *v, true
  2704. }
  2705. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2706. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2708. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2709. if !m.op.Is(OpUpdateOne) {
  2710. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2711. }
  2712. if m.id == nil || m.oldValue == nil {
  2713. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2714. }
  2715. oldValue, err := m.oldValue(ctx)
  2716. if err != nil {
  2717. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2718. }
  2719. return oldValue.SessionID, nil
  2720. }
  2721. // ResetSessionID resets all changes to the "session_id" field.
  2722. func (m *AliyunAvatarMutation) ResetSessionID() {
  2723. m.session_id = nil
  2724. }
  2725. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2726. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2727. m.predicates = append(m.predicates, ps...)
  2728. }
  2729. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2730. // users can use type-assertion to append predicates that do not depend on any generated package.
  2731. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2732. p := make([]predicate.AliyunAvatar, len(ps))
  2733. for i := range ps {
  2734. p[i] = ps[i]
  2735. }
  2736. m.Where(p...)
  2737. }
  2738. // Op returns the operation name.
  2739. func (m *AliyunAvatarMutation) Op() Op {
  2740. return m.op
  2741. }
  2742. // SetOp allows setting the mutation operation.
  2743. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2744. m.op = op
  2745. }
  2746. // Type returns the node type of this mutation (AliyunAvatar).
  2747. func (m *AliyunAvatarMutation) Type() string {
  2748. return m.typ
  2749. }
  2750. // Fields returns all fields that were changed during this mutation. Note that in
  2751. // order to get all numeric fields that were incremented/decremented, call
  2752. // AddedFields().
  2753. func (m *AliyunAvatarMutation) Fields() []string {
  2754. fields := make([]string, 0, 12)
  2755. if m.created_at != nil {
  2756. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2757. }
  2758. if m.updated_at != nil {
  2759. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2760. }
  2761. if m.deleted_at != nil {
  2762. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2763. }
  2764. if m.user_id != nil {
  2765. fields = append(fields, aliyunavatar.FieldUserID)
  2766. }
  2767. if m.biz_id != nil {
  2768. fields = append(fields, aliyunavatar.FieldBizID)
  2769. }
  2770. if m.access_key_id != nil {
  2771. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2772. }
  2773. if m.access_key_secret != nil {
  2774. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2775. }
  2776. if m.app_id != nil {
  2777. fields = append(fields, aliyunavatar.FieldAppID)
  2778. }
  2779. if m.tenant_id != nil {
  2780. fields = append(fields, aliyunavatar.FieldTenantID)
  2781. }
  2782. if m.response != nil {
  2783. fields = append(fields, aliyunavatar.FieldResponse)
  2784. }
  2785. if m.token != nil {
  2786. fields = append(fields, aliyunavatar.FieldToken)
  2787. }
  2788. if m.session_id != nil {
  2789. fields = append(fields, aliyunavatar.FieldSessionID)
  2790. }
  2791. return fields
  2792. }
  2793. // Field returns the value of a field with the given name. The second boolean
  2794. // return value indicates that this field was not set, or was not defined in the
  2795. // schema.
  2796. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2797. switch name {
  2798. case aliyunavatar.FieldCreatedAt:
  2799. return m.CreatedAt()
  2800. case aliyunavatar.FieldUpdatedAt:
  2801. return m.UpdatedAt()
  2802. case aliyunavatar.FieldDeletedAt:
  2803. return m.DeletedAt()
  2804. case aliyunavatar.FieldUserID:
  2805. return m.UserID()
  2806. case aliyunavatar.FieldBizID:
  2807. return m.BizID()
  2808. case aliyunavatar.FieldAccessKeyID:
  2809. return m.AccessKeyID()
  2810. case aliyunavatar.FieldAccessKeySecret:
  2811. return m.AccessKeySecret()
  2812. case aliyunavatar.FieldAppID:
  2813. return m.AppID()
  2814. case aliyunavatar.FieldTenantID:
  2815. return m.TenantID()
  2816. case aliyunavatar.FieldResponse:
  2817. return m.Response()
  2818. case aliyunavatar.FieldToken:
  2819. return m.Token()
  2820. case aliyunavatar.FieldSessionID:
  2821. return m.SessionID()
  2822. }
  2823. return nil, false
  2824. }
  2825. // OldField returns the old value of the field from the database. An error is
  2826. // returned if the mutation operation is not UpdateOne, or the query to the
  2827. // database failed.
  2828. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2829. switch name {
  2830. case aliyunavatar.FieldCreatedAt:
  2831. return m.OldCreatedAt(ctx)
  2832. case aliyunavatar.FieldUpdatedAt:
  2833. return m.OldUpdatedAt(ctx)
  2834. case aliyunavatar.FieldDeletedAt:
  2835. return m.OldDeletedAt(ctx)
  2836. case aliyunavatar.FieldUserID:
  2837. return m.OldUserID(ctx)
  2838. case aliyunavatar.FieldBizID:
  2839. return m.OldBizID(ctx)
  2840. case aliyunavatar.FieldAccessKeyID:
  2841. return m.OldAccessKeyID(ctx)
  2842. case aliyunavatar.FieldAccessKeySecret:
  2843. return m.OldAccessKeySecret(ctx)
  2844. case aliyunavatar.FieldAppID:
  2845. return m.OldAppID(ctx)
  2846. case aliyunavatar.FieldTenantID:
  2847. return m.OldTenantID(ctx)
  2848. case aliyunavatar.FieldResponse:
  2849. return m.OldResponse(ctx)
  2850. case aliyunavatar.FieldToken:
  2851. return m.OldToken(ctx)
  2852. case aliyunavatar.FieldSessionID:
  2853. return m.OldSessionID(ctx)
  2854. }
  2855. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2856. }
  2857. // SetField sets the value of a field with the given name. It returns an error if
  2858. // the field is not defined in the schema, or if the type mismatched the field
  2859. // type.
  2860. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2861. switch name {
  2862. case aliyunavatar.FieldCreatedAt:
  2863. v, ok := value.(time.Time)
  2864. if !ok {
  2865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2866. }
  2867. m.SetCreatedAt(v)
  2868. return nil
  2869. case aliyunavatar.FieldUpdatedAt:
  2870. v, ok := value.(time.Time)
  2871. if !ok {
  2872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2873. }
  2874. m.SetUpdatedAt(v)
  2875. return nil
  2876. case aliyunavatar.FieldDeletedAt:
  2877. v, ok := value.(time.Time)
  2878. if !ok {
  2879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2880. }
  2881. m.SetDeletedAt(v)
  2882. return nil
  2883. case aliyunavatar.FieldUserID:
  2884. v, ok := value.(uint64)
  2885. if !ok {
  2886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2887. }
  2888. m.SetUserID(v)
  2889. return nil
  2890. case aliyunavatar.FieldBizID:
  2891. v, ok := value.(string)
  2892. if !ok {
  2893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2894. }
  2895. m.SetBizID(v)
  2896. return nil
  2897. case aliyunavatar.FieldAccessKeyID:
  2898. v, ok := value.(string)
  2899. if !ok {
  2900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2901. }
  2902. m.SetAccessKeyID(v)
  2903. return nil
  2904. case aliyunavatar.FieldAccessKeySecret:
  2905. v, ok := value.(string)
  2906. if !ok {
  2907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2908. }
  2909. m.SetAccessKeySecret(v)
  2910. return nil
  2911. case aliyunavatar.FieldAppID:
  2912. v, ok := value.(string)
  2913. if !ok {
  2914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2915. }
  2916. m.SetAppID(v)
  2917. return nil
  2918. case aliyunavatar.FieldTenantID:
  2919. v, ok := value.(uint64)
  2920. if !ok {
  2921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2922. }
  2923. m.SetTenantID(v)
  2924. return nil
  2925. case aliyunavatar.FieldResponse:
  2926. v, ok := value.(string)
  2927. if !ok {
  2928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2929. }
  2930. m.SetResponse(v)
  2931. return nil
  2932. case aliyunavatar.FieldToken:
  2933. v, ok := value.(string)
  2934. if !ok {
  2935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2936. }
  2937. m.SetToken(v)
  2938. return nil
  2939. case aliyunavatar.FieldSessionID:
  2940. v, ok := value.(string)
  2941. if !ok {
  2942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2943. }
  2944. m.SetSessionID(v)
  2945. return nil
  2946. }
  2947. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2948. }
  2949. // AddedFields returns all numeric fields that were incremented/decremented during
  2950. // this mutation.
  2951. func (m *AliyunAvatarMutation) AddedFields() []string {
  2952. var fields []string
  2953. if m.adduser_id != nil {
  2954. fields = append(fields, aliyunavatar.FieldUserID)
  2955. }
  2956. if m.addtenant_id != nil {
  2957. fields = append(fields, aliyunavatar.FieldTenantID)
  2958. }
  2959. return fields
  2960. }
  2961. // AddedField returns the numeric value that was incremented/decremented on a field
  2962. // with the given name. The second boolean return value indicates that this field
  2963. // was not set, or was not defined in the schema.
  2964. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2965. switch name {
  2966. case aliyunavatar.FieldUserID:
  2967. return m.AddedUserID()
  2968. case aliyunavatar.FieldTenantID:
  2969. return m.AddedTenantID()
  2970. }
  2971. return nil, false
  2972. }
  2973. // AddField adds the value to the field with the given name. It returns an error if
  2974. // the field is not defined in the schema, or if the type mismatched the field
  2975. // type.
  2976. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  2977. switch name {
  2978. case aliyunavatar.FieldUserID:
  2979. v, ok := value.(int64)
  2980. if !ok {
  2981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2982. }
  2983. m.AddUserID(v)
  2984. return nil
  2985. case aliyunavatar.FieldTenantID:
  2986. v, ok := value.(int64)
  2987. if !ok {
  2988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2989. }
  2990. m.AddTenantID(v)
  2991. return nil
  2992. }
  2993. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  2994. }
  2995. // ClearedFields returns all nullable fields that were cleared during this
  2996. // mutation.
  2997. func (m *AliyunAvatarMutation) ClearedFields() []string {
  2998. var fields []string
  2999. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3000. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3001. }
  3002. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3003. fields = append(fields, aliyunavatar.FieldAppID)
  3004. }
  3005. return fields
  3006. }
  3007. // FieldCleared returns a boolean indicating if a field with the given name was
  3008. // cleared in this mutation.
  3009. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3010. _, ok := m.clearedFields[name]
  3011. return ok
  3012. }
  3013. // ClearField clears the value of the field with the given name. It returns an
  3014. // error if the field is not defined in the schema.
  3015. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3016. switch name {
  3017. case aliyunavatar.FieldDeletedAt:
  3018. m.ClearDeletedAt()
  3019. return nil
  3020. case aliyunavatar.FieldAppID:
  3021. m.ClearAppID()
  3022. return nil
  3023. }
  3024. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3025. }
  3026. // ResetField resets all changes in the mutation for the field with the given name.
  3027. // It returns an error if the field is not defined in the schema.
  3028. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3029. switch name {
  3030. case aliyunavatar.FieldCreatedAt:
  3031. m.ResetCreatedAt()
  3032. return nil
  3033. case aliyunavatar.FieldUpdatedAt:
  3034. m.ResetUpdatedAt()
  3035. return nil
  3036. case aliyunavatar.FieldDeletedAt:
  3037. m.ResetDeletedAt()
  3038. return nil
  3039. case aliyunavatar.FieldUserID:
  3040. m.ResetUserID()
  3041. return nil
  3042. case aliyunavatar.FieldBizID:
  3043. m.ResetBizID()
  3044. return nil
  3045. case aliyunavatar.FieldAccessKeyID:
  3046. m.ResetAccessKeyID()
  3047. return nil
  3048. case aliyunavatar.FieldAccessKeySecret:
  3049. m.ResetAccessKeySecret()
  3050. return nil
  3051. case aliyunavatar.FieldAppID:
  3052. m.ResetAppID()
  3053. return nil
  3054. case aliyunavatar.FieldTenantID:
  3055. m.ResetTenantID()
  3056. return nil
  3057. case aliyunavatar.FieldResponse:
  3058. m.ResetResponse()
  3059. return nil
  3060. case aliyunavatar.FieldToken:
  3061. m.ResetToken()
  3062. return nil
  3063. case aliyunavatar.FieldSessionID:
  3064. m.ResetSessionID()
  3065. return nil
  3066. }
  3067. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3068. }
  3069. // AddedEdges returns all edge names that were set/added in this mutation.
  3070. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3071. edges := make([]string, 0, 0)
  3072. return edges
  3073. }
  3074. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3075. // name in this mutation.
  3076. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3077. return nil
  3078. }
  3079. // RemovedEdges returns all edge names that were removed in this mutation.
  3080. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3081. edges := make([]string, 0, 0)
  3082. return edges
  3083. }
  3084. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3085. // the given name in this mutation.
  3086. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3087. return nil
  3088. }
  3089. // ClearedEdges returns all edge names that were cleared in this mutation.
  3090. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3091. edges := make([]string, 0, 0)
  3092. return edges
  3093. }
  3094. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3095. // was cleared in this mutation.
  3096. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3097. return false
  3098. }
  3099. // ClearEdge clears the value of the edge with the given name. It returns an error
  3100. // if that edge is not defined in the schema.
  3101. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3102. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3103. }
  3104. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3105. // It returns an error if the edge is not defined in the schema.
  3106. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3107. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3108. }
  3109. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3110. type BatchMsgMutation struct {
  3111. config
  3112. op Op
  3113. typ string
  3114. id *uint64
  3115. created_at *time.Time
  3116. updated_at *time.Time
  3117. deleted_at *time.Time
  3118. status *uint8
  3119. addstatus *int8
  3120. batch_no *string
  3121. task_name *string
  3122. fromwxid *string
  3123. msg *string
  3124. tag *string
  3125. tagids *string
  3126. total *int32
  3127. addtotal *int32
  3128. success *int32
  3129. addsuccess *int32
  3130. fail *int32
  3131. addfail *int32
  3132. start_time *time.Time
  3133. stop_time *time.Time
  3134. send_time *time.Time
  3135. _type *int32
  3136. add_type *int32
  3137. organization_id *uint64
  3138. addorganization_id *int64
  3139. clearedFields map[string]struct{}
  3140. done bool
  3141. oldValue func(context.Context) (*BatchMsg, error)
  3142. predicates []predicate.BatchMsg
  3143. }
  3144. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3145. // batchmsgOption allows management of the mutation configuration using functional options.
  3146. type batchmsgOption func(*BatchMsgMutation)
  3147. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3148. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3149. m := &BatchMsgMutation{
  3150. config: c,
  3151. op: op,
  3152. typ: TypeBatchMsg,
  3153. clearedFields: make(map[string]struct{}),
  3154. }
  3155. for _, opt := range opts {
  3156. opt(m)
  3157. }
  3158. return m
  3159. }
  3160. // withBatchMsgID sets the ID field of the mutation.
  3161. func withBatchMsgID(id uint64) batchmsgOption {
  3162. return func(m *BatchMsgMutation) {
  3163. var (
  3164. err error
  3165. once sync.Once
  3166. value *BatchMsg
  3167. )
  3168. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3169. once.Do(func() {
  3170. if m.done {
  3171. err = errors.New("querying old values post mutation is not allowed")
  3172. } else {
  3173. value, err = m.Client().BatchMsg.Get(ctx, id)
  3174. }
  3175. })
  3176. return value, err
  3177. }
  3178. m.id = &id
  3179. }
  3180. }
  3181. // withBatchMsg sets the old BatchMsg of the mutation.
  3182. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3183. return func(m *BatchMsgMutation) {
  3184. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3185. return node, nil
  3186. }
  3187. m.id = &node.ID
  3188. }
  3189. }
  3190. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3191. // executed in a transaction (ent.Tx), a transactional client is returned.
  3192. func (m BatchMsgMutation) Client() *Client {
  3193. client := &Client{config: m.config}
  3194. client.init()
  3195. return client
  3196. }
  3197. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3198. // it returns an error otherwise.
  3199. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3200. if _, ok := m.driver.(*txDriver); !ok {
  3201. return nil, errors.New("ent: mutation is not running in a transaction")
  3202. }
  3203. tx := &Tx{config: m.config}
  3204. tx.init()
  3205. return tx, nil
  3206. }
  3207. // SetID sets the value of the id field. Note that this
  3208. // operation is only accepted on creation of BatchMsg entities.
  3209. func (m *BatchMsgMutation) SetID(id uint64) {
  3210. m.id = &id
  3211. }
  3212. // ID returns the ID value in the mutation. Note that the ID is only available
  3213. // if it was provided to the builder or after it was returned from the database.
  3214. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3215. if m.id == nil {
  3216. return
  3217. }
  3218. return *m.id, true
  3219. }
  3220. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3221. // That means, if the mutation is applied within a transaction with an isolation level such
  3222. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3223. // or updated by the mutation.
  3224. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3225. switch {
  3226. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3227. id, exists := m.ID()
  3228. if exists {
  3229. return []uint64{id}, nil
  3230. }
  3231. fallthrough
  3232. case m.op.Is(OpUpdate | OpDelete):
  3233. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  3234. default:
  3235. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3236. }
  3237. }
  3238. // SetCreatedAt sets the "created_at" field.
  3239. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  3240. m.created_at = &t
  3241. }
  3242. // CreatedAt returns the value of the "created_at" field in the mutation.
  3243. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  3244. v := m.created_at
  3245. if v == nil {
  3246. return
  3247. }
  3248. return *v, true
  3249. }
  3250. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  3251. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3253. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3254. if !m.op.Is(OpUpdateOne) {
  3255. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3256. }
  3257. if m.id == nil || m.oldValue == nil {
  3258. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3259. }
  3260. oldValue, err := m.oldValue(ctx)
  3261. if err != nil {
  3262. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3263. }
  3264. return oldValue.CreatedAt, nil
  3265. }
  3266. // ResetCreatedAt resets all changes to the "created_at" field.
  3267. func (m *BatchMsgMutation) ResetCreatedAt() {
  3268. m.created_at = nil
  3269. }
  3270. // SetUpdatedAt sets the "updated_at" field.
  3271. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  3272. m.updated_at = &t
  3273. }
  3274. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3275. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  3276. v := m.updated_at
  3277. if v == nil {
  3278. return
  3279. }
  3280. return *v, true
  3281. }
  3282. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  3283. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3285. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3286. if !m.op.Is(OpUpdateOne) {
  3287. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3288. }
  3289. if m.id == nil || m.oldValue == nil {
  3290. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3291. }
  3292. oldValue, err := m.oldValue(ctx)
  3293. if err != nil {
  3294. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3295. }
  3296. return oldValue.UpdatedAt, nil
  3297. }
  3298. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3299. func (m *BatchMsgMutation) ResetUpdatedAt() {
  3300. m.updated_at = nil
  3301. }
  3302. // SetDeletedAt sets the "deleted_at" field.
  3303. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  3304. m.deleted_at = &t
  3305. }
  3306. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3307. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  3308. v := m.deleted_at
  3309. if v == nil {
  3310. return
  3311. }
  3312. return *v, true
  3313. }
  3314. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  3315. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3317. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3318. if !m.op.Is(OpUpdateOne) {
  3319. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3320. }
  3321. if m.id == nil || m.oldValue == nil {
  3322. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3323. }
  3324. oldValue, err := m.oldValue(ctx)
  3325. if err != nil {
  3326. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3327. }
  3328. return oldValue.DeletedAt, nil
  3329. }
  3330. // ClearDeletedAt clears the value of the "deleted_at" field.
  3331. func (m *BatchMsgMutation) ClearDeletedAt() {
  3332. m.deleted_at = nil
  3333. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  3334. }
  3335. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3336. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  3337. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  3338. return ok
  3339. }
  3340. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3341. func (m *BatchMsgMutation) ResetDeletedAt() {
  3342. m.deleted_at = nil
  3343. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  3344. }
  3345. // SetStatus sets the "status" field.
  3346. func (m *BatchMsgMutation) SetStatus(u uint8) {
  3347. m.status = &u
  3348. m.addstatus = nil
  3349. }
  3350. // Status returns the value of the "status" field in the mutation.
  3351. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  3352. v := m.status
  3353. if v == nil {
  3354. return
  3355. }
  3356. return *v, true
  3357. }
  3358. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  3359. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3361. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3362. if !m.op.Is(OpUpdateOne) {
  3363. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3364. }
  3365. if m.id == nil || m.oldValue == nil {
  3366. return v, errors.New("OldStatus requires an ID field in the mutation")
  3367. }
  3368. oldValue, err := m.oldValue(ctx)
  3369. if err != nil {
  3370. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3371. }
  3372. return oldValue.Status, nil
  3373. }
  3374. // AddStatus adds u to the "status" field.
  3375. func (m *BatchMsgMutation) AddStatus(u int8) {
  3376. if m.addstatus != nil {
  3377. *m.addstatus += u
  3378. } else {
  3379. m.addstatus = &u
  3380. }
  3381. }
  3382. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3383. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  3384. v := m.addstatus
  3385. if v == nil {
  3386. return
  3387. }
  3388. return *v, true
  3389. }
  3390. // ClearStatus clears the value of the "status" field.
  3391. func (m *BatchMsgMutation) ClearStatus() {
  3392. m.status = nil
  3393. m.addstatus = nil
  3394. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  3395. }
  3396. // StatusCleared returns if the "status" field was cleared in this mutation.
  3397. func (m *BatchMsgMutation) StatusCleared() bool {
  3398. _, ok := m.clearedFields[batchmsg.FieldStatus]
  3399. return ok
  3400. }
  3401. // ResetStatus resets all changes to the "status" field.
  3402. func (m *BatchMsgMutation) ResetStatus() {
  3403. m.status = nil
  3404. m.addstatus = nil
  3405. delete(m.clearedFields, batchmsg.FieldStatus)
  3406. }
  3407. // SetBatchNo sets the "batch_no" field.
  3408. func (m *BatchMsgMutation) SetBatchNo(s string) {
  3409. m.batch_no = &s
  3410. }
  3411. // BatchNo returns the value of the "batch_no" field in the mutation.
  3412. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  3413. v := m.batch_no
  3414. if v == nil {
  3415. return
  3416. }
  3417. return *v, true
  3418. }
  3419. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  3420. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3422. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  3423. if !m.op.Is(OpUpdateOne) {
  3424. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  3425. }
  3426. if m.id == nil || m.oldValue == nil {
  3427. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  3428. }
  3429. oldValue, err := m.oldValue(ctx)
  3430. if err != nil {
  3431. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  3432. }
  3433. return oldValue.BatchNo, nil
  3434. }
  3435. // ClearBatchNo clears the value of the "batch_no" field.
  3436. func (m *BatchMsgMutation) ClearBatchNo() {
  3437. m.batch_no = nil
  3438. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  3439. }
  3440. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  3441. func (m *BatchMsgMutation) BatchNoCleared() bool {
  3442. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  3443. return ok
  3444. }
  3445. // ResetBatchNo resets all changes to the "batch_no" field.
  3446. func (m *BatchMsgMutation) ResetBatchNo() {
  3447. m.batch_no = nil
  3448. delete(m.clearedFields, batchmsg.FieldBatchNo)
  3449. }
  3450. // SetTaskName sets the "task_name" field.
  3451. func (m *BatchMsgMutation) SetTaskName(s string) {
  3452. m.task_name = &s
  3453. }
  3454. // TaskName returns the value of the "task_name" field in the mutation.
  3455. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  3456. v := m.task_name
  3457. if v == nil {
  3458. return
  3459. }
  3460. return *v, true
  3461. }
  3462. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  3463. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3465. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  3466. if !m.op.Is(OpUpdateOne) {
  3467. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  3468. }
  3469. if m.id == nil || m.oldValue == nil {
  3470. return v, errors.New("OldTaskName requires an ID field in the mutation")
  3471. }
  3472. oldValue, err := m.oldValue(ctx)
  3473. if err != nil {
  3474. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  3475. }
  3476. return oldValue.TaskName, nil
  3477. }
  3478. // ClearTaskName clears the value of the "task_name" field.
  3479. func (m *BatchMsgMutation) ClearTaskName() {
  3480. m.task_name = nil
  3481. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  3482. }
  3483. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  3484. func (m *BatchMsgMutation) TaskNameCleared() bool {
  3485. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  3486. return ok
  3487. }
  3488. // ResetTaskName resets all changes to the "task_name" field.
  3489. func (m *BatchMsgMutation) ResetTaskName() {
  3490. m.task_name = nil
  3491. delete(m.clearedFields, batchmsg.FieldTaskName)
  3492. }
  3493. // SetFromwxid sets the "fromwxid" field.
  3494. func (m *BatchMsgMutation) SetFromwxid(s string) {
  3495. m.fromwxid = &s
  3496. }
  3497. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  3498. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  3499. v := m.fromwxid
  3500. if v == nil {
  3501. return
  3502. }
  3503. return *v, true
  3504. }
  3505. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  3506. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3508. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  3509. if !m.op.Is(OpUpdateOne) {
  3510. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  3511. }
  3512. if m.id == nil || m.oldValue == nil {
  3513. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  3514. }
  3515. oldValue, err := m.oldValue(ctx)
  3516. if err != nil {
  3517. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  3518. }
  3519. return oldValue.Fromwxid, nil
  3520. }
  3521. // ClearFromwxid clears the value of the "fromwxid" field.
  3522. func (m *BatchMsgMutation) ClearFromwxid() {
  3523. m.fromwxid = nil
  3524. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  3525. }
  3526. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  3527. func (m *BatchMsgMutation) FromwxidCleared() bool {
  3528. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  3529. return ok
  3530. }
  3531. // ResetFromwxid resets all changes to the "fromwxid" field.
  3532. func (m *BatchMsgMutation) ResetFromwxid() {
  3533. m.fromwxid = nil
  3534. delete(m.clearedFields, batchmsg.FieldFromwxid)
  3535. }
  3536. // SetMsg sets the "msg" field.
  3537. func (m *BatchMsgMutation) SetMsg(s string) {
  3538. m.msg = &s
  3539. }
  3540. // Msg returns the value of the "msg" field in the mutation.
  3541. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  3542. v := m.msg
  3543. if v == nil {
  3544. return
  3545. }
  3546. return *v, true
  3547. }
  3548. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  3549. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3551. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  3552. if !m.op.Is(OpUpdateOne) {
  3553. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  3554. }
  3555. if m.id == nil || m.oldValue == nil {
  3556. return v, errors.New("OldMsg requires an ID field in the mutation")
  3557. }
  3558. oldValue, err := m.oldValue(ctx)
  3559. if err != nil {
  3560. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  3561. }
  3562. return oldValue.Msg, nil
  3563. }
  3564. // ClearMsg clears the value of the "msg" field.
  3565. func (m *BatchMsgMutation) ClearMsg() {
  3566. m.msg = nil
  3567. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  3568. }
  3569. // MsgCleared returns if the "msg" field was cleared in this mutation.
  3570. func (m *BatchMsgMutation) MsgCleared() bool {
  3571. _, ok := m.clearedFields[batchmsg.FieldMsg]
  3572. return ok
  3573. }
  3574. // ResetMsg resets all changes to the "msg" field.
  3575. func (m *BatchMsgMutation) ResetMsg() {
  3576. m.msg = nil
  3577. delete(m.clearedFields, batchmsg.FieldMsg)
  3578. }
  3579. // SetTag sets the "tag" field.
  3580. func (m *BatchMsgMutation) SetTag(s string) {
  3581. m.tag = &s
  3582. }
  3583. // Tag returns the value of the "tag" field in the mutation.
  3584. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  3585. v := m.tag
  3586. if v == nil {
  3587. return
  3588. }
  3589. return *v, true
  3590. }
  3591. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  3592. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3594. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  3595. if !m.op.Is(OpUpdateOne) {
  3596. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  3597. }
  3598. if m.id == nil || m.oldValue == nil {
  3599. return v, errors.New("OldTag requires an ID field in the mutation")
  3600. }
  3601. oldValue, err := m.oldValue(ctx)
  3602. if err != nil {
  3603. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  3604. }
  3605. return oldValue.Tag, nil
  3606. }
  3607. // ClearTag clears the value of the "tag" field.
  3608. func (m *BatchMsgMutation) ClearTag() {
  3609. m.tag = nil
  3610. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  3611. }
  3612. // TagCleared returns if the "tag" field was cleared in this mutation.
  3613. func (m *BatchMsgMutation) TagCleared() bool {
  3614. _, ok := m.clearedFields[batchmsg.FieldTag]
  3615. return ok
  3616. }
  3617. // ResetTag resets all changes to the "tag" field.
  3618. func (m *BatchMsgMutation) ResetTag() {
  3619. m.tag = nil
  3620. delete(m.clearedFields, batchmsg.FieldTag)
  3621. }
  3622. // SetTagids sets the "tagids" field.
  3623. func (m *BatchMsgMutation) SetTagids(s string) {
  3624. m.tagids = &s
  3625. }
  3626. // Tagids returns the value of the "tagids" field in the mutation.
  3627. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  3628. v := m.tagids
  3629. if v == nil {
  3630. return
  3631. }
  3632. return *v, true
  3633. }
  3634. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  3635. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3637. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  3638. if !m.op.Is(OpUpdateOne) {
  3639. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  3640. }
  3641. if m.id == nil || m.oldValue == nil {
  3642. return v, errors.New("OldTagids requires an ID field in the mutation")
  3643. }
  3644. oldValue, err := m.oldValue(ctx)
  3645. if err != nil {
  3646. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  3647. }
  3648. return oldValue.Tagids, nil
  3649. }
  3650. // ClearTagids clears the value of the "tagids" field.
  3651. func (m *BatchMsgMutation) ClearTagids() {
  3652. m.tagids = nil
  3653. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  3654. }
  3655. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  3656. func (m *BatchMsgMutation) TagidsCleared() bool {
  3657. _, ok := m.clearedFields[batchmsg.FieldTagids]
  3658. return ok
  3659. }
  3660. // ResetTagids resets all changes to the "tagids" field.
  3661. func (m *BatchMsgMutation) ResetTagids() {
  3662. m.tagids = nil
  3663. delete(m.clearedFields, batchmsg.FieldTagids)
  3664. }
  3665. // SetTotal sets the "total" field.
  3666. func (m *BatchMsgMutation) SetTotal(i int32) {
  3667. m.total = &i
  3668. m.addtotal = nil
  3669. }
  3670. // Total returns the value of the "total" field in the mutation.
  3671. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  3672. v := m.total
  3673. if v == nil {
  3674. return
  3675. }
  3676. return *v, true
  3677. }
  3678. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  3679. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3681. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  3682. if !m.op.Is(OpUpdateOne) {
  3683. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  3684. }
  3685. if m.id == nil || m.oldValue == nil {
  3686. return v, errors.New("OldTotal requires an ID field in the mutation")
  3687. }
  3688. oldValue, err := m.oldValue(ctx)
  3689. if err != nil {
  3690. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  3691. }
  3692. return oldValue.Total, nil
  3693. }
  3694. // AddTotal adds i to the "total" field.
  3695. func (m *BatchMsgMutation) AddTotal(i int32) {
  3696. if m.addtotal != nil {
  3697. *m.addtotal += i
  3698. } else {
  3699. m.addtotal = &i
  3700. }
  3701. }
  3702. // AddedTotal returns the value that was added to the "total" field in this mutation.
  3703. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  3704. v := m.addtotal
  3705. if v == nil {
  3706. return
  3707. }
  3708. return *v, true
  3709. }
  3710. // ClearTotal clears the value of the "total" field.
  3711. func (m *BatchMsgMutation) ClearTotal() {
  3712. m.total = nil
  3713. m.addtotal = nil
  3714. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  3715. }
  3716. // TotalCleared returns if the "total" field was cleared in this mutation.
  3717. func (m *BatchMsgMutation) TotalCleared() bool {
  3718. _, ok := m.clearedFields[batchmsg.FieldTotal]
  3719. return ok
  3720. }
  3721. // ResetTotal resets all changes to the "total" field.
  3722. func (m *BatchMsgMutation) ResetTotal() {
  3723. m.total = nil
  3724. m.addtotal = nil
  3725. delete(m.clearedFields, batchmsg.FieldTotal)
  3726. }
  3727. // SetSuccess sets the "success" field.
  3728. func (m *BatchMsgMutation) SetSuccess(i int32) {
  3729. m.success = &i
  3730. m.addsuccess = nil
  3731. }
  3732. // Success returns the value of the "success" field in the mutation.
  3733. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  3734. v := m.success
  3735. if v == nil {
  3736. return
  3737. }
  3738. return *v, true
  3739. }
  3740. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  3741. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3743. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  3744. if !m.op.Is(OpUpdateOne) {
  3745. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  3746. }
  3747. if m.id == nil || m.oldValue == nil {
  3748. return v, errors.New("OldSuccess requires an ID field in the mutation")
  3749. }
  3750. oldValue, err := m.oldValue(ctx)
  3751. if err != nil {
  3752. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  3753. }
  3754. return oldValue.Success, nil
  3755. }
  3756. // AddSuccess adds i to the "success" field.
  3757. func (m *BatchMsgMutation) AddSuccess(i int32) {
  3758. if m.addsuccess != nil {
  3759. *m.addsuccess += i
  3760. } else {
  3761. m.addsuccess = &i
  3762. }
  3763. }
  3764. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  3765. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  3766. v := m.addsuccess
  3767. if v == nil {
  3768. return
  3769. }
  3770. return *v, true
  3771. }
  3772. // ClearSuccess clears the value of the "success" field.
  3773. func (m *BatchMsgMutation) ClearSuccess() {
  3774. m.success = nil
  3775. m.addsuccess = nil
  3776. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  3777. }
  3778. // SuccessCleared returns if the "success" field was cleared in this mutation.
  3779. func (m *BatchMsgMutation) SuccessCleared() bool {
  3780. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  3781. return ok
  3782. }
  3783. // ResetSuccess resets all changes to the "success" field.
  3784. func (m *BatchMsgMutation) ResetSuccess() {
  3785. m.success = nil
  3786. m.addsuccess = nil
  3787. delete(m.clearedFields, batchmsg.FieldSuccess)
  3788. }
  3789. // SetFail sets the "fail" field.
  3790. func (m *BatchMsgMutation) SetFail(i int32) {
  3791. m.fail = &i
  3792. m.addfail = nil
  3793. }
  3794. // Fail returns the value of the "fail" field in the mutation.
  3795. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  3796. v := m.fail
  3797. if v == nil {
  3798. return
  3799. }
  3800. return *v, true
  3801. }
  3802. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  3803. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3805. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  3806. if !m.op.Is(OpUpdateOne) {
  3807. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  3808. }
  3809. if m.id == nil || m.oldValue == nil {
  3810. return v, errors.New("OldFail requires an ID field in the mutation")
  3811. }
  3812. oldValue, err := m.oldValue(ctx)
  3813. if err != nil {
  3814. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  3815. }
  3816. return oldValue.Fail, nil
  3817. }
  3818. // AddFail adds i to the "fail" field.
  3819. func (m *BatchMsgMutation) AddFail(i int32) {
  3820. if m.addfail != nil {
  3821. *m.addfail += i
  3822. } else {
  3823. m.addfail = &i
  3824. }
  3825. }
  3826. // AddedFail returns the value that was added to the "fail" field in this mutation.
  3827. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  3828. v := m.addfail
  3829. if v == nil {
  3830. return
  3831. }
  3832. return *v, true
  3833. }
  3834. // ClearFail clears the value of the "fail" field.
  3835. func (m *BatchMsgMutation) ClearFail() {
  3836. m.fail = nil
  3837. m.addfail = nil
  3838. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  3839. }
  3840. // FailCleared returns if the "fail" field was cleared in this mutation.
  3841. func (m *BatchMsgMutation) FailCleared() bool {
  3842. _, ok := m.clearedFields[batchmsg.FieldFail]
  3843. return ok
  3844. }
  3845. // ResetFail resets all changes to the "fail" field.
  3846. func (m *BatchMsgMutation) ResetFail() {
  3847. m.fail = nil
  3848. m.addfail = nil
  3849. delete(m.clearedFields, batchmsg.FieldFail)
  3850. }
  3851. // SetStartTime sets the "start_time" field.
  3852. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  3853. m.start_time = &t
  3854. }
  3855. // StartTime returns the value of the "start_time" field in the mutation.
  3856. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  3857. v := m.start_time
  3858. if v == nil {
  3859. return
  3860. }
  3861. return *v, true
  3862. }
  3863. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  3864. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3866. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  3867. if !m.op.Is(OpUpdateOne) {
  3868. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  3869. }
  3870. if m.id == nil || m.oldValue == nil {
  3871. return v, errors.New("OldStartTime requires an ID field in the mutation")
  3872. }
  3873. oldValue, err := m.oldValue(ctx)
  3874. if err != nil {
  3875. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  3876. }
  3877. return oldValue.StartTime, nil
  3878. }
  3879. // ClearStartTime clears the value of the "start_time" field.
  3880. func (m *BatchMsgMutation) ClearStartTime() {
  3881. m.start_time = nil
  3882. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  3883. }
  3884. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  3885. func (m *BatchMsgMutation) StartTimeCleared() bool {
  3886. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  3887. return ok
  3888. }
  3889. // ResetStartTime resets all changes to the "start_time" field.
  3890. func (m *BatchMsgMutation) ResetStartTime() {
  3891. m.start_time = nil
  3892. delete(m.clearedFields, batchmsg.FieldStartTime)
  3893. }
  3894. // SetStopTime sets the "stop_time" field.
  3895. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  3896. m.stop_time = &t
  3897. }
  3898. // StopTime returns the value of the "stop_time" field in the mutation.
  3899. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  3900. v := m.stop_time
  3901. if v == nil {
  3902. return
  3903. }
  3904. return *v, true
  3905. }
  3906. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  3907. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3909. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  3910. if !m.op.Is(OpUpdateOne) {
  3911. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  3912. }
  3913. if m.id == nil || m.oldValue == nil {
  3914. return v, errors.New("OldStopTime requires an ID field in the mutation")
  3915. }
  3916. oldValue, err := m.oldValue(ctx)
  3917. if err != nil {
  3918. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  3919. }
  3920. return oldValue.StopTime, nil
  3921. }
  3922. // ClearStopTime clears the value of the "stop_time" field.
  3923. func (m *BatchMsgMutation) ClearStopTime() {
  3924. m.stop_time = nil
  3925. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  3926. }
  3927. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  3928. func (m *BatchMsgMutation) StopTimeCleared() bool {
  3929. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  3930. return ok
  3931. }
  3932. // ResetStopTime resets all changes to the "stop_time" field.
  3933. func (m *BatchMsgMutation) ResetStopTime() {
  3934. m.stop_time = nil
  3935. delete(m.clearedFields, batchmsg.FieldStopTime)
  3936. }
  3937. // SetSendTime sets the "send_time" field.
  3938. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  3939. m.send_time = &t
  3940. }
  3941. // SendTime returns the value of the "send_time" field in the mutation.
  3942. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  3943. v := m.send_time
  3944. if v == nil {
  3945. return
  3946. }
  3947. return *v, true
  3948. }
  3949. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  3950. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3952. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  3953. if !m.op.Is(OpUpdateOne) {
  3954. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  3955. }
  3956. if m.id == nil || m.oldValue == nil {
  3957. return v, errors.New("OldSendTime requires an ID field in the mutation")
  3958. }
  3959. oldValue, err := m.oldValue(ctx)
  3960. if err != nil {
  3961. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  3962. }
  3963. return oldValue.SendTime, nil
  3964. }
  3965. // ClearSendTime clears the value of the "send_time" field.
  3966. func (m *BatchMsgMutation) ClearSendTime() {
  3967. m.send_time = nil
  3968. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  3969. }
  3970. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  3971. func (m *BatchMsgMutation) SendTimeCleared() bool {
  3972. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  3973. return ok
  3974. }
  3975. // ResetSendTime resets all changes to the "send_time" field.
  3976. func (m *BatchMsgMutation) ResetSendTime() {
  3977. m.send_time = nil
  3978. delete(m.clearedFields, batchmsg.FieldSendTime)
  3979. }
  3980. // SetType sets the "type" field.
  3981. func (m *BatchMsgMutation) SetType(i int32) {
  3982. m._type = &i
  3983. m.add_type = nil
  3984. }
  3985. // GetType returns the value of the "type" field in the mutation.
  3986. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  3987. v := m._type
  3988. if v == nil {
  3989. return
  3990. }
  3991. return *v, true
  3992. }
  3993. // OldType returns the old "type" field's value of the BatchMsg entity.
  3994. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3996. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  3997. if !m.op.Is(OpUpdateOne) {
  3998. return v, errors.New("OldType is only allowed on UpdateOne operations")
  3999. }
  4000. if m.id == nil || m.oldValue == nil {
  4001. return v, errors.New("OldType requires an ID field in the mutation")
  4002. }
  4003. oldValue, err := m.oldValue(ctx)
  4004. if err != nil {
  4005. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4006. }
  4007. return oldValue.Type, nil
  4008. }
  4009. // AddType adds i to the "type" field.
  4010. func (m *BatchMsgMutation) AddType(i int32) {
  4011. if m.add_type != nil {
  4012. *m.add_type += i
  4013. } else {
  4014. m.add_type = &i
  4015. }
  4016. }
  4017. // AddedType returns the value that was added to the "type" field in this mutation.
  4018. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4019. v := m.add_type
  4020. if v == nil {
  4021. return
  4022. }
  4023. return *v, true
  4024. }
  4025. // ClearType clears the value of the "type" field.
  4026. func (m *BatchMsgMutation) ClearType() {
  4027. m._type = nil
  4028. m.add_type = nil
  4029. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4030. }
  4031. // TypeCleared returns if the "type" field was cleared in this mutation.
  4032. func (m *BatchMsgMutation) TypeCleared() bool {
  4033. _, ok := m.clearedFields[batchmsg.FieldType]
  4034. return ok
  4035. }
  4036. // ResetType resets all changes to the "type" field.
  4037. func (m *BatchMsgMutation) ResetType() {
  4038. m._type = nil
  4039. m.add_type = nil
  4040. delete(m.clearedFields, batchmsg.FieldType)
  4041. }
  4042. // SetOrganizationID sets the "organization_id" field.
  4043. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4044. m.organization_id = &u
  4045. m.addorganization_id = nil
  4046. }
  4047. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4048. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4049. v := m.organization_id
  4050. if v == nil {
  4051. return
  4052. }
  4053. return *v, true
  4054. }
  4055. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4056. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4058. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4059. if !m.op.Is(OpUpdateOne) {
  4060. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4061. }
  4062. if m.id == nil || m.oldValue == nil {
  4063. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4064. }
  4065. oldValue, err := m.oldValue(ctx)
  4066. if err != nil {
  4067. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4068. }
  4069. return oldValue.OrganizationID, nil
  4070. }
  4071. // AddOrganizationID adds u to the "organization_id" field.
  4072. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4073. if m.addorganization_id != nil {
  4074. *m.addorganization_id += u
  4075. } else {
  4076. m.addorganization_id = &u
  4077. }
  4078. }
  4079. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4080. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4081. v := m.addorganization_id
  4082. if v == nil {
  4083. return
  4084. }
  4085. return *v, true
  4086. }
  4087. // ResetOrganizationID resets all changes to the "organization_id" field.
  4088. func (m *BatchMsgMutation) ResetOrganizationID() {
  4089. m.organization_id = nil
  4090. m.addorganization_id = nil
  4091. }
  4092. // Where appends a list predicates to the BatchMsgMutation builder.
  4093. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4094. m.predicates = append(m.predicates, ps...)
  4095. }
  4096. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4097. // users can use type-assertion to append predicates that do not depend on any generated package.
  4098. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4099. p := make([]predicate.BatchMsg, len(ps))
  4100. for i := range ps {
  4101. p[i] = ps[i]
  4102. }
  4103. m.Where(p...)
  4104. }
  4105. // Op returns the operation name.
  4106. func (m *BatchMsgMutation) Op() Op {
  4107. return m.op
  4108. }
  4109. // SetOp allows setting the mutation operation.
  4110. func (m *BatchMsgMutation) SetOp(op Op) {
  4111. m.op = op
  4112. }
  4113. // Type returns the node type of this mutation (BatchMsg).
  4114. func (m *BatchMsgMutation) Type() string {
  4115. return m.typ
  4116. }
  4117. // Fields returns all fields that were changed during this mutation. Note that in
  4118. // order to get all numeric fields that were incremented/decremented, call
  4119. // AddedFields().
  4120. func (m *BatchMsgMutation) Fields() []string {
  4121. fields := make([]string, 0, 18)
  4122. if m.created_at != nil {
  4123. fields = append(fields, batchmsg.FieldCreatedAt)
  4124. }
  4125. if m.updated_at != nil {
  4126. fields = append(fields, batchmsg.FieldUpdatedAt)
  4127. }
  4128. if m.deleted_at != nil {
  4129. fields = append(fields, batchmsg.FieldDeletedAt)
  4130. }
  4131. if m.status != nil {
  4132. fields = append(fields, batchmsg.FieldStatus)
  4133. }
  4134. if m.batch_no != nil {
  4135. fields = append(fields, batchmsg.FieldBatchNo)
  4136. }
  4137. if m.task_name != nil {
  4138. fields = append(fields, batchmsg.FieldTaskName)
  4139. }
  4140. if m.fromwxid != nil {
  4141. fields = append(fields, batchmsg.FieldFromwxid)
  4142. }
  4143. if m.msg != nil {
  4144. fields = append(fields, batchmsg.FieldMsg)
  4145. }
  4146. if m.tag != nil {
  4147. fields = append(fields, batchmsg.FieldTag)
  4148. }
  4149. if m.tagids != nil {
  4150. fields = append(fields, batchmsg.FieldTagids)
  4151. }
  4152. if m.total != nil {
  4153. fields = append(fields, batchmsg.FieldTotal)
  4154. }
  4155. if m.success != nil {
  4156. fields = append(fields, batchmsg.FieldSuccess)
  4157. }
  4158. if m.fail != nil {
  4159. fields = append(fields, batchmsg.FieldFail)
  4160. }
  4161. if m.start_time != nil {
  4162. fields = append(fields, batchmsg.FieldStartTime)
  4163. }
  4164. if m.stop_time != nil {
  4165. fields = append(fields, batchmsg.FieldStopTime)
  4166. }
  4167. if m.send_time != nil {
  4168. fields = append(fields, batchmsg.FieldSendTime)
  4169. }
  4170. if m._type != nil {
  4171. fields = append(fields, batchmsg.FieldType)
  4172. }
  4173. if m.organization_id != nil {
  4174. fields = append(fields, batchmsg.FieldOrganizationID)
  4175. }
  4176. return fields
  4177. }
  4178. // Field returns the value of a field with the given name. The second boolean
  4179. // return value indicates that this field was not set, or was not defined in the
  4180. // schema.
  4181. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4182. switch name {
  4183. case batchmsg.FieldCreatedAt:
  4184. return m.CreatedAt()
  4185. case batchmsg.FieldUpdatedAt:
  4186. return m.UpdatedAt()
  4187. case batchmsg.FieldDeletedAt:
  4188. return m.DeletedAt()
  4189. case batchmsg.FieldStatus:
  4190. return m.Status()
  4191. case batchmsg.FieldBatchNo:
  4192. return m.BatchNo()
  4193. case batchmsg.FieldTaskName:
  4194. return m.TaskName()
  4195. case batchmsg.FieldFromwxid:
  4196. return m.Fromwxid()
  4197. case batchmsg.FieldMsg:
  4198. return m.Msg()
  4199. case batchmsg.FieldTag:
  4200. return m.Tag()
  4201. case batchmsg.FieldTagids:
  4202. return m.Tagids()
  4203. case batchmsg.FieldTotal:
  4204. return m.Total()
  4205. case batchmsg.FieldSuccess:
  4206. return m.Success()
  4207. case batchmsg.FieldFail:
  4208. return m.Fail()
  4209. case batchmsg.FieldStartTime:
  4210. return m.StartTime()
  4211. case batchmsg.FieldStopTime:
  4212. return m.StopTime()
  4213. case batchmsg.FieldSendTime:
  4214. return m.SendTime()
  4215. case batchmsg.FieldType:
  4216. return m.GetType()
  4217. case batchmsg.FieldOrganizationID:
  4218. return m.OrganizationID()
  4219. }
  4220. return nil, false
  4221. }
  4222. // OldField returns the old value of the field from the database. An error is
  4223. // returned if the mutation operation is not UpdateOne, or the query to the
  4224. // database failed.
  4225. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4226. switch name {
  4227. case batchmsg.FieldCreatedAt:
  4228. return m.OldCreatedAt(ctx)
  4229. case batchmsg.FieldUpdatedAt:
  4230. return m.OldUpdatedAt(ctx)
  4231. case batchmsg.FieldDeletedAt:
  4232. return m.OldDeletedAt(ctx)
  4233. case batchmsg.FieldStatus:
  4234. return m.OldStatus(ctx)
  4235. case batchmsg.FieldBatchNo:
  4236. return m.OldBatchNo(ctx)
  4237. case batchmsg.FieldTaskName:
  4238. return m.OldTaskName(ctx)
  4239. case batchmsg.FieldFromwxid:
  4240. return m.OldFromwxid(ctx)
  4241. case batchmsg.FieldMsg:
  4242. return m.OldMsg(ctx)
  4243. case batchmsg.FieldTag:
  4244. return m.OldTag(ctx)
  4245. case batchmsg.FieldTagids:
  4246. return m.OldTagids(ctx)
  4247. case batchmsg.FieldTotal:
  4248. return m.OldTotal(ctx)
  4249. case batchmsg.FieldSuccess:
  4250. return m.OldSuccess(ctx)
  4251. case batchmsg.FieldFail:
  4252. return m.OldFail(ctx)
  4253. case batchmsg.FieldStartTime:
  4254. return m.OldStartTime(ctx)
  4255. case batchmsg.FieldStopTime:
  4256. return m.OldStopTime(ctx)
  4257. case batchmsg.FieldSendTime:
  4258. return m.OldSendTime(ctx)
  4259. case batchmsg.FieldType:
  4260. return m.OldType(ctx)
  4261. case batchmsg.FieldOrganizationID:
  4262. return m.OldOrganizationID(ctx)
  4263. }
  4264. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  4265. }
  4266. // SetField sets the value of a field with the given name. It returns an error if
  4267. // the field is not defined in the schema, or if the type mismatched the field
  4268. // type.
  4269. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  4270. switch name {
  4271. case batchmsg.FieldCreatedAt:
  4272. v, ok := value.(time.Time)
  4273. if !ok {
  4274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4275. }
  4276. m.SetCreatedAt(v)
  4277. return nil
  4278. case batchmsg.FieldUpdatedAt:
  4279. v, ok := value.(time.Time)
  4280. if !ok {
  4281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4282. }
  4283. m.SetUpdatedAt(v)
  4284. return nil
  4285. case batchmsg.FieldDeletedAt:
  4286. v, ok := value.(time.Time)
  4287. if !ok {
  4288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4289. }
  4290. m.SetDeletedAt(v)
  4291. return nil
  4292. case batchmsg.FieldStatus:
  4293. v, ok := value.(uint8)
  4294. if !ok {
  4295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4296. }
  4297. m.SetStatus(v)
  4298. return nil
  4299. case batchmsg.FieldBatchNo:
  4300. v, ok := value.(string)
  4301. if !ok {
  4302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4303. }
  4304. m.SetBatchNo(v)
  4305. return nil
  4306. case batchmsg.FieldTaskName:
  4307. v, ok := value.(string)
  4308. if !ok {
  4309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4310. }
  4311. m.SetTaskName(v)
  4312. return nil
  4313. case batchmsg.FieldFromwxid:
  4314. v, ok := value.(string)
  4315. if !ok {
  4316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4317. }
  4318. m.SetFromwxid(v)
  4319. return nil
  4320. case batchmsg.FieldMsg:
  4321. v, ok := value.(string)
  4322. if !ok {
  4323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4324. }
  4325. m.SetMsg(v)
  4326. return nil
  4327. case batchmsg.FieldTag:
  4328. v, ok := value.(string)
  4329. if !ok {
  4330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4331. }
  4332. m.SetTag(v)
  4333. return nil
  4334. case batchmsg.FieldTagids:
  4335. v, ok := value.(string)
  4336. if !ok {
  4337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4338. }
  4339. m.SetTagids(v)
  4340. return nil
  4341. case batchmsg.FieldTotal:
  4342. v, ok := value.(int32)
  4343. if !ok {
  4344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4345. }
  4346. m.SetTotal(v)
  4347. return nil
  4348. case batchmsg.FieldSuccess:
  4349. v, ok := value.(int32)
  4350. if !ok {
  4351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4352. }
  4353. m.SetSuccess(v)
  4354. return nil
  4355. case batchmsg.FieldFail:
  4356. v, ok := value.(int32)
  4357. if !ok {
  4358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4359. }
  4360. m.SetFail(v)
  4361. return nil
  4362. case batchmsg.FieldStartTime:
  4363. v, ok := value.(time.Time)
  4364. if !ok {
  4365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4366. }
  4367. m.SetStartTime(v)
  4368. return nil
  4369. case batchmsg.FieldStopTime:
  4370. v, ok := value.(time.Time)
  4371. if !ok {
  4372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4373. }
  4374. m.SetStopTime(v)
  4375. return nil
  4376. case batchmsg.FieldSendTime:
  4377. v, ok := value.(time.Time)
  4378. if !ok {
  4379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4380. }
  4381. m.SetSendTime(v)
  4382. return nil
  4383. case batchmsg.FieldType:
  4384. v, ok := value.(int32)
  4385. if !ok {
  4386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4387. }
  4388. m.SetType(v)
  4389. return nil
  4390. case batchmsg.FieldOrganizationID:
  4391. v, ok := value.(uint64)
  4392. if !ok {
  4393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4394. }
  4395. m.SetOrganizationID(v)
  4396. return nil
  4397. }
  4398. return fmt.Errorf("unknown BatchMsg field %s", name)
  4399. }
  4400. // AddedFields returns all numeric fields that were incremented/decremented during
  4401. // this mutation.
  4402. func (m *BatchMsgMutation) AddedFields() []string {
  4403. var fields []string
  4404. if m.addstatus != nil {
  4405. fields = append(fields, batchmsg.FieldStatus)
  4406. }
  4407. if m.addtotal != nil {
  4408. fields = append(fields, batchmsg.FieldTotal)
  4409. }
  4410. if m.addsuccess != nil {
  4411. fields = append(fields, batchmsg.FieldSuccess)
  4412. }
  4413. if m.addfail != nil {
  4414. fields = append(fields, batchmsg.FieldFail)
  4415. }
  4416. if m.add_type != nil {
  4417. fields = append(fields, batchmsg.FieldType)
  4418. }
  4419. if m.addorganization_id != nil {
  4420. fields = append(fields, batchmsg.FieldOrganizationID)
  4421. }
  4422. return fields
  4423. }
  4424. // AddedField returns the numeric value that was incremented/decremented on a field
  4425. // with the given name. The second boolean return value indicates that this field
  4426. // was not set, or was not defined in the schema.
  4427. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  4428. switch name {
  4429. case batchmsg.FieldStatus:
  4430. return m.AddedStatus()
  4431. case batchmsg.FieldTotal:
  4432. return m.AddedTotal()
  4433. case batchmsg.FieldSuccess:
  4434. return m.AddedSuccess()
  4435. case batchmsg.FieldFail:
  4436. return m.AddedFail()
  4437. case batchmsg.FieldType:
  4438. return m.AddedType()
  4439. case batchmsg.FieldOrganizationID:
  4440. return m.AddedOrganizationID()
  4441. }
  4442. return nil, false
  4443. }
  4444. // AddField adds the value to the field with the given name. It returns an error if
  4445. // the field is not defined in the schema, or if the type mismatched the field
  4446. // type.
  4447. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  4448. switch name {
  4449. case batchmsg.FieldStatus:
  4450. v, ok := value.(int8)
  4451. if !ok {
  4452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4453. }
  4454. m.AddStatus(v)
  4455. return nil
  4456. case batchmsg.FieldTotal:
  4457. v, ok := value.(int32)
  4458. if !ok {
  4459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4460. }
  4461. m.AddTotal(v)
  4462. return nil
  4463. case batchmsg.FieldSuccess:
  4464. v, ok := value.(int32)
  4465. if !ok {
  4466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4467. }
  4468. m.AddSuccess(v)
  4469. return nil
  4470. case batchmsg.FieldFail:
  4471. v, ok := value.(int32)
  4472. if !ok {
  4473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4474. }
  4475. m.AddFail(v)
  4476. return nil
  4477. case batchmsg.FieldType:
  4478. v, ok := value.(int32)
  4479. if !ok {
  4480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4481. }
  4482. m.AddType(v)
  4483. return nil
  4484. case batchmsg.FieldOrganizationID:
  4485. v, ok := value.(int64)
  4486. if !ok {
  4487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4488. }
  4489. m.AddOrganizationID(v)
  4490. return nil
  4491. }
  4492. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  4493. }
  4494. // ClearedFields returns all nullable fields that were cleared during this
  4495. // mutation.
  4496. func (m *BatchMsgMutation) ClearedFields() []string {
  4497. var fields []string
  4498. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  4499. fields = append(fields, batchmsg.FieldDeletedAt)
  4500. }
  4501. if m.FieldCleared(batchmsg.FieldStatus) {
  4502. fields = append(fields, batchmsg.FieldStatus)
  4503. }
  4504. if m.FieldCleared(batchmsg.FieldBatchNo) {
  4505. fields = append(fields, batchmsg.FieldBatchNo)
  4506. }
  4507. if m.FieldCleared(batchmsg.FieldTaskName) {
  4508. fields = append(fields, batchmsg.FieldTaskName)
  4509. }
  4510. if m.FieldCleared(batchmsg.FieldFromwxid) {
  4511. fields = append(fields, batchmsg.FieldFromwxid)
  4512. }
  4513. if m.FieldCleared(batchmsg.FieldMsg) {
  4514. fields = append(fields, batchmsg.FieldMsg)
  4515. }
  4516. if m.FieldCleared(batchmsg.FieldTag) {
  4517. fields = append(fields, batchmsg.FieldTag)
  4518. }
  4519. if m.FieldCleared(batchmsg.FieldTagids) {
  4520. fields = append(fields, batchmsg.FieldTagids)
  4521. }
  4522. if m.FieldCleared(batchmsg.FieldTotal) {
  4523. fields = append(fields, batchmsg.FieldTotal)
  4524. }
  4525. if m.FieldCleared(batchmsg.FieldSuccess) {
  4526. fields = append(fields, batchmsg.FieldSuccess)
  4527. }
  4528. if m.FieldCleared(batchmsg.FieldFail) {
  4529. fields = append(fields, batchmsg.FieldFail)
  4530. }
  4531. if m.FieldCleared(batchmsg.FieldStartTime) {
  4532. fields = append(fields, batchmsg.FieldStartTime)
  4533. }
  4534. if m.FieldCleared(batchmsg.FieldStopTime) {
  4535. fields = append(fields, batchmsg.FieldStopTime)
  4536. }
  4537. if m.FieldCleared(batchmsg.FieldSendTime) {
  4538. fields = append(fields, batchmsg.FieldSendTime)
  4539. }
  4540. if m.FieldCleared(batchmsg.FieldType) {
  4541. fields = append(fields, batchmsg.FieldType)
  4542. }
  4543. return fields
  4544. }
  4545. // FieldCleared returns a boolean indicating if a field with the given name was
  4546. // cleared in this mutation.
  4547. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  4548. _, ok := m.clearedFields[name]
  4549. return ok
  4550. }
  4551. // ClearField clears the value of the field with the given name. It returns an
  4552. // error if the field is not defined in the schema.
  4553. func (m *BatchMsgMutation) ClearField(name string) error {
  4554. switch name {
  4555. case batchmsg.FieldDeletedAt:
  4556. m.ClearDeletedAt()
  4557. return nil
  4558. case batchmsg.FieldStatus:
  4559. m.ClearStatus()
  4560. return nil
  4561. case batchmsg.FieldBatchNo:
  4562. m.ClearBatchNo()
  4563. return nil
  4564. case batchmsg.FieldTaskName:
  4565. m.ClearTaskName()
  4566. return nil
  4567. case batchmsg.FieldFromwxid:
  4568. m.ClearFromwxid()
  4569. return nil
  4570. case batchmsg.FieldMsg:
  4571. m.ClearMsg()
  4572. return nil
  4573. case batchmsg.FieldTag:
  4574. m.ClearTag()
  4575. return nil
  4576. case batchmsg.FieldTagids:
  4577. m.ClearTagids()
  4578. return nil
  4579. case batchmsg.FieldTotal:
  4580. m.ClearTotal()
  4581. return nil
  4582. case batchmsg.FieldSuccess:
  4583. m.ClearSuccess()
  4584. return nil
  4585. case batchmsg.FieldFail:
  4586. m.ClearFail()
  4587. return nil
  4588. case batchmsg.FieldStartTime:
  4589. m.ClearStartTime()
  4590. return nil
  4591. case batchmsg.FieldStopTime:
  4592. m.ClearStopTime()
  4593. return nil
  4594. case batchmsg.FieldSendTime:
  4595. m.ClearSendTime()
  4596. return nil
  4597. case batchmsg.FieldType:
  4598. m.ClearType()
  4599. return nil
  4600. }
  4601. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  4602. }
  4603. // ResetField resets all changes in the mutation for the field with the given name.
  4604. // It returns an error if the field is not defined in the schema.
  4605. func (m *BatchMsgMutation) ResetField(name string) error {
  4606. switch name {
  4607. case batchmsg.FieldCreatedAt:
  4608. m.ResetCreatedAt()
  4609. return nil
  4610. case batchmsg.FieldUpdatedAt:
  4611. m.ResetUpdatedAt()
  4612. return nil
  4613. case batchmsg.FieldDeletedAt:
  4614. m.ResetDeletedAt()
  4615. return nil
  4616. case batchmsg.FieldStatus:
  4617. m.ResetStatus()
  4618. return nil
  4619. case batchmsg.FieldBatchNo:
  4620. m.ResetBatchNo()
  4621. return nil
  4622. case batchmsg.FieldTaskName:
  4623. m.ResetTaskName()
  4624. return nil
  4625. case batchmsg.FieldFromwxid:
  4626. m.ResetFromwxid()
  4627. return nil
  4628. case batchmsg.FieldMsg:
  4629. m.ResetMsg()
  4630. return nil
  4631. case batchmsg.FieldTag:
  4632. m.ResetTag()
  4633. return nil
  4634. case batchmsg.FieldTagids:
  4635. m.ResetTagids()
  4636. return nil
  4637. case batchmsg.FieldTotal:
  4638. m.ResetTotal()
  4639. return nil
  4640. case batchmsg.FieldSuccess:
  4641. m.ResetSuccess()
  4642. return nil
  4643. case batchmsg.FieldFail:
  4644. m.ResetFail()
  4645. return nil
  4646. case batchmsg.FieldStartTime:
  4647. m.ResetStartTime()
  4648. return nil
  4649. case batchmsg.FieldStopTime:
  4650. m.ResetStopTime()
  4651. return nil
  4652. case batchmsg.FieldSendTime:
  4653. m.ResetSendTime()
  4654. return nil
  4655. case batchmsg.FieldType:
  4656. m.ResetType()
  4657. return nil
  4658. case batchmsg.FieldOrganizationID:
  4659. m.ResetOrganizationID()
  4660. return nil
  4661. }
  4662. return fmt.Errorf("unknown BatchMsg field %s", name)
  4663. }
  4664. // AddedEdges returns all edge names that were set/added in this mutation.
  4665. func (m *BatchMsgMutation) AddedEdges() []string {
  4666. edges := make([]string, 0, 0)
  4667. return edges
  4668. }
  4669. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4670. // name in this mutation.
  4671. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  4672. return nil
  4673. }
  4674. // RemovedEdges returns all edge names that were removed in this mutation.
  4675. func (m *BatchMsgMutation) RemovedEdges() []string {
  4676. edges := make([]string, 0, 0)
  4677. return edges
  4678. }
  4679. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4680. // the given name in this mutation.
  4681. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  4682. return nil
  4683. }
  4684. // ClearedEdges returns all edge names that were cleared in this mutation.
  4685. func (m *BatchMsgMutation) ClearedEdges() []string {
  4686. edges := make([]string, 0, 0)
  4687. return edges
  4688. }
  4689. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4690. // was cleared in this mutation.
  4691. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  4692. return false
  4693. }
  4694. // ClearEdge clears the value of the edge with the given name. It returns an error
  4695. // if that edge is not defined in the schema.
  4696. func (m *BatchMsgMutation) ClearEdge(name string) error {
  4697. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  4698. }
  4699. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4700. // It returns an error if the edge is not defined in the schema.
  4701. func (m *BatchMsgMutation) ResetEdge(name string) error {
  4702. return fmt.Errorf("unknown BatchMsg edge %s", name)
  4703. }
  4704. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  4705. type CategoryMutation struct {
  4706. config
  4707. op Op
  4708. typ string
  4709. id *uint64
  4710. created_at *time.Time
  4711. updated_at *time.Time
  4712. deleted_at *time.Time
  4713. name *string
  4714. organization_id *uint64
  4715. addorganization_id *int64
  4716. clearedFields map[string]struct{}
  4717. done bool
  4718. oldValue func(context.Context) (*Category, error)
  4719. predicates []predicate.Category
  4720. }
  4721. var _ ent.Mutation = (*CategoryMutation)(nil)
  4722. // categoryOption allows management of the mutation configuration using functional options.
  4723. type categoryOption func(*CategoryMutation)
  4724. // newCategoryMutation creates new mutation for the Category entity.
  4725. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  4726. m := &CategoryMutation{
  4727. config: c,
  4728. op: op,
  4729. typ: TypeCategory,
  4730. clearedFields: make(map[string]struct{}),
  4731. }
  4732. for _, opt := range opts {
  4733. opt(m)
  4734. }
  4735. return m
  4736. }
  4737. // withCategoryID sets the ID field of the mutation.
  4738. func withCategoryID(id uint64) categoryOption {
  4739. return func(m *CategoryMutation) {
  4740. var (
  4741. err error
  4742. once sync.Once
  4743. value *Category
  4744. )
  4745. m.oldValue = func(ctx context.Context) (*Category, error) {
  4746. once.Do(func() {
  4747. if m.done {
  4748. err = errors.New("querying old values post mutation is not allowed")
  4749. } else {
  4750. value, err = m.Client().Category.Get(ctx, id)
  4751. }
  4752. })
  4753. return value, err
  4754. }
  4755. m.id = &id
  4756. }
  4757. }
  4758. // withCategory sets the old Category of the mutation.
  4759. func withCategory(node *Category) categoryOption {
  4760. return func(m *CategoryMutation) {
  4761. m.oldValue = func(context.Context) (*Category, error) {
  4762. return node, nil
  4763. }
  4764. m.id = &node.ID
  4765. }
  4766. }
  4767. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4768. // executed in a transaction (ent.Tx), a transactional client is returned.
  4769. func (m CategoryMutation) Client() *Client {
  4770. client := &Client{config: m.config}
  4771. client.init()
  4772. return client
  4773. }
  4774. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4775. // it returns an error otherwise.
  4776. func (m CategoryMutation) Tx() (*Tx, error) {
  4777. if _, ok := m.driver.(*txDriver); !ok {
  4778. return nil, errors.New("ent: mutation is not running in a transaction")
  4779. }
  4780. tx := &Tx{config: m.config}
  4781. tx.init()
  4782. return tx, nil
  4783. }
  4784. // SetID sets the value of the id field. Note that this
  4785. // operation is only accepted on creation of Category entities.
  4786. func (m *CategoryMutation) SetID(id uint64) {
  4787. m.id = &id
  4788. }
  4789. // ID returns the ID value in the mutation. Note that the ID is only available
  4790. // if it was provided to the builder or after it was returned from the database.
  4791. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  4792. if m.id == nil {
  4793. return
  4794. }
  4795. return *m.id, true
  4796. }
  4797. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4798. // That means, if the mutation is applied within a transaction with an isolation level such
  4799. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4800. // or updated by the mutation.
  4801. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  4802. switch {
  4803. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4804. id, exists := m.ID()
  4805. if exists {
  4806. return []uint64{id}, nil
  4807. }
  4808. fallthrough
  4809. case m.op.Is(OpUpdate | OpDelete):
  4810. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  4811. default:
  4812. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4813. }
  4814. }
  4815. // SetCreatedAt sets the "created_at" field.
  4816. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  4817. m.created_at = &t
  4818. }
  4819. // CreatedAt returns the value of the "created_at" field in the mutation.
  4820. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  4821. v := m.created_at
  4822. if v == nil {
  4823. return
  4824. }
  4825. return *v, true
  4826. }
  4827. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  4828. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4830. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4831. if !m.op.Is(OpUpdateOne) {
  4832. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4833. }
  4834. if m.id == nil || m.oldValue == nil {
  4835. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4836. }
  4837. oldValue, err := m.oldValue(ctx)
  4838. if err != nil {
  4839. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4840. }
  4841. return oldValue.CreatedAt, nil
  4842. }
  4843. // ResetCreatedAt resets all changes to the "created_at" field.
  4844. func (m *CategoryMutation) ResetCreatedAt() {
  4845. m.created_at = nil
  4846. }
  4847. // SetUpdatedAt sets the "updated_at" field.
  4848. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  4849. m.updated_at = &t
  4850. }
  4851. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4852. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  4853. v := m.updated_at
  4854. if v == nil {
  4855. return
  4856. }
  4857. return *v, true
  4858. }
  4859. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  4860. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4862. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4863. if !m.op.Is(OpUpdateOne) {
  4864. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4865. }
  4866. if m.id == nil || m.oldValue == nil {
  4867. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4868. }
  4869. oldValue, err := m.oldValue(ctx)
  4870. if err != nil {
  4871. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4872. }
  4873. return oldValue.UpdatedAt, nil
  4874. }
  4875. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4876. func (m *CategoryMutation) ResetUpdatedAt() {
  4877. m.updated_at = nil
  4878. }
  4879. // SetDeletedAt sets the "deleted_at" field.
  4880. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  4881. m.deleted_at = &t
  4882. }
  4883. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4884. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  4885. v := m.deleted_at
  4886. if v == nil {
  4887. return
  4888. }
  4889. return *v, true
  4890. }
  4891. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  4892. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4894. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4895. if !m.op.Is(OpUpdateOne) {
  4896. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4897. }
  4898. if m.id == nil || m.oldValue == nil {
  4899. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4900. }
  4901. oldValue, err := m.oldValue(ctx)
  4902. if err != nil {
  4903. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4904. }
  4905. return oldValue.DeletedAt, nil
  4906. }
  4907. // ClearDeletedAt clears the value of the "deleted_at" field.
  4908. func (m *CategoryMutation) ClearDeletedAt() {
  4909. m.deleted_at = nil
  4910. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  4911. }
  4912. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4913. func (m *CategoryMutation) DeletedAtCleared() bool {
  4914. _, ok := m.clearedFields[category.FieldDeletedAt]
  4915. return ok
  4916. }
  4917. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4918. func (m *CategoryMutation) ResetDeletedAt() {
  4919. m.deleted_at = nil
  4920. delete(m.clearedFields, category.FieldDeletedAt)
  4921. }
  4922. // SetName sets the "name" field.
  4923. func (m *CategoryMutation) SetName(s string) {
  4924. m.name = &s
  4925. }
  4926. // Name returns the value of the "name" field in the mutation.
  4927. func (m *CategoryMutation) Name() (r string, exists bool) {
  4928. v := m.name
  4929. if v == nil {
  4930. return
  4931. }
  4932. return *v, true
  4933. }
  4934. // OldName returns the old "name" field's value of the Category entity.
  4935. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4937. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  4938. if !m.op.Is(OpUpdateOne) {
  4939. return v, errors.New("OldName is only allowed on UpdateOne operations")
  4940. }
  4941. if m.id == nil || m.oldValue == nil {
  4942. return v, errors.New("OldName requires an ID field in the mutation")
  4943. }
  4944. oldValue, err := m.oldValue(ctx)
  4945. if err != nil {
  4946. return v, fmt.Errorf("querying old value for OldName: %w", err)
  4947. }
  4948. return oldValue.Name, nil
  4949. }
  4950. // ResetName resets all changes to the "name" field.
  4951. func (m *CategoryMutation) ResetName() {
  4952. m.name = nil
  4953. }
  4954. // SetOrganizationID sets the "organization_id" field.
  4955. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  4956. m.organization_id = &u
  4957. m.addorganization_id = nil
  4958. }
  4959. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4960. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  4961. v := m.organization_id
  4962. if v == nil {
  4963. return
  4964. }
  4965. return *v, true
  4966. }
  4967. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  4968. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4970. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4971. if !m.op.Is(OpUpdateOne) {
  4972. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4973. }
  4974. if m.id == nil || m.oldValue == nil {
  4975. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4976. }
  4977. oldValue, err := m.oldValue(ctx)
  4978. if err != nil {
  4979. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4980. }
  4981. return oldValue.OrganizationID, nil
  4982. }
  4983. // AddOrganizationID adds u to the "organization_id" field.
  4984. func (m *CategoryMutation) AddOrganizationID(u int64) {
  4985. if m.addorganization_id != nil {
  4986. *m.addorganization_id += u
  4987. } else {
  4988. m.addorganization_id = &u
  4989. }
  4990. }
  4991. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4992. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  4993. v := m.addorganization_id
  4994. if v == nil {
  4995. return
  4996. }
  4997. return *v, true
  4998. }
  4999. // ResetOrganizationID resets all changes to the "organization_id" field.
  5000. func (m *CategoryMutation) ResetOrganizationID() {
  5001. m.organization_id = nil
  5002. m.addorganization_id = nil
  5003. }
  5004. // Where appends a list predicates to the CategoryMutation builder.
  5005. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5006. m.predicates = append(m.predicates, ps...)
  5007. }
  5008. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5009. // users can use type-assertion to append predicates that do not depend on any generated package.
  5010. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5011. p := make([]predicate.Category, len(ps))
  5012. for i := range ps {
  5013. p[i] = ps[i]
  5014. }
  5015. m.Where(p...)
  5016. }
  5017. // Op returns the operation name.
  5018. func (m *CategoryMutation) Op() Op {
  5019. return m.op
  5020. }
  5021. // SetOp allows setting the mutation operation.
  5022. func (m *CategoryMutation) SetOp(op Op) {
  5023. m.op = op
  5024. }
  5025. // Type returns the node type of this mutation (Category).
  5026. func (m *CategoryMutation) Type() string {
  5027. return m.typ
  5028. }
  5029. // Fields returns all fields that were changed during this mutation. Note that in
  5030. // order to get all numeric fields that were incremented/decremented, call
  5031. // AddedFields().
  5032. func (m *CategoryMutation) Fields() []string {
  5033. fields := make([]string, 0, 5)
  5034. if m.created_at != nil {
  5035. fields = append(fields, category.FieldCreatedAt)
  5036. }
  5037. if m.updated_at != nil {
  5038. fields = append(fields, category.FieldUpdatedAt)
  5039. }
  5040. if m.deleted_at != nil {
  5041. fields = append(fields, category.FieldDeletedAt)
  5042. }
  5043. if m.name != nil {
  5044. fields = append(fields, category.FieldName)
  5045. }
  5046. if m.organization_id != nil {
  5047. fields = append(fields, category.FieldOrganizationID)
  5048. }
  5049. return fields
  5050. }
  5051. // Field returns the value of a field with the given name. The second boolean
  5052. // return value indicates that this field was not set, or was not defined in the
  5053. // schema.
  5054. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5055. switch name {
  5056. case category.FieldCreatedAt:
  5057. return m.CreatedAt()
  5058. case category.FieldUpdatedAt:
  5059. return m.UpdatedAt()
  5060. case category.FieldDeletedAt:
  5061. return m.DeletedAt()
  5062. case category.FieldName:
  5063. return m.Name()
  5064. case category.FieldOrganizationID:
  5065. return m.OrganizationID()
  5066. }
  5067. return nil, false
  5068. }
  5069. // OldField returns the old value of the field from the database. An error is
  5070. // returned if the mutation operation is not UpdateOne, or the query to the
  5071. // database failed.
  5072. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5073. switch name {
  5074. case category.FieldCreatedAt:
  5075. return m.OldCreatedAt(ctx)
  5076. case category.FieldUpdatedAt:
  5077. return m.OldUpdatedAt(ctx)
  5078. case category.FieldDeletedAt:
  5079. return m.OldDeletedAt(ctx)
  5080. case category.FieldName:
  5081. return m.OldName(ctx)
  5082. case category.FieldOrganizationID:
  5083. return m.OldOrganizationID(ctx)
  5084. }
  5085. return nil, fmt.Errorf("unknown Category field %s", name)
  5086. }
  5087. // SetField sets the value of a field with the given name. It returns an error if
  5088. // the field is not defined in the schema, or if the type mismatched the field
  5089. // type.
  5090. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5091. switch name {
  5092. case category.FieldCreatedAt:
  5093. v, ok := value.(time.Time)
  5094. if !ok {
  5095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5096. }
  5097. m.SetCreatedAt(v)
  5098. return nil
  5099. case category.FieldUpdatedAt:
  5100. v, ok := value.(time.Time)
  5101. if !ok {
  5102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5103. }
  5104. m.SetUpdatedAt(v)
  5105. return nil
  5106. case category.FieldDeletedAt:
  5107. v, ok := value.(time.Time)
  5108. if !ok {
  5109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5110. }
  5111. m.SetDeletedAt(v)
  5112. return nil
  5113. case category.FieldName:
  5114. v, ok := value.(string)
  5115. if !ok {
  5116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5117. }
  5118. m.SetName(v)
  5119. return nil
  5120. case category.FieldOrganizationID:
  5121. v, ok := value.(uint64)
  5122. if !ok {
  5123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5124. }
  5125. m.SetOrganizationID(v)
  5126. return nil
  5127. }
  5128. return fmt.Errorf("unknown Category field %s", name)
  5129. }
  5130. // AddedFields returns all numeric fields that were incremented/decremented during
  5131. // this mutation.
  5132. func (m *CategoryMutation) AddedFields() []string {
  5133. var fields []string
  5134. if m.addorganization_id != nil {
  5135. fields = append(fields, category.FieldOrganizationID)
  5136. }
  5137. return fields
  5138. }
  5139. // AddedField returns the numeric value that was incremented/decremented on a field
  5140. // with the given name. The second boolean return value indicates that this field
  5141. // was not set, or was not defined in the schema.
  5142. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5143. switch name {
  5144. case category.FieldOrganizationID:
  5145. return m.AddedOrganizationID()
  5146. }
  5147. return nil, false
  5148. }
  5149. // AddField adds the value to the field with the given name. It returns an error if
  5150. // the field is not defined in the schema, or if the type mismatched the field
  5151. // type.
  5152. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5153. switch name {
  5154. case category.FieldOrganizationID:
  5155. v, ok := value.(int64)
  5156. if !ok {
  5157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5158. }
  5159. m.AddOrganizationID(v)
  5160. return nil
  5161. }
  5162. return fmt.Errorf("unknown Category numeric field %s", name)
  5163. }
  5164. // ClearedFields returns all nullable fields that were cleared during this
  5165. // mutation.
  5166. func (m *CategoryMutation) ClearedFields() []string {
  5167. var fields []string
  5168. if m.FieldCleared(category.FieldDeletedAt) {
  5169. fields = append(fields, category.FieldDeletedAt)
  5170. }
  5171. return fields
  5172. }
  5173. // FieldCleared returns a boolean indicating if a field with the given name was
  5174. // cleared in this mutation.
  5175. func (m *CategoryMutation) FieldCleared(name string) bool {
  5176. _, ok := m.clearedFields[name]
  5177. return ok
  5178. }
  5179. // ClearField clears the value of the field with the given name. It returns an
  5180. // error if the field is not defined in the schema.
  5181. func (m *CategoryMutation) ClearField(name string) error {
  5182. switch name {
  5183. case category.FieldDeletedAt:
  5184. m.ClearDeletedAt()
  5185. return nil
  5186. }
  5187. return fmt.Errorf("unknown Category nullable field %s", name)
  5188. }
  5189. // ResetField resets all changes in the mutation for the field with the given name.
  5190. // It returns an error if the field is not defined in the schema.
  5191. func (m *CategoryMutation) ResetField(name string) error {
  5192. switch name {
  5193. case category.FieldCreatedAt:
  5194. m.ResetCreatedAt()
  5195. return nil
  5196. case category.FieldUpdatedAt:
  5197. m.ResetUpdatedAt()
  5198. return nil
  5199. case category.FieldDeletedAt:
  5200. m.ResetDeletedAt()
  5201. return nil
  5202. case category.FieldName:
  5203. m.ResetName()
  5204. return nil
  5205. case category.FieldOrganizationID:
  5206. m.ResetOrganizationID()
  5207. return nil
  5208. }
  5209. return fmt.Errorf("unknown Category field %s", name)
  5210. }
  5211. // AddedEdges returns all edge names that were set/added in this mutation.
  5212. func (m *CategoryMutation) AddedEdges() []string {
  5213. edges := make([]string, 0, 0)
  5214. return edges
  5215. }
  5216. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5217. // name in this mutation.
  5218. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5219. return nil
  5220. }
  5221. // RemovedEdges returns all edge names that were removed in this mutation.
  5222. func (m *CategoryMutation) RemovedEdges() []string {
  5223. edges := make([]string, 0, 0)
  5224. return edges
  5225. }
  5226. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5227. // the given name in this mutation.
  5228. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  5229. return nil
  5230. }
  5231. // ClearedEdges returns all edge names that were cleared in this mutation.
  5232. func (m *CategoryMutation) ClearedEdges() []string {
  5233. edges := make([]string, 0, 0)
  5234. return edges
  5235. }
  5236. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5237. // was cleared in this mutation.
  5238. func (m *CategoryMutation) EdgeCleared(name string) bool {
  5239. return false
  5240. }
  5241. // ClearEdge clears the value of the edge with the given name. It returns an error
  5242. // if that edge is not defined in the schema.
  5243. func (m *CategoryMutation) ClearEdge(name string) error {
  5244. return fmt.Errorf("unknown Category unique edge %s", name)
  5245. }
  5246. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5247. // It returns an error if the edge is not defined in the schema.
  5248. func (m *CategoryMutation) ResetEdge(name string) error {
  5249. return fmt.Errorf("unknown Category edge %s", name)
  5250. }
  5251. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  5252. type ChatRecordsMutation struct {
  5253. config
  5254. op Op
  5255. typ string
  5256. id *uint64
  5257. created_at *time.Time
  5258. updated_at *time.Time
  5259. deleted_at *time.Time
  5260. content *string
  5261. content_type *uint8
  5262. addcontent_type *int8
  5263. session_id *uint64
  5264. addsession_id *int64
  5265. user_id *uint64
  5266. adduser_id *int64
  5267. bot_id *uint64
  5268. addbot_id *int64
  5269. bot_type *uint8
  5270. addbot_type *int8
  5271. clearedFields map[string]struct{}
  5272. done bool
  5273. oldValue func(context.Context) (*ChatRecords, error)
  5274. predicates []predicate.ChatRecords
  5275. }
  5276. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  5277. // chatrecordsOption allows management of the mutation configuration using functional options.
  5278. type chatrecordsOption func(*ChatRecordsMutation)
  5279. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  5280. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  5281. m := &ChatRecordsMutation{
  5282. config: c,
  5283. op: op,
  5284. typ: TypeChatRecords,
  5285. clearedFields: make(map[string]struct{}),
  5286. }
  5287. for _, opt := range opts {
  5288. opt(m)
  5289. }
  5290. return m
  5291. }
  5292. // withChatRecordsID sets the ID field of the mutation.
  5293. func withChatRecordsID(id uint64) chatrecordsOption {
  5294. return func(m *ChatRecordsMutation) {
  5295. var (
  5296. err error
  5297. once sync.Once
  5298. value *ChatRecords
  5299. )
  5300. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  5301. once.Do(func() {
  5302. if m.done {
  5303. err = errors.New("querying old values post mutation is not allowed")
  5304. } else {
  5305. value, err = m.Client().ChatRecords.Get(ctx, id)
  5306. }
  5307. })
  5308. return value, err
  5309. }
  5310. m.id = &id
  5311. }
  5312. }
  5313. // withChatRecords sets the old ChatRecords of the mutation.
  5314. func withChatRecords(node *ChatRecords) chatrecordsOption {
  5315. return func(m *ChatRecordsMutation) {
  5316. m.oldValue = func(context.Context) (*ChatRecords, error) {
  5317. return node, nil
  5318. }
  5319. m.id = &node.ID
  5320. }
  5321. }
  5322. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5323. // executed in a transaction (ent.Tx), a transactional client is returned.
  5324. func (m ChatRecordsMutation) Client() *Client {
  5325. client := &Client{config: m.config}
  5326. client.init()
  5327. return client
  5328. }
  5329. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5330. // it returns an error otherwise.
  5331. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  5332. if _, ok := m.driver.(*txDriver); !ok {
  5333. return nil, errors.New("ent: mutation is not running in a transaction")
  5334. }
  5335. tx := &Tx{config: m.config}
  5336. tx.init()
  5337. return tx, nil
  5338. }
  5339. // SetID sets the value of the id field. Note that this
  5340. // operation is only accepted on creation of ChatRecords entities.
  5341. func (m *ChatRecordsMutation) SetID(id uint64) {
  5342. m.id = &id
  5343. }
  5344. // ID returns the ID value in the mutation. Note that the ID is only available
  5345. // if it was provided to the builder or after it was returned from the database.
  5346. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  5347. if m.id == nil {
  5348. return
  5349. }
  5350. return *m.id, true
  5351. }
  5352. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5353. // That means, if the mutation is applied within a transaction with an isolation level such
  5354. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5355. // or updated by the mutation.
  5356. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  5357. switch {
  5358. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5359. id, exists := m.ID()
  5360. if exists {
  5361. return []uint64{id}, nil
  5362. }
  5363. fallthrough
  5364. case m.op.Is(OpUpdate | OpDelete):
  5365. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  5366. default:
  5367. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5368. }
  5369. }
  5370. // SetCreatedAt sets the "created_at" field.
  5371. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  5372. m.created_at = &t
  5373. }
  5374. // CreatedAt returns the value of the "created_at" field in the mutation.
  5375. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  5376. v := m.created_at
  5377. if v == nil {
  5378. return
  5379. }
  5380. return *v, true
  5381. }
  5382. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  5383. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5385. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5386. if !m.op.Is(OpUpdateOne) {
  5387. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5388. }
  5389. if m.id == nil || m.oldValue == nil {
  5390. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5391. }
  5392. oldValue, err := m.oldValue(ctx)
  5393. if err != nil {
  5394. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5395. }
  5396. return oldValue.CreatedAt, nil
  5397. }
  5398. // ResetCreatedAt resets all changes to the "created_at" field.
  5399. func (m *ChatRecordsMutation) ResetCreatedAt() {
  5400. m.created_at = nil
  5401. }
  5402. // SetUpdatedAt sets the "updated_at" field.
  5403. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  5404. m.updated_at = &t
  5405. }
  5406. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5407. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  5408. v := m.updated_at
  5409. if v == nil {
  5410. return
  5411. }
  5412. return *v, true
  5413. }
  5414. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  5415. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5417. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5418. if !m.op.Is(OpUpdateOne) {
  5419. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5420. }
  5421. if m.id == nil || m.oldValue == nil {
  5422. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5423. }
  5424. oldValue, err := m.oldValue(ctx)
  5425. if err != nil {
  5426. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5427. }
  5428. return oldValue.UpdatedAt, nil
  5429. }
  5430. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5431. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  5432. m.updated_at = nil
  5433. }
  5434. // SetDeletedAt sets the "deleted_at" field.
  5435. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  5436. m.deleted_at = &t
  5437. }
  5438. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5439. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  5440. v := m.deleted_at
  5441. if v == nil {
  5442. return
  5443. }
  5444. return *v, true
  5445. }
  5446. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  5447. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5449. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5450. if !m.op.Is(OpUpdateOne) {
  5451. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5452. }
  5453. if m.id == nil || m.oldValue == nil {
  5454. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5455. }
  5456. oldValue, err := m.oldValue(ctx)
  5457. if err != nil {
  5458. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5459. }
  5460. return oldValue.DeletedAt, nil
  5461. }
  5462. // ClearDeletedAt clears the value of the "deleted_at" field.
  5463. func (m *ChatRecordsMutation) ClearDeletedAt() {
  5464. m.deleted_at = nil
  5465. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  5466. }
  5467. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5468. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  5469. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  5470. return ok
  5471. }
  5472. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5473. func (m *ChatRecordsMutation) ResetDeletedAt() {
  5474. m.deleted_at = nil
  5475. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  5476. }
  5477. // SetContent sets the "content" field.
  5478. func (m *ChatRecordsMutation) SetContent(s string) {
  5479. m.content = &s
  5480. }
  5481. // Content returns the value of the "content" field in the mutation.
  5482. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  5483. v := m.content
  5484. if v == nil {
  5485. return
  5486. }
  5487. return *v, true
  5488. }
  5489. // OldContent returns the old "content" field's value of the ChatRecords entity.
  5490. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5492. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  5493. if !m.op.Is(OpUpdateOne) {
  5494. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  5495. }
  5496. if m.id == nil || m.oldValue == nil {
  5497. return v, errors.New("OldContent requires an ID field in the mutation")
  5498. }
  5499. oldValue, err := m.oldValue(ctx)
  5500. if err != nil {
  5501. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  5502. }
  5503. return oldValue.Content, nil
  5504. }
  5505. // ResetContent resets all changes to the "content" field.
  5506. func (m *ChatRecordsMutation) ResetContent() {
  5507. m.content = nil
  5508. }
  5509. // SetContentType sets the "content_type" field.
  5510. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  5511. m.content_type = &u
  5512. m.addcontent_type = nil
  5513. }
  5514. // ContentType returns the value of the "content_type" field in the mutation.
  5515. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  5516. v := m.content_type
  5517. if v == nil {
  5518. return
  5519. }
  5520. return *v, true
  5521. }
  5522. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  5523. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5525. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  5526. if !m.op.Is(OpUpdateOne) {
  5527. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  5528. }
  5529. if m.id == nil || m.oldValue == nil {
  5530. return v, errors.New("OldContentType requires an ID field in the mutation")
  5531. }
  5532. oldValue, err := m.oldValue(ctx)
  5533. if err != nil {
  5534. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  5535. }
  5536. return oldValue.ContentType, nil
  5537. }
  5538. // AddContentType adds u to the "content_type" field.
  5539. func (m *ChatRecordsMutation) AddContentType(u int8) {
  5540. if m.addcontent_type != nil {
  5541. *m.addcontent_type += u
  5542. } else {
  5543. m.addcontent_type = &u
  5544. }
  5545. }
  5546. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  5547. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  5548. v := m.addcontent_type
  5549. if v == nil {
  5550. return
  5551. }
  5552. return *v, true
  5553. }
  5554. // ResetContentType resets all changes to the "content_type" field.
  5555. func (m *ChatRecordsMutation) ResetContentType() {
  5556. m.content_type = nil
  5557. m.addcontent_type = nil
  5558. }
  5559. // SetSessionID sets the "session_id" field.
  5560. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  5561. m.session_id = &u
  5562. m.addsession_id = nil
  5563. }
  5564. // SessionID returns the value of the "session_id" field in the mutation.
  5565. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  5566. v := m.session_id
  5567. if v == nil {
  5568. return
  5569. }
  5570. return *v, true
  5571. }
  5572. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  5573. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5575. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  5576. if !m.op.Is(OpUpdateOne) {
  5577. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  5578. }
  5579. if m.id == nil || m.oldValue == nil {
  5580. return v, errors.New("OldSessionID requires an ID field in the mutation")
  5581. }
  5582. oldValue, err := m.oldValue(ctx)
  5583. if err != nil {
  5584. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  5585. }
  5586. return oldValue.SessionID, nil
  5587. }
  5588. // AddSessionID adds u to the "session_id" field.
  5589. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  5590. if m.addsession_id != nil {
  5591. *m.addsession_id += u
  5592. } else {
  5593. m.addsession_id = &u
  5594. }
  5595. }
  5596. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  5597. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  5598. v := m.addsession_id
  5599. if v == nil {
  5600. return
  5601. }
  5602. return *v, true
  5603. }
  5604. // ResetSessionID resets all changes to the "session_id" field.
  5605. func (m *ChatRecordsMutation) ResetSessionID() {
  5606. m.session_id = nil
  5607. m.addsession_id = nil
  5608. }
  5609. // SetUserID sets the "user_id" field.
  5610. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  5611. m.user_id = &u
  5612. m.adduser_id = nil
  5613. }
  5614. // UserID returns the value of the "user_id" field in the mutation.
  5615. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  5616. v := m.user_id
  5617. if v == nil {
  5618. return
  5619. }
  5620. return *v, true
  5621. }
  5622. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  5623. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5625. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  5626. if !m.op.Is(OpUpdateOne) {
  5627. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  5628. }
  5629. if m.id == nil || m.oldValue == nil {
  5630. return v, errors.New("OldUserID requires an ID field in the mutation")
  5631. }
  5632. oldValue, err := m.oldValue(ctx)
  5633. if err != nil {
  5634. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  5635. }
  5636. return oldValue.UserID, nil
  5637. }
  5638. // AddUserID adds u to the "user_id" field.
  5639. func (m *ChatRecordsMutation) AddUserID(u int64) {
  5640. if m.adduser_id != nil {
  5641. *m.adduser_id += u
  5642. } else {
  5643. m.adduser_id = &u
  5644. }
  5645. }
  5646. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  5647. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  5648. v := m.adduser_id
  5649. if v == nil {
  5650. return
  5651. }
  5652. return *v, true
  5653. }
  5654. // ResetUserID resets all changes to the "user_id" field.
  5655. func (m *ChatRecordsMutation) ResetUserID() {
  5656. m.user_id = nil
  5657. m.adduser_id = nil
  5658. }
  5659. // SetBotID sets the "bot_id" field.
  5660. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  5661. m.bot_id = &u
  5662. m.addbot_id = nil
  5663. }
  5664. // BotID returns the value of the "bot_id" field in the mutation.
  5665. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  5666. v := m.bot_id
  5667. if v == nil {
  5668. return
  5669. }
  5670. return *v, true
  5671. }
  5672. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  5673. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5675. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  5676. if !m.op.Is(OpUpdateOne) {
  5677. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  5678. }
  5679. if m.id == nil || m.oldValue == nil {
  5680. return v, errors.New("OldBotID requires an ID field in the mutation")
  5681. }
  5682. oldValue, err := m.oldValue(ctx)
  5683. if err != nil {
  5684. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  5685. }
  5686. return oldValue.BotID, nil
  5687. }
  5688. // AddBotID adds u to the "bot_id" field.
  5689. func (m *ChatRecordsMutation) AddBotID(u int64) {
  5690. if m.addbot_id != nil {
  5691. *m.addbot_id += u
  5692. } else {
  5693. m.addbot_id = &u
  5694. }
  5695. }
  5696. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  5697. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  5698. v := m.addbot_id
  5699. if v == nil {
  5700. return
  5701. }
  5702. return *v, true
  5703. }
  5704. // ResetBotID resets all changes to the "bot_id" field.
  5705. func (m *ChatRecordsMutation) ResetBotID() {
  5706. m.bot_id = nil
  5707. m.addbot_id = nil
  5708. }
  5709. // SetBotType sets the "bot_type" field.
  5710. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  5711. m.bot_type = &u
  5712. m.addbot_type = nil
  5713. }
  5714. // BotType returns the value of the "bot_type" field in the mutation.
  5715. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  5716. v := m.bot_type
  5717. if v == nil {
  5718. return
  5719. }
  5720. return *v, true
  5721. }
  5722. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  5723. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5725. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  5726. if !m.op.Is(OpUpdateOne) {
  5727. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  5728. }
  5729. if m.id == nil || m.oldValue == nil {
  5730. return v, errors.New("OldBotType requires an ID field in the mutation")
  5731. }
  5732. oldValue, err := m.oldValue(ctx)
  5733. if err != nil {
  5734. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  5735. }
  5736. return oldValue.BotType, nil
  5737. }
  5738. // AddBotType adds u to the "bot_type" field.
  5739. func (m *ChatRecordsMutation) AddBotType(u int8) {
  5740. if m.addbot_type != nil {
  5741. *m.addbot_type += u
  5742. } else {
  5743. m.addbot_type = &u
  5744. }
  5745. }
  5746. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  5747. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  5748. v := m.addbot_type
  5749. if v == nil {
  5750. return
  5751. }
  5752. return *v, true
  5753. }
  5754. // ResetBotType resets all changes to the "bot_type" field.
  5755. func (m *ChatRecordsMutation) ResetBotType() {
  5756. m.bot_type = nil
  5757. m.addbot_type = nil
  5758. }
  5759. // Where appends a list predicates to the ChatRecordsMutation builder.
  5760. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  5761. m.predicates = append(m.predicates, ps...)
  5762. }
  5763. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  5764. // users can use type-assertion to append predicates that do not depend on any generated package.
  5765. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  5766. p := make([]predicate.ChatRecords, len(ps))
  5767. for i := range ps {
  5768. p[i] = ps[i]
  5769. }
  5770. m.Where(p...)
  5771. }
  5772. // Op returns the operation name.
  5773. func (m *ChatRecordsMutation) Op() Op {
  5774. return m.op
  5775. }
  5776. // SetOp allows setting the mutation operation.
  5777. func (m *ChatRecordsMutation) SetOp(op Op) {
  5778. m.op = op
  5779. }
  5780. // Type returns the node type of this mutation (ChatRecords).
  5781. func (m *ChatRecordsMutation) Type() string {
  5782. return m.typ
  5783. }
  5784. // Fields returns all fields that were changed during this mutation. Note that in
  5785. // order to get all numeric fields that were incremented/decremented, call
  5786. // AddedFields().
  5787. func (m *ChatRecordsMutation) Fields() []string {
  5788. fields := make([]string, 0, 9)
  5789. if m.created_at != nil {
  5790. fields = append(fields, chatrecords.FieldCreatedAt)
  5791. }
  5792. if m.updated_at != nil {
  5793. fields = append(fields, chatrecords.FieldUpdatedAt)
  5794. }
  5795. if m.deleted_at != nil {
  5796. fields = append(fields, chatrecords.FieldDeletedAt)
  5797. }
  5798. if m.content != nil {
  5799. fields = append(fields, chatrecords.FieldContent)
  5800. }
  5801. if m.content_type != nil {
  5802. fields = append(fields, chatrecords.FieldContentType)
  5803. }
  5804. if m.session_id != nil {
  5805. fields = append(fields, chatrecords.FieldSessionID)
  5806. }
  5807. if m.user_id != nil {
  5808. fields = append(fields, chatrecords.FieldUserID)
  5809. }
  5810. if m.bot_id != nil {
  5811. fields = append(fields, chatrecords.FieldBotID)
  5812. }
  5813. if m.bot_type != nil {
  5814. fields = append(fields, chatrecords.FieldBotType)
  5815. }
  5816. return fields
  5817. }
  5818. // Field returns the value of a field with the given name. The second boolean
  5819. // return value indicates that this field was not set, or was not defined in the
  5820. // schema.
  5821. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  5822. switch name {
  5823. case chatrecords.FieldCreatedAt:
  5824. return m.CreatedAt()
  5825. case chatrecords.FieldUpdatedAt:
  5826. return m.UpdatedAt()
  5827. case chatrecords.FieldDeletedAt:
  5828. return m.DeletedAt()
  5829. case chatrecords.FieldContent:
  5830. return m.Content()
  5831. case chatrecords.FieldContentType:
  5832. return m.ContentType()
  5833. case chatrecords.FieldSessionID:
  5834. return m.SessionID()
  5835. case chatrecords.FieldUserID:
  5836. return m.UserID()
  5837. case chatrecords.FieldBotID:
  5838. return m.BotID()
  5839. case chatrecords.FieldBotType:
  5840. return m.BotType()
  5841. }
  5842. return nil, false
  5843. }
  5844. // OldField returns the old value of the field from the database. An error is
  5845. // returned if the mutation operation is not UpdateOne, or the query to the
  5846. // database failed.
  5847. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5848. switch name {
  5849. case chatrecords.FieldCreatedAt:
  5850. return m.OldCreatedAt(ctx)
  5851. case chatrecords.FieldUpdatedAt:
  5852. return m.OldUpdatedAt(ctx)
  5853. case chatrecords.FieldDeletedAt:
  5854. return m.OldDeletedAt(ctx)
  5855. case chatrecords.FieldContent:
  5856. return m.OldContent(ctx)
  5857. case chatrecords.FieldContentType:
  5858. return m.OldContentType(ctx)
  5859. case chatrecords.FieldSessionID:
  5860. return m.OldSessionID(ctx)
  5861. case chatrecords.FieldUserID:
  5862. return m.OldUserID(ctx)
  5863. case chatrecords.FieldBotID:
  5864. return m.OldBotID(ctx)
  5865. case chatrecords.FieldBotType:
  5866. return m.OldBotType(ctx)
  5867. }
  5868. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  5869. }
  5870. // SetField sets the value of a field with the given name. It returns an error if
  5871. // the field is not defined in the schema, or if the type mismatched the field
  5872. // type.
  5873. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  5874. switch name {
  5875. case chatrecords.FieldCreatedAt:
  5876. v, ok := value.(time.Time)
  5877. if !ok {
  5878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5879. }
  5880. m.SetCreatedAt(v)
  5881. return nil
  5882. case chatrecords.FieldUpdatedAt:
  5883. v, ok := value.(time.Time)
  5884. if !ok {
  5885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5886. }
  5887. m.SetUpdatedAt(v)
  5888. return nil
  5889. case chatrecords.FieldDeletedAt:
  5890. v, ok := value.(time.Time)
  5891. if !ok {
  5892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5893. }
  5894. m.SetDeletedAt(v)
  5895. return nil
  5896. case chatrecords.FieldContent:
  5897. v, ok := value.(string)
  5898. if !ok {
  5899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5900. }
  5901. m.SetContent(v)
  5902. return nil
  5903. case chatrecords.FieldContentType:
  5904. v, ok := value.(uint8)
  5905. if !ok {
  5906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5907. }
  5908. m.SetContentType(v)
  5909. return nil
  5910. case chatrecords.FieldSessionID:
  5911. v, ok := value.(uint64)
  5912. if !ok {
  5913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5914. }
  5915. m.SetSessionID(v)
  5916. return nil
  5917. case chatrecords.FieldUserID:
  5918. v, ok := value.(uint64)
  5919. if !ok {
  5920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5921. }
  5922. m.SetUserID(v)
  5923. return nil
  5924. case chatrecords.FieldBotID:
  5925. v, ok := value.(uint64)
  5926. if !ok {
  5927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5928. }
  5929. m.SetBotID(v)
  5930. return nil
  5931. case chatrecords.FieldBotType:
  5932. v, ok := value.(uint8)
  5933. if !ok {
  5934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5935. }
  5936. m.SetBotType(v)
  5937. return nil
  5938. }
  5939. return fmt.Errorf("unknown ChatRecords field %s", name)
  5940. }
  5941. // AddedFields returns all numeric fields that were incremented/decremented during
  5942. // this mutation.
  5943. func (m *ChatRecordsMutation) AddedFields() []string {
  5944. var fields []string
  5945. if m.addcontent_type != nil {
  5946. fields = append(fields, chatrecords.FieldContentType)
  5947. }
  5948. if m.addsession_id != nil {
  5949. fields = append(fields, chatrecords.FieldSessionID)
  5950. }
  5951. if m.adduser_id != nil {
  5952. fields = append(fields, chatrecords.FieldUserID)
  5953. }
  5954. if m.addbot_id != nil {
  5955. fields = append(fields, chatrecords.FieldBotID)
  5956. }
  5957. if m.addbot_type != nil {
  5958. fields = append(fields, chatrecords.FieldBotType)
  5959. }
  5960. return fields
  5961. }
  5962. // AddedField returns the numeric value that was incremented/decremented on a field
  5963. // with the given name. The second boolean return value indicates that this field
  5964. // was not set, or was not defined in the schema.
  5965. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  5966. switch name {
  5967. case chatrecords.FieldContentType:
  5968. return m.AddedContentType()
  5969. case chatrecords.FieldSessionID:
  5970. return m.AddedSessionID()
  5971. case chatrecords.FieldUserID:
  5972. return m.AddedUserID()
  5973. case chatrecords.FieldBotID:
  5974. return m.AddedBotID()
  5975. case chatrecords.FieldBotType:
  5976. return m.AddedBotType()
  5977. }
  5978. return nil, false
  5979. }
  5980. // AddField adds the value to the field with the given name. It returns an error if
  5981. // the field is not defined in the schema, or if the type mismatched the field
  5982. // type.
  5983. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  5984. switch name {
  5985. case chatrecords.FieldContentType:
  5986. v, ok := value.(int8)
  5987. if !ok {
  5988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5989. }
  5990. m.AddContentType(v)
  5991. return nil
  5992. case chatrecords.FieldSessionID:
  5993. v, ok := value.(int64)
  5994. if !ok {
  5995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5996. }
  5997. m.AddSessionID(v)
  5998. return nil
  5999. case chatrecords.FieldUserID:
  6000. v, ok := value.(int64)
  6001. if !ok {
  6002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6003. }
  6004. m.AddUserID(v)
  6005. return nil
  6006. case chatrecords.FieldBotID:
  6007. v, ok := value.(int64)
  6008. if !ok {
  6009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6010. }
  6011. m.AddBotID(v)
  6012. return nil
  6013. case chatrecords.FieldBotType:
  6014. v, ok := value.(int8)
  6015. if !ok {
  6016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6017. }
  6018. m.AddBotType(v)
  6019. return nil
  6020. }
  6021. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6022. }
  6023. // ClearedFields returns all nullable fields that were cleared during this
  6024. // mutation.
  6025. func (m *ChatRecordsMutation) ClearedFields() []string {
  6026. var fields []string
  6027. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6028. fields = append(fields, chatrecords.FieldDeletedAt)
  6029. }
  6030. return fields
  6031. }
  6032. // FieldCleared returns a boolean indicating if a field with the given name was
  6033. // cleared in this mutation.
  6034. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6035. _, ok := m.clearedFields[name]
  6036. return ok
  6037. }
  6038. // ClearField clears the value of the field with the given name. It returns an
  6039. // error if the field is not defined in the schema.
  6040. func (m *ChatRecordsMutation) ClearField(name string) error {
  6041. switch name {
  6042. case chatrecords.FieldDeletedAt:
  6043. m.ClearDeletedAt()
  6044. return nil
  6045. }
  6046. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6047. }
  6048. // ResetField resets all changes in the mutation for the field with the given name.
  6049. // It returns an error if the field is not defined in the schema.
  6050. func (m *ChatRecordsMutation) ResetField(name string) error {
  6051. switch name {
  6052. case chatrecords.FieldCreatedAt:
  6053. m.ResetCreatedAt()
  6054. return nil
  6055. case chatrecords.FieldUpdatedAt:
  6056. m.ResetUpdatedAt()
  6057. return nil
  6058. case chatrecords.FieldDeletedAt:
  6059. m.ResetDeletedAt()
  6060. return nil
  6061. case chatrecords.FieldContent:
  6062. m.ResetContent()
  6063. return nil
  6064. case chatrecords.FieldContentType:
  6065. m.ResetContentType()
  6066. return nil
  6067. case chatrecords.FieldSessionID:
  6068. m.ResetSessionID()
  6069. return nil
  6070. case chatrecords.FieldUserID:
  6071. m.ResetUserID()
  6072. return nil
  6073. case chatrecords.FieldBotID:
  6074. m.ResetBotID()
  6075. return nil
  6076. case chatrecords.FieldBotType:
  6077. m.ResetBotType()
  6078. return nil
  6079. }
  6080. return fmt.Errorf("unknown ChatRecords field %s", name)
  6081. }
  6082. // AddedEdges returns all edge names that were set/added in this mutation.
  6083. func (m *ChatRecordsMutation) AddedEdges() []string {
  6084. edges := make([]string, 0, 0)
  6085. return edges
  6086. }
  6087. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6088. // name in this mutation.
  6089. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6090. return nil
  6091. }
  6092. // RemovedEdges returns all edge names that were removed in this mutation.
  6093. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6094. edges := make([]string, 0, 0)
  6095. return edges
  6096. }
  6097. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6098. // the given name in this mutation.
  6099. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6100. return nil
  6101. }
  6102. // ClearedEdges returns all edge names that were cleared in this mutation.
  6103. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6104. edges := make([]string, 0, 0)
  6105. return edges
  6106. }
  6107. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6108. // was cleared in this mutation.
  6109. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6110. return false
  6111. }
  6112. // ClearEdge clears the value of the edge with the given name. It returns an error
  6113. // if that edge is not defined in the schema.
  6114. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6115. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6116. }
  6117. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6118. // It returns an error if the edge is not defined in the schema.
  6119. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6120. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6121. }
  6122. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6123. type ChatSessionMutation struct {
  6124. config
  6125. op Op
  6126. typ string
  6127. id *uint64
  6128. created_at *time.Time
  6129. updated_at *time.Time
  6130. deleted_at *time.Time
  6131. name *string
  6132. user_id *uint64
  6133. adduser_id *int64
  6134. bot_id *uint64
  6135. addbot_id *int64
  6136. bot_type *uint8
  6137. addbot_type *int8
  6138. clearedFields map[string]struct{}
  6139. done bool
  6140. oldValue func(context.Context) (*ChatSession, error)
  6141. predicates []predicate.ChatSession
  6142. }
  6143. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6144. // chatsessionOption allows management of the mutation configuration using functional options.
  6145. type chatsessionOption func(*ChatSessionMutation)
  6146. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6147. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6148. m := &ChatSessionMutation{
  6149. config: c,
  6150. op: op,
  6151. typ: TypeChatSession,
  6152. clearedFields: make(map[string]struct{}),
  6153. }
  6154. for _, opt := range opts {
  6155. opt(m)
  6156. }
  6157. return m
  6158. }
  6159. // withChatSessionID sets the ID field of the mutation.
  6160. func withChatSessionID(id uint64) chatsessionOption {
  6161. return func(m *ChatSessionMutation) {
  6162. var (
  6163. err error
  6164. once sync.Once
  6165. value *ChatSession
  6166. )
  6167. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6168. once.Do(func() {
  6169. if m.done {
  6170. err = errors.New("querying old values post mutation is not allowed")
  6171. } else {
  6172. value, err = m.Client().ChatSession.Get(ctx, id)
  6173. }
  6174. })
  6175. return value, err
  6176. }
  6177. m.id = &id
  6178. }
  6179. }
  6180. // withChatSession sets the old ChatSession of the mutation.
  6181. func withChatSession(node *ChatSession) chatsessionOption {
  6182. return func(m *ChatSessionMutation) {
  6183. m.oldValue = func(context.Context) (*ChatSession, error) {
  6184. return node, nil
  6185. }
  6186. m.id = &node.ID
  6187. }
  6188. }
  6189. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6190. // executed in a transaction (ent.Tx), a transactional client is returned.
  6191. func (m ChatSessionMutation) Client() *Client {
  6192. client := &Client{config: m.config}
  6193. client.init()
  6194. return client
  6195. }
  6196. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6197. // it returns an error otherwise.
  6198. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6199. if _, ok := m.driver.(*txDriver); !ok {
  6200. return nil, errors.New("ent: mutation is not running in a transaction")
  6201. }
  6202. tx := &Tx{config: m.config}
  6203. tx.init()
  6204. return tx, nil
  6205. }
  6206. // SetID sets the value of the id field. Note that this
  6207. // operation is only accepted on creation of ChatSession entities.
  6208. func (m *ChatSessionMutation) SetID(id uint64) {
  6209. m.id = &id
  6210. }
  6211. // ID returns the ID value in the mutation. Note that the ID is only available
  6212. // if it was provided to the builder or after it was returned from the database.
  6213. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6214. if m.id == nil {
  6215. return
  6216. }
  6217. return *m.id, true
  6218. }
  6219. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6220. // That means, if the mutation is applied within a transaction with an isolation level such
  6221. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6222. // or updated by the mutation.
  6223. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6224. switch {
  6225. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6226. id, exists := m.ID()
  6227. if exists {
  6228. return []uint64{id}, nil
  6229. }
  6230. fallthrough
  6231. case m.op.Is(OpUpdate | OpDelete):
  6232. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  6233. default:
  6234. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6235. }
  6236. }
  6237. // SetCreatedAt sets the "created_at" field.
  6238. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  6239. m.created_at = &t
  6240. }
  6241. // CreatedAt returns the value of the "created_at" field in the mutation.
  6242. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  6243. v := m.created_at
  6244. if v == nil {
  6245. return
  6246. }
  6247. return *v, true
  6248. }
  6249. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  6250. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6252. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6253. if !m.op.Is(OpUpdateOne) {
  6254. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6255. }
  6256. if m.id == nil || m.oldValue == nil {
  6257. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6258. }
  6259. oldValue, err := m.oldValue(ctx)
  6260. if err != nil {
  6261. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6262. }
  6263. return oldValue.CreatedAt, nil
  6264. }
  6265. // ResetCreatedAt resets all changes to the "created_at" field.
  6266. func (m *ChatSessionMutation) ResetCreatedAt() {
  6267. m.created_at = nil
  6268. }
  6269. // SetUpdatedAt sets the "updated_at" field.
  6270. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  6271. m.updated_at = &t
  6272. }
  6273. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6274. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  6275. v := m.updated_at
  6276. if v == nil {
  6277. return
  6278. }
  6279. return *v, true
  6280. }
  6281. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  6282. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6284. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6285. if !m.op.Is(OpUpdateOne) {
  6286. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6287. }
  6288. if m.id == nil || m.oldValue == nil {
  6289. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6290. }
  6291. oldValue, err := m.oldValue(ctx)
  6292. if err != nil {
  6293. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6294. }
  6295. return oldValue.UpdatedAt, nil
  6296. }
  6297. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6298. func (m *ChatSessionMutation) ResetUpdatedAt() {
  6299. m.updated_at = nil
  6300. }
  6301. // SetDeletedAt sets the "deleted_at" field.
  6302. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  6303. m.deleted_at = &t
  6304. }
  6305. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6306. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  6307. v := m.deleted_at
  6308. if v == nil {
  6309. return
  6310. }
  6311. return *v, true
  6312. }
  6313. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  6314. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6316. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6317. if !m.op.Is(OpUpdateOne) {
  6318. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6319. }
  6320. if m.id == nil || m.oldValue == nil {
  6321. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6322. }
  6323. oldValue, err := m.oldValue(ctx)
  6324. if err != nil {
  6325. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6326. }
  6327. return oldValue.DeletedAt, nil
  6328. }
  6329. // ClearDeletedAt clears the value of the "deleted_at" field.
  6330. func (m *ChatSessionMutation) ClearDeletedAt() {
  6331. m.deleted_at = nil
  6332. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  6333. }
  6334. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6335. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  6336. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  6337. return ok
  6338. }
  6339. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6340. func (m *ChatSessionMutation) ResetDeletedAt() {
  6341. m.deleted_at = nil
  6342. delete(m.clearedFields, chatsession.FieldDeletedAt)
  6343. }
  6344. // SetName sets the "name" field.
  6345. func (m *ChatSessionMutation) SetName(s string) {
  6346. m.name = &s
  6347. }
  6348. // Name returns the value of the "name" field in the mutation.
  6349. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  6350. v := m.name
  6351. if v == nil {
  6352. return
  6353. }
  6354. return *v, true
  6355. }
  6356. // OldName returns the old "name" field's value of the ChatSession entity.
  6357. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6359. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  6360. if !m.op.Is(OpUpdateOne) {
  6361. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6362. }
  6363. if m.id == nil || m.oldValue == nil {
  6364. return v, errors.New("OldName requires an ID field in the mutation")
  6365. }
  6366. oldValue, err := m.oldValue(ctx)
  6367. if err != nil {
  6368. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6369. }
  6370. return oldValue.Name, nil
  6371. }
  6372. // ResetName resets all changes to the "name" field.
  6373. func (m *ChatSessionMutation) ResetName() {
  6374. m.name = nil
  6375. }
  6376. // SetUserID sets the "user_id" field.
  6377. func (m *ChatSessionMutation) SetUserID(u uint64) {
  6378. m.user_id = &u
  6379. m.adduser_id = nil
  6380. }
  6381. // UserID returns the value of the "user_id" field in the mutation.
  6382. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  6383. v := m.user_id
  6384. if v == nil {
  6385. return
  6386. }
  6387. return *v, true
  6388. }
  6389. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  6390. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6392. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6393. if !m.op.Is(OpUpdateOne) {
  6394. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6395. }
  6396. if m.id == nil || m.oldValue == nil {
  6397. return v, errors.New("OldUserID requires an ID field in the mutation")
  6398. }
  6399. oldValue, err := m.oldValue(ctx)
  6400. if err != nil {
  6401. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6402. }
  6403. return oldValue.UserID, nil
  6404. }
  6405. // AddUserID adds u to the "user_id" field.
  6406. func (m *ChatSessionMutation) AddUserID(u int64) {
  6407. if m.adduser_id != nil {
  6408. *m.adduser_id += u
  6409. } else {
  6410. m.adduser_id = &u
  6411. }
  6412. }
  6413. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6414. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  6415. v := m.adduser_id
  6416. if v == nil {
  6417. return
  6418. }
  6419. return *v, true
  6420. }
  6421. // ResetUserID resets all changes to the "user_id" field.
  6422. func (m *ChatSessionMutation) ResetUserID() {
  6423. m.user_id = nil
  6424. m.adduser_id = nil
  6425. }
  6426. // SetBotID sets the "bot_id" field.
  6427. func (m *ChatSessionMutation) SetBotID(u uint64) {
  6428. m.bot_id = &u
  6429. m.addbot_id = nil
  6430. }
  6431. // BotID returns the value of the "bot_id" field in the mutation.
  6432. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  6433. v := m.bot_id
  6434. if v == nil {
  6435. return
  6436. }
  6437. return *v, true
  6438. }
  6439. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  6440. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6442. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6443. if !m.op.Is(OpUpdateOne) {
  6444. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6445. }
  6446. if m.id == nil || m.oldValue == nil {
  6447. return v, errors.New("OldBotID requires an ID field in the mutation")
  6448. }
  6449. oldValue, err := m.oldValue(ctx)
  6450. if err != nil {
  6451. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6452. }
  6453. return oldValue.BotID, nil
  6454. }
  6455. // AddBotID adds u to the "bot_id" field.
  6456. func (m *ChatSessionMutation) AddBotID(u int64) {
  6457. if m.addbot_id != nil {
  6458. *m.addbot_id += u
  6459. } else {
  6460. m.addbot_id = &u
  6461. }
  6462. }
  6463. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6464. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  6465. v := m.addbot_id
  6466. if v == nil {
  6467. return
  6468. }
  6469. return *v, true
  6470. }
  6471. // ResetBotID resets all changes to the "bot_id" field.
  6472. func (m *ChatSessionMutation) ResetBotID() {
  6473. m.bot_id = nil
  6474. m.addbot_id = nil
  6475. }
  6476. // SetBotType sets the "bot_type" field.
  6477. func (m *ChatSessionMutation) SetBotType(u uint8) {
  6478. m.bot_type = &u
  6479. m.addbot_type = nil
  6480. }
  6481. // BotType returns the value of the "bot_type" field in the mutation.
  6482. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  6483. v := m.bot_type
  6484. if v == nil {
  6485. return
  6486. }
  6487. return *v, true
  6488. }
  6489. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  6490. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6492. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6493. if !m.op.Is(OpUpdateOne) {
  6494. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6495. }
  6496. if m.id == nil || m.oldValue == nil {
  6497. return v, errors.New("OldBotType requires an ID field in the mutation")
  6498. }
  6499. oldValue, err := m.oldValue(ctx)
  6500. if err != nil {
  6501. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6502. }
  6503. return oldValue.BotType, nil
  6504. }
  6505. // AddBotType adds u to the "bot_type" field.
  6506. func (m *ChatSessionMutation) AddBotType(u int8) {
  6507. if m.addbot_type != nil {
  6508. *m.addbot_type += u
  6509. } else {
  6510. m.addbot_type = &u
  6511. }
  6512. }
  6513. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6514. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  6515. v := m.addbot_type
  6516. if v == nil {
  6517. return
  6518. }
  6519. return *v, true
  6520. }
  6521. // ResetBotType resets all changes to the "bot_type" field.
  6522. func (m *ChatSessionMutation) ResetBotType() {
  6523. m.bot_type = nil
  6524. m.addbot_type = nil
  6525. }
  6526. // Where appends a list predicates to the ChatSessionMutation builder.
  6527. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  6528. m.predicates = append(m.predicates, ps...)
  6529. }
  6530. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  6531. // users can use type-assertion to append predicates that do not depend on any generated package.
  6532. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  6533. p := make([]predicate.ChatSession, len(ps))
  6534. for i := range ps {
  6535. p[i] = ps[i]
  6536. }
  6537. m.Where(p...)
  6538. }
  6539. // Op returns the operation name.
  6540. func (m *ChatSessionMutation) Op() Op {
  6541. return m.op
  6542. }
  6543. // SetOp allows setting the mutation operation.
  6544. func (m *ChatSessionMutation) SetOp(op Op) {
  6545. m.op = op
  6546. }
  6547. // Type returns the node type of this mutation (ChatSession).
  6548. func (m *ChatSessionMutation) Type() string {
  6549. return m.typ
  6550. }
  6551. // Fields returns all fields that were changed during this mutation. Note that in
  6552. // order to get all numeric fields that were incremented/decremented, call
  6553. // AddedFields().
  6554. func (m *ChatSessionMutation) Fields() []string {
  6555. fields := make([]string, 0, 7)
  6556. if m.created_at != nil {
  6557. fields = append(fields, chatsession.FieldCreatedAt)
  6558. }
  6559. if m.updated_at != nil {
  6560. fields = append(fields, chatsession.FieldUpdatedAt)
  6561. }
  6562. if m.deleted_at != nil {
  6563. fields = append(fields, chatsession.FieldDeletedAt)
  6564. }
  6565. if m.name != nil {
  6566. fields = append(fields, chatsession.FieldName)
  6567. }
  6568. if m.user_id != nil {
  6569. fields = append(fields, chatsession.FieldUserID)
  6570. }
  6571. if m.bot_id != nil {
  6572. fields = append(fields, chatsession.FieldBotID)
  6573. }
  6574. if m.bot_type != nil {
  6575. fields = append(fields, chatsession.FieldBotType)
  6576. }
  6577. return fields
  6578. }
  6579. // Field returns the value of a field with the given name. The second boolean
  6580. // return value indicates that this field was not set, or was not defined in the
  6581. // schema.
  6582. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  6583. switch name {
  6584. case chatsession.FieldCreatedAt:
  6585. return m.CreatedAt()
  6586. case chatsession.FieldUpdatedAt:
  6587. return m.UpdatedAt()
  6588. case chatsession.FieldDeletedAt:
  6589. return m.DeletedAt()
  6590. case chatsession.FieldName:
  6591. return m.Name()
  6592. case chatsession.FieldUserID:
  6593. return m.UserID()
  6594. case chatsession.FieldBotID:
  6595. return m.BotID()
  6596. case chatsession.FieldBotType:
  6597. return m.BotType()
  6598. }
  6599. return nil, false
  6600. }
  6601. // OldField returns the old value of the field from the database. An error is
  6602. // returned if the mutation operation is not UpdateOne, or the query to the
  6603. // database failed.
  6604. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6605. switch name {
  6606. case chatsession.FieldCreatedAt:
  6607. return m.OldCreatedAt(ctx)
  6608. case chatsession.FieldUpdatedAt:
  6609. return m.OldUpdatedAt(ctx)
  6610. case chatsession.FieldDeletedAt:
  6611. return m.OldDeletedAt(ctx)
  6612. case chatsession.FieldName:
  6613. return m.OldName(ctx)
  6614. case chatsession.FieldUserID:
  6615. return m.OldUserID(ctx)
  6616. case chatsession.FieldBotID:
  6617. return m.OldBotID(ctx)
  6618. case chatsession.FieldBotType:
  6619. return m.OldBotType(ctx)
  6620. }
  6621. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  6622. }
  6623. // SetField sets the value of a field with the given name. It returns an error if
  6624. // the field is not defined in the schema, or if the type mismatched the field
  6625. // type.
  6626. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  6627. switch name {
  6628. case chatsession.FieldCreatedAt:
  6629. v, ok := value.(time.Time)
  6630. if !ok {
  6631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6632. }
  6633. m.SetCreatedAt(v)
  6634. return nil
  6635. case chatsession.FieldUpdatedAt:
  6636. v, ok := value.(time.Time)
  6637. if !ok {
  6638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6639. }
  6640. m.SetUpdatedAt(v)
  6641. return nil
  6642. case chatsession.FieldDeletedAt:
  6643. v, ok := value.(time.Time)
  6644. if !ok {
  6645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6646. }
  6647. m.SetDeletedAt(v)
  6648. return nil
  6649. case chatsession.FieldName:
  6650. v, ok := value.(string)
  6651. if !ok {
  6652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6653. }
  6654. m.SetName(v)
  6655. return nil
  6656. case chatsession.FieldUserID:
  6657. v, ok := value.(uint64)
  6658. if !ok {
  6659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6660. }
  6661. m.SetUserID(v)
  6662. return nil
  6663. case chatsession.FieldBotID:
  6664. v, ok := value.(uint64)
  6665. if !ok {
  6666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6667. }
  6668. m.SetBotID(v)
  6669. return nil
  6670. case chatsession.FieldBotType:
  6671. v, ok := value.(uint8)
  6672. if !ok {
  6673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6674. }
  6675. m.SetBotType(v)
  6676. return nil
  6677. }
  6678. return fmt.Errorf("unknown ChatSession field %s", name)
  6679. }
  6680. // AddedFields returns all numeric fields that were incremented/decremented during
  6681. // this mutation.
  6682. func (m *ChatSessionMutation) AddedFields() []string {
  6683. var fields []string
  6684. if m.adduser_id != nil {
  6685. fields = append(fields, chatsession.FieldUserID)
  6686. }
  6687. if m.addbot_id != nil {
  6688. fields = append(fields, chatsession.FieldBotID)
  6689. }
  6690. if m.addbot_type != nil {
  6691. fields = append(fields, chatsession.FieldBotType)
  6692. }
  6693. return fields
  6694. }
  6695. // AddedField returns the numeric value that was incremented/decremented on a field
  6696. // with the given name. The second boolean return value indicates that this field
  6697. // was not set, or was not defined in the schema.
  6698. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  6699. switch name {
  6700. case chatsession.FieldUserID:
  6701. return m.AddedUserID()
  6702. case chatsession.FieldBotID:
  6703. return m.AddedBotID()
  6704. case chatsession.FieldBotType:
  6705. return m.AddedBotType()
  6706. }
  6707. return nil, false
  6708. }
  6709. // AddField adds the value to the field with the given name. It returns an error if
  6710. // the field is not defined in the schema, or if the type mismatched the field
  6711. // type.
  6712. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  6713. switch name {
  6714. case chatsession.FieldUserID:
  6715. v, ok := value.(int64)
  6716. if !ok {
  6717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6718. }
  6719. m.AddUserID(v)
  6720. return nil
  6721. case chatsession.FieldBotID:
  6722. v, ok := value.(int64)
  6723. if !ok {
  6724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6725. }
  6726. m.AddBotID(v)
  6727. return nil
  6728. case chatsession.FieldBotType:
  6729. v, ok := value.(int8)
  6730. if !ok {
  6731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6732. }
  6733. m.AddBotType(v)
  6734. return nil
  6735. }
  6736. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  6737. }
  6738. // ClearedFields returns all nullable fields that were cleared during this
  6739. // mutation.
  6740. func (m *ChatSessionMutation) ClearedFields() []string {
  6741. var fields []string
  6742. if m.FieldCleared(chatsession.FieldDeletedAt) {
  6743. fields = append(fields, chatsession.FieldDeletedAt)
  6744. }
  6745. return fields
  6746. }
  6747. // FieldCleared returns a boolean indicating if a field with the given name was
  6748. // cleared in this mutation.
  6749. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  6750. _, ok := m.clearedFields[name]
  6751. return ok
  6752. }
  6753. // ClearField clears the value of the field with the given name. It returns an
  6754. // error if the field is not defined in the schema.
  6755. func (m *ChatSessionMutation) ClearField(name string) error {
  6756. switch name {
  6757. case chatsession.FieldDeletedAt:
  6758. m.ClearDeletedAt()
  6759. return nil
  6760. }
  6761. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  6762. }
  6763. // ResetField resets all changes in the mutation for the field with the given name.
  6764. // It returns an error if the field is not defined in the schema.
  6765. func (m *ChatSessionMutation) ResetField(name string) error {
  6766. switch name {
  6767. case chatsession.FieldCreatedAt:
  6768. m.ResetCreatedAt()
  6769. return nil
  6770. case chatsession.FieldUpdatedAt:
  6771. m.ResetUpdatedAt()
  6772. return nil
  6773. case chatsession.FieldDeletedAt:
  6774. m.ResetDeletedAt()
  6775. return nil
  6776. case chatsession.FieldName:
  6777. m.ResetName()
  6778. return nil
  6779. case chatsession.FieldUserID:
  6780. m.ResetUserID()
  6781. return nil
  6782. case chatsession.FieldBotID:
  6783. m.ResetBotID()
  6784. return nil
  6785. case chatsession.FieldBotType:
  6786. m.ResetBotType()
  6787. return nil
  6788. }
  6789. return fmt.Errorf("unknown ChatSession field %s", name)
  6790. }
  6791. // AddedEdges returns all edge names that were set/added in this mutation.
  6792. func (m *ChatSessionMutation) AddedEdges() []string {
  6793. edges := make([]string, 0, 0)
  6794. return edges
  6795. }
  6796. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6797. // name in this mutation.
  6798. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  6799. return nil
  6800. }
  6801. // RemovedEdges returns all edge names that were removed in this mutation.
  6802. func (m *ChatSessionMutation) RemovedEdges() []string {
  6803. edges := make([]string, 0, 0)
  6804. return edges
  6805. }
  6806. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6807. // the given name in this mutation.
  6808. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  6809. return nil
  6810. }
  6811. // ClearedEdges returns all edge names that were cleared in this mutation.
  6812. func (m *ChatSessionMutation) ClearedEdges() []string {
  6813. edges := make([]string, 0, 0)
  6814. return edges
  6815. }
  6816. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6817. // was cleared in this mutation.
  6818. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  6819. return false
  6820. }
  6821. // ClearEdge clears the value of the edge with the given name. It returns an error
  6822. // if that edge is not defined in the schema.
  6823. func (m *ChatSessionMutation) ClearEdge(name string) error {
  6824. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  6825. }
  6826. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6827. // It returns an error if the edge is not defined in the schema.
  6828. func (m *ChatSessionMutation) ResetEdge(name string) error {
  6829. return fmt.Errorf("unknown ChatSession edge %s", name)
  6830. }
  6831. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  6832. type ContactMutation struct {
  6833. config
  6834. op Op
  6835. typ string
  6836. id *uint64
  6837. created_at *time.Time
  6838. updated_at *time.Time
  6839. status *uint8
  6840. addstatus *int8
  6841. deleted_at *time.Time
  6842. wx_wxid *string
  6843. _type *int
  6844. add_type *int
  6845. wxid *string
  6846. account *string
  6847. nickname *string
  6848. markname *string
  6849. headimg *string
  6850. sex *int
  6851. addsex *int
  6852. starrole *string
  6853. dontseeit *int
  6854. adddontseeit *int
  6855. dontseeme *int
  6856. adddontseeme *int
  6857. lag *string
  6858. gid *string
  6859. gname *string
  6860. v3 *string
  6861. organization_id *uint64
  6862. addorganization_id *int64
  6863. clearedFields map[string]struct{}
  6864. contact_relationships map[uint64]struct{}
  6865. removedcontact_relationships map[uint64]struct{}
  6866. clearedcontact_relationships bool
  6867. contact_messages map[uint64]struct{}
  6868. removedcontact_messages map[uint64]struct{}
  6869. clearedcontact_messages bool
  6870. done bool
  6871. oldValue func(context.Context) (*Contact, error)
  6872. predicates []predicate.Contact
  6873. }
  6874. var _ ent.Mutation = (*ContactMutation)(nil)
  6875. // contactOption allows management of the mutation configuration using functional options.
  6876. type contactOption func(*ContactMutation)
  6877. // newContactMutation creates new mutation for the Contact entity.
  6878. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  6879. m := &ContactMutation{
  6880. config: c,
  6881. op: op,
  6882. typ: TypeContact,
  6883. clearedFields: make(map[string]struct{}),
  6884. }
  6885. for _, opt := range opts {
  6886. opt(m)
  6887. }
  6888. return m
  6889. }
  6890. // withContactID sets the ID field of the mutation.
  6891. func withContactID(id uint64) contactOption {
  6892. return func(m *ContactMutation) {
  6893. var (
  6894. err error
  6895. once sync.Once
  6896. value *Contact
  6897. )
  6898. m.oldValue = func(ctx context.Context) (*Contact, error) {
  6899. once.Do(func() {
  6900. if m.done {
  6901. err = errors.New("querying old values post mutation is not allowed")
  6902. } else {
  6903. value, err = m.Client().Contact.Get(ctx, id)
  6904. }
  6905. })
  6906. return value, err
  6907. }
  6908. m.id = &id
  6909. }
  6910. }
  6911. // withContact sets the old Contact of the mutation.
  6912. func withContact(node *Contact) contactOption {
  6913. return func(m *ContactMutation) {
  6914. m.oldValue = func(context.Context) (*Contact, error) {
  6915. return node, nil
  6916. }
  6917. m.id = &node.ID
  6918. }
  6919. }
  6920. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6921. // executed in a transaction (ent.Tx), a transactional client is returned.
  6922. func (m ContactMutation) Client() *Client {
  6923. client := &Client{config: m.config}
  6924. client.init()
  6925. return client
  6926. }
  6927. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6928. // it returns an error otherwise.
  6929. func (m ContactMutation) Tx() (*Tx, error) {
  6930. if _, ok := m.driver.(*txDriver); !ok {
  6931. return nil, errors.New("ent: mutation is not running in a transaction")
  6932. }
  6933. tx := &Tx{config: m.config}
  6934. tx.init()
  6935. return tx, nil
  6936. }
  6937. // SetID sets the value of the id field. Note that this
  6938. // operation is only accepted on creation of Contact entities.
  6939. func (m *ContactMutation) SetID(id uint64) {
  6940. m.id = &id
  6941. }
  6942. // ID returns the ID value in the mutation. Note that the ID is only available
  6943. // if it was provided to the builder or after it was returned from the database.
  6944. func (m *ContactMutation) ID() (id uint64, exists bool) {
  6945. if m.id == nil {
  6946. return
  6947. }
  6948. return *m.id, true
  6949. }
  6950. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6951. // That means, if the mutation is applied within a transaction with an isolation level such
  6952. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6953. // or updated by the mutation.
  6954. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  6955. switch {
  6956. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6957. id, exists := m.ID()
  6958. if exists {
  6959. return []uint64{id}, nil
  6960. }
  6961. fallthrough
  6962. case m.op.Is(OpUpdate | OpDelete):
  6963. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  6964. default:
  6965. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6966. }
  6967. }
  6968. // SetCreatedAt sets the "created_at" field.
  6969. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  6970. m.created_at = &t
  6971. }
  6972. // CreatedAt returns the value of the "created_at" field in the mutation.
  6973. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  6974. v := m.created_at
  6975. if v == nil {
  6976. return
  6977. }
  6978. return *v, true
  6979. }
  6980. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  6981. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6983. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6984. if !m.op.Is(OpUpdateOne) {
  6985. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6986. }
  6987. if m.id == nil || m.oldValue == nil {
  6988. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6989. }
  6990. oldValue, err := m.oldValue(ctx)
  6991. if err != nil {
  6992. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6993. }
  6994. return oldValue.CreatedAt, nil
  6995. }
  6996. // ResetCreatedAt resets all changes to the "created_at" field.
  6997. func (m *ContactMutation) ResetCreatedAt() {
  6998. m.created_at = nil
  6999. }
  7000. // SetUpdatedAt sets the "updated_at" field.
  7001. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7002. m.updated_at = &t
  7003. }
  7004. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7005. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7006. v := m.updated_at
  7007. if v == nil {
  7008. return
  7009. }
  7010. return *v, true
  7011. }
  7012. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7013. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7015. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7016. if !m.op.Is(OpUpdateOne) {
  7017. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7018. }
  7019. if m.id == nil || m.oldValue == nil {
  7020. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7021. }
  7022. oldValue, err := m.oldValue(ctx)
  7023. if err != nil {
  7024. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7025. }
  7026. return oldValue.UpdatedAt, nil
  7027. }
  7028. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7029. func (m *ContactMutation) ResetUpdatedAt() {
  7030. m.updated_at = nil
  7031. }
  7032. // SetStatus sets the "status" field.
  7033. func (m *ContactMutation) SetStatus(u uint8) {
  7034. m.status = &u
  7035. m.addstatus = nil
  7036. }
  7037. // Status returns the value of the "status" field in the mutation.
  7038. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7039. v := m.status
  7040. if v == nil {
  7041. return
  7042. }
  7043. return *v, true
  7044. }
  7045. // OldStatus returns the old "status" field's value of the Contact entity.
  7046. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7048. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7049. if !m.op.Is(OpUpdateOne) {
  7050. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7051. }
  7052. if m.id == nil || m.oldValue == nil {
  7053. return v, errors.New("OldStatus requires an ID field in the mutation")
  7054. }
  7055. oldValue, err := m.oldValue(ctx)
  7056. if err != nil {
  7057. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7058. }
  7059. return oldValue.Status, nil
  7060. }
  7061. // AddStatus adds u to the "status" field.
  7062. func (m *ContactMutation) AddStatus(u int8) {
  7063. if m.addstatus != nil {
  7064. *m.addstatus += u
  7065. } else {
  7066. m.addstatus = &u
  7067. }
  7068. }
  7069. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7070. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7071. v := m.addstatus
  7072. if v == nil {
  7073. return
  7074. }
  7075. return *v, true
  7076. }
  7077. // ClearStatus clears the value of the "status" field.
  7078. func (m *ContactMutation) ClearStatus() {
  7079. m.status = nil
  7080. m.addstatus = nil
  7081. m.clearedFields[contact.FieldStatus] = struct{}{}
  7082. }
  7083. // StatusCleared returns if the "status" field was cleared in this mutation.
  7084. func (m *ContactMutation) StatusCleared() bool {
  7085. _, ok := m.clearedFields[contact.FieldStatus]
  7086. return ok
  7087. }
  7088. // ResetStatus resets all changes to the "status" field.
  7089. func (m *ContactMutation) ResetStatus() {
  7090. m.status = nil
  7091. m.addstatus = nil
  7092. delete(m.clearedFields, contact.FieldStatus)
  7093. }
  7094. // SetDeletedAt sets the "deleted_at" field.
  7095. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7096. m.deleted_at = &t
  7097. }
  7098. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7099. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7100. v := m.deleted_at
  7101. if v == nil {
  7102. return
  7103. }
  7104. return *v, true
  7105. }
  7106. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7107. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7109. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7110. if !m.op.Is(OpUpdateOne) {
  7111. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7112. }
  7113. if m.id == nil || m.oldValue == nil {
  7114. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7115. }
  7116. oldValue, err := m.oldValue(ctx)
  7117. if err != nil {
  7118. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7119. }
  7120. return oldValue.DeletedAt, nil
  7121. }
  7122. // ClearDeletedAt clears the value of the "deleted_at" field.
  7123. func (m *ContactMutation) ClearDeletedAt() {
  7124. m.deleted_at = nil
  7125. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7126. }
  7127. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7128. func (m *ContactMutation) DeletedAtCleared() bool {
  7129. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7130. return ok
  7131. }
  7132. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7133. func (m *ContactMutation) ResetDeletedAt() {
  7134. m.deleted_at = nil
  7135. delete(m.clearedFields, contact.FieldDeletedAt)
  7136. }
  7137. // SetWxWxid sets the "wx_wxid" field.
  7138. func (m *ContactMutation) SetWxWxid(s string) {
  7139. m.wx_wxid = &s
  7140. }
  7141. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7142. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7143. v := m.wx_wxid
  7144. if v == nil {
  7145. return
  7146. }
  7147. return *v, true
  7148. }
  7149. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7150. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7152. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7153. if !m.op.Is(OpUpdateOne) {
  7154. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7155. }
  7156. if m.id == nil || m.oldValue == nil {
  7157. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7158. }
  7159. oldValue, err := m.oldValue(ctx)
  7160. if err != nil {
  7161. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7162. }
  7163. return oldValue.WxWxid, nil
  7164. }
  7165. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7166. func (m *ContactMutation) ResetWxWxid() {
  7167. m.wx_wxid = nil
  7168. }
  7169. // SetType sets the "type" field.
  7170. func (m *ContactMutation) SetType(i int) {
  7171. m._type = &i
  7172. m.add_type = nil
  7173. }
  7174. // GetType returns the value of the "type" field in the mutation.
  7175. func (m *ContactMutation) GetType() (r int, exists bool) {
  7176. v := m._type
  7177. if v == nil {
  7178. return
  7179. }
  7180. return *v, true
  7181. }
  7182. // OldType returns the old "type" field's value of the Contact entity.
  7183. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7185. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7186. if !m.op.Is(OpUpdateOne) {
  7187. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7188. }
  7189. if m.id == nil || m.oldValue == nil {
  7190. return v, errors.New("OldType requires an ID field in the mutation")
  7191. }
  7192. oldValue, err := m.oldValue(ctx)
  7193. if err != nil {
  7194. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7195. }
  7196. return oldValue.Type, nil
  7197. }
  7198. // AddType adds i to the "type" field.
  7199. func (m *ContactMutation) AddType(i int) {
  7200. if m.add_type != nil {
  7201. *m.add_type += i
  7202. } else {
  7203. m.add_type = &i
  7204. }
  7205. }
  7206. // AddedType returns the value that was added to the "type" field in this mutation.
  7207. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7208. v := m.add_type
  7209. if v == nil {
  7210. return
  7211. }
  7212. return *v, true
  7213. }
  7214. // ClearType clears the value of the "type" field.
  7215. func (m *ContactMutation) ClearType() {
  7216. m._type = nil
  7217. m.add_type = nil
  7218. m.clearedFields[contact.FieldType] = struct{}{}
  7219. }
  7220. // TypeCleared returns if the "type" field was cleared in this mutation.
  7221. func (m *ContactMutation) TypeCleared() bool {
  7222. _, ok := m.clearedFields[contact.FieldType]
  7223. return ok
  7224. }
  7225. // ResetType resets all changes to the "type" field.
  7226. func (m *ContactMutation) ResetType() {
  7227. m._type = nil
  7228. m.add_type = nil
  7229. delete(m.clearedFields, contact.FieldType)
  7230. }
  7231. // SetWxid sets the "wxid" field.
  7232. func (m *ContactMutation) SetWxid(s string) {
  7233. m.wxid = &s
  7234. }
  7235. // Wxid returns the value of the "wxid" field in the mutation.
  7236. func (m *ContactMutation) Wxid() (r string, exists bool) {
  7237. v := m.wxid
  7238. if v == nil {
  7239. return
  7240. }
  7241. return *v, true
  7242. }
  7243. // OldWxid returns the old "wxid" field's value of the Contact entity.
  7244. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7246. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  7247. if !m.op.Is(OpUpdateOne) {
  7248. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  7249. }
  7250. if m.id == nil || m.oldValue == nil {
  7251. return v, errors.New("OldWxid requires an ID field in the mutation")
  7252. }
  7253. oldValue, err := m.oldValue(ctx)
  7254. if err != nil {
  7255. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  7256. }
  7257. return oldValue.Wxid, nil
  7258. }
  7259. // ResetWxid resets all changes to the "wxid" field.
  7260. func (m *ContactMutation) ResetWxid() {
  7261. m.wxid = nil
  7262. }
  7263. // SetAccount sets the "account" field.
  7264. func (m *ContactMutation) SetAccount(s string) {
  7265. m.account = &s
  7266. }
  7267. // Account returns the value of the "account" field in the mutation.
  7268. func (m *ContactMutation) Account() (r string, exists bool) {
  7269. v := m.account
  7270. if v == nil {
  7271. return
  7272. }
  7273. return *v, true
  7274. }
  7275. // OldAccount returns the old "account" field's value of the Contact entity.
  7276. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7278. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  7279. if !m.op.Is(OpUpdateOne) {
  7280. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  7281. }
  7282. if m.id == nil || m.oldValue == nil {
  7283. return v, errors.New("OldAccount requires an ID field in the mutation")
  7284. }
  7285. oldValue, err := m.oldValue(ctx)
  7286. if err != nil {
  7287. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  7288. }
  7289. return oldValue.Account, nil
  7290. }
  7291. // ResetAccount resets all changes to the "account" field.
  7292. func (m *ContactMutation) ResetAccount() {
  7293. m.account = nil
  7294. }
  7295. // SetNickname sets the "nickname" field.
  7296. func (m *ContactMutation) SetNickname(s string) {
  7297. m.nickname = &s
  7298. }
  7299. // Nickname returns the value of the "nickname" field in the mutation.
  7300. func (m *ContactMutation) Nickname() (r string, exists bool) {
  7301. v := m.nickname
  7302. if v == nil {
  7303. return
  7304. }
  7305. return *v, true
  7306. }
  7307. // OldNickname returns the old "nickname" field's value of the Contact entity.
  7308. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7310. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  7311. if !m.op.Is(OpUpdateOne) {
  7312. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  7313. }
  7314. if m.id == nil || m.oldValue == nil {
  7315. return v, errors.New("OldNickname requires an ID field in the mutation")
  7316. }
  7317. oldValue, err := m.oldValue(ctx)
  7318. if err != nil {
  7319. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  7320. }
  7321. return oldValue.Nickname, nil
  7322. }
  7323. // ResetNickname resets all changes to the "nickname" field.
  7324. func (m *ContactMutation) ResetNickname() {
  7325. m.nickname = nil
  7326. }
  7327. // SetMarkname sets the "markname" field.
  7328. func (m *ContactMutation) SetMarkname(s string) {
  7329. m.markname = &s
  7330. }
  7331. // Markname returns the value of the "markname" field in the mutation.
  7332. func (m *ContactMutation) Markname() (r string, exists bool) {
  7333. v := m.markname
  7334. if v == nil {
  7335. return
  7336. }
  7337. return *v, true
  7338. }
  7339. // OldMarkname returns the old "markname" field's value of the Contact entity.
  7340. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7342. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  7343. if !m.op.Is(OpUpdateOne) {
  7344. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  7345. }
  7346. if m.id == nil || m.oldValue == nil {
  7347. return v, errors.New("OldMarkname requires an ID field in the mutation")
  7348. }
  7349. oldValue, err := m.oldValue(ctx)
  7350. if err != nil {
  7351. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  7352. }
  7353. return oldValue.Markname, nil
  7354. }
  7355. // ResetMarkname resets all changes to the "markname" field.
  7356. func (m *ContactMutation) ResetMarkname() {
  7357. m.markname = nil
  7358. }
  7359. // SetHeadimg sets the "headimg" field.
  7360. func (m *ContactMutation) SetHeadimg(s string) {
  7361. m.headimg = &s
  7362. }
  7363. // Headimg returns the value of the "headimg" field in the mutation.
  7364. func (m *ContactMutation) Headimg() (r string, exists bool) {
  7365. v := m.headimg
  7366. if v == nil {
  7367. return
  7368. }
  7369. return *v, true
  7370. }
  7371. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  7372. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7374. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  7375. if !m.op.Is(OpUpdateOne) {
  7376. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  7377. }
  7378. if m.id == nil || m.oldValue == nil {
  7379. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  7380. }
  7381. oldValue, err := m.oldValue(ctx)
  7382. if err != nil {
  7383. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  7384. }
  7385. return oldValue.Headimg, nil
  7386. }
  7387. // ResetHeadimg resets all changes to the "headimg" field.
  7388. func (m *ContactMutation) ResetHeadimg() {
  7389. m.headimg = nil
  7390. }
  7391. // SetSex sets the "sex" field.
  7392. func (m *ContactMutation) SetSex(i int) {
  7393. m.sex = &i
  7394. m.addsex = nil
  7395. }
  7396. // Sex returns the value of the "sex" field in the mutation.
  7397. func (m *ContactMutation) Sex() (r int, exists bool) {
  7398. v := m.sex
  7399. if v == nil {
  7400. return
  7401. }
  7402. return *v, true
  7403. }
  7404. // OldSex returns the old "sex" field's value of the Contact entity.
  7405. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7407. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  7408. if !m.op.Is(OpUpdateOne) {
  7409. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  7410. }
  7411. if m.id == nil || m.oldValue == nil {
  7412. return v, errors.New("OldSex requires an ID field in the mutation")
  7413. }
  7414. oldValue, err := m.oldValue(ctx)
  7415. if err != nil {
  7416. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  7417. }
  7418. return oldValue.Sex, nil
  7419. }
  7420. // AddSex adds i to the "sex" field.
  7421. func (m *ContactMutation) AddSex(i int) {
  7422. if m.addsex != nil {
  7423. *m.addsex += i
  7424. } else {
  7425. m.addsex = &i
  7426. }
  7427. }
  7428. // AddedSex returns the value that was added to the "sex" field in this mutation.
  7429. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  7430. v := m.addsex
  7431. if v == nil {
  7432. return
  7433. }
  7434. return *v, true
  7435. }
  7436. // ResetSex resets all changes to the "sex" field.
  7437. func (m *ContactMutation) ResetSex() {
  7438. m.sex = nil
  7439. m.addsex = nil
  7440. }
  7441. // SetStarrole sets the "starrole" field.
  7442. func (m *ContactMutation) SetStarrole(s string) {
  7443. m.starrole = &s
  7444. }
  7445. // Starrole returns the value of the "starrole" field in the mutation.
  7446. func (m *ContactMutation) Starrole() (r string, exists bool) {
  7447. v := m.starrole
  7448. if v == nil {
  7449. return
  7450. }
  7451. return *v, true
  7452. }
  7453. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  7454. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7456. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  7457. if !m.op.Is(OpUpdateOne) {
  7458. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  7459. }
  7460. if m.id == nil || m.oldValue == nil {
  7461. return v, errors.New("OldStarrole requires an ID field in the mutation")
  7462. }
  7463. oldValue, err := m.oldValue(ctx)
  7464. if err != nil {
  7465. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  7466. }
  7467. return oldValue.Starrole, nil
  7468. }
  7469. // ResetStarrole resets all changes to the "starrole" field.
  7470. func (m *ContactMutation) ResetStarrole() {
  7471. m.starrole = nil
  7472. }
  7473. // SetDontseeit sets the "dontseeit" field.
  7474. func (m *ContactMutation) SetDontseeit(i int) {
  7475. m.dontseeit = &i
  7476. m.adddontseeit = nil
  7477. }
  7478. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  7479. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  7480. v := m.dontseeit
  7481. if v == nil {
  7482. return
  7483. }
  7484. return *v, true
  7485. }
  7486. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  7487. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7489. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  7490. if !m.op.Is(OpUpdateOne) {
  7491. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  7492. }
  7493. if m.id == nil || m.oldValue == nil {
  7494. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  7495. }
  7496. oldValue, err := m.oldValue(ctx)
  7497. if err != nil {
  7498. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  7499. }
  7500. return oldValue.Dontseeit, nil
  7501. }
  7502. // AddDontseeit adds i to the "dontseeit" field.
  7503. func (m *ContactMutation) AddDontseeit(i int) {
  7504. if m.adddontseeit != nil {
  7505. *m.adddontseeit += i
  7506. } else {
  7507. m.adddontseeit = &i
  7508. }
  7509. }
  7510. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  7511. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  7512. v := m.adddontseeit
  7513. if v == nil {
  7514. return
  7515. }
  7516. return *v, true
  7517. }
  7518. // ResetDontseeit resets all changes to the "dontseeit" field.
  7519. func (m *ContactMutation) ResetDontseeit() {
  7520. m.dontseeit = nil
  7521. m.adddontseeit = nil
  7522. }
  7523. // SetDontseeme sets the "dontseeme" field.
  7524. func (m *ContactMutation) SetDontseeme(i int) {
  7525. m.dontseeme = &i
  7526. m.adddontseeme = nil
  7527. }
  7528. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  7529. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  7530. v := m.dontseeme
  7531. if v == nil {
  7532. return
  7533. }
  7534. return *v, true
  7535. }
  7536. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  7537. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7539. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  7540. if !m.op.Is(OpUpdateOne) {
  7541. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  7542. }
  7543. if m.id == nil || m.oldValue == nil {
  7544. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  7545. }
  7546. oldValue, err := m.oldValue(ctx)
  7547. if err != nil {
  7548. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  7549. }
  7550. return oldValue.Dontseeme, nil
  7551. }
  7552. // AddDontseeme adds i to the "dontseeme" field.
  7553. func (m *ContactMutation) AddDontseeme(i int) {
  7554. if m.adddontseeme != nil {
  7555. *m.adddontseeme += i
  7556. } else {
  7557. m.adddontseeme = &i
  7558. }
  7559. }
  7560. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  7561. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  7562. v := m.adddontseeme
  7563. if v == nil {
  7564. return
  7565. }
  7566. return *v, true
  7567. }
  7568. // ResetDontseeme resets all changes to the "dontseeme" field.
  7569. func (m *ContactMutation) ResetDontseeme() {
  7570. m.dontseeme = nil
  7571. m.adddontseeme = nil
  7572. }
  7573. // SetLag sets the "lag" field.
  7574. func (m *ContactMutation) SetLag(s string) {
  7575. m.lag = &s
  7576. }
  7577. // Lag returns the value of the "lag" field in the mutation.
  7578. func (m *ContactMutation) Lag() (r string, exists bool) {
  7579. v := m.lag
  7580. if v == nil {
  7581. return
  7582. }
  7583. return *v, true
  7584. }
  7585. // OldLag returns the old "lag" field's value of the Contact entity.
  7586. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7588. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  7589. if !m.op.Is(OpUpdateOne) {
  7590. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  7591. }
  7592. if m.id == nil || m.oldValue == nil {
  7593. return v, errors.New("OldLag requires an ID field in the mutation")
  7594. }
  7595. oldValue, err := m.oldValue(ctx)
  7596. if err != nil {
  7597. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  7598. }
  7599. return oldValue.Lag, nil
  7600. }
  7601. // ResetLag resets all changes to the "lag" field.
  7602. func (m *ContactMutation) ResetLag() {
  7603. m.lag = nil
  7604. }
  7605. // SetGid sets the "gid" field.
  7606. func (m *ContactMutation) SetGid(s string) {
  7607. m.gid = &s
  7608. }
  7609. // Gid returns the value of the "gid" field in the mutation.
  7610. func (m *ContactMutation) Gid() (r string, exists bool) {
  7611. v := m.gid
  7612. if v == nil {
  7613. return
  7614. }
  7615. return *v, true
  7616. }
  7617. // OldGid returns the old "gid" field's value of the Contact entity.
  7618. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7620. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  7621. if !m.op.Is(OpUpdateOne) {
  7622. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  7623. }
  7624. if m.id == nil || m.oldValue == nil {
  7625. return v, errors.New("OldGid requires an ID field in the mutation")
  7626. }
  7627. oldValue, err := m.oldValue(ctx)
  7628. if err != nil {
  7629. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  7630. }
  7631. return oldValue.Gid, nil
  7632. }
  7633. // ResetGid resets all changes to the "gid" field.
  7634. func (m *ContactMutation) ResetGid() {
  7635. m.gid = nil
  7636. }
  7637. // SetGname sets the "gname" field.
  7638. func (m *ContactMutation) SetGname(s string) {
  7639. m.gname = &s
  7640. }
  7641. // Gname returns the value of the "gname" field in the mutation.
  7642. func (m *ContactMutation) Gname() (r string, exists bool) {
  7643. v := m.gname
  7644. if v == nil {
  7645. return
  7646. }
  7647. return *v, true
  7648. }
  7649. // OldGname returns the old "gname" field's value of the Contact entity.
  7650. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7652. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  7653. if !m.op.Is(OpUpdateOne) {
  7654. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  7655. }
  7656. if m.id == nil || m.oldValue == nil {
  7657. return v, errors.New("OldGname requires an ID field in the mutation")
  7658. }
  7659. oldValue, err := m.oldValue(ctx)
  7660. if err != nil {
  7661. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  7662. }
  7663. return oldValue.Gname, nil
  7664. }
  7665. // ResetGname resets all changes to the "gname" field.
  7666. func (m *ContactMutation) ResetGname() {
  7667. m.gname = nil
  7668. }
  7669. // SetV3 sets the "v3" field.
  7670. func (m *ContactMutation) SetV3(s string) {
  7671. m.v3 = &s
  7672. }
  7673. // V3 returns the value of the "v3" field in the mutation.
  7674. func (m *ContactMutation) V3() (r string, exists bool) {
  7675. v := m.v3
  7676. if v == nil {
  7677. return
  7678. }
  7679. return *v, true
  7680. }
  7681. // OldV3 returns the old "v3" field's value of the Contact entity.
  7682. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7684. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  7685. if !m.op.Is(OpUpdateOne) {
  7686. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  7687. }
  7688. if m.id == nil || m.oldValue == nil {
  7689. return v, errors.New("OldV3 requires an ID field in the mutation")
  7690. }
  7691. oldValue, err := m.oldValue(ctx)
  7692. if err != nil {
  7693. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  7694. }
  7695. return oldValue.V3, nil
  7696. }
  7697. // ResetV3 resets all changes to the "v3" field.
  7698. func (m *ContactMutation) ResetV3() {
  7699. m.v3 = nil
  7700. }
  7701. // SetOrganizationID sets the "organization_id" field.
  7702. func (m *ContactMutation) SetOrganizationID(u uint64) {
  7703. m.organization_id = &u
  7704. m.addorganization_id = nil
  7705. }
  7706. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7707. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  7708. v := m.organization_id
  7709. if v == nil {
  7710. return
  7711. }
  7712. return *v, true
  7713. }
  7714. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  7715. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7717. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7718. if !m.op.Is(OpUpdateOne) {
  7719. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7720. }
  7721. if m.id == nil || m.oldValue == nil {
  7722. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7723. }
  7724. oldValue, err := m.oldValue(ctx)
  7725. if err != nil {
  7726. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7727. }
  7728. return oldValue.OrganizationID, nil
  7729. }
  7730. // AddOrganizationID adds u to the "organization_id" field.
  7731. func (m *ContactMutation) AddOrganizationID(u int64) {
  7732. if m.addorganization_id != nil {
  7733. *m.addorganization_id += u
  7734. } else {
  7735. m.addorganization_id = &u
  7736. }
  7737. }
  7738. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7739. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  7740. v := m.addorganization_id
  7741. if v == nil {
  7742. return
  7743. }
  7744. return *v, true
  7745. }
  7746. // ClearOrganizationID clears the value of the "organization_id" field.
  7747. func (m *ContactMutation) ClearOrganizationID() {
  7748. m.organization_id = nil
  7749. m.addorganization_id = nil
  7750. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  7751. }
  7752. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7753. func (m *ContactMutation) OrganizationIDCleared() bool {
  7754. _, ok := m.clearedFields[contact.FieldOrganizationID]
  7755. return ok
  7756. }
  7757. // ResetOrganizationID resets all changes to the "organization_id" field.
  7758. func (m *ContactMutation) ResetOrganizationID() {
  7759. m.organization_id = nil
  7760. m.addorganization_id = nil
  7761. delete(m.clearedFields, contact.FieldOrganizationID)
  7762. }
  7763. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  7764. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  7765. if m.contact_relationships == nil {
  7766. m.contact_relationships = make(map[uint64]struct{})
  7767. }
  7768. for i := range ids {
  7769. m.contact_relationships[ids[i]] = struct{}{}
  7770. }
  7771. }
  7772. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  7773. func (m *ContactMutation) ClearContactRelationships() {
  7774. m.clearedcontact_relationships = true
  7775. }
  7776. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  7777. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  7778. return m.clearedcontact_relationships
  7779. }
  7780. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  7781. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  7782. if m.removedcontact_relationships == nil {
  7783. m.removedcontact_relationships = make(map[uint64]struct{})
  7784. }
  7785. for i := range ids {
  7786. delete(m.contact_relationships, ids[i])
  7787. m.removedcontact_relationships[ids[i]] = struct{}{}
  7788. }
  7789. }
  7790. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  7791. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  7792. for id := range m.removedcontact_relationships {
  7793. ids = append(ids, id)
  7794. }
  7795. return
  7796. }
  7797. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  7798. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  7799. for id := range m.contact_relationships {
  7800. ids = append(ids, id)
  7801. }
  7802. return
  7803. }
  7804. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  7805. func (m *ContactMutation) ResetContactRelationships() {
  7806. m.contact_relationships = nil
  7807. m.clearedcontact_relationships = false
  7808. m.removedcontact_relationships = nil
  7809. }
  7810. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  7811. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  7812. if m.contact_messages == nil {
  7813. m.contact_messages = make(map[uint64]struct{})
  7814. }
  7815. for i := range ids {
  7816. m.contact_messages[ids[i]] = struct{}{}
  7817. }
  7818. }
  7819. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  7820. func (m *ContactMutation) ClearContactMessages() {
  7821. m.clearedcontact_messages = true
  7822. }
  7823. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  7824. func (m *ContactMutation) ContactMessagesCleared() bool {
  7825. return m.clearedcontact_messages
  7826. }
  7827. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  7828. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  7829. if m.removedcontact_messages == nil {
  7830. m.removedcontact_messages = make(map[uint64]struct{})
  7831. }
  7832. for i := range ids {
  7833. delete(m.contact_messages, ids[i])
  7834. m.removedcontact_messages[ids[i]] = struct{}{}
  7835. }
  7836. }
  7837. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  7838. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  7839. for id := range m.removedcontact_messages {
  7840. ids = append(ids, id)
  7841. }
  7842. return
  7843. }
  7844. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  7845. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  7846. for id := range m.contact_messages {
  7847. ids = append(ids, id)
  7848. }
  7849. return
  7850. }
  7851. // ResetContactMessages resets all changes to the "contact_messages" edge.
  7852. func (m *ContactMutation) ResetContactMessages() {
  7853. m.contact_messages = nil
  7854. m.clearedcontact_messages = false
  7855. m.removedcontact_messages = nil
  7856. }
  7857. // Where appends a list predicates to the ContactMutation builder.
  7858. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  7859. m.predicates = append(m.predicates, ps...)
  7860. }
  7861. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  7862. // users can use type-assertion to append predicates that do not depend on any generated package.
  7863. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  7864. p := make([]predicate.Contact, len(ps))
  7865. for i := range ps {
  7866. p[i] = ps[i]
  7867. }
  7868. m.Where(p...)
  7869. }
  7870. // Op returns the operation name.
  7871. func (m *ContactMutation) Op() Op {
  7872. return m.op
  7873. }
  7874. // SetOp allows setting the mutation operation.
  7875. func (m *ContactMutation) SetOp(op Op) {
  7876. m.op = op
  7877. }
  7878. // Type returns the node type of this mutation (Contact).
  7879. func (m *ContactMutation) Type() string {
  7880. return m.typ
  7881. }
  7882. // Fields returns all fields that were changed during this mutation. Note that in
  7883. // order to get all numeric fields that were incremented/decremented, call
  7884. // AddedFields().
  7885. func (m *ContactMutation) Fields() []string {
  7886. fields := make([]string, 0, 20)
  7887. if m.created_at != nil {
  7888. fields = append(fields, contact.FieldCreatedAt)
  7889. }
  7890. if m.updated_at != nil {
  7891. fields = append(fields, contact.FieldUpdatedAt)
  7892. }
  7893. if m.status != nil {
  7894. fields = append(fields, contact.FieldStatus)
  7895. }
  7896. if m.deleted_at != nil {
  7897. fields = append(fields, contact.FieldDeletedAt)
  7898. }
  7899. if m.wx_wxid != nil {
  7900. fields = append(fields, contact.FieldWxWxid)
  7901. }
  7902. if m._type != nil {
  7903. fields = append(fields, contact.FieldType)
  7904. }
  7905. if m.wxid != nil {
  7906. fields = append(fields, contact.FieldWxid)
  7907. }
  7908. if m.account != nil {
  7909. fields = append(fields, contact.FieldAccount)
  7910. }
  7911. if m.nickname != nil {
  7912. fields = append(fields, contact.FieldNickname)
  7913. }
  7914. if m.markname != nil {
  7915. fields = append(fields, contact.FieldMarkname)
  7916. }
  7917. if m.headimg != nil {
  7918. fields = append(fields, contact.FieldHeadimg)
  7919. }
  7920. if m.sex != nil {
  7921. fields = append(fields, contact.FieldSex)
  7922. }
  7923. if m.starrole != nil {
  7924. fields = append(fields, contact.FieldStarrole)
  7925. }
  7926. if m.dontseeit != nil {
  7927. fields = append(fields, contact.FieldDontseeit)
  7928. }
  7929. if m.dontseeme != nil {
  7930. fields = append(fields, contact.FieldDontseeme)
  7931. }
  7932. if m.lag != nil {
  7933. fields = append(fields, contact.FieldLag)
  7934. }
  7935. if m.gid != nil {
  7936. fields = append(fields, contact.FieldGid)
  7937. }
  7938. if m.gname != nil {
  7939. fields = append(fields, contact.FieldGname)
  7940. }
  7941. if m.v3 != nil {
  7942. fields = append(fields, contact.FieldV3)
  7943. }
  7944. if m.organization_id != nil {
  7945. fields = append(fields, contact.FieldOrganizationID)
  7946. }
  7947. return fields
  7948. }
  7949. // Field returns the value of a field with the given name. The second boolean
  7950. // return value indicates that this field was not set, or was not defined in the
  7951. // schema.
  7952. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  7953. switch name {
  7954. case contact.FieldCreatedAt:
  7955. return m.CreatedAt()
  7956. case contact.FieldUpdatedAt:
  7957. return m.UpdatedAt()
  7958. case contact.FieldStatus:
  7959. return m.Status()
  7960. case contact.FieldDeletedAt:
  7961. return m.DeletedAt()
  7962. case contact.FieldWxWxid:
  7963. return m.WxWxid()
  7964. case contact.FieldType:
  7965. return m.GetType()
  7966. case contact.FieldWxid:
  7967. return m.Wxid()
  7968. case contact.FieldAccount:
  7969. return m.Account()
  7970. case contact.FieldNickname:
  7971. return m.Nickname()
  7972. case contact.FieldMarkname:
  7973. return m.Markname()
  7974. case contact.FieldHeadimg:
  7975. return m.Headimg()
  7976. case contact.FieldSex:
  7977. return m.Sex()
  7978. case contact.FieldStarrole:
  7979. return m.Starrole()
  7980. case contact.FieldDontseeit:
  7981. return m.Dontseeit()
  7982. case contact.FieldDontseeme:
  7983. return m.Dontseeme()
  7984. case contact.FieldLag:
  7985. return m.Lag()
  7986. case contact.FieldGid:
  7987. return m.Gid()
  7988. case contact.FieldGname:
  7989. return m.Gname()
  7990. case contact.FieldV3:
  7991. return m.V3()
  7992. case contact.FieldOrganizationID:
  7993. return m.OrganizationID()
  7994. }
  7995. return nil, false
  7996. }
  7997. // OldField returns the old value of the field from the database. An error is
  7998. // returned if the mutation operation is not UpdateOne, or the query to the
  7999. // database failed.
  8000. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8001. switch name {
  8002. case contact.FieldCreatedAt:
  8003. return m.OldCreatedAt(ctx)
  8004. case contact.FieldUpdatedAt:
  8005. return m.OldUpdatedAt(ctx)
  8006. case contact.FieldStatus:
  8007. return m.OldStatus(ctx)
  8008. case contact.FieldDeletedAt:
  8009. return m.OldDeletedAt(ctx)
  8010. case contact.FieldWxWxid:
  8011. return m.OldWxWxid(ctx)
  8012. case contact.FieldType:
  8013. return m.OldType(ctx)
  8014. case contact.FieldWxid:
  8015. return m.OldWxid(ctx)
  8016. case contact.FieldAccount:
  8017. return m.OldAccount(ctx)
  8018. case contact.FieldNickname:
  8019. return m.OldNickname(ctx)
  8020. case contact.FieldMarkname:
  8021. return m.OldMarkname(ctx)
  8022. case contact.FieldHeadimg:
  8023. return m.OldHeadimg(ctx)
  8024. case contact.FieldSex:
  8025. return m.OldSex(ctx)
  8026. case contact.FieldStarrole:
  8027. return m.OldStarrole(ctx)
  8028. case contact.FieldDontseeit:
  8029. return m.OldDontseeit(ctx)
  8030. case contact.FieldDontseeme:
  8031. return m.OldDontseeme(ctx)
  8032. case contact.FieldLag:
  8033. return m.OldLag(ctx)
  8034. case contact.FieldGid:
  8035. return m.OldGid(ctx)
  8036. case contact.FieldGname:
  8037. return m.OldGname(ctx)
  8038. case contact.FieldV3:
  8039. return m.OldV3(ctx)
  8040. case contact.FieldOrganizationID:
  8041. return m.OldOrganizationID(ctx)
  8042. }
  8043. return nil, fmt.Errorf("unknown Contact field %s", name)
  8044. }
  8045. // SetField sets the value of a field with the given name. It returns an error if
  8046. // the field is not defined in the schema, or if the type mismatched the field
  8047. // type.
  8048. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8049. switch name {
  8050. case contact.FieldCreatedAt:
  8051. v, ok := value.(time.Time)
  8052. if !ok {
  8053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8054. }
  8055. m.SetCreatedAt(v)
  8056. return nil
  8057. case contact.FieldUpdatedAt:
  8058. v, ok := value.(time.Time)
  8059. if !ok {
  8060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8061. }
  8062. m.SetUpdatedAt(v)
  8063. return nil
  8064. case contact.FieldStatus:
  8065. v, ok := value.(uint8)
  8066. if !ok {
  8067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8068. }
  8069. m.SetStatus(v)
  8070. return nil
  8071. case contact.FieldDeletedAt:
  8072. v, ok := value.(time.Time)
  8073. if !ok {
  8074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8075. }
  8076. m.SetDeletedAt(v)
  8077. return nil
  8078. case contact.FieldWxWxid:
  8079. v, ok := value.(string)
  8080. if !ok {
  8081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8082. }
  8083. m.SetWxWxid(v)
  8084. return nil
  8085. case contact.FieldType:
  8086. v, ok := value.(int)
  8087. if !ok {
  8088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8089. }
  8090. m.SetType(v)
  8091. return nil
  8092. case contact.FieldWxid:
  8093. v, ok := value.(string)
  8094. if !ok {
  8095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8096. }
  8097. m.SetWxid(v)
  8098. return nil
  8099. case contact.FieldAccount:
  8100. v, ok := value.(string)
  8101. if !ok {
  8102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8103. }
  8104. m.SetAccount(v)
  8105. return nil
  8106. case contact.FieldNickname:
  8107. v, ok := value.(string)
  8108. if !ok {
  8109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8110. }
  8111. m.SetNickname(v)
  8112. return nil
  8113. case contact.FieldMarkname:
  8114. v, ok := value.(string)
  8115. if !ok {
  8116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8117. }
  8118. m.SetMarkname(v)
  8119. return nil
  8120. case contact.FieldHeadimg:
  8121. v, ok := value.(string)
  8122. if !ok {
  8123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8124. }
  8125. m.SetHeadimg(v)
  8126. return nil
  8127. case contact.FieldSex:
  8128. v, ok := value.(int)
  8129. if !ok {
  8130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8131. }
  8132. m.SetSex(v)
  8133. return nil
  8134. case contact.FieldStarrole:
  8135. v, ok := value.(string)
  8136. if !ok {
  8137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8138. }
  8139. m.SetStarrole(v)
  8140. return nil
  8141. case contact.FieldDontseeit:
  8142. v, ok := value.(int)
  8143. if !ok {
  8144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8145. }
  8146. m.SetDontseeit(v)
  8147. return nil
  8148. case contact.FieldDontseeme:
  8149. v, ok := value.(int)
  8150. if !ok {
  8151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8152. }
  8153. m.SetDontseeme(v)
  8154. return nil
  8155. case contact.FieldLag:
  8156. v, ok := value.(string)
  8157. if !ok {
  8158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8159. }
  8160. m.SetLag(v)
  8161. return nil
  8162. case contact.FieldGid:
  8163. v, ok := value.(string)
  8164. if !ok {
  8165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8166. }
  8167. m.SetGid(v)
  8168. return nil
  8169. case contact.FieldGname:
  8170. v, ok := value.(string)
  8171. if !ok {
  8172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8173. }
  8174. m.SetGname(v)
  8175. return nil
  8176. case contact.FieldV3:
  8177. v, ok := value.(string)
  8178. if !ok {
  8179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8180. }
  8181. m.SetV3(v)
  8182. return nil
  8183. case contact.FieldOrganizationID:
  8184. v, ok := value.(uint64)
  8185. if !ok {
  8186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8187. }
  8188. m.SetOrganizationID(v)
  8189. return nil
  8190. }
  8191. return fmt.Errorf("unknown Contact field %s", name)
  8192. }
  8193. // AddedFields returns all numeric fields that were incremented/decremented during
  8194. // this mutation.
  8195. func (m *ContactMutation) AddedFields() []string {
  8196. var fields []string
  8197. if m.addstatus != nil {
  8198. fields = append(fields, contact.FieldStatus)
  8199. }
  8200. if m.add_type != nil {
  8201. fields = append(fields, contact.FieldType)
  8202. }
  8203. if m.addsex != nil {
  8204. fields = append(fields, contact.FieldSex)
  8205. }
  8206. if m.adddontseeit != nil {
  8207. fields = append(fields, contact.FieldDontseeit)
  8208. }
  8209. if m.adddontseeme != nil {
  8210. fields = append(fields, contact.FieldDontseeme)
  8211. }
  8212. if m.addorganization_id != nil {
  8213. fields = append(fields, contact.FieldOrganizationID)
  8214. }
  8215. return fields
  8216. }
  8217. // AddedField returns the numeric value that was incremented/decremented on a field
  8218. // with the given name. The second boolean return value indicates that this field
  8219. // was not set, or was not defined in the schema.
  8220. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8221. switch name {
  8222. case contact.FieldStatus:
  8223. return m.AddedStatus()
  8224. case contact.FieldType:
  8225. return m.AddedType()
  8226. case contact.FieldSex:
  8227. return m.AddedSex()
  8228. case contact.FieldDontseeit:
  8229. return m.AddedDontseeit()
  8230. case contact.FieldDontseeme:
  8231. return m.AddedDontseeme()
  8232. case contact.FieldOrganizationID:
  8233. return m.AddedOrganizationID()
  8234. }
  8235. return nil, false
  8236. }
  8237. // AddField adds the value to the field with the given name. It returns an error if
  8238. // the field is not defined in the schema, or if the type mismatched the field
  8239. // type.
  8240. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  8241. switch name {
  8242. case contact.FieldStatus:
  8243. v, ok := value.(int8)
  8244. if !ok {
  8245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8246. }
  8247. m.AddStatus(v)
  8248. return nil
  8249. case contact.FieldType:
  8250. v, ok := value.(int)
  8251. if !ok {
  8252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8253. }
  8254. m.AddType(v)
  8255. return nil
  8256. case contact.FieldSex:
  8257. v, ok := value.(int)
  8258. if !ok {
  8259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8260. }
  8261. m.AddSex(v)
  8262. return nil
  8263. case contact.FieldDontseeit:
  8264. v, ok := value.(int)
  8265. if !ok {
  8266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8267. }
  8268. m.AddDontseeit(v)
  8269. return nil
  8270. case contact.FieldDontseeme:
  8271. v, ok := value.(int)
  8272. if !ok {
  8273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8274. }
  8275. m.AddDontseeme(v)
  8276. return nil
  8277. case contact.FieldOrganizationID:
  8278. v, ok := value.(int64)
  8279. if !ok {
  8280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8281. }
  8282. m.AddOrganizationID(v)
  8283. return nil
  8284. }
  8285. return fmt.Errorf("unknown Contact numeric field %s", name)
  8286. }
  8287. // ClearedFields returns all nullable fields that were cleared during this
  8288. // mutation.
  8289. func (m *ContactMutation) ClearedFields() []string {
  8290. var fields []string
  8291. if m.FieldCleared(contact.FieldStatus) {
  8292. fields = append(fields, contact.FieldStatus)
  8293. }
  8294. if m.FieldCleared(contact.FieldDeletedAt) {
  8295. fields = append(fields, contact.FieldDeletedAt)
  8296. }
  8297. if m.FieldCleared(contact.FieldType) {
  8298. fields = append(fields, contact.FieldType)
  8299. }
  8300. if m.FieldCleared(contact.FieldOrganizationID) {
  8301. fields = append(fields, contact.FieldOrganizationID)
  8302. }
  8303. return fields
  8304. }
  8305. // FieldCleared returns a boolean indicating if a field with the given name was
  8306. // cleared in this mutation.
  8307. func (m *ContactMutation) FieldCleared(name string) bool {
  8308. _, ok := m.clearedFields[name]
  8309. return ok
  8310. }
  8311. // ClearField clears the value of the field with the given name. It returns an
  8312. // error if the field is not defined in the schema.
  8313. func (m *ContactMutation) ClearField(name string) error {
  8314. switch name {
  8315. case contact.FieldStatus:
  8316. m.ClearStatus()
  8317. return nil
  8318. case contact.FieldDeletedAt:
  8319. m.ClearDeletedAt()
  8320. return nil
  8321. case contact.FieldType:
  8322. m.ClearType()
  8323. return nil
  8324. case contact.FieldOrganizationID:
  8325. m.ClearOrganizationID()
  8326. return nil
  8327. }
  8328. return fmt.Errorf("unknown Contact nullable field %s", name)
  8329. }
  8330. // ResetField resets all changes in the mutation for the field with the given name.
  8331. // It returns an error if the field is not defined in the schema.
  8332. func (m *ContactMutation) ResetField(name string) error {
  8333. switch name {
  8334. case contact.FieldCreatedAt:
  8335. m.ResetCreatedAt()
  8336. return nil
  8337. case contact.FieldUpdatedAt:
  8338. m.ResetUpdatedAt()
  8339. return nil
  8340. case contact.FieldStatus:
  8341. m.ResetStatus()
  8342. return nil
  8343. case contact.FieldDeletedAt:
  8344. m.ResetDeletedAt()
  8345. return nil
  8346. case contact.FieldWxWxid:
  8347. m.ResetWxWxid()
  8348. return nil
  8349. case contact.FieldType:
  8350. m.ResetType()
  8351. return nil
  8352. case contact.FieldWxid:
  8353. m.ResetWxid()
  8354. return nil
  8355. case contact.FieldAccount:
  8356. m.ResetAccount()
  8357. return nil
  8358. case contact.FieldNickname:
  8359. m.ResetNickname()
  8360. return nil
  8361. case contact.FieldMarkname:
  8362. m.ResetMarkname()
  8363. return nil
  8364. case contact.FieldHeadimg:
  8365. m.ResetHeadimg()
  8366. return nil
  8367. case contact.FieldSex:
  8368. m.ResetSex()
  8369. return nil
  8370. case contact.FieldStarrole:
  8371. m.ResetStarrole()
  8372. return nil
  8373. case contact.FieldDontseeit:
  8374. m.ResetDontseeit()
  8375. return nil
  8376. case contact.FieldDontseeme:
  8377. m.ResetDontseeme()
  8378. return nil
  8379. case contact.FieldLag:
  8380. m.ResetLag()
  8381. return nil
  8382. case contact.FieldGid:
  8383. m.ResetGid()
  8384. return nil
  8385. case contact.FieldGname:
  8386. m.ResetGname()
  8387. return nil
  8388. case contact.FieldV3:
  8389. m.ResetV3()
  8390. return nil
  8391. case contact.FieldOrganizationID:
  8392. m.ResetOrganizationID()
  8393. return nil
  8394. }
  8395. return fmt.Errorf("unknown Contact field %s", name)
  8396. }
  8397. // AddedEdges returns all edge names that were set/added in this mutation.
  8398. func (m *ContactMutation) AddedEdges() []string {
  8399. edges := make([]string, 0, 2)
  8400. if m.contact_relationships != nil {
  8401. edges = append(edges, contact.EdgeContactRelationships)
  8402. }
  8403. if m.contact_messages != nil {
  8404. edges = append(edges, contact.EdgeContactMessages)
  8405. }
  8406. return edges
  8407. }
  8408. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8409. // name in this mutation.
  8410. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  8411. switch name {
  8412. case contact.EdgeContactRelationships:
  8413. ids := make([]ent.Value, 0, len(m.contact_relationships))
  8414. for id := range m.contact_relationships {
  8415. ids = append(ids, id)
  8416. }
  8417. return ids
  8418. case contact.EdgeContactMessages:
  8419. ids := make([]ent.Value, 0, len(m.contact_messages))
  8420. for id := range m.contact_messages {
  8421. ids = append(ids, id)
  8422. }
  8423. return ids
  8424. }
  8425. return nil
  8426. }
  8427. // RemovedEdges returns all edge names that were removed in this mutation.
  8428. func (m *ContactMutation) RemovedEdges() []string {
  8429. edges := make([]string, 0, 2)
  8430. if m.removedcontact_relationships != nil {
  8431. edges = append(edges, contact.EdgeContactRelationships)
  8432. }
  8433. if m.removedcontact_messages != nil {
  8434. edges = append(edges, contact.EdgeContactMessages)
  8435. }
  8436. return edges
  8437. }
  8438. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8439. // the given name in this mutation.
  8440. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  8441. switch name {
  8442. case contact.EdgeContactRelationships:
  8443. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  8444. for id := range m.removedcontact_relationships {
  8445. ids = append(ids, id)
  8446. }
  8447. return ids
  8448. case contact.EdgeContactMessages:
  8449. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  8450. for id := range m.removedcontact_messages {
  8451. ids = append(ids, id)
  8452. }
  8453. return ids
  8454. }
  8455. return nil
  8456. }
  8457. // ClearedEdges returns all edge names that were cleared in this mutation.
  8458. func (m *ContactMutation) ClearedEdges() []string {
  8459. edges := make([]string, 0, 2)
  8460. if m.clearedcontact_relationships {
  8461. edges = append(edges, contact.EdgeContactRelationships)
  8462. }
  8463. if m.clearedcontact_messages {
  8464. edges = append(edges, contact.EdgeContactMessages)
  8465. }
  8466. return edges
  8467. }
  8468. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8469. // was cleared in this mutation.
  8470. func (m *ContactMutation) EdgeCleared(name string) bool {
  8471. switch name {
  8472. case contact.EdgeContactRelationships:
  8473. return m.clearedcontact_relationships
  8474. case contact.EdgeContactMessages:
  8475. return m.clearedcontact_messages
  8476. }
  8477. return false
  8478. }
  8479. // ClearEdge clears the value of the edge with the given name. It returns an error
  8480. // if that edge is not defined in the schema.
  8481. func (m *ContactMutation) ClearEdge(name string) error {
  8482. switch name {
  8483. }
  8484. return fmt.Errorf("unknown Contact unique edge %s", name)
  8485. }
  8486. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8487. // It returns an error if the edge is not defined in the schema.
  8488. func (m *ContactMutation) ResetEdge(name string) error {
  8489. switch name {
  8490. case contact.EdgeContactRelationships:
  8491. m.ResetContactRelationships()
  8492. return nil
  8493. case contact.EdgeContactMessages:
  8494. m.ResetContactMessages()
  8495. return nil
  8496. }
  8497. return fmt.Errorf("unknown Contact edge %s", name)
  8498. }
  8499. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  8500. type EmployeeMutation struct {
  8501. config
  8502. op Op
  8503. typ string
  8504. id *uint64
  8505. created_at *time.Time
  8506. updated_at *time.Time
  8507. deleted_at *time.Time
  8508. title *string
  8509. avatar *string
  8510. tags *string
  8511. hire_count *int
  8512. addhire_count *int
  8513. service_count *int
  8514. addservice_count *int
  8515. achievement_count *int
  8516. addachievement_count *int
  8517. intro *string
  8518. estimate *string
  8519. skill *string
  8520. ability_type *string
  8521. scene *string
  8522. switch_in *string
  8523. video_url *string
  8524. organization_id *uint64
  8525. addorganization_id *int64
  8526. category_id *uint64
  8527. addcategory_id *int64
  8528. api_base *string
  8529. api_key *string
  8530. ai_info *string
  8531. is_vip *int
  8532. addis_vip *int
  8533. chat_url *string
  8534. clearedFields map[string]struct{}
  8535. em_work_experiences map[uint64]struct{}
  8536. removedem_work_experiences map[uint64]struct{}
  8537. clearedem_work_experiences bool
  8538. em_tutorial map[uint64]struct{}
  8539. removedem_tutorial map[uint64]struct{}
  8540. clearedem_tutorial bool
  8541. done bool
  8542. oldValue func(context.Context) (*Employee, error)
  8543. predicates []predicate.Employee
  8544. }
  8545. var _ ent.Mutation = (*EmployeeMutation)(nil)
  8546. // employeeOption allows management of the mutation configuration using functional options.
  8547. type employeeOption func(*EmployeeMutation)
  8548. // newEmployeeMutation creates new mutation for the Employee entity.
  8549. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  8550. m := &EmployeeMutation{
  8551. config: c,
  8552. op: op,
  8553. typ: TypeEmployee,
  8554. clearedFields: make(map[string]struct{}),
  8555. }
  8556. for _, opt := range opts {
  8557. opt(m)
  8558. }
  8559. return m
  8560. }
  8561. // withEmployeeID sets the ID field of the mutation.
  8562. func withEmployeeID(id uint64) employeeOption {
  8563. return func(m *EmployeeMutation) {
  8564. var (
  8565. err error
  8566. once sync.Once
  8567. value *Employee
  8568. )
  8569. m.oldValue = func(ctx context.Context) (*Employee, error) {
  8570. once.Do(func() {
  8571. if m.done {
  8572. err = errors.New("querying old values post mutation is not allowed")
  8573. } else {
  8574. value, err = m.Client().Employee.Get(ctx, id)
  8575. }
  8576. })
  8577. return value, err
  8578. }
  8579. m.id = &id
  8580. }
  8581. }
  8582. // withEmployee sets the old Employee of the mutation.
  8583. func withEmployee(node *Employee) employeeOption {
  8584. return func(m *EmployeeMutation) {
  8585. m.oldValue = func(context.Context) (*Employee, error) {
  8586. return node, nil
  8587. }
  8588. m.id = &node.ID
  8589. }
  8590. }
  8591. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8592. // executed in a transaction (ent.Tx), a transactional client is returned.
  8593. func (m EmployeeMutation) Client() *Client {
  8594. client := &Client{config: m.config}
  8595. client.init()
  8596. return client
  8597. }
  8598. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8599. // it returns an error otherwise.
  8600. func (m EmployeeMutation) Tx() (*Tx, error) {
  8601. if _, ok := m.driver.(*txDriver); !ok {
  8602. return nil, errors.New("ent: mutation is not running in a transaction")
  8603. }
  8604. tx := &Tx{config: m.config}
  8605. tx.init()
  8606. return tx, nil
  8607. }
  8608. // SetID sets the value of the id field. Note that this
  8609. // operation is only accepted on creation of Employee entities.
  8610. func (m *EmployeeMutation) SetID(id uint64) {
  8611. m.id = &id
  8612. }
  8613. // ID returns the ID value in the mutation. Note that the ID is only available
  8614. // if it was provided to the builder or after it was returned from the database.
  8615. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  8616. if m.id == nil {
  8617. return
  8618. }
  8619. return *m.id, true
  8620. }
  8621. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8622. // That means, if the mutation is applied within a transaction with an isolation level such
  8623. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8624. // or updated by the mutation.
  8625. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  8626. switch {
  8627. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8628. id, exists := m.ID()
  8629. if exists {
  8630. return []uint64{id}, nil
  8631. }
  8632. fallthrough
  8633. case m.op.Is(OpUpdate | OpDelete):
  8634. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  8635. default:
  8636. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8637. }
  8638. }
  8639. // SetCreatedAt sets the "created_at" field.
  8640. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  8641. m.created_at = &t
  8642. }
  8643. // CreatedAt returns the value of the "created_at" field in the mutation.
  8644. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  8645. v := m.created_at
  8646. if v == nil {
  8647. return
  8648. }
  8649. return *v, true
  8650. }
  8651. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  8652. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8654. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8655. if !m.op.Is(OpUpdateOne) {
  8656. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8657. }
  8658. if m.id == nil || m.oldValue == nil {
  8659. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8660. }
  8661. oldValue, err := m.oldValue(ctx)
  8662. if err != nil {
  8663. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8664. }
  8665. return oldValue.CreatedAt, nil
  8666. }
  8667. // ResetCreatedAt resets all changes to the "created_at" field.
  8668. func (m *EmployeeMutation) ResetCreatedAt() {
  8669. m.created_at = nil
  8670. }
  8671. // SetUpdatedAt sets the "updated_at" field.
  8672. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  8673. m.updated_at = &t
  8674. }
  8675. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8676. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  8677. v := m.updated_at
  8678. if v == nil {
  8679. return
  8680. }
  8681. return *v, true
  8682. }
  8683. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  8684. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8686. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8687. if !m.op.Is(OpUpdateOne) {
  8688. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8689. }
  8690. if m.id == nil || m.oldValue == nil {
  8691. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8692. }
  8693. oldValue, err := m.oldValue(ctx)
  8694. if err != nil {
  8695. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8696. }
  8697. return oldValue.UpdatedAt, nil
  8698. }
  8699. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8700. func (m *EmployeeMutation) ResetUpdatedAt() {
  8701. m.updated_at = nil
  8702. }
  8703. // SetDeletedAt sets the "deleted_at" field.
  8704. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  8705. m.deleted_at = &t
  8706. }
  8707. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8708. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  8709. v := m.deleted_at
  8710. if v == nil {
  8711. return
  8712. }
  8713. return *v, true
  8714. }
  8715. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  8716. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8718. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8719. if !m.op.Is(OpUpdateOne) {
  8720. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8721. }
  8722. if m.id == nil || m.oldValue == nil {
  8723. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8724. }
  8725. oldValue, err := m.oldValue(ctx)
  8726. if err != nil {
  8727. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8728. }
  8729. return oldValue.DeletedAt, nil
  8730. }
  8731. // ClearDeletedAt clears the value of the "deleted_at" field.
  8732. func (m *EmployeeMutation) ClearDeletedAt() {
  8733. m.deleted_at = nil
  8734. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  8735. }
  8736. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8737. func (m *EmployeeMutation) DeletedAtCleared() bool {
  8738. _, ok := m.clearedFields[employee.FieldDeletedAt]
  8739. return ok
  8740. }
  8741. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8742. func (m *EmployeeMutation) ResetDeletedAt() {
  8743. m.deleted_at = nil
  8744. delete(m.clearedFields, employee.FieldDeletedAt)
  8745. }
  8746. // SetTitle sets the "title" field.
  8747. func (m *EmployeeMutation) SetTitle(s string) {
  8748. m.title = &s
  8749. }
  8750. // Title returns the value of the "title" field in the mutation.
  8751. func (m *EmployeeMutation) Title() (r string, exists bool) {
  8752. v := m.title
  8753. if v == nil {
  8754. return
  8755. }
  8756. return *v, true
  8757. }
  8758. // OldTitle returns the old "title" field's value of the Employee entity.
  8759. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8761. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  8762. if !m.op.Is(OpUpdateOne) {
  8763. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  8764. }
  8765. if m.id == nil || m.oldValue == nil {
  8766. return v, errors.New("OldTitle requires an ID field in the mutation")
  8767. }
  8768. oldValue, err := m.oldValue(ctx)
  8769. if err != nil {
  8770. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  8771. }
  8772. return oldValue.Title, nil
  8773. }
  8774. // ResetTitle resets all changes to the "title" field.
  8775. func (m *EmployeeMutation) ResetTitle() {
  8776. m.title = nil
  8777. }
  8778. // SetAvatar sets the "avatar" field.
  8779. func (m *EmployeeMutation) SetAvatar(s string) {
  8780. m.avatar = &s
  8781. }
  8782. // Avatar returns the value of the "avatar" field in the mutation.
  8783. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  8784. v := m.avatar
  8785. if v == nil {
  8786. return
  8787. }
  8788. return *v, true
  8789. }
  8790. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  8791. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8793. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  8794. if !m.op.Is(OpUpdateOne) {
  8795. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  8796. }
  8797. if m.id == nil || m.oldValue == nil {
  8798. return v, errors.New("OldAvatar requires an ID field in the mutation")
  8799. }
  8800. oldValue, err := m.oldValue(ctx)
  8801. if err != nil {
  8802. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  8803. }
  8804. return oldValue.Avatar, nil
  8805. }
  8806. // ResetAvatar resets all changes to the "avatar" field.
  8807. func (m *EmployeeMutation) ResetAvatar() {
  8808. m.avatar = nil
  8809. }
  8810. // SetTags sets the "tags" field.
  8811. func (m *EmployeeMutation) SetTags(s string) {
  8812. m.tags = &s
  8813. }
  8814. // Tags returns the value of the "tags" field in the mutation.
  8815. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  8816. v := m.tags
  8817. if v == nil {
  8818. return
  8819. }
  8820. return *v, true
  8821. }
  8822. // OldTags returns the old "tags" field's value of the Employee entity.
  8823. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8825. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  8826. if !m.op.Is(OpUpdateOne) {
  8827. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  8828. }
  8829. if m.id == nil || m.oldValue == nil {
  8830. return v, errors.New("OldTags requires an ID field in the mutation")
  8831. }
  8832. oldValue, err := m.oldValue(ctx)
  8833. if err != nil {
  8834. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  8835. }
  8836. return oldValue.Tags, nil
  8837. }
  8838. // ResetTags resets all changes to the "tags" field.
  8839. func (m *EmployeeMutation) ResetTags() {
  8840. m.tags = nil
  8841. }
  8842. // SetHireCount sets the "hire_count" field.
  8843. func (m *EmployeeMutation) SetHireCount(i int) {
  8844. m.hire_count = &i
  8845. m.addhire_count = nil
  8846. }
  8847. // HireCount returns the value of the "hire_count" field in the mutation.
  8848. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  8849. v := m.hire_count
  8850. if v == nil {
  8851. return
  8852. }
  8853. return *v, true
  8854. }
  8855. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  8856. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8858. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  8859. if !m.op.Is(OpUpdateOne) {
  8860. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  8861. }
  8862. if m.id == nil || m.oldValue == nil {
  8863. return v, errors.New("OldHireCount requires an ID field in the mutation")
  8864. }
  8865. oldValue, err := m.oldValue(ctx)
  8866. if err != nil {
  8867. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  8868. }
  8869. return oldValue.HireCount, nil
  8870. }
  8871. // AddHireCount adds i to the "hire_count" field.
  8872. func (m *EmployeeMutation) AddHireCount(i int) {
  8873. if m.addhire_count != nil {
  8874. *m.addhire_count += i
  8875. } else {
  8876. m.addhire_count = &i
  8877. }
  8878. }
  8879. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  8880. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  8881. v := m.addhire_count
  8882. if v == nil {
  8883. return
  8884. }
  8885. return *v, true
  8886. }
  8887. // ResetHireCount resets all changes to the "hire_count" field.
  8888. func (m *EmployeeMutation) ResetHireCount() {
  8889. m.hire_count = nil
  8890. m.addhire_count = nil
  8891. }
  8892. // SetServiceCount sets the "service_count" field.
  8893. func (m *EmployeeMutation) SetServiceCount(i int) {
  8894. m.service_count = &i
  8895. m.addservice_count = nil
  8896. }
  8897. // ServiceCount returns the value of the "service_count" field in the mutation.
  8898. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  8899. v := m.service_count
  8900. if v == nil {
  8901. return
  8902. }
  8903. return *v, true
  8904. }
  8905. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  8906. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8908. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  8909. if !m.op.Is(OpUpdateOne) {
  8910. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  8911. }
  8912. if m.id == nil || m.oldValue == nil {
  8913. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  8914. }
  8915. oldValue, err := m.oldValue(ctx)
  8916. if err != nil {
  8917. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  8918. }
  8919. return oldValue.ServiceCount, nil
  8920. }
  8921. // AddServiceCount adds i to the "service_count" field.
  8922. func (m *EmployeeMutation) AddServiceCount(i int) {
  8923. if m.addservice_count != nil {
  8924. *m.addservice_count += i
  8925. } else {
  8926. m.addservice_count = &i
  8927. }
  8928. }
  8929. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  8930. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  8931. v := m.addservice_count
  8932. if v == nil {
  8933. return
  8934. }
  8935. return *v, true
  8936. }
  8937. // ResetServiceCount resets all changes to the "service_count" field.
  8938. func (m *EmployeeMutation) ResetServiceCount() {
  8939. m.service_count = nil
  8940. m.addservice_count = nil
  8941. }
  8942. // SetAchievementCount sets the "achievement_count" field.
  8943. func (m *EmployeeMutation) SetAchievementCount(i int) {
  8944. m.achievement_count = &i
  8945. m.addachievement_count = nil
  8946. }
  8947. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  8948. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  8949. v := m.achievement_count
  8950. if v == nil {
  8951. return
  8952. }
  8953. return *v, true
  8954. }
  8955. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  8956. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8958. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  8959. if !m.op.Is(OpUpdateOne) {
  8960. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  8961. }
  8962. if m.id == nil || m.oldValue == nil {
  8963. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  8964. }
  8965. oldValue, err := m.oldValue(ctx)
  8966. if err != nil {
  8967. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  8968. }
  8969. return oldValue.AchievementCount, nil
  8970. }
  8971. // AddAchievementCount adds i to the "achievement_count" field.
  8972. func (m *EmployeeMutation) AddAchievementCount(i int) {
  8973. if m.addachievement_count != nil {
  8974. *m.addachievement_count += i
  8975. } else {
  8976. m.addachievement_count = &i
  8977. }
  8978. }
  8979. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  8980. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  8981. v := m.addachievement_count
  8982. if v == nil {
  8983. return
  8984. }
  8985. return *v, true
  8986. }
  8987. // ResetAchievementCount resets all changes to the "achievement_count" field.
  8988. func (m *EmployeeMutation) ResetAchievementCount() {
  8989. m.achievement_count = nil
  8990. m.addachievement_count = nil
  8991. }
  8992. // SetIntro sets the "intro" field.
  8993. func (m *EmployeeMutation) SetIntro(s string) {
  8994. m.intro = &s
  8995. }
  8996. // Intro returns the value of the "intro" field in the mutation.
  8997. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  8998. v := m.intro
  8999. if v == nil {
  9000. return
  9001. }
  9002. return *v, true
  9003. }
  9004. // OldIntro returns the old "intro" field's value of the Employee entity.
  9005. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9007. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  9008. if !m.op.Is(OpUpdateOne) {
  9009. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  9010. }
  9011. if m.id == nil || m.oldValue == nil {
  9012. return v, errors.New("OldIntro requires an ID field in the mutation")
  9013. }
  9014. oldValue, err := m.oldValue(ctx)
  9015. if err != nil {
  9016. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  9017. }
  9018. return oldValue.Intro, nil
  9019. }
  9020. // ResetIntro resets all changes to the "intro" field.
  9021. func (m *EmployeeMutation) ResetIntro() {
  9022. m.intro = nil
  9023. }
  9024. // SetEstimate sets the "estimate" field.
  9025. func (m *EmployeeMutation) SetEstimate(s string) {
  9026. m.estimate = &s
  9027. }
  9028. // Estimate returns the value of the "estimate" field in the mutation.
  9029. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  9030. v := m.estimate
  9031. if v == nil {
  9032. return
  9033. }
  9034. return *v, true
  9035. }
  9036. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  9037. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9039. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  9040. if !m.op.Is(OpUpdateOne) {
  9041. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  9042. }
  9043. if m.id == nil || m.oldValue == nil {
  9044. return v, errors.New("OldEstimate requires an ID field in the mutation")
  9045. }
  9046. oldValue, err := m.oldValue(ctx)
  9047. if err != nil {
  9048. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  9049. }
  9050. return oldValue.Estimate, nil
  9051. }
  9052. // ResetEstimate resets all changes to the "estimate" field.
  9053. func (m *EmployeeMutation) ResetEstimate() {
  9054. m.estimate = nil
  9055. }
  9056. // SetSkill sets the "skill" field.
  9057. func (m *EmployeeMutation) SetSkill(s string) {
  9058. m.skill = &s
  9059. }
  9060. // Skill returns the value of the "skill" field in the mutation.
  9061. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  9062. v := m.skill
  9063. if v == nil {
  9064. return
  9065. }
  9066. return *v, true
  9067. }
  9068. // OldSkill returns the old "skill" field's value of the Employee entity.
  9069. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9071. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  9072. if !m.op.Is(OpUpdateOne) {
  9073. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  9074. }
  9075. if m.id == nil || m.oldValue == nil {
  9076. return v, errors.New("OldSkill requires an ID field in the mutation")
  9077. }
  9078. oldValue, err := m.oldValue(ctx)
  9079. if err != nil {
  9080. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  9081. }
  9082. return oldValue.Skill, nil
  9083. }
  9084. // ResetSkill resets all changes to the "skill" field.
  9085. func (m *EmployeeMutation) ResetSkill() {
  9086. m.skill = nil
  9087. }
  9088. // SetAbilityType sets the "ability_type" field.
  9089. func (m *EmployeeMutation) SetAbilityType(s string) {
  9090. m.ability_type = &s
  9091. }
  9092. // AbilityType returns the value of the "ability_type" field in the mutation.
  9093. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  9094. v := m.ability_type
  9095. if v == nil {
  9096. return
  9097. }
  9098. return *v, true
  9099. }
  9100. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  9101. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9103. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  9104. if !m.op.Is(OpUpdateOne) {
  9105. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  9106. }
  9107. if m.id == nil || m.oldValue == nil {
  9108. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  9109. }
  9110. oldValue, err := m.oldValue(ctx)
  9111. if err != nil {
  9112. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  9113. }
  9114. return oldValue.AbilityType, nil
  9115. }
  9116. // ResetAbilityType resets all changes to the "ability_type" field.
  9117. func (m *EmployeeMutation) ResetAbilityType() {
  9118. m.ability_type = nil
  9119. }
  9120. // SetScene sets the "scene" field.
  9121. func (m *EmployeeMutation) SetScene(s string) {
  9122. m.scene = &s
  9123. }
  9124. // Scene returns the value of the "scene" field in the mutation.
  9125. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  9126. v := m.scene
  9127. if v == nil {
  9128. return
  9129. }
  9130. return *v, true
  9131. }
  9132. // OldScene returns the old "scene" field's value of the Employee entity.
  9133. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9135. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  9136. if !m.op.Is(OpUpdateOne) {
  9137. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  9138. }
  9139. if m.id == nil || m.oldValue == nil {
  9140. return v, errors.New("OldScene requires an ID field in the mutation")
  9141. }
  9142. oldValue, err := m.oldValue(ctx)
  9143. if err != nil {
  9144. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  9145. }
  9146. return oldValue.Scene, nil
  9147. }
  9148. // ResetScene resets all changes to the "scene" field.
  9149. func (m *EmployeeMutation) ResetScene() {
  9150. m.scene = nil
  9151. }
  9152. // SetSwitchIn sets the "switch_in" field.
  9153. func (m *EmployeeMutation) SetSwitchIn(s string) {
  9154. m.switch_in = &s
  9155. }
  9156. // SwitchIn returns the value of the "switch_in" field in the mutation.
  9157. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  9158. v := m.switch_in
  9159. if v == nil {
  9160. return
  9161. }
  9162. return *v, true
  9163. }
  9164. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  9165. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9167. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  9168. if !m.op.Is(OpUpdateOne) {
  9169. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  9170. }
  9171. if m.id == nil || m.oldValue == nil {
  9172. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  9173. }
  9174. oldValue, err := m.oldValue(ctx)
  9175. if err != nil {
  9176. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  9177. }
  9178. return oldValue.SwitchIn, nil
  9179. }
  9180. // ResetSwitchIn resets all changes to the "switch_in" field.
  9181. func (m *EmployeeMutation) ResetSwitchIn() {
  9182. m.switch_in = nil
  9183. }
  9184. // SetVideoURL sets the "video_url" field.
  9185. func (m *EmployeeMutation) SetVideoURL(s string) {
  9186. m.video_url = &s
  9187. }
  9188. // VideoURL returns the value of the "video_url" field in the mutation.
  9189. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  9190. v := m.video_url
  9191. if v == nil {
  9192. return
  9193. }
  9194. return *v, true
  9195. }
  9196. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  9197. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9199. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  9200. if !m.op.Is(OpUpdateOne) {
  9201. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  9202. }
  9203. if m.id == nil || m.oldValue == nil {
  9204. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  9205. }
  9206. oldValue, err := m.oldValue(ctx)
  9207. if err != nil {
  9208. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  9209. }
  9210. return oldValue.VideoURL, nil
  9211. }
  9212. // ResetVideoURL resets all changes to the "video_url" field.
  9213. func (m *EmployeeMutation) ResetVideoURL() {
  9214. m.video_url = nil
  9215. }
  9216. // SetOrganizationID sets the "organization_id" field.
  9217. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  9218. m.organization_id = &u
  9219. m.addorganization_id = nil
  9220. }
  9221. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9222. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  9223. v := m.organization_id
  9224. if v == nil {
  9225. return
  9226. }
  9227. return *v, true
  9228. }
  9229. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  9230. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9232. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9233. if !m.op.Is(OpUpdateOne) {
  9234. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9235. }
  9236. if m.id == nil || m.oldValue == nil {
  9237. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9238. }
  9239. oldValue, err := m.oldValue(ctx)
  9240. if err != nil {
  9241. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9242. }
  9243. return oldValue.OrganizationID, nil
  9244. }
  9245. // AddOrganizationID adds u to the "organization_id" field.
  9246. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  9247. if m.addorganization_id != nil {
  9248. *m.addorganization_id += u
  9249. } else {
  9250. m.addorganization_id = &u
  9251. }
  9252. }
  9253. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9254. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  9255. v := m.addorganization_id
  9256. if v == nil {
  9257. return
  9258. }
  9259. return *v, true
  9260. }
  9261. // ResetOrganizationID resets all changes to the "organization_id" field.
  9262. func (m *EmployeeMutation) ResetOrganizationID() {
  9263. m.organization_id = nil
  9264. m.addorganization_id = nil
  9265. }
  9266. // SetCategoryID sets the "category_id" field.
  9267. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  9268. m.category_id = &u
  9269. m.addcategory_id = nil
  9270. }
  9271. // CategoryID returns the value of the "category_id" field in the mutation.
  9272. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  9273. v := m.category_id
  9274. if v == nil {
  9275. return
  9276. }
  9277. return *v, true
  9278. }
  9279. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  9280. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9282. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  9283. if !m.op.Is(OpUpdateOne) {
  9284. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  9285. }
  9286. if m.id == nil || m.oldValue == nil {
  9287. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  9288. }
  9289. oldValue, err := m.oldValue(ctx)
  9290. if err != nil {
  9291. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  9292. }
  9293. return oldValue.CategoryID, nil
  9294. }
  9295. // AddCategoryID adds u to the "category_id" field.
  9296. func (m *EmployeeMutation) AddCategoryID(u int64) {
  9297. if m.addcategory_id != nil {
  9298. *m.addcategory_id += u
  9299. } else {
  9300. m.addcategory_id = &u
  9301. }
  9302. }
  9303. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  9304. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  9305. v := m.addcategory_id
  9306. if v == nil {
  9307. return
  9308. }
  9309. return *v, true
  9310. }
  9311. // ResetCategoryID resets all changes to the "category_id" field.
  9312. func (m *EmployeeMutation) ResetCategoryID() {
  9313. m.category_id = nil
  9314. m.addcategory_id = nil
  9315. }
  9316. // SetAPIBase sets the "api_base" field.
  9317. func (m *EmployeeMutation) SetAPIBase(s string) {
  9318. m.api_base = &s
  9319. }
  9320. // APIBase returns the value of the "api_base" field in the mutation.
  9321. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  9322. v := m.api_base
  9323. if v == nil {
  9324. return
  9325. }
  9326. return *v, true
  9327. }
  9328. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  9329. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9331. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  9332. if !m.op.Is(OpUpdateOne) {
  9333. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  9334. }
  9335. if m.id == nil || m.oldValue == nil {
  9336. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  9337. }
  9338. oldValue, err := m.oldValue(ctx)
  9339. if err != nil {
  9340. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  9341. }
  9342. return oldValue.APIBase, nil
  9343. }
  9344. // ResetAPIBase resets all changes to the "api_base" field.
  9345. func (m *EmployeeMutation) ResetAPIBase() {
  9346. m.api_base = nil
  9347. }
  9348. // SetAPIKey sets the "api_key" field.
  9349. func (m *EmployeeMutation) SetAPIKey(s string) {
  9350. m.api_key = &s
  9351. }
  9352. // APIKey returns the value of the "api_key" field in the mutation.
  9353. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  9354. v := m.api_key
  9355. if v == nil {
  9356. return
  9357. }
  9358. return *v, true
  9359. }
  9360. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  9361. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9363. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  9364. if !m.op.Is(OpUpdateOne) {
  9365. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  9366. }
  9367. if m.id == nil || m.oldValue == nil {
  9368. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  9369. }
  9370. oldValue, err := m.oldValue(ctx)
  9371. if err != nil {
  9372. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  9373. }
  9374. return oldValue.APIKey, nil
  9375. }
  9376. // ResetAPIKey resets all changes to the "api_key" field.
  9377. func (m *EmployeeMutation) ResetAPIKey() {
  9378. m.api_key = nil
  9379. }
  9380. // SetAiInfo sets the "ai_info" field.
  9381. func (m *EmployeeMutation) SetAiInfo(s string) {
  9382. m.ai_info = &s
  9383. }
  9384. // AiInfo returns the value of the "ai_info" field in the mutation.
  9385. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  9386. v := m.ai_info
  9387. if v == nil {
  9388. return
  9389. }
  9390. return *v, true
  9391. }
  9392. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  9393. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9395. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  9396. if !m.op.Is(OpUpdateOne) {
  9397. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  9398. }
  9399. if m.id == nil || m.oldValue == nil {
  9400. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  9401. }
  9402. oldValue, err := m.oldValue(ctx)
  9403. if err != nil {
  9404. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  9405. }
  9406. return oldValue.AiInfo, nil
  9407. }
  9408. // ClearAiInfo clears the value of the "ai_info" field.
  9409. func (m *EmployeeMutation) ClearAiInfo() {
  9410. m.ai_info = nil
  9411. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  9412. }
  9413. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  9414. func (m *EmployeeMutation) AiInfoCleared() bool {
  9415. _, ok := m.clearedFields[employee.FieldAiInfo]
  9416. return ok
  9417. }
  9418. // ResetAiInfo resets all changes to the "ai_info" field.
  9419. func (m *EmployeeMutation) ResetAiInfo() {
  9420. m.ai_info = nil
  9421. delete(m.clearedFields, employee.FieldAiInfo)
  9422. }
  9423. // SetIsVip sets the "is_vip" field.
  9424. func (m *EmployeeMutation) SetIsVip(i int) {
  9425. m.is_vip = &i
  9426. m.addis_vip = nil
  9427. }
  9428. // IsVip returns the value of the "is_vip" field in the mutation.
  9429. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  9430. v := m.is_vip
  9431. if v == nil {
  9432. return
  9433. }
  9434. return *v, true
  9435. }
  9436. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  9437. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9439. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  9440. if !m.op.Is(OpUpdateOne) {
  9441. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  9442. }
  9443. if m.id == nil || m.oldValue == nil {
  9444. return v, errors.New("OldIsVip requires an ID field in the mutation")
  9445. }
  9446. oldValue, err := m.oldValue(ctx)
  9447. if err != nil {
  9448. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  9449. }
  9450. return oldValue.IsVip, nil
  9451. }
  9452. // AddIsVip adds i to the "is_vip" field.
  9453. func (m *EmployeeMutation) AddIsVip(i int) {
  9454. if m.addis_vip != nil {
  9455. *m.addis_vip += i
  9456. } else {
  9457. m.addis_vip = &i
  9458. }
  9459. }
  9460. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  9461. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  9462. v := m.addis_vip
  9463. if v == nil {
  9464. return
  9465. }
  9466. return *v, true
  9467. }
  9468. // ResetIsVip resets all changes to the "is_vip" field.
  9469. func (m *EmployeeMutation) ResetIsVip() {
  9470. m.is_vip = nil
  9471. m.addis_vip = nil
  9472. }
  9473. // SetChatURL sets the "chat_url" field.
  9474. func (m *EmployeeMutation) SetChatURL(s string) {
  9475. m.chat_url = &s
  9476. }
  9477. // ChatURL returns the value of the "chat_url" field in the mutation.
  9478. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  9479. v := m.chat_url
  9480. if v == nil {
  9481. return
  9482. }
  9483. return *v, true
  9484. }
  9485. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  9486. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9488. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  9489. if !m.op.Is(OpUpdateOne) {
  9490. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  9491. }
  9492. if m.id == nil || m.oldValue == nil {
  9493. return v, errors.New("OldChatURL requires an ID field in the mutation")
  9494. }
  9495. oldValue, err := m.oldValue(ctx)
  9496. if err != nil {
  9497. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  9498. }
  9499. return oldValue.ChatURL, nil
  9500. }
  9501. // ResetChatURL resets all changes to the "chat_url" field.
  9502. func (m *EmployeeMutation) ResetChatURL() {
  9503. m.chat_url = nil
  9504. }
  9505. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  9506. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  9507. if m.em_work_experiences == nil {
  9508. m.em_work_experiences = make(map[uint64]struct{})
  9509. }
  9510. for i := range ids {
  9511. m.em_work_experiences[ids[i]] = struct{}{}
  9512. }
  9513. }
  9514. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  9515. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  9516. m.clearedem_work_experiences = true
  9517. }
  9518. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  9519. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  9520. return m.clearedem_work_experiences
  9521. }
  9522. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  9523. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  9524. if m.removedem_work_experiences == nil {
  9525. m.removedem_work_experiences = make(map[uint64]struct{})
  9526. }
  9527. for i := range ids {
  9528. delete(m.em_work_experiences, ids[i])
  9529. m.removedem_work_experiences[ids[i]] = struct{}{}
  9530. }
  9531. }
  9532. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  9533. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  9534. for id := range m.removedem_work_experiences {
  9535. ids = append(ids, id)
  9536. }
  9537. return
  9538. }
  9539. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  9540. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  9541. for id := range m.em_work_experiences {
  9542. ids = append(ids, id)
  9543. }
  9544. return
  9545. }
  9546. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  9547. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  9548. m.em_work_experiences = nil
  9549. m.clearedem_work_experiences = false
  9550. m.removedem_work_experiences = nil
  9551. }
  9552. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  9553. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  9554. if m.em_tutorial == nil {
  9555. m.em_tutorial = make(map[uint64]struct{})
  9556. }
  9557. for i := range ids {
  9558. m.em_tutorial[ids[i]] = struct{}{}
  9559. }
  9560. }
  9561. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  9562. func (m *EmployeeMutation) ClearEmTutorial() {
  9563. m.clearedem_tutorial = true
  9564. }
  9565. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  9566. func (m *EmployeeMutation) EmTutorialCleared() bool {
  9567. return m.clearedem_tutorial
  9568. }
  9569. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  9570. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  9571. if m.removedem_tutorial == nil {
  9572. m.removedem_tutorial = make(map[uint64]struct{})
  9573. }
  9574. for i := range ids {
  9575. delete(m.em_tutorial, ids[i])
  9576. m.removedem_tutorial[ids[i]] = struct{}{}
  9577. }
  9578. }
  9579. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  9580. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  9581. for id := range m.removedem_tutorial {
  9582. ids = append(ids, id)
  9583. }
  9584. return
  9585. }
  9586. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  9587. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  9588. for id := range m.em_tutorial {
  9589. ids = append(ids, id)
  9590. }
  9591. return
  9592. }
  9593. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  9594. func (m *EmployeeMutation) ResetEmTutorial() {
  9595. m.em_tutorial = nil
  9596. m.clearedem_tutorial = false
  9597. m.removedem_tutorial = nil
  9598. }
  9599. // Where appends a list predicates to the EmployeeMutation builder.
  9600. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  9601. m.predicates = append(m.predicates, ps...)
  9602. }
  9603. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  9604. // users can use type-assertion to append predicates that do not depend on any generated package.
  9605. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  9606. p := make([]predicate.Employee, len(ps))
  9607. for i := range ps {
  9608. p[i] = ps[i]
  9609. }
  9610. m.Where(p...)
  9611. }
  9612. // Op returns the operation name.
  9613. func (m *EmployeeMutation) Op() Op {
  9614. return m.op
  9615. }
  9616. // SetOp allows setting the mutation operation.
  9617. func (m *EmployeeMutation) SetOp(op Op) {
  9618. m.op = op
  9619. }
  9620. // Type returns the node type of this mutation (Employee).
  9621. func (m *EmployeeMutation) Type() string {
  9622. return m.typ
  9623. }
  9624. // Fields returns all fields that were changed during this mutation. Note that in
  9625. // order to get all numeric fields that were incremented/decremented, call
  9626. // AddedFields().
  9627. func (m *EmployeeMutation) Fields() []string {
  9628. fields := make([]string, 0, 23)
  9629. if m.created_at != nil {
  9630. fields = append(fields, employee.FieldCreatedAt)
  9631. }
  9632. if m.updated_at != nil {
  9633. fields = append(fields, employee.FieldUpdatedAt)
  9634. }
  9635. if m.deleted_at != nil {
  9636. fields = append(fields, employee.FieldDeletedAt)
  9637. }
  9638. if m.title != nil {
  9639. fields = append(fields, employee.FieldTitle)
  9640. }
  9641. if m.avatar != nil {
  9642. fields = append(fields, employee.FieldAvatar)
  9643. }
  9644. if m.tags != nil {
  9645. fields = append(fields, employee.FieldTags)
  9646. }
  9647. if m.hire_count != nil {
  9648. fields = append(fields, employee.FieldHireCount)
  9649. }
  9650. if m.service_count != nil {
  9651. fields = append(fields, employee.FieldServiceCount)
  9652. }
  9653. if m.achievement_count != nil {
  9654. fields = append(fields, employee.FieldAchievementCount)
  9655. }
  9656. if m.intro != nil {
  9657. fields = append(fields, employee.FieldIntro)
  9658. }
  9659. if m.estimate != nil {
  9660. fields = append(fields, employee.FieldEstimate)
  9661. }
  9662. if m.skill != nil {
  9663. fields = append(fields, employee.FieldSkill)
  9664. }
  9665. if m.ability_type != nil {
  9666. fields = append(fields, employee.FieldAbilityType)
  9667. }
  9668. if m.scene != nil {
  9669. fields = append(fields, employee.FieldScene)
  9670. }
  9671. if m.switch_in != nil {
  9672. fields = append(fields, employee.FieldSwitchIn)
  9673. }
  9674. if m.video_url != nil {
  9675. fields = append(fields, employee.FieldVideoURL)
  9676. }
  9677. if m.organization_id != nil {
  9678. fields = append(fields, employee.FieldOrganizationID)
  9679. }
  9680. if m.category_id != nil {
  9681. fields = append(fields, employee.FieldCategoryID)
  9682. }
  9683. if m.api_base != nil {
  9684. fields = append(fields, employee.FieldAPIBase)
  9685. }
  9686. if m.api_key != nil {
  9687. fields = append(fields, employee.FieldAPIKey)
  9688. }
  9689. if m.ai_info != nil {
  9690. fields = append(fields, employee.FieldAiInfo)
  9691. }
  9692. if m.is_vip != nil {
  9693. fields = append(fields, employee.FieldIsVip)
  9694. }
  9695. if m.chat_url != nil {
  9696. fields = append(fields, employee.FieldChatURL)
  9697. }
  9698. return fields
  9699. }
  9700. // Field returns the value of a field with the given name. The second boolean
  9701. // return value indicates that this field was not set, or was not defined in the
  9702. // schema.
  9703. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  9704. switch name {
  9705. case employee.FieldCreatedAt:
  9706. return m.CreatedAt()
  9707. case employee.FieldUpdatedAt:
  9708. return m.UpdatedAt()
  9709. case employee.FieldDeletedAt:
  9710. return m.DeletedAt()
  9711. case employee.FieldTitle:
  9712. return m.Title()
  9713. case employee.FieldAvatar:
  9714. return m.Avatar()
  9715. case employee.FieldTags:
  9716. return m.Tags()
  9717. case employee.FieldHireCount:
  9718. return m.HireCount()
  9719. case employee.FieldServiceCount:
  9720. return m.ServiceCount()
  9721. case employee.FieldAchievementCount:
  9722. return m.AchievementCount()
  9723. case employee.FieldIntro:
  9724. return m.Intro()
  9725. case employee.FieldEstimate:
  9726. return m.Estimate()
  9727. case employee.FieldSkill:
  9728. return m.Skill()
  9729. case employee.FieldAbilityType:
  9730. return m.AbilityType()
  9731. case employee.FieldScene:
  9732. return m.Scene()
  9733. case employee.FieldSwitchIn:
  9734. return m.SwitchIn()
  9735. case employee.FieldVideoURL:
  9736. return m.VideoURL()
  9737. case employee.FieldOrganizationID:
  9738. return m.OrganizationID()
  9739. case employee.FieldCategoryID:
  9740. return m.CategoryID()
  9741. case employee.FieldAPIBase:
  9742. return m.APIBase()
  9743. case employee.FieldAPIKey:
  9744. return m.APIKey()
  9745. case employee.FieldAiInfo:
  9746. return m.AiInfo()
  9747. case employee.FieldIsVip:
  9748. return m.IsVip()
  9749. case employee.FieldChatURL:
  9750. return m.ChatURL()
  9751. }
  9752. return nil, false
  9753. }
  9754. // OldField returns the old value of the field from the database. An error is
  9755. // returned if the mutation operation is not UpdateOne, or the query to the
  9756. // database failed.
  9757. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9758. switch name {
  9759. case employee.FieldCreatedAt:
  9760. return m.OldCreatedAt(ctx)
  9761. case employee.FieldUpdatedAt:
  9762. return m.OldUpdatedAt(ctx)
  9763. case employee.FieldDeletedAt:
  9764. return m.OldDeletedAt(ctx)
  9765. case employee.FieldTitle:
  9766. return m.OldTitle(ctx)
  9767. case employee.FieldAvatar:
  9768. return m.OldAvatar(ctx)
  9769. case employee.FieldTags:
  9770. return m.OldTags(ctx)
  9771. case employee.FieldHireCount:
  9772. return m.OldHireCount(ctx)
  9773. case employee.FieldServiceCount:
  9774. return m.OldServiceCount(ctx)
  9775. case employee.FieldAchievementCount:
  9776. return m.OldAchievementCount(ctx)
  9777. case employee.FieldIntro:
  9778. return m.OldIntro(ctx)
  9779. case employee.FieldEstimate:
  9780. return m.OldEstimate(ctx)
  9781. case employee.FieldSkill:
  9782. return m.OldSkill(ctx)
  9783. case employee.FieldAbilityType:
  9784. return m.OldAbilityType(ctx)
  9785. case employee.FieldScene:
  9786. return m.OldScene(ctx)
  9787. case employee.FieldSwitchIn:
  9788. return m.OldSwitchIn(ctx)
  9789. case employee.FieldVideoURL:
  9790. return m.OldVideoURL(ctx)
  9791. case employee.FieldOrganizationID:
  9792. return m.OldOrganizationID(ctx)
  9793. case employee.FieldCategoryID:
  9794. return m.OldCategoryID(ctx)
  9795. case employee.FieldAPIBase:
  9796. return m.OldAPIBase(ctx)
  9797. case employee.FieldAPIKey:
  9798. return m.OldAPIKey(ctx)
  9799. case employee.FieldAiInfo:
  9800. return m.OldAiInfo(ctx)
  9801. case employee.FieldIsVip:
  9802. return m.OldIsVip(ctx)
  9803. case employee.FieldChatURL:
  9804. return m.OldChatURL(ctx)
  9805. }
  9806. return nil, fmt.Errorf("unknown Employee field %s", name)
  9807. }
  9808. // SetField sets the value of a field with the given name. It returns an error if
  9809. // the field is not defined in the schema, or if the type mismatched the field
  9810. // type.
  9811. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  9812. switch name {
  9813. case employee.FieldCreatedAt:
  9814. v, ok := value.(time.Time)
  9815. if !ok {
  9816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9817. }
  9818. m.SetCreatedAt(v)
  9819. return nil
  9820. case employee.FieldUpdatedAt:
  9821. v, ok := value.(time.Time)
  9822. if !ok {
  9823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9824. }
  9825. m.SetUpdatedAt(v)
  9826. return nil
  9827. case employee.FieldDeletedAt:
  9828. v, ok := value.(time.Time)
  9829. if !ok {
  9830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9831. }
  9832. m.SetDeletedAt(v)
  9833. return nil
  9834. case employee.FieldTitle:
  9835. v, ok := value.(string)
  9836. if !ok {
  9837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9838. }
  9839. m.SetTitle(v)
  9840. return nil
  9841. case employee.FieldAvatar:
  9842. v, ok := value.(string)
  9843. if !ok {
  9844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9845. }
  9846. m.SetAvatar(v)
  9847. return nil
  9848. case employee.FieldTags:
  9849. v, ok := value.(string)
  9850. if !ok {
  9851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9852. }
  9853. m.SetTags(v)
  9854. return nil
  9855. case employee.FieldHireCount:
  9856. v, ok := value.(int)
  9857. if !ok {
  9858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9859. }
  9860. m.SetHireCount(v)
  9861. return nil
  9862. case employee.FieldServiceCount:
  9863. v, ok := value.(int)
  9864. if !ok {
  9865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9866. }
  9867. m.SetServiceCount(v)
  9868. return nil
  9869. case employee.FieldAchievementCount:
  9870. v, ok := value.(int)
  9871. if !ok {
  9872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9873. }
  9874. m.SetAchievementCount(v)
  9875. return nil
  9876. case employee.FieldIntro:
  9877. v, ok := value.(string)
  9878. if !ok {
  9879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9880. }
  9881. m.SetIntro(v)
  9882. return nil
  9883. case employee.FieldEstimate:
  9884. v, ok := value.(string)
  9885. if !ok {
  9886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9887. }
  9888. m.SetEstimate(v)
  9889. return nil
  9890. case employee.FieldSkill:
  9891. v, ok := value.(string)
  9892. if !ok {
  9893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9894. }
  9895. m.SetSkill(v)
  9896. return nil
  9897. case employee.FieldAbilityType:
  9898. v, ok := value.(string)
  9899. if !ok {
  9900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9901. }
  9902. m.SetAbilityType(v)
  9903. return nil
  9904. case employee.FieldScene:
  9905. v, ok := value.(string)
  9906. if !ok {
  9907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9908. }
  9909. m.SetScene(v)
  9910. return nil
  9911. case employee.FieldSwitchIn:
  9912. v, ok := value.(string)
  9913. if !ok {
  9914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9915. }
  9916. m.SetSwitchIn(v)
  9917. return nil
  9918. case employee.FieldVideoURL:
  9919. v, ok := value.(string)
  9920. if !ok {
  9921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9922. }
  9923. m.SetVideoURL(v)
  9924. return nil
  9925. case employee.FieldOrganizationID:
  9926. v, ok := value.(uint64)
  9927. if !ok {
  9928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9929. }
  9930. m.SetOrganizationID(v)
  9931. return nil
  9932. case employee.FieldCategoryID:
  9933. v, ok := value.(uint64)
  9934. if !ok {
  9935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9936. }
  9937. m.SetCategoryID(v)
  9938. return nil
  9939. case employee.FieldAPIBase:
  9940. v, ok := value.(string)
  9941. if !ok {
  9942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9943. }
  9944. m.SetAPIBase(v)
  9945. return nil
  9946. case employee.FieldAPIKey:
  9947. v, ok := value.(string)
  9948. if !ok {
  9949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9950. }
  9951. m.SetAPIKey(v)
  9952. return nil
  9953. case employee.FieldAiInfo:
  9954. v, ok := value.(string)
  9955. if !ok {
  9956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9957. }
  9958. m.SetAiInfo(v)
  9959. return nil
  9960. case employee.FieldIsVip:
  9961. v, ok := value.(int)
  9962. if !ok {
  9963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9964. }
  9965. m.SetIsVip(v)
  9966. return nil
  9967. case employee.FieldChatURL:
  9968. v, ok := value.(string)
  9969. if !ok {
  9970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9971. }
  9972. m.SetChatURL(v)
  9973. return nil
  9974. }
  9975. return fmt.Errorf("unknown Employee field %s", name)
  9976. }
  9977. // AddedFields returns all numeric fields that were incremented/decremented during
  9978. // this mutation.
  9979. func (m *EmployeeMutation) AddedFields() []string {
  9980. var fields []string
  9981. if m.addhire_count != nil {
  9982. fields = append(fields, employee.FieldHireCount)
  9983. }
  9984. if m.addservice_count != nil {
  9985. fields = append(fields, employee.FieldServiceCount)
  9986. }
  9987. if m.addachievement_count != nil {
  9988. fields = append(fields, employee.FieldAchievementCount)
  9989. }
  9990. if m.addorganization_id != nil {
  9991. fields = append(fields, employee.FieldOrganizationID)
  9992. }
  9993. if m.addcategory_id != nil {
  9994. fields = append(fields, employee.FieldCategoryID)
  9995. }
  9996. if m.addis_vip != nil {
  9997. fields = append(fields, employee.FieldIsVip)
  9998. }
  9999. return fields
  10000. }
  10001. // AddedField returns the numeric value that was incremented/decremented on a field
  10002. // with the given name. The second boolean return value indicates that this field
  10003. // was not set, or was not defined in the schema.
  10004. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  10005. switch name {
  10006. case employee.FieldHireCount:
  10007. return m.AddedHireCount()
  10008. case employee.FieldServiceCount:
  10009. return m.AddedServiceCount()
  10010. case employee.FieldAchievementCount:
  10011. return m.AddedAchievementCount()
  10012. case employee.FieldOrganizationID:
  10013. return m.AddedOrganizationID()
  10014. case employee.FieldCategoryID:
  10015. return m.AddedCategoryID()
  10016. case employee.FieldIsVip:
  10017. return m.AddedIsVip()
  10018. }
  10019. return nil, false
  10020. }
  10021. // AddField adds the value to the field with the given name. It returns an error if
  10022. // the field is not defined in the schema, or if the type mismatched the field
  10023. // type.
  10024. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  10025. switch name {
  10026. case employee.FieldHireCount:
  10027. v, ok := value.(int)
  10028. if !ok {
  10029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10030. }
  10031. m.AddHireCount(v)
  10032. return nil
  10033. case employee.FieldServiceCount:
  10034. v, ok := value.(int)
  10035. if !ok {
  10036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10037. }
  10038. m.AddServiceCount(v)
  10039. return nil
  10040. case employee.FieldAchievementCount:
  10041. v, ok := value.(int)
  10042. if !ok {
  10043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10044. }
  10045. m.AddAchievementCount(v)
  10046. return nil
  10047. case employee.FieldOrganizationID:
  10048. v, ok := value.(int64)
  10049. if !ok {
  10050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10051. }
  10052. m.AddOrganizationID(v)
  10053. return nil
  10054. case employee.FieldCategoryID:
  10055. v, ok := value.(int64)
  10056. if !ok {
  10057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10058. }
  10059. m.AddCategoryID(v)
  10060. return nil
  10061. case employee.FieldIsVip:
  10062. v, ok := value.(int)
  10063. if !ok {
  10064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10065. }
  10066. m.AddIsVip(v)
  10067. return nil
  10068. }
  10069. return fmt.Errorf("unknown Employee numeric field %s", name)
  10070. }
  10071. // ClearedFields returns all nullable fields that were cleared during this
  10072. // mutation.
  10073. func (m *EmployeeMutation) ClearedFields() []string {
  10074. var fields []string
  10075. if m.FieldCleared(employee.FieldDeletedAt) {
  10076. fields = append(fields, employee.FieldDeletedAt)
  10077. }
  10078. if m.FieldCleared(employee.FieldAiInfo) {
  10079. fields = append(fields, employee.FieldAiInfo)
  10080. }
  10081. return fields
  10082. }
  10083. // FieldCleared returns a boolean indicating if a field with the given name was
  10084. // cleared in this mutation.
  10085. func (m *EmployeeMutation) FieldCleared(name string) bool {
  10086. _, ok := m.clearedFields[name]
  10087. return ok
  10088. }
  10089. // ClearField clears the value of the field with the given name. It returns an
  10090. // error if the field is not defined in the schema.
  10091. func (m *EmployeeMutation) ClearField(name string) error {
  10092. switch name {
  10093. case employee.FieldDeletedAt:
  10094. m.ClearDeletedAt()
  10095. return nil
  10096. case employee.FieldAiInfo:
  10097. m.ClearAiInfo()
  10098. return nil
  10099. }
  10100. return fmt.Errorf("unknown Employee nullable field %s", name)
  10101. }
  10102. // ResetField resets all changes in the mutation for the field with the given name.
  10103. // It returns an error if the field is not defined in the schema.
  10104. func (m *EmployeeMutation) ResetField(name string) error {
  10105. switch name {
  10106. case employee.FieldCreatedAt:
  10107. m.ResetCreatedAt()
  10108. return nil
  10109. case employee.FieldUpdatedAt:
  10110. m.ResetUpdatedAt()
  10111. return nil
  10112. case employee.FieldDeletedAt:
  10113. m.ResetDeletedAt()
  10114. return nil
  10115. case employee.FieldTitle:
  10116. m.ResetTitle()
  10117. return nil
  10118. case employee.FieldAvatar:
  10119. m.ResetAvatar()
  10120. return nil
  10121. case employee.FieldTags:
  10122. m.ResetTags()
  10123. return nil
  10124. case employee.FieldHireCount:
  10125. m.ResetHireCount()
  10126. return nil
  10127. case employee.FieldServiceCount:
  10128. m.ResetServiceCount()
  10129. return nil
  10130. case employee.FieldAchievementCount:
  10131. m.ResetAchievementCount()
  10132. return nil
  10133. case employee.FieldIntro:
  10134. m.ResetIntro()
  10135. return nil
  10136. case employee.FieldEstimate:
  10137. m.ResetEstimate()
  10138. return nil
  10139. case employee.FieldSkill:
  10140. m.ResetSkill()
  10141. return nil
  10142. case employee.FieldAbilityType:
  10143. m.ResetAbilityType()
  10144. return nil
  10145. case employee.FieldScene:
  10146. m.ResetScene()
  10147. return nil
  10148. case employee.FieldSwitchIn:
  10149. m.ResetSwitchIn()
  10150. return nil
  10151. case employee.FieldVideoURL:
  10152. m.ResetVideoURL()
  10153. return nil
  10154. case employee.FieldOrganizationID:
  10155. m.ResetOrganizationID()
  10156. return nil
  10157. case employee.FieldCategoryID:
  10158. m.ResetCategoryID()
  10159. return nil
  10160. case employee.FieldAPIBase:
  10161. m.ResetAPIBase()
  10162. return nil
  10163. case employee.FieldAPIKey:
  10164. m.ResetAPIKey()
  10165. return nil
  10166. case employee.FieldAiInfo:
  10167. m.ResetAiInfo()
  10168. return nil
  10169. case employee.FieldIsVip:
  10170. m.ResetIsVip()
  10171. return nil
  10172. case employee.FieldChatURL:
  10173. m.ResetChatURL()
  10174. return nil
  10175. }
  10176. return fmt.Errorf("unknown Employee field %s", name)
  10177. }
  10178. // AddedEdges returns all edge names that were set/added in this mutation.
  10179. func (m *EmployeeMutation) AddedEdges() []string {
  10180. edges := make([]string, 0, 2)
  10181. if m.em_work_experiences != nil {
  10182. edges = append(edges, employee.EdgeEmWorkExperiences)
  10183. }
  10184. if m.em_tutorial != nil {
  10185. edges = append(edges, employee.EdgeEmTutorial)
  10186. }
  10187. return edges
  10188. }
  10189. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10190. // name in this mutation.
  10191. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  10192. switch name {
  10193. case employee.EdgeEmWorkExperiences:
  10194. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  10195. for id := range m.em_work_experiences {
  10196. ids = append(ids, id)
  10197. }
  10198. return ids
  10199. case employee.EdgeEmTutorial:
  10200. ids := make([]ent.Value, 0, len(m.em_tutorial))
  10201. for id := range m.em_tutorial {
  10202. ids = append(ids, id)
  10203. }
  10204. return ids
  10205. }
  10206. return nil
  10207. }
  10208. // RemovedEdges returns all edge names that were removed in this mutation.
  10209. func (m *EmployeeMutation) RemovedEdges() []string {
  10210. edges := make([]string, 0, 2)
  10211. if m.removedem_work_experiences != nil {
  10212. edges = append(edges, employee.EdgeEmWorkExperiences)
  10213. }
  10214. if m.removedem_tutorial != nil {
  10215. edges = append(edges, employee.EdgeEmTutorial)
  10216. }
  10217. return edges
  10218. }
  10219. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10220. // the given name in this mutation.
  10221. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  10222. switch name {
  10223. case employee.EdgeEmWorkExperiences:
  10224. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  10225. for id := range m.removedem_work_experiences {
  10226. ids = append(ids, id)
  10227. }
  10228. return ids
  10229. case employee.EdgeEmTutorial:
  10230. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  10231. for id := range m.removedem_tutorial {
  10232. ids = append(ids, id)
  10233. }
  10234. return ids
  10235. }
  10236. return nil
  10237. }
  10238. // ClearedEdges returns all edge names that were cleared in this mutation.
  10239. func (m *EmployeeMutation) ClearedEdges() []string {
  10240. edges := make([]string, 0, 2)
  10241. if m.clearedem_work_experiences {
  10242. edges = append(edges, employee.EdgeEmWorkExperiences)
  10243. }
  10244. if m.clearedem_tutorial {
  10245. edges = append(edges, employee.EdgeEmTutorial)
  10246. }
  10247. return edges
  10248. }
  10249. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10250. // was cleared in this mutation.
  10251. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  10252. switch name {
  10253. case employee.EdgeEmWorkExperiences:
  10254. return m.clearedem_work_experiences
  10255. case employee.EdgeEmTutorial:
  10256. return m.clearedem_tutorial
  10257. }
  10258. return false
  10259. }
  10260. // ClearEdge clears the value of the edge with the given name. It returns an error
  10261. // if that edge is not defined in the schema.
  10262. func (m *EmployeeMutation) ClearEdge(name string) error {
  10263. switch name {
  10264. }
  10265. return fmt.Errorf("unknown Employee unique edge %s", name)
  10266. }
  10267. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10268. // It returns an error if the edge is not defined in the schema.
  10269. func (m *EmployeeMutation) ResetEdge(name string) error {
  10270. switch name {
  10271. case employee.EdgeEmWorkExperiences:
  10272. m.ResetEmWorkExperiences()
  10273. return nil
  10274. case employee.EdgeEmTutorial:
  10275. m.ResetEmTutorial()
  10276. return nil
  10277. }
  10278. return fmt.Errorf("unknown Employee edge %s", name)
  10279. }
  10280. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  10281. type EmployeeConfigMutation struct {
  10282. config
  10283. op Op
  10284. typ string
  10285. id *uint64
  10286. created_at *time.Time
  10287. updated_at *time.Time
  10288. deleted_at *time.Time
  10289. stype *string
  10290. title *string
  10291. photo *string
  10292. organization_id *uint64
  10293. addorganization_id *int64
  10294. clearedFields map[string]struct{}
  10295. done bool
  10296. oldValue func(context.Context) (*EmployeeConfig, error)
  10297. predicates []predicate.EmployeeConfig
  10298. }
  10299. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  10300. // employeeconfigOption allows management of the mutation configuration using functional options.
  10301. type employeeconfigOption func(*EmployeeConfigMutation)
  10302. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  10303. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  10304. m := &EmployeeConfigMutation{
  10305. config: c,
  10306. op: op,
  10307. typ: TypeEmployeeConfig,
  10308. clearedFields: make(map[string]struct{}),
  10309. }
  10310. for _, opt := range opts {
  10311. opt(m)
  10312. }
  10313. return m
  10314. }
  10315. // withEmployeeConfigID sets the ID field of the mutation.
  10316. func withEmployeeConfigID(id uint64) employeeconfigOption {
  10317. return func(m *EmployeeConfigMutation) {
  10318. var (
  10319. err error
  10320. once sync.Once
  10321. value *EmployeeConfig
  10322. )
  10323. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  10324. once.Do(func() {
  10325. if m.done {
  10326. err = errors.New("querying old values post mutation is not allowed")
  10327. } else {
  10328. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  10329. }
  10330. })
  10331. return value, err
  10332. }
  10333. m.id = &id
  10334. }
  10335. }
  10336. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  10337. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  10338. return func(m *EmployeeConfigMutation) {
  10339. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  10340. return node, nil
  10341. }
  10342. m.id = &node.ID
  10343. }
  10344. }
  10345. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10346. // executed in a transaction (ent.Tx), a transactional client is returned.
  10347. func (m EmployeeConfigMutation) Client() *Client {
  10348. client := &Client{config: m.config}
  10349. client.init()
  10350. return client
  10351. }
  10352. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10353. // it returns an error otherwise.
  10354. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  10355. if _, ok := m.driver.(*txDriver); !ok {
  10356. return nil, errors.New("ent: mutation is not running in a transaction")
  10357. }
  10358. tx := &Tx{config: m.config}
  10359. tx.init()
  10360. return tx, nil
  10361. }
  10362. // SetID sets the value of the id field. Note that this
  10363. // operation is only accepted on creation of EmployeeConfig entities.
  10364. func (m *EmployeeConfigMutation) SetID(id uint64) {
  10365. m.id = &id
  10366. }
  10367. // ID returns the ID value in the mutation. Note that the ID is only available
  10368. // if it was provided to the builder or after it was returned from the database.
  10369. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  10370. if m.id == nil {
  10371. return
  10372. }
  10373. return *m.id, true
  10374. }
  10375. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10376. // That means, if the mutation is applied within a transaction with an isolation level such
  10377. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10378. // or updated by the mutation.
  10379. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  10380. switch {
  10381. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10382. id, exists := m.ID()
  10383. if exists {
  10384. return []uint64{id}, nil
  10385. }
  10386. fallthrough
  10387. case m.op.Is(OpUpdate | OpDelete):
  10388. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  10389. default:
  10390. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10391. }
  10392. }
  10393. // SetCreatedAt sets the "created_at" field.
  10394. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  10395. m.created_at = &t
  10396. }
  10397. // CreatedAt returns the value of the "created_at" field in the mutation.
  10398. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  10399. v := m.created_at
  10400. if v == nil {
  10401. return
  10402. }
  10403. return *v, true
  10404. }
  10405. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  10406. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10408. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10409. if !m.op.Is(OpUpdateOne) {
  10410. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10411. }
  10412. if m.id == nil || m.oldValue == nil {
  10413. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10414. }
  10415. oldValue, err := m.oldValue(ctx)
  10416. if err != nil {
  10417. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10418. }
  10419. return oldValue.CreatedAt, nil
  10420. }
  10421. // ResetCreatedAt resets all changes to the "created_at" field.
  10422. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  10423. m.created_at = nil
  10424. }
  10425. // SetUpdatedAt sets the "updated_at" field.
  10426. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  10427. m.updated_at = &t
  10428. }
  10429. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10430. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  10431. v := m.updated_at
  10432. if v == nil {
  10433. return
  10434. }
  10435. return *v, true
  10436. }
  10437. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  10438. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10440. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10441. if !m.op.Is(OpUpdateOne) {
  10442. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10443. }
  10444. if m.id == nil || m.oldValue == nil {
  10445. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10446. }
  10447. oldValue, err := m.oldValue(ctx)
  10448. if err != nil {
  10449. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10450. }
  10451. return oldValue.UpdatedAt, nil
  10452. }
  10453. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10454. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  10455. m.updated_at = nil
  10456. }
  10457. // SetDeletedAt sets the "deleted_at" field.
  10458. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  10459. m.deleted_at = &t
  10460. }
  10461. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10462. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  10463. v := m.deleted_at
  10464. if v == nil {
  10465. return
  10466. }
  10467. return *v, true
  10468. }
  10469. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  10470. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10472. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10473. if !m.op.Is(OpUpdateOne) {
  10474. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10475. }
  10476. if m.id == nil || m.oldValue == nil {
  10477. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10478. }
  10479. oldValue, err := m.oldValue(ctx)
  10480. if err != nil {
  10481. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10482. }
  10483. return oldValue.DeletedAt, nil
  10484. }
  10485. // ClearDeletedAt clears the value of the "deleted_at" field.
  10486. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  10487. m.deleted_at = nil
  10488. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  10489. }
  10490. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10491. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  10492. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  10493. return ok
  10494. }
  10495. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10496. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  10497. m.deleted_at = nil
  10498. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  10499. }
  10500. // SetStype sets the "stype" field.
  10501. func (m *EmployeeConfigMutation) SetStype(s string) {
  10502. m.stype = &s
  10503. }
  10504. // Stype returns the value of the "stype" field in the mutation.
  10505. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  10506. v := m.stype
  10507. if v == nil {
  10508. return
  10509. }
  10510. return *v, true
  10511. }
  10512. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  10513. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10515. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  10516. if !m.op.Is(OpUpdateOne) {
  10517. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  10518. }
  10519. if m.id == nil || m.oldValue == nil {
  10520. return v, errors.New("OldStype requires an ID field in the mutation")
  10521. }
  10522. oldValue, err := m.oldValue(ctx)
  10523. if err != nil {
  10524. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  10525. }
  10526. return oldValue.Stype, nil
  10527. }
  10528. // ResetStype resets all changes to the "stype" field.
  10529. func (m *EmployeeConfigMutation) ResetStype() {
  10530. m.stype = nil
  10531. }
  10532. // SetTitle sets the "title" field.
  10533. func (m *EmployeeConfigMutation) SetTitle(s string) {
  10534. m.title = &s
  10535. }
  10536. // Title returns the value of the "title" field in the mutation.
  10537. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  10538. v := m.title
  10539. if v == nil {
  10540. return
  10541. }
  10542. return *v, true
  10543. }
  10544. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  10545. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10547. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  10548. if !m.op.Is(OpUpdateOne) {
  10549. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  10550. }
  10551. if m.id == nil || m.oldValue == nil {
  10552. return v, errors.New("OldTitle requires an ID field in the mutation")
  10553. }
  10554. oldValue, err := m.oldValue(ctx)
  10555. if err != nil {
  10556. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  10557. }
  10558. return oldValue.Title, nil
  10559. }
  10560. // ResetTitle resets all changes to the "title" field.
  10561. func (m *EmployeeConfigMutation) ResetTitle() {
  10562. m.title = nil
  10563. }
  10564. // SetPhoto sets the "photo" field.
  10565. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  10566. m.photo = &s
  10567. }
  10568. // Photo returns the value of the "photo" field in the mutation.
  10569. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  10570. v := m.photo
  10571. if v == nil {
  10572. return
  10573. }
  10574. return *v, true
  10575. }
  10576. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  10577. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10579. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  10580. if !m.op.Is(OpUpdateOne) {
  10581. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  10582. }
  10583. if m.id == nil || m.oldValue == nil {
  10584. return v, errors.New("OldPhoto requires an ID field in the mutation")
  10585. }
  10586. oldValue, err := m.oldValue(ctx)
  10587. if err != nil {
  10588. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  10589. }
  10590. return oldValue.Photo, nil
  10591. }
  10592. // ResetPhoto resets all changes to the "photo" field.
  10593. func (m *EmployeeConfigMutation) ResetPhoto() {
  10594. m.photo = nil
  10595. }
  10596. // SetOrganizationID sets the "organization_id" field.
  10597. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  10598. m.organization_id = &u
  10599. m.addorganization_id = nil
  10600. }
  10601. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10602. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  10603. v := m.organization_id
  10604. if v == nil {
  10605. return
  10606. }
  10607. return *v, true
  10608. }
  10609. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  10610. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10612. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10613. if !m.op.Is(OpUpdateOne) {
  10614. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10615. }
  10616. if m.id == nil || m.oldValue == nil {
  10617. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10618. }
  10619. oldValue, err := m.oldValue(ctx)
  10620. if err != nil {
  10621. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10622. }
  10623. return oldValue.OrganizationID, nil
  10624. }
  10625. // AddOrganizationID adds u to the "organization_id" field.
  10626. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  10627. if m.addorganization_id != nil {
  10628. *m.addorganization_id += u
  10629. } else {
  10630. m.addorganization_id = &u
  10631. }
  10632. }
  10633. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10634. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  10635. v := m.addorganization_id
  10636. if v == nil {
  10637. return
  10638. }
  10639. return *v, true
  10640. }
  10641. // ClearOrganizationID clears the value of the "organization_id" field.
  10642. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  10643. m.organization_id = nil
  10644. m.addorganization_id = nil
  10645. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  10646. }
  10647. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10648. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  10649. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  10650. return ok
  10651. }
  10652. // ResetOrganizationID resets all changes to the "organization_id" field.
  10653. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  10654. m.organization_id = nil
  10655. m.addorganization_id = nil
  10656. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  10657. }
  10658. // Where appends a list predicates to the EmployeeConfigMutation builder.
  10659. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  10660. m.predicates = append(m.predicates, ps...)
  10661. }
  10662. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  10663. // users can use type-assertion to append predicates that do not depend on any generated package.
  10664. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  10665. p := make([]predicate.EmployeeConfig, len(ps))
  10666. for i := range ps {
  10667. p[i] = ps[i]
  10668. }
  10669. m.Where(p...)
  10670. }
  10671. // Op returns the operation name.
  10672. func (m *EmployeeConfigMutation) Op() Op {
  10673. return m.op
  10674. }
  10675. // SetOp allows setting the mutation operation.
  10676. func (m *EmployeeConfigMutation) SetOp(op Op) {
  10677. m.op = op
  10678. }
  10679. // Type returns the node type of this mutation (EmployeeConfig).
  10680. func (m *EmployeeConfigMutation) Type() string {
  10681. return m.typ
  10682. }
  10683. // Fields returns all fields that were changed during this mutation. Note that in
  10684. // order to get all numeric fields that were incremented/decremented, call
  10685. // AddedFields().
  10686. func (m *EmployeeConfigMutation) Fields() []string {
  10687. fields := make([]string, 0, 7)
  10688. if m.created_at != nil {
  10689. fields = append(fields, employeeconfig.FieldCreatedAt)
  10690. }
  10691. if m.updated_at != nil {
  10692. fields = append(fields, employeeconfig.FieldUpdatedAt)
  10693. }
  10694. if m.deleted_at != nil {
  10695. fields = append(fields, employeeconfig.FieldDeletedAt)
  10696. }
  10697. if m.stype != nil {
  10698. fields = append(fields, employeeconfig.FieldStype)
  10699. }
  10700. if m.title != nil {
  10701. fields = append(fields, employeeconfig.FieldTitle)
  10702. }
  10703. if m.photo != nil {
  10704. fields = append(fields, employeeconfig.FieldPhoto)
  10705. }
  10706. if m.organization_id != nil {
  10707. fields = append(fields, employeeconfig.FieldOrganizationID)
  10708. }
  10709. return fields
  10710. }
  10711. // Field returns the value of a field with the given name. The second boolean
  10712. // return value indicates that this field was not set, or was not defined in the
  10713. // schema.
  10714. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  10715. switch name {
  10716. case employeeconfig.FieldCreatedAt:
  10717. return m.CreatedAt()
  10718. case employeeconfig.FieldUpdatedAt:
  10719. return m.UpdatedAt()
  10720. case employeeconfig.FieldDeletedAt:
  10721. return m.DeletedAt()
  10722. case employeeconfig.FieldStype:
  10723. return m.Stype()
  10724. case employeeconfig.FieldTitle:
  10725. return m.Title()
  10726. case employeeconfig.FieldPhoto:
  10727. return m.Photo()
  10728. case employeeconfig.FieldOrganizationID:
  10729. return m.OrganizationID()
  10730. }
  10731. return nil, false
  10732. }
  10733. // OldField returns the old value of the field from the database. An error is
  10734. // returned if the mutation operation is not UpdateOne, or the query to the
  10735. // database failed.
  10736. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10737. switch name {
  10738. case employeeconfig.FieldCreatedAt:
  10739. return m.OldCreatedAt(ctx)
  10740. case employeeconfig.FieldUpdatedAt:
  10741. return m.OldUpdatedAt(ctx)
  10742. case employeeconfig.FieldDeletedAt:
  10743. return m.OldDeletedAt(ctx)
  10744. case employeeconfig.FieldStype:
  10745. return m.OldStype(ctx)
  10746. case employeeconfig.FieldTitle:
  10747. return m.OldTitle(ctx)
  10748. case employeeconfig.FieldPhoto:
  10749. return m.OldPhoto(ctx)
  10750. case employeeconfig.FieldOrganizationID:
  10751. return m.OldOrganizationID(ctx)
  10752. }
  10753. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  10754. }
  10755. // SetField sets the value of a field with the given name. It returns an error if
  10756. // the field is not defined in the schema, or if the type mismatched the field
  10757. // type.
  10758. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  10759. switch name {
  10760. case employeeconfig.FieldCreatedAt:
  10761. v, ok := value.(time.Time)
  10762. if !ok {
  10763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10764. }
  10765. m.SetCreatedAt(v)
  10766. return nil
  10767. case employeeconfig.FieldUpdatedAt:
  10768. v, ok := value.(time.Time)
  10769. if !ok {
  10770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10771. }
  10772. m.SetUpdatedAt(v)
  10773. return nil
  10774. case employeeconfig.FieldDeletedAt:
  10775. v, ok := value.(time.Time)
  10776. if !ok {
  10777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10778. }
  10779. m.SetDeletedAt(v)
  10780. return nil
  10781. case employeeconfig.FieldStype:
  10782. v, ok := value.(string)
  10783. if !ok {
  10784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10785. }
  10786. m.SetStype(v)
  10787. return nil
  10788. case employeeconfig.FieldTitle:
  10789. v, ok := value.(string)
  10790. if !ok {
  10791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10792. }
  10793. m.SetTitle(v)
  10794. return nil
  10795. case employeeconfig.FieldPhoto:
  10796. v, ok := value.(string)
  10797. if !ok {
  10798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10799. }
  10800. m.SetPhoto(v)
  10801. return nil
  10802. case employeeconfig.FieldOrganizationID:
  10803. v, ok := value.(uint64)
  10804. if !ok {
  10805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10806. }
  10807. m.SetOrganizationID(v)
  10808. return nil
  10809. }
  10810. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10811. }
  10812. // AddedFields returns all numeric fields that were incremented/decremented during
  10813. // this mutation.
  10814. func (m *EmployeeConfigMutation) AddedFields() []string {
  10815. var fields []string
  10816. if m.addorganization_id != nil {
  10817. fields = append(fields, employeeconfig.FieldOrganizationID)
  10818. }
  10819. return fields
  10820. }
  10821. // AddedField returns the numeric value that was incremented/decremented on a field
  10822. // with the given name. The second boolean return value indicates that this field
  10823. // was not set, or was not defined in the schema.
  10824. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  10825. switch name {
  10826. case employeeconfig.FieldOrganizationID:
  10827. return m.AddedOrganizationID()
  10828. }
  10829. return nil, false
  10830. }
  10831. // AddField adds the value to the field with the given name. It returns an error if
  10832. // the field is not defined in the schema, or if the type mismatched the field
  10833. // type.
  10834. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  10835. switch name {
  10836. case employeeconfig.FieldOrganizationID:
  10837. v, ok := value.(int64)
  10838. if !ok {
  10839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10840. }
  10841. m.AddOrganizationID(v)
  10842. return nil
  10843. }
  10844. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  10845. }
  10846. // ClearedFields returns all nullable fields that were cleared during this
  10847. // mutation.
  10848. func (m *EmployeeConfigMutation) ClearedFields() []string {
  10849. var fields []string
  10850. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  10851. fields = append(fields, employeeconfig.FieldDeletedAt)
  10852. }
  10853. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  10854. fields = append(fields, employeeconfig.FieldOrganizationID)
  10855. }
  10856. return fields
  10857. }
  10858. // FieldCleared returns a boolean indicating if a field with the given name was
  10859. // cleared in this mutation.
  10860. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  10861. _, ok := m.clearedFields[name]
  10862. return ok
  10863. }
  10864. // ClearField clears the value of the field with the given name. It returns an
  10865. // error if the field is not defined in the schema.
  10866. func (m *EmployeeConfigMutation) ClearField(name string) error {
  10867. switch name {
  10868. case employeeconfig.FieldDeletedAt:
  10869. m.ClearDeletedAt()
  10870. return nil
  10871. case employeeconfig.FieldOrganizationID:
  10872. m.ClearOrganizationID()
  10873. return nil
  10874. }
  10875. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  10876. }
  10877. // ResetField resets all changes in the mutation for the field with the given name.
  10878. // It returns an error if the field is not defined in the schema.
  10879. func (m *EmployeeConfigMutation) ResetField(name string) error {
  10880. switch name {
  10881. case employeeconfig.FieldCreatedAt:
  10882. m.ResetCreatedAt()
  10883. return nil
  10884. case employeeconfig.FieldUpdatedAt:
  10885. m.ResetUpdatedAt()
  10886. return nil
  10887. case employeeconfig.FieldDeletedAt:
  10888. m.ResetDeletedAt()
  10889. return nil
  10890. case employeeconfig.FieldStype:
  10891. m.ResetStype()
  10892. return nil
  10893. case employeeconfig.FieldTitle:
  10894. m.ResetTitle()
  10895. return nil
  10896. case employeeconfig.FieldPhoto:
  10897. m.ResetPhoto()
  10898. return nil
  10899. case employeeconfig.FieldOrganizationID:
  10900. m.ResetOrganizationID()
  10901. return nil
  10902. }
  10903. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10904. }
  10905. // AddedEdges returns all edge names that were set/added in this mutation.
  10906. func (m *EmployeeConfigMutation) AddedEdges() []string {
  10907. edges := make([]string, 0, 0)
  10908. return edges
  10909. }
  10910. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10911. // name in this mutation.
  10912. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  10913. return nil
  10914. }
  10915. // RemovedEdges returns all edge names that were removed in this mutation.
  10916. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  10917. edges := make([]string, 0, 0)
  10918. return edges
  10919. }
  10920. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10921. // the given name in this mutation.
  10922. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  10923. return nil
  10924. }
  10925. // ClearedEdges returns all edge names that were cleared in this mutation.
  10926. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  10927. edges := make([]string, 0, 0)
  10928. return edges
  10929. }
  10930. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10931. // was cleared in this mutation.
  10932. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  10933. return false
  10934. }
  10935. // ClearEdge clears the value of the edge with the given name. It returns an error
  10936. // if that edge is not defined in the schema.
  10937. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  10938. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  10939. }
  10940. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10941. // It returns an error if the edge is not defined in the schema.
  10942. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  10943. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  10944. }
  10945. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  10946. type LabelMutation struct {
  10947. config
  10948. op Op
  10949. typ string
  10950. id *uint64
  10951. created_at *time.Time
  10952. updated_at *time.Time
  10953. status *uint8
  10954. addstatus *int8
  10955. _type *int
  10956. add_type *int
  10957. name *string
  10958. from *int
  10959. addfrom *int
  10960. mode *int
  10961. addmode *int
  10962. conditions *string
  10963. organization_id *uint64
  10964. addorganization_id *int64
  10965. clearedFields map[string]struct{}
  10966. label_relationships map[uint64]struct{}
  10967. removedlabel_relationships map[uint64]struct{}
  10968. clearedlabel_relationships bool
  10969. done bool
  10970. oldValue func(context.Context) (*Label, error)
  10971. predicates []predicate.Label
  10972. }
  10973. var _ ent.Mutation = (*LabelMutation)(nil)
  10974. // labelOption allows management of the mutation configuration using functional options.
  10975. type labelOption func(*LabelMutation)
  10976. // newLabelMutation creates new mutation for the Label entity.
  10977. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  10978. m := &LabelMutation{
  10979. config: c,
  10980. op: op,
  10981. typ: TypeLabel,
  10982. clearedFields: make(map[string]struct{}),
  10983. }
  10984. for _, opt := range opts {
  10985. opt(m)
  10986. }
  10987. return m
  10988. }
  10989. // withLabelID sets the ID field of the mutation.
  10990. func withLabelID(id uint64) labelOption {
  10991. return func(m *LabelMutation) {
  10992. var (
  10993. err error
  10994. once sync.Once
  10995. value *Label
  10996. )
  10997. m.oldValue = func(ctx context.Context) (*Label, error) {
  10998. once.Do(func() {
  10999. if m.done {
  11000. err = errors.New("querying old values post mutation is not allowed")
  11001. } else {
  11002. value, err = m.Client().Label.Get(ctx, id)
  11003. }
  11004. })
  11005. return value, err
  11006. }
  11007. m.id = &id
  11008. }
  11009. }
  11010. // withLabel sets the old Label of the mutation.
  11011. func withLabel(node *Label) labelOption {
  11012. return func(m *LabelMutation) {
  11013. m.oldValue = func(context.Context) (*Label, error) {
  11014. return node, nil
  11015. }
  11016. m.id = &node.ID
  11017. }
  11018. }
  11019. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11020. // executed in a transaction (ent.Tx), a transactional client is returned.
  11021. func (m LabelMutation) Client() *Client {
  11022. client := &Client{config: m.config}
  11023. client.init()
  11024. return client
  11025. }
  11026. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11027. // it returns an error otherwise.
  11028. func (m LabelMutation) Tx() (*Tx, error) {
  11029. if _, ok := m.driver.(*txDriver); !ok {
  11030. return nil, errors.New("ent: mutation is not running in a transaction")
  11031. }
  11032. tx := &Tx{config: m.config}
  11033. tx.init()
  11034. return tx, nil
  11035. }
  11036. // SetID sets the value of the id field. Note that this
  11037. // operation is only accepted on creation of Label entities.
  11038. func (m *LabelMutation) SetID(id uint64) {
  11039. m.id = &id
  11040. }
  11041. // ID returns the ID value in the mutation. Note that the ID is only available
  11042. // if it was provided to the builder or after it was returned from the database.
  11043. func (m *LabelMutation) ID() (id uint64, exists bool) {
  11044. if m.id == nil {
  11045. return
  11046. }
  11047. return *m.id, true
  11048. }
  11049. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11050. // That means, if the mutation is applied within a transaction with an isolation level such
  11051. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11052. // or updated by the mutation.
  11053. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  11054. switch {
  11055. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11056. id, exists := m.ID()
  11057. if exists {
  11058. return []uint64{id}, nil
  11059. }
  11060. fallthrough
  11061. case m.op.Is(OpUpdate | OpDelete):
  11062. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  11063. default:
  11064. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11065. }
  11066. }
  11067. // SetCreatedAt sets the "created_at" field.
  11068. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  11069. m.created_at = &t
  11070. }
  11071. // CreatedAt returns the value of the "created_at" field in the mutation.
  11072. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  11073. v := m.created_at
  11074. if v == nil {
  11075. return
  11076. }
  11077. return *v, true
  11078. }
  11079. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  11080. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11082. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11083. if !m.op.Is(OpUpdateOne) {
  11084. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11085. }
  11086. if m.id == nil || m.oldValue == nil {
  11087. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11088. }
  11089. oldValue, err := m.oldValue(ctx)
  11090. if err != nil {
  11091. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11092. }
  11093. return oldValue.CreatedAt, nil
  11094. }
  11095. // ResetCreatedAt resets all changes to the "created_at" field.
  11096. func (m *LabelMutation) ResetCreatedAt() {
  11097. m.created_at = nil
  11098. }
  11099. // SetUpdatedAt sets the "updated_at" field.
  11100. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  11101. m.updated_at = &t
  11102. }
  11103. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11104. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  11105. v := m.updated_at
  11106. if v == nil {
  11107. return
  11108. }
  11109. return *v, true
  11110. }
  11111. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  11112. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11114. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11115. if !m.op.Is(OpUpdateOne) {
  11116. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11117. }
  11118. if m.id == nil || m.oldValue == nil {
  11119. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11120. }
  11121. oldValue, err := m.oldValue(ctx)
  11122. if err != nil {
  11123. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11124. }
  11125. return oldValue.UpdatedAt, nil
  11126. }
  11127. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11128. func (m *LabelMutation) ResetUpdatedAt() {
  11129. m.updated_at = nil
  11130. }
  11131. // SetStatus sets the "status" field.
  11132. func (m *LabelMutation) SetStatus(u uint8) {
  11133. m.status = &u
  11134. m.addstatus = nil
  11135. }
  11136. // Status returns the value of the "status" field in the mutation.
  11137. func (m *LabelMutation) Status() (r uint8, exists bool) {
  11138. v := m.status
  11139. if v == nil {
  11140. return
  11141. }
  11142. return *v, true
  11143. }
  11144. // OldStatus returns the old "status" field's value of the Label entity.
  11145. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11147. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11148. if !m.op.Is(OpUpdateOne) {
  11149. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11150. }
  11151. if m.id == nil || m.oldValue == nil {
  11152. return v, errors.New("OldStatus requires an ID field in the mutation")
  11153. }
  11154. oldValue, err := m.oldValue(ctx)
  11155. if err != nil {
  11156. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11157. }
  11158. return oldValue.Status, nil
  11159. }
  11160. // AddStatus adds u to the "status" field.
  11161. func (m *LabelMutation) AddStatus(u int8) {
  11162. if m.addstatus != nil {
  11163. *m.addstatus += u
  11164. } else {
  11165. m.addstatus = &u
  11166. }
  11167. }
  11168. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11169. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  11170. v := m.addstatus
  11171. if v == nil {
  11172. return
  11173. }
  11174. return *v, true
  11175. }
  11176. // ClearStatus clears the value of the "status" field.
  11177. func (m *LabelMutation) ClearStatus() {
  11178. m.status = nil
  11179. m.addstatus = nil
  11180. m.clearedFields[label.FieldStatus] = struct{}{}
  11181. }
  11182. // StatusCleared returns if the "status" field was cleared in this mutation.
  11183. func (m *LabelMutation) StatusCleared() bool {
  11184. _, ok := m.clearedFields[label.FieldStatus]
  11185. return ok
  11186. }
  11187. // ResetStatus resets all changes to the "status" field.
  11188. func (m *LabelMutation) ResetStatus() {
  11189. m.status = nil
  11190. m.addstatus = nil
  11191. delete(m.clearedFields, label.FieldStatus)
  11192. }
  11193. // SetType sets the "type" field.
  11194. func (m *LabelMutation) SetType(i int) {
  11195. m._type = &i
  11196. m.add_type = nil
  11197. }
  11198. // GetType returns the value of the "type" field in the mutation.
  11199. func (m *LabelMutation) GetType() (r int, exists bool) {
  11200. v := m._type
  11201. if v == nil {
  11202. return
  11203. }
  11204. return *v, true
  11205. }
  11206. // OldType returns the old "type" field's value of the Label entity.
  11207. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11209. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  11210. if !m.op.Is(OpUpdateOne) {
  11211. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11212. }
  11213. if m.id == nil || m.oldValue == nil {
  11214. return v, errors.New("OldType requires an ID field in the mutation")
  11215. }
  11216. oldValue, err := m.oldValue(ctx)
  11217. if err != nil {
  11218. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11219. }
  11220. return oldValue.Type, nil
  11221. }
  11222. // AddType adds i to the "type" field.
  11223. func (m *LabelMutation) AddType(i int) {
  11224. if m.add_type != nil {
  11225. *m.add_type += i
  11226. } else {
  11227. m.add_type = &i
  11228. }
  11229. }
  11230. // AddedType returns the value that was added to the "type" field in this mutation.
  11231. func (m *LabelMutation) AddedType() (r int, exists bool) {
  11232. v := m.add_type
  11233. if v == nil {
  11234. return
  11235. }
  11236. return *v, true
  11237. }
  11238. // ResetType resets all changes to the "type" field.
  11239. func (m *LabelMutation) ResetType() {
  11240. m._type = nil
  11241. m.add_type = nil
  11242. }
  11243. // SetName sets the "name" field.
  11244. func (m *LabelMutation) SetName(s string) {
  11245. m.name = &s
  11246. }
  11247. // Name returns the value of the "name" field in the mutation.
  11248. func (m *LabelMutation) Name() (r string, exists bool) {
  11249. v := m.name
  11250. if v == nil {
  11251. return
  11252. }
  11253. return *v, true
  11254. }
  11255. // OldName returns the old "name" field's value of the Label entity.
  11256. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11258. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  11259. if !m.op.Is(OpUpdateOne) {
  11260. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11261. }
  11262. if m.id == nil || m.oldValue == nil {
  11263. return v, errors.New("OldName requires an ID field in the mutation")
  11264. }
  11265. oldValue, err := m.oldValue(ctx)
  11266. if err != nil {
  11267. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11268. }
  11269. return oldValue.Name, nil
  11270. }
  11271. // ResetName resets all changes to the "name" field.
  11272. func (m *LabelMutation) ResetName() {
  11273. m.name = nil
  11274. }
  11275. // SetFrom sets the "from" field.
  11276. func (m *LabelMutation) SetFrom(i int) {
  11277. m.from = &i
  11278. m.addfrom = nil
  11279. }
  11280. // From returns the value of the "from" field in the mutation.
  11281. func (m *LabelMutation) From() (r int, exists bool) {
  11282. v := m.from
  11283. if v == nil {
  11284. return
  11285. }
  11286. return *v, true
  11287. }
  11288. // OldFrom returns the old "from" field's value of the Label entity.
  11289. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11291. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  11292. if !m.op.Is(OpUpdateOne) {
  11293. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  11294. }
  11295. if m.id == nil || m.oldValue == nil {
  11296. return v, errors.New("OldFrom requires an ID field in the mutation")
  11297. }
  11298. oldValue, err := m.oldValue(ctx)
  11299. if err != nil {
  11300. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  11301. }
  11302. return oldValue.From, nil
  11303. }
  11304. // AddFrom adds i to the "from" field.
  11305. func (m *LabelMutation) AddFrom(i int) {
  11306. if m.addfrom != nil {
  11307. *m.addfrom += i
  11308. } else {
  11309. m.addfrom = &i
  11310. }
  11311. }
  11312. // AddedFrom returns the value that was added to the "from" field in this mutation.
  11313. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  11314. v := m.addfrom
  11315. if v == nil {
  11316. return
  11317. }
  11318. return *v, true
  11319. }
  11320. // ResetFrom resets all changes to the "from" field.
  11321. func (m *LabelMutation) ResetFrom() {
  11322. m.from = nil
  11323. m.addfrom = nil
  11324. }
  11325. // SetMode sets the "mode" field.
  11326. func (m *LabelMutation) SetMode(i int) {
  11327. m.mode = &i
  11328. m.addmode = nil
  11329. }
  11330. // Mode returns the value of the "mode" field in the mutation.
  11331. func (m *LabelMutation) Mode() (r int, exists bool) {
  11332. v := m.mode
  11333. if v == nil {
  11334. return
  11335. }
  11336. return *v, true
  11337. }
  11338. // OldMode returns the old "mode" field's value of the Label entity.
  11339. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11341. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  11342. if !m.op.Is(OpUpdateOne) {
  11343. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  11344. }
  11345. if m.id == nil || m.oldValue == nil {
  11346. return v, errors.New("OldMode requires an ID field in the mutation")
  11347. }
  11348. oldValue, err := m.oldValue(ctx)
  11349. if err != nil {
  11350. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  11351. }
  11352. return oldValue.Mode, nil
  11353. }
  11354. // AddMode adds i to the "mode" field.
  11355. func (m *LabelMutation) AddMode(i int) {
  11356. if m.addmode != nil {
  11357. *m.addmode += i
  11358. } else {
  11359. m.addmode = &i
  11360. }
  11361. }
  11362. // AddedMode returns the value that was added to the "mode" field in this mutation.
  11363. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  11364. v := m.addmode
  11365. if v == nil {
  11366. return
  11367. }
  11368. return *v, true
  11369. }
  11370. // ResetMode resets all changes to the "mode" field.
  11371. func (m *LabelMutation) ResetMode() {
  11372. m.mode = nil
  11373. m.addmode = nil
  11374. }
  11375. // SetConditions sets the "conditions" field.
  11376. func (m *LabelMutation) SetConditions(s string) {
  11377. m.conditions = &s
  11378. }
  11379. // Conditions returns the value of the "conditions" field in the mutation.
  11380. func (m *LabelMutation) Conditions() (r string, exists bool) {
  11381. v := m.conditions
  11382. if v == nil {
  11383. return
  11384. }
  11385. return *v, true
  11386. }
  11387. // OldConditions returns the old "conditions" field's value of the Label entity.
  11388. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11390. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  11391. if !m.op.Is(OpUpdateOne) {
  11392. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  11393. }
  11394. if m.id == nil || m.oldValue == nil {
  11395. return v, errors.New("OldConditions requires an ID field in the mutation")
  11396. }
  11397. oldValue, err := m.oldValue(ctx)
  11398. if err != nil {
  11399. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  11400. }
  11401. return oldValue.Conditions, nil
  11402. }
  11403. // ClearConditions clears the value of the "conditions" field.
  11404. func (m *LabelMutation) ClearConditions() {
  11405. m.conditions = nil
  11406. m.clearedFields[label.FieldConditions] = struct{}{}
  11407. }
  11408. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  11409. func (m *LabelMutation) ConditionsCleared() bool {
  11410. _, ok := m.clearedFields[label.FieldConditions]
  11411. return ok
  11412. }
  11413. // ResetConditions resets all changes to the "conditions" field.
  11414. func (m *LabelMutation) ResetConditions() {
  11415. m.conditions = nil
  11416. delete(m.clearedFields, label.FieldConditions)
  11417. }
  11418. // SetOrganizationID sets the "organization_id" field.
  11419. func (m *LabelMutation) SetOrganizationID(u uint64) {
  11420. m.organization_id = &u
  11421. m.addorganization_id = nil
  11422. }
  11423. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11424. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  11425. v := m.organization_id
  11426. if v == nil {
  11427. return
  11428. }
  11429. return *v, true
  11430. }
  11431. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  11432. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11434. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11435. if !m.op.Is(OpUpdateOne) {
  11436. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11437. }
  11438. if m.id == nil || m.oldValue == nil {
  11439. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11440. }
  11441. oldValue, err := m.oldValue(ctx)
  11442. if err != nil {
  11443. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11444. }
  11445. return oldValue.OrganizationID, nil
  11446. }
  11447. // AddOrganizationID adds u to the "organization_id" field.
  11448. func (m *LabelMutation) AddOrganizationID(u int64) {
  11449. if m.addorganization_id != nil {
  11450. *m.addorganization_id += u
  11451. } else {
  11452. m.addorganization_id = &u
  11453. }
  11454. }
  11455. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11456. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  11457. v := m.addorganization_id
  11458. if v == nil {
  11459. return
  11460. }
  11461. return *v, true
  11462. }
  11463. // ClearOrganizationID clears the value of the "organization_id" field.
  11464. func (m *LabelMutation) ClearOrganizationID() {
  11465. m.organization_id = nil
  11466. m.addorganization_id = nil
  11467. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  11468. }
  11469. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11470. func (m *LabelMutation) OrganizationIDCleared() bool {
  11471. _, ok := m.clearedFields[label.FieldOrganizationID]
  11472. return ok
  11473. }
  11474. // ResetOrganizationID resets all changes to the "organization_id" field.
  11475. func (m *LabelMutation) ResetOrganizationID() {
  11476. m.organization_id = nil
  11477. m.addorganization_id = nil
  11478. delete(m.clearedFields, label.FieldOrganizationID)
  11479. }
  11480. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  11481. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  11482. if m.label_relationships == nil {
  11483. m.label_relationships = make(map[uint64]struct{})
  11484. }
  11485. for i := range ids {
  11486. m.label_relationships[ids[i]] = struct{}{}
  11487. }
  11488. }
  11489. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  11490. func (m *LabelMutation) ClearLabelRelationships() {
  11491. m.clearedlabel_relationships = true
  11492. }
  11493. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  11494. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  11495. return m.clearedlabel_relationships
  11496. }
  11497. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  11498. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  11499. if m.removedlabel_relationships == nil {
  11500. m.removedlabel_relationships = make(map[uint64]struct{})
  11501. }
  11502. for i := range ids {
  11503. delete(m.label_relationships, ids[i])
  11504. m.removedlabel_relationships[ids[i]] = struct{}{}
  11505. }
  11506. }
  11507. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  11508. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  11509. for id := range m.removedlabel_relationships {
  11510. ids = append(ids, id)
  11511. }
  11512. return
  11513. }
  11514. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  11515. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  11516. for id := range m.label_relationships {
  11517. ids = append(ids, id)
  11518. }
  11519. return
  11520. }
  11521. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  11522. func (m *LabelMutation) ResetLabelRelationships() {
  11523. m.label_relationships = nil
  11524. m.clearedlabel_relationships = false
  11525. m.removedlabel_relationships = nil
  11526. }
  11527. // Where appends a list predicates to the LabelMutation builder.
  11528. func (m *LabelMutation) Where(ps ...predicate.Label) {
  11529. m.predicates = append(m.predicates, ps...)
  11530. }
  11531. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  11532. // users can use type-assertion to append predicates that do not depend on any generated package.
  11533. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  11534. p := make([]predicate.Label, len(ps))
  11535. for i := range ps {
  11536. p[i] = ps[i]
  11537. }
  11538. m.Where(p...)
  11539. }
  11540. // Op returns the operation name.
  11541. func (m *LabelMutation) Op() Op {
  11542. return m.op
  11543. }
  11544. // SetOp allows setting the mutation operation.
  11545. func (m *LabelMutation) SetOp(op Op) {
  11546. m.op = op
  11547. }
  11548. // Type returns the node type of this mutation (Label).
  11549. func (m *LabelMutation) Type() string {
  11550. return m.typ
  11551. }
  11552. // Fields returns all fields that were changed during this mutation. Note that in
  11553. // order to get all numeric fields that were incremented/decremented, call
  11554. // AddedFields().
  11555. func (m *LabelMutation) Fields() []string {
  11556. fields := make([]string, 0, 9)
  11557. if m.created_at != nil {
  11558. fields = append(fields, label.FieldCreatedAt)
  11559. }
  11560. if m.updated_at != nil {
  11561. fields = append(fields, label.FieldUpdatedAt)
  11562. }
  11563. if m.status != nil {
  11564. fields = append(fields, label.FieldStatus)
  11565. }
  11566. if m._type != nil {
  11567. fields = append(fields, label.FieldType)
  11568. }
  11569. if m.name != nil {
  11570. fields = append(fields, label.FieldName)
  11571. }
  11572. if m.from != nil {
  11573. fields = append(fields, label.FieldFrom)
  11574. }
  11575. if m.mode != nil {
  11576. fields = append(fields, label.FieldMode)
  11577. }
  11578. if m.conditions != nil {
  11579. fields = append(fields, label.FieldConditions)
  11580. }
  11581. if m.organization_id != nil {
  11582. fields = append(fields, label.FieldOrganizationID)
  11583. }
  11584. return fields
  11585. }
  11586. // Field returns the value of a field with the given name. The second boolean
  11587. // return value indicates that this field was not set, or was not defined in the
  11588. // schema.
  11589. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  11590. switch name {
  11591. case label.FieldCreatedAt:
  11592. return m.CreatedAt()
  11593. case label.FieldUpdatedAt:
  11594. return m.UpdatedAt()
  11595. case label.FieldStatus:
  11596. return m.Status()
  11597. case label.FieldType:
  11598. return m.GetType()
  11599. case label.FieldName:
  11600. return m.Name()
  11601. case label.FieldFrom:
  11602. return m.From()
  11603. case label.FieldMode:
  11604. return m.Mode()
  11605. case label.FieldConditions:
  11606. return m.Conditions()
  11607. case label.FieldOrganizationID:
  11608. return m.OrganizationID()
  11609. }
  11610. return nil, false
  11611. }
  11612. // OldField returns the old value of the field from the database. An error is
  11613. // returned if the mutation operation is not UpdateOne, or the query to the
  11614. // database failed.
  11615. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11616. switch name {
  11617. case label.FieldCreatedAt:
  11618. return m.OldCreatedAt(ctx)
  11619. case label.FieldUpdatedAt:
  11620. return m.OldUpdatedAt(ctx)
  11621. case label.FieldStatus:
  11622. return m.OldStatus(ctx)
  11623. case label.FieldType:
  11624. return m.OldType(ctx)
  11625. case label.FieldName:
  11626. return m.OldName(ctx)
  11627. case label.FieldFrom:
  11628. return m.OldFrom(ctx)
  11629. case label.FieldMode:
  11630. return m.OldMode(ctx)
  11631. case label.FieldConditions:
  11632. return m.OldConditions(ctx)
  11633. case label.FieldOrganizationID:
  11634. return m.OldOrganizationID(ctx)
  11635. }
  11636. return nil, fmt.Errorf("unknown Label field %s", name)
  11637. }
  11638. // SetField sets the value of a field with the given name. It returns an error if
  11639. // the field is not defined in the schema, or if the type mismatched the field
  11640. // type.
  11641. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  11642. switch name {
  11643. case label.FieldCreatedAt:
  11644. v, ok := value.(time.Time)
  11645. if !ok {
  11646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11647. }
  11648. m.SetCreatedAt(v)
  11649. return nil
  11650. case label.FieldUpdatedAt:
  11651. v, ok := value.(time.Time)
  11652. if !ok {
  11653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11654. }
  11655. m.SetUpdatedAt(v)
  11656. return nil
  11657. case label.FieldStatus:
  11658. v, ok := value.(uint8)
  11659. if !ok {
  11660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11661. }
  11662. m.SetStatus(v)
  11663. return nil
  11664. case label.FieldType:
  11665. v, ok := value.(int)
  11666. if !ok {
  11667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11668. }
  11669. m.SetType(v)
  11670. return nil
  11671. case label.FieldName:
  11672. v, ok := value.(string)
  11673. if !ok {
  11674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11675. }
  11676. m.SetName(v)
  11677. return nil
  11678. case label.FieldFrom:
  11679. v, ok := value.(int)
  11680. if !ok {
  11681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11682. }
  11683. m.SetFrom(v)
  11684. return nil
  11685. case label.FieldMode:
  11686. v, ok := value.(int)
  11687. if !ok {
  11688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11689. }
  11690. m.SetMode(v)
  11691. return nil
  11692. case label.FieldConditions:
  11693. v, ok := value.(string)
  11694. if !ok {
  11695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11696. }
  11697. m.SetConditions(v)
  11698. return nil
  11699. case label.FieldOrganizationID:
  11700. v, ok := value.(uint64)
  11701. if !ok {
  11702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11703. }
  11704. m.SetOrganizationID(v)
  11705. return nil
  11706. }
  11707. return fmt.Errorf("unknown Label field %s", name)
  11708. }
  11709. // AddedFields returns all numeric fields that were incremented/decremented during
  11710. // this mutation.
  11711. func (m *LabelMutation) AddedFields() []string {
  11712. var fields []string
  11713. if m.addstatus != nil {
  11714. fields = append(fields, label.FieldStatus)
  11715. }
  11716. if m.add_type != nil {
  11717. fields = append(fields, label.FieldType)
  11718. }
  11719. if m.addfrom != nil {
  11720. fields = append(fields, label.FieldFrom)
  11721. }
  11722. if m.addmode != nil {
  11723. fields = append(fields, label.FieldMode)
  11724. }
  11725. if m.addorganization_id != nil {
  11726. fields = append(fields, label.FieldOrganizationID)
  11727. }
  11728. return fields
  11729. }
  11730. // AddedField returns the numeric value that was incremented/decremented on a field
  11731. // with the given name. The second boolean return value indicates that this field
  11732. // was not set, or was not defined in the schema.
  11733. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  11734. switch name {
  11735. case label.FieldStatus:
  11736. return m.AddedStatus()
  11737. case label.FieldType:
  11738. return m.AddedType()
  11739. case label.FieldFrom:
  11740. return m.AddedFrom()
  11741. case label.FieldMode:
  11742. return m.AddedMode()
  11743. case label.FieldOrganizationID:
  11744. return m.AddedOrganizationID()
  11745. }
  11746. return nil, false
  11747. }
  11748. // AddField adds the value to the field with the given name. It returns an error if
  11749. // the field is not defined in the schema, or if the type mismatched the field
  11750. // type.
  11751. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  11752. switch name {
  11753. case label.FieldStatus:
  11754. v, ok := value.(int8)
  11755. if !ok {
  11756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11757. }
  11758. m.AddStatus(v)
  11759. return nil
  11760. case label.FieldType:
  11761. v, ok := value.(int)
  11762. if !ok {
  11763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11764. }
  11765. m.AddType(v)
  11766. return nil
  11767. case label.FieldFrom:
  11768. v, ok := value.(int)
  11769. if !ok {
  11770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11771. }
  11772. m.AddFrom(v)
  11773. return nil
  11774. case label.FieldMode:
  11775. v, ok := value.(int)
  11776. if !ok {
  11777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11778. }
  11779. m.AddMode(v)
  11780. return nil
  11781. case label.FieldOrganizationID:
  11782. v, ok := value.(int64)
  11783. if !ok {
  11784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11785. }
  11786. m.AddOrganizationID(v)
  11787. return nil
  11788. }
  11789. return fmt.Errorf("unknown Label numeric field %s", name)
  11790. }
  11791. // ClearedFields returns all nullable fields that were cleared during this
  11792. // mutation.
  11793. func (m *LabelMutation) ClearedFields() []string {
  11794. var fields []string
  11795. if m.FieldCleared(label.FieldStatus) {
  11796. fields = append(fields, label.FieldStatus)
  11797. }
  11798. if m.FieldCleared(label.FieldConditions) {
  11799. fields = append(fields, label.FieldConditions)
  11800. }
  11801. if m.FieldCleared(label.FieldOrganizationID) {
  11802. fields = append(fields, label.FieldOrganizationID)
  11803. }
  11804. return fields
  11805. }
  11806. // FieldCleared returns a boolean indicating if a field with the given name was
  11807. // cleared in this mutation.
  11808. func (m *LabelMutation) FieldCleared(name string) bool {
  11809. _, ok := m.clearedFields[name]
  11810. return ok
  11811. }
  11812. // ClearField clears the value of the field with the given name. It returns an
  11813. // error if the field is not defined in the schema.
  11814. func (m *LabelMutation) ClearField(name string) error {
  11815. switch name {
  11816. case label.FieldStatus:
  11817. m.ClearStatus()
  11818. return nil
  11819. case label.FieldConditions:
  11820. m.ClearConditions()
  11821. return nil
  11822. case label.FieldOrganizationID:
  11823. m.ClearOrganizationID()
  11824. return nil
  11825. }
  11826. return fmt.Errorf("unknown Label nullable field %s", name)
  11827. }
  11828. // ResetField resets all changes in the mutation for the field with the given name.
  11829. // It returns an error if the field is not defined in the schema.
  11830. func (m *LabelMutation) ResetField(name string) error {
  11831. switch name {
  11832. case label.FieldCreatedAt:
  11833. m.ResetCreatedAt()
  11834. return nil
  11835. case label.FieldUpdatedAt:
  11836. m.ResetUpdatedAt()
  11837. return nil
  11838. case label.FieldStatus:
  11839. m.ResetStatus()
  11840. return nil
  11841. case label.FieldType:
  11842. m.ResetType()
  11843. return nil
  11844. case label.FieldName:
  11845. m.ResetName()
  11846. return nil
  11847. case label.FieldFrom:
  11848. m.ResetFrom()
  11849. return nil
  11850. case label.FieldMode:
  11851. m.ResetMode()
  11852. return nil
  11853. case label.FieldConditions:
  11854. m.ResetConditions()
  11855. return nil
  11856. case label.FieldOrganizationID:
  11857. m.ResetOrganizationID()
  11858. return nil
  11859. }
  11860. return fmt.Errorf("unknown Label field %s", name)
  11861. }
  11862. // AddedEdges returns all edge names that were set/added in this mutation.
  11863. func (m *LabelMutation) AddedEdges() []string {
  11864. edges := make([]string, 0, 1)
  11865. if m.label_relationships != nil {
  11866. edges = append(edges, label.EdgeLabelRelationships)
  11867. }
  11868. return edges
  11869. }
  11870. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11871. // name in this mutation.
  11872. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  11873. switch name {
  11874. case label.EdgeLabelRelationships:
  11875. ids := make([]ent.Value, 0, len(m.label_relationships))
  11876. for id := range m.label_relationships {
  11877. ids = append(ids, id)
  11878. }
  11879. return ids
  11880. }
  11881. return nil
  11882. }
  11883. // RemovedEdges returns all edge names that were removed in this mutation.
  11884. func (m *LabelMutation) RemovedEdges() []string {
  11885. edges := make([]string, 0, 1)
  11886. if m.removedlabel_relationships != nil {
  11887. edges = append(edges, label.EdgeLabelRelationships)
  11888. }
  11889. return edges
  11890. }
  11891. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11892. // the given name in this mutation.
  11893. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  11894. switch name {
  11895. case label.EdgeLabelRelationships:
  11896. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  11897. for id := range m.removedlabel_relationships {
  11898. ids = append(ids, id)
  11899. }
  11900. return ids
  11901. }
  11902. return nil
  11903. }
  11904. // ClearedEdges returns all edge names that were cleared in this mutation.
  11905. func (m *LabelMutation) ClearedEdges() []string {
  11906. edges := make([]string, 0, 1)
  11907. if m.clearedlabel_relationships {
  11908. edges = append(edges, label.EdgeLabelRelationships)
  11909. }
  11910. return edges
  11911. }
  11912. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11913. // was cleared in this mutation.
  11914. func (m *LabelMutation) EdgeCleared(name string) bool {
  11915. switch name {
  11916. case label.EdgeLabelRelationships:
  11917. return m.clearedlabel_relationships
  11918. }
  11919. return false
  11920. }
  11921. // ClearEdge clears the value of the edge with the given name. It returns an error
  11922. // if that edge is not defined in the schema.
  11923. func (m *LabelMutation) ClearEdge(name string) error {
  11924. switch name {
  11925. }
  11926. return fmt.Errorf("unknown Label unique edge %s", name)
  11927. }
  11928. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11929. // It returns an error if the edge is not defined in the schema.
  11930. func (m *LabelMutation) ResetEdge(name string) error {
  11931. switch name {
  11932. case label.EdgeLabelRelationships:
  11933. m.ResetLabelRelationships()
  11934. return nil
  11935. }
  11936. return fmt.Errorf("unknown Label edge %s", name)
  11937. }
  11938. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  11939. type LabelRelationshipMutation struct {
  11940. config
  11941. op Op
  11942. typ string
  11943. id *uint64
  11944. created_at *time.Time
  11945. updated_at *time.Time
  11946. status *uint8
  11947. addstatus *int8
  11948. deleted_at *time.Time
  11949. organization_id *uint64
  11950. addorganization_id *int64
  11951. clearedFields map[string]struct{}
  11952. contacts *uint64
  11953. clearedcontacts bool
  11954. labels *uint64
  11955. clearedlabels bool
  11956. done bool
  11957. oldValue func(context.Context) (*LabelRelationship, error)
  11958. predicates []predicate.LabelRelationship
  11959. }
  11960. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  11961. // labelrelationshipOption allows management of the mutation configuration using functional options.
  11962. type labelrelationshipOption func(*LabelRelationshipMutation)
  11963. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  11964. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  11965. m := &LabelRelationshipMutation{
  11966. config: c,
  11967. op: op,
  11968. typ: TypeLabelRelationship,
  11969. clearedFields: make(map[string]struct{}),
  11970. }
  11971. for _, opt := range opts {
  11972. opt(m)
  11973. }
  11974. return m
  11975. }
  11976. // withLabelRelationshipID sets the ID field of the mutation.
  11977. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  11978. return func(m *LabelRelationshipMutation) {
  11979. var (
  11980. err error
  11981. once sync.Once
  11982. value *LabelRelationship
  11983. )
  11984. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  11985. once.Do(func() {
  11986. if m.done {
  11987. err = errors.New("querying old values post mutation is not allowed")
  11988. } else {
  11989. value, err = m.Client().LabelRelationship.Get(ctx, id)
  11990. }
  11991. })
  11992. return value, err
  11993. }
  11994. m.id = &id
  11995. }
  11996. }
  11997. // withLabelRelationship sets the old LabelRelationship of the mutation.
  11998. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  11999. return func(m *LabelRelationshipMutation) {
  12000. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  12001. return node, nil
  12002. }
  12003. m.id = &node.ID
  12004. }
  12005. }
  12006. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12007. // executed in a transaction (ent.Tx), a transactional client is returned.
  12008. func (m LabelRelationshipMutation) Client() *Client {
  12009. client := &Client{config: m.config}
  12010. client.init()
  12011. return client
  12012. }
  12013. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12014. // it returns an error otherwise.
  12015. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  12016. if _, ok := m.driver.(*txDriver); !ok {
  12017. return nil, errors.New("ent: mutation is not running in a transaction")
  12018. }
  12019. tx := &Tx{config: m.config}
  12020. tx.init()
  12021. return tx, nil
  12022. }
  12023. // SetID sets the value of the id field. Note that this
  12024. // operation is only accepted on creation of LabelRelationship entities.
  12025. func (m *LabelRelationshipMutation) SetID(id uint64) {
  12026. m.id = &id
  12027. }
  12028. // ID returns the ID value in the mutation. Note that the ID is only available
  12029. // if it was provided to the builder or after it was returned from the database.
  12030. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  12031. if m.id == nil {
  12032. return
  12033. }
  12034. return *m.id, true
  12035. }
  12036. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12037. // That means, if the mutation is applied within a transaction with an isolation level such
  12038. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12039. // or updated by the mutation.
  12040. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  12041. switch {
  12042. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12043. id, exists := m.ID()
  12044. if exists {
  12045. return []uint64{id}, nil
  12046. }
  12047. fallthrough
  12048. case m.op.Is(OpUpdate | OpDelete):
  12049. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  12050. default:
  12051. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12052. }
  12053. }
  12054. // SetCreatedAt sets the "created_at" field.
  12055. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  12056. m.created_at = &t
  12057. }
  12058. // CreatedAt returns the value of the "created_at" field in the mutation.
  12059. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  12060. v := m.created_at
  12061. if v == nil {
  12062. return
  12063. }
  12064. return *v, true
  12065. }
  12066. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  12067. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12069. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12070. if !m.op.Is(OpUpdateOne) {
  12071. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12072. }
  12073. if m.id == nil || m.oldValue == nil {
  12074. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12075. }
  12076. oldValue, err := m.oldValue(ctx)
  12077. if err != nil {
  12078. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12079. }
  12080. return oldValue.CreatedAt, nil
  12081. }
  12082. // ResetCreatedAt resets all changes to the "created_at" field.
  12083. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  12084. m.created_at = nil
  12085. }
  12086. // SetUpdatedAt sets the "updated_at" field.
  12087. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  12088. m.updated_at = &t
  12089. }
  12090. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12091. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  12092. v := m.updated_at
  12093. if v == nil {
  12094. return
  12095. }
  12096. return *v, true
  12097. }
  12098. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  12099. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12101. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12102. if !m.op.Is(OpUpdateOne) {
  12103. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12104. }
  12105. if m.id == nil || m.oldValue == nil {
  12106. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12107. }
  12108. oldValue, err := m.oldValue(ctx)
  12109. if err != nil {
  12110. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12111. }
  12112. return oldValue.UpdatedAt, nil
  12113. }
  12114. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12115. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  12116. m.updated_at = nil
  12117. }
  12118. // SetStatus sets the "status" field.
  12119. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  12120. m.status = &u
  12121. m.addstatus = nil
  12122. }
  12123. // Status returns the value of the "status" field in the mutation.
  12124. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  12125. v := m.status
  12126. if v == nil {
  12127. return
  12128. }
  12129. return *v, true
  12130. }
  12131. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  12132. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12134. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12135. if !m.op.Is(OpUpdateOne) {
  12136. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12137. }
  12138. if m.id == nil || m.oldValue == nil {
  12139. return v, errors.New("OldStatus requires an ID field in the mutation")
  12140. }
  12141. oldValue, err := m.oldValue(ctx)
  12142. if err != nil {
  12143. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12144. }
  12145. return oldValue.Status, nil
  12146. }
  12147. // AddStatus adds u to the "status" field.
  12148. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  12149. if m.addstatus != nil {
  12150. *m.addstatus += u
  12151. } else {
  12152. m.addstatus = &u
  12153. }
  12154. }
  12155. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12156. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  12157. v := m.addstatus
  12158. if v == nil {
  12159. return
  12160. }
  12161. return *v, true
  12162. }
  12163. // ClearStatus clears the value of the "status" field.
  12164. func (m *LabelRelationshipMutation) ClearStatus() {
  12165. m.status = nil
  12166. m.addstatus = nil
  12167. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  12168. }
  12169. // StatusCleared returns if the "status" field was cleared in this mutation.
  12170. func (m *LabelRelationshipMutation) StatusCleared() bool {
  12171. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  12172. return ok
  12173. }
  12174. // ResetStatus resets all changes to the "status" field.
  12175. func (m *LabelRelationshipMutation) ResetStatus() {
  12176. m.status = nil
  12177. m.addstatus = nil
  12178. delete(m.clearedFields, labelrelationship.FieldStatus)
  12179. }
  12180. // SetDeletedAt sets the "deleted_at" field.
  12181. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  12182. m.deleted_at = &t
  12183. }
  12184. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12185. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  12186. v := m.deleted_at
  12187. if v == nil {
  12188. return
  12189. }
  12190. return *v, true
  12191. }
  12192. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  12193. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12195. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12196. if !m.op.Is(OpUpdateOne) {
  12197. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12198. }
  12199. if m.id == nil || m.oldValue == nil {
  12200. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12201. }
  12202. oldValue, err := m.oldValue(ctx)
  12203. if err != nil {
  12204. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12205. }
  12206. return oldValue.DeletedAt, nil
  12207. }
  12208. // ClearDeletedAt clears the value of the "deleted_at" field.
  12209. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  12210. m.deleted_at = nil
  12211. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  12212. }
  12213. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12214. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  12215. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  12216. return ok
  12217. }
  12218. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12219. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  12220. m.deleted_at = nil
  12221. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  12222. }
  12223. // SetLabelID sets the "label_id" field.
  12224. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  12225. m.labels = &u
  12226. }
  12227. // LabelID returns the value of the "label_id" field in the mutation.
  12228. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  12229. v := m.labels
  12230. if v == nil {
  12231. return
  12232. }
  12233. return *v, true
  12234. }
  12235. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  12236. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12238. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  12239. if !m.op.Is(OpUpdateOne) {
  12240. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  12241. }
  12242. if m.id == nil || m.oldValue == nil {
  12243. return v, errors.New("OldLabelID requires an ID field in the mutation")
  12244. }
  12245. oldValue, err := m.oldValue(ctx)
  12246. if err != nil {
  12247. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  12248. }
  12249. return oldValue.LabelID, nil
  12250. }
  12251. // ResetLabelID resets all changes to the "label_id" field.
  12252. func (m *LabelRelationshipMutation) ResetLabelID() {
  12253. m.labels = nil
  12254. }
  12255. // SetContactID sets the "contact_id" field.
  12256. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  12257. m.contacts = &u
  12258. }
  12259. // ContactID returns the value of the "contact_id" field in the mutation.
  12260. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  12261. v := m.contacts
  12262. if v == nil {
  12263. return
  12264. }
  12265. return *v, true
  12266. }
  12267. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  12268. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12270. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  12271. if !m.op.Is(OpUpdateOne) {
  12272. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  12273. }
  12274. if m.id == nil || m.oldValue == nil {
  12275. return v, errors.New("OldContactID requires an ID field in the mutation")
  12276. }
  12277. oldValue, err := m.oldValue(ctx)
  12278. if err != nil {
  12279. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  12280. }
  12281. return oldValue.ContactID, nil
  12282. }
  12283. // ResetContactID resets all changes to the "contact_id" field.
  12284. func (m *LabelRelationshipMutation) ResetContactID() {
  12285. m.contacts = nil
  12286. }
  12287. // SetOrganizationID sets the "organization_id" field.
  12288. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  12289. m.organization_id = &u
  12290. m.addorganization_id = nil
  12291. }
  12292. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12293. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  12294. v := m.organization_id
  12295. if v == nil {
  12296. return
  12297. }
  12298. return *v, true
  12299. }
  12300. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  12301. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12303. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12304. if !m.op.Is(OpUpdateOne) {
  12305. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12306. }
  12307. if m.id == nil || m.oldValue == nil {
  12308. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12309. }
  12310. oldValue, err := m.oldValue(ctx)
  12311. if err != nil {
  12312. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12313. }
  12314. return oldValue.OrganizationID, nil
  12315. }
  12316. // AddOrganizationID adds u to the "organization_id" field.
  12317. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  12318. if m.addorganization_id != nil {
  12319. *m.addorganization_id += u
  12320. } else {
  12321. m.addorganization_id = &u
  12322. }
  12323. }
  12324. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12325. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  12326. v := m.addorganization_id
  12327. if v == nil {
  12328. return
  12329. }
  12330. return *v, true
  12331. }
  12332. // ClearOrganizationID clears the value of the "organization_id" field.
  12333. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  12334. m.organization_id = nil
  12335. m.addorganization_id = nil
  12336. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  12337. }
  12338. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12339. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  12340. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  12341. return ok
  12342. }
  12343. // ResetOrganizationID resets all changes to the "organization_id" field.
  12344. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  12345. m.organization_id = nil
  12346. m.addorganization_id = nil
  12347. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  12348. }
  12349. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  12350. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  12351. m.contacts = &id
  12352. }
  12353. // ClearContacts clears the "contacts" edge to the Contact entity.
  12354. func (m *LabelRelationshipMutation) ClearContacts() {
  12355. m.clearedcontacts = true
  12356. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  12357. }
  12358. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  12359. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  12360. return m.clearedcontacts
  12361. }
  12362. // ContactsID returns the "contacts" edge ID in the mutation.
  12363. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  12364. if m.contacts != nil {
  12365. return *m.contacts, true
  12366. }
  12367. return
  12368. }
  12369. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  12370. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12371. // ContactsID instead. It exists only for internal usage by the builders.
  12372. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  12373. if id := m.contacts; id != nil {
  12374. ids = append(ids, *id)
  12375. }
  12376. return
  12377. }
  12378. // ResetContacts resets all changes to the "contacts" edge.
  12379. func (m *LabelRelationshipMutation) ResetContacts() {
  12380. m.contacts = nil
  12381. m.clearedcontacts = false
  12382. }
  12383. // SetLabelsID sets the "labels" edge to the Label entity by id.
  12384. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  12385. m.labels = &id
  12386. }
  12387. // ClearLabels clears the "labels" edge to the Label entity.
  12388. func (m *LabelRelationshipMutation) ClearLabels() {
  12389. m.clearedlabels = true
  12390. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  12391. }
  12392. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  12393. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  12394. return m.clearedlabels
  12395. }
  12396. // LabelsID returns the "labels" edge ID in the mutation.
  12397. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  12398. if m.labels != nil {
  12399. return *m.labels, true
  12400. }
  12401. return
  12402. }
  12403. // LabelsIDs returns the "labels" edge IDs in the mutation.
  12404. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12405. // LabelsID instead. It exists only for internal usage by the builders.
  12406. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  12407. if id := m.labels; id != nil {
  12408. ids = append(ids, *id)
  12409. }
  12410. return
  12411. }
  12412. // ResetLabels resets all changes to the "labels" edge.
  12413. func (m *LabelRelationshipMutation) ResetLabels() {
  12414. m.labels = nil
  12415. m.clearedlabels = false
  12416. }
  12417. // Where appends a list predicates to the LabelRelationshipMutation builder.
  12418. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  12419. m.predicates = append(m.predicates, ps...)
  12420. }
  12421. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  12422. // users can use type-assertion to append predicates that do not depend on any generated package.
  12423. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  12424. p := make([]predicate.LabelRelationship, len(ps))
  12425. for i := range ps {
  12426. p[i] = ps[i]
  12427. }
  12428. m.Where(p...)
  12429. }
  12430. // Op returns the operation name.
  12431. func (m *LabelRelationshipMutation) Op() Op {
  12432. return m.op
  12433. }
  12434. // SetOp allows setting the mutation operation.
  12435. func (m *LabelRelationshipMutation) SetOp(op Op) {
  12436. m.op = op
  12437. }
  12438. // Type returns the node type of this mutation (LabelRelationship).
  12439. func (m *LabelRelationshipMutation) Type() string {
  12440. return m.typ
  12441. }
  12442. // Fields returns all fields that were changed during this mutation. Note that in
  12443. // order to get all numeric fields that were incremented/decremented, call
  12444. // AddedFields().
  12445. func (m *LabelRelationshipMutation) Fields() []string {
  12446. fields := make([]string, 0, 7)
  12447. if m.created_at != nil {
  12448. fields = append(fields, labelrelationship.FieldCreatedAt)
  12449. }
  12450. if m.updated_at != nil {
  12451. fields = append(fields, labelrelationship.FieldUpdatedAt)
  12452. }
  12453. if m.status != nil {
  12454. fields = append(fields, labelrelationship.FieldStatus)
  12455. }
  12456. if m.deleted_at != nil {
  12457. fields = append(fields, labelrelationship.FieldDeletedAt)
  12458. }
  12459. if m.labels != nil {
  12460. fields = append(fields, labelrelationship.FieldLabelID)
  12461. }
  12462. if m.contacts != nil {
  12463. fields = append(fields, labelrelationship.FieldContactID)
  12464. }
  12465. if m.organization_id != nil {
  12466. fields = append(fields, labelrelationship.FieldOrganizationID)
  12467. }
  12468. return fields
  12469. }
  12470. // Field returns the value of a field with the given name. The second boolean
  12471. // return value indicates that this field was not set, or was not defined in the
  12472. // schema.
  12473. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  12474. switch name {
  12475. case labelrelationship.FieldCreatedAt:
  12476. return m.CreatedAt()
  12477. case labelrelationship.FieldUpdatedAt:
  12478. return m.UpdatedAt()
  12479. case labelrelationship.FieldStatus:
  12480. return m.Status()
  12481. case labelrelationship.FieldDeletedAt:
  12482. return m.DeletedAt()
  12483. case labelrelationship.FieldLabelID:
  12484. return m.LabelID()
  12485. case labelrelationship.FieldContactID:
  12486. return m.ContactID()
  12487. case labelrelationship.FieldOrganizationID:
  12488. return m.OrganizationID()
  12489. }
  12490. return nil, false
  12491. }
  12492. // OldField returns the old value of the field from the database. An error is
  12493. // returned if the mutation operation is not UpdateOne, or the query to the
  12494. // database failed.
  12495. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12496. switch name {
  12497. case labelrelationship.FieldCreatedAt:
  12498. return m.OldCreatedAt(ctx)
  12499. case labelrelationship.FieldUpdatedAt:
  12500. return m.OldUpdatedAt(ctx)
  12501. case labelrelationship.FieldStatus:
  12502. return m.OldStatus(ctx)
  12503. case labelrelationship.FieldDeletedAt:
  12504. return m.OldDeletedAt(ctx)
  12505. case labelrelationship.FieldLabelID:
  12506. return m.OldLabelID(ctx)
  12507. case labelrelationship.FieldContactID:
  12508. return m.OldContactID(ctx)
  12509. case labelrelationship.FieldOrganizationID:
  12510. return m.OldOrganizationID(ctx)
  12511. }
  12512. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  12513. }
  12514. // SetField sets the value of a field with the given name. It returns an error if
  12515. // the field is not defined in the schema, or if the type mismatched the field
  12516. // type.
  12517. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  12518. switch name {
  12519. case labelrelationship.FieldCreatedAt:
  12520. v, ok := value.(time.Time)
  12521. if !ok {
  12522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12523. }
  12524. m.SetCreatedAt(v)
  12525. return nil
  12526. case labelrelationship.FieldUpdatedAt:
  12527. v, ok := value.(time.Time)
  12528. if !ok {
  12529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12530. }
  12531. m.SetUpdatedAt(v)
  12532. return nil
  12533. case labelrelationship.FieldStatus:
  12534. v, ok := value.(uint8)
  12535. if !ok {
  12536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12537. }
  12538. m.SetStatus(v)
  12539. return nil
  12540. case labelrelationship.FieldDeletedAt:
  12541. v, ok := value.(time.Time)
  12542. if !ok {
  12543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12544. }
  12545. m.SetDeletedAt(v)
  12546. return nil
  12547. case labelrelationship.FieldLabelID:
  12548. v, ok := value.(uint64)
  12549. if !ok {
  12550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12551. }
  12552. m.SetLabelID(v)
  12553. return nil
  12554. case labelrelationship.FieldContactID:
  12555. v, ok := value.(uint64)
  12556. if !ok {
  12557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12558. }
  12559. m.SetContactID(v)
  12560. return nil
  12561. case labelrelationship.FieldOrganizationID:
  12562. v, ok := value.(uint64)
  12563. if !ok {
  12564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12565. }
  12566. m.SetOrganizationID(v)
  12567. return nil
  12568. }
  12569. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12570. }
  12571. // AddedFields returns all numeric fields that were incremented/decremented during
  12572. // this mutation.
  12573. func (m *LabelRelationshipMutation) AddedFields() []string {
  12574. var fields []string
  12575. if m.addstatus != nil {
  12576. fields = append(fields, labelrelationship.FieldStatus)
  12577. }
  12578. if m.addorganization_id != nil {
  12579. fields = append(fields, labelrelationship.FieldOrganizationID)
  12580. }
  12581. return fields
  12582. }
  12583. // AddedField returns the numeric value that was incremented/decremented on a field
  12584. // with the given name. The second boolean return value indicates that this field
  12585. // was not set, or was not defined in the schema.
  12586. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  12587. switch name {
  12588. case labelrelationship.FieldStatus:
  12589. return m.AddedStatus()
  12590. case labelrelationship.FieldOrganizationID:
  12591. return m.AddedOrganizationID()
  12592. }
  12593. return nil, false
  12594. }
  12595. // AddField adds the value to the field with the given name. It returns an error if
  12596. // the field is not defined in the schema, or if the type mismatched the field
  12597. // type.
  12598. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  12599. switch name {
  12600. case labelrelationship.FieldStatus:
  12601. v, ok := value.(int8)
  12602. if !ok {
  12603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12604. }
  12605. m.AddStatus(v)
  12606. return nil
  12607. case labelrelationship.FieldOrganizationID:
  12608. v, ok := value.(int64)
  12609. if !ok {
  12610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12611. }
  12612. m.AddOrganizationID(v)
  12613. return nil
  12614. }
  12615. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  12616. }
  12617. // ClearedFields returns all nullable fields that were cleared during this
  12618. // mutation.
  12619. func (m *LabelRelationshipMutation) ClearedFields() []string {
  12620. var fields []string
  12621. if m.FieldCleared(labelrelationship.FieldStatus) {
  12622. fields = append(fields, labelrelationship.FieldStatus)
  12623. }
  12624. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  12625. fields = append(fields, labelrelationship.FieldDeletedAt)
  12626. }
  12627. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  12628. fields = append(fields, labelrelationship.FieldOrganizationID)
  12629. }
  12630. return fields
  12631. }
  12632. // FieldCleared returns a boolean indicating if a field with the given name was
  12633. // cleared in this mutation.
  12634. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  12635. _, ok := m.clearedFields[name]
  12636. return ok
  12637. }
  12638. // ClearField clears the value of the field with the given name. It returns an
  12639. // error if the field is not defined in the schema.
  12640. func (m *LabelRelationshipMutation) ClearField(name string) error {
  12641. switch name {
  12642. case labelrelationship.FieldStatus:
  12643. m.ClearStatus()
  12644. return nil
  12645. case labelrelationship.FieldDeletedAt:
  12646. m.ClearDeletedAt()
  12647. return nil
  12648. case labelrelationship.FieldOrganizationID:
  12649. m.ClearOrganizationID()
  12650. return nil
  12651. }
  12652. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  12653. }
  12654. // ResetField resets all changes in the mutation for the field with the given name.
  12655. // It returns an error if the field is not defined in the schema.
  12656. func (m *LabelRelationshipMutation) ResetField(name string) error {
  12657. switch name {
  12658. case labelrelationship.FieldCreatedAt:
  12659. m.ResetCreatedAt()
  12660. return nil
  12661. case labelrelationship.FieldUpdatedAt:
  12662. m.ResetUpdatedAt()
  12663. return nil
  12664. case labelrelationship.FieldStatus:
  12665. m.ResetStatus()
  12666. return nil
  12667. case labelrelationship.FieldDeletedAt:
  12668. m.ResetDeletedAt()
  12669. return nil
  12670. case labelrelationship.FieldLabelID:
  12671. m.ResetLabelID()
  12672. return nil
  12673. case labelrelationship.FieldContactID:
  12674. m.ResetContactID()
  12675. return nil
  12676. case labelrelationship.FieldOrganizationID:
  12677. m.ResetOrganizationID()
  12678. return nil
  12679. }
  12680. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12681. }
  12682. // AddedEdges returns all edge names that were set/added in this mutation.
  12683. func (m *LabelRelationshipMutation) AddedEdges() []string {
  12684. edges := make([]string, 0, 2)
  12685. if m.contacts != nil {
  12686. edges = append(edges, labelrelationship.EdgeContacts)
  12687. }
  12688. if m.labels != nil {
  12689. edges = append(edges, labelrelationship.EdgeLabels)
  12690. }
  12691. return edges
  12692. }
  12693. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12694. // name in this mutation.
  12695. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  12696. switch name {
  12697. case labelrelationship.EdgeContacts:
  12698. if id := m.contacts; id != nil {
  12699. return []ent.Value{*id}
  12700. }
  12701. case labelrelationship.EdgeLabels:
  12702. if id := m.labels; id != nil {
  12703. return []ent.Value{*id}
  12704. }
  12705. }
  12706. return nil
  12707. }
  12708. // RemovedEdges returns all edge names that were removed in this mutation.
  12709. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  12710. edges := make([]string, 0, 2)
  12711. return edges
  12712. }
  12713. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12714. // the given name in this mutation.
  12715. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  12716. return nil
  12717. }
  12718. // ClearedEdges returns all edge names that were cleared in this mutation.
  12719. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  12720. edges := make([]string, 0, 2)
  12721. if m.clearedcontacts {
  12722. edges = append(edges, labelrelationship.EdgeContacts)
  12723. }
  12724. if m.clearedlabels {
  12725. edges = append(edges, labelrelationship.EdgeLabels)
  12726. }
  12727. return edges
  12728. }
  12729. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12730. // was cleared in this mutation.
  12731. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  12732. switch name {
  12733. case labelrelationship.EdgeContacts:
  12734. return m.clearedcontacts
  12735. case labelrelationship.EdgeLabels:
  12736. return m.clearedlabels
  12737. }
  12738. return false
  12739. }
  12740. // ClearEdge clears the value of the edge with the given name. It returns an error
  12741. // if that edge is not defined in the schema.
  12742. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  12743. switch name {
  12744. case labelrelationship.EdgeContacts:
  12745. m.ClearContacts()
  12746. return nil
  12747. case labelrelationship.EdgeLabels:
  12748. m.ClearLabels()
  12749. return nil
  12750. }
  12751. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  12752. }
  12753. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12754. // It returns an error if the edge is not defined in the schema.
  12755. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  12756. switch name {
  12757. case labelrelationship.EdgeContacts:
  12758. m.ResetContacts()
  12759. return nil
  12760. case labelrelationship.EdgeLabels:
  12761. m.ResetLabels()
  12762. return nil
  12763. }
  12764. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  12765. }
  12766. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  12767. type MessageMutation struct {
  12768. config
  12769. op Op
  12770. typ string
  12771. id *int
  12772. wx_wxid *string
  12773. wxid *string
  12774. content *string
  12775. clearedFields map[string]struct{}
  12776. done bool
  12777. oldValue func(context.Context) (*Message, error)
  12778. predicates []predicate.Message
  12779. }
  12780. var _ ent.Mutation = (*MessageMutation)(nil)
  12781. // messageOption allows management of the mutation configuration using functional options.
  12782. type messageOption func(*MessageMutation)
  12783. // newMessageMutation creates new mutation for the Message entity.
  12784. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  12785. m := &MessageMutation{
  12786. config: c,
  12787. op: op,
  12788. typ: TypeMessage,
  12789. clearedFields: make(map[string]struct{}),
  12790. }
  12791. for _, opt := range opts {
  12792. opt(m)
  12793. }
  12794. return m
  12795. }
  12796. // withMessageID sets the ID field of the mutation.
  12797. func withMessageID(id int) messageOption {
  12798. return func(m *MessageMutation) {
  12799. var (
  12800. err error
  12801. once sync.Once
  12802. value *Message
  12803. )
  12804. m.oldValue = func(ctx context.Context) (*Message, error) {
  12805. once.Do(func() {
  12806. if m.done {
  12807. err = errors.New("querying old values post mutation is not allowed")
  12808. } else {
  12809. value, err = m.Client().Message.Get(ctx, id)
  12810. }
  12811. })
  12812. return value, err
  12813. }
  12814. m.id = &id
  12815. }
  12816. }
  12817. // withMessage sets the old Message of the mutation.
  12818. func withMessage(node *Message) messageOption {
  12819. return func(m *MessageMutation) {
  12820. m.oldValue = func(context.Context) (*Message, error) {
  12821. return node, nil
  12822. }
  12823. m.id = &node.ID
  12824. }
  12825. }
  12826. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12827. // executed in a transaction (ent.Tx), a transactional client is returned.
  12828. func (m MessageMutation) Client() *Client {
  12829. client := &Client{config: m.config}
  12830. client.init()
  12831. return client
  12832. }
  12833. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12834. // it returns an error otherwise.
  12835. func (m MessageMutation) Tx() (*Tx, error) {
  12836. if _, ok := m.driver.(*txDriver); !ok {
  12837. return nil, errors.New("ent: mutation is not running in a transaction")
  12838. }
  12839. tx := &Tx{config: m.config}
  12840. tx.init()
  12841. return tx, nil
  12842. }
  12843. // ID returns the ID value in the mutation. Note that the ID is only available
  12844. // if it was provided to the builder or after it was returned from the database.
  12845. func (m *MessageMutation) ID() (id int, exists bool) {
  12846. if m.id == nil {
  12847. return
  12848. }
  12849. return *m.id, true
  12850. }
  12851. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12852. // That means, if the mutation is applied within a transaction with an isolation level such
  12853. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12854. // or updated by the mutation.
  12855. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  12856. switch {
  12857. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12858. id, exists := m.ID()
  12859. if exists {
  12860. return []int{id}, nil
  12861. }
  12862. fallthrough
  12863. case m.op.Is(OpUpdate | OpDelete):
  12864. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  12865. default:
  12866. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12867. }
  12868. }
  12869. // SetWxWxid sets the "wx_wxid" field.
  12870. func (m *MessageMutation) SetWxWxid(s string) {
  12871. m.wx_wxid = &s
  12872. }
  12873. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  12874. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  12875. v := m.wx_wxid
  12876. if v == nil {
  12877. return
  12878. }
  12879. return *v, true
  12880. }
  12881. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  12882. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12884. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  12885. if !m.op.Is(OpUpdateOne) {
  12886. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  12887. }
  12888. if m.id == nil || m.oldValue == nil {
  12889. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  12890. }
  12891. oldValue, err := m.oldValue(ctx)
  12892. if err != nil {
  12893. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  12894. }
  12895. return oldValue.WxWxid, nil
  12896. }
  12897. // ClearWxWxid clears the value of the "wx_wxid" field.
  12898. func (m *MessageMutation) ClearWxWxid() {
  12899. m.wx_wxid = nil
  12900. m.clearedFields[message.FieldWxWxid] = struct{}{}
  12901. }
  12902. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  12903. func (m *MessageMutation) WxWxidCleared() bool {
  12904. _, ok := m.clearedFields[message.FieldWxWxid]
  12905. return ok
  12906. }
  12907. // ResetWxWxid resets all changes to the "wx_wxid" field.
  12908. func (m *MessageMutation) ResetWxWxid() {
  12909. m.wx_wxid = nil
  12910. delete(m.clearedFields, message.FieldWxWxid)
  12911. }
  12912. // SetWxid sets the "wxid" field.
  12913. func (m *MessageMutation) SetWxid(s string) {
  12914. m.wxid = &s
  12915. }
  12916. // Wxid returns the value of the "wxid" field in the mutation.
  12917. func (m *MessageMutation) Wxid() (r string, exists bool) {
  12918. v := m.wxid
  12919. if v == nil {
  12920. return
  12921. }
  12922. return *v, true
  12923. }
  12924. // OldWxid returns the old "wxid" field's value of the Message entity.
  12925. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12927. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  12928. if !m.op.Is(OpUpdateOne) {
  12929. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  12930. }
  12931. if m.id == nil || m.oldValue == nil {
  12932. return v, errors.New("OldWxid requires an ID field in the mutation")
  12933. }
  12934. oldValue, err := m.oldValue(ctx)
  12935. if err != nil {
  12936. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  12937. }
  12938. return oldValue.Wxid, nil
  12939. }
  12940. // ResetWxid resets all changes to the "wxid" field.
  12941. func (m *MessageMutation) ResetWxid() {
  12942. m.wxid = nil
  12943. }
  12944. // SetContent sets the "content" field.
  12945. func (m *MessageMutation) SetContent(s string) {
  12946. m.content = &s
  12947. }
  12948. // Content returns the value of the "content" field in the mutation.
  12949. func (m *MessageMutation) Content() (r string, exists bool) {
  12950. v := m.content
  12951. if v == nil {
  12952. return
  12953. }
  12954. return *v, true
  12955. }
  12956. // OldContent returns the old "content" field's value of the Message entity.
  12957. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12959. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  12960. if !m.op.Is(OpUpdateOne) {
  12961. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  12962. }
  12963. if m.id == nil || m.oldValue == nil {
  12964. return v, errors.New("OldContent requires an ID field in the mutation")
  12965. }
  12966. oldValue, err := m.oldValue(ctx)
  12967. if err != nil {
  12968. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  12969. }
  12970. return oldValue.Content, nil
  12971. }
  12972. // ResetContent resets all changes to the "content" field.
  12973. func (m *MessageMutation) ResetContent() {
  12974. m.content = nil
  12975. }
  12976. // Where appends a list predicates to the MessageMutation builder.
  12977. func (m *MessageMutation) Where(ps ...predicate.Message) {
  12978. m.predicates = append(m.predicates, ps...)
  12979. }
  12980. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  12981. // users can use type-assertion to append predicates that do not depend on any generated package.
  12982. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  12983. p := make([]predicate.Message, len(ps))
  12984. for i := range ps {
  12985. p[i] = ps[i]
  12986. }
  12987. m.Where(p...)
  12988. }
  12989. // Op returns the operation name.
  12990. func (m *MessageMutation) Op() Op {
  12991. return m.op
  12992. }
  12993. // SetOp allows setting the mutation operation.
  12994. func (m *MessageMutation) SetOp(op Op) {
  12995. m.op = op
  12996. }
  12997. // Type returns the node type of this mutation (Message).
  12998. func (m *MessageMutation) Type() string {
  12999. return m.typ
  13000. }
  13001. // Fields returns all fields that were changed during this mutation. Note that in
  13002. // order to get all numeric fields that were incremented/decremented, call
  13003. // AddedFields().
  13004. func (m *MessageMutation) Fields() []string {
  13005. fields := make([]string, 0, 3)
  13006. if m.wx_wxid != nil {
  13007. fields = append(fields, message.FieldWxWxid)
  13008. }
  13009. if m.wxid != nil {
  13010. fields = append(fields, message.FieldWxid)
  13011. }
  13012. if m.content != nil {
  13013. fields = append(fields, message.FieldContent)
  13014. }
  13015. return fields
  13016. }
  13017. // Field returns the value of a field with the given name. The second boolean
  13018. // return value indicates that this field was not set, or was not defined in the
  13019. // schema.
  13020. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  13021. switch name {
  13022. case message.FieldWxWxid:
  13023. return m.WxWxid()
  13024. case message.FieldWxid:
  13025. return m.Wxid()
  13026. case message.FieldContent:
  13027. return m.Content()
  13028. }
  13029. return nil, false
  13030. }
  13031. // OldField returns the old value of the field from the database. An error is
  13032. // returned if the mutation operation is not UpdateOne, or the query to the
  13033. // database failed.
  13034. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13035. switch name {
  13036. case message.FieldWxWxid:
  13037. return m.OldWxWxid(ctx)
  13038. case message.FieldWxid:
  13039. return m.OldWxid(ctx)
  13040. case message.FieldContent:
  13041. return m.OldContent(ctx)
  13042. }
  13043. return nil, fmt.Errorf("unknown Message field %s", name)
  13044. }
  13045. // SetField sets the value of a field with the given name. It returns an error if
  13046. // the field is not defined in the schema, or if the type mismatched the field
  13047. // type.
  13048. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  13049. switch name {
  13050. case message.FieldWxWxid:
  13051. v, ok := value.(string)
  13052. if !ok {
  13053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13054. }
  13055. m.SetWxWxid(v)
  13056. return nil
  13057. case message.FieldWxid:
  13058. v, ok := value.(string)
  13059. if !ok {
  13060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13061. }
  13062. m.SetWxid(v)
  13063. return nil
  13064. case message.FieldContent:
  13065. v, ok := value.(string)
  13066. if !ok {
  13067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13068. }
  13069. m.SetContent(v)
  13070. return nil
  13071. }
  13072. return fmt.Errorf("unknown Message field %s", name)
  13073. }
  13074. // AddedFields returns all numeric fields that were incremented/decremented during
  13075. // this mutation.
  13076. func (m *MessageMutation) AddedFields() []string {
  13077. return nil
  13078. }
  13079. // AddedField returns the numeric value that was incremented/decremented on a field
  13080. // with the given name. The second boolean return value indicates that this field
  13081. // was not set, or was not defined in the schema.
  13082. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  13083. return nil, false
  13084. }
  13085. // AddField adds the value to the field with the given name. It returns an error if
  13086. // the field is not defined in the schema, or if the type mismatched the field
  13087. // type.
  13088. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  13089. switch name {
  13090. }
  13091. return fmt.Errorf("unknown Message numeric field %s", name)
  13092. }
  13093. // ClearedFields returns all nullable fields that were cleared during this
  13094. // mutation.
  13095. func (m *MessageMutation) ClearedFields() []string {
  13096. var fields []string
  13097. if m.FieldCleared(message.FieldWxWxid) {
  13098. fields = append(fields, message.FieldWxWxid)
  13099. }
  13100. return fields
  13101. }
  13102. // FieldCleared returns a boolean indicating if a field with the given name was
  13103. // cleared in this mutation.
  13104. func (m *MessageMutation) FieldCleared(name string) bool {
  13105. _, ok := m.clearedFields[name]
  13106. return ok
  13107. }
  13108. // ClearField clears the value of the field with the given name. It returns an
  13109. // error if the field is not defined in the schema.
  13110. func (m *MessageMutation) ClearField(name string) error {
  13111. switch name {
  13112. case message.FieldWxWxid:
  13113. m.ClearWxWxid()
  13114. return nil
  13115. }
  13116. return fmt.Errorf("unknown Message nullable field %s", name)
  13117. }
  13118. // ResetField resets all changes in the mutation for the field with the given name.
  13119. // It returns an error if the field is not defined in the schema.
  13120. func (m *MessageMutation) ResetField(name string) error {
  13121. switch name {
  13122. case message.FieldWxWxid:
  13123. m.ResetWxWxid()
  13124. return nil
  13125. case message.FieldWxid:
  13126. m.ResetWxid()
  13127. return nil
  13128. case message.FieldContent:
  13129. m.ResetContent()
  13130. return nil
  13131. }
  13132. return fmt.Errorf("unknown Message field %s", name)
  13133. }
  13134. // AddedEdges returns all edge names that were set/added in this mutation.
  13135. func (m *MessageMutation) AddedEdges() []string {
  13136. edges := make([]string, 0, 0)
  13137. return edges
  13138. }
  13139. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13140. // name in this mutation.
  13141. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  13142. return nil
  13143. }
  13144. // RemovedEdges returns all edge names that were removed in this mutation.
  13145. func (m *MessageMutation) RemovedEdges() []string {
  13146. edges := make([]string, 0, 0)
  13147. return edges
  13148. }
  13149. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13150. // the given name in this mutation.
  13151. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  13152. return nil
  13153. }
  13154. // ClearedEdges returns all edge names that were cleared in this mutation.
  13155. func (m *MessageMutation) ClearedEdges() []string {
  13156. edges := make([]string, 0, 0)
  13157. return edges
  13158. }
  13159. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13160. // was cleared in this mutation.
  13161. func (m *MessageMutation) EdgeCleared(name string) bool {
  13162. return false
  13163. }
  13164. // ClearEdge clears the value of the edge with the given name. It returns an error
  13165. // if that edge is not defined in the schema.
  13166. func (m *MessageMutation) ClearEdge(name string) error {
  13167. return fmt.Errorf("unknown Message unique edge %s", name)
  13168. }
  13169. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13170. // It returns an error if the edge is not defined in the schema.
  13171. func (m *MessageMutation) ResetEdge(name string) error {
  13172. return fmt.Errorf("unknown Message edge %s", name)
  13173. }
  13174. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  13175. type MessageRecordsMutation struct {
  13176. config
  13177. op Op
  13178. typ string
  13179. id *uint64
  13180. created_at *time.Time
  13181. updated_at *time.Time
  13182. status *uint8
  13183. addstatus *int8
  13184. bot_wxid *string
  13185. contact_type *int
  13186. addcontact_type *int
  13187. contact_wxid *string
  13188. content_type *int
  13189. addcontent_type *int
  13190. content *string
  13191. meta *custom_types.Meta
  13192. error_detail *string
  13193. send_time *time.Time
  13194. source_type *int
  13195. addsource_type *int
  13196. organization_id *uint64
  13197. addorganization_id *int64
  13198. clearedFields map[string]struct{}
  13199. sop_stage *uint64
  13200. clearedsop_stage bool
  13201. sop_node *uint64
  13202. clearedsop_node bool
  13203. message_contact *uint64
  13204. clearedmessage_contact bool
  13205. done bool
  13206. oldValue func(context.Context) (*MessageRecords, error)
  13207. predicates []predicate.MessageRecords
  13208. }
  13209. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  13210. // messagerecordsOption allows management of the mutation configuration using functional options.
  13211. type messagerecordsOption func(*MessageRecordsMutation)
  13212. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  13213. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  13214. m := &MessageRecordsMutation{
  13215. config: c,
  13216. op: op,
  13217. typ: TypeMessageRecords,
  13218. clearedFields: make(map[string]struct{}),
  13219. }
  13220. for _, opt := range opts {
  13221. opt(m)
  13222. }
  13223. return m
  13224. }
  13225. // withMessageRecordsID sets the ID field of the mutation.
  13226. func withMessageRecordsID(id uint64) messagerecordsOption {
  13227. return func(m *MessageRecordsMutation) {
  13228. var (
  13229. err error
  13230. once sync.Once
  13231. value *MessageRecords
  13232. )
  13233. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  13234. once.Do(func() {
  13235. if m.done {
  13236. err = errors.New("querying old values post mutation is not allowed")
  13237. } else {
  13238. value, err = m.Client().MessageRecords.Get(ctx, id)
  13239. }
  13240. })
  13241. return value, err
  13242. }
  13243. m.id = &id
  13244. }
  13245. }
  13246. // withMessageRecords sets the old MessageRecords of the mutation.
  13247. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  13248. return func(m *MessageRecordsMutation) {
  13249. m.oldValue = func(context.Context) (*MessageRecords, error) {
  13250. return node, nil
  13251. }
  13252. m.id = &node.ID
  13253. }
  13254. }
  13255. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13256. // executed in a transaction (ent.Tx), a transactional client is returned.
  13257. func (m MessageRecordsMutation) Client() *Client {
  13258. client := &Client{config: m.config}
  13259. client.init()
  13260. return client
  13261. }
  13262. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13263. // it returns an error otherwise.
  13264. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  13265. if _, ok := m.driver.(*txDriver); !ok {
  13266. return nil, errors.New("ent: mutation is not running in a transaction")
  13267. }
  13268. tx := &Tx{config: m.config}
  13269. tx.init()
  13270. return tx, nil
  13271. }
  13272. // SetID sets the value of the id field. Note that this
  13273. // operation is only accepted on creation of MessageRecords entities.
  13274. func (m *MessageRecordsMutation) SetID(id uint64) {
  13275. m.id = &id
  13276. }
  13277. // ID returns the ID value in the mutation. Note that the ID is only available
  13278. // if it was provided to the builder or after it was returned from the database.
  13279. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  13280. if m.id == nil {
  13281. return
  13282. }
  13283. return *m.id, true
  13284. }
  13285. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13286. // That means, if the mutation is applied within a transaction with an isolation level such
  13287. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13288. // or updated by the mutation.
  13289. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  13290. switch {
  13291. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13292. id, exists := m.ID()
  13293. if exists {
  13294. return []uint64{id}, nil
  13295. }
  13296. fallthrough
  13297. case m.op.Is(OpUpdate | OpDelete):
  13298. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  13299. default:
  13300. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13301. }
  13302. }
  13303. // SetCreatedAt sets the "created_at" field.
  13304. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  13305. m.created_at = &t
  13306. }
  13307. // CreatedAt returns the value of the "created_at" field in the mutation.
  13308. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  13309. v := m.created_at
  13310. if v == nil {
  13311. return
  13312. }
  13313. return *v, true
  13314. }
  13315. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  13316. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13318. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13319. if !m.op.Is(OpUpdateOne) {
  13320. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13321. }
  13322. if m.id == nil || m.oldValue == nil {
  13323. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13324. }
  13325. oldValue, err := m.oldValue(ctx)
  13326. if err != nil {
  13327. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13328. }
  13329. return oldValue.CreatedAt, nil
  13330. }
  13331. // ResetCreatedAt resets all changes to the "created_at" field.
  13332. func (m *MessageRecordsMutation) ResetCreatedAt() {
  13333. m.created_at = nil
  13334. }
  13335. // SetUpdatedAt sets the "updated_at" field.
  13336. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  13337. m.updated_at = &t
  13338. }
  13339. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13340. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  13341. v := m.updated_at
  13342. if v == nil {
  13343. return
  13344. }
  13345. return *v, true
  13346. }
  13347. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  13348. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13350. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13351. if !m.op.Is(OpUpdateOne) {
  13352. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13353. }
  13354. if m.id == nil || m.oldValue == nil {
  13355. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13356. }
  13357. oldValue, err := m.oldValue(ctx)
  13358. if err != nil {
  13359. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13360. }
  13361. return oldValue.UpdatedAt, nil
  13362. }
  13363. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13364. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  13365. m.updated_at = nil
  13366. }
  13367. // SetStatus sets the "status" field.
  13368. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  13369. m.status = &u
  13370. m.addstatus = nil
  13371. }
  13372. // Status returns the value of the "status" field in the mutation.
  13373. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  13374. v := m.status
  13375. if v == nil {
  13376. return
  13377. }
  13378. return *v, true
  13379. }
  13380. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  13381. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13383. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13384. if !m.op.Is(OpUpdateOne) {
  13385. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13386. }
  13387. if m.id == nil || m.oldValue == nil {
  13388. return v, errors.New("OldStatus requires an ID field in the mutation")
  13389. }
  13390. oldValue, err := m.oldValue(ctx)
  13391. if err != nil {
  13392. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13393. }
  13394. return oldValue.Status, nil
  13395. }
  13396. // AddStatus adds u to the "status" field.
  13397. func (m *MessageRecordsMutation) AddStatus(u int8) {
  13398. if m.addstatus != nil {
  13399. *m.addstatus += u
  13400. } else {
  13401. m.addstatus = &u
  13402. }
  13403. }
  13404. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13405. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  13406. v := m.addstatus
  13407. if v == nil {
  13408. return
  13409. }
  13410. return *v, true
  13411. }
  13412. // ClearStatus clears the value of the "status" field.
  13413. func (m *MessageRecordsMutation) ClearStatus() {
  13414. m.status = nil
  13415. m.addstatus = nil
  13416. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  13417. }
  13418. // StatusCleared returns if the "status" field was cleared in this mutation.
  13419. func (m *MessageRecordsMutation) StatusCleared() bool {
  13420. _, ok := m.clearedFields[messagerecords.FieldStatus]
  13421. return ok
  13422. }
  13423. // ResetStatus resets all changes to the "status" field.
  13424. func (m *MessageRecordsMutation) ResetStatus() {
  13425. m.status = nil
  13426. m.addstatus = nil
  13427. delete(m.clearedFields, messagerecords.FieldStatus)
  13428. }
  13429. // SetBotWxid sets the "bot_wxid" field.
  13430. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  13431. m.bot_wxid = &s
  13432. }
  13433. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  13434. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  13435. v := m.bot_wxid
  13436. if v == nil {
  13437. return
  13438. }
  13439. return *v, true
  13440. }
  13441. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  13442. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13444. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  13445. if !m.op.Is(OpUpdateOne) {
  13446. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  13447. }
  13448. if m.id == nil || m.oldValue == nil {
  13449. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  13450. }
  13451. oldValue, err := m.oldValue(ctx)
  13452. if err != nil {
  13453. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  13454. }
  13455. return oldValue.BotWxid, nil
  13456. }
  13457. // ResetBotWxid resets all changes to the "bot_wxid" field.
  13458. func (m *MessageRecordsMutation) ResetBotWxid() {
  13459. m.bot_wxid = nil
  13460. }
  13461. // SetContactID sets the "contact_id" field.
  13462. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  13463. m.message_contact = &u
  13464. }
  13465. // ContactID returns the value of the "contact_id" field in the mutation.
  13466. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  13467. v := m.message_contact
  13468. if v == nil {
  13469. return
  13470. }
  13471. return *v, true
  13472. }
  13473. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  13474. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13476. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13477. if !m.op.Is(OpUpdateOne) {
  13478. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13479. }
  13480. if m.id == nil || m.oldValue == nil {
  13481. return v, errors.New("OldContactID requires an ID field in the mutation")
  13482. }
  13483. oldValue, err := m.oldValue(ctx)
  13484. if err != nil {
  13485. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13486. }
  13487. return oldValue.ContactID, nil
  13488. }
  13489. // ClearContactID clears the value of the "contact_id" field.
  13490. func (m *MessageRecordsMutation) ClearContactID() {
  13491. m.message_contact = nil
  13492. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  13493. }
  13494. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  13495. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  13496. _, ok := m.clearedFields[messagerecords.FieldContactID]
  13497. return ok
  13498. }
  13499. // ResetContactID resets all changes to the "contact_id" field.
  13500. func (m *MessageRecordsMutation) ResetContactID() {
  13501. m.message_contact = nil
  13502. delete(m.clearedFields, messagerecords.FieldContactID)
  13503. }
  13504. // SetContactType sets the "contact_type" field.
  13505. func (m *MessageRecordsMutation) SetContactType(i int) {
  13506. m.contact_type = &i
  13507. m.addcontact_type = nil
  13508. }
  13509. // ContactType returns the value of the "contact_type" field in the mutation.
  13510. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  13511. v := m.contact_type
  13512. if v == nil {
  13513. return
  13514. }
  13515. return *v, true
  13516. }
  13517. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  13518. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13520. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  13521. if !m.op.Is(OpUpdateOne) {
  13522. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  13523. }
  13524. if m.id == nil || m.oldValue == nil {
  13525. return v, errors.New("OldContactType requires an ID field in the mutation")
  13526. }
  13527. oldValue, err := m.oldValue(ctx)
  13528. if err != nil {
  13529. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  13530. }
  13531. return oldValue.ContactType, nil
  13532. }
  13533. // AddContactType adds i to the "contact_type" field.
  13534. func (m *MessageRecordsMutation) AddContactType(i int) {
  13535. if m.addcontact_type != nil {
  13536. *m.addcontact_type += i
  13537. } else {
  13538. m.addcontact_type = &i
  13539. }
  13540. }
  13541. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  13542. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  13543. v := m.addcontact_type
  13544. if v == nil {
  13545. return
  13546. }
  13547. return *v, true
  13548. }
  13549. // ResetContactType resets all changes to the "contact_type" field.
  13550. func (m *MessageRecordsMutation) ResetContactType() {
  13551. m.contact_type = nil
  13552. m.addcontact_type = nil
  13553. }
  13554. // SetContactWxid sets the "contact_wxid" field.
  13555. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  13556. m.contact_wxid = &s
  13557. }
  13558. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  13559. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  13560. v := m.contact_wxid
  13561. if v == nil {
  13562. return
  13563. }
  13564. return *v, true
  13565. }
  13566. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  13567. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13569. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  13570. if !m.op.Is(OpUpdateOne) {
  13571. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  13572. }
  13573. if m.id == nil || m.oldValue == nil {
  13574. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  13575. }
  13576. oldValue, err := m.oldValue(ctx)
  13577. if err != nil {
  13578. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  13579. }
  13580. return oldValue.ContactWxid, nil
  13581. }
  13582. // ResetContactWxid resets all changes to the "contact_wxid" field.
  13583. func (m *MessageRecordsMutation) ResetContactWxid() {
  13584. m.contact_wxid = nil
  13585. }
  13586. // SetContentType sets the "content_type" field.
  13587. func (m *MessageRecordsMutation) SetContentType(i int) {
  13588. m.content_type = &i
  13589. m.addcontent_type = nil
  13590. }
  13591. // ContentType returns the value of the "content_type" field in the mutation.
  13592. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  13593. v := m.content_type
  13594. if v == nil {
  13595. return
  13596. }
  13597. return *v, true
  13598. }
  13599. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  13600. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13602. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  13603. if !m.op.Is(OpUpdateOne) {
  13604. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  13605. }
  13606. if m.id == nil || m.oldValue == nil {
  13607. return v, errors.New("OldContentType requires an ID field in the mutation")
  13608. }
  13609. oldValue, err := m.oldValue(ctx)
  13610. if err != nil {
  13611. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  13612. }
  13613. return oldValue.ContentType, nil
  13614. }
  13615. // AddContentType adds i to the "content_type" field.
  13616. func (m *MessageRecordsMutation) AddContentType(i int) {
  13617. if m.addcontent_type != nil {
  13618. *m.addcontent_type += i
  13619. } else {
  13620. m.addcontent_type = &i
  13621. }
  13622. }
  13623. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  13624. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  13625. v := m.addcontent_type
  13626. if v == nil {
  13627. return
  13628. }
  13629. return *v, true
  13630. }
  13631. // ResetContentType resets all changes to the "content_type" field.
  13632. func (m *MessageRecordsMutation) ResetContentType() {
  13633. m.content_type = nil
  13634. m.addcontent_type = nil
  13635. }
  13636. // SetContent sets the "content" field.
  13637. func (m *MessageRecordsMutation) SetContent(s string) {
  13638. m.content = &s
  13639. }
  13640. // Content returns the value of the "content" field in the mutation.
  13641. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  13642. v := m.content
  13643. if v == nil {
  13644. return
  13645. }
  13646. return *v, true
  13647. }
  13648. // OldContent returns the old "content" field's value of the MessageRecords entity.
  13649. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13651. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  13652. if !m.op.Is(OpUpdateOne) {
  13653. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  13654. }
  13655. if m.id == nil || m.oldValue == nil {
  13656. return v, errors.New("OldContent requires an ID field in the mutation")
  13657. }
  13658. oldValue, err := m.oldValue(ctx)
  13659. if err != nil {
  13660. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  13661. }
  13662. return oldValue.Content, nil
  13663. }
  13664. // ResetContent resets all changes to the "content" field.
  13665. func (m *MessageRecordsMutation) ResetContent() {
  13666. m.content = nil
  13667. }
  13668. // SetMeta sets the "meta" field.
  13669. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  13670. m.meta = &ct
  13671. }
  13672. // Meta returns the value of the "meta" field in the mutation.
  13673. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  13674. v := m.meta
  13675. if v == nil {
  13676. return
  13677. }
  13678. return *v, true
  13679. }
  13680. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  13681. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13683. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  13684. if !m.op.Is(OpUpdateOne) {
  13685. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  13686. }
  13687. if m.id == nil || m.oldValue == nil {
  13688. return v, errors.New("OldMeta requires an ID field in the mutation")
  13689. }
  13690. oldValue, err := m.oldValue(ctx)
  13691. if err != nil {
  13692. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  13693. }
  13694. return oldValue.Meta, nil
  13695. }
  13696. // ClearMeta clears the value of the "meta" field.
  13697. func (m *MessageRecordsMutation) ClearMeta() {
  13698. m.meta = nil
  13699. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  13700. }
  13701. // MetaCleared returns if the "meta" field was cleared in this mutation.
  13702. func (m *MessageRecordsMutation) MetaCleared() bool {
  13703. _, ok := m.clearedFields[messagerecords.FieldMeta]
  13704. return ok
  13705. }
  13706. // ResetMeta resets all changes to the "meta" field.
  13707. func (m *MessageRecordsMutation) ResetMeta() {
  13708. m.meta = nil
  13709. delete(m.clearedFields, messagerecords.FieldMeta)
  13710. }
  13711. // SetErrorDetail sets the "error_detail" field.
  13712. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  13713. m.error_detail = &s
  13714. }
  13715. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  13716. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  13717. v := m.error_detail
  13718. if v == nil {
  13719. return
  13720. }
  13721. return *v, true
  13722. }
  13723. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  13724. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13726. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  13727. if !m.op.Is(OpUpdateOne) {
  13728. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  13729. }
  13730. if m.id == nil || m.oldValue == nil {
  13731. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  13732. }
  13733. oldValue, err := m.oldValue(ctx)
  13734. if err != nil {
  13735. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  13736. }
  13737. return oldValue.ErrorDetail, nil
  13738. }
  13739. // ResetErrorDetail resets all changes to the "error_detail" field.
  13740. func (m *MessageRecordsMutation) ResetErrorDetail() {
  13741. m.error_detail = nil
  13742. }
  13743. // SetSendTime sets the "send_time" field.
  13744. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  13745. m.send_time = &t
  13746. }
  13747. // SendTime returns the value of the "send_time" field in the mutation.
  13748. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  13749. v := m.send_time
  13750. if v == nil {
  13751. return
  13752. }
  13753. return *v, true
  13754. }
  13755. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  13756. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13758. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  13759. if !m.op.Is(OpUpdateOne) {
  13760. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  13761. }
  13762. if m.id == nil || m.oldValue == nil {
  13763. return v, errors.New("OldSendTime requires an ID field in the mutation")
  13764. }
  13765. oldValue, err := m.oldValue(ctx)
  13766. if err != nil {
  13767. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  13768. }
  13769. return oldValue.SendTime, nil
  13770. }
  13771. // ClearSendTime clears the value of the "send_time" field.
  13772. func (m *MessageRecordsMutation) ClearSendTime() {
  13773. m.send_time = nil
  13774. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  13775. }
  13776. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  13777. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  13778. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  13779. return ok
  13780. }
  13781. // ResetSendTime resets all changes to the "send_time" field.
  13782. func (m *MessageRecordsMutation) ResetSendTime() {
  13783. m.send_time = nil
  13784. delete(m.clearedFields, messagerecords.FieldSendTime)
  13785. }
  13786. // SetSourceType sets the "source_type" field.
  13787. func (m *MessageRecordsMutation) SetSourceType(i int) {
  13788. m.source_type = &i
  13789. m.addsource_type = nil
  13790. }
  13791. // SourceType returns the value of the "source_type" field in the mutation.
  13792. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  13793. v := m.source_type
  13794. if v == nil {
  13795. return
  13796. }
  13797. return *v, true
  13798. }
  13799. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  13800. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13802. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  13803. if !m.op.Is(OpUpdateOne) {
  13804. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  13805. }
  13806. if m.id == nil || m.oldValue == nil {
  13807. return v, errors.New("OldSourceType requires an ID field in the mutation")
  13808. }
  13809. oldValue, err := m.oldValue(ctx)
  13810. if err != nil {
  13811. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  13812. }
  13813. return oldValue.SourceType, nil
  13814. }
  13815. // AddSourceType adds i to the "source_type" field.
  13816. func (m *MessageRecordsMutation) AddSourceType(i int) {
  13817. if m.addsource_type != nil {
  13818. *m.addsource_type += i
  13819. } else {
  13820. m.addsource_type = &i
  13821. }
  13822. }
  13823. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  13824. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  13825. v := m.addsource_type
  13826. if v == nil {
  13827. return
  13828. }
  13829. return *v, true
  13830. }
  13831. // ResetSourceType resets all changes to the "source_type" field.
  13832. func (m *MessageRecordsMutation) ResetSourceType() {
  13833. m.source_type = nil
  13834. m.addsource_type = nil
  13835. }
  13836. // SetSourceID sets the "source_id" field.
  13837. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  13838. m.sop_stage = &u
  13839. }
  13840. // SourceID returns the value of the "source_id" field in the mutation.
  13841. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  13842. v := m.sop_stage
  13843. if v == nil {
  13844. return
  13845. }
  13846. return *v, true
  13847. }
  13848. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  13849. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13851. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  13852. if !m.op.Is(OpUpdateOne) {
  13853. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  13854. }
  13855. if m.id == nil || m.oldValue == nil {
  13856. return v, errors.New("OldSourceID requires an ID field in the mutation")
  13857. }
  13858. oldValue, err := m.oldValue(ctx)
  13859. if err != nil {
  13860. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  13861. }
  13862. return oldValue.SourceID, nil
  13863. }
  13864. // ClearSourceID clears the value of the "source_id" field.
  13865. func (m *MessageRecordsMutation) ClearSourceID() {
  13866. m.sop_stage = nil
  13867. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  13868. }
  13869. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  13870. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  13871. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  13872. return ok
  13873. }
  13874. // ResetSourceID resets all changes to the "source_id" field.
  13875. func (m *MessageRecordsMutation) ResetSourceID() {
  13876. m.sop_stage = nil
  13877. delete(m.clearedFields, messagerecords.FieldSourceID)
  13878. }
  13879. // SetSubSourceID sets the "sub_source_id" field.
  13880. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  13881. m.sop_node = &u
  13882. }
  13883. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  13884. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  13885. v := m.sop_node
  13886. if v == nil {
  13887. return
  13888. }
  13889. return *v, true
  13890. }
  13891. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  13892. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13894. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  13895. if !m.op.Is(OpUpdateOne) {
  13896. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  13897. }
  13898. if m.id == nil || m.oldValue == nil {
  13899. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  13900. }
  13901. oldValue, err := m.oldValue(ctx)
  13902. if err != nil {
  13903. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  13904. }
  13905. return oldValue.SubSourceID, nil
  13906. }
  13907. // ClearSubSourceID clears the value of the "sub_source_id" field.
  13908. func (m *MessageRecordsMutation) ClearSubSourceID() {
  13909. m.sop_node = nil
  13910. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  13911. }
  13912. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  13913. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  13914. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  13915. return ok
  13916. }
  13917. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  13918. func (m *MessageRecordsMutation) ResetSubSourceID() {
  13919. m.sop_node = nil
  13920. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  13921. }
  13922. // SetOrganizationID sets the "organization_id" field.
  13923. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  13924. m.organization_id = &u
  13925. m.addorganization_id = nil
  13926. }
  13927. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13928. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  13929. v := m.organization_id
  13930. if v == nil {
  13931. return
  13932. }
  13933. return *v, true
  13934. }
  13935. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  13936. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13938. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13939. if !m.op.Is(OpUpdateOne) {
  13940. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13941. }
  13942. if m.id == nil || m.oldValue == nil {
  13943. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13944. }
  13945. oldValue, err := m.oldValue(ctx)
  13946. if err != nil {
  13947. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13948. }
  13949. return oldValue.OrganizationID, nil
  13950. }
  13951. // AddOrganizationID adds u to the "organization_id" field.
  13952. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  13953. if m.addorganization_id != nil {
  13954. *m.addorganization_id += u
  13955. } else {
  13956. m.addorganization_id = &u
  13957. }
  13958. }
  13959. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13960. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  13961. v := m.addorganization_id
  13962. if v == nil {
  13963. return
  13964. }
  13965. return *v, true
  13966. }
  13967. // ClearOrganizationID clears the value of the "organization_id" field.
  13968. func (m *MessageRecordsMutation) ClearOrganizationID() {
  13969. m.organization_id = nil
  13970. m.addorganization_id = nil
  13971. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  13972. }
  13973. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13974. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  13975. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  13976. return ok
  13977. }
  13978. // ResetOrganizationID resets all changes to the "organization_id" field.
  13979. func (m *MessageRecordsMutation) ResetOrganizationID() {
  13980. m.organization_id = nil
  13981. m.addorganization_id = nil
  13982. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  13983. }
  13984. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  13985. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  13986. m.sop_stage = &id
  13987. }
  13988. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  13989. func (m *MessageRecordsMutation) ClearSopStage() {
  13990. m.clearedsop_stage = true
  13991. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  13992. }
  13993. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  13994. func (m *MessageRecordsMutation) SopStageCleared() bool {
  13995. return m.SourceIDCleared() || m.clearedsop_stage
  13996. }
  13997. // SopStageID returns the "sop_stage" edge ID in the mutation.
  13998. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  13999. if m.sop_stage != nil {
  14000. return *m.sop_stage, true
  14001. }
  14002. return
  14003. }
  14004. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  14005. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14006. // SopStageID instead. It exists only for internal usage by the builders.
  14007. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  14008. if id := m.sop_stage; id != nil {
  14009. ids = append(ids, *id)
  14010. }
  14011. return
  14012. }
  14013. // ResetSopStage resets all changes to the "sop_stage" edge.
  14014. func (m *MessageRecordsMutation) ResetSopStage() {
  14015. m.sop_stage = nil
  14016. m.clearedsop_stage = false
  14017. }
  14018. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  14019. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  14020. m.sop_node = &id
  14021. }
  14022. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  14023. func (m *MessageRecordsMutation) ClearSopNode() {
  14024. m.clearedsop_node = true
  14025. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  14026. }
  14027. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  14028. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  14029. return m.SubSourceIDCleared() || m.clearedsop_node
  14030. }
  14031. // SopNodeID returns the "sop_node" edge ID in the mutation.
  14032. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  14033. if m.sop_node != nil {
  14034. return *m.sop_node, true
  14035. }
  14036. return
  14037. }
  14038. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  14039. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14040. // SopNodeID instead. It exists only for internal usage by the builders.
  14041. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  14042. if id := m.sop_node; id != nil {
  14043. ids = append(ids, *id)
  14044. }
  14045. return
  14046. }
  14047. // ResetSopNode resets all changes to the "sop_node" edge.
  14048. func (m *MessageRecordsMutation) ResetSopNode() {
  14049. m.sop_node = nil
  14050. m.clearedsop_node = false
  14051. }
  14052. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  14053. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  14054. m.message_contact = &id
  14055. }
  14056. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  14057. func (m *MessageRecordsMutation) ClearMessageContact() {
  14058. m.clearedmessage_contact = true
  14059. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  14060. }
  14061. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  14062. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  14063. return m.ContactIDCleared() || m.clearedmessage_contact
  14064. }
  14065. // MessageContactID returns the "message_contact" edge ID in the mutation.
  14066. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  14067. if m.message_contact != nil {
  14068. return *m.message_contact, true
  14069. }
  14070. return
  14071. }
  14072. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  14073. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14074. // MessageContactID instead. It exists only for internal usage by the builders.
  14075. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  14076. if id := m.message_contact; id != nil {
  14077. ids = append(ids, *id)
  14078. }
  14079. return
  14080. }
  14081. // ResetMessageContact resets all changes to the "message_contact" edge.
  14082. func (m *MessageRecordsMutation) ResetMessageContact() {
  14083. m.message_contact = nil
  14084. m.clearedmessage_contact = false
  14085. }
  14086. // Where appends a list predicates to the MessageRecordsMutation builder.
  14087. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  14088. m.predicates = append(m.predicates, ps...)
  14089. }
  14090. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  14091. // users can use type-assertion to append predicates that do not depend on any generated package.
  14092. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  14093. p := make([]predicate.MessageRecords, len(ps))
  14094. for i := range ps {
  14095. p[i] = ps[i]
  14096. }
  14097. m.Where(p...)
  14098. }
  14099. // Op returns the operation name.
  14100. func (m *MessageRecordsMutation) Op() Op {
  14101. return m.op
  14102. }
  14103. // SetOp allows setting the mutation operation.
  14104. func (m *MessageRecordsMutation) SetOp(op Op) {
  14105. m.op = op
  14106. }
  14107. // Type returns the node type of this mutation (MessageRecords).
  14108. func (m *MessageRecordsMutation) Type() string {
  14109. return m.typ
  14110. }
  14111. // Fields returns all fields that were changed during this mutation. Note that in
  14112. // order to get all numeric fields that were incremented/decremented, call
  14113. // AddedFields().
  14114. func (m *MessageRecordsMutation) Fields() []string {
  14115. fields := make([]string, 0, 16)
  14116. if m.created_at != nil {
  14117. fields = append(fields, messagerecords.FieldCreatedAt)
  14118. }
  14119. if m.updated_at != nil {
  14120. fields = append(fields, messagerecords.FieldUpdatedAt)
  14121. }
  14122. if m.status != nil {
  14123. fields = append(fields, messagerecords.FieldStatus)
  14124. }
  14125. if m.bot_wxid != nil {
  14126. fields = append(fields, messagerecords.FieldBotWxid)
  14127. }
  14128. if m.message_contact != nil {
  14129. fields = append(fields, messagerecords.FieldContactID)
  14130. }
  14131. if m.contact_type != nil {
  14132. fields = append(fields, messagerecords.FieldContactType)
  14133. }
  14134. if m.contact_wxid != nil {
  14135. fields = append(fields, messagerecords.FieldContactWxid)
  14136. }
  14137. if m.content_type != nil {
  14138. fields = append(fields, messagerecords.FieldContentType)
  14139. }
  14140. if m.content != nil {
  14141. fields = append(fields, messagerecords.FieldContent)
  14142. }
  14143. if m.meta != nil {
  14144. fields = append(fields, messagerecords.FieldMeta)
  14145. }
  14146. if m.error_detail != nil {
  14147. fields = append(fields, messagerecords.FieldErrorDetail)
  14148. }
  14149. if m.send_time != nil {
  14150. fields = append(fields, messagerecords.FieldSendTime)
  14151. }
  14152. if m.source_type != nil {
  14153. fields = append(fields, messagerecords.FieldSourceType)
  14154. }
  14155. if m.sop_stage != nil {
  14156. fields = append(fields, messagerecords.FieldSourceID)
  14157. }
  14158. if m.sop_node != nil {
  14159. fields = append(fields, messagerecords.FieldSubSourceID)
  14160. }
  14161. if m.organization_id != nil {
  14162. fields = append(fields, messagerecords.FieldOrganizationID)
  14163. }
  14164. return fields
  14165. }
  14166. // Field returns the value of a field with the given name. The second boolean
  14167. // return value indicates that this field was not set, or was not defined in the
  14168. // schema.
  14169. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  14170. switch name {
  14171. case messagerecords.FieldCreatedAt:
  14172. return m.CreatedAt()
  14173. case messagerecords.FieldUpdatedAt:
  14174. return m.UpdatedAt()
  14175. case messagerecords.FieldStatus:
  14176. return m.Status()
  14177. case messagerecords.FieldBotWxid:
  14178. return m.BotWxid()
  14179. case messagerecords.FieldContactID:
  14180. return m.ContactID()
  14181. case messagerecords.FieldContactType:
  14182. return m.ContactType()
  14183. case messagerecords.FieldContactWxid:
  14184. return m.ContactWxid()
  14185. case messagerecords.FieldContentType:
  14186. return m.ContentType()
  14187. case messagerecords.FieldContent:
  14188. return m.Content()
  14189. case messagerecords.FieldMeta:
  14190. return m.Meta()
  14191. case messagerecords.FieldErrorDetail:
  14192. return m.ErrorDetail()
  14193. case messagerecords.FieldSendTime:
  14194. return m.SendTime()
  14195. case messagerecords.FieldSourceType:
  14196. return m.SourceType()
  14197. case messagerecords.FieldSourceID:
  14198. return m.SourceID()
  14199. case messagerecords.FieldSubSourceID:
  14200. return m.SubSourceID()
  14201. case messagerecords.FieldOrganizationID:
  14202. return m.OrganizationID()
  14203. }
  14204. return nil, false
  14205. }
  14206. // OldField returns the old value of the field from the database. An error is
  14207. // returned if the mutation operation is not UpdateOne, or the query to the
  14208. // database failed.
  14209. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14210. switch name {
  14211. case messagerecords.FieldCreatedAt:
  14212. return m.OldCreatedAt(ctx)
  14213. case messagerecords.FieldUpdatedAt:
  14214. return m.OldUpdatedAt(ctx)
  14215. case messagerecords.FieldStatus:
  14216. return m.OldStatus(ctx)
  14217. case messagerecords.FieldBotWxid:
  14218. return m.OldBotWxid(ctx)
  14219. case messagerecords.FieldContactID:
  14220. return m.OldContactID(ctx)
  14221. case messagerecords.FieldContactType:
  14222. return m.OldContactType(ctx)
  14223. case messagerecords.FieldContactWxid:
  14224. return m.OldContactWxid(ctx)
  14225. case messagerecords.FieldContentType:
  14226. return m.OldContentType(ctx)
  14227. case messagerecords.FieldContent:
  14228. return m.OldContent(ctx)
  14229. case messagerecords.FieldMeta:
  14230. return m.OldMeta(ctx)
  14231. case messagerecords.FieldErrorDetail:
  14232. return m.OldErrorDetail(ctx)
  14233. case messagerecords.FieldSendTime:
  14234. return m.OldSendTime(ctx)
  14235. case messagerecords.FieldSourceType:
  14236. return m.OldSourceType(ctx)
  14237. case messagerecords.FieldSourceID:
  14238. return m.OldSourceID(ctx)
  14239. case messagerecords.FieldSubSourceID:
  14240. return m.OldSubSourceID(ctx)
  14241. case messagerecords.FieldOrganizationID:
  14242. return m.OldOrganizationID(ctx)
  14243. }
  14244. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  14245. }
  14246. // SetField sets the value of a field with the given name. It returns an error if
  14247. // the field is not defined in the schema, or if the type mismatched the field
  14248. // type.
  14249. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  14250. switch name {
  14251. case messagerecords.FieldCreatedAt:
  14252. v, ok := value.(time.Time)
  14253. if !ok {
  14254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14255. }
  14256. m.SetCreatedAt(v)
  14257. return nil
  14258. case messagerecords.FieldUpdatedAt:
  14259. v, ok := value.(time.Time)
  14260. if !ok {
  14261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14262. }
  14263. m.SetUpdatedAt(v)
  14264. return nil
  14265. case messagerecords.FieldStatus:
  14266. v, ok := value.(uint8)
  14267. if !ok {
  14268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14269. }
  14270. m.SetStatus(v)
  14271. return nil
  14272. case messagerecords.FieldBotWxid:
  14273. v, ok := value.(string)
  14274. if !ok {
  14275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14276. }
  14277. m.SetBotWxid(v)
  14278. return nil
  14279. case messagerecords.FieldContactID:
  14280. v, ok := value.(uint64)
  14281. if !ok {
  14282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14283. }
  14284. m.SetContactID(v)
  14285. return nil
  14286. case messagerecords.FieldContactType:
  14287. v, ok := value.(int)
  14288. if !ok {
  14289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14290. }
  14291. m.SetContactType(v)
  14292. return nil
  14293. case messagerecords.FieldContactWxid:
  14294. v, ok := value.(string)
  14295. if !ok {
  14296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14297. }
  14298. m.SetContactWxid(v)
  14299. return nil
  14300. case messagerecords.FieldContentType:
  14301. v, ok := value.(int)
  14302. if !ok {
  14303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14304. }
  14305. m.SetContentType(v)
  14306. return nil
  14307. case messagerecords.FieldContent:
  14308. v, ok := value.(string)
  14309. if !ok {
  14310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14311. }
  14312. m.SetContent(v)
  14313. return nil
  14314. case messagerecords.FieldMeta:
  14315. v, ok := value.(custom_types.Meta)
  14316. if !ok {
  14317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14318. }
  14319. m.SetMeta(v)
  14320. return nil
  14321. case messagerecords.FieldErrorDetail:
  14322. v, ok := value.(string)
  14323. if !ok {
  14324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14325. }
  14326. m.SetErrorDetail(v)
  14327. return nil
  14328. case messagerecords.FieldSendTime:
  14329. v, ok := value.(time.Time)
  14330. if !ok {
  14331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14332. }
  14333. m.SetSendTime(v)
  14334. return nil
  14335. case messagerecords.FieldSourceType:
  14336. v, ok := value.(int)
  14337. if !ok {
  14338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14339. }
  14340. m.SetSourceType(v)
  14341. return nil
  14342. case messagerecords.FieldSourceID:
  14343. v, ok := value.(uint64)
  14344. if !ok {
  14345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14346. }
  14347. m.SetSourceID(v)
  14348. return nil
  14349. case messagerecords.FieldSubSourceID:
  14350. v, ok := value.(uint64)
  14351. if !ok {
  14352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14353. }
  14354. m.SetSubSourceID(v)
  14355. return nil
  14356. case messagerecords.FieldOrganizationID:
  14357. v, ok := value.(uint64)
  14358. if !ok {
  14359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14360. }
  14361. m.SetOrganizationID(v)
  14362. return nil
  14363. }
  14364. return fmt.Errorf("unknown MessageRecords field %s", name)
  14365. }
  14366. // AddedFields returns all numeric fields that were incremented/decremented during
  14367. // this mutation.
  14368. func (m *MessageRecordsMutation) AddedFields() []string {
  14369. var fields []string
  14370. if m.addstatus != nil {
  14371. fields = append(fields, messagerecords.FieldStatus)
  14372. }
  14373. if m.addcontact_type != nil {
  14374. fields = append(fields, messagerecords.FieldContactType)
  14375. }
  14376. if m.addcontent_type != nil {
  14377. fields = append(fields, messagerecords.FieldContentType)
  14378. }
  14379. if m.addsource_type != nil {
  14380. fields = append(fields, messagerecords.FieldSourceType)
  14381. }
  14382. if m.addorganization_id != nil {
  14383. fields = append(fields, messagerecords.FieldOrganizationID)
  14384. }
  14385. return fields
  14386. }
  14387. // AddedField returns the numeric value that was incremented/decremented on a field
  14388. // with the given name. The second boolean return value indicates that this field
  14389. // was not set, or was not defined in the schema.
  14390. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  14391. switch name {
  14392. case messagerecords.FieldStatus:
  14393. return m.AddedStatus()
  14394. case messagerecords.FieldContactType:
  14395. return m.AddedContactType()
  14396. case messagerecords.FieldContentType:
  14397. return m.AddedContentType()
  14398. case messagerecords.FieldSourceType:
  14399. return m.AddedSourceType()
  14400. case messagerecords.FieldOrganizationID:
  14401. return m.AddedOrganizationID()
  14402. }
  14403. return nil, false
  14404. }
  14405. // AddField adds the value to the field with the given name. It returns an error if
  14406. // the field is not defined in the schema, or if the type mismatched the field
  14407. // type.
  14408. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  14409. switch name {
  14410. case messagerecords.FieldStatus:
  14411. v, ok := value.(int8)
  14412. if !ok {
  14413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14414. }
  14415. m.AddStatus(v)
  14416. return nil
  14417. case messagerecords.FieldContactType:
  14418. v, ok := value.(int)
  14419. if !ok {
  14420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14421. }
  14422. m.AddContactType(v)
  14423. return nil
  14424. case messagerecords.FieldContentType:
  14425. v, ok := value.(int)
  14426. if !ok {
  14427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14428. }
  14429. m.AddContentType(v)
  14430. return nil
  14431. case messagerecords.FieldSourceType:
  14432. v, ok := value.(int)
  14433. if !ok {
  14434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14435. }
  14436. m.AddSourceType(v)
  14437. return nil
  14438. case messagerecords.FieldOrganizationID:
  14439. v, ok := value.(int64)
  14440. if !ok {
  14441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14442. }
  14443. m.AddOrganizationID(v)
  14444. return nil
  14445. }
  14446. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  14447. }
  14448. // ClearedFields returns all nullable fields that were cleared during this
  14449. // mutation.
  14450. func (m *MessageRecordsMutation) ClearedFields() []string {
  14451. var fields []string
  14452. if m.FieldCleared(messagerecords.FieldStatus) {
  14453. fields = append(fields, messagerecords.FieldStatus)
  14454. }
  14455. if m.FieldCleared(messagerecords.FieldContactID) {
  14456. fields = append(fields, messagerecords.FieldContactID)
  14457. }
  14458. if m.FieldCleared(messagerecords.FieldMeta) {
  14459. fields = append(fields, messagerecords.FieldMeta)
  14460. }
  14461. if m.FieldCleared(messagerecords.FieldSendTime) {
  14462. fields = append(fields, messagerecords.FieldSendTime)
  14463. }
  14464. if m.FieldCleared(messagerecords.FieldSourceID) {
  14465. fields = append(fields, messagerecords.FieldSourceID)
  14466. }
  14467. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  14468. fields = append(fields, messagerecords.FieldSubSourceID)
  14469. }
  14470. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  14471. fields = append(fields, messagerecords.FieldOrganizationID)
  14472. }
  14473. return fields
  14474. }
  14475. // FieldCleared returns a boolean indicating if a field with the given name was
  14476. // cleared in this mutation.
  14477. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  14478. _, ok := m.clearedFields[name]
  14479. return ok
  14480. }
  14481. // ClearField clears the value of the field with the given name. It returns an
  14482. // error if the field is not defined in the schema.
  14483. func (m *MessageRecordsMutation) ClearField(name string) error {
  14484. switch name {
  14485. case messagerecords.FieldStatus:
  14486. m.ClearStatus()
  14487. return nil
  14488. case messagerecords.FieldContactID:
  14489. m.ClearContactID()
  14490. return nil
  14491. case messagerecords.FieldMeta:
  14492. m.ClearMeta()
  14493. return nil
  14494. case messagerecords.FieldSendTime:
  14495. m.ClearSendTime()
  14496. return nil
  14497. case messagerecords.FieldSourceID:
  14498. m.ClearSourceID()
  14499. return nil
  14500. case messagerecords.FieldSubSourceID:
  14501. m.ClearSubSourceID()
  14502. return nil
  14503. case messagerecords.FieldOrganizationID:
  14504. m.ClearOrganizationID()
  14505. return nil
  14506. }
  14507. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  14508. }
  14509. // ResetField resets all changes in the mutation for the field with the given name.
  14510. // It returns an error if the field is not defined in the schema.
  14511. func (m *MessageRecordsMutation) ResetField(name string) error {
  14512. switch name {
  14513. case messagerecords.FieldCreatedAt:
  14514. m.ResetCreatedAt()
  14515. return nil
  14516. case messagerecords.FieldUpdatedAt:
  14517. m.ResetUpdatedAt()
  14518. return nil
  14519. case messagerecords.FieldStatus:
  14520. m.ResetStatus()
  14521. return nil
  14522. case messagerecords.FieldBotWxid:
  14523. m.ResetBotWxid()
  14524. return nil
  14525. case messagerecords.FieldContactID:
  14526. m.ResetContactID()
  14527. return nil
  14528. case messagerecords.FieldContactType:
  14529. m.ResetContactType()
  14530. return nil
  14531. case messagerecords.FieldContactWxid:
  14532. m.ResetContactWxid()
  14533. return nil
  14534. case messagerecords.FieldContentType:
  14535. m.ResetContentType()
  14536. return nil
  14537. case messagerecords.FieldContent:
  14538. m.ResetContent()
  14539. return nil
  14540. case messagerecords.FieldMeta:
  14541. m.ResetMeta()
  14542. return nil
  14543. case messagerecords.FieldErrorDetail:
  14544. m.ResetErrorDetail()
  14545. return nil
  14546. case messagerecords.FieldSendTime:
  14547. m.ResetSendTime()
  14548. return nil
  14549. case messagerecords.FieldSourceType:
  14550. m.ResetSourceType()
  14551. return nil
  14552. case messagerecords.FieldSourceID:
  14553. m.ResetSourceID()
  14554. return nil
  14555. case messagerecords.FieldSubSourceID:
  14556. m.ResetSubSourceID()
  14557. return nil
  14558. case messagerecords.FieldOrganizationID:
  14559. m.ResetOrganizationID()
  14560. return nil
  14561. }
  14562. return fmt.Errorf("unknown MessageRecords field %s", name)
  14563. }
  14564. // AddedEdges returns all edge names that were set/added in this mutation.
  14565. func (m *MessageRecordsMutation) AddedEdges() []string {
  14566. edges := make([]string, 0, 3)
  14567. if m.sop_stage != nil {
  14568. edges = append(edges, messagerecords.EdgeSopStage)
  14569. }
  14570. if m.sop_node != nil {
  14571. edges = append(edges, messagerecords.EdgeSopNode)
  14572. }
  14573. if m.message_contact != nil {
  14574. edges = append(edges, messagerecords.EdgeMessageContact)
  14575. }
  14576. return edges
  14577. }
  14578. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14579. // name in this mutation.
  14580. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  14581. switch name {
  14582. case messagerecords.EdgeSopStage:
  14583. if id := m.sop_stage; id != nil {
  14584. return []ent.Value{*id}
  14585. }
  14586. case messagerecords.EdgeSopNode:
  14587. if id := m.sop_node; id != nil {
  14588. return []ent.Value{*id}
  14589. }
  14590. case messagerecords.EdgeMessageContact:
  14591. if id := m.message_contact; id != nil {
  14592. return []ent.Value{*id}
  14593. }
  14594. }
  14595. return nil
  14596. }
  14597. // RemovedEdges returns all edge names that were removed in this mutation.
  14598. func (m *MessageRecordsMutation) RemovedEdges() []string {
  14599. edges := make([]string, 0, 3)
  14600. return edges
  14601. }
  14602. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14603. // the given name in this mutation.
  14604. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  14605. return nil
  14606. }
  14607. // ClearedEdges returns all edge names that were cleared in this mutation.
  14608. func (m *MessageRecordsMutation) ClearedEdges() []string {
  14609. edges := make([]string, 0, 3)
  14610. if m.clearedsop_stage {
  14611. edges = append(edges, messagerecords.EdgeSopStage)
  14612. }
  14613. if m.clearedsop_node {
  14614. edges = append(edges, messagerecords.EdgeSopNode)
  14615. }
  14616. if m.clearedmessage_contact {
  14617. edges = append(edges, messagerecords.EdgeMessageContact)
  14618. }
  14619. return edges
  14620. }
  14621. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14622. // was cleared in this mutation.
  14623. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  14624. switch name {
  14625. case messagerecords.EdgeSopStage:
  14626. return m.clearedsop_stage
  14627. case messagerecords.EdgeSopNode:
  14628. return m.clearedsop_node
  14629. case messagerecords.EdgeMessageContact:
  14630. return m.clearedmessage_contact
  14631. }
  14632. return false
  14633. }
  14634. // ClearEdge clears the value of the edge with the given name. It returns an error
  14635. // if that edge is not defined in the schema.
  14636. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  14637. switch name {
  14638. case messagerecords.EdgeSopStage:
  14639. m.ClearSopStage()
  14640. return nil
  14641. case messagerecords.EdgeSopNode:
  14642. m.ClearSopNode()
  14643. return nil
  14644. case messagerecords.EdgeMessageContact:
  14645. m.ClearMessageContact()
  14646. return nil
  14647. }
  14648. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  14649. }
  14650. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14651. // It returns an error if the edge is not defined in the schema.
  14652. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  14653. switch name {
  14654. case messagerecords.EdgeSopStage:
  14655. m.ResetSopStage()
  14656. return nil
  14657. case messagerecords.EdgeSopNode:
  14658. m.ResetSopNode()
  14659. return nil
  14660. case messagerecords.EdgeMessageContact:
  14661. m.ResetMessageContact()
  14662. return nil
  14663. }
  14664. return fmt.Errorf("unknown MessageRecords edge %s", name)
  14665. }
  14666. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  14667. type MsgMutation struct {
  14668. config
  14669. op Op
  14670. typ string
  14671. id *uint64
  14672. created_at *time.Time
  14673. updated_at *time.Time
  14674. deleted_at *time.Time
  14675. status *uint8
  14676. addstatus *int8
  14677. fromwxid *string
  14678. toid *string
  14679. msgtype *int32
  14680. addmsgtype *int32
  14681. msg *string
  14682. batch_no *string
  14683. clearedFields map[string]struct{}
  14684. done bool
  14685. oldValue func(context.Context) (*Msg, error)
  14686. predicates []predicate.Msg
  14687. }
  14688. var _ ent.Mutation = (*MsgMutation)(nil)
  14689. // msgOption allows management of the mutation configuration using functional options.
  14690. type msgOption func(*MsgMutation)
  14691. // newMsgMutation creates new mutation for the Msg entity.
  14692. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  14693. m := &MsgMutation{
  14694. config: c,
  14695. op: op,
  14696. typ: TypeMsg,
  14697. clearedFields: make(map[string]struct{}),
  14698. }
  14699. for _, opt := range opts {
  14700. opt(m)
  14701. }
  14702. return m
  14703. }
  14704. // withMsgID sets the ID field of the mutation.
  14705. func withMsgID(id uint64) msgOption {
  14706. return func(m *MsgMutation) {
  14707. var (
  14708. err error
  14709. once sync.Once
  14710. value *Msg
  14711. )
  14712. m.oldValue = func(ctx context.Context) (*Msg, error) {
  14713. once.Do(func() {
  14714. if m.done {
  14715. err = errors.New("querying old values post mutation is not allowed")
  14716. } else {
  14717. value, err = m.Client().Msg.Get(ctx, id)
  14718. }
  14719. })
  14720. return value, err
  14721. }
  14722. m.id = &id
  14723. }
  14724. }
  14725. // withMsg sets the old Msg of the mutation.
  14726. func withMsg(node *Msg) msgOption {
  14727. return func(m *MsgMutation) {
  14728. m.oldValue = func(context.Context) (*Msg, error) {
  14729. return node, nil
  14730. }
  14731. m.id = &node.ID
  14732. }
  14733. }
  14734. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14735. // executed in a transaction (ent.Tx), a transactional client is returned.
  14736. func (m MsgMutation) Client() *Client {
  14737. client := &Client{config: m.config}
  14738. client.init()
  14739. return client
  14740. }
  14741. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14742. // it returns an error otherwise.
  14743. func (m MsgMutation) Tx() (*Tx, error) {
  14744. if _, ok := m.driver.(*txDriver); !ok {
  14745. return nil, errors.New("ent: mutation is not running in a transaction")
  14746. }
  14747. tx := &Tx{config: m.config}
  14748. tx.init()
  14749. return tx, nil
  14750. }
  14751. // SetID sets the value of the id field. Note that this
  14752. // operation is only accepted on creation of Msg entities.
  14753. func (m *MsgMutation) SetID(id uint64) {
  14754. m.id = &id
  14755. }
  14756. // ID returns the ID value in the mutation. Note that the ID is only available
  14757. // if it was provided to the builder or after it was returned from the database.
  14758. func (m *MsgMutation) ID() (id uint64, exists bool) {
  14759. if m.id == nil {
  14760. return
  14761. }
  14762. return *m.id, true
  14763. }
  14764. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14765. // That means, if the mutation is applied within a transaction with an isolation level such
  14766. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14767. // or updated by the mutation.
  14768. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  14769. switch {
  14770. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14771. id, exists := m.ID()
  14772. if exists {
  14773. return []uint64{id}, nil
  14774. }
  14775. fallthrough
  14776. case m.op.Is(OpUpdate | OpDelete):
  14777. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  14778. default:
  14779. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14780. }
  14781. }
  14782. // SetCreatedAt sets the "created_at" field.
  14783. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  14784. m.created_at = &t
  14785. }
  14786. // CreatedAt returns the value of the "created_at" field in the mutation.
  14787. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  14788. v := m.created_at
  14789. if v == nil {
  14790. return
  14791. }
  14792. return *v, true
  14793. }
  14794. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  14795. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14797. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14798. if !m.op.Is(OpUpdateOne) {
  14799. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14800. }
  14801. if m.id == nil || m.oldValue == nil {
  14802. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14803. }
  14804. oldValue, err := m.oldValue(ctx)
  14805. if err != nil {
  14806. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14807. }
  14808. return oldValue.CreatedAt, nil
  14809. }
  14810. // ResetCreatedAt resets all changes to the "created_at" field.
  14811. func (m *MsgMutation) ResetCreatedAt() {
  14812. m.created_at = nil
  14813. }
  14814. // SetUpdatedAt sets the "updated_at" field.
  14815. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  14816. m.updated_at = &t
  14817. }
  14818. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14819. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  14820. v := m.updated_at
  14821. if v == nil {
  14822. return
  14823. }
  14824. return *v, true
  14825. }
  14826. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  14827. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14829. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14830. if !m.op.Is(OpUpdateOne) {
  14831. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14832. }
  14833. if m.id == nil || m.oldValue == nil {
  14834. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14835. }
  14836. oldValue, err := m.oldValue(ctx)
  14837. if err != nil {
  14838. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14839. }
  14840. return oldValue.UpdatedAt, nil
  14841. }
  14842. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14843. func (m *MsgMutation) ResetUpdatedAt() {
  14844. m.updated_at = nil
  14845. }
  14846. // SetDeletedAt sets the "deleted_at" field.
  14847. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  14848. m.deleted_at = &t
  14849. }
  14850. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14851. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  14852. v := m.deleted_at
  14853. if v == nil {
  14854. return
  14855. }
  14856. return *v, true
  14857. }
  14858. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  14859. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14861. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14862. if !m.op.Is(OpUpdateOne) {
  14863. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14864. }
  14865. if m.id == nil || m.oldValue == nil {
  14866. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14867. }
  14868. oldValue, err := m.oldValue(ctx)
  14869. if err != nil {
  14870. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14871. }
  14872. return oldValue.DeletedAt, nil
  14873. }
  14874. // ClearDeletedAt clears the value of the "deleted_at" field.
  14875. func (m *MsgMutation) ClearDeletedAt() {
  14876. m.deleted_at = nil
  14877. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  14878. }
  14879. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14880. func (m *MsgMutation) DeletedAtCleared() bool {
  14881. _, ok := m.clearedFields[msg.FieldDeletedAt]
  14882. return ok
  14883. }
  14884. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14885. func (m *MsgMutation) ResetDeletedAt() {
  14886. m.deleted_at = nil
  14887. delete(m.clearedFields, msg.FieldDeletedAt)
  14888. }
  14889. // SetStatus sets the "status" field.
  14890. func (m *MsgMutation) SetStatus(u uint8) {
  14891. m.status = &u
  14892. m.addstatus = nil
  14893. }
  14894. // Status returns the value of the "status" field in the mutation.
  14895. func (m *MsgMutation) Status() (r uint8, exists bool) {
  14896. v := m.status
  14897. if v == nil {
  14898. return
  14899. }
  14900. return *v, true
  14901. }
  14902. // OldStatus returns the old "status" field's value of the Msg entity.
  14903. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14905. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14906. if !m.op.Is(OpUpdateOne) {
  14907. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14908. }
  14909. if m.id == nil || m.oldValue == nil {
  14910. return v, errors.New("OldStatus requires an ID field in the mutation")
  14911. }
  14912. oldValue, err := m.oldValue(ctx)
  14913. if err != nil {
  14914. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14915. }
  14916. return oldValue.Status, nil
  14917. }
  14918. // AddStatus adds u to the "status" field.
  14919. func (m *MsgMutation) AddStatus(u int8) {
  14920. if m.addstatus != nil {
  14921. *m.addstatus += u
  14922. } else {
  14923. m.addstatus = &u
  14924. }
  14925. }
  14926. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14927. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  14928. v := m.addstatus
  14929. if v == nil {
  14930. return
  14931. }
  14932. return *v, true
  14933. }
  14934. // ClearStatus clears the value of the "status" field.
  14935. func (m *MsgMutation) ClearStatus() {
  14936. m.status = nil
  14937. m.addstatus = nil
  14938. m.clearedFields[msg.FieldStatus] = struct{}{}
  14939. }
  14940. // StatusCleared returns if the "status" field was cleared in this mutation.
  14941. func (m *MsgMutation) StatusCleared() bool {
  14942. _, ok := m.clearedFields[msg.FieldStatus]
  14943. return ok
  14944. }
  14945. // ResetStatus resets all changes to the "status" field.
  14946. func (m *MsgMutation) ResetStatus() {
  14947. m.status = nil
  14948. m.addstatus = nil
  14949. delete(m.clearedFields, msg.FieldStatus)
  14950. }
  14951. // SetFromwxid sets the "fromwxid" field.
  14952. func (m *MsgMutation) SetFromwxid(s string) {
  14953. m.fromwxid = &s
  14954. }
  14955. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  14956. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  14957. v := m.fromwxid
  14958. if v == nil {
  14959. return
  14960. }
  14961. return *v, true
  14962. }
  14963. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  14964. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14966. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  14967. if !m.op.Is(OpUpdateOne) {
  14968. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  14969. }
  14970. if m.id == nil || m.oldValue == nil {
  14971. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  14972. }
  14973. oldValue, err := m.oldValue(ctx)
  14974. if err != nil {
  14975. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  14976. }
  14977. return oldValue.Fromwxid, nil
  14978. }
  14979. // ClearFromwxid clears the value of the "fromwxid" field.
  14980. func (m *MsgMutation) ClearFromwxid() {
  14981. m.fromwxid = nil
  14982. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  14983. }
  14984. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  14985. func (m *MsgMutation) FromwxidCleared() bool {
  14986. _, ok := m.clearedFields[msg.FieldFromwxid]
  14987. return ok
  14988. }
  14989. // ResetFromwxid resets all changes to the "fromwxid" field.
  14990. func (m *MsgMutation) ResetFromwxid() {
  14991. m.fromwxid = nil
  14992. delete(m.clearedFields, msg.FieldFromwxid)
  14993. }
  14994. // SetToid sets the "toid" field.
  14995. func (m *MsgMutation) SetToid(s string) {
  14996. m.toid = &s
  14997. }
  14998. // Toid returns the value of the "toid" field in the mutation.
  14999. func (m *MsgMutation) Toid() (r string, exists bool) {
  15000. v := m.toid
  15001. if v == nil {
  15002. return
  15003. }
  15004. return *v, true
  15005. }
  15006. // OldToid returns the old "toid" field's value of the Msg entity.
  15007. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15009. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  15010. if !m.op.Is(OpUpdateOne) {
  15011. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  15012. }
  15013. if m.id == nil || m.oldValue == nil {
  15014. return v, errors.New("OldToid requires an ID field in the mutation")
  15015. }
  15016. oldValue, err := m.oldValue(ctx)
  15017. if err != nil {
  15018. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  15019. }
  15020. return oldValue.Toid, nil
  15021. }
  15022. // ClearToid clears the value of the "toid" field.
  15023. func (m *MsgMutation) ClearToid() {
  15024. m.toid = nil
  15025. m.clearedFields[msg.FieldToid] = struct{}{}
  15026. }
  15027. // ToidCleared returns if the "toid" field was cleared in this mutation.
  15028. func (m *MsgMutation) ToidCleared() bool {
  15029. _, ok := m.clearedFields[msg.FieldToid]
  15030. return ok
  15031. }
  15032. // ResetToid resets all changes to the "toid" field.
  15033. func (m *MsgMutation) ResetToid() {
  15034. m.toid = nil
  15035. delete(m.clearedFields, msg.FieldToid)
  15036. }
  15037. // SetMsgtype sets the "msgtype" field.
  15038. func (m *MsgMutation) SetMsgtype(i int32) {
  15039. m.msgtype = &i
  15040. m.addmsgtype = nil
  15041. }
  15042. // Msgtype returns the value of the "msgtype" field in the mutation.
  15043. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  15044. v := m.msgtype
  15045. if v == nil {
  15046. return
  15047. }
  15048. return *v, true
  15049. }
  15050. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  15051. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15053. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  15054. if !m.op.Is(OpUpdateOne) {
  15055. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  15056. }
  15057. if m.id == nil || m.oldValue == nil {
  15058. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  15059. }
  15060. oldValue, err := m.oldValue(ctx)
  15061. if err != nil {
  15062. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  15063. }
  15064. return oldValue.Msgtype, nil
  15065. }
  15066. // AddMsgtype adds i to the "msgtype" field.
  15067. func (m *MsgMutation) AddMsgtype(i int32) {
  15068. if m.addmsgtype != nil {
  15069. *m.addmsgtype += i
  15070. } else {
  15071. m.addmsgtype = &i
  15072. }
  15073. }
  15074. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  15075. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  15076. v := m.addmsgtype
  15077. if v == nil {
  15078. return
  15079. }
  15080. return *v, true
  15081. }
  15082. // ClearMsgtype clears the value of the "msgtype" field.
  15083. func (m *MsgMutation) ClearMsgtype() {
  15084. m.msgtype = nil
  15085. m.addmsgtype = nil
  15086. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  15087. }
  15088. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  15089. func (m *MsgMutation) MsgtypeCleared() bool {
  15090. _, ok := m.clearedFields[msg.FieldMsgtype]
  15091. return ok
  15092. }
  15093. // ResetMsgtype resets all changes to the "msgtype" field.
  15094. func (m *MsgMutation) ResetMsgtype() {
  15095. m.msgtype = nil
  15096. m.addmsgtype = nil
  15097. delete(m.clearedFields, msg.FieldMsgtype)
  15098. }
  15099. // SetMsg sets the "msg" field.
  15100. func (m *MsgMutation) SetMsg(s string) {
  15101. m.msg = &s
  15102. }
  15103. // Msg returns the value of the "msg" field in the mutation.
  15104. func (m *MsgMutation) Msg() (r string, exists bool) {
  15105. v := m.msg
  15106. if v == nil {
  15107. return
  15108. }
  15109. return *v, true
  15110. }
  15111. // OldMsg returns the old "msg" field's value of the Msg entity.
  15112. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15114. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  15115. if !m.op.Is(OpUpdateOne) {
  15116. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  15117. }
  15118. if m.id == nil || m.oldValue == nil {
  15119. return v, errors.New("OldMsg requires an ID field in the mutation")
  15120. }
  15121. oldValue, err := m.oldValue(ctx)
  15122. if err != nil {
  15123. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  15124. }
  15125. return oldValue.Msg, nil
  15126. }
  15127. // ClearMsg clears the value of the "msg" field.
  15128. func (m *MsgMutation) ClearMsg() {
  15129. m.msg = nil
  15130. m.clearedFields[msg.FieldMsg] = struct{}{}
  15131. }
  15132. // MsgCleared returns if the "msg" field was cleared in this mutation.
  15133. func (m *MsgMutation) MsgCleared() bool {
  15134. _, ok := m.clearedFields[msg.FieldMsg]
  15135. return ok
  15136. }
  15137. // ResetMsg resets all changes to the "msg" field.
  15138. func (m *MsgMutation) ResetMsg() {
  15139. m.msg = nil
  15140. delete(m.clearedFields, msg.FieldMsg)
  15141. }
  15142. // SetBatchNo sets the "batch_no" field.
  15143. func (m *MsgMutation) SetBatchNo(s string) {
  15144. m.batch_no = &s
  15145. }
  15146. // BatchNo returns the value of the "batch_no" field in the mutation.
  15147. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  15148. v := m.batch_no
  15149. if v == nil {
  15150. return
  15151. }
  15152. return *v, true
  15153. }
  15154. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  15155. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15157. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  15158. if !m.op.Is(OpUpdateOne) {
  15159. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  15160. }
  15161. if m.id == nil || m.oldValue == nil {
  15162. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  15163. }
  15164. oldValue, err := m.oldValue(ctx)
  15165. if err != nil {
  15166. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  15167. }
  15168. return oldValue.BatchNo, nil
  15169. }
  15170. // ClearBatchNo clears the value of the "batch_no" field.
  15171. func (m *MsgMutation) ClearBatchNo() {
  15172. m.batch_no = nil
  15173. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  15174. }
  15175. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  15176. func (m *MsgMutation) BatchNoCleared() bool {
  15177. _, ok := m.clearedFields[msg.FieldBatchNo]
  15178. return ok
  15179. }
  15180. // ResetBatchNo resets all changes to the "batch_no" field.
  15181. func (m *MsgMutation) ResetBatchNo() {
  15182. m.batch_no = nil
  15183. delete(m.clearedFields, msg.FieldBatchNo)
  15184. }
  15185. // Where appends a list predicates to the MsgMutation builder.
  15186. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  15187. m.predicates = append(m.predicates, ps...)
  15188. }
  15189. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  15190. // users can use type-assertion to append predicates that do not depend on any generated package.
  15191. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  15192. p := make([]predicate.Msg, len(ps))
  15193. for i := range ps {
  15194. p[i] = ps[i]
  15195. }
  15196. m.Where(p...)
  15197. }
  15198. // Op returns the operation name.
  15199. func (m *MsgMutation) Op() Op {
  15200. return m.op
  15201. }
  15202. // SetOp allows setting the mutation operation.
  15203. func (m *MsgMutation) SetOp(op Op) {
  15204. m.op = op
  15205. }
  15206. // Type returns the node type of this mutation (Msg).
  15207. func (m *MsgMutation) Type() string {
  15208. return m.typ
  15209. }
  15210. // Fields returns all fields that were changed during this mutation. Note that in
  15211. // order to get all numeric fields that were incremented/decremented, call
  15212. // AddedFields().
  15213. func (m *MsgMutation) Fields() []string {
  15214. fields := make([]string, 0, 9)
  15215. if m.created_at != nil {
  15216. fields = append(fields, msg.FieldCreatedAt)
  15217. }
  15218. if m.updated_at != nil {
  15219. fields = append(fields, msg.FieldUpdatedAt)
  15220. }
  15221. if m.deleted_at != nil {
  15222. fields = append(fields, msg.FieldDeletedAt)
  15223. }
  15224. if m.status != nil {
  15225. fields = append(fields, msg.FieldStatus)
  15226. }
  15227. if m.fromwxid != nil {
  15228. fields = append(fields, msg.FieldFromwxid)
  15229. }
  15230. if m.toid != nil {
  15231. fields = append(fields, msg.FieldToid)
  15232. }
  15233. if m.msgtype != nil {
  15234. fields = append(fields, msg.FieldMsgtype)
  15235. }
  15236. if m.msg != nil {
  15237. fields = append(fields, msg.FieldMsg)
  15238. }
  15239. if m.batch_no != nil {
  15240. fields = append(fields, msg.FieldBatchNo)
  15241. }
  15242. return fields
  15243. }
  15244. // Field returns the value of a field with the given name. The second boolean
  15245. // return value indicates that this field was not set, or was not defined in the
  15246. // schema.
  15247. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  15248. switch name {
  15249. case msg.FieldCreatedAt:
  15250. return m.CreatedAt()
  15251. case msg.FieldUpdatedAt:
  15252. return m.UpdatedAt()
  15253. case msg.FieldDeletedAt:
  15254. return m.DeletedAt()
  15255. case msg.FieldStatus:
  15256. return m.Status()
  15257. case msg.FieldFromwxid:
  15258. return m.Fromwxid()
  15259. case msg.FieldToid:
  15260. return m.Toid()
  15261. case msg.FieldMsgtype:
  15262. return m.Msgtype()
  15263. case msg.FieldMsg:
  15264. return m.Msg()
  15265. case msg.FieldBatchNo:
  15266. return m.BatchNo()
  15267. }
  15268. return nil, false
  15269. }
  15270. // OldField returns the old value of the field from the database. An error is
  15271. // returned if the mutation operation is not UpdateOne, or the query to the
  15272. // database failed.
  15273. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15274. switch name {
  15275. case msg.FieldCreatedAt:
  15276. return m.OldCreatedAt(ctx)
  15277. case msg.FieldUpdatedAt:
  15278. return m.OldUpdatedAt(ctx)
  15279. case msg.FieldDeletedAt:
  15280. return m.OldDeletedAt(ctx)
  15281. case msg.FieldStatus:
  15282. return m.OldStatus(ctx)
  15283. case msg.FieldFromwxid:
  15284. return m.OldFromwxid(ctx)
  15285. case msg.FieldToid:
  15286. return m.OldToid(ctx)
  15287. case msg.FieldMsgtype:
  15288. return m.OldMsgtype(ctx)
  15289. case msg.FieldMsg:
  15290. return m.OldMsg(ctx)
  15291. case msg.FieldBatchNo:
  15292. return m.OldBatchNo(ctx)
  15293. }
  15294. return nil, fmt.Errorf("unknown Msg field %s", name)
  15295. }
  15296. // SetField sets the value of a field with the given name. It returns an error if
  15297. // the field is not defined in the schema, or if the type mismatched the field
  15298. // type.
  15299. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  15300. switch name {
  15301. case msg.FieldCreatedAt:
  15302. v, ok := value.(time.Time)
  15303. if !ok {
  15304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15305. }
  15306. m.SetCreatedAt(v)
  15307. return nil
  15308. case msg.FieldUpdatedAt:
  15309. v, ok := value.(time.Time)
  15310. if !ok {
  15311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15312. }
  15313. m.SetUpdatedAt(v)
  15314. return nil
  15315. case msg.FieldDeletedAt:
  15316. v, ok := value.(time.Time)
  15317. if !ok {
  15318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15319. }
  15320. m.SetDeletedAt(v)
  15321. return nil
  15322. case msg.FieldStatus:
  15323. v, ok := value.(uint8)
  15324. if !ok {
  15325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15326. }
  15327. m.SetStatus(v)
  15328. return nil
  15329. case msg.FieldFromwxid:
  15330. v, ok := value.(string)
  15331. if !ok {
  15332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15333. }
  15334. m.SetFromwxid(v)
  15335. return nil
  15336. case msg.FieldToid:
  15337. v, ok := value.(string)
  15338. if !ok {
  15339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15340. }
  15341. m.SetToid(v)
  15342. return nil
  15343. case msg.FieldMsgtype:
  15344. v, ok := value.(int32)
  15345. if !ok {
  15346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15347. }
  15348. m.SetMsgtype(v)
  15349. return nil
  15350. case msg.FieldMsg:
  15351. v, ok := value.(string)
  15352. if !ok {
  15353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15354. }
  15355. m.SetMsg(v)
  15356. return nil
  15357. case msg.FieldBatchNo:
  15358. v, ok := value.(string)
  15359. if !ok {
  15360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15361. }
  15362. m.SetBatchNo(v)
  15363. return nil
  15364. }
  15365. return fmt.Errorf("unknown Msg field %s", name)
  15366. }
  15367. // AddedFields returns all numeric fields that were incremented/decremented during
  15368. // this mutation.
  15369. func (m *MsgMutation) AddedFields() []string {
  15370. var fields []string
  15371. if m.addstatus != nil {
  15372. fields = append(fields, msg.FieldStatus)
  15373. }
  15374. if m.addmsgtype != nil {
  15375. fields = append(fields, msg.FieldMsgtype)
  15376. }
  15377. return fields
  15378. }
  15379. // AddedField returns the numeric value that was incremented/decremented on a field
  15380. // with the given name. The second boolean return value indicates that this field
  15381. // was not set, or was not defined in the schema.
  15382. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  15383. switch name {
  15384. case msg.FieldStatus:
  15385. return m.AddedStatus()
  15386. case msg.FieldMsgtype:
  15387. return m.AddedMsgtype()
  15388. }
  15389. return nil, false
  15390. }
  15391. // AddField adds the value to the field with the given name. It returns an error if
  15392. // the field is not defined in the schema, or if the type mismatched the field
  15393. // type.
  15394. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  15395. switch name {
  15396. case msg.FieldStatus:
  15397. v, ok := value.(int8)
  15398. if !ok {
  15399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15400. }
  15401. m.AddStatus(v)
  15402. return nil
  15403. case msg.FieldMsgtype:
  15404. v, ok := value.(int32)
  15405. if !ok {
  15406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15407. }
  15408. m.AddMsgtype(v)
  15409. return nil
  15410. }
  15411. return fmt.Errorf("unknown Msg numeric field %s", name)
  15412. }
  15413. // ClearedFields returns all nullable fields that were cleared during this
  15414. // mutation.
  15415. func (m *MsgMutation) ClearedFields() []string {
  15416. var fields []string
  15417. if m.FieldCleared(msg.FieldDeletedAt) {
  15418. fields = append(fields, msg.FieldDeletedAt)
  15419. }
  15420. if m.FieldCleared(msg.FieldStatus) {
  15421. fields = append(fields, msg.FieldStatus)
  15422. }
  15423. if m.FieldCleared(msg.FieldFromwxid) {
  15424. fields = append(fields, msg.FieldFromwxid)
  15425. }
  15426. if m.FieldCleared(msg.FieldToid) {
  15427. fields = append(fields, msg.FieldToid)
  15428. }
  15429. if m.FieldCleared(msg.FieldMsgtype) {
  15430. fields = append(fields, msg.FieldMsgtype)
  15431. }
  15432. if m.FieldCleared(msg.FieldMsg) {
  15433. fields = append(fields, msg.FieldMsg)
  15434. }
  15435. if m.FieldCleared(msg.FieldBatchNo) {
  15436. fields = append(fields, msg.FieldBatchNo)
  15437. }
  15438. return fields
  15439. }
  15440. // FieldCleared returns a boolean indicating if a field with the given name was
  15441. // cleared in this mutation.
  15442. func (m *MsgMutation) FieldCleared(name string) bool {
  15443. _, ok := m.clearedFields[name]
  15444. return ok
  15445. }
  15446. // ClearField clears the value of the field with the given name. It returns an
  15447. // error if the field is not defined in the schema.
  15448. func (m *MsgMutation) ClearField(name string) error {
  15449. switch name {
  15450. case msg.FieldDeletedAt:
  15451. m.ClearDeletedAt()
  15452. return nil
  15453. case msg.FieldStatus:
  15454. m.ClearStatus()
  15455. return nil
  15456. case msg.FieldFromwxid:
  15457. m.ClearFromwxid()
  15458. return nil
  15459. case msg.FieldToid:
  15460. m.ClearToid()
  15461. return nil
  15462. case msg.FieldMsgtype:
  15463. m.ClearMsgtype()
  15464. return nil
  15465. case msg.FieldMsg:
  15466. m.ClearMsg()
  15467. return nil
  15468. case msg.FieldBatchNo:
  15469. m.ClearBatchNo()
  15470. return nil
  15471. }
  15472. return fmt.Errorf("unknown Msg nullable field %s", name)
  15473. }
  15474. // ResetField resets all changes in the mutation for the field with the given name.
  15475. // It returns an error if the field is not defined in the schema.
  15476. func (m *MsgMutation) ResetField(name string) error {
  15477. switch name {
  15478. case msg.FieldCreatedAt:
  15479. m.ResetCreatedAt()
  15480. return nil
  15481. case msg.FieldUpdatedAt:
  15482. m.ResetUpdatedAt()
  15483. return nil
  15484. case msg.FieldDeletedAt:
  15485. m.ResetDeletedAt()
  15486. return nil
  15487. case msg.FieldStatus:
  15488. m.ResetStatus()
  15489. return nil
  15490. case msg.FieldFromwxid:
  15491. m.ResetFromwxid()
  15492. return nil
  15493. case msg.FieldToid:
  15494. m.ResetToid()
  15495. return nil
  15496. case msg.FieldMsgtype:
  15497. m.ResetMsgtype()
  15498. return nil
  15499. case msg.FieldMsg:
  15500. m.ResetMsg()
  15501. return nil
  15502. case msg.FieldBatchNo:
  15503. m.ResetBatchNo()
  15504. return nil
  15505. }
  15506. return fmt.Errorf("unknown Msg field %s", name)
  15507. }
  15508. // AddedEdges returns all edge names that were set/added in this mutation.
  15509. func (m *MsgMutation) AddedEdges() []string {
  15510. edges := make([]string, 0, 0)
  15511. return edges
  15512. }
  15513. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15514. // name in this mutation.
  15515. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  15516. return nil
  15517. }
  15518. // RemovedEdges returns all edge names that were removed in this mutation.
  15519. func (m *MsgMutation) RemovedEdges() []string {
  15520. edges := make([]string, 0, 0)
  15521. return edges
  15522. }
  15523. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15524. // the given name in this mutation.
  15525. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  15526. return nil
  15527. }
  15528. // ClearedEdges returns all edge names that were cleared in this mutation.
  15529. func (m *MsgMutation) ClearedEdges() []string {
  15530. edges := make([]string, 0, 0)
  15531. return edges
  15532. }
  15533. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15534. // was cleared in this mutation.
  15535. func (m *MsgMutation) EdgeCleared(name string) bool {
  15536. return false
  15537. }
  15538. // ClearEdge clears the value of the edge with the given name. It returns an error
  15539. // if that edge is not defined in the schema.
  15540. func (m *MsgMutation) ClearEdge(name string) error {
  15541. return fmt.Errorf("unknown Msg unique edge %s", name)
  15542. }
  15543. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15544. // It returns an error if the edge is not defined in the schema.
  15545. func (m *MsgMutation) ResetEdge(name string) error {
  15546. return fmt.Errorf("unknown Msg edge %s", name)
  15547. }
  15548. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  15549. type ServerMutation struct {
  15550. config
  15551. op Op
  15552. typ string
  15553. id *uint64
  15554. created_at *time.Time
  15555. updated_at *time.Time
  15556. status *uint8
  15557. addstatus *int8
  15558. deleted_at *time.Time
  15559. name *string
  15560. public_ip *string
  15561. private_ip *string
  15562. admin_port *string
  15563. clearedFields map[string]struct{}
  15564. wxs map[uint64]struct{}
  15565. removedwxs map[uint64]struct{}
  15566. clearedwxs bool
  15567. done bool
  15568. oldValue func(context.Context) (*Server, error)
  15569. predicates []predicate.Server
  15570. }
  15571. var _ ent.Mutation = (*ServerMutation)(nil)
  15572. // serverOption allows management of the mutation configuration using functional options.
  15573. type serverOption func(*ServerMutation)
  15574. // newServerMutation creates new mutation for the Server entity.
  15575. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  15576. m := &ServerMutation{
  15577. config: c,
  15578. op: op,
  15579. typ: TypeServer,
  15580. clearedFields: make(map[string]struct{}),
  15581. }
  15582. for _, opt := range opts {
  15583. opt(m)
  15584. }
  15585. return m
  15586. }
  15587. // withServerID sets the ID field of the mutation.
  15588. func withServerID(id uint64) serverOption {
  15589. return func(m *ServerMutation) {
  15590. var (
  15591. err error
  15592. once sync.Once
  15593. value *Server
  15594. )
  15595. m.oldValue = func(ctx context.Context) (*Server, error) {
  15596. once.Do(func() {
  15597. if m.done {
  15598. err = errors.New("querying old values post mutation is not allowed")
  15599. } else {
  15600. value, err = m.Client().Server.Get(ctx, id)
  15601. }
  15602. })
  15603. return value, err
  15604. }
  15605. m.id = &id
  15606. }
  15607. }
  15608. // withServer sets the old Server of the mutation.
  15609. func withServer(node *Server) serverOption {
  15610. return func(m *ServerMutation) {
  15611. m.oldValue = func(context.Context) (*Server, error) {
  15612. return node, nil
  15613. }
  15614. m.id = &node.ID
  15615. }
  15616. }
  15617. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15618. // executed in a transaction (ent.Tx), a transactional client is returned.
  15619. func (m ServerMutation) Client() *Client {
  15620. client := &Client{config: m.config}
  15621. client.init()
  15622. return client
  15623. }
  15624. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15625. // it returns an error otherwise.
  15626. func (m ServerMutation) Tx() (*Tx, error) {
  15627. if _, ok := m.driver.(*txDriver); !ok {
  15628. return nil, errors.New("ent: mutation is not running in a transaction")
  15629. }
  15630. tx := &Tx{config: m.config}
  15631. tx.init()
  15632. return tx, nil
  15633. }
  15634. // SetID sets the value of the id field. Note that this
  15635. // operation is only accepted on creation of Server entities.
  15636. func (m *ServerMutation) SetID(id uint64) {
  15637. m.id = &id
  15638. }
  15639. // ID returns the ID value in the mutation. Note that the ID is only available
  15640. // if it was provided to the builder or after it was returned from the database.
  15641. func (m *ServerMutation) ID() (id uint64, exists bool) {
  15642. if m.id == nil {
  15643. return
  15644. }
  15645. return *m.id, true
  15646. }
  15647. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15648. // That means, if the mutation is applied within a transaction with an isolation level such
  15649. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15650. // or updated by the mutation.
  15651. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  15652. switch {
  15653. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15654. id, exists := m.ID()
  15655. if exists {
  15656. return []uint64{id}, nil
  15657. }
  15658. fallthrough
  15659. case m.op.Is(OpUpdate | OpDelete):
  15660. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  15661. default:
  15662. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15663. }
  15664. }
  15665. // SetCreatedAt sets the "created_at" field.
  15666. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  15667. m.created_at = &t
  15668. }
  15669. // CreatedAt returns the value of the "created_at" field in the mutation.
  15670. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  15671. v := m.created_at
  15672. if v == nil {
  15673. return
  15674. }
  15675. return *v, true
  15676. }
  15677. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  15678. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15680. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15681. if !m.op.Is(OpUpdateOne) {
  15682. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15683. }
  15684. if m.id == nil || m.oldValue == nil {
  15685. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15686. }
  15687. oldValue, err := m.oldValue(ctx)
  15688. if err != nil {
  15689. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15690. }
  15691. return oldValue.CreatedAt, nil
  15692. }
  15693. // ResetCreatedAt resets all changes to the "created_at" field.
  15694. func (m *ServerMutation) ResetCreatedAt() {
  15695. m.created_at = nil
  15696. }
  15697. // SetUpdatedAt sets the "updated_at" field.
  15698. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  15699. m.updated_at = &t
  15700. }
  15701. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15702. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  15703. v := m.updated_at
  15704. if v == nil {
  15705. return
  15706. }
  15707. return *v, true
  15708. }
  15709. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  15710. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15712. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15713. if !m.op.Is(OpUpdateOne) {
  15714. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15715. }
  15716. if m.id == nil || m.oldValue == nil {
  15717. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15718. }
  15719. oldValue, err := m.oldValue(ctx)
  15720. if err != nil {
  15721. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15722. }
  15723. return oldValue.UpdatedAt, nil
  15724. }
  15725. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15726. func (m *ServerMutation) ResetUpdatedAt() {
  15727. m.updated_at = nil
  15728. }
  15729. // SetStatus sets the "status" field.
  15730. func (m *ServerMutation) SetStatus(u uint8) {
  15731. m.status = &u
  15732. m.addstatus = nil
  15733. }
  15734. // Status returns the value of the "status" field in the mutation.
  15735. func (m *ServerMutation) Status() (r uint8, exists bool) {
  15736. v := m.status
  15737. if v == nil {
  15738. return
  15739. }
  15740. return *v, true
  15741. }
  15742. // OldStatus returns the old "status" field's value of the Server entity.
  15743. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15745. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15746. if !m.op.Is(OpUpdateOne) {
  15747. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15748. }
  15749. if m.id == nil || m.oldValue == nil {
  15750. return v, errors.New("OldStatus requires an ID field in the mutation")
  15751. }
  15752. oldValue, err := m.oldValue(ctx)
  15753. if err != nil {
  15754. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15755. }
  15756. return oldValue.Status, nil
  15757. }
  15758. // AddStatus adds u to the "status" field.
  15759. func (m *ServerMutation) AddStatus(u int8) {
  15760. if m.addstatus != nil {
  15761. *m.addstatus += u
  15762. } else {
  15763. m.addstatus = &u
  15764. }
  15765. }
  15766. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15767. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  15768. v := m.addstatus
  15769. if v == nil {
  15770. return
  15771. }
  15772. return *v, true
  15773. }
  15774. // ClearStatus clears the value of the "status" field.
  15775. func (m *ServerMutation) ClearStatus() {
  15776. m.status = nil
  15777. m.addstatus = nil
  15778. m.clearedFields[server.FieldStatus] = struct{}{}
  15779. }
  15780. // StatusCleared returns if the "status" field was cleared in this mutation.
  15781. func (m *ServerMutation) StatusCleared() bool {
  15782. _, ok := m.clearedFields[server.FieldStatus]
  15783. return ok
  15784. }
  15785. // ResetStatus resets all changes to the "status" field.
  15786. func (m *ServerMutation) ResetStatus() {
  15787. m.status = nil
  15788. m.addstatus = nil
  15789. delete(m.clearedFields, server.FieldStatus)
  15790. }
  15791. // SetDeletedAt sets the "deleted_at" field.
  15792. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  15793. m.deleted_at = &t
  15794. }
  15795. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15796. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  15797. v := m.deleted_at
  15798. if v == nil {
  15799. return
  15800. }
  15801. return *v, true
  15802. }
  15803. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  15804. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15806. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15807. if !m.op.Is(OpUpdateOne) {
  15808. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15809. }
  15810. if m.id == nil || m.oldValue == nil {
  15811. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15812. }
  15813. oldValue, err := m.oldValue(ctx)
  15814. if err != nil {
  15815. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15816. }
  15817. return oldValue.DeletedAt, nil
  15818. }
  15819. // ClearDeletedAt clears the value of the "deleted_at" field.
  15820. func (m *ServerMutation) ClearDeletedAt() {
  15821. m.deleted_at = nil
  15822. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  15823. }
  15824. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15825. func (m *ServerMutation) DeletedAtCleared() bool {
  15826. _, ok := m.clearedFields[server.FieldDeletedAt]
  15827. return ok
  15828. }
  15829. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15830. func (m *ServerMutation) ResetDeletedAt() {
  15831. m.deleted_at = nil
  15832. delete(m.clearedFields, server.FieldDeletedAt)
  15833. }
  15834. // SetName sets the "name" field.
  15835. func (m *ServerMutation) SetName(s string) {
  15836. m.name = &s
  15837. }
  15838. // Name returns the value of the "name" field in the mutation.
  15839. func (m *ServerMutation) Name() (r string, exists bool) {
  15840. v := m.name
  15841. if v == nil {
  15842. return
  15843. }
  15844. return *v, true
  15845. }
  15846. // OldName returns the old "name" field's value of the Server entity.
  15847. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15849. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  15850. if !m.op.Is(OpUpdateOne) {
  15851. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15852. }
  15853. if m.id == nil || m.oldValue == nil {
  15854. return v, errors.New("OldName requires an ID field in the mutation")
  15855. }
  15856. oldValue, err := m.oldValue(ctx)
  15857. if err != nil {
  15858. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15859. }
  15860. return oldValue.Name, nil
  15861. }
  15862. // ResetName resets all changes to the "name" field.
  15863. func (m *ServerMutation) ResetName() {
  15864. m.name = nil
  15865. }
  15866. // SetPublicIP sets the "public_ip" field.
  15867. func (m *ServerMutation) SetPublicIP(s string) {
  15868. m.public_ip = &s
  15869. }
  15870. // PublicIP returns the value of the "public_ip" field in the mutation.
  15871. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  15872. v := m.public_ip
  15873. if v == nil {
  15874. return
  15875. }
  15876. return *v, true
  15877. }
  15878. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  15879. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15881. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  15882. if !m.op.Is(OpUpdateOne) {
  15883. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  15884. }
  15885. if m.id == nil || m.oldValue == nil {
  15886. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  15887. }
  15888. oldValue, err := m.oldValue(ctx)
  15889. if err != nil {
  15890. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  15891. }
  15892. return oldValue.PublicIP, nil
  15893. }
  15894. // ResetPublicIP resets all changes to the "public_ip" field.
  15895. func (m *ServerMutation) ResetPublicIP() {
  15896. m.public_ip = nil
  15897. }
  15898. // SetPrivateIP sets the "private_ip" field.
  15899. func (m *ServerMutation) SetPrivateIP(s string) {
  15900. m.private_ip = &s
  15901. }
  15902. // PrivateIP returns the value of the "private_ip" field in the mutation.
  15903. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  15904. v := m.private_ip
  15905. if v == nil {
  15906. return
  15907. }
  15908. return *v, true
  15909. }
  15910. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  15911. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15913. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  15914. if !m.op.Is(OpUpdateOne) {
  15915. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  15916. }
  15917. if m.id == nil || m.oldValue == nil {
  15918. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  15919. }
  15920. oldValue, err := m.oldValue(ctx)
  15921. if err != nil {
  15922. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  15923. }
  15924. return oldValue.PrivateIP, nil
  15925. }
  15926. // ResetPrivateIP resets all changes to the "private_ip" field.
  15927. func (m *ServerMutation) ResetPrivateIP() {
  15928. m.private_ip = nil
  15929. }
  15930. // SetAdminPort sets the "admin_port" field.
  15931. func (m *ServerMutation) SetAdminPort(s string) {
  15932. m.admin_port = &s
  15933. }
  15934. // AdminPort returns the value of the "admin_port" field in the mutation.
  15935. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  15936. v := m.admin_port
  15937. if v == nil {
  15938. return
  15939. }
  15940. return *v, true
  15941. }
  15942. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  15943. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15945. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  15946. if !m.op.Is(OpUpdateOne) {
  15947. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  15948. }
  15949. if m.id == nil || m.oldValue == nil {
  15950. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  15951. }
  15952. oldValue, err := m.oldValue(ctx)
  15953. if err != nil {
  15954. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  15955. }
  15956. return oldValue.AdminPort, nil
  15957. }
  15958. // ResetAdminPort resets all changes to the "admin_port" field.
  15959. func (m *ServerMutation) ResetAdminPort() {
  15960. m.admin_port = nil
  15961. }
  15962. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  15963. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  15964. if m.wxs == nil {
  15965. m.wxs = make(map[uint64]struct{})
  15966. }
  15967. for i := range ids {
  15968. m.wxs[ids[i]] = struct{}{}
  15969. }
  15970. }
  15971. // ClearWxs clears the "wxs" edge to the Wx entity.
  15972. func (m *ServerMutation) ClearWxs() {
  15973. m.clearedwxs = true
  15974. }
  15975. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  15976. func (m *ServerMutation) WxsCleared() bool {
  15977. return m.clearedwxs
  15978. }
  15979. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  15980. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  15981. if m.removedwxs == nil {
  15982. m.removedwxs = make(map[uint64]struct{})
  15983. }
  15984. for i := range ids {
  15985. delete(m.wxs, ids[i])
  15986. m.removedwxs[ids[i]] = struct{}{}
  15987. }
  15988. }
  15989. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  15990. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  15991. for id := range m.removedwxs {
  15992. ids = append(ids, id)
  15993. }
  15994. return
  15995. }
  15996. // WxsIDs returns the "wxs" edge IDs in the mutation.
  15997. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  15998. for id := range m.wxs {
  15999. ids = append(ids, id)
  16000. }
  16001. return
  16002. }
  16003. // ResetWxs resets all changes to the "wxs" edge.
  16004. func (m *ServerMutation) ResetWxs() {
  16005. m.wxs = nil
  16006. m.clearedwxs = false
  16007. m.removedwxs = nil
  16008. }
  16009. // Where appends a list predicates to the ServerMutation builder.
  16010. func (m *ServerMutation) Where(ps ...predicate.Server) {
  16011. m.predicates = append(m.predicates, ps...)
  16012. }
  16013. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  16014. // users can use type-assertion to append predicates that do not depend on any generated package.
  16015. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  16016. p := make([]predicate.Server, len(ps))
  16017. for i := range ps {
  16018. p[i] = ps[i]
  16019. }
  16020. m.Where(p...)
  16021. }
  16022. // Op returns the operation name.
  16023. func (m *ServerMutation) Op() Op {
  16024. return m.op
  16025. }
  16026. // SetOp allows setting the mutation operation.
  16027. func (m *ServerMutation) SetOp(op Op) {
  16028. m.op = op
  16029. }
  16030. // Type returns the node type of this mutation (Server).
  16031. func (m *ServerMutation) Type() string {
  16032. return m.typ
  16033. }
  16034. // Fields returns all fields that were changed during this mutation. Note that in
  16035. // order to get all numeric fields that were incremented/decremented, call
  16036. // AddedFields().
  16037. func (m *ServerMutation) Fields() []string {
  16038. fields := make([]string, 0, 8)
  16039. if m.created_at != nil {
  16040. fields = append(fields, server.FieldCreatedAt)
  16041. }
  16042. if m.updated_at != nil {
  16043. fields = append(fields, server.FieldUpdatedAt)
  16044. }
  16045. if m.status != nil {
  16046. fields = append(fields, server.FieldStatus)
  16047. }
  16048. if m.deleted_at != nil {
  16049. fields = append(fields, server.FieldDeletedAt)
  16050. }
  16051. if m.name != nil {
  16052. fields = append(fields, server.FieldName)
  16053. }
  16054. if m.public_ip != nil {
  16055. fields = append(fields, server.FieldPublicIP)
  16056. }
  16057. if m.private_ip != nil {
  16058. fields = append(fields, server.FieldPrivateIP)
  16059. }
  16060. if m.admin_port != nil {
  16061. fields = append(fields, server.FieldAdminPort)
  16062. }
  16063. return fields
  16064. }
  16065. // Field returns the value of a field with the given name. The second boolean
  16066. // return value indicates that this field was not set, or was not defined in the
  16067. // schema.
  16068. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  16069. switch name {
  16070. case server.FieldCreatedAt:
  16071. return m.CreatedAt()
  16072. case server.FieldUpdatedAt:
  16073. return m.UpdatedAt()
  16074. case server.FieldStatus:
  16075. return m.Status()
  16076. case server.FieldDeletedAt:
  16077. return m.DeletedAt()
  16078. case server.FieldName:
  16079. return m.Name()
  16080. case server.FieldPublicIP:
  16081. return m.PublicIP()
  16082. case server.FieldPrivateIP:
  16083. return m.PrivateIP()
  16084. case server.FieldAdminPort:
  16085. return m.AdminPort()
  16086. }
  16087. return nil, false
  16088. }
  16089. // OldField returns the old value of the field from the database. An error is
  16090. // returned if the mutation operation is not UpdateOne, or the query to the
  16091. // database failed.
  16092. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16093. switch name {
  16094. case server.FieldCreatedAt:
  16095. return m.OldCreatedAt(ctx)
  16096. case server.FieldUpdatedAt:
  16097. return m.OldUpdatedAt(ctx)
  16098. case server.FieldStatus:
  16099. return m.OldStatus(ctx)
  16100. case server.FieldDeletedAt:
  16101. return m.OldDeletedAt(ctx)
  16102. case server.FieldName:
  16103. return m.OldName(ctx)
  16104. case server.FieldPublicIP:
  16105. return m.OldPublicIP(ctx)
  16106. case server.FieldPrivateIP:
  16107. return m.OldPrivateIP(ctx)
  16108. case server.FieldAdminPort:
  16109. return m.OldAdminPort(ctx)
  16110. }
  16111. return nil, fmt.Errorf("unknown Server field %s", name)
  16112. }
  16113. // SetField sets the value of a field with the given name. It returns an error if
  16114. // the field is not defined in the schema, or if the type mismatched the field
  16115. // type.
  16116. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  16117. switch name {
  16118. case server.FieldCreatedAt:
  16119. v, ok := value.(time.Time)
  16120. if !ok {
  16121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16122. }
  16123. m.SetCreatedAt(v)
  16124. return nil
  16125. case server.FieldUpdatedAt:
  16126. v, ok := value.(time.Time)
  16127. if !ok {
  16128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16129. }
  16130. m.SetUpdatedAt(v)
  16131. return nil
  16132. case server.FieldStatus:
  16133. v, ok := value.(uint8)
  16134. if !ok {
  16135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16136. }
  16137. m.SetStatus(v)
  16138. return nil
  16139. case server.FieldDeletedAt:
  16140. v, ok := value.(time.Time)
  16141. if !ok {
  16142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16143. }
  16144. m.SetDeletedAt(v)
  16145. return nil
  16146. case server.FieldName:
  16147. v, ok := value.(string)
  16148. if !ok {
  16149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16150. }
  16151. m.SetName(v)
  16152. return nil
  16153. case server.FieldPublicIP:
  16154. v, ok := value.(string)
  16155. if !ok {
  16156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16157. }
  16158. m.SetPublicIP(v)
  16159. return nil
  16160. case server.FieldPrivateIP:
  16161. v, ok := value.(string)
  16162. if !ok {
  16163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16164. }
  16165. m.SetPrivateIP(v)
  16166. return nil
  16167. case server.FieldAdminPort:
  16168. v, ok := value.(string)
  16169. if !ok {
  16170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16171. }
  16172. m.SetAdminPort(v)
  16173. return nil
  16174. }
  16175. return fmt.Errorf("unknown Server field %s", name)
  16176. }
  16177. // AddedFields returns all numeric fields that were incremented/decremented during
  16178. // this mutation.
  16179. func (m *ServerMutation) AddedFields() []string {
  16180. var fields []string
  16181. if m.addstatus != nil {
  16182. fields = append(fields, server.FieldStatus)
  16183. }
  16184. return fields
  16185. }
  16186. // AddedField returns the numeric value that was incremented/decremented on a field
  16187. // with the given name. The second boolean return value indicates that this field
  16188. // was not set, or was not defined in the schema.
  16189. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  16190. switch name {
  16191. case server.FieldStatus:
  16192. return m.AddedStatus()
  16193. }
  16194. return nil, false
  16195. }
  16196. // AddField adds the value to the field with the given name. It returns an error if
  16197. // the field is not defined in the schema, or if the type mismatched the field
  16198. // type.
  16199. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  16200. switch name {
  16201. case server.FieldStatus:
  16202. v, ok := value.(int8)
  16203. if !ok {
  16204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16205. }
  16206. m.AddStatus(v)
  16207. return nil
  16208. }
  16209. return fmt.Errorf("unknown Server numeric field %s", name)
  16210. }
  16211. // ClearedFields returns all nullable fields that were cleared during this
  16212. // mutation.
  16213. func (m *ServerMutation) ClearedFields() []string {
  16214. var fields []string
  16215. if m.FieldCleared(server.FieldStatus) {
  16216. fields = append(fields, server.FieldStatus)
  16217. }
  16218. if m.FieldCleared(server.FieldDeletedAt) {
  16219. fields = append(fields, server.FieldDeletedAt)
  16220. }
  16221. return fields
  16222. }
  16223. // FieldCleared returns a boolean indicating if a field with the given name was
  16224. // cleared in this mutation.
  16225. func (m *ServerMutation) FieldCleared(name string) bool {
  16226. _, ok := m.clearedFields[name]
  16227. return ok
  16228. }
  16229. // ClearField clears the value of the field with the given name. It returns an
  16230. // error if the field is not defined in the schema.
  16231. func (m *ServerMutation) ClearField(name string) error {
  16232. switch name {
  16233. case server.FieldStatus:
  16234. m.ClearStatus()
  16235. return nil
  16236. case server.FieldDeletedAt:
  16237. m.ClearDeletedAt()
  16238. return nil
  16239. }
  16240. return fmt.Errorf("unknown Server nullable field %s", name)
  16241. }
  16242. // ResetField resets all changes in the mutation for the field with the given name.
  16243. // It returns an error if the field is not defined in the schema.
  16244. func (m *ServerMutation) ResetField(name string) error {
  16245. switch name {
  16246. case server.FieldCreatedAt:
  16247. m.ResetCreatedAt()
  16248. return nil
  16249. case server.FieldUpdatedAt:
  16250. m.ResetUpdatedAt()
  16251. return nil
  16252. case server.FieldStatus:
  16253. m.ResetStatus()
  16254. return nil
  16255. case server.FieldDeletedAt:
  16256. m.ResetDeletedAt()
  16257. return nil
  16258. case server.FieldName:
  16259. m.ResetName()
  16260. return nil
  16261. case server.FieldPublicIP:
  16262. m.ResetPublicIP()
  16263. return nil
  16264. case server.FieldPrivateIP:
  16265. m.ResetPrivateIP()
  16266. return nil
  16267. case server.FieldAdminPort:
  16268. m.ResetAdminPort()
  16269. return nil
  16270. }
  16271. return fmt.Errorf("unknown Server field %s", name)
  16272. }
  16273. // AddedEdges returns all edge names that were set/added in this mutation.
  16274. func (m *ServerMutation) AddedEdges() []string {
  16275. edges := make([]string, 0, 1)
  16276. if m.wxs != nil {
  16277. edges = append(edges, server.EdgeWxs)
  16278. }
  16279. return edges
  16280. }
  16281. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16282. // name in this mutation.
  16283. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  16284. switch name {
  16285. case server.EdgeWxs:
  16286. ids := make([]ent.Value, 0, len(m.wxs))
  16287. for id := range m.wxs {
  16288. ids = append(ids, id)
  16289. }
  16290. return ids
  16291. }
  16292. return nil
  16293. }
  16294. // RemovedEdges returns all edge names that were removed in this mutation.
  16295. func (m *ServerMutation) RemovedEdges() []string {
  16296. edges := make([]string, 0, 1)
  16297. if m.removedwxs != nil {
  16298. edges = append(edges, server.EdgeWxs)
  16299. }
  16300. return edges
  16301. }
  16302. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16303. // the given name in this mutation.
  16304. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  16305. switch name {
  16306. case server.EdgeWxs:
  16307. ids := make([]ent.Value, 0, len(m.removedwxs))
  16308. for id := range m.removedwxs {
  16309. ids = append(ids, id)
  16310. }
  16311. return ids
  16312. }
  16313. return nil
  16314. }
  16315. // ClearedEdges returns all edge names that were cleared in this mutation.
  16316. func (m *ServerMutation) ClearedEdges() []string {
  16317. edges := make([]string, 0, 1)
  16318. if m.clearedwxs {
  16319. edges = append(edges, server.EdgeWxs)
  16320. }
  16321. return edges
  16322. }
  16323. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16324. // was cleared in this mutation.
  16325. func (m *ServerMutation) EdgeCleared(name string) bool {
  16326. switch name {
  16327. case server.EdgeWxs:
  16328. return m.clearedwxs
  16329. }
  16330. return false
  16331. }
  16332. // ClearEdge clears the value of the edge with the given name. It returns an error
  16333. // if that edge is not defined in the schema.
  16334. func (m *ServerMutation) ClearEdge(name string) error {
  16335. switch name {
  16336. }
  16337. return fmt.Errorf("unknown Server unique edge %s", name)
  16338. }
  16339. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16340. // It returns an error if the edge is not defined in the schema.
  16341. func (m *ServerMutation) ResetEdge(name string) error {
  16342. switch name {
  16343. case server.EdgeWxs:
  16344. m.ResetWxs()
  16345. return nil
  16346. }
  16347. return fmt.Errorf("unknown Server edge %s", name)
  16348. }
  16349. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  16350. type SopNodeMutation struct {
  16351. config
  16352. op Op
  16353. typ string
  16354. id *uint64
  16355. created_at *time.Time
  16356. updated_at *time.Time
  16357. status *uint8
  16358. addstatus *int8
  16359. deleted_at *time.Time
  16360. parent_id *uint64
  16361. addparent_id *int64
  16362. name *string
  16363. condition_type *int
  16364. addcondition_type *int
  16365. condition_list *[]string
  16366. appendcondition_list []string
  16367. no_reply_condition *uint64
  16368. addno_reply_condition *int64
  16369. no_reply_unit *string
  16370. action_message *[]custom_types.Action
  16371. appendaction_message []custom_types.Action
  16372. action_label_add *[]uint64
  16373. appendaction_label_add []uint64
  16374. action_label_del *[]uint64
  16375. appendaction_label_del []uint64
  16376. action_forward **custom_types.ActionForward
  16377. clearedFields map[string]struct{}
  16378. sop_stage *uint64
  16379. clearedsop_stage bool
  16380. node_messages map[uint64]struct{}
  16381. removednode_messages map[uint64]struct{}
  16382. clearednode_messages bool
  16383. done bool
  16384. oldValue func(context.Context) (*SopNode, error)
  16385. predicates []predicate.SopNode
  16386. }
  16387. var _ ent.Mutation = (*SopNodeMutation)(nil)
  16388. // sopnodeOption allows management of the mutation configuration using functional options.
  16389. type sopnodeOption func(*SopNodeMutation)
  16390. // newSopNodeMutation creates new mutation for the SopNode entity.
  16391. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  16392. m := &SopNodeMutation{
  16393. config: c,
  16394. op: op,
  16395. typ: TypeSopNode,
  16396. clearedFields: make(map[string]struct{}),
  16397. }
  16398. for _, opt := range opts {
  16399. opt(m)
  16400. }
  16401. return m
  16402. }
  16403. // withSopNodeID sets the ID field of the mutation.
  16404. func withSopNodeID(id uint64) sopnodeOption {
  16405. return func(m *SopNodeMutation) {
  16406. var (
  16407. err error
  16408. once sync.Once
  16409. value *SopNode
  16410. )
  16411. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  16412. once.Do(func() {
  16413. if m.done {
  16414. err = errors.New("querying old values post mutation is not allowed")
  16415. } else {
  16416. value, err = m.Client().SopNode.Get(ctx, id)
  16417. }
  16418. })
  16419. return value, err
  16420. }
  16421. m.id = &id
  16422. }
  16423. }
  16424. // withSopNode sets the old SopNode of the mutation.
  16425. func withSopNode(node *SopNode) sopnodeOption {
  16426. return func(m *SopNodeMutation) {
  16427. m.oldValue = func(context.Context) (*SopNode, error) {
  16428. return node, nil
  16429. }
  16430. m.id = &node.ID
  16431. }
  16432. }
  16433. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16434. // executed in a transaction (ent.Tx), a transactional client is returned.
  16435. func (m SopNodeMutation) Client() *Client {
  16436. client := &Client{config: m.config}
  16437. client.init()
  16438. return client
  16439. }
  16440. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16441. // it returns an error otherwise.
  16442. func (m SopNodeMutation) Tx() (*Tx, error) {
  16443. if _, ok := m.driver.(*txDriver); !ok {
  16444. return nil, errors.New("ent: mutation is not running in a transaction")
  16445. }
  16446. tx := &Tx{config: m.config}
  16447. tx.init()
  16448. return tx, nil
  16449. }
  16450. // SetID sets the value of the id field. Note that this
  16451. // operation is only accepted on creation of SopNode entities.
  16452. func (m *SopNodeMutation) SetID(id uint64) {
  16453. m.id = &id
  16454. }
  16455. // ID returns the ID value in the mutation. Note that the ID is only available
  16456. // if it was provided to the builder or after it was returned from the database.
  16457. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  16458. if m.id == nil {
  16459. return
  16460. }
  16461. return *m.id, true
  16462. }
  16463. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16464. // That means, if the mutation is applied within a transaction with an isolation level such
  16465. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16466. // or updated by the mutation.
  16467. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  16468. switch {
  16469. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16470. id, exists := m.ID()
  16471. if exists {
  16472. return []uint64{id}, nil
  16473. }
  16474. fallthrough
  16475. case m.op.Is(OpUpdate | OpDelete):
  16476. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  16477. default:
  16478. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16479. }
  16480. }
  16481. // SetCreatedAt sets the "created_at" field.
  16482. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  16483. m.created_at = &t
  16484. }
  16485. // CreatedAt returns the value of the "created_at" field in the mutation.
  16486. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  16487. v := m.created_at
  16488. if v == nil {
  16489. return
  16490. }
  16491. return *v, true
  16492. }
  16493. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  16494. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16496. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16497. if !m.op.Is(OpUpdateOne) {
  16498. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16499. }
  16500. if m.id == nil || m.oldValue == nil {
  16501. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16502. }
  16503. oldValue, err := m.oldValue(ctx)
  16504. if err != nil {
  16505. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16506. }
  16507. return oldValue.CreatedAt, nil
  16508. }
  16509. // ResetCreatedAt resets all changes to the "created_at" field.
  16510. func (m *SopNodeMutation) ResetCreatedAt() {
  16511. m.created_at = nil
  16512. }
  16513. // SetUpdatedAt sets the "updated_at" field.
  16514. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  16515. m.updated_at = &t
  16516. }
  16517. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16518. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  16519. v := m.updated_at
  16520. if v == nil {
  16521. return
  16522. }
  16523. return *v, true
  16524. }
  16525. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  16526. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16528. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16529. if !m.op.Is(OpUpdateOne) {
  16530. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16531. }
  16532. if m.id == nil || m.oldValue == nil {
  16533. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16534. }
  16535. oldValue, err := m.oldValue(ctx)
  16536. if err != nil {
  16537. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16538. }
  16539. return oldValue.UpdatedAt, nil
  16540. }
  16541. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16542. func (m *SopNodeMutation) ResetUpdatedAt() {
  16543. m.updated_at = nil
  16544. }
  16545. // SetStatus sets the "status" field.
  16546. func (m *SopNodeMutation) SetStatus(u uint8) {
  16547. m.status = &u
  16548. m.addstatus = nil
  16549. }
  16550. // Status returns the value of the "status" field in the mutation.
  16551. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  16552. v := m.status
  16553. if v == nil {
  16554. return
  16555. }
  16556. return *v, true
  16557. }
  16558. // OldStatus returns the old "status" field's value of the SopNode entity.
  16559. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16561. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16562. if !m.op.Is(OpUpdateOne) {
  16563. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16564. }
  16565. if m.id == nil || m.oldValue == nil {
  16566. return v, errors.New("OldStatus requires an ID field in the mutation")
  16567. }
  16568. oldValue, err := m.oldValue(ctx)
  16569. if err != nil {
  16570. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16571. }
  16572. return oldValue.Status, nil
  16573. }
  16574. // AddStatus adds u to the "status" field.
  16575. func (m *SopNodeMutation) AddStatus(u int8) {
  16576. if m.addstatus != nil {
  16577. *m.addstatus += u
  16578. } else {
  16579. m.addstatus = &u
  16580. }
  16581. }
  16582. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16583. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  16584. v := m.addstatus
  16585. if v == nil {
  16586. return
  16587. }
  16588. return *v, true
  16589. }
  16590. // ClearStatus clears the value of the "status" field.
  16591. func (m *SopNodeMutation) ClearStatus() {
  16592. m.status = nil
  16593. m.addstatus = nil
  16594. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  16595. }
  16596. // StatusCleared returns if the "status" field was cleared in this mutation.
  16597. func (m *SopNodeMutation) StatusCleared() bool {
  16598. _, ok := m.clearedFields[sopnode.FieldStatus]
  16599. return ok
  16600. }
  16601. // ResetStatus resets all changes to the "status" field.
  16602. func (m *SopNodeMutation) ResetStatus() {
  16603. m.status = nil
  16604. m.addstatus = nil
  16605. delete(m.clearedFields, sopnode.FieldStatus)
  16606. }
  16607. // SetDeletedAt sets the "deleted_at" field.
  16608. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  16609. m.deleted_at = &t
  16610. }
  16611. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16612. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  16613. v := m.deleted_at
  16614. if v == nil {
  16615. return
  16616. }
  16617. return *v, true
  16618. }
  16619. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  16620. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16622. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16623. if !m.op.Is(OpUpdateOne) {
  16624. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16625. }
  16626. if m.id == nil || m.oldValue == nil {
  16627. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16628. }
  16629. oldValue, err := m.oldValue(ctx)
  16630. if err != nil {
  16631. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16632. }
  16633. return oldValue.DeletedAt, nil
  16634. }
  16635. // ClearDeletedAt clears the value of the "deleted_at" field.
  16636. func (m *SopNodeMutation) ClearDeletedAt() {
  16637. m.deleted_at = nil
  16638. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  16639. }
  16640. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16641. func (m *SopNodeMutation) DeletedAtCleared() bool {
  16642. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  16643. return ok
  16644. }
  16645. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16646. func (m *SopNodeMutation) ResetDeletedAt() {
  16647. m.deleted_at = nil
  16648. delete(m.clearedFields, sopnode.FieldDeletedAt)
  16649. }
  16650. // SetStageID sets the "stage_id" field.
  16651. func (m *SopNodeMutation) SetStageID(u uint64) {
  16652. m.sop_stage = &u
  16653. }
  16654. // StageID returns the value of the "stage_id" field in the mutation.
  16655. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  16656. v := m.sop_stage
  16657. if v == nil {
  16658. return
  16659. }
  16660. return *v, true
  16661. }
  16662. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  16663. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16665. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  16666. if !m.op.Is(OpUpdateOne) {
  16667. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  16668. }
  16669. if m.id == nil || m.oldValue == nil {
  16670. return v, errors.New("OldStageID requires an ID field in the mutation")
  16671. }
  16672. oldValue, err := m.oldValue(ctx)
  16673. if err != nil {
  16674. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  16675. }
  16676. return oldValue.StageID, nil
  16677. }
  16678. // ResetStageID resets all changes to the "stage_id" field.
  16679. func (m *SopNodeMutation) ResetStageID() {
  16680. m.sop_stage = nil
  16681. }
  16682. // SetParentID sets the "parent_id" field.
  16683. func (m *SopNodeMutation) SetParentID(u uint64) {
  16684. m.parent_id = &u
  16685. m.addparent_id = nil
  16686. }
  16687. // ParentID returns the value of the "parent_id" field in the mutation.
  16688. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  16689. v := m.parent_id
  16690. if v == nil {
  16691. return
  16692. }
  16693. return *v, true
  16694. }
  16695. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  16696. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16698. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  16699. if !m.op.Is(OpUpdateOne) {
  16700. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  16701. }
  16702. if m.id == nil || m.oldValue == nil {
  16703. return v, errors.New("OldParentID requires an ID field in the mutation")
  16704. }
  16705. oldValue, err := m.oldValue(ctx)
  16706. if err != nil {
  16707. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  16708. }
  16709. return oldValue.ParentID, nil
  16710. }
  16711. // AddParentID adds u to the "parent_id" field.
  16712. func (m *SopNodeMutation) AddParentID(u int64) {
  16713. if m.addparent_id != nil {
  16714. *m.addparent_id += u
  16715. } else {
  16716. m.addparent_id = &u
  16717. }
  16718. }
  16719. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  16720. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  16721. v := m.addparent_id
  16722. if v == nil {
  16723. return
  16724. }
  16725. return *v, true
  16726. }
  16727. // ResetParentID resets all changes to the "parent_id" field.
  16728. func (m *SopNodeMutation) ResetParentID() {
  16729. m.parent_id = nil
  16730. m.addparent_id = nil
  16731. }
  16732. // SetName sets the "name" field.
  16733. func (m *SopNodeMutation) SetName(s string) {
  16734. m.name = &s
  16735. }
  16736. // Name returns the value of the "name" field in the mutation.
  16737. func (m *SopNodeMutation) Name() (r string, exists bool) {
  16738. v := m.name
  16739. if v == nil {
  16740. return
  16741. }
  16742. return *v, true
  16743. }
  16744. // OldName returns the old "name" field's value of the SopNode entity.
  16745. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16747. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  16748. if !m.op.Is(OpUpdateOne) {
  16749. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16750. }
  16751. if m.id == nil || m.oldValue == nil {
  16752. return v, errors.New("OldName requires an ID field in the mutation")
  16753. }
  16754. oldValue, err := m.oldValue(ctx)
  16755. if err != nil {
  16756. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16757. }
  16758. return oldValue.Name, nil
  16759. }
  16760. // ResetName resets all changes to the "name" field.
  16761. func (m *SopNodeMutation) ResetName() {
  16762. m.name = nil
  16763. }
  16764. // SetConditionType sets the "condition_type" field.
  16765. func (m *SopNodeMutation) SetConditionType(i int) {
  16766. m.condition_type = &i
  16767. m.addcondition_type = nil
  16768. }
  16769. // ConditionType returns the value of the "condition_type" field in the mutation.
  16770. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  16771. v := m.condition_type
  16772. if v == nil {
  16773. return
  16774. }
  16775. return *v, true
  16776. }
  16777. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  16778. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16780. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  16781. if !m.op.Is(OpUpdateOne) {
  16782. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  16783. }
  16784. if m.id == nil || m.oldValue == nil {
  16785. return v, errors.New("OldConditionType requires an ID field in the mutation")
  16786. }
  16787. oldValue, err := m.oldValue(ctx)
  16788. if err != nil {
  16789. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  16790. }
  16791. return oldValue.ConditionType, nil
  16792. }
  16793. // AddConditionType adds i to the "condition_type" field.
  16794. func (m *SopNodeMutation) AddConditionType(i int) {
  16795. if m.addcondition_type != nil {
  16796. *m.addcondition_type += i
  16797. } else {
  16798. m.addcondition_type = &i
  16799. }
  16800. }
  16801. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  16802. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  16803. v := m.addcondition_type
  16804. if v == nil {
  16805. return
  16806. }
  16807. return *v, true
  16808. }
  16809. // ResetConditionType resets all changes to the "condition_type" field.
  16810. func (m *SopNodeMutation) ResetConditionType() {
  16811. m.condition_type = nil
  16812. m.addcondition_type = nil
  16813. }
  16814. // SetConditionList sets the "condition_list" field.
  16815. func (m *SopNodeMutation) SetConditionList(s []string) {
  16816. m.condition_list = &s
  16817. m.appendcondition_list = nil
  16818. }
  16819. // ConditionList returns the value of the "condition_list" field in the mutation.
  16820. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  16821. v := m.condition_list
  16822. if v == nil {
  16823. return
  16824. }
  16825. return *v, true
  16826. }
  16827. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  16828. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16830. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  16831. if !m.op.Is(OpUpdateOne) {
  16832. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  16833. }
  16834. if m.id == nil || m.oldValue == nil {
  16835. return v, errors.New("OldConditionList requires an ID field in the mutation")
  16836. }
  16837. oldValue, err := m.oldValue(ctx)
  16838. if err != nil {
  16839. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  16840. }
  16841. return oldValue.ConditionList, nil
  16842. }
  16843. // AppendConditionList adds s to the "condition_list" field.
  16844. func (m *SopNodeMutation) AppendConditionList(s []string) {
  16845. m.appendcondition_list = append(m.appendcondition_list, s...)
  16846. }
  16847. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  16848. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  16849. if len(m.appendcondition_list) == 0 {
  16850. return nil, false
  16851. }
  16852. return m.appendcondition_list, true
  16853. }
  16854. // ClearConditionList clears the value of the "condition_list" field.
  16855. func (m *SopNodeMutation) ClearConditionList() {
  16856. m.condition_list = nil
  16857. m.appendcondition_list = nil
  16858. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  16859. }
  16860. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  16861. func (m *SopNodeMutation) ConditionListCleared() bool {
  16862. _, ok := m.clearedFields[sopnode.FieldConditionList]
  16863. return ok
  16864. }
  16865. // ResetConditionList resets all changes to the "condition_list" field.
  16866. func (m *SopNodeMutation) ResetConditionList() {
  16867. m.condition_list = nil
  16868. m.appendcondition_list = nil
  16869. delete(m.clearedFields, sopnode.FieldConditionList)
  16870. }
  16871. // SetNoReplyCondition sets the "no_reply_condition" field.
  16872. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  16873. m.no_reply_condition = &u
  16874. m.addno_reply_condition = nil
  16875. }
  16876. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  16877. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  16878. v := m.no_reply_condition
  16879. if v == nil {
  16880. return
  16881. }
  16882. return *v, true
  16883. }
  16884. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  16885. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16887. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  16888. if !m.op.Is(OpUpdateOne) {
  16889. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  16890. }
  16891. if m.id == nil || m.oldValue == nil {
  16892. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  16893. }
  16894. oldValue, err := m.oldValue(ctx)
  16895. if err != nil {
  16896. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  16897. }
  16898. return oldValue.NoReplyCondition, nil
  16899. }
  16900. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  16901. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  16902. if m.addno_reply_condition != nil {
  16903. *m.addno_reply_condition += u
  16904. } else {
  16905. m.addno_reply_condition = &u
  16906. }
  16907. }
  16908. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  16909. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  16910. v := m.addno_reply_condition
  16911. if v == nil {
  16912. return
  16913. }
  16914. return *v, true
  16915. }
  16916. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  16917. func (m *SopNodeMutation) ResetNoReplyCondition() {
  16918. m.no_reply_condition = nil
  16919. m.addno_reply_condition = nil
  16920. }
  16921. // SetNoReplyUnit sets the "no_reply_unit" field.
  16922. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  16923. m.no_reply_unit = &s
  16924. }
  16925. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  16926. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  16927. v := m.no_reply_unit
  16928. if v == nil {
  16929. return
  16930. }
  16931. return *v, true
  16932. }
  16933. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  16934. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16936. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  16937. if !m.op.Is(OpUpdateOne) {
  16938. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  16939. }
  16940. if m.id == nil || m.oldValue == nil {
  16941. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  16942. }
  16943. oldValue, err := m.oldValue(ctx)
  16944. if err != nil {
  16945. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  16946. }
  16947. return oldValue.NoReplyUnit, nil
  16948. }
  16949. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  16950. func (m *SopNodeMutation) ResetNoReplyUnit() {
  16951. m.no_reply_unit = nil
  16952. }
  16953. // SetActionMessage sets the "action_message" field.
  16954. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  16955. m.action_message = &ct
  16956. m.appendaction_message = nil
  16957. }
  16958. // ActionMessage returns the value of the "action_message" field in the mutation.
  16959. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  16960. v := m.action_message
  16961. if v == nil {
  16962. return
  16963. }
  16964. return *v, true
  16965. }
  16966. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  16967. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16969. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  16970. if !m.op.Is(OpUpdateOne) {
  16971. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  16972. }
  16973. if m.id == nil || m.oldValue == nil {
  16974. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  16975. }
  16976. oldValue, err := m.oldValue(ctx)
  16977. if err != nil {
  16978. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  16979. }
  16980. return oldValue.ActionMessage, nil
  16981. }
  16982. // AppendActionMessage adds ct to the "action_message" field.
  16983. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  16984. m.appendaction_message = append(m.appendaction_message, ct...)
  16985. }
  16986. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  16987. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  16988. if len(m.appendaction_message) == 0 {
  16989. return nil, false
  16990. }
  16991. return m.appendaction_message, true
  16992. }
  16993. // ClearActionMessage clears the value of the "action_message" field.
  16994. func (m *SopNodeMutation) ClearActionMessage() {
  16995. m.action_message = nil
  16996. m.appendaction_message = nil
  16997. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  16998. }
  16999. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  17000. func (m *SopNodeMutation) ActionMessageCleared() bool {
  17001. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  17002. return ok
  17003. }
  17004. // ResetActionMessage resets all changes to the "action_message" field.
  17005. func (m *SopNodeMutation) ResetActionMessage() {
  17006. m.action_message = nil
  17007. m.appendaction_message = nil
  17008. delete(m.clearedFields, sopnode.FieldActionMessage)
  17009. }
  17010. // SetActionLabelAdd sets the "action_label_add" field.
  17011. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  17012. m.action_label_add = &u
  17013. m.appendaction_label_add = nil
  17014. }
  17015. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17016. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17017. v := m.action_label_add
  17018. if v == nil {
  17019. return
  17020. }
  17021. return *v, true
  17022. }
  17023. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  17024. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17026. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17027. if !m.op.Is(OpUpdateOne) {
  17028. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17029. }
  17030. if m.id == nil || m.oldValue == nil {
  17031. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17032. }
  17033. oldValue, err := m.oldValue(ctx)
  17034. if err != nil {
  17035. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17036. }
  17037. return oldValue.ActionLabelAdd, nil
  17038. }
  17039. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17040. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  17041. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17042. }
  17043. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17044. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17045. if len(m.appendaction_label_add) == 0 {
  17046. return nil, false
  17047. }
  17048. return m.appendaction_label_add, true
  17049. }
  17050. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17051. func (m *SopNodeMutation) ClearActionLabelAdd() {
  17052. m.action_label_add = nil
  17053. m.appendaction_label_add = nil
  17054. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  17055. }
  17056. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17057. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  17058. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  17059. return ok
  17060. }
  17061. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17062. func (m *SopNodeMutation) ResetActionLabelAdd() {
  17063. m.action_label_add = nil
  17064. m.appendaction_label_add = nil
  17065. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  17066. }
  17067. // SetActionLabelDel sets the "action_label_del" field.
  17068. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  17069. m.action_label_del = &u
  17070. m.appendaction_label_del = nil
  17071. }
  17072. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  17073. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  17074. v := m.action_label_del
  17075. if v == nil {
  17076. return
  17077. }
  17078. return *v, true
  17079. }
  17080. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  17081. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17083. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  17084. if !m.op.Is(OpUpdateOne) {
  17085. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  17086. }
  17087. if m.id == nil || m.oldValue == nil {
  17088. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  17089. }
  17090. oldValue, err := m.oldValue(ctx)
  17091. if err != nil {
  17092. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  17093. }
  17094. return oldValue.ActionLabelDel, nil
  17095. }
  17096. // AppendActionLabelDel adds u to the "action_label_del" field.
  17097. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  17098. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  17099. }
  17100. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  17101. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  17102. if len(m.appendaction_label_del) == 0 {
  17103. return nil, false
  17104. }
  17105. return m.appendaction_label_del, true
  17106. }
  17107. // ClearActionLabelDel clears the value of the "action_label_del" field.
  17108. func (m *SopNodeMutation) ClearActionLabelDel() {
  17109. m.action_label_del = nil
  17110. m.appendaction_label_del = nil
  17111. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  17112. }
  17113. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  17114. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  17115. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  17116. return ok
  17117. }
  17118. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  17119. func (m *SopNodeMutation) ResetActionLabelDel() {
  17120. m.action_label_del = nil
  17121. m.appendaction_label_del = nil
  17122. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  17123. }
  17124. // SetActionForward sets the "action_forward" field.
  17125. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  17126. m.action_forward = &ctf
  17127. }
  17128. // ActionForward returns the value of the "action_forward" field in the mutation.
  17129. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  17130. v := m.action_forward
  17131. if v == nil {
  17132. return
  17133. }
  17134. return *v, true
  17135. }
  17136. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  17137. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17139. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  17140. if !m.op.Is(OpUpdateOne) {
  17141. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  17142. }
  17143. if m.id == nil || m.oldValue == nil {
  17144. return v, errors.New("OldActionForward requires an ID field in the mutation")
  17145. }
  17146. oldValue, err := m.oldValue(ctx)
  17147. if err != nil {
  17148. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  17149. }
  17150. return oldValue.ActionForward, nil
  17151. }
  17152. // ClearActionForward clears the value of the "action_forward" field.
  17153. func (m *SopNodeMutation) ClearActionForward() {
  17154. m.action_forward = nil
  17155. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  17156. }
  17157. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  17158. func (m *SopNodeMutation) ActionForwardCleared() bool {
  17159. _, ok := m.clearedFields[sopnode.FieldActionForward]
  17160. return ok
  17161. }
  17162. // ResetActionForward resets all changes to the "action_forward" field.
  17163. func (m *SopNodeMutation) ResetActionForward() {
  17164. m.action_forward = nil
  17165. delete(m.clearedFields, sopnode.FieldActionForward)
  17166. }
  17167. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17168. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  17169. m.sop_stage = &id
  17170. }
  17171. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17172. func (m *SopNodeMutation) ClearSopStage() {
  17173. m.clearedsop_stage = true
  17174. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  17175. }
  17176. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17177. func (m *SopNodeMutation) SopStageCleared() bool {
  17178. return m.clearedsop_stage
  17179. }
  17180. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17181. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  17182. if m.sop_stage != nil {
  17183. return *m.sop_stage, true
  17184. }
  17185. return
  17186. }
  17187. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17188. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17189. // SopStageID instead. It exists only for internal usage by the builders.
  17190. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  17191. if id := m.sop_stage; id != nil {
  17192. ids = append(ids, *id)
  17193. }
  17194. return
  17195. }
  17196. // ResetSopStage resets all changes to the "sop_stage" edge.
  17197. func (m *SopNodeMutation) ResetSopStage() {
  17198. m.sop_stage = nil
  17199. m.clearedsop_stage = false
  17200. }
  17201. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  17202. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  17203. if m.node_messages == nil {
  17204. m.node_messages = make(map[uint64]struct{})
  17205. }
  17206. for i := range ids {
  17207. m.node_messages[ids[i]] = struct{}{}
  17208. }
  17209. }
  17210. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  17211. func (m *SopNodeMutation) ClearNodeMessages() {
  17212. m.clearednode_messages = true
  17213. }
  17214. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  17215. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  17216. return m.clearednode_messages
  17217. }
  17218. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  17219. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  17220. if m.removednode_messages == nil {
  17221. m.removednode_messages = make(map[uint64]struct{})
  17222. }
  17223. for i := range ids {
  17224. delete(m.node_messages, ids[i])
  17225. m.removednode_messages[ids[i]] = struct{}{}
  17226. }
  17227. }
  17228. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  17229. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  17230. for id := range m.removednode_messages {
  17231. ids = append(ids, id)
  17232. }
  17233. return
  17234. }
  17235. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  17236. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  17237. for id := range m.node_messages {
  17238. ids = append(ids, id)
  17239. }
  17240. return
  17241. }
  17242. // ResetNodeMessages resets all changes to the "node_messages" edge.
  17243. func (m *SopNodeMutation) ResetNodeMessages() {
  17244. m.node_messages = nil
  17245. m.clearednode_messages = false
  17246. m.removednode_messages = nil
  17247. }
  17248. // Where appends a list predicates to the SopNodeMutation builder.
  17249. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  17250. m.predicates = append(m.predicates, ps...)
  17251. }
  17252. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  17253. // users can use type-assertion to append predicates that do not depend on any generated package.
  17254. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  17255. p := make([]predicate.SopNode, len(ps))
  17256. for i := range ps {
  17257. p[i] = ps[i]
  17258. }
  17259. m.Where(p...)
  17260. }
  17261. // Op returns the operation name.
  17262. func (m *SopNodeMutation) Op() Op {
  17263. return m.op
  17264. }
  17265. // SetOp allows setting the mutation operation.
  17266. func (m *SopNodeMutation) SetOp(op Op) {
  17267. m.op = op
  17268. }
  17269. // Type returns the node type of this mutation (SopNode).
  17270. func (m *SopNodeMutation) Type() string {
  17271. return m.typ
  17272. }
  17273. // Fields returns all fields that were changed during this mutation. Note that in
  17274. // order to get all numeric fields that were incremented/decremented, call
  17275. // AddedFields().
  17276. func (m *SopNodeMutation) Fields() []string {
  17277. fields := make([]string, 0, 15)
  17278. if m.created_at != nil {
  17279. fields = append(fields, sopnode.FieldCreatedAt)
  17280. }
  17281. if m.updated_at != nil {
  17282. fields = append(fields, sopnode.FieldUpdatedAt)
  17283. }
  17284. if m.status != nil {
  17285. fields = append(fields, sopnode.FieldStatus)
  17286. }
  17287. if m.deleted_at != nil {
  17288. fields = append(fields, sopnode.FieldDeletedAt)
  17289. }
  17290. if m.sop_stage != nil {
  17291. fields = append(fields, sopnode.FieldStageID)
  17292. }
  17293. if m.parent_id != nil {
  17294. fields = append(fields, sopnode.FieldParentID)
  17295. }
  17296. if m.name != nil {
  17297. fields = append(fields, sopnode.FieldName)
  17298. }
  17299. if m.condition_type != nil {
  17300. fields = append(fields, sopnode.FieldConditionType)
  17301. }
  17302. if m.condition_list != nil {
  17303. fields = append(fields, sopnode.FieldConditionList)
  17304. }
  17305. if m.no_reply_condition != nil {
  17306. fields = append(fields, sopnode.FieldNoReplyCondition)
  17307. }
  17308. if m.no_reply_unit != nil {
  17309. fields = append(fields, sopnode.FieldNoReplyUnit)
  17310. }
  17311. if m.action_message != nil {
  17312. fields = append(fields, sopnode.FieldActionMessage)
  17313. }
  17314. if m.action_label_add != nil {
  17315. fields = append(fields, sopnode.FieldActionLabelAdd)
  17316. }
  17317. if m.action_label_del != nil {
  17318. fields = append(fields, sopnode.FieldActionLabelDel)
  17319. }
  17320. if m.action_forward != nil {
  17321. fields = append(fields, sopnode.FieldActionForward)
  17322. }
  17323. return fields
  17324. }
  17325. // Field returns the value of a field with the given name. The second boolean
  17326. // return value indicates that this field was not set, or was not defined in the
  17327. // schema.
  17328. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  17329. switch name {
  17330. case sopnode.FieldCreatedAt:
  17331. return m.CreatedAt()
  17332. case sopnode.FieldUpdatedAt:
  17333. return m.UpdatedAt()
  17334. case sopnode.FieldStatus:
  17335. return m.Status()
  17336. case sopnode.FieldDeletedAt:
  17337. return m.DeletedAt()
  17338. case sopnode.FieldStageID:
  17339. return m.StageID()
  17340. case sopnode.FieldParentID:
  17341. return m.ParentID()
  17342. case sopnode.FieldName:
  17343. return m.Name()
  17344. case sopnode.FieldConditionType:
  17345. return m.ConditionType()
  17346. case sopnode.FieldConditionList:
  17347. return m.ConditionList()
  17348. case sopnode.FieldNoReplyCondition:
  17349. return m.NoReplyCondition()
  17350. case sopnode.FieldNoReplyUnit:
  17351. return m.NoReplyUnit()
  17352. case sopnode.FieldActionMessage:
  17353. return m.ActionMessage()
  17354. case sopnode.FieldActionLabelAdd:
  17355. return m.ActionLabelAdd()
  17356. case sopnode.FieldActionLabelDel:
  17357. return m.ActionLabelDel()
  17358. case sopnode.FieldActionForward:
  17359. return m.ActionForward()
  17360. }
  17361. return nil, false
  17362. }
  17363. // OldField returns the old value of the field from the database. An error is
  17364. // returned if the mutation operation is not UpdateOne, or the query to the
  17365. // database failed.
  17366. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17367. switch name {
  17368. case sopnode.FieldCreatedAt:
  17369. return m.OldCreatedAt(ctx)
  17370. case sopnode.FieldUpdatedAt:
  17371. return m.OldUpdatedAt(ctx)
  17372. case sopnode.FieldStatus:
  17373. return m.OldStatus(ctx)
  17374. case sopnode.FieldDeletedAt:
  17375. return m.OldDeletedAt(ctx)
  17376. case sopnode.FieldStageID:
  17377. return m.OldStageID(ctx)
  17378. case sopnode.FieldParentID:
  17379. return m.OldParentID(ctx)
  17380. case sopnode.FieldName:
  17381. return m.OldName(ctx)
  17382. case sopnode.FieldConditionType:
  17383. return m.OldConditionType(ctx)
  17384. case sopnode.FieldConditionList:
  17385. return m.OldConditionList(ctx)
  17386. case sopnode.FieldNoReplyCondition:
  17387. return m.OldNoReplyCondition(ctx)
  17388. case sopnode.FieldNoReplyUnit:
  17389. return m.OldNoReplyUnit(ctx)
  17390. case sopnode.FieldActionMessage:
  17391. return m.OldActionMessage(ctx)
  17392. case sopnode.FieldActionLabelAdd:
  17393. return m.OldActionLabelAdd(ctx)
  17394. case sopnode.FieldActionLabelDel:
  17395. return m.OldActionLabelDel(ctx)
  17396. case sopnode.FieldActionForward:
  17397. return m.OldActionForward(ctx)
  17398. }
  17399. return nil, fmt.Errorf("unknown SopNode field %s", name)
  17400. }
  17401. // SetField sets the value of a field with the given name. It returns an error if
  17402. // the field is not defined in the schema, or if the type mismatched the field
  17403. // type.
  17404. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  17405. switch name {
  17406. case sopnode.FieldCreatedAt:
  17407. v, ok := value.(time.Time)
  17408. if !ok {
  17409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17410. }
  17411. m.SetCreatedAt(v)
  17412. return nil
  17413. case sopnode.FieldUpdatedAt:
  17414. v, ok := value.(time.Time)
  17415. if !ok {
  17416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17417. }
  17418. m.SetUpdatedAt(v)
  17419. return nil
  17420. case sopnode.FieldStatus:
  17421. v, ok := value.(uint8)
  17422. if !ok {
  17423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17424. }
  17425. m.SetStatus(v)
  17426. return nil
  17427. case sopnode.FieldDeletedAt:
  17428. v, ok := value.(time.Time)
  17429. if !ok {
  17430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17431. }
  17432. m.SetDeletedAt(v)
  17433. return nil
  17434. case sopnode.FieldStageID:
  17435. v, ok := value.(uint64)
  17436. if !ok {
  17437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17438. }
  17439. m.SetStageID(v)
  17440. return nil
  17441. case sopnode.FieldParentID:
  17442. v, ok := value.(uint64)
  17443. if !ok {
  17444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17445. }
  17446. m.SetParentID(v)
  17447. return nil
  17448. case sopnode.FieldName:
  17449. v, ok := value.(string)
  17450. if !ok {
  17451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17452. }
  17453. m.SetName(v)
  17454. return nil
  17455. case sopnode.FieldConditionType:
  17456. v, ok := value.(int)
  17457. if !ok {
  17458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17459. }
  17460. m.SetConditionType(v)
  17461. return nil
  17462. case sopnode.FieldConditionList:
  17463. v, ok := value.([]string)
  17464. if !ok {
  17465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17466. }
  17467. m.SetConditionList(v)
  17468. return nil
  17469. case sopnode.FieldNoReplyCondition:
  17470. v, ok := value.(uint64)
  17471. if !ok {
  17472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17473. }
  17474. m.SetNoReplyCondition(v)
  17475. return nil
  17476. case sopnode.FieldNoReplyUnit:
  17477. v, ok := value.(string)
  17478. if !ok {
  17479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17480. }
  17481. m.SetNoReplyUnit(v)
  17482. return nil
  17483. case sopnode.FieldActionMessage:
  17484. v, ok := value.([]custom_types.Action)
  17485. if !ok {
  17486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17487. }
  17488. m.SetActionMessage(v)
  17489. return nil
  17490. case sopnode.FieldActionLabelAdd:
  17491. v, ok := value.([]uint64)
  17492. if !ok {
  17493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17494. }
  17495. m.SetActionLabelAdd(v)
  17496. return nil
  17497. case sopnode.FieldActionLabelDel:
  17498. v, ok := value.([]uint64)
  17499. if !ok {
  17500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17501. }
  17502. m.SetActionLabelDel(v)
  17503. return nil
  17504. case sopnode.FieldActionForward:
  17505. v, ok := value.(*custom_types.ActionForward)
  17506. if !ok {
  17507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17508. }
  17509. m.SetActionForward(v)
  17510. return nil
  17511. }
  17512. return fmt.Errorf("unknown SopNode field %s", name)
  17513. }
  17514. // AddedFields returns all numeric fields that were incremented/decremented during
  17515. // this mutation.
  17516. func (m *SopNodeMutation) AddedFields() []string {
  17517. var fields []string
  17518. if m.addstatus != nil {
  17519. fields = append(fields, sopnode.FieldStatus)
  17520. }
  17521. if m.addparent_id != nil {
  17522. fields = append(fields, sopnode.FieldParentID)
  17523. }
  17524. if m.addcondition_type != nil {
  17525. fields = append(fields, sopnode.FieldConditionType)
  17526. }
  17527. if m.addno_reply_condition != nil {
  17528. fields = append(fields, sopnode.FieldNoReplyCondition)
  17529. }
  17530. return fields
  17531. }
  17532. // AddedField returns the numeric value that was incremented/decremented on a field
  17533. // with the given name. The second boolean return value indicates that this field
  17534. // was not set, or was not defined in the schema.
  17535. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  17536. switch name {
  17537. case sopnode.FieldStatus:
  17538. return m.AddedStatus()
  17539. case sopnode.FieldParentID:
  17540. return m.AddedParentID()
  17541. case sopnode.FieldConditionType:
  17542. return m.AddedConditionType()
  17543. case sopnode.FieldNoReplyCondition:
  17544. return m.AddedNoReplyCondition()
  17545. }
  17546. return nil, false
  17547. }
  17548. // AddField adds the value to the field with the given name. It returns an error if
  17549. // the field is not defined in the schema, or if the type mismatched the field
  17550. // type.
  17551. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  17552. switch name {
  17553. case sopnode.FieldStatus:
  17554. v, ok := value.(int8)
  17555. if !ok {
  17556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17557. }
  17558. m.AddStatus(v)
  17559. return nil
  17560. case sopnode.FieldParentID:
  17561. v, ok := value.(int64)
  17562. if !ok {
  17563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17564. }
  17565. m.AddParentID(v)
  17566. return nil
  17567. case sopnode.FieldConditionType:
  17568. v, ok := value.(int)
  17569. if !ok {
  17570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17571. }
  17572. m.AddConditionType(v)
  17573. return nil
  17574. case sopnode.FieldNoReplyCondition:
  17575. v, ok := value.(int64)
  17576. if !ok {
  17577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17578. }
  17579. m.AddNoReplyCondition(v)
  17580. return nil
  17581. }
  17582. return fmt.Errorf("unknown SopNode numeric field %s", name)
  17583. }
  17584. // ClearedFields returns all nullable fields that were cleared during this
  17585. // mutation.
  17586. func (m *SopNodeMutation) ClearedFields() []string {
  17587. var fields []string
  17588. if m.FieldCleared(sopnode.FieldStatus) {
  17589. fields = append(fields, sopnode.FieldStatus)
  17590. }
  17591. if m.FieldCleared(sopnode.FieldDeletedAt) {
  17592. fields = append(fields, sopnode.FieldDeletedAt)
  17593. }
  17594. if m.FieldCleared(sopnode.FieldConditionList) {
  17595. fields = append(fields, sopnode.FieldConditionList)
  17596. }
  17597. if m.FieldCleared(sopnode.FieldActionMessage) {
  17598. fields = append(fields, sopnode.FieldActionMessage)
  17599. }
  17600. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  17601. fields = append(fields, sopnode.FieldActionLabelAdd)
  17602. }
  17603. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  17604. fields = append(fields, sopnode.FieldActionLabelDel)
  17605. }
  17606. if m.FieldCleared(sopnode.FieldActionForward) {
  17607. fields = append(fields, sopnode.FieldActionForward)
  17608. }
  17609. return fields
  17610. }
  17611. // FieldCleared returns a boolean indicating if a field with the given name was
  17612. // cleared in this mutation.
  17613. func (m *SopNodeMutation) FieldCleared(name string) bool {
  17614. _, ok := m.clearedFields[name]
  17615. return ok
  17616. }
  17617. // ClearField clears the value of the field with the given name. It returns an
  17618. // error if the field is not defined in the schema.
  17619. func (m *SopNodeMutation) ClearField(name string) error {
  17620. switch name {
  17621. case sopnode.FieldStatus:
  17622. m.ClearStatus()
  17623. return nil
  17624. case sopnode.FieldDeletedAt:
  17625. m.ClearDeletedAt()
  17626. return nil
  17627. case sopnode.FieldConditionList:
  17628. m.ClearConditionList()
  17629. return nil
  17630. case sopnode.FieldActionMessage:
  17631. m.ClearActionMessage()
  17632. return nil
  17633. case sopnode.FieldActionLabelAdd:
  17634. m.ClearActionLabelAdd()
  17635. return nil
  17636. case sopnode.FieldActionLabelDel:
  17637. m.ClearActionLabelDel()
  17638. return nil
  17639. case sopnode.FieldActionForward:
  17640. m.ClearActionForward()
  17641. return nil
  17642. }
  17643. return fmt.Errorf("unknown SopNode nullable field %s", name)
  17644. }
  17645. // ResetField resets all changes in the mutation for the field with the given name.
  17646. // It returns an error if the field is not defined in the schema.
  17647. func (m *SopNodeMutation) ResetField(name string) error {
  17648. switch name {
  17649. case sopnode.FieldCreatedAt:
  17650. m.ResetCreatedAt()
  17651. return nil
  17652. case sopnode.FieldUpdatedAt:
  17653. m.ResetUpdatedAt()
  17654. return nil
  17655. case sopnode.FieldStatus:
  17656. m.ResetStatus()
  17657. return nil
  17658. case sopnode.FieldDeletedAt:
  17659. m.ResetDeletedAt()
  17660. return nil
  17661. case sopnode.FieldStageID:
  17662. m.ResetStageID()
  17663. return nil
  17664. case sopnode.FieldParentID:
  17665. m.ResetParentID()
  17666. return nil
  17667. case sopnode.FieldName:
  17668. m.ResetName()
  17669. return nil
  17670. case sopnode.FieldConditionType:
  17671. m.ResetConditionType()
  17672. return nil
  17673. case sopnode.FieldConditionList:
  17674. m.ResetConditionList()
  17675. return nil
  17676. case sopnode.FieldNoReplyCondition:
  17677. m.ResetNoReplyCondition()
  17678. return nil
  17679. case sopnode.FieldNoReplyUnit:
  17680. m.ResetNoReplyUnit()
  17681. return nil
  17682. case sopnode.FieldActionMessage:
  17683. m.ResetActionMessage()
  17684. return nil
  17685. case sopnode.FieldActionLabelAdd:
  17686. m.ResetActionLabelAdd()
  17687. return nil
  17688. case sopnode.FieldActionLabelDel:
  17689. m.ResetActionLabelDel()
  17690. return nil
  17691. case sopnode.FieldActionForward:
  17692. m.ResetActionForward()
  17693. return nil
  17694. }
  17695. return fmt.Errorf("unknown SopNode field %s", name)
  17696. }
  17697. // AddedEdges returns all edge names that were set/added in this mutation.
  17698. func (m *SopNodeMutation) AddedEdges() []string {
  17699. edges := make([]string, 0, 2)
  17700. if m.sop_stage != nil {
  17701. edges = append(edges, sopnode.EdgeSopStage)
  17702. }
  17703. if m.node_messages != nil {
  17704. edges = append(edges, sopnode.EdgeNodeMessages)
  17705. }
  17706. return edges
  17707. }
  17708. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17709. // name in this mutation.
  17710. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  17711. switch name {
  17712. case sopnode.EdgeSopStage:
  17713. if id := m.sop_stage; id != nil {
  17714. return []ent.Value{*id}
  17715. }
  17716. case sopnode.EdgeNodeMessages:
  17717. ids := make([]ent.Value, 0, len(m.node_messages))
  17718. for id := range m.node_messages {
  17719. ids = append(ids, id)
  17720. }
  17721. return ids
  17722. }
  17723. return nil
  17724. }
  17725. // RemovedEdges returns all edge names that were removed in this mutation.
  17726. func (m *SopNodeMutation) RemovedEdges() []string {
  17727. edges := make([]string, 0, 2)
  17728. if m.removednode_messages != nil {
  17729. edges = append(edges, sopnode.EdgeNodeMessages)
  17730. }
  17731. return edges
  17732. }
  17733. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17734. // the given name in this mutation.
  17735. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  17736. switch name {
  17737. case sopnode.EdgeNodeMessages:
  17738. ids := make([]ent.Value, 0, len(m.removednode_messages))
  17739. for id := range m.removednode_messages {
  17740. ids = append(ids, id)
  17741. }
  17742. return ids
  17743. }
  17744. return nil
  17745. }
  17746. // ClearedEdges returns all edge names that were cleared in this mutation.
  17747. func (m *SopNodeMutation) ClearedEdges() []string {
  17748. edges := make([]string, 0, 2)
  17749. if m.clearedsop_stage {
  17750. edges = append(edges, sopnode.EdgeSopStage)
  17751. }
  17752. if m.clearednode_messages {
  17753. edges = append(edges, sopnode.EdgeNodeMessages)
  17754. }
  17755. return edges
  17756. }
  17757. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17758. // was cleared in this mutation.
  17759. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  17760. switch name {
  17761. case sopnode.EdgeSopStage:
  17762. return m.clearedsop_stage
  17763. case sopnode.EdgeNodeMessages:
  17764. return m.clearednode_messages
  17765. }
  17766. return false
  17767. }
  17768. // ClearEdge clears the value of the edge with the given name. It returns an error
  17769. // if that edge is not defined in the schema.
  17770. func (m *SopNodeMutation) ClearEdge(name string) error {
  17771. switch name {
  17772. case sopnode.EdgeSopStage:
  17773. m.ClearSopStage()
  17774. return nil
  17775. }
  17776. return fmt.Errorf("unknown SopNode unique edge %s", name)
  17777. }
  17778. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17779. // It returns an error if the edge is not defined in the schema.
  17780. func (m *SopNodeMutation) ResetEdge(name string) error {
  17781. switch name {
  17782. case sopnode.EdgeSopStage:
  17783. m.ResetSopStage()
  17784. return nil
  17785. case sopnode.EdgeNodeMessages:
  17786. m.ResetNodeMessages()
  17787. return nil
  17788. }
  17789. return fmt.Errorf("unknown SopNode edge %s", name)
  17790. }
  17791. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  17792. type SopStageMutation struct {
  17793. config
  17794. op Op
  17795. typ string
  17796. id *uint64
  17797. created_at *time.Time
  17798. updated_at *time.Time
  17799. status *uint8
  17800. addstatus *int8
  17801. deleted_at *time.Time
  17802. name *string
  17803. condition_type *int
  17804. addcondition_type *int
  17805. condition_operator *int
  17806. addcondition_operator *int
  17807. condition_list *[]custom_types.Condition
  17808. appendcondition_list []custom_types.Condition
  17809. action_message *[]custom_types.Action
  17810. appendaction_message []custom_types.Action
  17811. action_label_add *[]uint64
  17812. appendaction_label_add []uint64
  17813. action_label_del *[]uint64
  17814. appendaction_label_del []uint64
  17815. action_forward **custom_types.ActionForward
  17816. index_sort *int
  17817. addindex_sort *int
  17818. clearedFields map[string]struct{}
  17819. sop_task *uint64
  17820. clearedsop_task bool
  17821. stage_nodes map[uint64]struct{}
  17822. removedstage_nodes map[uint64]struct{}
  17823. clearedstage_nodes bool
  17824. stage_messages map[uint64]struct{}
  17825. removedstage_messages map[uint64]struct{}
  17826. clearedstage_messages bool
  17827. done bool
  17828. oldValue func(context.Context) (*SopStage, error)
  17829. predicates []predicate.SopStage
  17830. }
  17831. var _ ent.Mutation = (*SopStageMutation)(nil)
  17832. // sopstageOption allows management of the mutation configuration using functional options.
  17833. type sopstageOption func(*SopStageMutation)
  17834. // newSopStageMutation creates new mutation for the SopStage entity.
  17835. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  17836. m := &SopStageMutation{
  17837. config: c,
  17838. op: op,
  17839. typ: TypeSopStage,
  17840. clearedFields: make(map[string]struct{}),
  17841. }
  17842. for _, opt := range opts {
  17843. opt(m)
  17844. }
  17845. return m
  17846. }
  17847. // withSopStageID sets the ID field of the mutation.
  17848. func withSopStageID(id uint64) sopstageOption {
  17849. return func(m *SopStageMutation) {
  17850. var (
  17851. err error
  17852. once sync.Once
  17853. value *SopStage
  17854. )
  17855. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  17856. once.Do(func() {
  17857. if m.done {
  17858. err = errors.New("querying old values post mutation is not allowed")
  17859. } else {
  17860. value, err = m.Client().SopStage.Get(ctx, id)
  17861. }
  17862. })
  17863. return value, err
  17864. }
  17865. m.id = &id
  17866. }
  17867. }
  17868. // withSopStage sets the old SopStage of the mutation.
  17869. func withSopStage(node *SopStage) sopstageOption {
  17870. return func(m *SopStageMutation) {
  17871. m.oldValue = func(context.Context) (*SopStage, error) {
  17872. return node, nil
  17873. }
  17874. m.id = &node.ID
  17875. }
  17876. }
  17877. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17878. // executed in a transaction (ent.Tx), a transactional client is returned.
  17879. func (m SopStageMutation) Client() *Client {
  17880. client := &Client{config: m.config}
  17881. client.init()
  17882. return client
  17883. }
  17884. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17885. // it returns an error otherwise.
  17886. func (m SopStageMutation) Tx() (*Tx, error) {
  17887. if _, ok := m.driver.(*txDriver); !ok {
  17888. return nil, errors.New("ent: mutation is not running in a transaction")
  17889. }
  17890. tx := &Tx{config: m.config}
  17891. tx.init()
  17892. return tx, nil
  17893. }
  17894. // SetID sets the value of the id field. Note that this
  17895. // operation is only accepted on creation of SopStage entities.
  17896. func (m *SopStageMutation) SetID(id uint64) {
  17897. m.id = &id
  17898. }
  17899. // ID returns the ID value in the mutation. Note that the ID is only available
  17900. // if it was provided to the builder or after it was returned from the database.
  17901. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  17902. if m.id == nil {
  17903. return
  17904. }
  17905. return *m.id, true
  17906. }
  17907. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17908. // That means, if the mutation is applied within a transaction with an isolation level such
  17909. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17910. // or updated by the mutation.
  17911. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  17912. switch {
  17913. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17914. id, exists := m.ID()
  17915. if exists {
  17916. return []uint64{id}, nil
  17917. }
  17918. fallthrough
  17919. case m.op.Is(OpUpdate | OpDelete):
  17920. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  17921. default:
  17922. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17923. }
  17924. }
  17925. // SetCreatedAt sets the "created_at" field.
  17926. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  17927. m.created_at = &t
  17928. }
  17929. // CreatedAt returns the value of the "created_at" field in the mutation.
  17930. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  17931. v := m.created_at
  17932. if v == nil {
  17933. return
  17934. }
  17935. return *v, true
  17936. }
  17937. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  17938. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17940. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17941. if !m.op.Is(OpUpdateOne) {
  17942. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17943. }
  17944. if m.id == nil || m.oldValue == nil {
  17945. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17946. }
  17947. oldValue, err := m.oldValue(ctx)
  17948. if err != nil {
  17949. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17950. }
  17951. return oldValue.CreatedAt, nil
  17952. }
  17953. // ResetCreatedAt resets all changes to the "created_at" field.
  17954. func (m *SopStageMutation) ResetCreatedAt() {
  17955. m.created_at = nil
  17956. }
  17957. // SetUpdatedAt sets the "updated_at" field.
  17958. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  17959. m.updated_at = &t
  17960. }
  17961. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17962. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  17963. v := m.updated_at
  17964. if v == nil {
  17965. return
  17966. }
  17967. return *v, true
  17968. }
  17969. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  17970. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17972. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17973. if !m.op.Is(OpUpdateOne) {
  17974. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17975. }
  17976. if m.id == nil || m.oldValue == nil {
  17977. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17978. }
  17979. oldValue, err := m.oldValue(ctx)
  17980. if err != nil {
  17981. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17982. }
  17983. return oldValue.UpdatedAt, nil
  17984. }
  17985. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17986. func (m *SopStageMutation) ResetUpdatedAt() {
  17987. m.updated_at = nil
  17988. }
  17989. // SetStatus sets the "status" field.
  17990. func (m *SopStageMutation) SetStatus(u uint8) {
  17991. m.status = &u
  17992. m.addstatus = nil
  17993. }
  17994. // Status returns the value of the "status" field in the mutation.
  17995. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  17996. v := m.status
  17997. if v == nil {
  17998. return
  17999. }
  18000. return *v, true
  18001. }
  18002. // OldStatus returns the old "status" field's value of the SopStage entity.
  18003. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18005. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18006. if !m.op.Is(OpUpdateOne) {
  18007. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18008. }
  18009. if m.id == nil || m.oldValue == nil {
  18010. return v, errors.New("OldStatus requires an ID field in the mutation")
  18011. }
  18012. oldValue, err := m.oldValue(ctx)
  18013. if err != nil {
  18014. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18015. }
  18016. return oldValue.Status, nil
  18017. }
  18018. // AddStatus adds u to the "status" field.
  18019. func (m *SopStageMutation) AddStatus(u int8) {
  18020. if m.addstatus != nil {
  18021. *m.addstatus += u
  18022. } else {
  18023. m.addstatus = &u
  18024. }
  18025. }
  18026. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18027. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  18028. v := m.addstatus
  18029. if v == nil {
  18030. return
  18031. }
  18032. return *v, true
  18033. }
  18034. // ClearStatus clears the value of the "status" field.
  18035. func (m *SopStageMutation) ClearStatus() {
  18036. m.status = nil
  18037. m.addstatus = nil
  18038. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  18039. }
  18040. // StatusCleared returns if the "status" field was cleared in this mutation.
  18041. func (m *SopStageMutation) StatusCleared() bool {
  18042. _, ok := m.clearedFields[sopstage.FieldStatus]
  18043. return ok
  18044. }
  18045. // ResetStatus resets all changes to the "status" field.
  18046. func (m *SopStageMutation) ResetStatus() {
  18047. m.status = nil
  18048. m.addstatus = nil
  18049. delete(m.clearedFields, sopstage.FieldStatus)
  18050. }
  18051. // SetDeletedAt sets the "deleted_at" field.
  18052. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  18053. m.deleted_at = &t
  18054. }
  18055. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18056. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  18057. v := m.deleted_at
  18058. if v == nil {
  18059. return
  18060. }
  18061. return *v, true
  18062. }
  18063. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  18064. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18066. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18067. if !m.op.Is(OpUpdateOne) {
  18068. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18069. }
  18070. if m.id == nil || m.oldValue == nil {
  18071. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18072. }
  18073. oldValue, err := m.oldValue(ctx)
  18074. if err != nil {
  18075. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18076. }
  18077. return oldValue.DeletedAt, nil
  18078. }
  18079. // ClearDeletedAt clears the value of the "deleted_at" field.
  18080. func (m *SopStageMutation) ClearDeletedAt() {
  18081. m.deleted_at = nil
  18082. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  18083. }
  18084. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18085. func (m *SopStageMutation) DeletedAtCleared() bool {
  18086. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  18087. return ok
  18088. }
  18089. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18090. func (m *SopStageMutation) ResetDeletedAt() {
  18091. m.deleted_at = nil
  18092. delete(m.clearedFields, sopstage.FieldDeletedAt)
  18093. }
  18094. // SetTaskID sets the "task_id" field.
  18095. func (m *SopStageMutation) SetTaskID(u uint64) {
  18096. m.sop_task = &u
  18097. }
  18098. // TaskID returns the value of the "task_id" field in the mutation.
  18099. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  18100. v := m.sop_task
  18101. if v == nil {
  18102. return
  18103. }
  18104. return *v, true
  18105. }
  18106. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  18107. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18109. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  18110. if !m.op.Is(OpUpdateOne) {
  18111. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  18112. }
  18113. if m.id == nil || m.oldValue == nil {
  18114. return v, errors.New("OldTaskID requires an ID field in the mutation")
  18115. }
  18116. oldValue, err := m.oldValue(ctx)
  18117. if err != nil {
  18118. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  18119. }
  18120. return oldValue.TaskID, nil
  18121. }
  18122. // ResetTaskID resets all changes to the "task_id" field.
  18123. func (m *SopStageMutation) ResetTaskID() {
  18124. m.sop_task = nil
  18125. }
  18126. // SetName sets the "name" field.
  18127. func (m *SopStageMutation) SetName(s string) {
  18128. m.name = &s
  18129. }
  18130. // Name returns the value of the "name" field in the mutation.
  18131. func (m *SopStageMutation) Name() (r string, exists bool) {
  18132. v := m.name
  18133. if v == nil {
  18134. return
  18135. }
  18136. return *v, true
  18137. }
  18138. // OldName returns the old "name" field's value of the SopStage entity.
  18139. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18141. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  18142. if !m.op.Is(OpUpdateOne) {
  18143. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18144. }
  18145. if m.id == nil || m.oldValue == nil {
  18146. return v, errors.New("OldName requires an ID field in the mutation")
  18147. }
  18148. oldValue, err := m.oldValue(ctx)
  18149. if err != nil {
  18150. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18151. }
  18152. return oldValue.Name, nil
  18153. }
  18154. // ResetName resets all changes to the "name" field.
  18155. func (m *SopStageMutation) ResetName() {
  18156. m.name = nil
  18157. }
  18158. // SetConditionType sets the "condition_type" field.
  18159. func (m *SopStageMutation) SetConditionType(i int) {
  18160. m.condition_type = &i
  18161. m.addcondition_type = nil
  18162. }
  18163. // ConditionType returns the value of the "condition_type" field in the mutation.
  18164. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  18165. v := m.condition_type
  18166. if v == nil {
  18167. return
  18168. }
  18169. return *v, true
  18170. }
  18171. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  18172. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18174. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  18175. if !m.op.Is(OpUpdateOne) {
  18176. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  18177. }
  18178. if m.id == nil || m.oldValue == nil {
  18179. return v, errors.New("OldConditionType requires an ID field in the mutation")
  18180. }
  18181. oldValue, err := m.oldValue(ctx)
  18182. if err != nil {
  18183. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  18184. }
  18185. return oldValue.ConditionType, nil
  18186. }
  18187. // AddConditionType adds i to the "condition_type" field.
  18188. func (m *SopStageMutation) AddConditionType(i int) {
  18189. if m.addcondition_type != nil {
  18190. *m.addcondition_type += i
  18191. } else {
  18192. m.addcondition_type = &i
  18193. }
  18194. }
  18195. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  18196. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  18197. v := m.addcondition_type
  18198. if v == nil {
  18199. return
  18200. }
  18201. return *v, true
  18202. }
  18203. // ResetConditionType resets all changes to the "condition_type" field.
  18204. func (m *SopStageMutation) ResetConditionType() {
  18205. m.condition_type = nil
  18206. m.addcondition_type = nil
  18207. }
  18208. // SetConditionOperator sets the "condition_operator" field.
  18209. func (m *SopStageMutation) SetConditionOperator(i int) {
  18210. m.condition_operator = &i
  18211. m.addcondition_operator = nil
  18212. }
  18213. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  18214. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  18215. v := m.condition_operator
  18216. if v == nil {
  18217. return
  18218. }
  18219. return *v, true
  18220. }
  18221. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  18222. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18224. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  18225. if !m.op.Is(OpUpdateOne) {
  18226. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  18227. }
  18228. if m.id == nil || m.oldValue == nil {
  18229. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  18230. }
  18231. oldValue, err := m.oldValue(ctx)
  18232. if err != nil {
  18233. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  18234. }
  18235. return oldValue.ConditionOperator, nil
  18236. }
  18237. // AddConditionOperator adds i to the "condition_operator" field.
  18238. func (m *SopStageMutation) AddConditionOperator(i int) {
  18239. if m.addcondition_operator != nil {
  18240. *m.addcondition_operator += i
  18241. } else {
  18242. m.addcondition_operator = &i
  18243. }
  18244. }
  18245. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  18246. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  18247. v := m.addcondition_operator
  18248. if v == nil {
  18249. return
  18250. }
  18251. return *v, true
  18252. }
  18253. // ResetConditionOperator resets all changes to the "condition_operator" field.
  18254. func (m *SopStageMutation) ResetConditionOperator() {
  18255. m.condition_operator = nil
  18256. m.addcondition_operator = nil
  18257. }
  18258. // SetConditionList sets the "condition_list" field.
  18259. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  18260. m.condition_list = &ct
  18261. m.appendcondition_list = nil
  18262. }
  18263. // ConditionList returns the value of the "condition_list" field in the mutation.
  18264. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  18265. v := m.condition_list
  18266. if v == nil {
  18267. return
  18268. }
  18269. return *v, true
  18270. }
  18271. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  18272. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18274. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  18275. if !m.op.Is(OpUpdateOne) {
  18276. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  18277. }
  18278. if m.id == nil || m.oldValue == nil {
  18279. return v, errors.New("OldConditionList requires an ID field in the mutation")
  18280. }
  18281. oldValue, err := m.oldValue(ctx)
  18282. if err != nil {
  18283. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  18284. }
  18285. return oldValue.ConditionList, nil
  18286. }
  18287. // AppendConditionList adds ct to the "condition_list" field.
  18288. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  18289. m.appendcondition_list = append(m.appendcondition_list, ct...)
  18290. }
  18291. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  18292. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  18293. if len(m.appendcondition_list) == 0 {
  18294. return nil, false
  18295. }
  18296. return m.appendcondition_list, true
  18297. }
  18298. // ResetConditionList resets all changes to the "condition_list" field.
  18299. func (m *SopStageMutation) ResetConditionList() {
  18300. m.condition_list = nil
  18301. m.appendcondition_list = nil
  18302. }
  18303. // SetActionMessage sets the "action_message" field.
  18304. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  18305. m.action_message = &ct
  18306. m.appendaction_message = nil
  18307. }
  18308. // ActionMessage returns the value of the "action_message" field in the mutation.
  18309. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  18310. v := m.action_message
  18311. if v == nil {
  18312. return
  18313. }
  18314. return *v, true
  18315. }
  18316. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  18317. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18319. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  18320. if !m.op.Is(OpUpdateOne) {
  18321. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  18322. }
  18323. if m.id == nil || m.oldValue == nil {
  18324. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  18325. }
  18326. oldValue, err := m.oldValue(ctx)
  18327. if err != nil {
  18328. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  18329. }
  18330. return oldValue.ActionMessage, nil
  18331. }
  18332. // AppendActionMessage adds ct to the "action_message" field.
  18333. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  18334. m.appendaction_message = append(m.appendaction_message, ct...)
  18335. }
  18336. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  18337. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  18338. if len(m.appendaction_message) == 0 {
  18339. return nil, false
  18340. }
  18341. return m.appendaction_message, true
  18342. }
  18343. // ClearActionMessage clears the value of the "action_message" field.
  18344. func (m *SopStageMutation) ClearActionMessage() {
  18345. m.action_message = nil
  18346. m.appendaction_message = nil
  18347. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  18348. }
  18349. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  18350. func (m *SopStageMutation) ActionMessageCleared() bool {
  18351. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  18352. return ok
  18353. }
  18354. // ResetActionMessage resets all changes to the "action_message" field.
  18355. func (m *SopStageMutation) ResetActionMessage() {
  18356. m.action_message = nil
  18357. m.appendaction_message = nil
  18358. delete(m.clearedFields, sopstage.FieldActionMessage)
  18359. }
  18360. // SetActionLabelAdd sets the "action_label_add" field.
  18361. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  18362. m.action_label_add = &u
  18363. m.appendaction_label_add = nil
  18364. }
  18365. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  18366. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  18367. v := m.action_label_add
  18368. if v == nil {
  18369. return
  18370. }
  18371. return *v, true
  18372. }
  18373. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  18374. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18376. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  18377. if !m.op.Is(OpUpdateOne) {
  18378. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  18379. }
  18380. if m.id == nil || m.oldValue == nil {
  18381. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  18382. }
  18383. oldValue, err := m.oldValue(ctx)
  18384. if err != nil {
  18385. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  18386. }
  18387. return oldValue.ActionLabelAdd, nil
  18388. }
  18389. // AppendActionLabelAdd adds u to the "action_label_add" field.
  18390. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  18391. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  18392. }
  18393. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  18394. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  18395. if len(m.appendaction_label_add) == 0 {
  18396. return nil, false
  18397. }
  18398. return m.appendaction_label_add, true
  18399. }
  18400. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  18401. func (m *SopStageMutation) ClearActionLabelAdd() {
  18402. m.action_label_add = nil
  18403. m.appendaction_label_add = nil
  18404. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  18405. }
  18406. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  18407. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  18408. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  18409. return ok
  18410. }
  18411. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  18412. func (m *SopStageMutation) ResetActionLabelAdd() {
  18413. m.action_label_add = nil
  18414. m.appendaction_label_add = nil
  18415. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  18416. }
  18417. // SetActionLabelDel sets the "action_label_del" field.
  18418. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  18419. m.action_label_del = &u
  18420. m.appendaction_label_del = nil
  18421. }
  18422. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18423. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  18424. v := m.action_label_del
  18425. if v == nil {
  18426. return
  18427. }
  18428. return *v, true
  18429. }
  18430. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  18431. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18433. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18434. if !m.op.Is(OpUpdateOne) {
  18435. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18436. }
  18437. if m.id == nil || m.oldValue == nil {
  18438. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18439. }
  18440. oldValue, err := m.oldValue(ctx)
  18441. if err != nil {
  18442. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18443. }
  18444. return oldValue.ActionLabelDel, nil
  18445. }
  18446. // AppendActionLabelDel adds u to the "action_label_del" field.
  18447. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  18448. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18449. }
  18450. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18451. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18452. if len(m.appendaction_label_del) == 0 {
  18453. return nil, false
  18454. }
  18455. return m.appendaction_label_del, true
  18456. }
  18457. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18458. func (m *SopStageMutation) ClearActionLabelDel() {
  18459. m.action_label_del = nil
  18460. m.appendaction_label_del = nil
  18461. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  18462. }
  18463. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18464. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  18465. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  18466. return ok
  18467. }
  18468. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18469. func (m *SopStageMutation) ResetActionLabelDel() {
  18470. m.action_label_del = nil
  18471. m.appendaction_label_del = nil
  18472. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  18473. }
  18474. // SetActionForward sets the "action_forward" field.
  18475. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  18476. m.action_forward = &ctf
  18477. }
  18478. // ActionForward returns the value of the "action_forward" field in the mutation.
  18479. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  18480. v := m.action_forward
  18481. if v == nil {
  18482. return
  18483. }
  18484. return *v, true
  18485. }
  18486. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  18487. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18489. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  18490. if !m.op.Is(OpUpdateOne) {
  18491. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  18492. }
  18493. if m.id == nil || m.oldValue == nil {
  18494. return v, errors.New("OldActionForward requires an ID field in the mutation")
  18495. }
  18496. oldValue, err := m.oldValue(ctx)
  18497. if err != nil {
  18498. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  18499. }
  18500. return oldValue.ActionForward, nil
  18501. }
  18502. // ClearActionForward clears the value of the "action_forward" field.
  18503. func (m *SopStageMutation) ClearActionForward() {
  18504. m.action_forward = nil
  18505. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  18506. }
  18507. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  18508. func (m *SopStageMutation) ActionForwardCleared() bool {
  18509. _, ok := m.clearedFields[sopstage.FieldActionForward]
  18510. return ok
  18511. }
  18512. // ResetActionForward resets all changes to the "action_forward" field.
  18513. func (m *SopStageMutation) ResetActionForward() {
  18514. m.action_forward = nil
  18515. delete(m.clearedFields, sopstage.FieldActionForward)
  18516. }
  18517. // SetIndexSort sets the "index_sort" field.
  18518. func (m *SopStageMutation) SetIndexSort(i int) {
  18519. m.index_sort = &i
  18520. m.addindex_sort = nil
  18521. }
  18522. // IndexSort returns the value of the "index_sort" field in the mutation.
  18523. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  18524. v := m.index_sort
  18525. if v == nil {
  18526. return
  18527. }
  18528. return *v, true
  18529. }
  18530. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  18531. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18533. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  18534. if !m.op.Is(OpUpdateOne) {
  18535. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  18536. }
  18537. if m.id == nil || m.oldValue == nil {
  18538. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  18539. }
  18540. oldValue, err := m.oldValue(ctx)
  18541. if err != nil {
  18542. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  18543. }
  18544. return oldValue.IndexSort, nil
  18545. }
  18546. // AddIndexSort adds i to the "index_sort" field.
  18547. func (m *SopStageMutation) AddIndexSort(i int) {
  18548. if m.addindex_sort != nil {
  18549. *m.addindex_sort += i
  18550. } else {
  18551. m.addindex_sort = &i
  18552. }
  18553. }
  18554. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  18555. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  18556. v := m.addindex_sort
  18557. if v == nil {
  18558. return
  18559. }
  18560. return *v, true
  18561. }
  18562. // ClearIndexSort clears the value of the "index_sort" field.
  18563. func (m *SopStageMutation) ClearIndexSort() {
  18564. m.index_sort = nil
  18565. m.addindex_sort = nil
  18566. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  18567. }
  18568. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  18569. func (m *SopStageMutation) IndexSortCleared() bool {
  18570. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  18571. return ok
  18572. }
  18573. // ResetIndexSort resets all changes to the "index_sort" field.
  18574. func (m *SopStageMutation) ResetIndexSort() {
  18575. m.index_sort = nil
  18576. m.addindex_sort = nil
  18577. delete(m.clearedFields, sopstage.FieldIndexSort)
  18578. }
  18579. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  18580. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  18581. m.sop_task = &id
  18582. }
  18583. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  18584. func (m *SopStageMutation) ClearSopTask() {
  18585. m.clearedsop_task = true
  18586. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  18587. }
  18588. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  18589. func (m *SopStageMutation) SopTaskCleared() bool {
  18590. return m.clearedsop_task
  18591. }
  18592. // SopTaskID returns the "sop_task" edge ID in the mutation.
  18593. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  18594. if m.sop_task != nil {
  18595. return *m.sop_task, true
  18596. }
  18597. return
  18598. }
  18599. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  18600. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18601. // SopTaskID instead. It exists only for internal usage by the builders.
  18602. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  18603. if id := m.sop_task; id != nil {
  18604. ids = append(ids, *id)
  18605. }
  18606. return
  18607. }
  18608. // ResetSopTask resets all changes to the "sop_task" edge.
  18609. func (m *SopStageMutation) ResetSopTask() {
  18610. m.sop_task = nil
  18611. m.clearedsop_task = false
  18612. }
  18613. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  18614. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  18615. if m.stage_nodes == nil {
  18616. m.stage_nodes = make(map[uint64]struct{})
  18617. }
  18618. for i := range ids {
  18619. m.stage_nodes[ids[i]] = struct{}{}
  18620. }
  18621. }
  18622. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  18623. func (m *SopStageMutation) ClearStageNodes() {
  18624. m.clearedstage_nodes = true
  18625. }
  18626. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  18627. func (m *SopStageMutation) StageNodesCleared() bool {
  18628. return m.clearedstage_nodes
  18629. }
  18630. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  18631. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  18632. if m.removedstage_nodes == nil {
  18633. m.removedstage_nodes = make(map[uint64]struct{})
  18634. }
  18635. for i := range ids {
  18636. delete(m.stage_nodes, ids[i])
  18637. m.removedstage_nodes[ids[i]] = struct{}{}
  18638. }
  18639. }
  18640. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  18641. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  18642. for id := range m.removedstage_nodes {
  18643. ids = append(ids, id)
  18644. }
  18645. return
  18646. }
  18647. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  18648. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  18649. for id := range m.stage_nodes {
  18650. ids = append(ids, id)
  18651. }
  18652. return
  18653. }
  18654. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  18655. func (m *SopStageMutation) ResetStageNodes() {
  18656. m.stage_nodes = nil
  18657. m.clearedstage_nodes = false
  18658. m.removedstage_nodes = nil
  18659. }
  18660. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  18661. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  18662. if m.stage_messages == nil {
  18663. m.stage_messages = make(map[uint64]struct{})
  18664. }
  18665. for i := range ids {
  18666. m.stage_messages[ids[i]] = struct{}{}
  18667. }
  18668. }
  18669. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  18670. func (m *SopStageMutation) ClearStageMessages() {
  18671. m.clearedstage_messages = true
  18672. }
  18673. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  18674. func (m *SopStageMutation) StageMessagesCleared() bool {
  18675. return m.clearedstage_messages
  18676. }
  18677. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  18678. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  18679. if m.removedstage_messages == nil {
  18680. m.removedstage_messages = make(map[uint64]struct{})
  18681. }
  18682. for i := range ids {
  18683. delete(m.stage_messages, ids[i])
  18684. m.removedstage_messages[ids[i]] = struct{}{}
  18685. }
  18686. }
  18687. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  18688. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  18689. for id := range m.removedstage_messages {
  18690. ids = append(ids, id)
  18691. }
  18692. return
  18693. }
  18694. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  18695. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  18696. for id := range m.stage_messages {
  18697. ids = append(ids, id)
  18698. }
  18699. return
  18700. }
  18701. // ResetStageMessages resets all changes to the "stage_messages" edge.
  18702. func (m *SopStageMutation) ResetStageMessages() {
  18703. m.stage_messages = nil
  18704. m.clearedstage_messages = false
  18705. m.removedstage_messages = nil
  18706. }
  18707. // Where appends a list predicates to the SopStageMutation builder.
  18708. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  18709. m.predicates = append(m.predicates, ps...)
  18710. }
  18711. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  18712. // users can use type-assertion to append predicates that do not depend on any generated package.
  18713. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  18714. p := make([]predicate.SopStage, len(ps))
  18715. for i := range ps {
  18716. p[i] = ps[i]
  18717. }
  18718. m.Where(p...)
  18719. }
  18720. // Op returns the operation name.
  18721. func (m *SopStageMutation) Op() Op {
  18722. return m.op
  18723. }
  18724. // SetOp allows setting the mutation operation.
  18725. func (m *SopStageMutation) SetOp(op Op) {
  18726. m.op = op
  18727. }
  18728. // Type returns the node type of this mutation (SopStage).
  18729. func (m *SopStageMutation) Type() string {
  18730. return m.typ
  18731. }
  18732. // Fields returns all fields that were changed during this mutation. Note that in
  18733. // order to get all numeric fields that were incremented/decremented, call
  18734. // AddedFields().
  18735. func (m *SopStageMutation) Fields() []string {
  18736. fields := make([]string, 0, 14)
  18737. if m.created_at != nil {
  18738. fields = append(fields, sopstage.FieldCreatedAt)
  18739. }
  18740. if m.updated_at != nil {
  18741. fields = append(fields, sopstage.FieldUpdatedAt)
  18742. }
  18743. if m.status != nil {
  18744. fields = append(fields, sopstage.FieldStatus)
  18745. }
  18746. if m.deleted_at != nil {
  18747. fields = append(fields, sopstage.FieldDeletedAt)
  18748. }
  18749. if m.sop_task != nil {
  18750. fields = append(fields, sopstage.FieldTaskID)
  18751. }
  18752. if m.name != nil {
  18753. fields = append(fields, sopstage.FieldName)
  18754. }
  18755. if m.condition_type != nil {
  18756. fields = append(fields, sopstage.FieldConditionType)
  18757. }
  18758. if m.condition_operator != nil {
  18759. fields = append(fields, sopstage.FieldConditionOperator)
  18760. }
  18761. if m.condition_list != nil {
  18762. fields = append(fields, sopstage.FieldConditionList)
  18763. }
  18764. if m.action_message != nil {
  18765. fields = append(fields, sopstage.FieldActionMessage)
  18766. }
  18767. if m.action_label_add != nil {
  18768. fields = append(fields, sopstage.FieldActionLabelAdd)
  18769. }
  18770. if m.action_label_del != nil {
  18771. fields = append(fields, sopstage.FieldActionLabelDel)
  18772. }
  18773. if m.action_forward != nil {
  18774. fields = append(fields, sopstage.FieldActionForward)
  18775. }
  18776. if m.index_sort != nil {
  18777. fields = append(fields, sopstage.FieldIndexSort)
  18778. }
  18779. return fields
  18780. }
  18781. // Field returns the value of a field with the given name. The second boolean
  18782. // return value indicates that this field was not set, or was not defined in the
  18783. // schema.
  18784. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  18785. switch name {
  18786. case sopstage.FieldCreatedAt:
  18787. return m.CreatedAt()
  18788. case sopstage.FieldUpdatedAt:
  18789. return m.UpdatedAt()
  18790. case sopstage.FieldStatus:
  18791. return m.Status()
  18792. case sopstage.FieldDeletedAt:
  18793. return m.DeletedAt()
  18794. case sopstage.FieldTaskID:
  18795. return m.TaskID()
  18796. case sopstage.FieldName:
  18797. return m.Name()
  18798. case sopstage.FieldConditionType:
  18799. return m.ConditionType()
  18800. case sopstage.FieldConditionOperator:
  18801. return m.ConditionOperator()
  18802. case sopstage.FieldConditionList:
  18803. return m.ConditionList()
  18804. case sopstage.FieldActionMessage:
  18805. return m.ActionMessage()
  18806. case sopstage.FieldActionLabelAdd:
  18807. return m.ActionLabelAdd()
  18808. case sopstage.FieldActionLabelDel:
  18809. return m.ActionLabelDel()
  18810. case sopstage.FieldActionForward:
  18811. return m.ActionForward()
  18812. case sopstage.FieldIndexSort:
  18813. return m.IndexSort()
  18814. }
  18815. return nil, false
  18816. }
  18817. // OldField returns the old value of the field from the database. An error is
  18818. // returned if the mutation operation is not UpdateOne, or the query to the
  18819. // database failed.
  18820. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18821. switch name {
  18822. case sopstage.FieldCreatedAt:
  18823. return m.OldCreatedAt(ctx)
  18824. case sopstage.FieldUpdatedAt:
  18825. return m.OldUpdatedAt(ctx)
  18826. case sopstage.FieldStatus:
  18827. return m.OldStatus(ctx)
  18828. case sopstage.FieldDeletedAt:
  18829. return m.OldDeletedAt(ctx)
  18830. case sopstage.FieldTaskID:
  18831. return m.OldTaskID(ctx)
  18832. case sopstage.FieldName:
  18833. return m.OldName(ctx)
  18834. case sopstage.FieldConditionType:
  18835. return m.OldConditionType(ctx)
  18836. case sopstage.FieldConditionOperator:
  18837. return m.OldConditionOperator(ctx)
  18838. case sopstage.FieldConditionList:
  18839. return m.OldConditionList(ctx)
  18840. case sopstage.FieldActionMessage:
  18841. return m.OldActionMessage(ctx)
  18842. case sopstage.FieldActionLabelAdd:
  18843. return m.OldActionLabelAdd(ctx)
  18844. case sopstage.FieldActionLabelDel:
  18845. return m.OldActionLabelDel(ctx)
  18846. case sopstage.FieldActionForward:
  18847. return m.OldActionForward(ctx)
  18848. case sopstage.FieldIndexSort:
  18849. return m.OldIndexSort(ctx)
  18850. }
  18851. return nil, fmt.Errorf("unknown SopStage field %s", name)
  18852. }
  18853. // SetField sets the value of a field with the given name. It returns an error if
  18854. // the field is not defined in the schema, or if the type mismatched the field
  18855. // type.
  18856. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  18857. switch name {
  18858. case sopstage.FieldCreatedAt:
  18859. v, ok := value.(time.Time)
  18860. if !ok {
  18861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18862. }
  18863. m.SetCreatedAt(v)
  18864. return nil
  18865. case sopstage.FieldUpdatedAt:
  18866. v, ok := value.(time.Time)
  18867. if !ok {
  18868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18869. }
  18870. m.SetUpdatedAt(v)
  18871. return nil
  18872. case sopstage.FieldStatus:
  18873. v, ok := value.(uint8)
  18874. if !ok {
  18875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18876. }
  18877. m.SetStatus(v)
  18878. return nil
  18879. case sopstage.FieldDeletedAt:
  18880. v, ok := value.(time.Time)
  18881. if !ok {
  18882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18883. }
  18884. m.SetDeletedAt(v)
  18885. return nil
  18886. case sopstage.FieldTaskID:
  18887. v, ok := value.(uint64)
  18888. if !ok {
  18889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18890. }
  18891. m.SetTaskID(v)
  18892. return nil
  18893. case sopstage.FieldName:
  18894. v, ok := value.(string)
  18895. if !ok {
  18896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18897. }
  18898. m.SetName(v)
  18899. return nil
  18900. case sopstage.FieldConditionType:
  18901. v, ok := value.(int)
  18902. if !ok {
  18903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18904. }
  18905. m.SetConditionType(v)
  18906. return nil
  18907. case sopstage.FieldConditionOperator:
  18908. v, ok := value.(int)
  18909. if !ok {
  18910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18911. }
  18912. m.SetConditionOperator(v)
  18913. return nil
  18914. case sopstage.FieldConditionList:
  18915. v, ok := value.([]custom_types.Condition)
  18916. if !ok {
  18917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18918. }
  18919. m.SetConditionList(v)
  18920. return nil
  18921. case sopstage.FieldActionMessage:
  18922. v, ok := value.([]custom_types.Action)
  18923. if !ok {
  18924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18925. }
  18926. m.SetActionMessage(v)
  18927. return nil
  18928. case sopstage.FieldActionLabelAdd:
  18929. v, ok := value.([]uint64)
  18930. if !ok {
  18931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18932. }
  18933. m.SetActionLabelAdd(v)
  18934. return nil
  18935. case sopstage.FieldActionLabelDel:
  18936. v, ok := value.([]uint64)
  18937. if !ok {
  18938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18939. }
  18940. m.SetActionLabelDel(v)
  18941. return nil
  18942. case sopstage.FieldActionForward:
  18943. v, ok := value.(*custom_types.ActionForward)
  18944. if !ok {
  18945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18946. }
  18947. m.SetActionForward(v)
  18948. return nil
  18949. case sopstage.FieldIndexSort:
  18950. v, ok := value.(int)
  18951. if !ok {
  18952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18953. }
  18954. m.SetIndexSort(v)
  18955. return nil
  18956. }
  18957. return fmt.Errorf("unknown SopStage field %s", name)
  18958. }
  18959. // AddedFields returns all numeric fields that were incremented/decremented during
  18960. // this mutation.
  18961. func (m *SopStageMutation) AddedFields() []string {
  18962. var fields []string
  18963. if m.addstatus != nil {
  18964. fields = append(fields, sopstage.FieldStatus)
  18965. }
  18966. if m.addcondition_type != nil {
  18967. fields = append(fields, sopstage.FieldConditionType)
  18968. }
  18969. if m.addcondition_operator != nil {
  18970. fields = append(fields, sopstage.FieldConditionOperator)
  18971. }
  18972. if m.addindex_sort != nil {
  18973. fields = append(fields, sopstage.FieldIndexSort)
  18974. }
  18975. return fields
  18976. }
  18977. // AddedField returns the numeric value that was incremented/decremented on a field
  18978. // with the given name. The second boolean return value indicates that this field
  18979. // was not set, or was not defined in the schema.
  18980. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  18981. switch name {
  18982. case sopstage.FieldStatus:
  18983. return m.AddedStatus()
  18984. case sopstage.FieldConditionType:
  18985. return m.AddedConditionType()
  18986. case sopstage.FieldConditionOperator:
  18987. return m.AddedConditionOperator()
  18988. case sopstage.FieldIndexSort:
  18989. return m.AddedIndexSort()
  18990. }
  18991. return nil, false
  18992. }
  18993. // AddField adds the value to the field with the given name. It returns an error if
  18994. // the field is not defined in the schema, or if the type mismatched the field
  18995. // type.
  18996. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  18997. switch name {
  18998. case sopstage.FieldStatus:
  18999. v, ok := value.(int8)
  19000. if !ok {
  19001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19002. }
  19003. m.AddStatus(v)
  19004. return nil
  19005. case sopstage.FieldConditionType:
  19006. v, ok := value.(int)
  19007. if !ok {
  19008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19009. }
  19010. m.AddConditionType(v)
  19011. return nil
  19012. case sopstage.FieldConditionOperator:
  19013. v, ok := value.(int)
  19014. if !ok {
  19015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19016. }
  19017. m.AddConditionOperator(v)
  19018. return nil
  19019. case sopstage.FieldIndexSort:
  19020. v, ok := value.(int)
  19021. if !ok {
  19022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19023. }
  19024. m.AddIndexSort(v)
  19025. return nil
  19026. }
  19027. return fmt.Errorf("unknown SopStage numeric field %s", name)
  19028. }
  19029. // ClearedFields returns all nullable fields that were cleared during this
  19030. // mutation.
  19031. func (m *SopStageMutation) ClearedFields() []string {
  19032. var fields []string
  19033. if m.FieldCleared(sopstage.FieldStatus) {
  19034. fields = append(fields, sopstage.FieldStatus)
  19035. }
  19036. if m.FieldCleared(sopstage.FieldDeletedAt) {
  19037. fields = append(fields, sopstage.FieldDeletedAt)
  19038. }
  19039. if m.FieldCleared(sopstage.FieldActionMessage) {
  19040. fields = append(fields, sopstage.FieldActionMessage)
  19041. }
  19042. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  19043. fields = append(fields, sopstage.FieldActionLabelAdd)
  19044. }
  19045. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  19046. fields = append(fields, sopstage.FieldActionLabelDel)
  19047. }
  19048. if m.FieldCleared(sopstage.FieldActionForward) {
  19049. fields = append(fields, sopstage.FieldActionForward)
  19050. }
  19051. if m.FieldCleared(sopstage.FieldIndexSort) {
  19052. fields = append(fields, sopstage.FieldIndexSort)
  19053. }
  19054. return fields
  19055. }
  19056. // FieldCleared returns a boolean indicating if a field with the given name was
  19057. // cleared in this mutation.
  19058. func (m *SopStageMutation) FieldCleared(name string) bool {
  19059. _, ok := m.clearedFields[name]
  19060. return ok
  19061. }
  19062. // ClearField clears the value of the field with the given name. It returns an
  19063. // error if the field is not defined in the schema.
  19064. func (m *SopStageMutation) ClearField(name string) error {
  19065. switch name {
  19066. case sopstage.FieldStatus:
  19067. m.ClearStatus()
  19068. return nil
  19069. case sopstage.FieldDeletedAt:
  19070. m.ClearDeletedAt()
  19071. return nil
  19072. case sopstage.FieldActionMessage:
  19073. m.ClearActionMessage()
  19074. return nil
  19075. case sopstage.FieldActionLabelAdd:
  19076. m.ClearActionLabelAdd()
  19077. return nil
  19078. case sopstage.FieldActionLabelDel:
  19079. m.ClearActionLabelDel()
  19080. return nil
  19081. case sopstage.FieldActionForward:
  19082. m.ClearActionForward()
  19083. return nil
  19084. case sopstage.FieldIndexSort:
  19085. m.ClearIndexSort()
  19086. return nil
  19087. }
  19088. return fmt.Errorf("unknown SopStage nullable field %s", name)
  19089. }
  19090. // ResetField resets all changes in the mutation for the field with the given name.
  19091. // It returns an error if the field is not defined in the schema.
  19092. func (m *SopStageMutation) ResetField(name string) error {
  19093. switch name {
  19094. case sopstage.FieldCreatedAt:
  19095. m.ResetCreatedAt()
  19096. return nil
  19097. case sopstage.FieldUpdatedAt:
  19098. m.ResetUpdatedAt()
  19099. return nil
  19100. case sopstage.FieldStatus:
  19101. m.ResetStatus()
  19102. return nil
  19103. case sopstage.FieldDeletedAt:
  19104. m.ResetDeletedAt()
  19105. return nil
  19106. case sopstage.FieldTaskID:
  19107. m.ResetTaskID()
  19108. return nil
  19109. case sopstage.FieldName:
  19110. m.ResetName()
  19111. return nil
  19112. case sopstage.FieldConditionType:
  19113. m.ResetConditionType()
  19114. return nil
  19115. case sopstage.FieldConditionOperator:
  19116. m.ResetConditionOperator()
  19117. return nil
  19118. case sopstage.FieldConditionList:
  19119. m.ResetConditionList()
  19120. return nil
  19121. case sopstage.FieldActionMessage:
  19122. m.ResetActionMessage()
  19123. return nil
  19124. case sopstage.FieldActionLabelAdd:
  19125. m.ResetActionLabelAdd()
  19126. return nil
  19127. case sopstage.FieldActionLabelDel:
  19128. m.ResetActionLabelDel()
  19129. return nil
  19130. case sopstage.FieldActionForward:
  19131. m.ResetActionForward()
  19132. return nil
  19133. case sopstage.FieldIndexSort:
  19134. m.ResetIndexSort()
  19135. return nil
  19136. }
  19137. return fmt.Errorf("unknown SopStage field %s", name)
  19138. }
  19139. // AddedEdges returns all edge names that were set/added in this mutation.
  19140. func (m *SopStageMutation) AddedEdges() []string {
  19141. edges := make([]string, 0, 3)
  19142. if m.sop_task != nil {
  19143. edges = append(edges, sopstage.EdgeSopTask)
  19144. }
  19145. if m.stage_nodes != nil {
  19146. edges = append(edges, sopstage.EdgeStageNodes)
  19147. }
  19148. if m.stage_messages != nil {
  19149. edges = append(edges, sopstage.EdgeStageMessages)
  19150. }
  19151. return edges
  19152. }
  19153. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19154. // name in this mutation.
  19155. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  19156. switch name {
  19157. case sopstage.EdgeSopTask:
  19158. if id := m.sop_task; id != nil {
  19159. return []ent.Value{*id}
  19160. }
  19161. case sopstage.EdgeStageNodes:
  19162. ids := make([]ent.Value, 0, len(m.stage_nodes))
  19163. for id := range m.stage_nodes {
  19164. ids = append(ids, id)
  19165. }
  19166. return ids
  19167. case sopstage.EdgeStageMessages:
  19168. ids := make([]ent.Value, 0, len(m.stage_messages))
  19169. for id := range m.stage_messages {
  19170. ids = append(ids, id)
  19171. }
  19172. return ids
  19173. }
  19174. return nil
  19175. }
  19176. // RemovedEdges returns all edge names that were removed in this mutation.
  19177. func (m *SopStageMutation) RemovedEdges() []string {
  19178. edges := make([]string, 0, 3)
  19179. if m.removedstage_nodes != nil {
  19180. edges = append(edges, sopstage.EdgeStageNodes)
  19181. }
  19182. if m.removedstage_messages != nil {
  19183. edges = append(edges, sopstage.EdgeStageMessages)
  19184. }
  19185. return edges
  19186. }
  19187. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19188. // the given name in this mutation.
  19189. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  19190. switch name {
  19191. case sopstage.EdgeStageNodes:
  19192. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  19193. for id := range m.removedstage_nodes {
  19194. ids = append(ids, id)
  19195. }
  19196. return ids
  19197. case sopstage.EdgeStageMessages:
  19198. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  19199. for id := range m.removedstage_messages {
  19200. ids = append(ids, id)
  19201. }
  19202. return ids
  19203. }
  19204. return nil
  19205. }
  19206. // ClearedEdges returns all edge names that were cleared in this mutation.
  19207. func (m *SopStageMutation) ClearedEdges() []string {
  19208. edges := make([]string, 0, 3)
  19209. if m.clearedsop_task {
  19210. edges = append(edges, sopstage.EdgeSopTask)
  19211. }
  19212. if m.clearedstage_nodes {
  19213. edges = append(edges, sopstage.EdgeStageNodes)
  19214. }
  19215. if m.clearedstage_messages {
  19216. edges = append(edges, sopstage.EdgeStageMessages)
  19217. }
  19218. return edges
  19219. }
  19220. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19221. // was cleared in this mutation.
  19222. func (m *SopStageMutation) EdgeCleared(name string) bool {
  19223. switch name {
  19224. case sopstage.EdgeSopTask:
  19225. return m.clearedsop_task
  19226. case sopstage.EdgeStageNodes:
  19227. return m.clearedstage_nodes
  19228. case sopstage.EdgeStageMessages:
  19229. return m.clearedstage_messages
  19230. }
  19231. return false
  19232. }
  19233. // ClearEdge clears the value of the edge with the given name. It returns an error
  19234. // if that edge is not defined in the schema.
  19235. func (m *SopStageMutation) ClearEdge(name string) error {
  19236. switch name {
  19237. case sopstage.EdgeSopTask:
  19238. m.ClearSopTask()
  19239. return nil
  19240. }
  19241. return fmt.Errorf("unknown SopStage unique edge %s", name)
  19242. }
  19243. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19244. // It returns an error if the edge is not defined in the schema.
  19245. func (m *SopStageMutation) ResetEdge(name string) error {
  19246. switch name {
  19247. case sopstage.EdgeSopTask:
  19248. m.ResetSopTask()
  19249. return nil
  19250. case sopstage.EdgeStageNodes:
  19251. m.ResetStageNodes()
  19252. return nil
  19253. case sopstage.EdgeStageMessages:
  19254. m.ResetStageMessages()
  19255. return nil
  19256. }
  19257. return fmt.Errorf("unknown SopStage edge %s", name)
  19258. }
  19259. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  19260. type SopTaskMutation struct {
  19261. config
  19262. op Op
  19263. typ string
  19264. id *uint64
  19265. created_at *time.Time
  19266. updated_at *time.Time
  19267. status *uint8
  19268. addstatus *int8
  19269. deleted_at *time.Time
  19270. name *string
  19271. bot_wxid_list *[]string
  19272. appendbot_wxid_list []string
  19273. _type *int
  19274. add_type *int
  19275. plan_start_time *time.Time
  19276. plan_end_time *time.Time
  19277. creator_id *string
  19278. organization_id *uint64
  19279. addorganization_id *int64
  19280. token *[]string
  19281. appendtoken []string
  19282. clearedFields map[string]struct{}
  19283. task_stages map[uint64]struct{}
  19284. removedtask_stages map[uint64]struct{}
  19285. clearedtask_stages bool
  19286. done bool
  19287. oldValue func(context.Context) (*SopTask, error)
  19288. predicates []predicate.SopTask
  19289. }
  19290. var _ ent.Mutation = (*SopTaskMutation)(nil)
  19291. // soptaskOption allows management of the mutation configuration using functional options.
  19292. type soptaskOption func(*SopTaskMutation)
  19293. // newSopTaskMutation creates new mutation for the SopTask entity.
  19294. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  19295. m := &SopTaskMutation{
  19296. config: c,
  19297. op: op,
  19298. typ: TypeSopTask,
  19299. clearedFields: make(map[string]struct{}),
  19300. }
  19301. for _, opt := range opts {
  19302. opt(m)
  19303. }
  19304. return m
  19305. }
  19306. // withSopTaskID sets the ID field of the mutation.
  19307. func withSopTaskID(id uint64) soptaskOption {
  19308. return func(m *SopTaskMutation) {
  19309. var (
  19310. err error
  19311. once sync.Once
  19312. value *SopTask
  19313. )
  19314. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  19315. once.Do(func() {
  19316. if m.done {
  19317. err = errors.New("querying old values post mutation is not allowed")
  19318. } else {
  19319. value, err = m.Client().SopTask.Get(ctx, id)
  19320. }
  19321. })
  19322. return value, err
  19323. }
  19324. m.id = &id
  19325. }
  19326. }
  19327. // withSopTask sets the old SopTask of the mutation.
  19328. func withSopTask(node *SopTask) soptaskOption {
  19329. return func(m *SopTaskMutation) {
  19330. m.oldValue = func(context.Context) (*SopTask, error) {
  19331. return node, nil
  19332. }
  19333. m.id = &node.ID
  19334. }
  19335. }
  19336. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19337. // executed in a transaction (ent.Tx), a transactional client is returned.
  19338. func (m SopTaskMutation) Client() *Client {
  19339. client := &Client{config: m.config}
  19340. client.init()
  19341. return client
  19342. }
  19343. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19344. // it returns an error otherwise.
  19345. func (m SopTaskMutation) Tx() (*Tx, error) {
  19346. if _, ok := m.driver.(*txDriver); !ok {
  19347. return nil, errors.New("ent: mutation is not running in a transaction")
  19348. }
  19349. tx := &Tx{config: m.config}
  19350. tx.init()
  19351. return tx, nil
  19352. }
  19353. // SetID sets the value of the id field. Note that this
  19354. // operation is only accepted on creation of SopTask entities.
  19355. func (m *SopTaskMutation) SetID(id uint64) {
  19356. m.id = &id
  19357. }
  19358. // ID returns the ID value in the mutation. Note that the ID is only available
  19359. // if it was provided to the builder or after it was returned from the database.
  19360. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  19361. if m.id == nil {
  19362. return
  19363. }
  19364. return *m.id, true
  19365. }
  19366. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19367. // That means, if the mutation is applied within a transaction with an isolation level such
  19368. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19369. // or updated by the mutation.
  19370. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  19371. switch {
  19372. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19373. id, exists := m.ID()
  19374. if exists {
  19375. return []uint64{id}, nil
  19376. }
  19377. fallthrough
  19378. case m.op.Is(OpUpdate | OpDelete):
  19379. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  19380. default:
  19381. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19382. }
  19383. }
  19384. // SetCreatedAt sets the "created_at" field.
  19385. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  19386. m.created_at = &t
  19387. }
  19388. // CreatedAt returns the value of the "created_at" field in the mutation.
  19389. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  19390. v := m.created_at
  19391. if v == nil {
  19392. return
  19393. }
  19394. return *v, true
  19395. }
  19396. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  19397. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19399. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19400. if !m.op.Is(OpUpdateOne) {
  19401. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19402. }
  19403. if m.id == nil || m.oldValue == nil {
  19404. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19405. }
  19406. oldValue, err := m.oldValue(ctx)
  19407. if err != nil {
  19408. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19409. }
  19410. return oldValue.CreatedAt, nil
  19411. }
  19412. // ResetCreatedAt resets all changes to the "created_at" field.
  19413. func (m *SopTaskMutation) ResetCreatedAt() {
  19414. m.created_at = nil
  19415. }
  19416. // SetUpdatedAt sets the "updated_at" field.
  19417. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  19418. m.updated_at = &t
  19419. }
  19420. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19421. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  19422. v := m.updated_at
  19423. if v == nil {
  19424. return
  19425. }
  19426. return *v, true
  19427. }
  19428. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  19429. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19431. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19432. if !m.op.Is(OpUpdateOne) {
  19433. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19434. }
  19435. if m.id == nil || m.oldValue == nil {
  19436. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19437. }
  19438. oldValue, err := m.oldValue(ctx)
  19439. if err != nil {
  19440. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19441. }
  19442. return oldValue.UpdatedAt, nil
  19443. }
  19444. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19445. func (m *SopTaskMutation) ResetUpdatedAt() {
  19446. m.updated_at = nil
  19447. }
  19448. // SetStatus sets the "status" field.
  19449. func (m *SopTaskMutation) SetStatus(u uint8) {
  19450. m.status = &u
  19451. m.addstatus = nil
  19452. }
  19453. // Status returns the value of the "status" field in the mutation.
  19454. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  19455. v := m.status
  19456. if v == nil {
  19457. return
  19458. }
  19459. return *v, true
  19460. }
  19461. // OldStatus returns the old "status" field's value of the SopTask entity.
  19462. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19464. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19465. if !m.op.Is(OpUpdateOne) {
  19466. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19467. }
  19468. if m.id == nil || m.oldValue == nil {
  19469. return v, errors.New("OldStatus requires an ID field in the mutation")
  19470. }
  19471. oldValue, err := m.oldValue(ctx)
  19472. if err != nil {
  19473. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19474. }
  19475. return oldValue.Status, nil
  19476. }
  19477. // AddStatus adds u to the "status" field.
  19478. func (m *SopTaskMutation) AddStatus(u int8) {
  19479. if m.addstatus != nil {
  19480. *m.addstatus += u
  19481. } else {
  19482. m.addstatus = &u
  19483. }
  19484. }
  19485. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19486. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  19487. v := m.addstatus
  19488. if v == nil {
  19489. return
  19490. }
  19491. return *v, true
  19492. }
  19493. // ClearStatus clears the value of the "status" field.
  19494. func (m *SopTaskMutation) ClearStatus() {
  19495. m.status = nil
  19496. m.addstatus = nil
  19497. m.clearedFields[soptask.FieldStatus] = struct{}{}
  19498. }
  19499. // StatusCleared returns if the "status" field was cleared in this mutation.
  19500. func (m *SopTaskMutation) StatusCleared() bool {
  19501. _, ok := m.clearedFields[soptask.FieldStatus]
  19502. return ok
  19503. }
  19504. // ResetStatus resets all changes to the "status" field.
  19505. func (m *SopTaskMutation) ResetStatus() {
  19506. m.status = nil
  19507. m.addstatus = nil
  19508. delete(m.clearedFields, soptask.FieldStatus)
  19509. }
  19510. // SetDeletedAt sets the "deleted_at" field.
  19511. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  19512. m.deleted_at = &t
  19513. }
  19514. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19515. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  19516. v := m.deleted_at
  19517. if v == nil {
  19518. return
  19519. }
  19520. return *v, true
  19521. }
  19522. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  19523. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19525. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19526. if !m.op.Is(OpUpdateOne) {
  19527. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19528. }
  19529. if m.id == nil || m.oldValue == nil {
  19530. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19531. }
  19532. oldValue, err := m.oldValue(ctx)
  19533. if err != nil {
  19534. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19535. }
  19536. return oldValue.DeletedAt, nil
  19537. }
  19538. // ClearDeletedAt clears the value of the "deleted_at" field.
  19539. func (m *SopTaskMutation) ClearDeletedAt() {
  19540. m.deleted_at = nil
  19541. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  19542. }
  19543. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19544. func (m *SopTaskMutation) DeletedAtCleared() bool {
  19545. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  19546. return ok
  19547. }
  19548. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19549. func (m *SopTaskMutation) ResetDeletedAt() {
  19550. m.deleted_at = nil
  19551. delete(m.clearedFields, soptask.FieldDeletedAt)
  19552. }
  19553. // SetName sets the "name" field.
  19554. func (m *SopTaskMutation) SetName(s string) {
  19555. m.name = &s
  19556. }
  19557. // Name returns the value of the "name" field in the mutation.
  19558. func (m *SopTaskMutation) Name() (r string, exists bool) {
  19559. v := m.name
  19560. if v == nil {
  19561. return
  19562. }
  19563. return *v, true
  19564. }
  19565. // OldName returns the old "name" field's value of the SopTask entity.
  19566. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19568. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  19569. if !m.op.Is(OpUpdateOne) {
  19570. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19571. }
  19572. if m.id == nil || m.oldValue == nil {
  19573. return v, errors.New("OldName requires an ID field in the mutation")
  19574. }
  19575. oldValue, err := m.oldValue(ctx)
  19576. if err != nil {
  19577. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19578. }
  19579. return oldValue.Name, nil
  19580. }
  19581. // ResetName resets all changes to the "name" field.
  19582. func (m *SopTaskMutation) ResetName() {
  19583. m.name = nil
  19584. }
  19585. // SetBotWxidList sets the "bot_wxid_list" field.
  19586. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  19587. m.bot_wxid_list = &s
  19588. m.appendbot_wxid_list = nil
  19589. }
  19590. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  19591. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  19592. v := m.bot_wxid_list
  19593. if v == nil {
  19594. return
  19595. }
  19596. return *v, true
  19597. }
  19598. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  19599. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19601. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  19602. if !m.op.Is(OpUpdateOne) {
  19603. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  19604. }
  19605. if m.id == nil || m.oldValue == nil {
  19606. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  19607. }
  19608. oldValue, err := m.oldValue(ctx)
  19609. if err != nil {
  19610. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  19611. }
  19612. return oldValue.BotWxidList, nil
  19613. }
  19614. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  19615. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  19616. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  19617. }
  19618. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  19619. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  19620. if len(m.appendbot_wxid_list) == 0 {
  19621. return nil, false
  19622. }
  19623. return m.appendbot_wxid_list, true
  19624. }
  19625. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  19626. func (m *SopTaskMutation) ClearBotWxidList() {
  19627. m.bot_wxid_list = nil
  19628. m.appendbot_wxid_list = nil
  19629. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  19630. }
  19631. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  19632. func (m *SopTaskMutation) BotWxidListCleared() bool {
  19633. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  19634. return ok
  19635. }
  19636. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  19637. func (m *SopTaskMutation) ResetBotWxidList() {
  19638. m.bot_wxid_list = nil
  19639. m.appendbot_wxid_list = nil
  19640. delete(m.clearedFields, soptask.FieldBotWxidList)
  19641. }
  19642. // SetType sets the "type" field.
  19643. func (m *SopTaskMutation) SetType(i int) {
  19644. m._type = &i
  19645. m.add_type = nil
  19646. }
  19647. // GetType returns the value of the "type" field in the mutation.
  19648. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  19649. v := m._type
  19650. if v == nil {
  19651. return
  19652. }
  19653. return *v, true
  19654. }
  19655. // OldType returns the old "type" field's value of the SopTask entity.
  19656. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19658. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  19659. if !m.op.Is(OpUpdateOne) {
  19660. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19661. }
  19662. if m.id == nil || m.oldValue == nil {
  19663. return v, errors.New("OldType requires an ID field in the mutation")
  19664. }
  19665. oldValue, err := m.oldValue(ctx)
  19666. if err != nil {
  19667. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19668. }
  19669. return oldValue.Type, nil
  19670. }
  19671. // AddType adds i to the "type" field.
  19672. func (m *SopTaskMutation) AddType(i int) {
  19673. if m.add_type != nil {
  19674. *m.add_type += i
  19675. } else {
  19676. m.add_type = &i
  19677. }
  19678. }
  19679. // AddedType returns the value that was added to the "type" field in this mutation.
  19680. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  19681. v := m.add_type
  19682. if v == nil {
  19683. return
  19684. }
  19685. return *v, true
  19686. }
  19687. // ResetType resets all changes to the "type" field.
  19688. func (m *SopTaskMutation) ResetType() {
  19689. m._type = nil
  19690. m.add_type = nil
  19691. }
  19692. // SetPlanStartTime sets the "plan_start_time" field.
  19693. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  19694. m.plan_start_time = &t
  19695. }
  19696. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  19697. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  19698. v := m.plan_start_time
  19699. if v == nil {
  19700. return
  19701. }
  19702. return *v, true
  19703. }
  19704. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  19705. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19707. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  19708. if !m.op.Is(OpUpdateOne) {
  19709. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  19710. }
  19711. if m.id == nil || m.oldValue == nil {
  19712. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  19713. }
  19714. oldValue, err := m.oldValue(ctx)
  19715. if err != nil {
  19716. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  19717. }
  19718. return oldValue.PlanStartTime, nil
  19719. }
  19720. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  19721. func (m *SopTaskMutation) ClearPlanStartTime() {
  19722. m.plan_start_time = nil
  19723. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  19724. }
  19725. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  19726. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  19727. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  19728. return ok
  19729. }
  19730. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  19731. func (m *SopTaskMutation) ResetPlanStartTime() {
  19732. m.plan_start_time = nil
  19733. delete(m.clearedFields, soptask.FieldPlanStartTime)
  19734. }
  19735. // SetPlanEndTime sets the "plan_end_time" field.
  19736. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  19737. m.plan_end_time = &t
  19738. }
  19739. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  19740. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  19741. v := m.plan_end_time
  19742. if v == nil {
  19743. return
  19744. }
  19745. return *v, true
  19746. }
  19747. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  19748. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19750. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  19751. if !m.op.Is(OpUpdateOne) {
  19752. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  19753. }
  19754. if m.id == nil || m.oldValue == nil {
  19755. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  19756. }
  19757. oldValue, err := m.oldValue(ctx)
  19758. if err != nil {
  19759. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  19760. }
  19761. return oldValue.PlanEndTime, nil
  19762. }
  19763. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  19764. func (m *SopTaskMutation) ClearPlanEndTime() {
  19765. m.plan_end_time = nil
  19766. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  19767. }
  19768. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  19769. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  19770. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  19771. return ok
  19772. }
  19773. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  19774. func (m *SopTaskMutation) ResetPlanEndTime() {
  19775. m.plan_end_time = nil
  19776. delete(m.clearedFields, soptask.FieldPlanEndTime)
  19777. }
  19778. // SetCreatorID sets the "creator_id" field.
  19779. func (m *SopTaskMutation) SetCreatorID(s string) {
  19780. m.creator_id = &s
  19781. }
  19782. // CreatorID returns the value of the "creator_id" field in the mutation.
  19783. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  19784. v := m.creator_id
  19785. if v == nil {
  19786. return
  19787. }
  19788. return *v, true
  19789. }
  19790. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  19791. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19793. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  19794. if !m.op.Is(OpUpdateOne) {
  19795. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  19796. }
  19797. if m.id == nil || m.oldValue == nil {
  19798. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  19799. }
  19800. oldValue, err := m.oldValue(ctx)
  19801. if err != nil {
  19802. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  19803. }
  19804. return oldValue.CreatorID, nil
  19805. }
  19806. // ClearCreatorID clears the value of the "creator_id" field.
  19807. func (m *SopTaskMutation) ClearCreatorID() {
  19808. m.creator_id = nil
  19809. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  19810. }
  19811. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  19812. func (m *SopTaskMutation) CreatorIDCleared() bool {
  19813. _, ok := m.clearedFields[soptask.FieldCreatorID]
  19814. return ok
  19815. }
  19816. // ResetCreatorID resets all changes to the "creator_id" field.
  19817. func (m *SopTaskMutation) ResetCreatorID() {
  19818. m.creator_id = nil
  19819. delete(m.clearedFields, soptask.FieldCreatorID)
  19820. }
  19821. // SetOrganizationID sets the "organization_id" field.
  19822. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  19823. m.organization_id = &u
  19824. m.addorganization_id = nil
  19825. }
  19826. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19827. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  19828. v := m.organization_id
  19829. if v == nil {
  19830. return
  19831. }
  19832. return *v, true
  19833. }
  19834. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  19835. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19837. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19838. if !m.op.Is(OpUpdateOne) {
  19839. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19840. }
  19841. if m.id == nil || m.oldValue == nil {
  19842. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19843. }
  19844. oldValue, err := m.oldValue(ctx)
  19845. if err != nil {
  19846. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19847. }
  19848. return oldValue.OrganizationID, nil
  19849. }
  19850. // AddOrganizationID adds u to the "organization_id" field.
  19851. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  19852. if m.addorganization_id != nil {
  19853. *m.addorganization_id += u
  19854. } else {
  19855. m.addorganization_id = &u
  19856. }
  19857. }
  19858. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19859. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  19860. v := m.addorganization_id
  19861. if v == nil {
  19862. return
  19863. }
  19864. return *v, true
  19865. }
  19866. // ClearOrganizationID clears the value of the "organization_id" field.
  19867. func (m *SopTaskMutation) ClearOrganizationID() {
  19868. m.organization_id = nil
  19869. m.addorganization_id = nil
  19870. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  19871. }
  19872. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19873. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  19874. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  19875. return ok
  19876. }
  19877. // ResetOrganizationID resets all changes to the "organization_id" field.
  19878. func (m *SopTaskMutation) ResetOrganizationID() {
  19879. m.organization_id = nil
  19880. m.addorganization_id = nil
  19881. delete(m.clearedFields, soptask.FieldOrganizationID)
  19882. }
  19883. // SetToken sets the "token" field.
  19884. func (m *SopTaskMutation) SetToken(s []string) {
  19885. m.token = &s
  19886. m.appendtoken = nil
  19887. }
  19888. // Token returns the value of the "token" field in the mutation.
  19889. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  19890. v := m.token
  19891. if v == nil {
  19892. return
  19893. }
  19894. return *v, true
  19895. }
  19896. // OldToken returns the old "token" field's value of the SopTask entity.
  19897. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19899. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  19900. if !m.op.Is(OpUpdateOne) {
  19901. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  19902. }
  19903. if m.id == nil || m.oldValue == nil {
  19904. return v, errors.New("OldToken requires an ID field in the mutation")
  19905. }
  19906. oldValue, err := m.oldValue(ctx)
  19907. if err != nil {
  19908. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  19909. }
  19910. return oldValue.Token, nil
  19911. }
  19912. // AppendToken adds s to the "token" field.
  19913. func (m *SopTaskMutation) AppendToken(s []string) {
  19914. m.appendtoken = append(m.appendtoken, s...)
  19915. }
  19916. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  19917. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  19918. if len(m.appendtoken) == 0 {
  19919. return nil, false
  19920. }
  19921. return m.appendtoken, true
  19922. }
  19923. // ClearToken clears the value of the "token" field.
  19924. func (m *SopTaskMutation) ClearToken() {
  19925. m.token = nil
  19926. m.appendtoken = nil
  19927. m.clearedFields[soptask.FieldToken] = struct{}{}
  19928. }
  19929. // TokenCleared returns if the "token" field was cleared in this mutation.
  19930. func (m *SopTaskMutation) TokenCleared() bool {
  19931. _, ok := m.clearedFields[soptask.FieldToken]
  19932. return ok
  19933. }
  19934. // ResetToken resets all changes to the "token" field.
  19935. func (m *SopTaskMutation) ResetToken() {
  19936. m.token = nil
  19937. m.appendtoken = nil
  19938. delete(m.clearedFields, soptask.FieldToken)
  19939. }
  19940. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  19941. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  19942. if m.task_stages == nil {
  19943. m.task_stages = make(map[uint64]struct{})
  19944. }
  19945. for i := range ids {
  19946. m.task_stages[ids[i]] = struct{}{}
  19947. }
  19948. }
  19949. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  19950. func (m *SopTaskMutation) ClearTaskStages() {
  19951. m.clearedtask_stages = true
  19952. }
  19953. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  19954. func (m *SopTaskMutation) TaskStagesCleared() bool {
  19955. return m.clearedtask_stages
  19956. }
  19957. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  19958. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  19959. if m.removedtask_stages == nil {
  19960. m.removedtask_stages = make(map[uint64]struct{})
  19961. }
  19962. for i := range ids {
  19963. delete(m.task_stages, ids[i])
  19964. m.removedtask_stages[ids[i]] = struct{}{}
  19965. }
  19966. }
  19967. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  19968. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  19969. for id := range m.removedtask_stages {
  19970. ids = append(ids, id)
  19971. }
  19972. return
  19973. }
  19974. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  19975. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  19976. for id := range m.task_stages {
  19977. ids = append(ids, id)
  19978. }
  19979. return
  19980. }
  19981. // ResetTaskStages resets all changes to the "task_stages" edge.
  19982. func (m *SopTaskMutation) ResetTaskStages() {
  19983. m.task_stages = nil
  19984. m.clearedtask_stages = false
  19985. m.removedtask_stages = nil
  19986. }
  19987. // Where appends a list predicates to the SopTaskMutation builder.
  19988. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  19989. m.predicates = append(m.predicates, ps...)
  19990. }
  19991. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  19992. // users can use type-assertion to append predicates that do not depend on any generated package.
  19993. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  19994. p := make([]predicate.SopTask, len(ps))
  19995. for i := range ps {
  19996. p[i] = ps[i]
  19997. }
  19998. m.Where(p...)
  19999. }
  20000. // Op returns the operation name.
  20001. func (m *SopTaskMutation) Op() Op {
  20002. return m.op
  20003. }
  20004. // SetOp allows setting the mutation operation.
  20005. func (m *SopTaskMutation) SetOp(op Op) {
  20006. m.op = op
  20007. }
  20008. // Type returns the node type of this mutation (SopTask).
  20009. func (m *SopTaskMutation) Type() string {
  20010. return m.typ
  20011. }
  20012. // Fields returns all fields that were changed during this mutation. Note that in
  20013. // order to get all numeric fields that were incremented/decremented, call
  20014. // AddedFields().
  20015. func (m *SopTaskMutation) Fields() []string {
  20016. fields := make([]string, 0, 12)
  20017. if m.created_at != nil {
  20018. fields = append(fields, soptask.FieldCreatedAt)
  20019. }
  20020. if m.updated_at != nil {
  20021. fields = append(fields, soptask.FieldUpdatedAt)
  20022. }
  20023. if m.status != nil {
  20024. fields = append(fields, soptask.FieldStatus)
  20025. }
  20026. if m.deleted_at != nil {
  20027. fields = append(fields, soptask.FieldDeletedAt)
  20028. }
  20029. if m.name != nil {
  20030. fields = append(fields, soptask.FieldName)
  20031. }
  20032. if m.bot_wxid_list != nil {
  20033. fields = append(fields, soptask.FieldBotWxidList)
  20034. }
  20035. if m._type != nil {
  20036. fields = append(fields, soptask.FieldType)
  20037. }
  20038. if m.plan_start_time != nil {
  20039. fields = append(fields, soptask.FieldPlanStartTime)
  20040. }
  20041. if m.plan_end_time != nil {
  20042. fields = append(fields, soptask.FieldPlanEndTime)
  20043. }
  20044. if m.creator_id != nil {
  20045. fields = append(fields, soptask.FieldCreatorID)
  20046. }
  20047. if m.organization_id != nil {
  20048. fields = append(fields, soptask.FieldOrganizationID)
  20049. }
  20050. if m.token != nil {
  20051. fields = append(fields, soptask.FieldToken)
  20052. }
  20053. return fields
  20054. }
  20055. // Field returns the value of a field with the given name. The second boolean
  20056. // return value indicates that this field was not set, or was not defined in the
  20057. // schema.
  20058. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  20059. switch name {
  20060. case soptask.FieldCreatedAt:
  20061. return m.CreatedAt()
  20062. case soptask.FieldUpdatedAt:
  20063. return m.UpdatedAt()
  20064. case soptask.FieldStatus:
  20065. return m.Status()
  20066. case soptask.FieldDeletedAt:
  20067. return m.DeletedAt()
  20068. case soptask.FieldName:
  20069. return m.Name()
  20070. case soptask.FieldBotWxidList:
  20071. return m.BotWxidList()
  20072. case soptask.FieldType:
  20073. return m.GetType()
  20074. case soptask.FieldPlanStartTime:
  20075. return m.PlanStartTime()
  20076. case soptask.FieldPlanEndTime:
  20077. return m.PlanEndTime()
  20078. case soptask.FieldCreatorID:
  20079. return m.CreatorID()
  20080. case soptask.FieldOrganizationID:
  20081. return m.OrganizationID()
  20082. case soptask.FieldToken:
  20083. return m.Token()
  20084. }
  20085. return nil, false
  20086. }
  20087. // OldField returns the old value of the field from the database. An error is
  20088. // returned if the mutation operation is not UpdateOne, or the query to the
  20089. // database failed.
  20090. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20091. switch name {
  20092. case soptask.FieldCreatedAt:
  20093. return m.OldCreatedAt(ctx)
  20094. case soptask.FieldUpdatedAt:
  20095. return m.OldUpdatedAt(ctx)
  20096. case soptask.FieldStatus:
  20097. return m.OldStatus(ctx)
  20098. case soptask.FieldDeletedAt:
  20099. return m.OldDeletedAt(ctx)
  20100. case soptask.FieldName:
  20101. return m.OldName(ctx)
  20102. case soptask.FieldBotWxidList:
  20103. return m.OldBotWxidList(ctx)
  20104. case soptask.FieldType:
  20105. return m.OldType(ctx)
  20106. case soptask.FieldPlanStartTime:
  20107. return m.OldPlanStartTime(ctx)
  20108. case soptask.FieldPlanEndTime:
  20109. return m.OldPlanEndTime(ctx)
  20110. case soptask.FieldCreatorID:
  20111. return m.OldCreatorID(ctx)
  20112. case soptask.FieldOrganizationID:
  20113. return m.OldOrganizationID(ctx)
  20114. case soptask.FieldToken:
  20115. return m.OldToken(ctx)
  20116. }
  20117. return nil, fmt.Errorf("unknown SopTask field %s", name)
  20118. }
  20119. // SetField sets the value of a field with the given name. It returns an error if
  20120. // the field is not defined in the schema, or if the type mismatched the field
  20121. // type.
  20122. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  20123. switch name {
  20124. case soptask.FieldCreatedAt:
  20125. v, ok := value.(time.Time)
  20126. if !ok {
  20127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20128. }
  20129. m.SetCreatedAt(v)
  20130. return nil
  20131. case soptask.FieldUpdatedAt:
  20132. v, ok := value.(time.Time)
  20133. if !ok {
  20134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20135. }
  20136. m.SetUpdatedAt(v)
  20137. return nil
  20138. case soptask.FieldStatus:
  20139. v, ok := value.(uint8)
  20140. if !ok {
  20141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20142. }
  20143. m.SetStatus(v)
  20144. return nil
  20145. case soptask.FieldDeletedAt:
  20146. v, ok := value.(time.Time)
  20147. if !ok {
  20148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20149. }
  20150. m.SetDeletedAt(v)
  20151. return nil
  20152. case soptask.FieldName:
  20153. v, ok := value.(string)
  20154. if !ok {
  20155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20156. }
  20157. m.SetName(v)
  20158. return nil
  20159. case soptask.FieldBotWxidList:
  20160. v, ok := value.([]string)
  20161. if !ok {
  20162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20163. }
  20164. m.SetBotWxidList(v)
  20165. return nil
  20166. case soptask.FieldType:
  20167. v, ok := value.(int)
  20168. if !ok {
  20169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20170. }
  20171. m.SetType(v)
  20172. return nil
  20173. case soptask.FieldPlanStartTime:
  20174. v, ok := value.(time.Time)
  20175. if !ok {
  20176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20177. }
  20178. m.SetPlanStartTime(v)
  20179. return nil
  20180. case soptask.FieldPlanEndTime:
  20181. v, ok := value.(time.Time)
  20182. if !ok {
  20183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20184. }
  20185. m.SetPlanEndTime(v)
  20186. return nil
  20187. case soptask.FieldCreatorID:
  20188. v, ok := value.(string)
  20189. if !ok {
  20190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20191. }
  20192. m.SetCreatorID(v)
  20193. return nil
  20194. case soptask.FieldOrganizationID:
  20195. v, ok := value.(uint64)
  20196. if !ok {
  20197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20198. }
  20199. m.SetOrganizationID(v)
  20200. return nil
  20201. case soptask.FieldToken:
  20202. v, ok := value.([]string)
  20203. if !ok {
  20204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20205. }
  20206. m.SetToken(v)
  20207. return nil
  20208. }
  20209. return fmt.Errorf("unknown SopTask field %s", name)
  20210. }
  20211. // AddedFields returns all numeric fields that were incremented/decremented during
  20212. // this mutation.
  20213. func (m *SopTaskMutation) AddedFields() []string {
  20214. var fields []string
  20215. if m.addstatus != nil {
  20216. fields = append(fields, soptask.FieldStatus)
  20217. }
  20218. if m.add_type != nil {
  20219. fields = append(fields, soptask.FieldType)
  20220. }
  20221. if m.addorganization_id != nil {
  20222. fields = append(fields, soptask.FieldOrganizationID)
  20223. }
  20224. return fields
  20225. }
  20226. // AddedField returns the numeric value that was incremented/decremented on a field
  20227. // with the given name. The second boolean return value indicates that this field
  20228. // was not set, or was not defined in the schema.
  20229. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  20230. switch name {
  20231. case soptask.FieldStatus:
  20232. return m.AddedStatus()
  20233. case soptask.FieldType:
  20234. return m.AddedType()
  20235. case soptask.FieldOrganizationID:
  20236. return m.AddedOrganizationID()
  20237. }
  20238. return nil, false
  20239. }
  20240. // AddField adds the value to the field with the given name. It returns an error if
  20241. // the field is not defined in the schema, or if the type mismatched the field
  20242. // type.
  20243. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  20244. switch name {
  20245. case soptask.FieldStatus:
  20246. v, ok := value.(int8)
  20247. if !ok {
  20248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20249. }
  20250. m.AddStatus(v)
  20251. return nil
  20252. case soptask.FieldType:
  20253. v, ok := value.(int)
  20254. if !ok {
  20255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20256. }
  20257. m.AddType(v)
  20258. return nil
  20259. case soptask.FieldOrganizationID:
  20260. v, ok := value.(int64)
  20261. if !ok {
  20262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20263. }
  20264. m.AddOrganizationID(v)
  20265. return nil
  20266. }
  20267. return fmt.Errorf("unknown SopTask numeric field %s", name)
  20268. }
  20269. // ClearedFields returns all nullable fields that were cleared during this
  20270. // mutation.
  20271. func (m *SopTaskMutation) ClearedFields() []string {
  20272. var fields []string
  20273. if m.FieldCleared(soptask.FieldStatus) {
  20274. fields = append(fields, soptask.FieldStatus)
  20275. }
  20276. if m.FieldCleared(soptask.FieldDeletedAt) {
  20277. fields = append(fields, soptask.FieldDeletedAt)
  20278. }
  20279. if m.FieldCleared(soptask.FieldBotWxidList) {
  20280. fields = append(fields, soptask.FieldBotWxidList)
  20281. }
  20282. if m.FieldCleared(soptask.FieldPlanStartTime) {
  20283. fields = append(fields, soptask.FieldPlanStartTime)
  20284. }
  20285. if m.FieldCleared(soptask.FieldPlanEndTime) {
  20286. fields = append(fields, soptask.FieldPlanEndTime)
  20287. }
  20288. if m.FieldCleared(soptask.FieldCreatorID) {
  20289. fields = append(fields, soptask.FieldCreatorID)
  20290. }
  20291. if m.FieldCleared(soptask.FieldOrganizationID) {
  20292. fields = append(fields, soptask.FieldOrganizationID)
  20293. }
  20294. if m.FieldCleared(soptask.FieldToken) {
  20295. fields = append(fields, soptask.FieldToken)
  20296. }
  20297. return fields
  20298. }
  20299. // FieldCleared returns a boolean indicating if a field with the given name was
  20300. // cleared in this mutation.
  20301. func (m *SopTaskMutation) FieldCleared(name string) bool {
  20302. _, ok := m.clearedFields[name]
  20303. return ok
  20304. }
  20305. // ClearField clears the value of the field with the given name. It returns an
  20306. // error if the field is not defined in the schema.
  20307. func (m *SopTaskMutation) ClearField(name string) error {
  20308. switch name {
  20309. case soptask.FieldStatus:
  20310. m.ClearStatus()
  20311. return nil
  20312. case soptask.FieldDeletedAt:
  20313. m.ClearDeletedAt()
  20314. return nil
  20315. case soptask.FieldBotWxidList:
  20316. m.ClearBotWxidList()
  20317. return nil
  20318. case soptask.FieldPlanStartTime:
  20319. m.ClearPlanStartTime()
  20320. return nil
  20321. case soptask.FieldPlanEndTime:
  20322. m.ClearPlanEndTime()
  20323. return nil
  20324. case soptask.FieldCreatorID:
  20325. m.ClearCreatorID()
  20326. return nil
  20327. case soptask.FieldOrganizationID:
  20328. m.ClearOrganizationID()
  20329. return nil
  20330. case soptask.FieldToken:
  20331. m.ClearToken()
  20332. return nil
  20333. }
  20334. return fmt.Errorf("unknown SopTask nullable field %s", name)
  20335. }
  20336. // ResetField resets all changes in the mutation for the field with the given name.
  20337. // It returns an error if the field is not defined in the schema.
  20338. func (m *SopTaskMutation) ResetField(name string) error {
  20339. switch name {
  20340. case soptask.FieldCreatedAt:
  20341. m.ResetCreatedAt()
  20342. return nil
  20343. case soptask.FieldUpdatedAt:
  20344. m.ResetUpdatedAt()
  20345. return nil
  20346. case soptask.FieldStatus:
  20347. m.ResetStatus()
  20348. return nil
  20349. case soptask.FieldDeletedAt:
  20350. m.ResetDeletedAt()
  20351. return nil
  20352. case soptask.FieldName:
  20353. m.ResetName()
  20354. return nil
  20355. case soptask.FieldBotWxidList:
  20356. m.ResetBotWxidList()
  20357. return nil
  20358. case soptask.FieldType:
  20359. m.ResetType()
  20360. return nil
  20361. case soptask.FieldPlanStartTime:
  20362. m.ResetPlanStartTime()
  20363. return nil
  20364. case soptask.FieldPlanEndTime:
  20365. m.ResetPlanEndTime()
  20366. return nil
  20367. case soptask.FieldCreatorID:
  20368. m.ResetCreatorID()
  20369. return nil
  20370. case soptask.FieldOrganizationID:
  20371. m.ResetOrganizationID()
  20372. return nil
  20373. case soptask.FieldToken:
  20374. m.ResetToken()
  20375. return nil
  20376. }
  20377. return fmt.Errorf("unknown SopTask field %s", name)
  20378. }
  20379. // AddedEdges returns all edge names that were set/added in this mutation.
  20380. func (m *SopTaskMutation) AddedEdges() []string {
  20381. edges := make([]string, 0, 1)
  20382. if m.task_stages != nil {
  20383. edges = append(edges, soptask.EdgeTaskStages)
  20384. }
  20385. return edges
  20386. }
  20387. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20388. // name in this mutation.
  20389. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  20390. switch name {
  20391. case soptask.EdgeTaskStages:
  20392. ids := make([]ent.Value, 0, len(m.task_stages))
  20393. for id := range m.task_stages {
  20394. ids = append(ids, id)
  20395. }
  20396. return ids
  20397. }
  20398. return nil
  20399. }
  20400. // RemovedEdges returns all edge names that were removed in this mutation.
  20401. func (m *SopTaskMutation) RemovedEdges() []string {
  20402. edges := make([]string, 0, 1)
  20403. if m.removedtask_stages != nil {
  20404. edges = append(edges, soptask.EdgeTaskStages)
  20405. }
  20406. return edges
  20407. }
  20408. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20409. // the given name in this mutation.
  20410. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  20411. switch name {
  20412. case soptask.EdgeTaskStages:
  20413. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  20414. for id := range m.removedtask_stages {
  20415. ids = append(ids, id)
  20416. }
  20417. return ids
  20418. }
  20419. return nil
  20420. }
  20421. // ClearedEdges returns all edge names that were cleared in this mutation.
  20422. func (m *SopTaskMutation) ClearedEdges() []string {
  20423. edges := make([]string, 0, 1)
  20424. if m.clearedtask_stages {
  20425. edges = append(edges, soptask.EdgeTaskStages)
  20426. }
  20427. return edges
  20428. }
  20429. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20430. // was cleared in this mutation.
  20431. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  20432. switch name {
  20433. case soptask.EdgeTaskStages:
  20434. return m.clearedtask_stages
  20435. }
  20436. return false
  20437. }
  20438. // ClearEdge clears the value of the edge with the given name. It returns an error
  20439. // if that edge is not defined in the schema.
  20440. func (m *SopTaskMutation) ClearEdge(name string) error {
  20441. switch name {
  20442. }
  20443. return fmt.Errorf("unknown SopTask unique edge %s", name)
  20444. }
  20445. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20446. // It returns an error if the edge is not defined in the schema.
  20447. func (m *SopTaskMutation) ResetEdge(name string) error {
  20448. switch name {
  20449. case soptask.EdgeTaskStages:
  20450. m.ResetTaskStages()
  20451. return nil
  20452. }
  20453. return fmt.Errorf("unknown SopTask edge %s", name)
  20454. }
  20455. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  20456. type TokenMutation struct {
  20457. config
  20458. op Op
  20459. typ string
  20460. id *uint64
  20461. created_at *time.Time
  20462. updated_at *time.Time
  20463. deleted_at *time.Time
  20464. expire_at *time.Time
  20465. token *string
  20466. mac *string
  20467. organization_id *uint64
  20468. addorganization_id *int64
  20469. custom_agent_base *string
  20470. custom_agent_key *string
  20471. openai_base *string
  20472. openai_key *string
  20473. clearedFields map[string]struct{}
  20474. agent *uint64
  20475. clearedagent bool
  20476. done bool
  20477. oldValue func(context.Context) (*Token, error)
  20478. predicates []predicate.Token
  20479. }
  20480. var _ ent.Mutation = (*TokenMutation)(nil)
  20481. // tokenOption allows management of the mutation configuration using functional options.
  20482. type tokenOption func(*TokenMutation)
  20483. // newTokenMutation creates new mutation for the Token entity.
  20484. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  20485. m := &TokenMutation{
  20486. config: c,
  20487. op: op,
  20488. typ: TypeToken,
  20489. clearedFields: make(map[string]struct{}),
  20490. }
  20491. for _, opt := range opts {
  20492. opt(m)
  20493. }
  20494. return m
  20495. }
  20496. // withTokenID sets the ID field of the mutation.
  20497. func withTokenID(id uint64) tokenOption {
  20498. return func(m *TokenMutation) {
  20499. var (
  20500. err error
  20501. once sync.Once
  20502. value *Token
  20503. )
  20504. m.oldValue = func(ctx context.Context) (*Token, error) {
  20505. once.Do(func() {
  20506. if m.done {
  20507. err = errors.New("querying old values post mutation is not allowed")
  20508. } else {
  20509. value, err = m.Client().Token.Get(ctx, id)
  20510. }
  20511. })
  20512. return value, err
  20513. }
  20514. m.id = &id
  20515. }
  20516. }
  20517. // withToken sets the old Token of the mutation.
  20518. func withToken(node *Token) tokenOption {
  20519. return func(m *TokenMutation) {
  20520. m.oldValue = func(context.Context) (*Token, error) {
  20521. return node, nil
  20522. }
  20523. m.id = &node.ID
  20524. }
  20525. }
  20526. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20527. // executed in a transaction (ent.Tx), a transactional client is returned.
  20528. func (m TokenMutation) Client() *Client {
  20529. client := &Client{config: m.config}
  20530. client.init()
  20531. return client
  20532. }
  20533. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20534. // it returns an error otherwise.
  20535. func (m TokenMutation) Tx() (*Tx, error) {
  20536. if _, ok := m.driver.(*txDriver); !ok {
  20537. return nil, errors.New("ent: mutation is not running in a transaction")
  20538. }
  20539. tx := &Tx{config: m.config}
  20540. tx.init()
  20541. return tx, nil
  20542. }
  20543. // SetID sets the value of the id field. Note that this
  20544. // operation is only accepted on creation of Token entities.
  20545. func (m *TokenMutation) SetID(id uint64) {
  20546. m.id = &id
  20547. }
  20548. // ID returns the ID value in the mutation. Note that the ID is only available
  20549. // if it was provided to the builder or after it was returned from the database.
  20550. func (m *TokenMutation) ID() (id uint64, exists bool) {
  20551. if m.id == nil {
  20552. return
  20553. }
  20554. return *m.id, true
  20555. }
  20556. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20557. // That means, if the mutation is applied within a transaction with an isolation level such
  20558. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20559. // or updated by the mutation.
  20560. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  20561. switch {
  20562. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20563. id, exists := m.ID()
  20564. if exists {
  20565. return []uint64{id}, nil
  20566. }
  20567. fallthrough
  20568. case m.op.Is(OpUpdate | OpDelete):
  20569. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  20570. default:
  20571. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20572. }
  20573. }
  20574. // SetCreatedAt sets the "created_at" field.
  20575. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  20576. m.created_at = &t
  20577. }
  20578. // CreatedAt returns the value of the "created_at" field in the mutation.
  20579. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  20580. v := m.created_at
  20581. if v == nil {
  20582. return
  20583. }
  20584. return *v, true
  20585. }
  20586. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  20587. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20589. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20590. if !m.op.Is(OpUpdateOne) {
  20591. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20592. }
  20593. if m.id == nil || m.oldValue == nil {
  20594. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20595. }
  20596. oldValue, err := m.oldValue(ctx)
  20597. if err != nil {
  20598. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20599. }
  20600. return oldValue.CreatedAt, nil
  20601. }
  20602. // ResetCreatedAt resets all changes to the "created_at" field.
  20603. func (m *TokenMutation) ResetCreatedAt() {
  20604. m.created_at = nil
  20605. }
  20606. // SetUpdatedAt sets the "updated_at" field.
  20607. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  20608. m.updated_at = &t
  20609. }
  20610. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20611. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  20612. v := m.updated_at
  20613. if v == nil {
  20614. return
  20615. }
  20616. return *v, true
  20617. }
  20618. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  20619. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20621. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20622. if !m.op.Is(OpUpdateOne) {
  20623. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20624. }
  20625. if m.id == nil || m.oldValue == nil {
  20626. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20627. }
  20628. oldValue, err := m.oldValue(ctx)
  20629. if err != nil {
  20630. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20631. }
  20632. return oldValue.UpdatedAt, nil
  20633. }
  20634. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20635. func (m *TokenMutation) ResetUpdatedAt() {
  20636. m.updated_at = nil
  20637. }
  20638. // SetDeletedAt sets the "deleted_at" field.
  20639. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  20640. m.deleted_at = &t
  20641. }
  20642. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20643. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  20644. v := m.deleted_at
  20645. if v == nil {
  20646. return
  20647. }
  20648. return *v, true
  20649. }
  20650. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  20651. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20653. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20654. if !m.op.Is(OpUpdateOne) {
  20655. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20656. }
  20657. if m.id == nil || m.oldValue == nil {
  20658. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20659. }
  20660. oldValue, err := m.oldValue(ctx)
  20661. if err != nil {
  20662. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20663. }
  20664. return oldValue.DeletedAt, nil
  20665. }
  20666. // ClearDeletedAt clears the value of the "deleted_at" field.
  20667. func (m *TokenMutation) ClearDeletedAt() {
  20668. m.deleted_at = nil
  20669. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  20670. }
  20671. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20672. func (m *TokenMutation) DeletedAtCleared() bool {
  20673. _, ok := m.clearedFields[token.FieldDeletedAt]
  20674. return ok
  20675. }
  20676. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20677. func (m *TokenMutation) ResetDeletedAt() {
  20678. m.deleted_at = nil
  20679. delete(m.clearedFields, token.FieldDeletedAt)
  20680. }
  20681. // SetExpireAt sets the "expire_at" field.
  20682. func (m *TokenMutation) SetExpireAt(t time.Time) {
  20683. m.expire_at = &t
  20684. }
  20685. // ExpireAt returns the value of the "expire_at" field in the mutation.
  20686. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  20687. v := m.expire_at
  20688. if v == nil {
  20689. return
  20690. }
  20691. return *v, true
  20692. }
  20693. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  20694. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20696. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  20697. if !m.op.Is(OpUpdateOne) {
  20698. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  20699. }
  20700. if m.id == nil || m.oldValue == nil {
  20701. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  20702. }
  20703. oldValue, err := m.oldValue(ctx)
  20704. if err != nil {
  20705. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  20706. }
  20707. return oldValue.ExpireAt, nil
  20708. }
  20709. // ClearExpireAt clears the value of the "expire_at" field.
  20710. func (m *TokenMutation) ClearExpireAt() {
  20711. m.expire_at = nil
  20712. m.clearedFields[token.FieldExpireAt] = struct{}{}
  20713. }
  20714. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  20715. func (m *TokenMutation) ExpireAtCleared() bool {
  20716. _, ok := m.clearedFields[token.FieldExpireAt]
  20717. return ok
  20718. }
  20719. // ResetExpireAt resets all changes to the "expire_at" field.
  20720. func (m *TokenMutation) ResetExpireAt() {
  20721. m.expire_at = nil
  20722. delete(m.clearedFields, token.FieldExpireAt)
  20723. }
  20724. // SetToken sets the "token" field.
  20725. func (m *TokenMutation) SetToken(s string) {
  20726. m.token = &s
  20727. }
  20728. // Token returns the value of the "token" field in the mutation.
  20729. func (m *TokenMutation) Token() (r string, exists bool) {
  20730. v := m.token
  20731. if v == nil {
  20732. return
  20733. }
  20734. return *v, true
  20735. }
  20736. // OldToken returns the old "token" field's value of the Token entity.
  20737. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20739. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  20740. if !m.op.Is(OpUpdateOne) {
  20741. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  20742. }
  20743. if m.id == nil || m.oldValue == nil {
  20744. return v, errors.New("OldToken requires an ID field in the mutation")
  20745. }
  20746. oldValue, err := m.oldValue(ctx)
  20747. if err != nil {
  20748. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  20749. }
  20750. return oldValue.Token, nil
  20751. }
  20752. // ClearToken clears the value of the "token" field.
  20753. func (m *TokenMutation) ClearToken() {
  20754. m.token = nil
  20755. m.clearedFields[token.FieldToken] = struct{}{}
  20756. }
  20757. // TokenCleared returns if the "token" field was cleared in this mutation.
  20758. func (m *TokenMutation) TokenCleared() bool {
  20759. _, ok := m.clearedFields[token.FieldToken]
  20760. return ok
  20761. }
  20762. // ResetToken resets all changes to the "token" field.
  20763. func (m *TokenMutation) ResetToken() {
  20764. m.token = nil
  20765. delete(m.clearedFields, token.FieldToken)
  20766. }
  20767. // SetMAC sets the "mac" field.
  20768. func (m *TokenMutation) SetMAC(s string) {
  20769. m.mac = &s
  20770. }
  20771. // MAC returns the value of the "mac" field in the mutation.
  20772. func (m *TokenMutation) MAC() (r string, exists bool) {
  20773. v := m.mac
  20774. if v == nil {
  20775. return
  20776. }
  20777. return *v, true
  20778. }
  20779. // OldMAC returns the old "mac" field's value of the Token entity.
  20780. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20782. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  20783. if !m.op.Is(OpUpdateOne) {
  20784. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  20785. }
  20786. if m.id == nil || m.oldValue == nil {
  20787. return v, errors.New("OldMAC requires an ID field in the mutation")
  20788. }
  20789. oldValue, err := m.oldValue(ctx)
  20790. if err != nil {
  20791. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  20792. }
  20793. return oldValue.MAC, nil
  20794. }
  20795. // ClearMAC clears the value of the "mac" field.
  20796. func (m *TokenMutation) ClearMAC() {
  20797. m.mac = nil
  20798. m.clearedFields[token.FieldMAC] = struct{}{}
  20799. }
  20800. // MACCleared returns if the "mac" field was cleared in this mutation.
  20801. func (m *TokenMutation) MACCleared() bool {
  20802. _, ok := m.clearedFields[token.FieldMAC]
  20803. return ok
  20804. }
  20805. // ResetMAC resets all changes to the "mac" field.
  20806. func (m *TokenMutation) ResetMAC() {
  20807. m.mac = nil
  20808. delete(m.clearedFields, token.FieldMAC)
  20809. }
  20810. // SetOrganizationID sets the "organization_id" field.
  20811. func (m *TokenMutation) SetOrganizationID(u uint64) {
  20812. m.organization_id = &u
  20813. m.addorganization_id = nil
  20814. }
  20815. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20816. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  20817. v := m.organization_id
  20818. if v == nil {
  20819. return
  20820. }
  20821. return *v, true
  20822. }
  20823. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  20824. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20826. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20827. if !m.op.Is(OpUpdateOne) {
  20828. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20829. }
  20830. if m.id == nil || m.oldValue == nil {
  20831. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20832. }
  20833. oldValue, err := m.oldValue(ctx)
  20834. if err != nil {
  20835. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20836. }
  20837. return oldValue.OrganizationID, nil
  20838. }
  20839. // AddOrganizationID adds u to the "organization_id" field.
  20840. func (m *TokenMutation) AddOrganizationID(u int64) {
  20841. if m.addorganization_id != nil {
  20842. *m.addorganization_id += u
  20843. } else {
  20844. m.addorganization_id = &u
  20845. }
  20846. }
  20847. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20848. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  20849. v := m.addorganization_id
  20850. if v == nil {
  20851. return
  20852. }
  20853. return *v, true
  20854. }
  20855. // ResetOrganizationID resets all changes to the "organization_id" field.
  20856. func (m *TokenMutation) ResetOrganizationID() {
  20857. m.organization_id = nil
  20858. m.addorganization_id = nil
  20859. }
  20860. // SetAgentID sets the "agent_id" field.
  20861. func (m *TokenMutation) SetAgentID(u uint64) {
  20862. m.agent = &u
  20863. }
  20864. // AgentID returns the value of the "agent_id" field in the mutation.
  20865. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  20866. v := m.agent
  20867. if v == nil {
  20868. return
  20869. }
  20870. return *v, true
  20871. }
  20872. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  20873. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20875. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  20876. if !m.op.Is(OpUpdateOne) {
  20877. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  20878. }
  20879. if m.id == nil || m.oldValue == nil {
  20880. return v, errors.New("OldAgentID requires an ID field in the mutation")
  20881. }
  20882. oldValue, err := m.oldValue(ctx)
  20883. if err != nil {
  20884. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  20885. }
  20886. return oldValue.AgentID, nil
  20887. }
  20888. // ResetAgentID resets all changes to the "agent_id" field.
  20889. func (m *TokenMutation) ResetAgentID() {
  20890. m.agent = nil
  20891. }
  20892. // SetCustomAgentBase sets the "custom_agent_base" field.
  20893. func (m *TokenMutation) SetCustomAgentBase(s string) {
  20894. m.custom_agent_base = &s
  20895. }
  20896. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  20897. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  20898. v := m.custom_agent_base
  20899. if v == nil {
  20900. return
  20901. }
  20902. return *v, true
  20903. }
  20904. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  20905. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20907. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  20908. if !m.op.Is(OpUpdateOne) {
  20909. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  20910. }
  20911. if m.id == nil || m.oldValue == nil {
  20912. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  20913. }
  20914. oldValue, err := m.oldValue(ctx)
  20915. if err != nil {
  20916. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  20917. }
  20918. return oldValue.CustomAgentBase, nil
  20919. }
  20920. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  20921. func (m *TokenMutation) ClearCustomAgentBase() {
  20922. m.custom_agent_base = nil
  20923. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  20924. }
  20925. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  20926. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  20927. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  20928. return ok
  20929. }
  20930. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  20931. func (m *TokenMutation) ResetCustomAgentBase() {
  20932. m.custom_agent_base = nil
  20933. delete(m.clearedFields, token.FieldCustomAgentBase)
  20934. }
  20935. // SetCustomAgentKey sets the "custom_agent_key" field.
  20936. func (m *TokenMutation) SetCustomAgentKey(s string) {
  20937. m.custom_agent_key = &s
  20938. }
  20939. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  20940. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  20941. v := m.custom_agent_key
  20942. if v == nil {
  20943. return
  20944. }
  20945. return *v, true
  20946. }
  20947. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  20948. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20950. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  20951. if !m.op.Is(OpUpdateOne) {
  20952. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  20953. }
  20954. if m.id == nil || m.oldValue == nil {
  20955. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  20956. }
  20957. oldValue, err := m.oldValue(ctx)
  20958. if err != nil {
  20959. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  20960. }
  20961. return oldValue.CustomAgentKey, nil
  20962. }
  20963. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  20964. func (m *TokenMutation) ClearCustomAgentKey() {
  20965. m.custom_agent_key = nil
  20966. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  20967. }
  20968. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  20969. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  20970. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  20971. return ok
  20972. }
  20973. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  20974. func (m *TokenMutation) ResetCustomAgentKey() {
  20975. m.custom_agent_key = nil
  20976. delete(m.clearedFields, token.FieldCustomAgentKey)
  20977. }
  20978. // SetOpenaiBase sets the "openai_base" field.
  20979. func (m *TokenMutation) SetOpenaiBase(s string) {
  20980. m.openai_base = &s
  20981. }
  20982. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  20983. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  20984. v := m.openai_base
  20985. if v == nil {
  20986. return
  20987. }
  20988. return *v, true
  20989. }
  20990. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  20991. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20993. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  20994. if !m.op.Is(OpUpdateOne) {
  20995. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  20996. }
  20997. if m.id == nil || m.oldValue == nil {
  20998. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  20999. }
  21000. oldValue, err := m.oldValue(ctx)
  21001. if err != nil {
  21002. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  21003. }
  21004. return oldValue.OpenaiBase, nil
  21005. }
  21006. // ClearOpenaiBase clears the value of the "openai_base" field.
  21007. func (m *TokenMutation) ClearOpenaiBase() {
  21008. m.openai_base = nil
  21009. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  21010. }
  21011. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  21012. func (m *TokenMutation) OpenaiBaseCleared() bool {
  21013. _, ok := m.clearedFields[token.FieldOpenaiBase]
  21014. return ok
  21015. }
  21016. // ResetOpenaiBase resets all changes to the "openai_base" field.
  21017. func (m *TokenMutation) ResetOpenaiBase() {
  21018. m.openai_base = nil
  21019. delete(m.clearedFields, token.FieldOpenaiBase)
  21020. }
  21021. // SetOpenaiKey sets the "openai_key" field.
  21022. func (m *TokenMutation) SetOpenaiKey(s string) {
  21023. m.openai_key = &s
  21024. }
  21025. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  21026. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  21027. v := m.openai_key
  21028. if v == nil {
  21029. return
  21030. }
  21031. return *v, true
  21032. }
  21033. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  21034. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21036. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  21037. if !m.op.Is(OpUpdateOne) {
  21038. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  21039. }
  21040. if m.id == nil || m.oldValue == nil {
  21041. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  21042. }
  21043. oldValue, err := m.oldValue(ctx)
  21044. if err != nil {
  21045. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  21046. }
  21047. return oldValue.OpenaiKey, nil
  21048. }
  21049. // ClearOpenaiKey clears the value of the "openai_key" field.
  21050. func (m *TokenMutation) ClearOpenaiKey() {
  21051. m.openai_key = nil
  21052. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  21053. }
  21054. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  21055. func (m *TokenMutation) OpenaiKeyCleared() bool {
  21056. _, ok := m.clearedFields[token.FieldOpenaiKey]
  21057. return ok
  21058. }
  21059. // ResetOpenaiKey resets all changes to the "openai_key" field.
  21060. func (m *TokenMutation) ResetOpenaiKey() {
  21061. m.openai_key = nil
  21062. delete(m.clearedFields, token.FieldOpenaiKey)
  21063. }
  21064. // ClearAgent clears the "agent" edge to the Agent entity.
  21065. func (m *TokenMutation) ClearAgent() {
  21066. m.clearedagent = true
  21067. m.clearedFields[token.FieldAgentID] = struct{}{}
  21068. }
  21069. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  21070. func (m *TokenMutation) AgentCleared() bool {
  21071. return m.clearedagent
  21072. }
  21073. // AgentIDs returns the "agent" edge IDs in the mutation.
  21074. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21075. // AgentID instead. It exists only for internal usage by the builders.
  21076. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  21077. if id := m.agent; id != nil {
  21078. ids = append(ids, *id)
  21079. }
  21080. return
  21081. }
  21082. // ResetAgent resets all changes to the "agent" edge.
  21083. func (m *TokenMutation) ResetAgent() {
  21084. m.agent = nil
  21085. m.clearedagent = false
  21086. }
  21087. // Where appends a list predicates to the TokenMutation builder.
  21088. func (m *TokenMutation) Where(ps ...predicate.Token) {
  21089. m.predicates = append(m.predicates, ps...)
  21090. }
  21091. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  21092. // users can use type-assertion to append predicates that do not depend on any generated package.
  21093. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  21094. p := make([]predicate.Token, len(ps))
  21095. for i := range ps {
  21096. p[i] = ps[i]
  21097. }
  21098. m.Where(p...)
  21099. }
  21100. // Op returns the operation name.
  21101. func (m *TokenMutation) Op() Op {
  21102. return m.op
  21103. }
  21104. // SetOp allows setting the mutation operation.
  21105. func (m *TokenMutation) SetOp(op Op) {
  21106. m.op = op
  21107. }
  21108. // Type returns the node type of this mutation (Token).
  21109. func (m *TokenMutation) Type() string {
  21110. return m.typ
  21111. }
  21112. // Fields returns all fields that were changed during this mutation. Note that in
  21113. // order to get all numeric fields that were incremented/decremented, call
  21114. // AddedFields().
  21115. func (m *TokenMutation) Fields() []string {
  21116. fields := make([]string, 0, 12)
  21117. if m.created_at != nil {
  21118. fields = append(fields, token.FieldCreatedAt)
  21119. }
  21120. if m.updated_at != nil {
  21121. fields = append(fields, token.FieldUpdatedAt)
  21122. }
  21123. if m.deleted_at != nil {
  21124. fields = append(fields, token.FieldDeletedAt)
  21125. }
  21126. if m.expire_at != nil {
  21127. fields = append(fields, token.FieldExpireAt)
  21128. }
  21129. if m.token != nil {
  21130. fields = append(fields, token.FieldToken)
  21131. }
  21132. if m.mac != nil {
  21133. fields = append(fields, token.FieldMAC)
  21134. }
  21135. if m.organization_id != nil {
  21136. fields = append(fields, token.FieldOrganizationID)
  21137. }
  21138. if m.agent != nil {
  21139. fields = append(fields, token.FieldAgentID)
  21140. }
  21141. if m.custom_agent_base != nil {
  21142. fields = append(fields, token.FieldCustomAgentBase)
  21143. }
  21144. if m.custom_agent_key != nil {
  21145. fields = append(fields, token.FieldCustomAgentKey)
  21146. }
  21147. if m.openai_base != nil {
  21148. fields = append(fields, token.FieldOpenaiBase)
  21149. }
  21150. if m.openai_key != nil {
  21151. fields = append(fields, token.FieldOpenaiKey)
  21152. }
  21153. return fields
  21154. }
  21155. // Field returns the value of a field with the given name. The second boolean
  21156. // return value indicates that this field was not set, or was not defined in the
  21157. // schema.
  21158. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  21159. switch name {
  21160. case token.FieldCreatedAt:
  21161. return m.CreatedAt()
  21162. case token.FieldUpdatedAt:
  21163. return m.UpdatedAt()
  21164. case token.FieldDeletedAt:
  21165. return m.DeletedAt()
  21166. case token.FieldExpireAt:
  21167. return m.ExpireAt()
  21168. case token.FieldToken:
  21169. return m.Token()
  21170. case token.FieldMAC:
  21171. return m.MAC()
  21172. case token.FieldOrganizationID:
  21173. return m.OrganizationID()
  21174. case token.FieldAgentID:
  21175. return m.AgentID()
  21176. case token.FieldCustomAgentBase:
  21177. return m.CustomAgentBase()
  21178. case token.FieldCustomAgentKey:
  21179. return m.CustomAgentKey()
  21180. case token.FieldOpenaiBase:
  21181. return m.OpenaiBase()
  21182. case token.FieldOpenaiKey:
  21183. return m.OpenaiKey()
  21184. }
  21185. return nil, false
  21186. }
  21187. // OldField returns the old value of the field from the database. An error is
  21188. // returned if the mutation operation is not UpdateOne, or the query to the
  21189. // database failed.
  21190. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21191. switch name {
  21192. case token.FieldCreatedAt:
  21193. return m.OldCreatedAt(ctx)
  21194. case token.FieldUpdatedAt:
  21195. return m.OldUpdatedAt(ctx)
  21196. case token.FieldDeletedAt:
  21197. return m.OldDeletedAt(ctx)
  21198. case token.FieldExpireAt:
  21199. return m.OldExpireAt(ctx)
  21200. case token.FieldToken:
  21201. return m.OldToken(ctx)
  21202. case token.FieldMAC:
  21203. return m.OldMAC(ctx)
  21204. case token.FieldOrganizationID:
  21205. return m.OldOrganizationID(ctx)
  21206. case token.FieldAgentID:
  21207. return m.OldAgentID(ctx)
  21208. case token.FieldCustomAgentBase:
  21209. return m.OldCustomAgentBase(ctx)
  21210. case token.FieldCustomAgentKey:
  21211. return m.OldCustomAgentKey(ctx)
  21212. case token.FieldOpenaiBase:
  21213. return m.OldOpenaiBase(ctx)
  21214. case token.FieldOpenaiKey:
  21215. return m.OldOpenaiKey(ctx)
  21216. }
  21217. return nil, fmt.Errorf("unknown Token field %s", name)
  21218. }
  21219. // SetField sets the value of a field with the given name. It returns an error if
  21220. // the field is not defined in the schema, or if the type mismatched the field
  21221. // type.
  21222. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  21223. switch name {
  21224. case token.FieldCreatedAt:
  21225. v, ok := value.(time.Time)
  21226. if !ok {
  21227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21228. }
  21229. m.SetCreatedAt(v)
  21230. return nil
  21231. case token.FieldUpdatedAt:
  21232. v, ok := value.(time.Time)
  21233. if !ok {
  21234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21235. }
  21236. m.SetUpdatedAt(v)
  21237. return nil
  21238. case token.FieldDeletedAt:
  21239. v, ok := value.(time.Time)
  21240. if !ok {
  21241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21242. }
  21243. m.SetDeletedAt(v)
  21244. return nil
  21245. case token.FieldExpireAt:
  21246. v, ok := value.(time.Time)
  21247. if !ok {
  21248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21249. }
  21250. m.SetExpireAt(v)
  21251. return nil
  21252. case token.FieldToken:
  21253. v, ok := value.(string)
  21254. if !ok {
  21255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21256. }
  21257. m.SetToken(v)
  21258. return nil
  21259. case token.FieldMAC:
  21260. v, ok := value.(string)
  21261. if !ok {
  21262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21263. }
  21264. m.SetMAC(v)
  21265. return nil
  21266. case token.FieldOrganizationID:
  21267. v, ok := value.(uint64)
  21268. if !ok {
  21269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21270. }
  21271. m.SetOrganizationID(v)
  21272. return nil
  21273. case token.FieldAgentID:
  21274. v, ok := value.(uint64)
  21275. if !ok {
  21276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21277. }
  21278. m.SetAgentID(v)
  21279. return nil
  21280. case token.FieldCustomAgentBase:
  21281. v, ok := value.(string)
  21282. if !ok {
  21283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21284. }
  21285. m.SetCustomAgentBase(v)
  21286. return nil
  21287. case token.FieldCustomAgentKey:
  21288. v, ok := value.(string)
  21289. if !ok {
  21290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21291. }
  21292. m.SetCustomAgentKey(v)
  21293. return nil
  21294. case token.FieldOpenaiBase:
  21295. v, ok := value.(string)
  21296. if !ok {
  21297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21298. }
  21299. m.SetOpenaiBase(v)
  21300. return nil
  21301. case token.FieldOpenaiKey:
  21302. v, ok := value.(string)
  21303. if !ok {
  21304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21305. }
  21306. m.SetOpenaiKey(v)
  21307. return nil
  21308. }
  21309. return fmt.Errorf("unknown Token field %s", name)
  21310. }
  21311. // AddedFields returns all numeric fields that were incremented/decremented during
  21312. // this mutation.
  21313. func (m *TokenMutation) AddedFields() []string {
  21314. var fields []string
  21315. if m.addorganization_id != nil {
  21316. fields = append(fields, token.FieldOrganizationID)
  21317. }
  21318. return fields
  21319. }
  21320. // AddedField returns the numeric value that was incremented/decremented on a field
  21321. // with the given name. The second boolean return value indicates that this field
  21322. // was not set, or was not defined in the schema.
  21323. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  21324. switch name {
  21325. case token.FieldOrganizationID:
  21326. return m.AddedOrganizationID()
  21327. }
  21328. return nil, false
  21329. }
  21330. // AddField adds the value to the field with the given name. It returns an error if
  21331. // the field is not defined in the schema, or if the type mismatched the field
  21332. // type.
  21333. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  21334. switch name {
  21335. case token.FieldOrganizationID:
  21336. v, ok := value.(int64)
  21337. if !ok {
  21338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21339. }
  21340. m.AddOrganizationID(v)
  21341. return nil
  21342. }
  21343. return fmt.Errorf("unknown Token numeric field %s", name)
  21344. }
  21345. // ClearedFields returns all nullable fields that were cleared during this
  21346. // mutation.
  21347. func (m *TokenMutation) ClearedFields() []string {
  21348. var fields []string
  21349. if m.FieldCleared(token.FieldDeletedAt) {
  21350. fields = append(fields, token.FieldDeletedAt)
  21351. }
  21352. if m.FieldCleared(token.FieldExpireAt) {
  21353. fields = append(fields, token.FieldExpireAt)
  21354. }
  21355. if m.FieldCleared(token.FieldToken) {
  21356. fields = append(fields, token.FieldToken)
  21357. }
  21358. if m.FieldCleared(token.FieldMAC) {
  21359. fields = append(fields, token.FieldMAC)
  21360. }
  21361. if m.FieldCleared(token.FieldCustomAgentBase) {
  21362. fields = append(fields, token.FieldCustomAgentBase)
  21363. }
  21364. if m.FieldCleared(token.FieldCustomAgentKey) {
  21365. fields = append(fields, token.FieldCustomAgentKey)
  21366. }
  21367. if m.FieldCleared(token.FieldOpenaiBase) {
  21368. fields = append(fields, token.FieldOpenaiBase)
  21369. }
  21370. if m.FieldCleared(token.FieldOpenaiKey) {
  21371. fields = append(fields, token.FieldOpenaiKey)
  21372. }
  21373. return fields
  21374. }
  21375. // FieldCleared returns a boolean indicating if a field with the given name was
  21376. // cleared in this mutation.
  21377. func (m *TokenMutation) FieldCleared(name string) bool {
  21378. _, ok := m.clearedFields[name]
  21379. return ok
  21380. }
  21381. // ClearField clears the value of the field with the given name. It returns an
  21382. // error if the field is not defined in the schema.
  21383. func (m *TokenMutation) ClearField(name string) error {
  21384. switch name {
  21385. case token.FieldDeletedAt:
  21386. m.ClearDeletedAt()
  21387. return nil
  21388. case token.FieldExpireAt:
  21389. m.ClearExpireAt()
  21390. return nil
  21391. case token.FieldToken:
  21392. m.ClearToken()
  21393. return nil
  21394. case token.FieldMAC:
  21395. m.ClearMAC()
  21396. return nil
  21397. case token.FieldCustomAgentBase:
  21398. m.ClearCustomAgentBase()
  21399. return nil
  21400. case token.FieldCustomAgentKey:
  21401. m.ClearCustomAgentKey()
  21402. return nil
  21403. case token.FieldOpenaiBase:
  21404. m.ClearOpenaiBase()
  21405. return nil
  21406. case token.FieldOpenaiKey:
  21407. m.ClearOpenaiKey()
  21408. return nil
  21409. }
  21410. return fmt.Errorf("unknown Token nullable field %s", name)
  21411. }
  21412. // ResetField resets all changes in the mutation for the field with the given name.
  21413. // It returns an error if the field is not defined in the schema.
  21414. func (m *TokenMutation) ResetField(name string) error {
  21415. switch name {
  21416. case token.FieldCreatedAt:
  21417. m.ResetCreatedAt()
  21418. return nil
  21419. case token.FieldUpdatedAt:
  21420. m.ResetUpdatedAt()
  21421. return nil
  21422. case token.FieldDeletedAt:
  21423. m.ResetDeletedAt()
  21424. return nil
  21425. case token.FieldExpireAt:
  21426. m.ResetExpireAt()
  21427. return nil
  21428. case token.FieldToken:
  21429. m.ResetToken()
  21430. return nil
  21431. case token.FieldMAC:
  21432. m.ResetMAC()
  21433. return nil
  21434. case token.FieldOrganizationID:
  21435. m.ResetOrganizationID()
  21436. return nil
  21437. case token.FieldAgentID:
  21438. m.ResetAgentID()
  21439. return nil
  21440. case token.FieldCustomAgentBase:
  21441. m.ResetCustomAgentBase()
  21442. return nil
  21443. case token.FieldCustomAgentKey:
  21444. m.ResetCustomAgentKey()
  21445. return nil
  21446. case token.FieldOpenaiBase:
  21447. m.ResetOpenaiBase()
  21448. return nil
  21449. case token.FieldOpenaiKey:
  21450. m.ResetOpenaiKey()
  21451. return nil
  21452. }
  21453. return fmt.Errorf("unknown Token field %s", name)
  21454. }
  21455. // AddedEdges returns all edge names that were set/added in this mutation.
  21456. func (m *TokenMutation) AddedEdges() []string {
  21457. edges := make([]string, 0, 1)
  21458. if m.agent != nil {
  21459. edges = append(edges, token.EdgeAgent)
  21460. }
  21461. return edges
  21462. }
  21463. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21464. // name in this mutation.
  21465. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  21466. switch name {
  21467. case token.EdgeAgent:
  21468. if id := m.agent; id != nil {
  21469. return []ent.Value{*id}
  21470. }
  21471. }
  21472. return nil
  21473. }
  21474. // RemovedEdges returns all edge names that were removed in this mutation.
  21475. func (m *TokenMutation) RemovedEdges() []string {
  21476. edges := make([]string, 0, 1)
  21477. return edges
  21478. }
  21479. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21480. // the given name in this mutation.
  21481. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  21482. return nil
  21483. }
  21484. // ClearedEdges returns all edge names that were cleared in this mutation.
  21485. func (m *TokenMutation) ClearedEdges() []string {
  21486. edges := make([]string, 0, 1)
  21487. if m.clearedagent {
  21488. edges = append(edges, token.EdgeAgent)
  21489. }
  21490. return edges
  21491. }
  21492. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21493. // was cleared in this mutation.
  21494. func (m *TokenMutation) EdgeCleared(name string) bool {
  21495. switch name {
  21496. case token.EdgeAgent:
  21497. return m.clearedagent
  21498. }
  21499. return false
  21500. }
  21501. // ClearEdge clears the value of the edge with the given name. It returns an error
  21502. // if that edge is not defined in the schema.
  21503. func (m *TokenMutation) ClearEdge(name string) error {
  21504. switch name {
  21505. case token.EdgeAgent:
  21506. m.ClearAgent()
  21507. return nil
  21508. }
  21509. return fmt.Errorf("unknown Token unique edge %s", name)
  21510. }
  21511. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21512. // It returns an error if the edge is not defined in the schema.
  21513. func (m *TokenMutation) ResetEdge(name string) error {
  21514. switch name {
  21515. case token.EdgeAgent:
  21516. m.ResetAgent()
  21517. return nil
  21518. }
  21519. return fmt.Errorf("unknown Token edge %s", name)
  21520. }
  21521. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  21522. type TutorialMutation struct {
  21523. config
  21524. op Op
  21525. typ string
  21526. id *uint64
  21527. created_at *time.Time
  21528. updated_at *time.Time
  21529. deleted_at *time.Time
  21530. index *int
  21531. addindex *int
  21532. title *string
  21533. content *string
  21534. organization_id *uint64
  21535. addorganization_id *int64
  21536. clearedFields map[string]struct{}
  21537. employee *uint64
  21538. clearedemployee bool
  21539. done bool
  21540. oldValue func(context.Context) (*Tutorial, error)
  21541. predicates []predicate.Tutorial
  21542. }
  21543. var _ ent.Mutation = (*TutorialMutation)(nil)
  21544. // tutorialOption allows management of the mutation configuration using functional options.
  21545. type tutorialOption func(*TutorialMutation)
  21546. // newTutorialMutation creates new mutation for the Tutorial entity.
  21547. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  21548. m := &TutorialMutation{
  21549. config: c,
  21550. op: op,
  21551. typ: TypeTutorial,
  21552. clearedFields: make(map[string]struct{}),
  21553. }
  21554. for _, opt := range opts {
  21555. opt(m)
  21556. }
  21557. return m
  21558. }
  21559. // withTutorialID sets the ID field of the mutation.
  21560. func withTutorialID(id uint64) tutorialOption {
  21561. return func(m *TutorialMutation) {
  21562. var (
  21563. err error
  21564. once sync.Once
  21565. value *Tutorial
  21566. )
  21567. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  21568. once.Do(func() {
  21569. if m.done {
  21570. err = errors.New("querying old values post mutation is not allowed")
  21571. } else {
  21572. value, err = m.Client().Tutorial.Get(ctx, id)
  21573. }
  21574. })
  21575. return value, err
  21576. }
  21577. m.id = &id
  21578. }
  21579. }
  21580. // withTutorial sets the old Tutorial of the mutation.
  21581. func withTutorial(node *Tutorial) tutorialOption {
  21582. return func(m *TutorialMutation) {
  21583. m.oldValue = func(context.Context) (*Tutorial, error) {
  21584. return node, nil
  21585. }
  21586. m.id = &node.ID
  21587. }
  21588. }
  21589. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21590. // executed in a transaction (ent.Tx), a transactional client is returned.
  21591. func (m TutorialMutation) Client() *Client {
  21592. client := &Client{config: m.config}
  21593. client.init()
  21594. return client
  21595. }
  21596. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21597. // it returns an error otherwise.
  21598. func (m TutorialMutation) Tx() (*Tx, error) {
  21599. if _, ok := m.driver.(*txDriver); !ok {
  21600. return nil, errors.New("ent: mutation is not running in a transaction")
  21601. }
  21602. tx := &Tx{config: m.config}
  21603. tx.init()
  21604. return tx, nil
  21605. }
  21606. // SetID sets the value of the id field. Note that this
  21607. // operation is only accepted on creation of Tutorial entities.
  21608. func (m *TutorialMutation) SetID(id uint64) {
  21609. m.id = &id
  21610. }
  21611. // ID returns the ID value in the mutation. Note that the ID is only available
  21612. // if it was provided to the builder or after it was returned from the database.
  21613. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  21614. if m.id == nil {
  21615. return
  21616. }
  21617. return *m.id, true
  21618. }
  21619. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21620. // That means, if the mutation is applied within a transaction with an isolation level such
  21621. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21622. // or updated by the mutation.
  21623. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  21624. switch {
  21625. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21626. id, exists := m.ID()
  21627. if exists {
  21628. return []uint64{id}, nil
  21629. }
  21630. fallthrough
  21631. case m.op.Is(OpUpdate | OpDelete):
  21632. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  21633. default:
  21634. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21635. }
  21636. }
  21637. // SetCreatedAt sets the "created_at" field.
  21638. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  21639. m.created_at = &t
  21640. }
  21641. // CreatedAt returns the value of the "created_at" field in the mutation.
  21642. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  21643. v := m.created_at
  21644. if v == nil {
  21645. return
  21646. }
  21647. return *v, true
  21648. }
  21649. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  21650. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21652. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21653. if !m.op.Is(OpUpdateOne) {
  21654. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21655. }
  21656. if m.id == nil || m.oldValue == nil {
  21657. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21658. }
  21659. oldValue, err := m.oldValue(ctx)
  21660. if err != nil {
  21661. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21662. }
  21663. return oldValue.CreatedAt, nil
  21664. }
  21665. // ResetCreatedAt resets all changes to the "created_at" field.
  21666. func (m *TutorialMutation) ResetCreatedAt() {
  21667. m.created_at = nil
  21668. }
  21669. // SetUpdatedAt sets the "updated_at" field.
  21670. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  21671. m.updated_at = &t
  21672. }
  21673. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21674. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  21675. v := m.updated_at
  21676. if v == nil {
  21677. return
  21678. }
  21679. return *v, true
  21680. }
  21681. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  21682. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21684. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21685. if !m.op.Is(OpUpdateOne) {
  21686. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21687. }
  21688. if m.id == nil || m.oldValue == nil {
  21689. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21690. }
  21691. oldValue, err := m.oldValue(ctx)
  21692. if err != nil {
  21693. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21694. }
  21695. return oldValue.UpdatedAt, nil
  21696. }
  21697. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21698. func (m *TutorialMutation) ResetUpdatedAt() {
  21699. m.updated_at = nil
  21700. }
  21701. // SetDeletedAt sets the "deleted_at" field.
  21702. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  21703. m.deleted_at = &t
  21704. }
  21705. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21706. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  21707. v := m.deleted_at
  21708. if v == nil {
  21709. return
  21710. }
  21711. return *v, true
  21712. }
  21713. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  21714. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21716. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21717. if !m.op.Is(OpUpdateOne) {
  21718. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21719. }
  21720. if m.id == nil || m.oldValue == nil {
  21721. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21722. }
  21723. oldValue, err := m.oldValue(ctx)
  21724. if err != nil {
  21725. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21726. }
  21727. return oldValue.DeletedAt, nil
  21728. }
  21729. // ClearDeletedAt clears the value of the "deleted_at" field.
  21730. func (m *TutorialMutation) ClearDeletedAt() {
  21731. m.deleted_at = nil
  21732. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  21733. }
  21734. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21735. func (m *TutorialMutation) DeletedAtCleared() bool {
  21736. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  21737. return ok
  21738. }
  21739. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21740. func (m *TutorialMutation) ResetDeletedAt() {
  21741. m.deleted_at = nil
  21742. delete(m.clearedFields, tutorial.FieldDeletedAt)
  21743. }
  21744. // SetEmployeeID sets the "employee_id" field.
  21745. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  21746. m.employee = &u
  21747. }
  21748. // EmployeeID returns the value of the "employee_id" field in the mutation.
  21749. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  21750. v := m.employee
  21751. if v == nil {
  21752. return
  21753. }
  21754. return *v, true
  21755. }
  21756. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  21757. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21759. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  21760. if !m.op.Is(OpUpdateOne) {
  21761. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  21762. }
  21763. if m.id == nil || m.oldValue == nil {
  21764. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  21765. }
  21766. oldValue, err := m.oldValue(ctx)
  21767. if err != nil {
  21768. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  21769. }
  21770. return oldValue.EmployeeID, nil
  21771. }
  21772. // ResetEmployeeID resets all changes to the "employee_id" field.
  21773. func (m *TutorialMutation) ResetEmployeeID() {
  21774. m.employee = nil
  21775. }
  21776. // SetIndex sets the "index" field.
  21777. func (m *TutorialMutation) SetIndex(i int) {
  21778. m.index = &i
  21779. m.addindex = nil
  21780. }
  21781. // Index returns the value of the "index" field in the mutation.
  21782. func (m *TutorialMutation) Index() (r int, exists bool) {
  21783. v := m.index
  21784. if v == nil {
  21785. return
  21786. }
  21787. return *v, true
  21788. }
  21789. // OldIndex returns the old "index" field's value of the Tutorial entity.
  21790. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21792. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  21793. if !m.op.Is(OpUpdateOne) {
  21794. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  21795. }
  21796. if m.id == nil || m.oldValue == nil {
  21797. return v, errors.New("OldIndex requires an ID field in the mutation")
  21798. }
  21799. oldValue, err := m.oldValue(ctx)
  21800. if err != nil {
  21801. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  21802. }
  21803. return oldValue.Index, nil
  21804. }
  21805. // AddIndex adds i to the "index" field.
  21806. func (m *TutorialMutation) AddIndex(i int) {
  21807. if m.addindex != nil {
  21808. *m.addindex += i
  21809. } else {
  21810. m.addindex = &i
  21811. }
  21812. }
  21813. // AddedIndex returns the value that was added to the "index" field in this mutation.
  21814. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  21815. v := m.addindex
  21816. if v == nil {
  21817. return
  21818. }
  21819. return *v, true
  21820. }
  21821. // ResetIndex resets all changes to the "index" field.
  21822. func (m *TutorialMutation) ResetIndex() {
  21823. m.index = nil
  21824. m.addindex = nil
  21825. }
  21826. // SetTitle sets the "title" field.
  21827. func (m *TutorialMutation) SetTitle(s string) {
  21828. m.title = &s
  21829. }
  21830. // Title returns the value of the "title" field in the mutation.
  21831. func (m *TutorialMutation) Title() (r string, exists bool) {
  21832. v := m.title
  21833. if v == nil {
  21834. return
  21835. }
  21836. return *v, true
  21837. }
  21838. // OldTitle returns the old "title" field's value of the Tutorial entity.
  21839. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21841. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  21842. if !m.op.Is(OpUpdateOne) {
  21843. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  21844. }
  21845. if m.id == nil || m.oldValue == nil {
  21846. return v, errors.New("OldTitle requires an ID field in the mutation")
  21847. }
  21848. oldValue, err := m.oldValue(ctx)
  21849. if err != nil {
  21850. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  21851. }
  21852. return oldValue.Title, nil
  21853. }
  21854. // ResetTitle resets all changes to the "title" field.
  21855. func (m *TutorialMutation) ResetTitle() {
  21856. m.title = nil
  21857. }
  21858. // SetContent sets the "content" field.
  21859. func (m *TutorialMutation) SetContent(s string) {
  21860. m.content = &s
  21861. }
  21862. // Content returns the value of the "content" field in the mutation.
  21863. func (m *TutorialMutation) Content() (r string, exists bool) {
  21864. v := m.content
  21865. if v == nil {
  21866. return
  21867. }
  21868. return *v, true
  21869. }
  21870. // OldContent returns the old "content" field's value of the Tutorial entity.
  21871. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21873. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  21874. if !m.op.Is(OpUpdateOne) {
  21875. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  21876. }
  21877. if m.id == nil || m.oldValue == nil {
  21878. return v, errors.New("OldContent requires an ID field in the mutation")
  21879. }
  21880. oldValue, err := m.oldValue(ctx)
  21881. if err != nil {
  21882. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  21883. }
  21884. return oldValue.Content, nil
  21885. }
  21886. // ResetContent resets all changes to the "content" field.
  21887. func (m *TutorialMutation) ResetContent() {
  21888. m.content = nil
  21889. }
  21890. // SetOrganizationID sets the "organization_id" field.
  21891. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  21892. m.organization_id = &u
  21893. m.addorganization_id = nil
  21894. }
  21895. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21896. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  21897. v := m.organization_id
  21898. if v == nil {
  21899. return
  21900. }
  21901. return *v, true
  21902. }
  21903. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  21904. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21906. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21907. if !m.op.Is(OpUpdateOne) {
  21908. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21909. }
  21910. if m.id == nil || m.oldValue == nil {
  21911. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21912. }
  21913. oldValue, err := m.oldValue(ctx)
  21914. if err != nil {
  21915. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21916. }
  21917. return oldValue.OrganizationID, nil
  21918. }
  21919. // AddOrganizationID adds u to the "organization_id" field.
  21920. func (m *TutorialMutation) AddOrganizationID(u int64) {
  21921. if m.addorganization_id != nil {
  21922. *m.addorganization_id += u
  21923. } else {
  21924. m.addorganization_id = &u
  21925. }
  21926. }
  21927. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21928. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  21929. v := m.addorganization_id
  21930. if v == nil {
  21931. return
  21932. }
  21933. return *v, true
  21934. }
  21935. // ResetOrganizationID resets all changes to the "organization_id" field.
  21936. func (m *TutorialMutation) ResetOrganizationID() {
  21937. m.organization_id = nil
  21938. m.addorganization_id = nil
  21939. }
  21940. // ClearEmployee clears the "employee" edge to the Employee entity.
  21941. func (m *TutorialMutation) ClearEmployee() {
  21942. m.clearedemployee = true
  21943. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  21944. }
  21945. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  21946. func (m *TutorialMutation) EmployeeCleared() bool {
  21947. return m.clearedemployee
  21948. }
  21949. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  21950. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21951. // EmployeeID instead. It exists only for internal usage by the builders.
  21952. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  21953. if id := m.employee; id != nil {
  21954. ids = append(ids, *id)
  21955. }
  21956. return
  21957. }
  21958. // ResetEmployee resets all changes to the "employee" edge.
  21959. func (m *TutorialMutation) ResetEmployee() {
  21960. m.employee = nil
  21961. m.clearedemployee = false
  21962. }
  21963. // Where appends a list predicates to the TutorialMutation builder.
  21964. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  21965. m.predicates = append(m.predicates, ps...)
  21966. }
  21967. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  21968. // users can use type-assertion to append predicates that do not depend on any generated package.
  21969. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  21970. p := make([]predicate.Tutorial, len(ps))
  21971. for i := range ps {
  21972. p[i] = ps[i]
  21973. }
  21974. m.Where(p...)
  21975. }
  21976. // Op returns the operation name.
  21977. func (m *TutorialMutation) Op() Op {
  21978. return m.op
  21979. }
  21980. // SetOp allows setting the mutation operation.
  21981. func (m *TutorialMutation) SetOp(op Op) {
  21982. m.op = op
  21983. }
  21984. // Type returns the node type of this mutation (Tutorial).
  21985. func (m *TutorialMutation) Type() string {
  21986. return m.typ
  21987. }
  21988. // Fields returns all fields that were changed during this mutation. Note that in
  21989. // order to get all numeric fields that were incremented/decremented, call
  21990. // AddedFields().
  21991. func (m *TutorialMutation) Fields() []string {
  21992. fields := make([]string, 0, 8)
  21993. if m.created_at != nil {
  21994. fields = append(fields, tutorial.FieldCreatedAt)
  21995. }
  21996. if m.updated_at != nil {
  21997. fields = append(fields, tutorial.FieldUpdatedAt)
  21998. }
  21999. if m.deleted_at != nil {
  22000. fields = append(fields, tutorial.FieldDeletedAt)
  22001. }
  22002. if m.employee != nil {
  22003. fields = append(fields, tutorial.FieldEmployeeID)
  22004. }
  22005. if m.index != nil {
  22006. fields = append(fields, tutorial.FieldIndex)
  22007. }
  22008. if m.title != nil {
  22009. fields = append(fields, tutorial.FieldTitle)
  22010. }
  22011. if m.content != nil {
  22012. fields = append(fields, tutorial.FieldContent)
  22013. }
  22014. if m.organization_id != nil {
  22015. fields = append(fields, tutorial.FieldOrganizationID)
  22016. }
  22017. return fields
  22018. }
  22019. // Field returns the value of a field with the given name. The second boolean
  22020. // return value indicates that this field was not set, or was not defined in the
  22021. // schema.
  22022. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  22023. switch name {
  22024. case tutorial.FieldCreatedAt:
  22025. return m.CreatedAt()
  22026. case tutorial.FieldUpdatedAt:
  22027. return m.UpdatedAt()
  22028. case tutorial.FieldDeletedAt:
  22029. return m.DeletedAt()
  22030. case tutorial.FieldEmployeeID:
  22031. return m.EmployeeID()
  22032. case tutorial.FieldIndex:
  22033. return m.Index()
  22034. case tutorial.FieldTitle:
  22035. return m.Title()
  22036. case tutorial.FieldContent:
  22037. return m.Content()
  22038. case tutorial.FieldOrganizationID:
  22039. return m.OrganizationID()
  22040. }
  22041. return nil, false
  22042. }
  22043. // OldField returns the old value of the field from the database. An error is
  22044. // returned if the mutation operation is not UpdateOne, or the query to the
  22045. // database failed.
  22046. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22047. switch name {
  22048. case tutorial.FieldCreatedAt:
  22049. return m.OldCreatedAt(ctx)
  22050. case tutorial.FieldUpdatedAt:
  22051. return m.OldUpdatedAt(ctx)
  22052. case tutorial.FieldDeletedAt:
  22053. return m.OldDeletedAt(ctx)
  22054. case tutorial.FieldEmployeeID:
  22055. return m.OldEmployeeID(ctx)
  22056. case tutorial.FieldIndex:
  22057. return m.OldIndex(ctx)
  22058. case tutorial.FieldTitle:
  22059. return m.OldTitle(ctx)
  22060. case tutorial.FieldContent:
  22061. return m.OldContent(ctx)
  22062. case tutorial.FieldOrganizationID:
  22063. return m.OldOrganizationID(ctx)
  22064. }
  22065. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  22066. }
  22067. // SetField sets the value of a field with the given name. It returns an error if
  22068. // the field is not defined in the schema, or if the type mismatched the field
  22069. // type.
  22070. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  22071. switch name {
  22072. case tutorial.FieldCreatedAt:
  22073. v, ok := value.(time.Time)
  22074. if !ok {
  22075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22076. }
  22077. m.SetCreatedAt(v)
  22078. return nil
  22079. case tutorial.FieldUpdatedAt:
  22080. v, ok := value.(time.Time)
  22081. if !ok {
  22082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22083. }
  22084. m.SetUpdatedAt(v)
  22085. return nil
  22086. case tutorial.FieldDeletedAt:
  22087. v, ok := value.(time.Time)
  22088. if !ok {
  22089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22090. }
  22091. m.SetDeletedAt(v)
  22092. return nil
  22093. case tutorial.FieldEmployeeID:
  22094. v, ok := value.(uint64)
  22095. if !ok {
  22096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22097. }
  22098. m.SetEmployeeID(v)
  22099. return nil
  22100. case tutorial.FieldIndex:
  22101. v, ok := value.(int)
  22102. if !ok {
  22103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22104. }
  22105. m.SetIndex(v)
  22106. return nil
  22107. case tutorial.FieldTitle:
  22108. v, ok := value.(string)
  22109. if !ok {
  22110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22111. }
  22112. m.SetTitle(v)
  22113. return nil
  22114. case tutorial.FieldContent:
  22115. v, ok := value.(string)
  22116. if !ok {
  22117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22118. }
  22119. m.SetContent(v)
  22120. return nil
  22121. case tutorial.FieldOrganizationID:
  22122. v, ok := value.(uint64)
  22123. if !ok {
  22124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22125. }
  22126. m.SetOrganizationID(v)
  22127. return nil
  22128. }
  22129. return fmt.Errorf("unknown Tutorial field %s", name)
  22130. }
  22131. // AddedFields returns all numeric fields that were incremented/decremented during
  22132. // this mutation.
  22133. func (m *TutorialMutation) AddedFields() []string {
  22134. var fields []string
  22135. if m.addindex != nil {
  22136. fields = append(fields, tutorial.FieldIndex)
  22137. }
  22138. if m.addorganization_id != nil {
  22139. fields = append(fields, tutorial.FieldOrganizationID)
  22140. }
  22141. return fields
  22142. }
  22143. // AddedField returns the numeric value that was incremented/decremented on a field
  22144. // with the given name. The second boolean return value indicates that this field
  22145. // was not set, or was not defined in the schema.
  22146. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  22147. switch name {
  22148. case tutorial.FieldIndex:
  22149. return m.AddedIndex()
  22150. case tutorial.FieldOrganizationID:
  22151. return m.AddedOrganizationID()
  22152. }
  22153. return nil, false
  22154. }
  22155. // AddField adds the value to the field with the given name. It returns an error if
  22156. // the field is not defined in the schema, or if the type mismatched the field
  22157. // type.
  22158. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  22159. switch name {
  22160. case tutorial.FieldIndex:
  22161. v, ok := value.(int)
  22162. if !ok {
  22163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22164. }
  22165. m.AddIndex(v)
  22166. return nil
  22167. case tutorial.FieldOrganizationID:
  22168. v, ok := value.(int64)
  22169. if !ok {
  22170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22171. }
  22172. m.AddOrganizationID(v)
  22173. return nil
  22174. }
  22175. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  22176. }
  22177. // ClearedFields returns all nullable fields that were cleared during this
  22178. // mutation.
  22179. func (m *TutorialMutation) ClearedFields() []string {
  22180. var fields []string
  22181. if m.FieldCleared(tutorial.FieldDeletedAt) {
  22182. fields = append(fields, tutorial.FieldDeletedAt)
  22183. }
  22184. return fields
  22185. }
  22186. // FieldCleared returns a boolean indicating if a field with the given name was
  22187. // cleared in this mutation.
  22188. func (m *TutorialMutation) FieldCleared(name string) bool {
  22189. _, ok := m.clearedFields[name]
  22190. return ok
  22191. }
  22192. // ClearField clears the value of the field with the given name. It returns an
  22193. // error if the field is not defined in the schema.
  22194. func (m *TutorialMutation) ClearField(name string) error {
  22195. switch name {
  22196. case tutorial.FieldDeletedAt:
  22197. m.ClearDeletedAt()
  22198. return nil
  22199. }
  22200. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  22201. }
  22202. // ResetField resets all changes in the mutation for the field with the given name.
  22203. // It returns an error if the field is not defined in the schema.
  22204. func (m *TutorialMutation) ResetField(name string) error {
  22205. switch name {
  22206. case tutorial.FieldCreatedAt:
  22207. m.ResetCreatedAt()
  22208. return nil
  22209. case tutorial.FieldUpdatedAt:
  22210. m.ResetUpdatedAt()
  22211. return nil
  22212. case tutorial.FieldDeletedAt:
  22213. m.ResetDeletedAt()
  22214. return nil
  22215. case tutorial.FieldEmployeeID:
  22216. m.ResetEmployeeID()
  22217. return nil
  22218. case tutorial.FieldIndex:
  22219. m.ResetIndex()
  22220. return nil
  22221. case tutorial.FieldTitle:
  22222. m.ResetTitle()
  22223. return nil
  22224. case tutorial.FieldContent:
  22225. m.ResetContent()
  22226. return nil
  22227. case tutorial.FieldOrganizationID:
  22228. m.ResetOrganizationID()
  22229. return nil
  22230. }
  22231. return fmt.Errorf("unknown Tutorial field %s", name)
  22232. }
  22233. // AddedEdges returns all edge names that were set/added in this mutation.
  22234. func (m *TutorialMutation) AddedEdges() []string {
  22235. edges := make([]string, 0, 1)
  22236. if m.employee != nil {
  22237. edges = append(edges, tutorial.EdgeEmployee)
  22238. }
  22239. return edges
  22240. }
  22241. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22242. // name in this mutation.
  22243. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  22244. switch name {
  22245. case tutorial.EdgeEmployee:
  22246. if id := m.employee; id != nil {
  22247. return []ent.Value{*id}
  22248. }
  22249. }
  22250. return nil
  22251. }
  22252. // RemovedEdges returns all edge names that were removed in this mutation.
  22253. func (m *TutorialMutation) RemovedEdges() []string {
  22254. edges := make([]string, 0, 1)
  22255. return edges
  22256. }
  22257. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22258. // the given name in this mutation.
  22259. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  22260. return nil
  22261. }
  22262. // ClearedEdges returns all edge names that were cleared in this mutation.
  22263. func (m *TutorialMutation) ClearedEdges() []string {
  22264. edges := make([]string, 0, 1)
  22265. if m.clearedemployee {
  22266. edges = append(edges, tutorial.EdgeEmployee)
  22267. }
  22268. return edges
  22269. }
  22270. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22271. // was cleared in this mutation.
  22272. func (m *TutorialMutation) EdgeCleared(name string) bool {
  22273. switch name {
  22274. case tutorial.EdgeEmployee:
  22275. return m.clearedemployee
  22276. }
  22277. return false
  22278. }
  22279. // ClearEdge clears the value of the edge with the given name. It returns an error
  22280. // if that edge is not defined in the schema.
  22281. func (m *TutorialMutation) ClearEdge(name string) error {
  22282. switch name {
  22283. case tutorial.EdgeEmployee:
  22284. m.ClearEmployee()
  22285. return nil
  22286. }
  22287. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  22288. }
  22289. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22290. // It returns an error if the edge is not defined in the schema.
  22291. func (m *TutorialMutation) ResetEdge(name string) error {
  22292. switch name {
  22293. case tutorial.EdgeEmployee:
  22294. m.ResetEmployee()
  22295. return nil
  22296. }
  22297. return fmt.Errorf("unknown Tutorial edge %s", name)
  22298. }
  22299. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  22300. type WorkExperienceMutation struct {
  22301. config
  22302. op Op
  22303. typ string
  22304. id *uint64
  22305. created_at *time.Time
  22306. updated_at *time.Time
  22307. deleted_at *time.Time
  22308. start_date *time.Time
  22309. end_date *time.Time
  22310. company *string
  22311. experience *string
  22312. organization_id *uint64
  22313. addorganization_id *int64
  22314. clearedFields map[string]struct{}
  22315. employee *uint64
  22316. clearedemployee bool
  22317. done bool
  22318. oldValue func(context.Context) (*WorkExperience, error)
  22319. predicates []predicate.WorkExperience
  22320. }
  22321. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  22322. // workexperienceOption allows management of the mutation configuration using functional options.
  22323. type workexperienceOption func(*WorkExperienceMutation)
  22324. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  22325. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  22326. m := &WorkExperienceMutation{
  22327. config: c,
  22328. op: op,
  22329. typ: TypeWorkExperience,
  22330. clearedFields: make(map[string]struct{}),
  22331. }
  22332. for _, opt := range opts {
  22333. opt(m)
  22334. }
  22335. return m
  22336. }
  22337. // withWorkExperienceID sets the ID field of the mutation.
  22338. func withWorkExperienceID(id uint64) workexperienceOption {
  22339. return func(m *WorkExperienceMutation) {
  22340. var (
  22341. err error
  22342. once sync.Once
  22343. value *WorkExperience
  22344. )
  22345. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  22346. once.Do(func() {
  22347. if m.done {
  22348. err = errors.New("querying old values post mutation is not allowed")
  22349. } else {
  22350. value, err = m.Client().WorkExperience.Get(ctx, id)
  22351. }
  22352. })
  22353. return value, err
  22354. }
  22355. m.id = &id
  22356. }
  22357. }
  22358. // withWorkExperience sets the old WorkExperience of the mutation.
  22359. func withWorkExperience(node *WorkExperience) workexperienceOption {
  22360. return func(m *WorkExperienceMutation) {
  22361. m.oldValue = func(context.Context) (*WorkExperience, error) {
  22362. return node, nil
  22363. }
  22364. m.id = &node.ID
  22365. }
  22366. }
  22367. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22368. // executed in a transaction (ent.Tx), a transactional client is returned.
  22369. func (m WorkExperienceMutation) Client() *Client {
  22370. client := &Client{config: m.config}
  22371. client.init()
  22372. return client
  22373. }
  22374. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22375. // it returns an error otherwise.
  22376. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  22377. if _, ok := m.driver.(*txDriver); !ok {
  22378. return nil, errors.New("ent: mutation is not running in a transaction")
  22379. }
  22380. tx := &Tx{config: m.config}
  22381. tx.init()
  22382. return tx, nil
  22383. }
  22384. // SetID sets the value of the id field. Note that this
  22385. // operation is only accepted on creation of WorkExperience entities.
  22386. func (m *WorkExperienceMutation) SetID(id uint64) {
  22387. m.id = &id
  22388. }
  22389. // ID returns the ID value in the mutation. Note that the ID is only available
  22390. // if it was provided to the builder or after it was returned from the database.
  22391. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  22392. if m.id == nil {
  22393. return
  22394. }
  22395. return *m.id, true
  22396. }
  22397. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22398. // That means, if the mutation is applied within a transaction with an isolation level such
  22399. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22400. // or updated by the mutation.
  22401. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  22402. switch {
  22403. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22404. id, exists := m.ID()
  22405. if exists {
  22406. return []uint64{id}, nil
  22407. }
  22408. fallthrough
  22409. case m.op.Is(OpUpdate | OpDelete):
  22410. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  22411. default:
  22412. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22413. }
  22414. }
  22415. // SetCreatedAt sets the "created_at" field.
  22416. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  22417. m.created_at = &t
  22418. }
  22419. // CreatedAt returns the value of the "created_at" field in the mutation.
  22420. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  22421. v := m.created_at
  22422. if v == nil {
  22423. return
  22424. }
  22425. return *v, true
  22426. }
  22427. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  22428. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22430. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22431. if !m.op.Is(OpUpdateOne) {
  22432. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22433. }
  22434. if m.id == nil || m.oldValue == nil {
  22435. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22436. }
  22437. oldValue, err := m.oldValue(ctx)
  22438. if err != nil {
  22439. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22440. }
  22441. return oldValue.CreatedAt, nil
  22442. }
  22443. // ResetCreatedAt resets all changes to the "created_at" field.
  22444. func (m *WorkExperienceMutation) ResetCreatedAt() {
  22445. m.created_at = nil
  22446. }
  22447. // SetUpdatedAt sets the "updated_at" field.
  22448. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  22449. m.updated_at = &t
  22450. }
  22451. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22452. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  22453. v := m.updated_at
  22454. if v == nil {
  22455. return
  22456. }
  22457. return *v, true
  22458. }
  22459. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  22460. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22462. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22463. if !m.op.Is(OpUpdateOne) {
  22464. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22465. }
  22466. if m.id == nil || m.oldValue == nil {
  22467. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22468. }
  22469. oldValue, err := m.oldValue(ctx)
  22470. if err != nil {
  22471. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22472. }
  22473. return oldValue.UpdatedAt, nil
  22474. }
  22475. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22476. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  22477. m.updated_at = nil
  22478. }
  22479. // SetDeletedAt sets the "deleted_at" field.
  22480. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  22481. m.deleted_at = &t
  22482. }
  22483. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22484. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  22485. v := m.deleted_at
  22486. if v == nil {
  22487. return
  22488. }
  22489. return *v, true
  22490. }
  22491. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  22492. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22494. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22495. if !m.op.Is(OpUpdateOne) {
  22496. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22497. }
  22498. if m.id == nil || m.oldValue == nil {
  22499. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22500. }
  22501. oldValue, err := m.oldValue(ctx)
  22502. if err != nil {
  22503. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22504. }
  22505. return oldValue.DeletedAt, nil
  22506. }
  22507. // ClearDeletedAt clears the value of the "deleted_at" field.
  22508. func (m *WorkExperienceMutation) ClearDeletedAt() {
  22509. m.deleted_at = nil
  22510. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  22511. }
  22512. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22513. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  22514. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  22515. return ok
  22516. }
  22517. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22518. func (m *WorkExperienceMutation) ResetDeletedAt() {
  22519. m.deleted_at = nil
  22520. delete(m.clearedFields, workexperience.FieldDeletedAt)
  22521. }
  22522. // SetEmployeeID sets the "employee_id" field.
  22523. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  22524. m.employee = &u
  22525. }
  22526. // EmployeeID returns the value of the "employee_id" field in the mutation.
  22527. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  22528. v := m.employee
  22529. if v == nil {
  22530. return
  22531. }
  22532. return *v, true
  22533. }
  22534. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  22535. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22537. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  22538. if !m.op.Is(OpUpdateOne) {
  22539. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  22540. }
  22541. if m.id == nil || m.oldValue == nil {
  22542. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  22543. }
  22544. oldValue, err := m.oldValue(ctx)
  22545. if err != nil {
  22546. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  22547. }
  22548. return oldValue.EmployeeID, nil
  22549. }
  22550. // ResetEmployeeID resets all changes to the "employee_id" field.
  22551. func (m *WorkExperienceMutation) ResetEmployeeID() {
  22552. m.employee = nil
  22553. }
  22554. // SetStartDate sets the "start_date" field.
  22555. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  22556. m.start_date = &t
  22557. }
  22558. // StartDate returns the value of the "start_date" field in the mutation.
  22559. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  22560. v := m.start_date
  22561. if v == nil {
  22562. return
  22563. }
  22564. return *v, true
  22565. }
  22566. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  22567. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22569. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  22570. if !m.op.Is(OpUpdateOne) {
  22571. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  22572. }
  22573. if m.id == nil || m.oldValue == nil {
  22574. return v, errors.New("OldStartDate requires an ID field in the mutation")
  22575. }
  22576. oldValue, err := m.oldValue(ctx)
  22577. if err != nil {
  22578. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  22579. }
  22580. return oldValue.StartDate, nil
  22581. }
  22582. // ResetStartDate resets all changes to the "start_date" field.
  22583. func (m *WorkExperienceMutation) ResetStartDate() {
  22584. m.start_date = nil
  22585. }
  22586. // SetEndDate sets the "end_date" field.
  22587. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  22588. m.end_date = &t
  22589. }
  22590. // EndDate returns the value of the "end_date" field in the mutation.
  22591. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  22592. v := m.end_date
  22593. if v == nil {
  22594. return
  22595. }
  22596. return *v, true
  22597. }
  22598. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  22599. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22601. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  22602. if !m.op.Is(OpUpdateOne) {
  22603. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  22604. }
  22605. if m.id == nil || m.oldValue == nil {
  22606. return v, errors.New("OldEndDate requires an ID field in the mutation")
  22607. }
  22608. oldValue, err := m.oldValue(ctx)
  22609. if err != nil {
  22610. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  22611. }
  22612. return oldValue.EndDate, nil
  22613. }
  22614. // ResetEndDate resets all changes to the "end_date" field.
  22615. func (m *WorkExperienceMutation) ResetEndDate() {
  22616. m.end_date = nil
  22617. }
  22618. // SetCompany sets the "company" field.
  22619. func (m *WorkExperienceMutation) SetCompany(s string) {
  22620. m.company = &s
  22621. }
  22622. // Company returns the value of the "company" field in the mutation.
  22623. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  22624. v := m.company
  22625. if v == nil {
  22626. return
  22627. }
  22628. return *v, true
  22629. }
  22630. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  22631. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22633. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  22634. if !m.op.Is(OpUpdateOne) {
  22635. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  22636. }
  22637. if m.id == nil || m.oldValue == nil {
  22638. return v, errors.New("OldCompany requires an ID field in the mutation")
  22639. }
  22640. oldValue, err := m.oldValue(ctx)
  22641. if err != nil {
  22642. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  22643. }
  22644. return oldValue.Company, nil
  22645. }
  22646. // ResetCompany resets all changes to the "company" field.
  22647. func (m *WorkExperienceMutation) ResetCompany() {
  22648. m.company = nil
  22649. }
  22650. // SetExperience sets the "experience" field.
  22651. func (m *WorkExperienceMutation) SetExperience(s string) {
  22652. m.experience = &s
  22653. }
  22654. // Experience returns the value of the "experience" field in the mutation.
  22655. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  22656. v := m.experience
  22657. if v == nil {
  22658. return
  22659. }
  22660. return *v, true
  22661. }
  22662. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  22663. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22665. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  22666. if !m.op.Is(OpUpdateOne) {
  22667. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  22668. }
  22669. if m.id == nil || m.oldValue == nil {
  22670. return v, errors.New("OldExperience requires an ID field in the mutation")
  22671. }
  22672. oldValue, err := m.oldValue(ctx)
  22673. if err != nil {
  22674. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  22675. }
  22676. return oldValue.Experience, nil
  22677. }
  22678. // ResetExperience resets all changes to the "experience" field.
  22679. func (m *WorkExperienceMutation) ResetExperience() {
  22680. m.experience = nil
  22681. }
  22682. // SetOrganizationID sets the "organization_id" field.
  22683. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  22684. m.organization_id = &u
  22685. m.addorganization_id = nil
  22686. }
  22687. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22688. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  22689. v := m.organization_id
  22690. if v == nil {
  22691. return
  22692. }
  22693. return *v, true
  22694. }
  22695. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  22696. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22698. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22699. if !m.op.Is(OpUpdateOne) {
  22700. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22701. }
  22702. if m.id == nil || m.oldValue == nil {
  22703. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22704. }
  22705. oldValue, err := m.oldValue(ctx)
  22706. if err != nil {
  22707. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22708. }
  22709. return oldValue.OrganizationID, nil
  22710. }
  22711. // AddOrganizationID adds u to the "organization_id" field.
  22712. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  22713. if m.addorganization_id != nil {
  22714. *m.addorganization_id += u
  22715. } else {
  22716. m.addorganization_id = &u
  22717. }
  22718. }
  22719. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22720. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  22721. v := m.addorganization_id
  22722. if v == nil {
  22723. return
  22724. }
  22725. return *v, true
  22726. }
  22727. // ResetOrganizationID resets all changes to the "organization_id" field.
  22728. func (m *WorkExperienceMutation) ResetOrganizationID() {
  22729. m.organization_id = nil
  22730. m.addorganization_id = nil
  22731. }
  22732. // ClearEmployee clears the "employee" edge to the Employee entity.
  22733. func (m *WorkExperienceMutation) ClearEmployee() {
  22734. m.clearedemployee = true
  22735. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  22736. }
  22737. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  22738. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  22739. return m.clearedemployee
  22740. }
  22741. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  22742. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22743. // EmployeeID instead. It exists only for internal usage by the builders.
  22744. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  22745. if id := m.employee; id != nil {
  22746. ids = append(ids, *id)
  22747. }
  22748. return
  22749. }
  22750. // ResetEmployee resets all changes to the "employee" edge.
  22751. func (m *WorkExperienceMutation) ResetEmployee() {
  22752. m.employee = nil
  22753. m.clearedemployee = false
  22754. }
  22755. // Where appends a list predicates to the WorkExperienceMutation builder.
  22756. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  22757. m.predicates = append(m.predicates, ps...)
  22758. }
  22759. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  22760. // users can use type-assertion to append predicates that do not depend on any generated package.
  22761. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  22762. p := make([]predicate.WorkExperience, len(ps))
  22763. for i := range ps {
  22764. p[i] = ps[i]
  22765. }
  22766. m.Where(p...)
  22767. }
  22768. // Op returns the operation name.
  22769. func (m *WorkExperienceMutation) Op() Op {
  22770. return m.op
  22771. }
  22772. // SetOp allows setting the mutation operation.
  22773. func (m *WorkExperienceMutation) SetOp(op Op) {
  22774. m.op = op
  22775. }
  22776. // Type returns the node type of this mutation (WorkExperience).
  22777. func (m *WorkExperienceMutation) Type() string {
  22778. return m.typ
  22779. }
  22780. // Fields returns all fields that were changed during this mutation. Note that in
  22781. // order to get all numeric fields that were incremented/decremented, call
  22782. // AddedFields().
  22783. func (m *WorkExperienceMutation) Fields() []string {
  22784. fields := make([]string, 0, 9)
  22785. if m.created_at != nil {
  22786. fields = append(fields, workexperience.FieldCreatedAt)
  22787. }
  22788. if m.updated_at != nil {
  22789. fields = append(fields, workexperience.FieldUpdatedAt)
  22790. }
  22791. if m.deleted_at != nil {
  22792. fields = append(fields, workexperience.FieldDeletedAt)
  22793. }
  22794. if m.employee != nil {
  22795. fields = append(fields, workexperience.FieldEmployeeID)
  22796. }
  22797. if m.start_date != nil {
  22798. fields = append(fields, workexperience.FieldStartDate)
  22799. }
  22800. if m.end_date != nil {
  22801. fields = append(fields, workexperience.FieldEndDate)
  22802. }
  22803. if m.company != nil {
  22804. fields = append(fields, workexperience.FieldCompany)
  22805. }
  22806. if m.experience != nil {
  22807. fields = append(fields, workexperience.FieldExperience)
  22808. }
  22809. if m.organization_id != nil {
  22810. fields = append(fields, workexperience.FieldOrganizationID)
  22811. }
  22812. return fields
  22813. }
  22814. // Field returns the value of a field with the given name. The second boolean
  22815. // return value indicates that this field was not set, or was not defined in the
  22816. // schema.
  22817. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  22818. switch name {
  22819. case workexperience.FieldCreatedAt:
  22820. return m.CreatedAt()
  22821. case workexperience.FieldUpdatedAt:
  22822. return m.UpdatedAt()
  22823. case workexperience.FieldDeletedAt:
  22824. return m.DeletedAt()
  22825. case workexperience.FieldEmployeeID:
  22826. return m.EmployeeID()
  22827. case workexperience.FieldStartDate:
  22828. return m.StartDate()
  22829. case workexperience.FieldEndDate:
  22830. return m.EndDate()
  22831. case workexperience.FieldCompany:
  22832. return m.Company()
  22833. case workexperience.FieldExperience:
  22834. return m.Experience()
  22835. case workexperience.FieldOrganizationID:
  22836. return m.OrganizationID()
  22837. }
  22838. return nil, false
  22839. }
  22840. // OldField returns the old value of the field from the database. An error is
  22841. // returned if the mutation operation is not UpdateOne, or the query to the
  22842. // database failed.
  22843. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22844. switch name {
  22845. case workexperience.FieldCreatedAt:
  22846. return m.OldCreatedAt(ctx)
  22847. case workexperience.FieldUpdatedAt:
  22848. return m.OldUpdatedAt(ctx)
  22849. case workexperience.FieldDeletedAt:
  22850. return m.OldDeletedAt(ctx)
  22851. case workexperience.FieldEmployeeID:
  22852. return m.OldEmployeeID(ctx)
  22853. case workexperience.FieldStartDate:
  22854. return m.OldStartDate(ctx)
  22855. case workexperience.FieldEndDate:
  22856. return m.OldEndDate(ctx)
  22857. case workexperience.FieldCompany:
  22858. return m.OldCompany(ctx)
  22859. case workexperience.FieldExperience:
  22860. return m.OldExperience(ctx)
  22861. case workexperience.FieldOrganizationID:
  22862. return m.OldOrganizationID(ctx)
  22863. }
  22864. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  22865. }
  22866. // SetField sets the value of a field with the given name. It returns an error if
  22867. // the field is not defined in the schema, or if the type mismatched the field
  22868. // type.
  22869. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  22870. switch name {
  22871. case workexperience.FieldCreatedAt:
  22872. v, ok := value.(time.Time)
  22873. if !ok {
  22874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22875. }
  22876. m.SetCreatedAt(v)
  22877. return nil
  22878. case workexperience.FieldUpdatedAt:
  22879. v, ok := value.(time.Time)
  22880. if !ok {
  22881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22882. }
  22883. m.SetUpdatedAt(v)
  22884. return nil
  22885. case workexperience.FieldDeletedAt:
  22886. v, ok := value.(time.Time)
  22887. if !ok {
  22888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22889. }
  22890. m.SetDeletedAt(v)
  22891. return nil
  22892. case workexperience.FieldEmployeeID:
  22893. v, ok := value.(uint64)
  22894. if !ok {
  22895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22896. }
  22897. m.SetEmployeeID(v)
  22898. return nil
  22899. case workexperience.FieldStartDate:
  22900. v, ok := value.(time.Time)
  22901. if !ok {
  22902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22903. }
  22904. m.SetStartDate(v)
  22905. return nil
  22906. case workexperience.FieldEndDate:
  22907. v, ok := value.(time.Time)
  22908. if !ok {
  22909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22910. }
  22911. m.SetEndDate(v)
  22912. return nil
  22913. case workexperience.FieldCompany:
  22914. v, ok := value.(string)
  22915. if !ok {
  22916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22917. }
  22918. m.SetCompany(v)
  22919. return nil
  22920. case workexperience.FieldExperience:
  22921. v, ok := value.(string)
  22922. if !ok {
  22923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22924. }
  22925. m.SetExperience(v)
  22926. return nil
  22927. case workexperience.FieldOrganizationID:
  22928. v, ok := value.(uint64)
  22929. if !ok {
  22930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22931. }
  22932. m.SetOrganizationID(v)
  22933. return nil
  22934. }
  22935. return fmt.Errorf("unknown WorkExperience field %s", name)
  22936. }
  22937. // AddedFields returns all numeric fields that were incremented/decremented during
  22938. // this mutation.
  22939. func (m *WorkExperienceMutation) AddedFields() []string {
  22940. var fields []string
  22941. if m.addorganization_id != nil {
  22942. fields = append(fields, workexperience.FieldOrganizationID)
  22943. }
  22944. return fields
  22945. }
  22946. // AddedField returns the numeric value that was incremented/decremented on a field
  22947. // with the given name. The second boolean return value indicates that this field
  22948. // was not set, or was not defined in the schema.
  22949. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  22950. switch name {
  22951. case workexperience.FieldOrganizationID:
  22952. return m.AddedOrganizationID()
  22953. }
  22954. return nil, false
  22955. }
  22956. // AddField adds the value to the field with the given name. It returns an error if
  22957. // the field is not defined in the schema, or if the type mismatched the field
  22958. // type.
  22959. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  22960. switch name {
  22961. case workexperience.FieldOrganizationID:
  22962. v, ok := value.(int64)
  22963. if !ok {
  22964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22965. }
  22966. m.AddOrganizationID(v)
  22967. return nil
  22968. }
  22969. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  22970. }
  22971. // ClearedFields returns all nullable fields that were cleared during this
  22972. // mutation.
  22973. func (m *WorkExperienceMutation) ClearedFields() []string {
  22974. var fields []string
  22975. if m.FieldCleared(workexperience.FieldDeletedAt) {
  22976. fields = append(fields, workexperience.FieldDeletedAt)
  22977. }
  22978. return fields
  22979. }
  22980. // FieldCleared returns a boolean indicating if a field with the given name was
  22981. // cleared in this mutation.
  22982. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  22983. _, ok := m.clearedFields[name]
  22984. return ok
  22985. }
  22986. // ClearField clears the value of the field with the given name. It returns an
  22987. // error if the field is not defined in the schema.
  22988. func (m *WorkExperienceMutation) ClearField(name string) error {
  22989. switch name {
  22990. case workexperience.FieldDeletedAt:
  22991. m.ClearDeletedAt()
  22992. return nil
  22993. }
  22994. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  22995. }
  22996. // ResetField resets all changes in the mutation for the field with the given name.
  22997. // It returns an error if the field is not defined in the schema.
  22998. func (m *WorkExperienceMutation) ResetField(name string) error {
  22999. switch name {
  23000. case workexperience.FieldCreatedAt:
  23001. m.ResetCreatedAt()
  23002. return nil
  23003. case workexperience.FieldUpdatedAt:
  23004. m.ResetUpdatedAt()
  23005. return nil
  23006. case workexperience.FieldDeletedAt:
  23007. m.ResetDeletedAt()
  23008. return nil
  23009. case workexperience.FieldEmployeeID:
  23010. m.ResetEmployeeID()
  23011. return nil
  23012. case workexperience.FieldStartDate:
  23013. m.ResetStartDate()
  23014. return nil
  23015. case workexperience.FieldEndDate:
  23016. m.ResetEndDate()
  23017. return nil
  23018. case workexperience.FieldCompany:
  23019. m.ResetCompany()
  23020. return nil
  23021. case workexperience.FieldExperience:
  23022. m.ResetExperience()
  23023. return nil
  23024. case workexperience.FieldOrganizationID:
  23025. m.ResetOrganizationID()
  23026. return nil
  23027. }
  23028. return fmt.Errorf("unknown WorkExperience field %s", name)
  23029. }
  23030. // AddedEdges returns all edge names that were set/added in this mutation.
  23031. func (m *WorkExperienceMutation) AddedEdges() []string {
  23032. edges := make([]string, 0, 1)
  23033. if m.employee != nil {
  23034. edges = append(edges, workexperience.EdgeEmployee)
  23035. }
  23036. return edges
  23037. }
  23038. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23039. // name in this mutation.
  23040. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  23041. switch name {
  23042. case workexperience.EdgeEmployee:
  23043. if id := m.employee; id != nil {
  23044. return []ent.Value{*id}
  23045. }
  23046. }
  23047. return nil
  23048. }
  23049. // RemovedEdges returns all edge names that were removed in this mutation.
  23050. func (m *WorkExperienceMutation) RemovedEdges() []string {
  23051. edges := make([]string, 0, 1)
  23052. return edges
  23053. }
  23054. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23055. // the given name in this mutation.
  23056. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  23057. return nil
  23058. }
  23059. // ClearedEdges returns all edge names that were cleared in this mutation.
  23060. func (m *WorkExperienceMutation) ClearedEdges() []string {
  23061. edges := make([]string, 0, 1)
  23062. if m.clearedemployee {
  23063. edges = append(edges, workexperience.EdgeEmployee)
  23064. }
  23065. return edges
  23066. }
  23067. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23068. // was cleared in this mutation.
  23069. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  23070. switch name {
  23071. case workexperience.EdgeEmployee:
  23072. return m.clearedemployee
  23073. }
  23074. return false
  23075. }
  23076. // ClearEdge clears the value of the edge with the given name. It returns an error
  23077. // if that edge is not defined in the schema.
  23078. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  23079. switch name {
  23080. case workexperience.EdgeEmployee:
  23081. m.ClearEmployee()
  23082. return nil
  23083. }
  23084. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  23085. }
  23086. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23087. // It returns an error if the edge is not defined in the schema.
  23088. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  23089. switch name {
  23090. case workexperience.EdgeEmployee:
  23091. m.ResetEmployee()
  23092. return nil
  23093. }
  23094. return fmt.Errorf("unknown WorkExperience edge %s", name)
  23095. }
  23096. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  23097. type WxMutation struct {
  23098. config
  23099. op Op
  23100. typ string
  23101. id *uint64
  23102. created_at *time.Time
  23103. updated_at *time.Time
  23104. status *uint8
  23105. addstatus *int8
  23106. deleted_at *time.Time
  23107. port *string
  23108. process_id *string
  23109. callback *string
  23110. wxid *string
  23111. account *string
  23112. nickname *string
  23113. tel *string
  23114. head_big *string
  23115. organization_id *uint64
  23116. addorganization_id *int64
  23117. api_base *string
  23118. api_key *string
  23119. allow_list *[]string
  23120. appendallow_list []string
  23121. group_allow_list *[]string
  23122. appendgroup_allow_list []string
  23123. block_list *[]string
  23124. appendblock_list []string
  23125. group_block_list *[]string
  23126. appendgroup_block_list []string
  23127. clearedFields map[string]struct{}
  23128. server *uint64
  23129. clearedserver bool
  23130. agent *uint64
  23131. clearedagent bool
  23132. done bool
  23133. oldValue func(context.Context) (*Wx, error)
  23134. predicates []predicate.Wx
  23135. }
  23136. var _ ent.Mutation = (*WxMutation)(nil)
  23137. // wxOption allows management of the mutation configuration using functional options.
  23138. type wxOption func(*WxMutation)
  23139. // newWxMutation creates new mutation for the Wx entity.
  23140. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  23141. m := &WxMutation{
  23142. config: c,
  23143. op: op,
  23144. typ: TypeWx,
  23145. clearedFields: make(map[string]struct{}),
  23146. }
  23147. for _, opt := range opts {
  23148. opt(m)
  23149. }
  23150. return m
  23151. }
  23152. // withWxID sets the ID field of the mutation.
  23153. func withWxID(id uint64) wxOption {
  23154. return func(m *WxMutation) {
  23155. var (
  23156. err error
  23157. once sync.Once
  23158. value *Wx
  23159. )
  23160. m.oldValue = func(ctx context.Context) (*Wx, error) {
  23161. once.Do(func() {
  23162. if m.done {
  23163. err = errors.New("querying old values post mutation is not allowed")
  23164. } else {
  23165. value, err = m.Client().Wx.Get(ctx, id)
  23166. }
  23167. })
  23168. return value, err
  23169. }
  23170. m.id = &id
  23171. }
  23172. }
  23173. // withWx sets the old Wx of the mutation.
  23174. func withWx(node *Wx) wxOption {
  23175. return func(m *WxMutation) {
  23176. m.oldValue = func(context.Context) (*Wx, error) {
  23177. return node, nil
  23178. }
  23179. m.id = &node.ID
  23180. }
  23181. }
  23182. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23183. // executed in a transaction (ent.Tx), a transactional client is returned.
  23184. func (m WxMutation) Client() *Client {
  23185. client := &Client{config: m.config}
  23186. client.init()
  23187. return client
  23188. }
  23189. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23190. // it returns an error otherwise.
  23191. func (m WxMutation) Tx() (*Tx, error) {
  23192. if _, ok := m.driver.(*txDriver); !ok {
  23193. return nil, errors.New("ent: mutation is not running in a transaction")
  23194. }
  23195. tx := &Tx{config: m.config}
  23196. tx.init()
  23197. return tx, nil
  23198. }
  23199. // SetID sets the value of the id field. Note that this
  23200. // operation is only accepted on creation of Wx entities.
  23201. func (m *WxMutation) SetID(id uint64) {
  23202. m.id = &id
  23203. }
  23204. // ID returns the ID value in the mutation. Note that the ID is only available
  23205. // if it was provided to the builder or after it was returned from the database.
  23206. func (m *WxMutation) ID() (id uint64, exists bool) {
  23207. if m.id == nil {
  23208. return
  23209. }
  23210. return *m.id, true
  23211. }
  23212. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23213. // That means, if the mutation is applied within a transaction with an isolation level such
  23214. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23215. // or updated by the mutation.
  23216. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  23217. switch {
  23218. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23219. id, exists := m.ID()
  23220. if exists {
  23221. return []uint64{id}, nil
  23222. }
  23223. fallthrough
  23224. case m.op.Is(OpUpdate | OpDelete):
  23225. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  23226. default:
  23227. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23228. }
  23229. }
  23230. // SetCreatedAt sets the "created_at" field.
  23231. func (m *WxMutation) SetCreatedAt(t time.Time) {
  23232. m.created_at = &t
  23233. }
  23234. // CreatedAt returns the value of the "created_at" field in the mutation.
  23235. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  23236. v := m.created_at
  23237. if v == nil {
  23238. return
  23239. }
  23240. return *v, true
  23241. }
  23242. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  23243. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23245. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23246. if !m.op.Is(OpUpdateOne) {
  23247. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23248. }
  23249. if m.id == nil || m.oldValue == nil {
  23250. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23251. }
  23252. oldValue, err := m.oldValue(ctx)
  23253. if err != nil {
  23254. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23255. }
  23256. return oldValue.CreatedAt, nil
  23257. }
  23258. // ResetCreatedAt resets all changes to the "created_at" field.
  23259. func (m *WxMutation) ResetCreatedAt() {
  23260. m.created_at = nil
  23261. }
  23262. // SetUpdatedAt sets the "updated_at" field.
  23263. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  23264. m.updated_at = &t
  23265. }
  23266. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23267. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  23268. v := m.updated_at
  23269. if v == nil {
  23270. return
  23271. }
  23272. return *v, true
  23273. }
  23274. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  23275. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23277. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23278. if !m.op.Is(OpUpdateOne) {
  23279. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23280. }
  23281. if m.id == nil || m.oldValue == nil {
  23282. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23283. }
  23284. oldValue, err := m.oldValue(ctx)
  23285. if err != nil {
  23286. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23287. }
  23288. return oldValue.UpdatedAt, nil
  23289. }
  23290. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23291. func (m *WxMutation) ResetUpdatedAt() {
  23292. m.updated_at = nil
  23293. }
  23294. // SetStatus sets the "status" field.
  23295. func (m *WxMutation) SetStatus(u uint8) {
  23296. m.status = &u
  23297. m.addstatus = nil
  23298. }
  23299. // Status returns the value of the "status" field in the mutation.
  23300. func (m *WxMutation) Status() (r uint8, exists bool) {
  23301. v := m.status
  23302. if v == nil {
  23303. return
  23304. }
  23305. return *v, true
  23306. }
  23307. // OldStatus returns the old "status" field's value of the Wx entity.
  23308. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23310. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23311. if !m.op.Is(OpUpdateOne) {
  23312. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23313. }
  23314. if m.id == nil || m.oldValue == nil {
  23315. return v, errors.New("OldStatus requires an ID field in the mutation")
  23316. }
  23317. oldValue, err := m.oldValue(ctx)
  23318. if err != nil {
  23319. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23320. }
  23321. return oldValue.Status, nil
  23322. }
  23323. // AddStatus adds u to the "status" field.
  23324. func (m *WxMutation) AddStatus(u int8) {
  23325. if m.addstatus != nil {
  23326. *m.addstatus += u
  23327. } else {
  23328. m.addstatus = &u
  23329. }
  23330. }
  23331. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23332. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  23333. v := m.addstatus
  23334. if v == nil {
  23335. return
  23336. }
  23337. return *v, true
  23338. }
  23339. // ClearStatus clears the value of the "status" field.
  23340. func (m *WxMutation) ClearStatus() {
  23341. m.status = nil
  23342. m.addstatus = nil
  23343. m.clearedFields[wx.FieldStatus] = struct{}{}
  23344. }
  23345. // StatusCleared returns if the "status" field was cleared in this mutation.
  23346. func (m *WxMutation) StatusCleared() bool {
  23347. _, ok := m.clearedFields[wx.FieldStatus]
  23348. return ok
  23349. }
  23350. // ResetStatus resets all changes to the "status" field.
  23351. func (m *WxMutation) ResetStatus() {
  23352. m.status = nil
  23353. m.addstatus = nil
  23354. delete(m.clearedFields, wx.FieldStatus)
  23355. }
  23356. // SetDeletedAt sets the "deleted_at" field.
  23357. func (m *WxMutation) SetDeletedAt(t time.Time) {
  23358. m.deleted_at = &t
  23359. }
  23360. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23361. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  23362. v := m.deleted_at
  23363. if v == nil {
  23364. return
  23365. }
  23366. return *v, true
  23367. }
  23368. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  23369. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23371. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23372. if !m.op.Is(OpUpdateOne) {
  23373. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23374. }
  23375. if m.id == nil || m.oldValue == nil {
  23376. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23377. }
  23378. oldValue, err := m.oldValue(ctx)
  23379. if err != nil {
  23380. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23381. }
  23382. return oldValue.DeletedAt, nil
  23383. }
  23384. // ClearDeletedAt clears the value of the "deleted_at" field.
  23385. func (m *WxMutation) ClearDeletedAt() {
  23386. m.deleted_at = nil
  23387. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  23388. }
  23389. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23390. func (m *WxMutation) DeletedAtCleared() bool {
  23391. _, ok := m.clearedFields[wx.FieldDeletedAt]
  23392. return ok
  23393. }
  23394. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23395. func (m *WxMutation) ResetDeletedAt() {
  23396. m.deleted_at = nil
  23397. delete(m.clearedFields, wx.FieldDeletedAt)
  23398. }
  23399. // SetServerID sets the "server_id" field.
  23400. func (m *WxMutation) SetServerID(u uint64) {
  23401. m.server = &u
  23402. }
  23403. // ServerID returns the value of the "server_id" field in the mutation.
  23404. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  23405. v := m.server
  23406. if v == nil {
  23407. return
  23408. }
  23409. return *v, true
  23410. }
  23411. // OldServerID returns the old "server_id" field's value of the Wx entity.
  23412. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23414. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  23415. if !m.op.Is(OpUpdateOne) {
  23416. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  23417. }
  23418. if m.id == nil || m.oldValue == nil {
  23419. return v, errors.New("OldServerID requires an ID field in the mutation")
  23420. }
  23421. oldValue, err := m.oldValue(ctx)
  23422. if err != nil {
  23423. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  23424. }
  23425. return oldValue.ServerID, nil
  23426. }
  23427. // ClearServerID clears the value of the "server_id" field.
  23428. func (m *WxMutation) ClearServerID() {
  23429. m.server = nil
  23430. m.clearedFields[wx.FieldServerID] = struct{}{}
  23431. }
  23432. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  23433. func (m *WxMutation) ServerIDCleared() bool {
  23434. _, ok := m.clearedFields[wx.FieldServerID]
  23435. return ok
  23436. }
  23437. // ResetServerID resets all changes to the "server_id" field.
  23438. func (m *WxMutation) ResetServerID() {
  23439. m.server = nil
  23440. delete(m.clearedFields, wx.FieldServerID)
  23441. }
  23442. // SetPort sets the "port" field.
  23443. func (m *WxMutation) SetPort(s string) {
  23444. m.port = &s
  23445. }
  23446. // Port returns the value of the "port" field in the mutation.
  23447. func (m *WxMutation) Port() (r string, exists bool) {
  23448. v := m.port
  23449. if v == nil {
  23450. return
  23451. }
  23452. return *v, true
  23453. }
  23454. // OldPort returns the old "port" field's value of the Wx entity.
  23455. // If the Wx 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 *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  23458. if !m.op.Is(OpUpdateOne) {
  23459. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  23460. }
  23461. if m.id == nil || m.oldValue == nil {
  23462. return v, errors.New("OldPort 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 OldPort: %w", err)
  23467. }
  23468. return oldValue.Port, nil
  23469. }
  23470. // ResetPort resets all changes to the "port" field.
  23471. func (m *WxMutation) ResetPort() {
  23472. m.port = nil
  23473. }
  23474. // SetProcessID sets the "process_id" field.
  23475. func (m *WxMutation) SetProcessID(s string) {
  23476. m.process_id = &s
  23477. }
  23478. // ProcessID returns the value of the "process_id" field in the mutation.
  23479. func (m *WxMutation) ProcessID() (r string, exists bool) {
  23480. v := m.process_id
  23481. if v == nil {
  23482. return
  23483. }
  23484. return *v, true
  23485. }
  23486. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  23487. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23489. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  23490. if !m.op.Is(OpUpdateOne) {
  23491. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  23492. }
  23493. if m.id == nil || m.oldValue == nil {
  23494. return v, errors.New("OldProcessID requires an ID field in the mutation")
  23495. }
  23496. oldValue, err := m.oldValue(ctx)
  23497. if err != nil {
  23498. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  23499. }
  23500. return oldValue.ProcessID, nil
  23501. }
  23502. // ResetProcessID resets all changes to the "process_id" field.
  23503. func (m *WxMutation) ResetProcessID() {
  23504. m.process_id = nil
  23505. }
  23506. // SetCallback sets the "callback" field.
  23507. func (m *WxMutation) SetCallback(s string) {
  23508. m.callback = &s
  23509. }
  23510. // Callback returns the value of the "callback" field in the mutation.
  23511. func (m *WxMutation) Callback() (r string, exists bool) {
  23512. v := m.callback
  23513. if v == nil {
  23514. return
  23515. }
  23516. return *v, true
  23517. }
  23518. // OldCallback returns the old "callback" field's value of the Wx entity.
  23519. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23521. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  23522. if !m.op.Is(OpUpdateOne) {
  23523. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  23524. }
  23525. if m.id == nil || m.oldValue == nil {
  23526. return v, errors.New("OldCallback requires an ID field in the mutation")
  23527. }
  23528. oldValue, err := m.oldValue(ctx)
  23529. if err != nil {
  23530. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  23531. }
  23532. return oldValue.Callback, nil
  23533. }
  23534. // ResetCallback resets all changes to the "callback" field.
  23535. func (m *WxMutation) ResetCallback() {
  23536. m.callback = nil
  23537. }
  23538. // SetWxid sets the "wxid" field.
  23539. func (m *WxMutation) SetWxid(s string) {
  23540. m.wxid = &s
  23541. }
  23542. // Wxid returns the value of the "wxid" field in the mutation.
  23543. func (m *WxMutation) Wxid() (r string, exists bool) {
  23544. v := m.wxid
  23545. if v == nil {
  23546. return
  23547. }
  23548. return *v, true
  23549. }
  23550. // OldWxid returns the old "wxid" field's value of the Wx entity.
  23551. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23553. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  23554. if !m.op.Is(OpUpdateOne) {
  23555. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  23556. }
  23557. if m.id == nil || m.oldValue == nil {
  23558. return v, errors.New("OldWxid requires an ID field in the mutation")
  23559. }
  23560. oldValue, err := m.oldValue(ctx)
  23561. if err != nil {
  23562. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  23563. }
  23564. return oldValue.Wxid, nil
  23565. }
  23566. // ResetWxid resets all changes to the "wxid" field.
  23567. func (m *WxMutation) ResetWxid() {
  23568. m.wxid = nil
  23569. }
  23570. // SetAccount sets the "account" field.
  23571. func (m *WxMutation) SetAccount(s string) {
  23572. m.account = &s
  23573. }
  23574. // Account returns the value of the "account" field in the mutation.
  23575. func (m *WxMutation) Account() (r string, exists bool) {
  23576. v := m.account
  23577. if v == nil {
  23578. return
  23579. }
  23580. return *v, true
  23581. }
  23582. // OldAccount returns the old "account" field's value of the Wx entity.
  23583. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23585. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  23586. if !m.op.Is(OpUpdateOne) {
  23587. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  23588. }
  23589. if m.id == nil || m.oldValue == nil {
  23590. return v, errors.New("OldAccount requires an ID field in the mutation")
  23591. }
  23592. oldValue, err := m.oldValue(ctx)
  23593. if err != nil {
  23594. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  23595. }
  23596. return oldValue.Account, nil
  23597. }
  23598. // ResetAccount resets all changes to the "account" field.
  23599. func (m *WxMutation) ResetAccount() {
  23600. m.account = nil
  23601. }
  23602. // SetNickname sets the "nickname" field.
  23603. func (m *WxMutation) SetNickname(s string) {
  23604. m.nickname = &s
  23605. }
  23606. // Nickname returns the value of the "nickname" field in the mutation.
  23607. func (m *WxMutation) Nickname() (r string, exists bool) {
  23608. v := m.nickname
  23609. if v == nil {
  23610. return
  23611. }
  23612. return *v, true
  23613. }
  23614. // OldNickname returns the old "nickname" field's value of the Wx entity.
  23615. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23617. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  23618. if !m.op.Is(OpUpdateOne) {
  23619. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  23620. }
  23621. if m.id == nil || m.oldValue == nil {
  23622. return v, errors.New("OldNickname requires an ID field in the mutation")
  23623. }
  23624. oldValue, err := m.oldValue(ctx)
  23625. if err != nil {
  23626. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  23627. }
  23628. return oldValue.Nickname, nil
  23629. }
  23630. // ResetNickname resets all changes to the "nickname" field.
  23631. func (m *WxMutation) ResetNickname() {
  23632. m.nickname = nil
  23633. }
  23634. // SetTel sets the "tel" field.
  23635. func (m *WxMutation) SetTel(s string) {
  23636. m.tel = &s
  23637. }
  23638. // Tel returns the value of the "tel" field in the mutation.
  23639. func (m *WxMutation) Tel() (r string, exists bool) {
  23640. v := m.tel
  23641. if v == nil {
  23642. return
  23643. }
  23644. return *v, true
  23645. }
  23646. // OldTel returns the old "tel" field's value of the Wx entity.
  23647. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23649. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  23650. if !m.op.Is(OpUpdateOne) {
  23651. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  23652. }
  23653. if m.id == nil || m.oldValue == nil {
  23654. return v, errors.New("OldTel requires an ID field in the mutation")
  23655. }
  23656. oldValue, err := m.oldValue(ctx)
  23657. if err != nil {
  23658. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  23659. }
  23660. return oldValue.Tel, nil
  23661. }
  23662. // ResetTel resets all changes to the "tel" field.
  23663. func (m *WxMutation) ResetTel() {
  23664. m.tel = nil
  23665. }
  23666. // SetHeadBig sets the "head_big" field.
  23667. func (m *WxMutation) SetHeadBig(s string) {
  23668. m.head_big = &s
  23669. }
  23670. // HeadBig returns the value of the "head_big" field in the mutation.
  23671. func (m *WxMutation) HeadBig() (r string, exists bool) {
  23672. v := m.head_big
  23673. if v == nil {
  23674. return
  23675. }
  23676. return *v, true
  23677. }
  23678. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  23679. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23681. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  23682. if !m.op.Is(OpUpdateOne) {
  23683. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  23684. }
  23685. if m.id == nil || m.oldValue == nil {
  23686. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  23687. }
  23688. oldValue, err := m.oldValue(ctx)
  23689. if err != nil {
  23690. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  23691. }
  23692. return oldValue.HeadBig, nil
  23693. }
  23694. // ResetHeadBig resets all changes to the "head_big" field.
  23695. func (m *WxMutation) ResetHeadBig() {
  23696. m.head_big = nil
  23697. }
  23698. // SetOrganizationID sets the "organization_id" field.
  23699. func (m *WxMutation) SetOrganizationID(u uint64) {
  23700. m.organization_id = &u
  23701. m.addorganization_id = nil
  23702. }
  23703. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23704. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  23705. v := m.organization_id
  23706. if v == nil {
  23707. return
  23708. }
  23709. return *v, true
  23710. }
  23711. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  23712. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23714. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23715. if !m.op.Is(OpUpdateOne) {
  23716. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23717. }
  23718. if m.id == nil || m.oldValue == nil {
  23719. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23720. }
  23721. oldValue, err := m.oldValue(ctx)
  23722. if err != nil {
  23723. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23724. }
  23725. return oldValue.OrganizationID, nil
  23726. }
  23727. // AddOrganizationID adds u to the "organization_id" field.
  23728. func (m *WxMutation) AddOrganizationID(u int64) {
  23729. if m.addorganization_id != nil {
  23730. *m.addorganization_id += u
  23731. } else {
  23732. m.addorganization_id = &u
  23733. }
  23734. }
  23735. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23736. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  23737. v := m.addorganization_id
  23738. if v == nil {
  23739. return
  23740. }
  23741. return *v, true
  23742. }
  23743. // ClearOrganizationID clears the value of the "organization_id" field.
  23744. func (m *WxMutation) ClearOrganizationID() {
  23745. m.organization_id = nil
  23746. m.addorganization_id = nil
  23747. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  23748. }
  23749. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  23750. func (m *WxMutation) OrganizationIDCleared() bool {
  23751. _, ok := m.clearedFields[wx.FieldOrganizationID]
  23752. return ok
  23753. }
  23754. // ResetOrganizationID resets all changes to the "organization_id" field.
  23755. func (m *WxMutation) ResetOrganizationID() {
  23756. m.organization_id = nil
  23757. m.addorganization_id = nil
  23758. delete(m.clearedFields, wx.FieldOrganizationID)
  23759. }
  23760. // SetAgentID sets the "agent_id" field.
  23761. func (m *WxMutation) SetAgentID(u uint64) {
  23762. m.agent = &u
  23763. }
  23764. // AgentID returns the value of the "agent_id" field in the mutation.
  23765. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  23766. v := m.agent
  23767. if v == nil {
  23768. return
  23769. }
  23770. return *v, true
  23771. }
  23772. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  23773. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23775. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  23776. if !m.op.Is(OpUpdateOne) {
  23777. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  23778. }
  23779. if m.id == nil || m.oldValue == nil {
  23780. return v, errors.New("OldAgentID requires an ID field in the mutation")
  23781. }
  23782. oldValue, err := m.oldValue(ctx)
  23783. if err != nil {
  23784. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  23785. }
  23786. return oldValue.AgentID, nil
  23787. }
  23788. // ResetAgentID resets all changes to the "agent_id" field.
  23789. func (m *WxMutation) ResetAgentID() {
  23790. m.agent = nil
  23791. }
  23792. // SetAPIBase sets the "api_base" field.
  23793. func (m *WxMutation) SetAPIBase(s string) {
  23794. m.api_base = &s
  23795. }
  23796. // APIBase returns the value of the "api_base" field in the mutation.
  23797. func (m *WxMutation) APIBase() (r string, exists bool) {
  23798. v := m.api_base
  23799. if v == nil {
  23800. return
  23801. }
  23802. return *v, true
  23803. }
  23804. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  23805. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23807. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  23808. if !m.op.Is(OpUpdateOne) {
  23809. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  23810. }
  23811. if m.id == nil || m.oldValue == nil {
  23812. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  23813. }
  23814. oldValue, err := m.oldValue(ctx)
  23815. if err != nil {
  23816. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  23817. }
  23818. return oldValue.APIBase, nil
  23819. }
  23820. // ClearAPIBase clears the value of the "api_base" field.
  23821. func (m *WxMutation) ClearAPIBase() {
  23822. m.api_base = nil
  23823. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  23824. }
  23825. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  23826. func (m *WxMutation) APIBaseCleared() bool {
  23827. _, ok := m.clearedFields[wx.FieldAPIBase]
  23828. return ok
  23829. }
  23830. // ResetAPIBase resets all changes to the "api_base" field.
  23831. func (m *WxMutation) ResetAPIBase() {
  23832. m.api_base = nil
  23833. delete(m.clearedFields, wx.FieldAPIBase)
  23834. }
  23835. // SetAPIKey sets the "api_key" field.
  23836. func (m *WxMutation) SetAPIKey(s string) {
  23837. m.api_key = &s
  23838. }
  23839. // APIKey returns the value of the "api_key" field in the mutation.
  23840. func (m *WxMutation) APIKey() (r string, exists bool) {
  23841. v := m.api_key
  23842. if v == nil {
  23843. return
  23844. }
  23845. return *v, true
  23846. }
  23847. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  23848. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23850. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  23851. if !m.op.Is(OpUpdateOne) {
  23852. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  23853. }
  23854. if m.id == nil || m.oldValue == nil {
  23855. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  23856. }
  23857. oldValue, err := m.oldValue(ctx)
  23858. if err != nil {
  23859. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  23860. }
  23861. return oldValue.APIKey, nil
  23862. }
  23863. // ClearAPIKey clears the value of the "api_key" field.
  23864. func (m *WxMutation) ClearAPIKey() {
  23865. m.api_key = nil
  23866. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  23867. }
  23868. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  23869. func (m *WxMutation) APIKeyCleared() bool {
  23870. _, ok := m.clearedFields[wx.FieldAPIKey]
  23871. return ok
  23872. }
  23873. // ResetAPIKey resets all changes to the "api_key" field.
  23874. func (m *WxMutation) ResetAPIKey() {
  23875. m.api_key = nil
  23876. delete(m.clearedFields, wx.FieldAPIKey)
  23877. }
  23878. // SetAllowList sets the "allow_list" field.
  23879. func (m *WxMutation) SetAllowList(s []string) {
  23880. m.allow_list = &s
  23881. m.appendallow_list = nil
  23882. }
  23883. // AllowList returns the value of the "allow_list" field in the mutation.
  23884. func (m *WxMutation) AllowList() (r []string, exists bool) {
  23885. v := m.allow_list
  23886. if v == nil {
  23887. return
  23888. }
  23889. return *v, true
  23890. }
  23891. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  23892. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23894. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  23895. if !m.op.Is(OpUpdateOne) {
  23896. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  23897. }
  23898. if m.id == nil || m.oldValue == nil {
  23899. return v, errors.New("OldAllowList requires an ID field in the mutation")
  23900. }
  23901. oldValue, err := m.oldValue(ctx)
  23902. if err != nil {
  23903. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  23904. }
  23905. return oldValue.AllowList, nil
  23906. }
  23907. // AppendAllowList adds s to the "allow_list" field.
  23908. func (m *WxMutation) AppendAllowList(s []string) {
  23909. m.appendallow_list = append(m.appendallow_list, s...)
  23910. }
  23911. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  23912. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  23913. if len(m.appendallow_list) == 0 {
  23914. return nil, false
  23915. }
  23916. return m.appendallow_list, true
  23917. }
  23918. // ResetAllowList resets all changes to the "allow_list" field.
  23919. func (m *WxMutation) ResetAllowList() {
  23920. m.allow_list = nil
  23921. m.appendallow_list = nil
  23922. }
  23923. // SetGroupAllowList sets the "group_allow_list" field.
  23924. func (m *WxMutation) SetGroupAllowList(s []string) {
  23925. m.group_allow_list = &s
  23926. m.appendgroup_allow_list = nil
  23927. }
  23928. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  23929. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  23930. v := m.group_allow_list
  23931. if v == nil {
  23932. return
  23933. }
  23934. return *v, true
  23935. }
  23936. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  23937. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23939. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  23940. if !m.op.Is(OpUpdateOne) {
  23941. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  23942. }
  23943. if m.id == nil || m.oldValue == nil {
  23944. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  23945. }
  23946. oldValue, err := m.oldValue(ctx)
  23947. if err != nil {
  23948. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  23949. }
  23950. return oldValue.GroupAllowList, nil
  23951. }
  23952. // AppendGroupAllowList adds s to the "group_allow_list" field.
  23953. func (m *WxMutation) AppendGroupAllowList(s []string) {
  23954. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  23955. }
  23956. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  23957. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  23958. if len(m.appendgroup_allow_list) == 0 {
  23959. return nil, false
  23960. }
  23961. return m.appendgroup_allow_list, true
  23962. }
  23963. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  23964. func (m *WxMutation) ResetGroupAllowList() {
  23965. m.group_allow_list = nil
  23966. m.appendgroup_allow_list = nil
  23967. }
  23968. // SetBlockList sets the "block_list" field.
  23969. func (m *WxMutation) SetBlockList(s []string) {
  23970. m.block_list = &s
  23971. m.appendblock_list = nil
  23972. }
  23973. // BlockList returns the value of the "block_list" field in the mutation.
  23974. func (m *WxMutation) BlockList() (r []string, exists bool) {
  23975. v := m.block_list
  23976. if v == nil {
  23977. return
  23978. }
  23979. return *v, true
  23980. }
  23981. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  23982. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23984. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  23985. if !m.op.Is(OpUpdateOne) {
  23986. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  23987. }
  23988. if m.id == nil || m.oldValue == nil {
  23989. return v, errors.New("OldBlockList requires an ID field in the mutation")
  23990. }
  23991. oldValue, err := m.oldValue(ctx)
  23992. if err != nil {
  23993. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  23994. }
  23995. return oldValue.BlockList, nil
  23996. }
  23997. // AppendBlockList adds s to the "block_list" field.
  23998. func (m *WxMutation) AppendBlockList(s []string) {
  23999. m.appendblock_list = append(m.appendblock_list, s...)
  24000. }
  24001. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  24002. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  24003. if len(m.appendblock_list) == 0 {
  24004. return nil, false
  24005. }
  24006. return m.appendblock_list, true
  24007. }
  24008. // ResetBlockList resets all changes to the "block_list" field.
  24009. func (m *WxMutation) ResetBlockList() {
  24010. m.block_list = nil
  24011. m.appendblock_list = nil
  24012. }
  24013. // SetGroupBlockList sets the "group_block_list" field.
  24014. func (m *WxMutation) SetGroupBlockList(s []string) {
  24015. m.group_block_list = &s
  24016. m.appendgroup_block_list = nil
  24017. }
  24018. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  24019. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  24020. v := m.group_block_list
  24021. if v == nil {
  24022. return
  24023. }
  24024. return *v, true
  24025. }
  24026. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  24027. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  24028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24029. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  24030. if !m.op.Is(OpUpdateOne) {
  24031. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  24032. }
  24033. if m.id == nil || m.oldValue == nil {
  24034. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  24035. }
  24036. oldValue, err := m.oldValue(ctx)
  24037. if err != nil {
  24038. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  24039. }
  24040. return oldValue.GroupBlockList, nil
  24041. }
  24042. // AppendGroupBlockList adds s to the "group_block_list" field.
  24043. func (m *WxMutation) AppendGroupBlockList(s []string) {
  24044. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  24045. }
  24046. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  24047. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  24048. if len(m.appendgroup_block_list) == 0 {
  24049. return nil, false
  24050. }
  24051. return m.appendgroup_block_list, true
  24052. }
  24053. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  24054. func (m *WxMutation) ResetGroupBlockList() {
  24055. m.group_block_list = nil
  24056. m.appendgroup_block_list = nil
  24057. }
  24058. // ClearServer clears the "server" edge to the Server entity.
  24059. func (m *WxMutation) ClearServer() {
  24060. m.clearedserver = true
  24061. m.clearedFields[wx.FieldServerID] = struct{}{}
  24062. }
  24063. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  24064. func (m *WxMutation) ServerCleared() bool {
  24065. return m.ServerIDCleared() || m.clearedserver
  24066. }
  24067. // ServerIDs returns the "server" edge IDs in the mutation.
  24068. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24069. // ServerID instead. It exists only for internal usage by the builders.
  24070. func (m *WxMutation) ServerIDs() (ids []uint64) {
  24071. if id := m.server; id != nil {
  24072. ids = append(ids, *id)
  24073. }
  24074. return
  24075. }
  24076. // ResetServer resets all changes to the "server" edge.
  24077. func (m *WxMutation) ResetServer() {
  24078. m.server = nil
  24079. m.clearedserver = false
  24080. }
  24081. // ClearAgent clears the "agent" edge to the Agent entity.
  24082. func (m *WxMutation) ClearAgent() {
  24083. m.clearedagent = true
  24084. m.clearedFields[wx.FieldAgentID] = struct{}{}
  24085. }
  24086. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  24087. func (m *WxMutation) AgentCleared() bool {
  24088. return m.clearedagent
  24089. }
  24090. // AgentIDs returns the "agent" edge IDs in the mutation.
  24091. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24092. // AgentID instead. It exists only for internal usage by the builders.
  24093. func (m *WxMutation) AgentIDs() (ids []uint64) {
  24094. if id := m.agent; id != nil {
  24095. ids = append(ids, *id)
  24096. }
  24097. return
  24098. }
  24099. // ResetAgent resets all changes to the "agent" edge.
  24100. func (m *WxMutation) ResetAgent() {
  24101. m.agent = nil
  24102. m.clearedagent = false
  24103. }
  24104. // Where appends a list predicates to the WxMutation builder.
  24105. func (m *WxMutation) Where(ps ...predicate.Wx) {
  24106. m.predicates = append(m.predicates, ps...)
  24107. }
  24108. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  24109. // users can use type-assertion to append predicates that do not depend on any generated package.
  24110. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  24111. p := make([]predicate.Wx, len(ps))
  24112. for i := range ps {
  24113. p[i] = ps[i]
  24114. }
  24115. m.Where(p...)
  24116. }
  24117. // Op returns the operation name.
  24118. func (m *WxMutation) Op() Op {
  24119. return m.op
  24120. }
  24121. // SetOp allows setting the mutation operation.
  24122. func (m *WxMutation) SetOp(op Op) {
  24123. m.op = op
  24124. }
  24125. // Type returns the node type of this mutation (Wx).
  24126. func (m *WxMutation) Type() string {
  24127. return m.typ
  24128. }
  24129. // Fields returns all fields that were changed during this mutation. Note that in
  24130. // order to get all numeric fields that were incremented/decremented, call
  24131. // AddedFields().
  24132. func (m *WxMutation) Fields() []string {
  24133. fields := make([]string, 0, 21)
  24134. if m.created_at != nil {
  24135. fields = append(fields, wx.FieldCreatedAt)
  24136. }
  24137. if m.updated_at != nil {
  24138. fields = append(fields, wx.FieldUpdatedAt)
  24139. }
  24140. if m.status != nil {
  24141. fields = append(fields, wx.FieldStatus)
  24142. }
  24143. if m.deleted_at != nil {
  24144. fields = append(fields, wx.FieldDeletedAt)
  24145. }
  24146. if m.server != nil {
  24147. fields = append(fields, wx.FieldServerID)
  24148. }
  24149. if m.port != nil {
  24150. fields = append(fields, wx.FieldPort)
  24151. }
  24152. if m.process_id != nil {
  24153. fields = append(fields, wx.FieldProcessID)
  24154. }
  24155. if m.callback != nil {
  24156. fields = append(fields, wx.FieldCallback)
  24157. }
  24158. if m.wxid != nil {
  24159. fields = append(fields, wx.FieldWxid)
  24160. }
  24161. if m.account != nil {
  24162. fields = append(fields, wx.FieldAccount)
  24163. }
  24164. if m.nickname != nil {
  24165. fields = append(fields, wx.FieldNickname)
  24166. }
  24167. if m.tel != nil {
  24168. fields = append(fields, wx.FieldTel)
  24169. }
  24170. if m.head_big != nil {
  24171. fields = append(fields, wx.FieldHeadBig)
  24172. }
  24173. if m.organization_id != nil {
  24174. fields = append(fields, wx.FieldOrganizationID)
  24175. }
  24176. if m.agent != nil {
  24177. fields = append(fields, wx.FieldAgentID)
  24178. }
  24179. if m.api_base != nil {
  24180. fields = append(fields, wx.FieldAPIBase)
  24181. }
  24182. if m.api_key != nil {
  24183. fields = append(fields, wx.FieldAPIKey)
  24184. }
  24185. if m.allow_list != nil {
  24186. fields = append(fields, wx.FieldAllowList)
  24187. }
  24188. if m.group_allow_list != nil {
  24189. fields = append(fields, wx.FieldGroupAllowList)
  24190. }
  24191. if m.block_list != nil {
  24192. fields = append(fields, wx.FieldBlockList)
  24193. }
  24194. if m.group_block_list != nil {
  24195. fields = append(fields, wx.FieldGroupBlockList)
  24196. }
  24197. return fields
  24198. }
  24199. // Field returns the value of a field with the given name. The second boolean
  24200. // return value indicates that this field was not set, or was not defined in the
  24201. // schema.
  24202. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  24203. switch name {
  24204. case wx.FieldCreatedAt:
  24205. return m.CreatedAt()
  24206. case wx.FieldUpdatedAt:
  24207. return m.UpdatedAt()
  24208. case wx.FieldStatus:
  24209. return m.Status()
  24210. case wx.FieldDeletedAt:
  24211. return m.DeletedAt()
  24212. case wx.FieldServerID:
  24213. return m.ServerID()
  24214. case wx.FieldPort:
  24215. return m.Port()
  24216. case wx.FieldProcessID:
  24217. return m.ProcessID()
  24218. case wx.FieldCallback:
  24219. return m.Callback()
  24220. case wx.FieldWxid:
  24221. return m.Wxid()
  24222. case wx.FieldAccount:
  24223. return m.Account()
  24224. case wx.FieldNickname:
  24225. return m.Nickname()
  24226. case wx.FieldTel:
  24227. return m.Tel()
  24228. case wx.FieldHeadBig:
  24229. return m.HeadBig()
  24230. case wx.FieldOrganizationID:
  24231. return m.OrganizationID()
  24232. case wx.FieldAgentID:
  24233. return m.AgentID()
  24234. case wx.FieldAPIBase:
  24235. return m.APIBase()
  24236. case wx.FieldAPIKey:
  24237. return m.APIKey()
  24238. case wx.FieldAllowList:
  24239. return m.AllowList()
  24240. case wx.FieldGroupAllowList:
  24241. return m.GroupAllowList()
  24242. case wx.FieldBlockList:
  24243. return m.BlockList()
  24244. case wx.FieldGroupBlockList:
  24245. return m.GroupBlockList()
  24246. }
  24247. return nil, false
  24248. }
  24249. // OldField returns the old value of the field from the database. An error is
  24250. // returned if the mutation operation is not UpdateOne, or the query to the
  24251. // database failed.
  24252. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24253. switch name {
  24254. case wx.FieldCreatedAt:
  24255. return m.OldCreatedAt(ctx)
  24256. case wx.FieldUpdatedAt:
  24257. return m.OldUpdatedAt(ctx)
  24258. case wx.FieldStatus:
  24259. return m.OldStatus(ctx)
  24260. case wx.FieldDeletedAt:
  24261. return m.OldDeletedAt(ctx)
  24262. case wx.FieldServerID:
  24263. return m.OldServerID(ctx)
  24264. case wx.FieldPort:
  24265. return m.OldPort(ctx)
  24266. case wx.FieldProcessID:
  24267. return m.OldProcessID(ctx)
  24268. case wx.FieldCallback:
  24269. return m.OldCallback(ctx)
  24270. case wx.FieldWxid:
  24271. return m.OldWxid(ctx)
  24272. case wx.FieldAccount:
  24273. return m.OldAccount(ctx)
  24274. case wx.FieldNickname:
  24275. return m.OldNickname(ctx)
  24276. case wx.FieldTel:
  24277. return m.OldTel(ctx)
  24278. case wx.FieldHeadBig:
  24279. return m.OldHeadBig(ctx)
  24280. case wx.FieldOrganizationID:
  24281. return m.OldOrganizationID(ctx)
  24282. case wx.FieldAgentID:
  24283. return m.OldAgentID(ctx)
  24284. case wx.FieldAPIBase:
  24285. return m.OldAPIBase(ctx)
  24286. case wx.FieldAPIKey:
  24287. return m.OldAPIKey(ctx)
  24288. case wx.FieldAllowList:
  24289. return m.OldAllowList(ctx)
  24290. case wx.FieldGroupAllowList:
  24291. return m.OldGroupAllowList(ctx)
  24292. case wx.FieldBlockList:
  24293. return m.OldBlockList(ctx)
  24294. case wx.FieldGroupBlockList:
  24295. return m.OldGroupBlockList(ctx)
  24296. }
  24297. return nil, fmt.Errorf("unknown Wx field %s", name)
  24298. }
  24299. // SetField sets the value of a field with the given name. It returns an error if
  24300. // the field is not defined in the schema, or if the type mismatched the field
  24301. // type.
  24302. func (m *WxMutation) SetField(name string, value ent.Value) error {
  24303. switch name {
  24304. case wx.FieldCreatedAt:
  24305. v, ok := value.(time.Time)
  24306. if !ok {
  24307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24308. }
  24309. m.SetCreatedAt(v)
  24310. return nil
  24311. case wx.FieldUpdatedAt:
  24312. v, ok := value.(time.Time)
  24313. if !ok {
  24314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24315. }
  24316. m.SetUpdatedAt(v)
  24317. return nil
  24318. case wx.FieldStatus:
  24319. v, ok := value.(uint8)
  24320. if !ok {
  24321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24322. }
  24323. m.SetStatus(v)
  24324. return nil
  24325. case wx.FieldDeletedAt:
  24326. v, ok := value.(time.Time)
  24327. if !ok {
  24328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24329. }
  24330. m.SetDeletedAt(v)
  24331. return nil
  24332. case wx.FieldServerID:
  24333. v, ok := value.(uint64)
  24334. if !ok {
  24335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24336. }
  24337. m.SetServerID(v)
  24338. return nil
  24339. case wx.FieldPort:
  24340. v, ok := value.(string)
  24341. if !ok {
  24342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24343. }
  24344. m.SetPort(v)
  24345. return nil
  24346. case wx.FieldProcessID:
  24347. v, ok := value.(string)
  24348. if !ok {
  24349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24350. }
  24351. m.SetProcessID(v)
  24352. return nil
  24353. case wx.FieldCallback:
  24354. v, ok := value.(string)
  24355. if !ok {
  24356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24357. }
  24358. m.SetCallback(v)
  24359. return nil
  24360. case wx.FieldWxid:
  24361. v, ok := value.(string)
  24362. if !ok {
  24363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24364. }
  24365. m.SetWxid(v)
  24366. return nil
  24367. case wx.FieldAccount:
  24368. v, ok := value.(string)
  24369. if !ok {
  24370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24371. }
  24372. m.SetAccount(v)
  24373. return nil
  24374. case wx.FieldNickname:
  24375. v, ok := value.(string)
  24376. if !ok {
  24377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24378. }
  24379. m.SetNickname(v)
  24380. return nil
  24381. case wx.FieldTel:
  24382. v, ok := value.(string)
  24383. if !ok {
  24384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24385. }
  24386. m.SetTel(v)
  24387. return nil
  24388. case wx.FieldHeadBig:
  24389. v, ok := value.(string)
  24390. if !ok {
  24391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24392. }
  24393. m.SetHeadBig(v)
  24394. return nil
  24395. case wx.FieldOrganizationID:
  24396. v, ok := value.(uint64)
  24397. if !ok {
  24398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24399. }
  24400. m.SetOrganizationID(v)
  24401. return nil
  24402. case wx.FieldAgentID:
  24403. v, ok := value.(uint64)
  24404. if !ok {
  24405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24406. }
  24407. m.SetAgentID(v)
  24408. return nil
  24409. case wx.FieldAPIBase:
  24410. v, ok := value.(string)
  24411. if !ok {
  24412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24413. }
  24414. m.SetAPIBase(v)
  24415. return nil
  24416. case wx.FieldAPIKey:
  24417. v, ok := value.(string)
  24418. if !ok {
  24419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24420. }
  24421. m.SetAPIKey(v)
  24422. return nil
  24423. case wx.FieldAllowList:
  24424. v, ok := value.([]string)
  24425. if !ok {
  24426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24427. }
  24428. m.SetAllowList(v)
  24429. return nil
  24430. case wx.FieldGroupAllowList:
  24431. v, ok := value.([]string)
  24432. if !ok {
  24433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24434. }
  24435. m.SetGroupAllowList(v)
  24436. return nil
  24437. case wx.FieldBlockList:
  24438. v, ok := value.([]string)
  24439. if !ok {
  24440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24441. }
  24442. m.SetBlockList(v)
  24443. return nil
  24444. case wx.FieldGroupBlockList:
  24445. v, ok := value.([]string)
  24446. if !ok {
  24447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24448. }
  24449. m.SetGroupBlockList(v)
  24450. return nil
  24451. }
  24452. return fmt.Errorf("unknown Wx field %s", name)
  24453. }
  24454. // AddedFields returns all numeric fields that were incremented/decremented during
  24455. // this mutation.
  24456. func (m *WxMutation) AddedFields() []string {
  24457. var fields []string
  24458. if m.addstatus != nil {
  24459. fields = append(fields, wx.FieldStatus)
  24460. }
  24461. if m.addorganization_id != nil {
  24462. fields = append(fields, wx.FieldOrganizationID)
  24463. }
  24464. return fields
  24465. }
  24466. // AddedField returns the numeric value that was incremented/decremented on a field
  24467. // with the given name. The second boolean return value indicates that this field
  24468. // was not set, or was not defined in the schema.
  24469. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  24470. switch name {
  24471. case wx.FieldStatus:
  24472. return m.AddedStatus()
  24473. case wx.FieldOrganizationID:
  24474. return m.AddedOrganizationID()
  24475. }
  24476. return nil, false
  24477. }
  24478. // AddField adds the value to the field with the given name. It returns an error if
  24479. // the field is not defined in the schema, or if the type mismatched the field
  24480. // type.
  24481. func (m *WxMutation) AddField(name string, value ent.Value) error {
  24482. switch name {
  24483. case wx.FieldStatus:
  24484. v, ok := value.(int8)
  24485. if !ok {
  24486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24487. }
  24488. m.AddStatus(v)
  24489. return nil
  24490. case wx.FieldOrganizationID:
  24491. v, ok := value.(int64)
  24492. if !ok {
  24493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24494. }
  24495. m.AddOrganizationID(v)
  24496. return nil
  24497. }
  24498. return fmt.Errorf("unknown Wx numeric field %s", name)
  24499. }
  24500. // ClearedFields returns all nullable fields that were cleared during this
  24501. // mutation.
  24502. func (m *WxMutation) ClearedFields() []string {
  24503. var fields []string
  24504. if m.FieldCleared(wx.FieldStatus) {
  24505. fields = append(fields, wx.FieldStatus)
  24506. }
  24507. if m.FieldCleared(wx.FieldDeletedAt) {
  24508. fields = append(fields, wx.FieldDeletedAt)
  24509. }
  24510. if m.FieldCleared(wx.FieldServerID) {
  24511. fields = append(fields, wx.FieldServerID)
  24512. }
  24513. if m.FieldCleared(wx.FieldOrganizationID) {
  24514. fields = append(fields, wx.FieldOrganizationID)
  24515. }
  24516. if m.FieldCleared(wx.FieldAPIBase) {
  24517. fields = append(fields, wx.FieldAPIBase)
  24518. }
  24519. if m.FieldCleared(wx.FieldAPIKey) {
  24520. fields = append(fields, wx.FieldAPIKey)
  24521. }
  24522. return fields
  24523. }
  24524. // FieldCleared returns a boolean indicating if a field with the given name was
  24525. // cleared in this mutation.
  24526. func (m *WxMutation) FieldCleared(name string) bool {
  24527. _, ok := m.clearedFields[name]
  24528. return ok
  24529. }
  24530. // ClearField clears the value of the field with the given name. It returns an
  24531. // error if the field is not defined in the schema.
  24532. func (m *WxMutation) ClearField(name string) error {
  24533. switch name {
  24534. case wx.FieldStatus:
  24535. m.ClearStatus()
  24536. return nil
  24537. case wx.FieldDeletedAt:
  24538. m.ClearDeletedAt()
  24539. return nil
  24540. case wx.FieldServerID:
  24541. m.ClearServerID()
  24542. return nil
  24543. case wx.FieldOrganizationID:
  24544. m.ClearOrganizationID()
  24545. return nil
  24546. case wx.FieldAPIBase:
  24547. m.ClearAPIBase()
  24548. return nil
  24549. case wx.FieldAPIKey:
  24550. m.ClearAPIKey()
  24551. return nil
  24552. }
  24553. return fmt.Errorf("unknown Wx nullable field %s", name)
  24554. }
  24555. // ResetField resets all changes in the mutation for the field with the given name.
  24556. // It returns an error if the field is not defined in the schema.
  24557. func (m *WxMutation) ResetField(name string) error {
  24558. switch name {
  24559. case wx.FieldCreatedAt:
  24560. m.ResetCreatedAt()
  24561. return nil
  24562. case wx.FieldUpdatedAt:
  24563. m.ResetUpdatedAt()
  24564. return nil
  24565. case wx.FieldStatus:
  24566. m.ResetStatus()
  24567. return nil
  24568. case wx.FieldDeletedAt:
  24569. m.ResetDeletedAt()
  24570. return nil
  24571. case wx.FieldServerID:
  24572. m.ResetServerID()
  24573. return nil
  24574. case wx.FieldPort:
  24575. m.ResetPort()
  24576. return nil
  24577. case wx.FieldProcessID:
  24578. m.ResetProcessID()
  24579. return nil
  24580. case wx.FieldCallback:
  24581. m.ResetCallback()
  24582. return nil
  24583. case wx.FieldWxid:
  24584. m.ResetWxid()
  24585. return nil
  24586. case wx.FieldAccount:
  24587. m.ResetAccount()
  24588. return nil
  24589. case wx.FieldNickname:
  24590. m.ResetNickname()
  24591. return nil
  24592. case wx.FieldTel:
  24593. m.ResetTel()
  24594. return nil
  24595. case wx.FieldHeadBig:
  24596. m.ResetHeadBig()
  24597. return nil
  24598. case wx.FieldOrganizationID:
  24599. m.ResetOrganizationID()
  24600. return nil
  24601. case wx.FieldAgentID:
  24602. m.ResetAgentID()
  24603. return nil
  24604. case wx.FieldAPIBase:
  24605. m.ResetAPIBase()
  24606. return nil
  24607. case wx.FieldAPIKey:
  24608. m.ResetAPIKey()
  24609. return nil
  24610. case wx.FieldAllowList:
  24611. m.ResetAllowList()
  24612. return nil
  24613. case wx.FieldGroupAllowList:
  24614. m.ResetGroupAllowList()
  24615. return nil
  24616. case wx.FieldBlockList:
  24617. m.ResetBlockList()
  24618. return nil
  24619. case wx.FieldGroupBlockList:
  24620. m.ResetGroupBlockList()
  24621. return nil
  24622. }
  24623. return fmt.Errorf("unknown Wx field %s", name)
  24624. }
  24625. // AddedEdges returns all edge names that were set/added in this mutation.
  24626. func (m *WxMutation) AddedEdges() []string {
  24627. edges := make([]string, 0, 2)
  24628. if m.server != nil {
  24629. edges = append(edges, wx.EdgeServer)
  24630. }
  24631. if m.agent != nil {
  24632. edges = append(edges, wx.EdgeAgent)
  24633. }
  24634. return edges
  24635. }
  24636. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24637. // name in this mutation.
  24638. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  24639. switch name {
  24640. case wx.EdgeServer:
  24641. if id := m.server; id != nil {
  24642. return []ent.Value{*id}
  24643. }
  24644. case wx.EdgeAgent:
  24645. if id := m.agent; id != nil {
  24646. return []ent.Value{*id}
  24647. }
  24648. }
  24649. return nil
  24650. }
  24651. // RemovedEdges returns all edge names that were removed in this mutation.
  24652. func (m *WxMutation) RemovedEdges() []string {
  24653. edges := make([]string, 0, 2)
  24654. return edges
  24655. }
  24656. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24657. // the given name in this mutation.
  24658. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  24659. return nil
  24660. }
  24661. // ClearedEdges returns all edge names that were cleared in this mutation.
  24662. func (m *WxMutation) ClearedEdges() []string {
  24663. edges := make([]string, 0, 2)
  24664. if m.clearedserver {
  24665. edges = append(edges, wx.EdgeServer)
  24666. }
  24667. if m.clearedagent {
  24668. edges = append(edges, wx.EdgeAgent)
  24669. }
  24670. return edges
  24671. }
  24672. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24673. // was cleared in this mutation.
  24674. func (m *WxMutation) EdgeCleared(name string) bool {
  24675. switch name {
  24676. case wx.EdgeServer:
  24677. return m.clearedserver
  24678. case wx.EdgeAgent:
  24679. return m.clearedagent
  24680. }
  24681. return false
  24682. }
  24683. // ClearEdge clears the value of the edge with the given name. It returns an error
  24684. // if that edge is not defined in the schema.
  24685. func (m *WxMutation) ClearEdge(name string) error {
  24686. switch name {
  24687. case wx.EdgeServer:
  24688. m.ClearServer()
  24689. return nil
  24690. case wx.EdgeAgent:
  24691. m.ClearAgent()
  24692. return nil
  24693. }
  24694. return fmt.Errorf("unknown Wx unique edge %s", name)
  24695. }
  24696. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24697. // It returns an error if the edge is not defined in the schema.
  24698. func (m *WxMutation) ResetEdge(name string) error {
  24699. switch name {
  24700. case wx.EdgeServer:
  24701. m.ResetServer()
  24702. return nil
  24703. case wx.EdgeAgent:
  24704. m.ResetAgent()
  24705. return nil
  24706. }
  24707. return fmt.Errorf("unknown Wx edge %s", name)
  24708. }
  24709. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  24710. type WxCardMutation struct {
  24711. config
  24712. op Op
  24713. typ string
  24714. id *uint64
  24715. created_at *time.Time
  24716. updated_at *time.Time
  24717. deleted_at *time.Time
  24718. user_id *uint64
  24719. adduser_id *int64
  24720. wx_user_id *uint64
  24721. addwx_user_id *int64
  24722. avatar *string
  24723. logo *string
  24724. name *string
  24725. company *string
  24726. address *string
  24727. phone *string
  24728. official_account *string
  24729. wechat_account *string
  24730. email *string
  24731. api_base *string
  24732. api_key *string
  24733. ai_info *string
  24734. intro *string
  24735. clearedFields map[string]struct{}
  24736. done bool
  24737. oldValue func(context.Context) (*WxCard, error)
  24738. predicates []predicate.WxCard
  24739. }
  24740. var _ ent.Mutation = (*WxCardMutation)(nil)
  24741. // wxcardOption allows management of the mutation configuration using functional options.
  24742. type wxcardOption func(*WxCardMutation)
  24743. // newWxCardMutation creates new mutation for the WxCard entity.
  24744. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  24745. m := &WxCardMutation{
  24746. config: c,
  24747. op: op,
  24748. typ: TypeWxCard,
  24749. clearedFields: make(map[string]struct{}),
  24750. }
  24751. for _, opt := range opts {
  24752. opt(m)
  24753. }
  24754. return m
  24755. }
  24756. // withWxCardID sets the ID field of the mutation.
  24757. func withWxCardID(id uint64) wxcardOption {
  24758. return func(m *WxCardMutation) {
  24759. var (
  24760. err error
  24761. once sync.Once
  24762. value *WxCard
  24763. )
  24764. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  24765. once.Do(func() {
  24766. if m.done {
  24767. err = errors.New("querying old values post mutation is not allowed")
  24768. } else {
  24769. value, err = m.Client().WxCard.Get(ctx, id)
  24770. }
  24771. })
  24772. return value, err
  24773. }
  24774. m.id = &id
  24775. }
  24776. }
  24777. // withWxCard sets the old WxCard of the mutation.
  24778. func withWxCard(node *WxCard) wxcardOption {
  24779. return func(m *WxCardMutation) {
  24780. m.oldValue = func(context.Context) (*WxCard, error) {
  24781. return node, nil
  24782. }
  24783. m.id = &node.ID
  24784. }
  24785. }
  24786. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24787. // executed in a transaction (ent.Tx), a transactional client is returned.
  24788. func (m WxCardMutation) Client() *Client {
  24789. client := &Client{config: m.config}
  24790. client.init()
  24791. return client
  24792. }
  24793. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24794. // it returns an error otherwise.
  24795. func (m WxCardMutation) Tx() (*Tx, error) {
  24796. if _, ok := m.driver.(*txDriver); !ok {
  24797. return nil, errors.New("ent: mutation is not running in a transaction")
  24798. }
  24799. tx := &Tx{config: m.config}
  24800. tx.init()
  24801. return tx, nil
  24802. }
  24803. // SetID sets the value of the id field. Note that this
  24804. // operation is only accepted on creation of WxCard entities.
  24805. func (m *WxCardMutation) SetID(id uint64) {
  24806. m.id = &id
  24807. }
  24808. // ID returns the ID value in the mutation. Note that the ID is only available
  24809. // if it was provided to the builder or after it was returned from the database.
  24810. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  24811. if m.id == nil {
  24812. return
  24813. }
  24814. return *m.id, true
  24815. }
  24816. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24817. // That means, if the mutation is applied within a transaction with an isolation level such
  24818. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24819. // or updated by the mutation.
  24820. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  24821. switch {
  24822. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24823. id, exists := m.ID()
  24824. if exists {
  24825. return []uint64{id}, nil
  24826. }
  24827. fallthrough
  24828. case m.op.Is(OpUpdate | OpDelete):
  24829. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  24830. default:
  24831. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24832. }
  24833. }
  24834. // SetCreatedAt sets the "created_at" field.
  24835. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  24836. m.created_at = &t
  24837. }
  24838. // CreatedAt returns the value of the "created_at" field in the mutation.
  24839. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  24840. v := m.created_at
  24841. if v == nil {
  24842. return
  24843. }
  24844. return *v, true
  24845. }
  24846. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  24847. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24849. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24850. if !m.op.Is(OpUpdateOne) {
  24851. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24852. }
  24853. if m.id == nil || m.oldValue == nil {
  24854. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24855. }
  24856. oldValue, err := m.oldValue(ctx)
  24857. if err != nil {
  24858. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24859. }
  24860. return oldValue.CreatedAt, nil
  24861. }
  24862. // ResetCreatedAt resets all changes to the "created_at" field.
  24863. func (m *WxCardMutation) ResetCreatedAt() {
  24864. m.created_at = nil
  24865. }
  24866. // SetUpdatedAt sets the "updated_at" field.
  24867. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  24868. m.updated_at = &t
  24869. }
  24870. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24871. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  24872. v := m.updated_at
  24873. if v == nil {
  24874. return
  24875. }
  24876. return *v, true
  24877. }
  24878. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  24879. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24881. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24882. if !m.op.Is(OpUpdateOne) {
  24883. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24884. }
  24885. if m.id == nil || m.oldValue == nil {
  24886. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24887. }
  24888. oldValue, err := m.oldValue(ctx)
  24889. if err != nil {
  24890. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24891. }
  24892. return oldValue.UpdatedAt, nil
  24893. }
  24894. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24895. func (m *WxCardMutation) ResetUpdatedAt() {
  24896. m.updated_at = nil
  24897. }
  24898. // SetDeletedAt sets the "deleted_at" field.
  24899. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  24900. m.deleted_at = &t
  24901. }
  24902. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24903. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  24904. v := m.deleted_at
  24905. if v == nil {
  24906. return
  24907. }
  24908. return *v, true
  24909. }
  24910. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  24911. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24913. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24914. if !m.op.Is(OpUpdateOne) {
  24915. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24916. }
  24917. if m.id == nil || m.oldValue == nil {
  24918. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24919. }
  24920. oldValue, err := m.oldValue(ctx)
  24921. if err != nil {
  24922. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24923. }
  24924. return oldValue.DeletedAt, nil
  24925. }
  24926. // ClearDeletedAt clears the value of the "deleted_at" field.
  24927. func (m *WxCardMutation) ClearDeletedAt() {
  24928. m.deleted_at = nil
  24929. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  24930. }
  24931. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24932. func (m *WxCardMutation) DeletedAtCleared() bool {
  24933. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  24934. return ok
  24935. }
  24936. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24937. func (m *WxCardMutation) ResetDeletedAt() {
  24938. m.deleted_at = nil
  24939. delete(m.clearedFields, wxcard.FieldDeletedAt)
  24940. }
  24941. // SetUserID sets the "user_id" field.
  24942. func (m *WxCardMutation) SetUserID(u uint64) {
  24943. m.user_id = &u
  24944. m.adduser_id = nil
  24945. }
  24946. // UserID returns the value of the "user_id" field in the mutation.
  24947. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  24948. v := m.user_id
  24949. if v == nil {
  24950. return
  24951. }
  24952. return *v, true
  24953. }
  24954. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  24955. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24957. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  24958. if !m.op.Is(OpUpdateOne) {
  24959. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  24960. }
  24961. if m.id == nil || m.oldValue == nil {
  24962. return v, errors.New("OldUserID requires an ID field in the mutation")
  24963. }
  24964. oldValue, err := m.oldValue(ctx)
  24965. if err != nil {
  24966. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  24967. }
  24968. return oldValue.UserID, nil
  24969. }
  24970. // AddUserID adds u to the "user_id" field.
  24971. func (m *WxCardMutation) AddUserID(u int64) {
  24972. if m.adduser_id != nil {
  24973. *m.adduser_id += u
  24974. } else {
  24975. m.adduser_id = &u
  24976. }
  24977. }
  24978. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  24979. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  24980. v := m.adduser_id
  24981. if v == nil {
  24982. return
  24983. }
  24984. return *v, true
  24985. }
  24986. // ClearUserID clears the value of the "user_id" field.
  24987. func (m *WxCardMutation) ClearUserID() {
  24988. m.user_id = nil
  24989. m.adduser_id = nil
  24990. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  24991. }
  24992. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  24993. func (m *WxCardMutation) UserIDCleared() bool {
  24994. _, ok := m.clearedFields[wxcard.FieldUserID]
  24995. return ok
  24996. }
  24997. // ResetUserID resets all changes to the "user_id" field.
  24998. func (m *WxCardMutation) ResetUserID() {
  24999. m.user_id = nil
  25000. m.adduser_id = nil
  25001. delete(m.clearedFields, wxcard.FieldUserID)
  25002. }
  25003. // SetWxUserID sets the "wx_user_id" field.
  25004. func (m *WxCardMutation) SetWxUserID(u uint64) {
  25005. m.wx_user_id = &u
  25006. m.addwx_user_id = nil
  25007. }
  25008. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  25009. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  25010. v := m.wx_user_id
  25011. if v == nil {
  25012. return
  25013. }
  25014. return *v, true
  25015. }
  25016. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  25017. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25019. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  25020. if !m.op.Is(OpUpdateOne) {
  25021. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  25022. }
  25023. if m.id == nil || m.oldValue == nil {
  25024. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  25025. }
  25026. oldValue, err := m.oldValue(ctx)
  25027. if err != nil {
  25028. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  25029. }
  25030. return oldValue.WxUserID, nil
  25031. }
  25032. // AddWxUserID adds u to the "wx_user_id" field.
  25033. func (m *WxCardMutation) AddWxUserID(u int64) {
  25034. if m.addwx_user_id != nil {
  25035. *m.addwx_user_id += u
  25036. } else {
  25037. m.addwx_user_id = &u
  25038. }
  25039. }
  25040. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  25041. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  25042. v := m.addwx_user_id
  25043. if v == nil {
  25044. return
  25045. }
  25046. return *v, true
  25047. }
  25048. // ClearWxUserID clears the value of the "wx_user_id" field.
  25049. func (m *WxCardMutation) ClearWxUserID() {
  25050. m.wx_user_id = nil
  25051. m.addwx_user_id = nil
  25052. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  25053. }
  25054. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  25055. func (m *WxCardMutation) WxUserIDCleared() bool {
  25056. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  25057. return ok
  25058. }
  25059. // ResetWxUserID resets all changes to the "wx_user_id" field.
  25060. func (m *WxCardMutation) ResetWxUserID() {
  25061. m.wx_user_id = nil
  25062. m.addwx_user_id = nil
  25063. delete(m.clearedFields, wxcard.FieldWxUserID)
  25064. }
  25065. // SetAvatar sets the "avatar" field.
  25066. func (m *WxCardMutation) SetAvatar(s string) {
  25067. m.avatar = &s
  25068. }
  25069. // Avatar returns the value of the "avatar" field in the mutation.
  25070. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  25071. v := m.avatar
  25072. if v == nil {
  25073. return
  25074. }
  25075. return *v, true
  25076. }
  25077. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  25078. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25080. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  25081. if !m.op.Is(OpUpdateOne) {
  25082. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  25083. }
  25084. if m.id == nil || m.oldValue == nil {
  25085. return v, errors.New("OldAvatar requires an ID field in the mutation")
  25086. }
  25087. oldValue, err := m.oldValue(ctx)
  25088. if err != nil {
  25089. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  25090. }
  25091. return oldValue.Avatar, nil
  25092. }
  25093. // ResetAvatar resets all changes to the "avatar" field.
  25094. func (m *WxCardMutation) ResetAvatar() {
  25095. m.avatar = nil
  25096. }
  25097. // SetLogo sets the "logo" field.
  25098. func (m *WxCardMutation) SetLogo(s string) {
  25099. m.logo = &s
  25100. }
  25101. // Logo returns the value of the "logo" field in the mutation.
  25102. func (m *WxCardMutation) Logo() (r string, exists bool) {
  25103. v := m.logo
  25104. if v == nil {
  25105. return
  25106. }
  25107. return *v, true
  25108. }
  25109. // OldLogo returns the old "logo" field's value of the WxCard entity.
  25110. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25112. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  25113. if !m.op.Is(OpUpdateOne) {
  25114. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  25115. }
  25116. if m.id == nil || m.oldValue == nil {
  25117. return v, errors.New("OldLogo requires an ID field in the mutation")
  25118. }
  25119. oldValue, err := m.oldValue(ctx)
  25120. if err != nil {
  25121. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  25122. }
  25123. return oldValue.Logo, nil
  25124. }
  25125. // ResetLogo resets all changes to the "logo" field.
  25126. func (m *WxCardMutation) ResetLogo() {
  25127. m.logo = nil
  25128. }
  25129. // SetName sets the "name" field.
  25130. func (m *WxCardMutation) SetName(s string) {
  25131. m.name = &s
  25132. }
  25133. // Name returns the value of the "name" field in the mutation.
  25134. func (m *WxCardMutation) Name() (r string, exists bool) {
  25135. v := m.name
  25136. if v == nil {
  25137. return
  25138. }
  25139. return *v, true
  25140. }
  25141. // OldName returns the old "name" field's value of the WxCard entity.
  25142. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25144. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  25145. if !m.op.Is(OpUpdateOne) {
  25146. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25147. }
  25148. if m.id == nil || m.oldValue == nil {
  25149. return v, errors.New("OldName requires an ID field in the mutation")
  25150. }
  25151. oldValue, err := m.oldValue(ctx)
  25152. if err != nil {
  25153. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25154. }
  25155. return oldValue.Name, nil
  25156. }
  25157. // ResetName resets all changes to the "name" field.
  25158. func (m *WxCardMutation) ResetName() {
  25159. m.name = nil
  25160. }
  25161. // SetCompany sets the "company" field.
  25162. func (m *WxCardMutation) SetCompany(s string) {
  25163. m.company = &s
  25164. }
  25165. // Company returns the value of the "company" field in the mutation.
  25166. func (m *WxCardMutation) Company() (r string, exists bool) {
  25167. v := m.company
  25168. if v == nil {
  25169. return
  25170. }
  25171. return *v, true
  25172. }
  25173. // OldCompany returns the old "company" field's value of the WxCard entity.
  25174. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25176. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  25177. if !m.op.Is(OpUpdateOne) {
  25178. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  25179. }
  25180. if m.id == nil || m.oldValue == nil {
  25181. return v, errors.New("OldCompany requires an ID field in the mutation")
  25182. }
  25183. oldValue, err := m.oldValue(ctx)
  25184. if err != nil {
  25185. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  25186. }
  25187. return oldValue.Company, nil
  25188. }
  25189. // ResetCompany resets all changes to the "company" field.
  25190. func (m *WxCardMutation) ResetCompany() {
  25191. m.company = nil
  25192. }
  25193. // SetAddress sets the "address" field.
  25194. func (m *WxCardMutation) SetAddress(s string) {
  25195. m.address = &s
  25196. }
  25197. // Address returns the value of the "address" field in the mutation.
  25198. func (m *WxCardMutation) Address() (r string, exists bool) {
  25199. v := m.address
  25200. if v == nil {
  25201. return
  25202. }
  25203. return *v, true
  25204. }
  25205. // OldAddress returns the old "address" field's value of the WxCard entity.
  25206. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25208. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  25209. if !m.op.Is(OpUpdateOne) {
  25210. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  25211. }
  25212. if m.id == nil || m.oldValue == nil {
  25213. return v, errors.New("OldAddress requires an ID field in the mutation")
  25214. }
  25215. oldValue, err := m.oldValue(ctx)
  25216. if err != nil {
  25217. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  25218. }
  25219. return oldValue.Address, nil
  25220. }
  25221. // ResetAddress resets all changes to the "address" field.
  25222. func (m *WxCardMutation) ResetAddress() {
  25223. m.address = nil
  25224. }
  25225. // SetPhone sets the "phone" field.
  25226. func (m *WxCardMutation) SetPhone(s string) {
  25227. m.phone = &s
  25228. }
  25229. // Phone returns the value of the "phone" field in the mutation.
  25230. func (m *WxCardMutation) Phone() (r string, exists bool) {
  25231. v := m.phone
  25232. if v == nil {
  25233. return
  25234. }
  25235. return *v, true
  25236. }
  25237. // OldPhone returns the old "phone" field's value of the WxCard entity.
  25238. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25240. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  25241. if !m.op.Is(OpUpdateOne) {
  25242. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  25243. }
  25244. if m.id == nil || m.oldValue == nil {
  25245. return v, errors.New("OldPhone requires an ID field in the mutation")
  25246. }
  25247. oldValue, err := m.oldValue(ctx)
  25248. if err != nil {
  25249. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  25250. }
  25251. return oldValue.Phone, nil
  25252. }
  25253. // ResetPhone resets all changes to the "phone" field.
  25254. func (m *WxCardMutation) ResetPhone() {
  25255. m.phone = nil
  25256. }
  25257. // SetOfficialAccount sets the "official_account" field.
  25258. func (m *WxCardMutation) SetOfficialAccount(s string) {
  25259. m.official_account = &s
  25260. }
  25261. // OfficialAccount returns the value of the "official_account" field in the mutation.
  25262. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  25263. v := m.official_account
  25264. if v == nil {
  25265. return
  25266. }
  25267. return *v, true
  25268. }
  25269. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  25270. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25272. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  25273. if !m.op.Is(OpUpdateOne) {
  25274. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  25275. }
  25276. if m.id == nil || m.oldValue == nil {
  25277. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  25278. }
  25279. oldValue, err := m.oldValue(ctx)
  25280. if err != nil {
  25281. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  25282. }
  25283. return oldValue.OfficialAccount, nil
  25284. }
  25285. // ResetOfficialAccount resets all changes to the "official_account" field.
  25286. func (m *WxCardMutation) ResetOfficialAccount() {
  25287. m.official_account = nil
  25288. }
  25289. // SetWechatAccount sets the "wechat_account" field.
  25290. func (m *WxCardMutation) SetWechatAccount(s string) {
  25291. m.wechat_account = &s
  25292. }
  25293. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  25294. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  25295. v := m.wechat_account
  25296. if v == nil {
  25297. return
  25298. }
  25299. return *v, true
  25300. }
  25301. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  25302. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25304. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  25305. if !m.op.Is(OpUpdateOne) {
  25306. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  25307. }
  25308. if m.id == nil || m.oldValue == nil {
  25309. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  25310. }
  25311. oldValue, err := m.oldValue(ctx)
  25312. if err != nil {
  25313. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  25314. }
  25315. return oldValue.WechatAccount, nil
  25316. }
  25317. // ResetWechatAccount resets all changes to the "wechat_account" field.
  25318. func (m *WxCardMutation) ResetWechatAccount() {
  25319. m.wechat_account = nil
  25320. }
  25321. // SetEmail sets the "email" field.
  25322. func (m *WxCardMutation) SetEmail(s string) {
  25323. m.email = &s
  25324. }
  25325. // Email returns the value of the "email" field in the mutation.
  25326. func (m *WxCardMutation) Email() (r string, exists bool) {
  25327. v := m.email
  25328. if v == nil {
  25329. return
  25330. }
  25331. return *v, true
  25332. }
  25333. // OldEmail returns the old "email" field's value of the WxCard entity.
  25334. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25336. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  25337. if !m.op.Is(OpUpdateOne) {
  25338. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  25339. }
  25340. if m.id == nil || m.oldValue == nil {
  25341. return v, errors.New("OldEmail requires an ID field in the mutation")
  25342. }
  25343. oldValue, err := m.oldValue(ctx)
  25344. if err != nil {
  25345. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  25346. }
  25347. return oldValue.Email, nil
  25348. }
  25349. // ClearEmail clears the value of the "email" field.
  25350. func (m *WxCardMutation) ClearEmail() {
  25351. m.email = nil
  25352. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  25353. }
  25354. // EmailCleared returns if the "email" field was cleared in this mutation.
  25355. func (m *WxCardMutation) EmailCleared() bool {
  25356. _, ok := m.clearedFields[wxcard.FieldEmail]
  25357. return ok
  25358. }
  25359. // ResetEmail resets all changes to the "email" field.
  25360. func (m *WxCardMutation) ResetEmail() {
  25361. m.email = nil
  25362. delete(m.clearedFields, wxcard.FieldEmail)
  25363. }
  25364. // SetAPIBase sets the "api_base" field.
  25365. func (m *WxCardMutation) SetAPIBase(s string) {
  25366. m.api_base = &s
  25367. }
  25368. // APIBase returns the value of the "api_base" field in the mutation.
  25369. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  25370. v := m.api_base
  25371. if v == nil {
  25372. return
  25373. }
  25374. return *v, true
  25375. }
  25376. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  25377. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25379. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  25380. if !m.op.Is(OpUpdateOne) {
  25381. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  25382. }
  25383. if m.id == nil || m.oldValue == nil {
  25384. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  25385. }
  25386. oldValue, err := m.oldValue(ctx)
  25387. if err != nil {
  25388. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  25389. }
  25390. return oldValue.APIBase, nil
  25391. }
  25392. // ClearAPIBase clears the value of the "api_base" field.
  25393. func (m *WxCardMutation) ClearAPIBase() {
  25394. m.api_base = nil
  25395. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  25396. }
  25397. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  25398. func (m *WxCardMutation) APIBaseCleared() bool {
  25399. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  25400. return ok
  25401. }
  25402. // ResetAPIBase resets all changes to the "api_base" field.
  25403. func (m *WxCardMutation) ResetAPIBase() {
  25404. m.api_base = nil
  25405. delete(m.clearedFields, wxcard.FieldAPIBase)
  25406. }
  25407. // SetAPIKey sets the "api_key" field.
  25408. func (m *WxCardMutation) SetAPIKey(s string) {
  25409. m.api_key = &s
  25410. }
  25411. // APIKey returns the value of the "api_key" field in the mutation.
  25412. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  25413. v := m.api_key
  25414. if v == nil {
  25415. return
  25416. }
  25417. return *v, true
  25418. }
  25419. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  25420. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25422. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  25423. if !m.op.Is(OpUpdateOne) {
  25424. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  25425. }
  25426. if m.id == nil || m.oldValue == nil {
  25427. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  25428. }
  25429. oldValue, err := m.oldValue(ctx)
  25430. if err != nil {
  25431. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  25432. }
  25433. return oldValue.APIKey, nil
  25434. }
  25435. // ClearAPIKey clears the value of the "api_key" field.
  25436. func (m *WxCardMutation) ClearAPIKey() {
  25437. m.api_key = nil
  25438. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  25439. }
  25440. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  25441. func (m *WxCardMutation) APIKeyCleared() bool {
  25442. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  25443. return ok
  25444. }
  25445. // ResetAPIKey resets all changes to the "api_key" field.
  25446. func (m *WxCardMutation) ResetAPIKey() {
  25447. m.api_key = nil
  25448. delete(m.clearedFields, wxcard.FieldAPIKey)
  25449. }
  25450. // SetAiInfo sets the "ai_info" field.
  25451. func (m *WxCardMutation) SetAiInfo(s string) {
  25452. m.ai_info = &s
  25453. }
  25454. // AiInfo returns the value of the "ai_info" field in the mutation.
  25455. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  25456. v := m.ai_info
  25457. if v == nil {
  25458. return
  25459. }
  25460. return *v, true
  25461. }
  25462. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  25463. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25465. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  25466. if !m.op.Is(OpUpdateOne) {
  25467. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  25468. }
  25469. if m.id == nil || m.oldValue == nil {
  25470. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  25471. }
  25472. oldValue, err := m.oldValue(ctx)
  25473. if err != nil {
  25474. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  25475. }
  25476. return oldValue.AiInfo, nil
  25477. }
  25478. // ClearAiInfo clears the value of the "ai_info" field.
  25479. func (m *WxCardMutation) ClearAiInfo() {
  25480. m.ai_info = nil
  25481. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  25482. }
  25483. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  25484. func (m *WxCardMutation) AiInfoCleared() bool {
  25485. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  25486. return ok
  25487. }
  25488. // ResetAiInfo resets all changes to the "ai_info" field.
  25489. func (m *WxCardMutation) ResetAiInfo() {
  25490. m.ai_info = nil
  25491. delete(m.clearedFields, wxcard.FieldAiInfo)
  25492. }
  25493. // SetIntro sets the "intro" field.
  25494. func (m *WxCardMutation) SetIntro(s string) {
  25495. m.intro = &s
  25496. }
  25497. // Intro returns the value of the "intro" field in the mutation.
  25498. func (m *WxCardMutation) Intro() (r string, exists bool) {
  25499. v := m.intro
  25500. if v == nil {
  25501. return
  25502. }
  25503. return *v, true
  25504. }
  25505. // OldIntro returns the old "intro" field's value of the WxCard entity.
  25506. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25508. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  25509. if !m.op.Is(OpUpdateOne) {
  25510. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  25511. }
  25512. if m.id == nil || m.oldValue == nil {
  25513. return v, errors.New("OldIntro requires an ID field in the mutation")
  25514. }
  25515. oldValue, err := m.oldValue(ctx)
  25516. if err != nil {
  25517. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  25518. }
  25519. return oldValue.Intro, nil
  25520. }
  25521. // ClearIntro clears the value of the "intro" field.
  25522. func (m *WxCardMutation) ClearIntro() {
  25523. m.intro = nil
  25524. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  25525. }
  25526. // IntroCleared returns if the "intro" field was cleared in this mutation.
  25527. func (m *WxCardMutation) IntroCleared() bool {
  25528. _, ok := m.clearedFields[wxcard.FieldIntro]
  25529. return ok
  25530. }
  25531. // ResetIntro resets all changes to the "intro" field.
  25532. func (m *WxCardMutation) ResetIntro() {
  25533. m.intro = nil
  25534. delete(m.clearedFields, wxcard.FieldIntro)
  25535. }
  25536. // Where appends a list predicates to the WxCardMutation builder.
  25537. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  25538. m.predicates = append(m.predicates, ps...)
  25539. }
  25540. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  25541. // users can use type-assertion to append predicates that do not depend on any generated package.
  25542. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  25543. p := make([]predicate.WxCard, len(ps))
  25544. for i := range ps {
  25545. p[i] = ps[i]
  25546. }
  25547. m.Where(p...)
  25548. }
  25549. // Op returns the operation name.
  25550. func (m *WxCardMutation) Op() Op {
  25551. return m.op
  25552. }
  25553. // SetOp allows setting the mutation operation.
  25554. func (m *WxCardMutation) SetOp(op Op) {
  25555. m.op = op
  25556. }
  25557. // Type returns the node type of this mutation (WxCard).
  25558. func (m *WxCardMutation) Type() string {
  25559. return m.typ
  25560. }
  25561. // Fields returns all fields that were changed during this mutation. Note that in
  25562. // order to get all numeric fields that were incremented/decremented, call
  25563. // AddedFields().
  25564. func (m *WxCardMutation) Fields() []string {
  25565. fields := make([]string, 0, 18)
  25566. if m.created_at != nil {
  25567. fields = append(fields, wxcard.FieldCreatedAt)
  25568. }
  25569. if m.updated_at != nil {
  25570. fields = append(fields, wxcard.FieldUpdatedAt)
  25571. }
  25572. if m.deleted_at != nil {
  25573. fields = append(fields, wxcard.FieldDeletedAt)
  25574. }
  25575. if m.user_id != nil {
  25576. fields = append(fields, wxcard.FieldUserID)
  25577. }
  25578. if m.wx_user_id != nil {
  25579. fields = append(fields, wxcard.FieldWxUserID)
  25580. }
  25581. if m.avatar != nil {
  25582. fields = append(fields, wxcard.FieldAvatar)
  25583. }
  25584. if m.logo != nil {
  25585. fields = append(fields, wxcard.FieldLogo)
  25586. }
  25587. if m.name != nil {
  25588. fields = append(fields, wxcard.FieldName)
  25589. }
  25590. if m.company != nil {
  25591. fields = append(fields, wxcard.FieldCompany)
  25592. }
  25593. if m.address != nil {
  25594. fields = append(fields, wxcard.FieldAddress)
  25595. }
  25596. if m.phone != nil {
  25597. fields = append(fields, wxcard.FieldPhone)
  25598. }
  25599. if m.official_account != nil {
  25600. fields = append(fields, wxcard.FieldOfficialAccount)
  25601. }
  25602. if m.wechat_account != nil {
  25603. fields = append(fields, wxcard.FieldWechatAccount)
  25604. }
  25605. if m.email != nil {
  25606. fields = append(fields, wxcard.FieldEmail)
  25607. }
  25608. if m.api_base != nil {
  25609. fields = append(fields, wxcard.FieldAPIBase)
  25610. }
  25611. if m.api_key != nil {
  25612. fields = append(fields, wxcard.FieldAPIKey)
  25613. }
  25614. if m.ai_info != nil {
  25615. fields = append(fields, wxcard.FieldAiInfo)
  25616. }
  25617. if m.intro != nil {
  25618. fields = append(fields, wxcard.FieldIntro)
  25619. }
  25620. return fields
  25621. }
  25622. // Field returns the value of a field with the given name. The second boolean
  25623. // return value indicates that this field was not set, or was not defined in the
  25624. // schema.
  25625. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  25626. switch name {
  25627. case wxcard.FieldCreatedAt:
  25628. return m.CreatedAt()
  25629. case wxcard.FieldUpdatedAt:
  25630. return m.UpdatedAt()
  25631. case wxcard.FieldDeletedAt:
  25632. return m.DeletedAt()
  25633. case wxcard.FieldUserID:
  25634. return m.UserID()
  25635. case wxcard.FieldWxUserID:
  25636. return m.WxUserID()
  25637. case wxcard.FieldAvatar:
  25638. return m.Avatar()
  25639. case wxcard.FieldLogo:
  25640. return m.Logo()
  25641. case wxcard.FieldName:
  25642. return m.Name()
  25643. case wxcard.FieldCompany:
  25644. return m.Company()
  25645. case wxcard.FieldAddress:
  25646. return m.Address()
  25647. case wxcard.FieldPhone:
  25648. return m.Phone()
  25649. case wxcard.FieldOfficialAccount:
  25650. return m.OfficialAccount()
  25651. case wxcard.FieldWechatAccount:
  25652. return m.WechatAccount()
  25653. case wxcard.FieldEmail:
  25654. return m.Email()
  25655. case wxcard.FieldAPIBase:
  25656. return m.APIBase()
  25657. case wxcard.FieldAPIKey:
  25658. return m.APIKey()
  25659. case wxcard.FieldAiInfo:
  25660. return m.AiInfo()
  25661. case wxcard.FieldIntro:
  25662. return m.Intro()
  25663. }
  25664. return nil, false
  25665. }
  25666. // OldField returns the old value of the field from the database. An error is
  25667. // returned if the mutation operation is not UpdateOne, or the query to the
  25668. // database failed.
  25669. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25670. switch name {
  25671. case wxcard.FieldCreatedAt:
  25672. return m.OldCreatedAt(ctx)
  25673. case wxcard.FieldUpdatedAt:
  25674. return m.OldUpdatedAt(ctx)
  25675. case wxcard.FieldDeletedAt:
  25676. return m.OldDeletedAt(ctx)
  25677. case wxcard.FieldUserID:
  25678. return m.OldUserID(ctx)
  25679. case wxcard.FieldWxUserID:
  25680. return m.OldWxUserID(ctx)
  25681. case wxcard.FieldAvatar:
  25682. return m.OldAvatar(ctx)
  25683. case wxcard.FieldLogo:
  25684. return m.OldLogo(ctx)
  25685. case wxcard.FieldName:
  25686. return m.OldName(ctx)
  25687. case wxcard.FieldCompany:
  25688. return m.OldCompany(ctx)
  25689. case wxcard.FieldAddress:
  25690. return m.OldAddress(ctx)
  25691. case wxcard.FieldPhone:
  25692. return m.OldPhone(ctx)
  25693. case wxcard.FieldOfficialAccount:
  25694. return m.OldOfficialAccount(ctx)
  25695. case wxcard.FieldWechatAccount:
  25696. return m.OldWechatAccount(ctx)
  25697. case wxcard.FieldEmail:
  25698. return m.OldEmail(ctx)
  25699. case wxcard.FieldAPIBase:
  25700. return m.OldAPIBase(ctx)
  25701. case wxcard.FieldAPIKey:
  25702. return m.OldAPIKey(ctx)
  25703. case wxcard.FieldAiInfo:
  25704. return m.OldAiInfo(ctx)
  25705. case wxcard.FieldIntro:
  25706. return m.OldIntro(ctx)
  25707. }
  25708. return nil, fmt.Errorf("unknown WxCard field %s", name)
  25709. }
  25710. // SetField sets the value of a field with the given name. It returns an error if
  25711. // the field is not defined in the schema, or if the type mismatched the field
  25712. // type.
  25713. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  25714. switch name {
  25715. case wxcard.FieldCreatedAt:
  25716. v, ok := value.(time.Time)
  25717. if !ok {
  25718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25719. }
  25720. m.SetCreatedAt(v)
  25721. return nil
  25722. case wxcard.FieldUpdatedAt:
  25723. v, ok := value.(time.Time)
  25724. if !ok {
  25725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25726. }
  25727. m.SetUpdatedAt(v)
  25728. return nil
  25729. case wxcard.FieldDeletedAt:
  25730. v, ok := value.(time.Time)
  25731. if !ok {
  25732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25733. }
  25734. m.SetDeletedAt(v)
  25735. return nil
  25736. case wxcard.FieldUserID:
  25737. v, ok := value.(uint64)
  25738. if !ok {
  25739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25740. }
  25741. m.SetUserID(v)
  25742. return nil
  25743. case wxcard.FieldWxUserID:
  25744. v, ok := value.(uint64)
  25745. if !ok {
  25746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25747. }
  25748. m.SetWxUserID(v)
  25749. return nil
  25750. case wxcard.FieldAvatar:
  25751. v, ok := value.(string)
  25752. if !ok {
  25753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25754. }
  25755. m.SetAvatar(v)
  25756. return nil
  25757. case wxcard.FieldLogo:
  25758. v, ok := value.(string)
  25759. if !ok {
  25760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25761. }
  25762. m.SetLogo(v)
  25763. return nil
  25764. case wxcard.FieldName:
  25765. v, ok := value.(string)
  25766. if !ok {
  25767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25768. }
  25769. m.SetName(v)
  25770. return nil
  25771. case wxcard.FieldCompany:
  25772. v, ok := value.(string)
  25773. if !ok {
  25774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25775. }
  25776. m.SetCompany(v)
  25777. return nil
  25778. case wxcard.FieldAddress:
  25779. v, ok := value.(string)
  25780. if !ok {
  25781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25782. }
  25783. m.SetAddress(v)
  25784. return nil
  25785. case wxcard.FieldPhone:
  25786. v, ok := value.(string)
  25787. if !ok {
  25788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25789. }
  25790. m.SetPhone(v)
  25791. return nil
  25792. case wxcard.FieldOfficialAccount:
  25793. v, ok := value.(string)
  25794. if !ok {
  25795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25796. }
  25797. m.SetOfficialAccount(v)
  25798. return nil
  25799. case wxcard.FieldWechatAccount:
  25800. v, ok := value.(string)
  25801. if !ok {
  25802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25803. }
  25804. m.SetWechatAccount(v)
  25805. return nil
  25806. case wxcard.FieldEmail:
  25807. v, ok := value.(string)
  25808. if !ok {
  25809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25810. }
  25811. m.SetEmail(v)
  25812. return nil
  25813. case wxcard.FieldAPIBase:
  25814. v, ok := value.(string)
  25815. if !ok {
  25816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25817. }
  25818. m.SetAPIBase(v)
  25819. return nil
  25820. case wxcard.FieldAPIKey:
  25821. v, ok := value.(string)
  25822. if !ok {
  25823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25824. }
  25825. m.SetAPIKey(v)
  25826. return nil
  25827. case wxcard.FieldAiInfo:
  25828. v, ok := value.(string)
  25829. if !ok {
  25830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25831. }
  25832. m.SetAiInfo(v)
  25833. return nil
  25834. case wxcard.FieldIntro:
  25835. v, ok := value.(string)
  25836. if !ok {
  25837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25838. }
  25839. m.SetIntro(v)
  25840. return nil
  25841. }
  25842. return fmt.Errorf("unknown WxCard field %s", name)
  25843. }
  25844. // AddedFields returns all numeric fields that were incremented/decremented during
  25845. // this mutation.
  25846. func (m *WxCardMutation) AddedFields() []string {
  25847. var fields []string
  25848. if m.adduser_id != nil {
  25849. fields = append(fields, wxcard.FieldUserID)
  25850. }
  25851. if m.addwx_user_id != nil {
  25852. fields = append(fields, wxcard.FieldWxUserID)
  25853. }
  25854. return fields
  25855. }
  25856. // AddedField returns the numeric value that was incremented/decremented on a field
  25857. // with the given name. The second boolean return value indicates that this field
  25858. // was not set, or was not defined in the schema.
  25859. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  25860. switch name {
  25861. case wxcard.FieldUserID:
  25862. return m.AddedUserID()
  25863. case wxcard.FieldWxUserID:
  25864. return m.AddedWxUserID()
  25865. }
  25866. return nil, false
  25867. }
  25868. // AddField adds the value to the field with the given name. It returns an error if
  25869. // the field is not defined in the schema, or if the type mismatched the field
  25870. // type.
  25871. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  25872. switch name {
  25873. case wxcard.FieldUserID:
  25874. v, ok := value.(int64)
  25875. if !ok {
  25876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25877. }
  25878. m.AddUserID(v)
  25879. return nil
  25880. case wxcard.FieldWxUserID:
  25881. v, ok := value.(int64)
  25882. if !ok {
  25883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25884. }
  25885. m.AddWxUserID(v)
  25886. return nil
  25887. }
  25888. return fmt.Errorf("unknown WxCard numeric field %s", name)
  25889. }
  25890. // ClearedFields returns all nullable fields that were cleared during this
  25891. // mutation.
  25892. func (m *WxCardMutation) ClearedFields() []string {
  25893. var fields []string
  25894. if m.FieldCleared(wxcard.FieldDeletedAt) {
  25895. fields = append(fields, wxcard.FieldDeletedAt)
  25896. }
  25897. if m.FieldCleared(wxcard.FieldUserID) {
  25898. fields = append(fields, wxcard.FieldUserID)
  25899. }
  25900. if m.FieldCleared(wxcard.FieldWxUserID) {
  25901. fields = append(fields, wxcard.FieldWxUserID)
  25902. }
  25903. if m.FieldCleared(wxcard.FieldEmail) {
  25904. fields = append(fields, wxcard.FieldEmail)
  25905. }
  25906. if m.FieldCleared(wxcard.FieldAPIBase) {
  25907. fields = append(fields, wxcard.FieldAPIBase)
  25908. }
  25909. if m.FieldCleared(wxcard.FieldAPIKey) {
  25910. fields = append(fields, wxcard.FieldAPIKey)
  25911. }
  25912. if m.FieldCleared(wxcard.FieldAiInfo) {
  25913. fields = append(fields, wxcard.FieldAiInfo)
  25914. }
  25915. if m.FieldCleared(wxcard.FieldIntro) {
  25916. fields = append(fields, wxcard.FieldIntro)
  25917. }
  25918. return fields
  25919. }
  25920. // FieldCleared returns a boolean indicating if a field with the given name was
  25921. // cleared in this mutation.
  25922. func (m *WxCardMutation) FieldCleared(name string) bool {
  25923. _, ok := m.clearedFields[name]
  25924. return ok
  25925. }
  25926. // ClearField clears the value of the field with the given name. It returns an
  25927. // error if the field is not defined in the schema.
  25928. func (m *WxCardMutation) ClearField(name string) error {
  25929. switch name {
  25930. case wxcard.FieldDeletedAt:
  25931. m.ClearDeletedAt()
  25932. return nil
  25933. case wxcard.FieldUserID:
  25934. m.ClearUserID()
  25935. return nil
  25936. case wxcard.FieldWxUserID:
  25937. m.ClearWxUserID()
  25938. return nil
  25939. case wxcard.FieldEmail:
  25940. m.ClearEmail()
  25941. return nil
  25942. case wxcard.FieldAPIBase:
  25943. m.ClearAPIBase()
  25944. return nil
  25945. case wxcard.FieldAPIKey:
  25946. m.ClearAPIKey()
  25947. return nil
  25948. case wxcard.FieldAiInfo:
  25949. m.ClearAiInfo()
  25950. return nil
  25951. case wxcard.FieldIntro:
  25952. m.ClearIntro()
  25953. return nil
  25954. }
  25955. return fmt.Errorf("unknown WxCard nullable field %s", name)
  25956. }
  25957. // ResetField resets all changes in the mutation for the field with the given name.
  25958. // It returns an error if the field is not defined in the schema.
  25959. func (m *WxCardMutation) ResetField(name string) error {
  25960. switch name {
  25961. case wxcard.FieldCreatedAt:
  25962. m.ResetCreatedAt()
  25963. return nil
  25964. case wxcard.FieldUpdatedAt:
  25965. m.ResetUpdatedAt()
  25966. return nil
  25967. case wxcard.FieldDeletedAt:
  25968. m.ResetDeletedAt()
  25969. return nil
  25970. case wxcard.FieldUserID:
  25971. m.ResetUserID()
  25972. return nil
  25973. case wxcard.FieldWxUserID:
  25974. m.ResetWxUserID()
  25975. return nil
  25976. case wxcard.FieldAvatar:
  25977. m.ResetAvatar()
  25978. return nil
  25979. case wxcard.FieldLogo:
  25980. m.ResetLogo()
  25981. return nil
  25982. case wxcard.FieldName:
  25983. m.ResetName()
  25984. return nil
  25985. case wxcard.FieldCompany:
  25986. m.ResetCompany()
  25987. return nil
  25988. case wxcard.FieldAddress:
  25989. m.ResetAddress()
  25990. return nil
  25991. case wxcard.FieldPhone:
  25992. m.ResetPhone()
  25993. return nil
  25994. case wxcard.FieldOfficialAccount:
  25995. m.ResetOfficialAccount()
  25996. return nil
  25997. case wxcard.FieldWechatAccount:
  25998. m.ResetWechatAccount()
  25999. return nil
  26000. case wxcard.FieldEmail:
  26001. m.ResetEmail()
  26002. return nil
  26003. case wxcard.FieldAPIBase:
  26004. m.ResetAPIBase()
  26005. return nil
  26006. case wxcard.FieldAPIKey:
  26007. m.ResetAPIKey()
  26008. return nil
  26009. case wxcard.FieldAiInfo:
  26010. m.ResetAiInfo()
  26011. return nil
  26012. case wxcard.FieldIntro:
  26013. m.ResetIntro()
  26014. return nil
  26015. }
  26016. return fmt.Errorf("unknown WxCard field %s", name)
  26017. }
  26018. // AddedEdges returns all edge names that were set/added in this mutation.
  26019. func (m *WxCardMutation) AddedEdges() []string {
  26020. edges := make([]string, 0, 0)
  26021. return edges
  26022. }
  26023. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26024. // name in this mutation.
  26025. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  26026. return nil
  26027. }
  26028. // RemovedEdges returns all edge names that were removed in this mutation.
  26029. func (m *WxCardMutation) RemovedEdges() []string {
  26030. edges := make([]string, 0, 0)
  26031. return edges
  26032. }
  26033. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26034. // the given name in this mutation.
  26035. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  26036. return nil
  26037. }
  26038. // ClearedEdges returns all edge names that were cleared in this mutation.
  26039. func (m *WxCardMutation) ClearedEdges() []string {
  26040. edges := make([]string, 0, 0)
  26041. return edges
  26042. }
  26043. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26044. // was cleared in this mutation.
  26045. func (m *WxCardMutation) EdgeCleared(name string) bool {
  26046. return false
  26047. }
  26048. // ClearEdge clears the value of the edge with the given name. It returns an error
  26049. // if that edge is not defined in the schema.
  26050. func (m *WxCardMutation) ClearEdge(name string) error {
  26051. return fmt.Errorf("unknown WxCard unique edge %s", name)
  26052. }
  26053. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26054. // It returns an error if the edge is not defined in the schema.
  26055. func (m *WxCardMutation) ResetEdge(name string) error {
  26056. return fmt.Errorf("unknown WxCard edge %s", name)
  26057. }
  26058. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  26059. type WxCardUserMutation struct {
  26060. config
  26061. op Op
  26062. typ string
  26063. id *uint64
  26064. created_at *time.Time
  26065. updated_at *time.Time
  26066. deleted_at *time.Time
  26067. wxid *string
  26068. account *string
  26069. avatar *string
  26070. nickname *string
  26071. remark *string
  26072. phone *string
  26073. open_id *string
  26074. union_id *string
  26075. session_key *string
  26076. is_vip *int
  26077. addis_vip *int
  26078. clearedFields map[string]struct{}
  26079. done bool
  26080. oldValue func(context.Context) (*WxCardUser, error)
  26081. predicates []predicate.WxCardUser
  26082. }
  26083. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  26084. // wxcarduserOption allows management of the mutation configuration using functional options.
  26085. type wxcarduserOption func(*WxCardUserMutation)
  26086. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  26087. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  26088. m := &WxCardUserMutation{
  26089. config: c,
  26090. op: op,
  26091. typ: TypeWxCardUser,
  26092. clearedFields: make(map[string]struct{}),
  26093. }
  26094. for _, opt := range opts {
  26095. opt(m)
  26096. }
  26097. return m
  26098. }
  26099. // withWxCardUserID sets the ID field of the mutation.
  26100. func withWxCardUserID(id uint64) wxcarduserOption {
  26101. return func(m *WxCardUserMutation) {
  26102. var (
  26103. err error
  26104. once sync.Once
  26105. value *WxCardUser
  26106. )
  26107. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  26108. once.Do(func() {
  26109. if m.done {
  26110. err = errors.New("querying old values post mutation is not allowed")
  26111. } else {
  26112. value, err = m.Client().WxCardUser.Get(ctx, id)
  26113. }
  26114. })
  26115. return value, err
  26116. }
  26117. m.id = &id
  26118. }
  26119. }
  26120. // withWxCardUser sets the old WxCardUser of the mutation.
  26121. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  26122. return func(m *WxCardUserMutation) {
  26123. m.oldValue = func(context.Context) (*WxCardUser, error) {
  26124. return node, nil
  26125. }
  26126. m.id = &node.ID
  26127. }
  26128. }
  26129. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26130. // executed in a transaction (ent.Tx), a transactional client is returned.
  26131. func (m WxCardUserMutation) Client() *Client {
  26132. client := &Client{config: m.config}
  26133. client.init()
  26134. return client
  26135. }
  26136. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26137. // it returns an error otherwise.
  26138. func (m WxCardUserMutation) Tx() (*Tx, error) {
  26139. if _, ok := m.driver.(*txDriver); !ok {
  26140. return nil, errors.New("ent: mutation is not running in a transaction")
  26141. }
  26142. tx := &Tx{config: m.config}
  26143. tx.init()
  26144. return tx, nil
  26145. }
  26146. // SetID sets the value of the id field. Note that this
  26147. // operation is only accepted on creation of WxCardUser entities.
  26148. func (m *WxCardUserMutation) SetID(id uint64) {
  26149. m.id = &id
  26150. }
  26151. // ID returns the ID value in the mutation. Note that the ID is only available
  26152. // if it was provided to the builder or after it was returned from the database.
  26153. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  26154. if m.id == nil {
  26155. return
  26156. }
  26157. return *m.id, true
  26158. }
  26159. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26160. // That means, if the mutation is applied within a transaction with an isolation level such
  26161. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26162. // or updated by the mutation.
  26163. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  26164. switch {
  26165. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26166. id, exists := m.ID()
  26167. if exists {
  26168. return []uint64{id}, nil
  26169. }
  26170. fallthrough
  26171. case m.op.Is(OpUpdate | OpDelete):
  26172. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  26173. default:
  26174. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26175. }
  26176. }
  26177. // SetCreatedAt sets the "created_at" field.
  26178. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  26179. m.created_at = &t
  26180. }
  26181. // CreatedAt returns the value of the "created_at" field in the mutation.
  26182. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  26183. v := m.created_at
  26184. if v == nil {
  26185. return
  26186. }
  26187. return *v, true
  26188. }
  26189. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  26190. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26192. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26193. if !m.op.Is(OpUpdateOne) {
  26194. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26195. }
  26196. if m.id == nil || m.oldValue == nil {
  26197. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26198. }
  26199. oldValue, err := m.oldValue(ctx)
  26200. if err != nil {
  26201. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26202. }
  26203. return oldValue.CreatedAt, nil
  26204. }
  26205. // ResetCreatedAt resets all changes to the "created_at" field.
  26206. func (m *WxCardUserMutation) ResetCreatedAt() {
  26207. m.created_at = nil
  26208. }
  26209. // SetUpdatedAt sets the "updated_at" field.
  26210. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  26211. m.updated_at = &t
  26212. }
  26213. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26214. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  26215. v := m.updated_at
  26216. if v == nil {
  26217. return
  26218. }
  26219. return *v, true
  26220. }
  26221. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  26222. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26224. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26225. if !m.op.Is(OpUpdateOne) {
  26226. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26227. }
  26228. if m.id == nil || m.oldValue == nil {
  26229. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26230. }
  26231. oldValue, err := m.oldValue(ctx)
  26232. if err != nil {
  26233. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26234. }
  26235. return oldValue.UpdatedAt, nil
  26236. }
  26237. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26238. func (m *WxCardUserMutation) ResetUpdatedAt() {
  26239. m.updated_at = nil
  26240. }
  26241. // SetDeletedAt sets the "deleted_at" field.
  26242. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  26243. m.deleted_at = &t
  26244. }
  26245. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26246. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  26247. v := m.deleted_at
  26248. if v == nil {
  26249. return
  26250. }
  26251. return *v, true
  26252. }
  26253. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  26254. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26256. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26257. if !m.op.Is(OpUpdateOne) {
  26258. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26259. }
  26260. if m.id == nil || m.oldValue == nil {
  26261. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26262. }
  26263. oldValue, err := m.oldValue(ctx)
  26264. if err != nil {
  26265. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26266. }
  26267. return oldValue.DeletedAt, nil
  26268. }
  26269. // ClearDeletedAt clears the value of the "deleted_at" field.
  26270. func (m *WxCardUserMutation) ClearDeletedAt() {
  26271. m.deleted_at = nil
  26272. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  26273. }
  26274. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26275. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  26276. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  26277. return ok
  26278. }
  26279. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26280. func (m *WxCardUserMutation) ResetDeletedAt() {
  26281. m.deleted_at = nil
  26282. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  26283. }
  26284. // SetWxid sets the "wxid" field.
  26285. func (m *WxCardUserMutation) SetWxid(s string) {
  26286. m.wxid = &s
  26287. }
  26288. // Wxid returns the value of the "wxid" field in the mutation.
  26289. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  26290. v := m.wxid
  26291. if v == nil {
  26292. return
  26293. }
  26294. return *v, true
  26295. }
  26296. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  26297. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26299. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  26300. if !m.op.Is(OpUpdateOne) {
  26301. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  26302. }
  26303. if m.id == nil || m.oldValue == nil {
  26304. return v, errors.New("OldWxid requires an ID field in the mutation")
  26305. }
  26306. oldValue, err := m.oldValue(ctx)
  26307. if err != nil {
  26308. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  26309. }
  26310. return oldValue.Wxid, nil
  26311. }
  26312. // ResetWxid resets all changes to the "wxid" field.
  26313. func (m *WxCardUserMutation) ResetWxid() {
  26314. m.wxid = nil
  26315. }
  26316. // SetAccount sets the "account" field.
  26317. func (m *WxCardUserMutation) SetAccount(s string) {
  26318. m.account = &s
  26319. }
  26320. // Account returns the value of the "account" field in the mutation.
  26321. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  26322. v := m.account
  26323. if v == nil {
  26324. return
  26325. }
  26326. return *v, true
  26327. }
  26328. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  26329. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26331. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  26332. if !m.op.Is(OpUpdateOne) {
  26333. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  26334. }
  26335. if m.id == nil || m.oldValue == nil {
  26336. return v, errors.New("OldAccount requires an ID field in the mutation")
  26337. }
  26338. oldValue, err := m.oldValue(ctx)
  26339. if err != nil {
  26340. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  26341. }
  26342. return oldValue.Account, nil
  26343. }
  26344. // ResetAccount resets all changes to the "account" field.
  26345. func (m *WxCardUserMutation) ResetAccount() {
  26346. m.account = nil
  26347. }
  26348. // SetAvatar sets the "avatar" field.
  26349. func (m *WxCardUserMutation) SetAvatar(s string) {
  26350. m.avatar = &s
  26351. }
  26352. // Avatar returns the value of the "avatar" field in the mutation.
  26353. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  26354. v := m.avatar
  26355. if v == nil {
  26356. return
  26357. }
  26358. return *v, true
  26359. }
  26360. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  26361. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26363. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  26364. if !m.op.Is(OpUpdateOne) {
  26365. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  26366. }
  26367. if m.id == nil || m.oldValue == nil {
  26368. return v, errors.New("OldAvatar requires an ID field in the mutation")
  26369. }
  26370. oldValue, err := m.oldValue(ctx)
  26371. if err != nil {
  26372. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  26373. }
  26374. return oldValue.Avatar, nil
  26375. }
  26376. // ResetAvatar resets all changes to the "avatar" field.
  26377. func (m *WxCardUserMutation) ResetAvatar() {
  26378. m.avatar = nil
  26379. }
  26380. // SetNickname sets the "nickname" field.
  26381. func (m *WxCardUserMutation) SetNickname(s string) {
  26382. m.nickname = &s
  26383. }
  26384. // Nickname returns the value of the "nickname" field in the mutation.
  26385. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  26386. v := m.nickname
  26387. if v == nil {
  26388. return
  26389. }
  26390. return *v, true
  26391. }
  26392. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  26393. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26395. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  26396. if !m.op.Is(OpUpdateOne) {
  26397. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  26398. }
  26399. if m.id == nil || m.oldValue == nil {
  26400. return v, errors.New("OldNickname requires an ID field in the mutation")
  26401. }
  26402. oldValue, err := m.oldValue(ctx)
  26403. if err != nil {
  26404. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  26405. }
  26406. return oldValue.Nickname, nil
  26407. }
  26408. // ResetNickname resets all changes to the "nickname" field.
  26409. func (m *WxCardUserMutation) ResetNickname() {
  26410. m.nickname = nil
  26411. }
  26412. // SetRemark sets the "remark" field.
  26413. func (m *WxCardUserMutation) SetRemark(s string) {
  26414. m.remark = &s
  26415. }
  26416. // Remark returns the value of the "remark" field in the mutation.
  26417. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  26418. v := m.remark
  26419. if v == nil {
  26420. return
  26421. }
  26422. return *v, true
  26423. }
  26424. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  26425. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26427. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  26428. if !m.op.Is(OpUpdateOne) {
  26429. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  26430. }
  26431. if m.id == nil || m.oldValue == nil {
  26432. return v, errors.New("OldRemark requires an ID field in the mutation")
  26433. }
  26434. oldValue, err := m.oldValue(ctx)
  26435. if err != nil {
  26436. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  26437. }
  26438. return oldValue.Remark, nil
  26439. }
  26440. // ResetRemark resets all changes to the "remark" field.
  26441. func (m *WxCardUserMutation) ResetRemark() {
  26442. m.remark = nil
  26443. }
  26444. // SetPhone sets the "phone" field.
  26445. func (m *WxCardUserMutation) SetPhone(s string) {
  26446. m.phone = &s
  26447. }
  26448. // Phone returns the value of the "phone" field in the mutation.
  26449. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  26450. v := m.phone
  26451. if v == nil {
  26452. return
  26453. }
  26454. return *v, true
  26455. }
  26456. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  26457. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26459. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  26460. if !m.op.Is(OpUpdateOne) {
  26461. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  26462. }
  26463. if m.id == nil || m.oldValue == nil {
  26464. return v, errors.New("OldPhone requires an ID field in the mutation")
  26465. }
  26466. oldValue, err := m.oldValue(ctx)
  26467. if err != nil {
  26468. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  26469. }
  26470. return oldValue.Phone, nil
  26471. }
  26472. // ResetPhone resets all changes to the "phone" field.
  26473. func (m *WxCardUserMutation) ResetPhone() {
  26474. m.phone = nil
  26475. }
  26476. // SetOpenID sets the "open_id" field.
  26477. func (m *WxCardUserMutation) SetOpenID(s string) {
  26478. m.open_id = &s
  26479. }
  26480. // OpenID returns the value of the "open_id" field in the mutation.
  26481. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  26482. v := m.open_id
  26483. if v == nil {
  26484. return
  26485. }
  26486. return *v, true
  26487. }
  26488. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  26489. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26491. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  26492. if !m.op.Is(OpUpdateOne) {
  26493. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  26494. }
  26495. if m.id == nil || m.oldValue == nil {
  26496. return v, errors.New("OldOpenID requires an ID field in the mutation")
  26497. }
  26498. oldValue, err := m.oldValue(ctx)
  26499. if err != nil {
  26500. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  26501. }
  26502. return oldValue.OpenID, nil
  26503. }
  26504. // ResetOpenID resets all changes to the "open_id" field.
  26505. func (m *WxCardUserMutation) ResetOpenID() {
  26506. m.open_id = nil
  26507. }
  26508. // SetUnionID sets the "union_id" field.
  26509. func (m *WxCardUserMutation) SetUnionID(s string) {
  26510. m.union_id = &s
  26511. }
  26512. // UnionID returns the value of the "union_id" field in the mutation.
  26513. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  26514. v := m.union_id
  26515. if v == nil {
  26516. return
  26517. }
  26518. return *v, true
  26519. }
  26520. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  26521. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26523. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  26524. if !m.op.Is(OpUpdateOne) {
  26525. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  26526. }
  26527. if m.id == nil || m.oldValue == nil {
  26528. return v, errors.New("OldUnionID requires an ID field in the mutation")
  26529. }
  26530. oldValue, err := m.oldValue(ctx)
  26531. if err != nil {
  26532. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  26533. }
  26534. return oldValue.UnionID, nil
  26535. }
  26536. // ResetUnionID resets all changes to the "union_id" field.
  26537. func (m *WxCardUserMutation) ResetUnionID() {
  26538. m.union_id = nil
  26539. }
  26540. // SetSessionKey sets the "session_key" field.
  26541. func (m *WxCardUserMutation) SetSessionKey(s string) {
  26542. m.session_key = &s
  26543. }
  26544. // SessionKey returns the value of the "session_key" field in the mutation.
  26545. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  26546. v := m.session_key
  26547. if v == nil {
  26548. return
  26549. }
  26550. return *v, true
  26551. }
  26552. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  26553. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26555. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  26556. if !m.op.Is(OpUpdateOne) {
  26557. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  26558. }
  26559. if m.id == nil || m.oldValue == nil {
  26560. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  26561. }
  26562. oldValue, err := m.oldValue(ctx)
  26563. if err != nil {
  26564. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  26565. }
  26566. return oldValue.SessionKey, nil
  26567. }
  26568. // ResetSessionKey resets all changes to the "session_key" field.
  26569. func (m *WxCardUserMutation) ResetSessionKey() {
  26570. m.session_key = nil
  26571. }
  26572. // SetIsVip sets the "is_vip" field.
  26573. func (m *WxCardUserMutation) SetIsVip(i int) {
  26574. m.is_vip = &i
  26575. m.addis_vip = nil
  26576. }
  26577. // IsVip returns the value of the "is_vip" field in the mutation.
  26578. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  26579. v := m.is_vip
  26580. if v == nil {
  26581. return
  26582. }
  26583. return *v, true
  26584. }
  26585. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  26586. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26588. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  26589. if !m.op.Is(OpUpdateOne) {
  26590. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  26591. }
  26592. if m.id == nil || m.oldValue == nil {
  26593. return v, errors.New("OldIsVip requires an ID field in the mutation")
  26594. }
  26595. oldValue, err := m.oldValue(ctx)
  26596. if err != nil {
  26597. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  26598. }
  26599. return oldValue.IsVip, nil
  26600. }
  26601. // AddIsVip adds i to the "is_vip" field.
  26602. func (m *WxCardUserMutation) AddIsVip(i int) {
  26603. if m.addis_vip != nil {
  26604. *m.addis_vip += i
  26605. } else {
  26606. m.addis_vip = &i
  26607. }
  26608. }
  26609. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  26610. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  26611. v := m.addis_vip
  26612. if v == nil {
  26613. return
  26614. }
  26615. return *v, true
  26616. }
  26617. // ResetIsVip resets all changes to the "is_vip" field.
  26618. func (m *WxCardUserMutation) ResetIsVip() {
  26619. m.is_vip = nil
  26620. m.addis_vip = nil
  26621. }
  26622. // Where appends a list predicates to the WxCardUserMutation builder.
  26623. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  26624. m.predicates = append(m.predicates, ps...)
  26625. }
  26626. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  26627. // users can use type-assertion to append predicates that do not depend on any generated package.
  26628. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  26629. p := make([]predicate.WxCardUser, len(ps))
  26630. for i := range ps {
  26631. p[i] = ps[i]
  26632. }
  26633. m.Where(p...)
  26634. }
  26635. // Op returns the operation name.
  26636. func (m *WxCardUserMutation) Op() Op {
  26637. return m.op
  26638. }
  26639. // SetOp allows setting the mutation operation.
  26640. func (m *WxCardUserMutation) SetOp(op Op) {
  26641. m.op = op
  26642. }
  26643. // Type returns the node type of this mutation (WxCardUser).
  26644. func (m *WxCardUserMutation) Type() string {
  26645. return m.typ
  26646. }
  26647. // Fields returns all fields that were changed during this mutation. Note that in
  26648. // order to get all numeric fields that were incremented/decremented, call
  26649. // AddedFields().
  26650. func (m *WxCardUserMutation) Fields() []string {
  26651. fields := make([]string, 0, 13)
  26652. if m.created_at != nil {
  26653. fields = append(fields, wxcarduser.FieldCreatedAt)
  26654. }
  26655. if m.updated_at != nil {
  26656. fields = append(fields, wxcarduser.FieldUpdatedAt)
  26657. }
  26658. if m.deleted_at != nil {
  26659. fields = append(fields, wxcarduser.FieldDeletedAt)
  26660. }
  26661. if m.wxid != nil {
  26662. fields = append(fields, wxcarduser.FieldWxid)
  26663. }
  26664. if m.account != nil {
  26665. fields = append(fields, wxcarduser.FieldAccount)
  26666. }
  26667. if m.avatar != nil {
  26668. fields = append(fields, wxcarduser.FieldAvatar)
  26669. }
  26670. if m.nickname != nil {
  26671. fields = append(fields, wxcarduser.FieldNickname)
  26672. }
  26673. if m.remark != nil {
  26674. fields = append(fields, wxcarduser.FieldRemark)
  26675. }
  26676. if m.phone != nil {
  26677. fields = append(fields, wxcarduser.FieldPhone)
  26678. }
  26679. if m.open_id != nil {
  26680. fields = append(fields, wxcarduser.FieldOpenID)
  26681. }
  26682. if m.union_id != nil {
  26683. fields = append(fields, wxcarduser.FieldUnionID)
  26684. }
  26685. if m.session_key != nil {
  26686. fields = append(fields, wxcarduser.FieldSessionKey)
  26687. }
  26688. if m.is_vip != nil {
  26689. fields = append(fields, wxcarduser.FieldIsVip)
  26690. }
  26691. return fields
  26692. }
  26693. // Field returns the value of a field with the given name. The second boolean
  26694. // return value indicates that this field was not set, or was not defined in the
  26695. // schema.
  26696. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  26697. switch name {
  26698. case wxcarduser.FieldCreatedAt:
  26699. return m.CreatedAt()
  26700. case wxcarduser.FieldUpdatedAt:
  26701. return m.UpdatedAt()
  26702. case wxcarduser.FieldDeletedAt:
  26703. return m.DeletedAt()
  26704. case wxcarduser.FieldWxid:
  26705. return m.Wxid()
  26706. case wxcarduser.FieldAccount:
  26707. return m.Account()
  26708. case wxcarduser.FieldAvatar:
  26709. return m.Avatar()
  26710. case wxcarduser.FieldNickname:
  26711. return m.Nickname()
  26712. case wxcarduser.FieldRemark:
  26713. return m.Remark()
  26714. case wxcarduser.FieldPhone:
  26715. return m.Phone()
  26716. case wxcarduser.FieldOpenID:
  26717. return m.OpenID()
  26718. case wxcarduser.FieldUnionID:
  26719. return m.UnionID()
  26720. case wxcarduser.FieldSessionKey:
  26721. return m.SessionKey()
  26722. case wxcarduser.FieldIsVip:
  26723. return m.IsVip()
  26724. }
  26725. return nil, false
  26726. }
  26727. // OldField returns the old value of the field from the database. An error is
  26728. // returned if the mutation operation is not UpdateOne, or the query to the
  26729. // database failed.
  26730. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26731. switch name {
  26732. case wxcarduser.FieldCreatedAt:
  26733. return m.OldCreatedAt(ctx)
  26734. case wxcarduser.FieldUpdatedAt:
  26735. return m.OldUpdatedAt(ctx)
  26736. case wxcarduser.FieldDeletedAt:
  26737. return m.OldDeletedAt(ctx)
  26738. case wxcarduser.FieldWxid:
  26739. return m.OldWxid(ctx)
  26740. case wxcarduser.FieldAccount:
  26741. return m.OldAccount(ctx)
  26742. case wxcarduser.FieldAvatar:
  26743. return m.OldAvatar(ctx)
  26744. case wxcarduser.FieldNickname:
  26745. return m.OldNickname(ctx)
  26746. case wxcarduser.FieldRemark:
  26747. return m.OldRemark(ctx)
  26748. case wxcarduser.FieldPhone:
  26749. return m.OldPhone(ctx)
  26750. case wxcarduser.FieldOpenID:
  26751. return m.OldOpenID(ctx)
  26752. case wxcarduser.FieldUnionID:
  26753. return m.OldUnionID(ctx)
  26754. case wxcarduser.FieldSessionKey:
  26755. return m.OldSessionKey(ctx)
  26756. case wxcarduser.FieldIsVip:
  26757. return m.OldIsVip(ctx)
  26758. }
  26759. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  26760. }
  26761. // SetField sets the value of a field with the given name. It returns an error if
  26762. // the field is not defined in the schema, or if the type mismatched the field
  26763. // type.
  26764. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  26765. switch name {
  26766. case wxcarduser.FieldCreatedAt:
  26767. v, ok := value.(time.Time)
  26768. if !ok {
  26769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26770. }
  26771. m.SetCreatedAt(v)
  26772. return nil
  26773. case wxcarduser.FieldUpdatedAt:
  26774. v, ok := value.(time.Time)
  26775. if !ok {
  26776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26777. }
  26778. m.SetUpdatedAt(v)
  26779. return nil
  26780. case wxcarduser.FieldDeletedAt:
  26781. v, ok := value.(time.Time)
  26782. if !ok {
  26783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26784. }
  26785. m.SetDeletedAt(v)
  26786. return nil
  26787. case wxcarduser.FieldWxid:
  26788. v, ok := value.(string)
  26789. if !ok {
  26790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26791. }
  26792. m.SetWxid(v)
  26793. return nil
  26794. case wxcarduser.FieldAccount:
  26795. v, ok := value.(string)
  26796. if !ok {
  26797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26798. }
  26799. m.SetAccount(v)
  26800. return nil
  26801. case wxcarduser.FieldAvatar:
  26802. v, ok := value.(string)
  26803. if !ok {
  26804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26805. }
  26806. m.SetAvatar(v)
  26807. return nil
  26808. case wxcarduser.FieldNickname:
  26809. v, ok := value.(string)
  26810. if !ok {
  26811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26812. }
  26813. m.SetNickname(v)
  26814. return nil
  26815. case wxcarduser.FieldRemark:
  26816. v, ok := value.(string)
  26817. if !ok {
  26818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26819. }
  26820. m.SetRemark(v)
  26821. return nil
  26822. case wxcarduser.FieldPhone:
  26823. v, ok := value.(string)
  26824. if !ok {
  26825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26826. }
  26827. m.SetPhone(v)
  26828. return nil
  26829. case wxcarduser.FieldOpenID:
  26830. v, ok := value.(string)
  26831. if !ok {
  26832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26833. }
  26834. m.SetOpenID(v)
  26835. return nil
  26836. case wxcarduser.FieldUnionID:
  26837. v, ok := value.(string)
  26838. if !ok {
  26839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26840. }
  26841. m.SetUnionID(v)
  26842. return nil
  26843. case wxcarduser.FieldSessionKey:
  26844. v, ok := value.(string)
  26845. if !ok {
  26846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26847. }
  26848. m.SetSessionKey(v)
  26849. return nil
  26850. case wxcarduser.FieldIsVip:
  26851. v, ok := value.(int)
  26852. if !ok {
  26853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26854. }
  26855. m.SetIsVip(v)
  26856. return nil
  26857. }
  26858. return fmt.Errorf("unknown WxCardUser field %s", name)
  26859. }
  26860. // AddedFields returns all numeric fields that were incremented/decremented during
  26861. // this mutation.
  26862. func (m *WxCardUserMutation) AddedFields() []string {
  26863. var fields []string
  26864. if m.addis_vip != nil {
  26865. fields = append(fields, wxcarduser.FieldIsVip)
  26866. }
  26867. return fields
  26868. }
  26869. // AddedField returns the numeric value that was incremented/decremented on a field
  26870. // with the given name. The second boolean return value indicates that this field
  26871. // was not set, or was not defined in the schema.
  26872. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  26873. switch name {
  26874. case wxcarduser.FieldIsVip:
  26875. return m.AddedIsVip()
  26876. }
  26877. return nil, false
  26878. }
  26879. // AddField adds the value to the field with the given name. It returns an error if
  26880. // the field is not defined in the schema, or if the type mismatched the field
  26881. // type.
  26882. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  26883. switch name {
  26884. case wxcarduser.FieldIsVip:
  26885. v, ok := value.(int)
  26886. if !ok {
  26887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26888. }
  26889. m.AddIsVip(v)
  26890. return nil
  26891. }
  26892. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  26893. }
  26894. // ClearedFields returns all nullable fields that were cleared during this
  26895. // mutation.
  26896. func (m *WxCardUserMutation) ClearedFields() []string {
  26897. var fields []string
  26898. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  26899. fields = append(fields, wxcarduser.FieldDeletedAt)
  26900. }
  26901. return fields
  26902. }
  26903. // FieldCleared returns a boolean indicating if a field with the given name was
  26904. // cleared in this mutation.
  26905. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  26906. _, ok := m.clearedFields[name]
  26907. return ok
  26908. }
  26909. // ClearField clears the value of the field with the given name. It returns an
  26910. // error if the field is not defined in the schema.
  26911. func (m *WxCardUserMutation) ClearField(name string) error {
  26912. switch name {
  26913. case wxcarduser.FieldDeletedAt:
  26914. m.ClearDeletedAt()
  26915. return nil
  26916. }
  26917. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  26918. }
  26919. // ResetField resets all changes in the mutation for the field with the given name.
  26920. // It returns an error if the field is not defined in the schema.
  26921. func (m *WxCardUserMutation) ResetField(name string) error {
  26922. switch name {
  26923. case wxcarduser.FieldCreatedAt:
  26924. m.ResetCreatedAt()
  26925. return nil
  26926. case wxcarduser.FieldUpdatedAt:
  26927. m.ResetUpdatedAt()
  26928. return nil
  26929. case wxcarduser.FieldDeletedAt:
  26930. m.ResetDeletedAt()
  26931. return nil
  26932. case wxcarduser.FieldWxid:
  26933. m.ResetWxid()
  26934. return nil
  26935. case wxcarduser.FieldAccount:
  26936. m.ResetAccount()
  26937. return nil
  26938. case wxcarduser.FieldAvatar:
  26939. m.ResetAvatar()
  26940. return nil
  26941. case wxcarduser.FieldNickname:
  26942. m.ResetNickname()
  26943. return nil
  26944. case wxcarduser.FieldRemark:
  26945. m.ResetRemark()
  26946. return nil
  26947. case wxcarduser.FieldPhone:
  26948. m.ResetPhone()
  26949. return nil
  26950. case wxcarduser.FieldOpenID:
  26951. m.ResetOpenID()
  26952. return nil
  26953. case wxcarduser.FieldUnionID:
  26954. m.ResetUnionID()
  26955. return nil
  26956. case wxcarduser.FieldSessionKey:
  26957. m.ResetSessionKey()
  26958. return nil
  26959. case wxcarduser.FieldIsVip:
  26960. m.ResetIsVip()
  26961. return nil
  26962. }
  26963. return fmt.Errorf("unknown WxCardUser field %s", name)
  26964. }
  26965. // AddedEdges returns all edge names that were set/added in this mutation.
  26966. func (m *WxCardUserMutation) AddedEdges() []string {
  26967. edges := make([]string, 0, 0)
  26968. return edges
  26969. }
  26970. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26971. // name in this mutation.
  26972. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  26973. return nil
  26974. }
  26975. // RemovedEdges returns all edge names that were removed in this mutation.
  26976. func (m *WxCardUserMutation) RemovedEdges() []string {
  26977. edges := make([]string, 0, 0)
  26978. return edges
  26979. }
  26980. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26981. // the given name in this mutation.
  26982. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  26983. return nil
  26984. }
  26985. // ClearedEdges returns all edge names that were cleared in this mutation.
  26986. func (m *WxCardUserMutation) ClearedEdges() []string {
  26987. edges := make([]string, 0, 0)
  26988. return edges
  26989. }
  26990. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26991. // was cleared in this mutation.
  26992. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  26993. return false
  26994. }
  26995. // ClearEdge clears the value of the edge with the given name. It returns an error
  26996. // if that edge is not defined in the schema.
  26997. func (m *WxCardUserMutation) ClearEdge(name string) error {
  26998. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  26999. }
  27000. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27001. // It returns an error if the edge is not defined in the schema.
  27002. func (m *WxCardUserMutation) ResetEdge(name string) error {
  27003. return fmt.Errorf("unknown WxCardUser edge %s", name)
  27004. }
  27005. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  27006. type WxCardVisitMutation struct {
  27007. config
  27008. op Op
  27009. typ string
  27010. id *uint64
  27011. created_at *time.Time
  27012. updated_at *time.Time
  27013. deleted_at *time.Time
  27014. user_id *uint64
  27015. adduser_id *int64
  27016. bot_id *uint64
  27017. addbot_id *int64
  27018. bot_type *uint8
  27019. addbot_type *int8
  27020. clearedFields map[string]struct{}
  27021. done bool
  27022. oldValue func(context.Context) (*WxCardVisit, error)
  27023. predicates []predicate.WxCardVisit
  27024. }
  27025. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  27026. // wxcardvisitOption allows management of the mutation configuration using functional options.
  27027. type wxcardvisitOption func(*WxCardVisitMutation)
  27028. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  27029. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  27030. m := &WxCardVisitMutation{
  27031. config: c,
  27032. op: op,
  27033. typ: TypeWxCardVisit,
  27034. clearedFields: make(map[string]struct{}),
  27035. }
  27036. for _, opt := range opts {
  27037. opt(m)
  27038. }
  27039. return m
  27040. }
  27041. // withWxCardVisitID sets the ID field of the mutation.
  27042. func withWxCardVisitID(id uint64) wxcardvisitOption {
  27043. return func(m *WxCardVisitMutation) {
  27044. var (
  27045. err error
  27046. once sync.Once
  27047. value *WxCardVisit
  27048. )
  27049. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  27050. once.Do(func() {
  27051. if m.done {
  27052. err = errors.New("querying old values post mutation is not allowed")
  27053. } else {
  27054. value, err = m.Client().WxCardVisit.Get(ctx, id)
  27055. }
  27056. })
  27057. return value, err
  27058. }
  27059. m.id = &id
  27060. }
  27061. }
  27062. // withWxCardVisit sets the old WxCardVisit of the mutation.
  27063. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  27064. return func(m *WxCardVisitMutation) {
  27065. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  27066. return node, nil
  27067. }
  27068. m.id = &node.ID
  27069. }
  27070. }
  27071. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27072. // executed in a transaction (ent.Tx), a transactional client is returned.
  27073. func (m WxCardVisitMutation) Client() *Client {
  27074. client := &Client{config: m.config}
  27075. client.init()
  27076. return client
  27077. }
  27078. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27079. // it returns an error otherwise.
  27080. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  27081. if _, ok := m.driver.(*txDriver); !ok {
  27082. return nil, errors.New("ent: mutation is not running in a transaction")
  27083. }
  27084. tx := &Tx{config: m.config}
  27085. tx.init()
  27086. return tx, nil
  27087. }
  27088. // SetID sets the value of the id field. Note that this
  27089. // operation is only accepted on creation of WxCardVisit entities.
  27090. func (m *WxCardVisitMutation) SetID(id uint64) {
  27091. m.id = &id
  27092. }
  27093. // ID returns the ID value in the mutation. Note that the ID is only available
  27094. // if it was provided to the builder or after it was returned from the database.
  27095. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  27096. if m.id == nil {
  27097. return
  27098. }
  27099. return *m.id, true
  27100. }
  27101. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27102. // That means, if the mutation is applied within a transaction with an isolation level such
  27103. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27104. // or updated by the mutation.
  27105. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  27106. switch {
  27107. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27108. id, exists := m.ID()
  27109. if exists {
  27110. return []uint64{id}, nil
  27111. }
  27112. fallthrough
  27113. case m.op.Is(OpUpdate | OpDelete):
  27114. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  27115. default:
  27116. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27117. }
  27118. }
  27119. // SetCreatedAt sets the "created_at" field.
  27120. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  27121. m.created_at = &t
  27122. }
  27123. // CreatedAt returns the value of the "created_at" field in the mutation.
  27124. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  27125. v := m.created_at
  27126. if v == nil {
  27127. return
  27128. }
  27129. return *v, true
  27130. }
  27131. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  27132. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  27133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27134. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27135. if !m.op.Is(OpUpdateOne) {
  27136. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27137. }
  27138. if m.id == nil || m.oldValue == nil {
  27139. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27140. }
  27141. oldValue, err := m.oldValue(ctx)
  27142. if err != nil {
  27143. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27144. }
  27145. return oldValue.CreatedAt, nil
  27146. }
  27147. // ResetCreatedAt resets all changes to the "created_at" field.
  27148. func (m *WxCardVisitMutation) ResetCreatedAt() {
  27149. m.created_at = nil
  27150. }
  27151. // SetUpdatedAt sets the "updated_at" field.
  27152. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  27153. m.updated_at = &t
  27154. }
  27155. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27156. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  27157. v := m.updated_at
  27158. if v == nil {
  27159. return
  27160. }
  27161. return *v, true
  27162. }
  27163. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  27164. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  27165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27166. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27167. if !m.op.Is(OpUpdateOne) {
  27168. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27169. }
  27170. if m.id == nil || m.oldValue == nil {
  27171. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27172. }
  27173. oldValue, err := m.oldValue(ctx)
  27174. if err != nil {
  27175. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27176. }
  27177. return oldValue.UpdatedAt, nil
  27178. }
  27179. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27180. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  27181. m.updated_at = nil
  27182. }
  27183. // SetDeletedAt sets the "deleted_at" field.
  27184. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  27185. m.deleted_at = &t
  27186. }
  27187. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27188. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  27189. v := m.deleted_at
  27190. if v == nil {
  27191. return
  27192. }
  27193. return *v, true
  27194. }
  27195. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  27196. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  27197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27198. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27199. if !m.op.Is(OpUpdateOne) {
  27200. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27201. }
  27202. if m.id == nil || m.oldValue == nil {
  27203. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27204. }
  27205. oldValue, err := m.oldValue(ctx)
  27206. if err != nil {
  27207. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27208. }
  27209. return oldValue.DeletedAt, nil
  27210. }
  27211. // ClearDeletedAt clears the value of the "deleted_at" field.
  27212. func (m *WxCardVisitMutation) ClearDeletedAt() {
  27213. m.deleted_at = nil
  27214. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  27215. }
  27216. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27217. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  27218. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  27219. return ok
  27220. }
  27221. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27222. func (m *WxCardVisitMutation) ResetDeletedAt() {
  27223. m.deleted_at = nil
  27224. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  27225. }
  27226. // SetUserID sets the "user_id" field.
  27227. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  27228. m.user_id = &u
  27229. m.adduser_id = nil
  27230. }
  27231. // UserID returns the value of the "user_id" field in the mutation.
  27232. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  27233. v := m.user_id
  27234. if v == nil {
  27235. return
  27236. }
  27237. return *v, true
  27238. }
  27239. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  27240. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  27241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27242. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  27243. if !m.op.Is(OpUpdateOne) {
  27244. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  27245. }
  27246. if m.id == nil || m.oldValue == nil {
  27247. return v, errors.New("OldUserID requires an ID field in the mutation")
  27248. }
  27249. oldValue, err := m.oldValue(ctx)
  27250. if err != nil {
  27251. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  27252. }
  27253. return oldValue.UserID, nil
  27254. }
  27255. // AddUserID adds u to the "user_id" field.
  27256. func (m *WxCardVisitMutation) AddUserID(u int64) {
  27257. if m.adduser_id != nil {
  27258. *m.adduser_id += u
  27259. } else {
  27260. m.adduser_id = &u
  27261. }
  27262. }
  27263. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  27264. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  27265. v := m.adduser_id
  27266. if v == nil {
  27267. return
  27268. }
  27269. return *v, true
  27270. }
  27271. // ClearUserID clears the value of the "user_id" field.
  27272. func (m *WxCardVisitMutation) ClearUserID() {
  27273. m.user_id = nil
  27274. m.adduser_id = nil
  27275. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  27276. }
  27277. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  27278. func (m *WxCardVisitMutation) UserIDCleared() bool {
  27279. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  27280. return ok
  27281. }
  27282. // ResetUserID resets all changes to the "user_id" field.
  27283. func (m *WxCardVisitMutation) ResetUserID() {
  27284. m.user_id = nil
  27285. m.adduser_id = nil
  27286. delete(m.clearedFields, wxcardvisit.FieldUserID)
  27287. }
  27288. // SetBotID sets the "bot_id" field.
  27289. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  27290. m.bot_id = &u
  27291. m.addbot_id = nil
  27292. }
  27293. // BotID returns the value of the "bot_id" field in the mutation.
  27294. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  27295. v := m.bot_id
  27296. if v == nil {
  27297. return
  27298. }
  27299. return *v, true
  27300. }
  27301. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  27302. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  27303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27304. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  27305. if !m.op.Is(OpUpdateOne) {
  27306. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  27307. }
  27308. if m.id == nil || m.oldValue == nil {
  27309. return v, errors.New("OldBotID requires an ID field in the mutation")
  27310. }
  27311. oldValue, err := m.oldValue(ctx)
  27312. if err != nil {
  27313. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  27314. }
  27315. return oldValue.BotID, nil
  27316. }
  27317. // AddBotID adds u to the "bot_id" field.
  27318. func (m *WxCardVisitMutation) AddBotID(u int64) {
  27319. if m.addbot_id != nil {
  27320. *m.addbot_id += u
  27321. } else {
  27322. m.addbot_id = &u
  27323. }
  27324. }
  27325. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  27326. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  27327. v := m.addbot_id
  27328. if v == nil {
  27329. return
  27330. }
  27331. return *v, true
  27332. }
  27333. // ResetBotID resets all changes to the "bot_id" field.
  27334. func (m *WxCardVisitMutation) ResetBotID() {
  27335. m.bot_id = nil
  27336. m.addbot_id = nil
  27337. }
  27338. // SetBotType sets the "bot_type" field.
  27339. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  27340. m.bot_type = &u
  27341. m.addbot_type = nil
  27342. }
  27343. // BotType returns the value of the "bot_type" field in the mutation.
  27344. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  27345. v := m.bot_type
  27346. if v == nil {
  27347. return
  27348. }
  27349. return *v, true
  27350. }
  27351. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  27352. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  27353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27354. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  27355. if !m.op.Is(OpUpdateOne) {
  27356. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  27357. }
  27358. if m.id == nil || m.oldValue == nil {
  27359. return v, errors.New("OldBotType requires an ID field in the mutation")
  27360. }
  27361. oldValue, err := m.oldValue(ctx)
  27362. if err != nil {
  27363. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  27364. }
  27365. return oldValue.BotType, nil
  27366. }
  27367. // AddBotType adds u to the "bot_type" field.
  27368. func (m *WxCardVisitMutation) AddBotType(u int8) {
  27369. if m.addbot_type != nil {
  27370. *m.addbot_type += u
  27371. } else {
  27372. m.addbot_type = &u
  27373. }
  27374. }
  27375. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  27376. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  27377. v := m.addbot_type
  27378. if v == nil {
  27379. return
  27380. }
  27381. return *v, true
  27382. }
  27383. // ResetBotType resets all changes to the "bot_type" field.
  27384. func (m *WxCardVisitMutation) ResetBotType() {
  27385. m.bot_type = nil
  27386. m.addbot_type = nil
  27387. }
  27388. // Where appends a list predicates to the WxCardVisitMutation builder.
  27389. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  27390. m.predicates = append(m.predicates, ps...)
  27391. }
  27392. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  27393. // users can use type-assertion to append predicates that do not depend on any generated package.
  27394. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  27395. p := make([]predicate.WxCardVisit, len(ps))
  27396. for i := range ps {
  27397. p[i] = ps[i]
  27398. }
  27399. m.Where(p...)
  27400. }
  27401. // Op returns the operation name.
  27402. func (m *WxCardVisitMutation) Op() Op {
  27403. return m.op
  27404. }
  27405. // SetOp allows setting the mutation operation.
  27406. func (m *WxCardVisitMutation) SetOp(op Op) {
  27407. m.op = op
  27408. }
  27409. // Type returns the node type of this mutation (WxCardVisit).
  27410. func (m *WxCardVisitMutation) Type() string {
  27411. return m.typ
  27412. }
  27413. // Fields returns all fields that were changed during this mutation. Note that in
  27414. // order to get all numeric fields that were incremented/decremented, call
  27415. // AddedFields().
  27416. func (m *WxCardVisitMutation) Fields() []string {
  27417. fields := make([]string, 0, 6)
  27418. if m.created_at != nil {
  27419. fields = append(fields, wxcardvisit.FieldCreatedAt)
  27420. }
  27421. if m.updated_at != nil {
  27422. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  27423. }
  27424. if m.deleted_at != nil {
  27425. fields = append(fields, wxcardvisit.FieldDeletedAt)
  27426. }
  27427. if m.user_id != nil {
  27428. fields = append(fields, wxcardvisit.FieldUserID)
  27429. }
  27430. if m.bot_id != nil {
  27431. fields = append(fields, wxcardvisit.FieldBotID)
  27432. }
  27433. if m.bot_type != nil {
  27434. fields = append(fields, wxcardvisit.FieldBotType)
  27435. }
  27436. return fields
  27437. }
  27438. // Field returns the value of a field with the given name. The second boolean
  27439. // return value indicates that this field was not set, or was not defined in the
  27440. // schema.
  27441. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  27442. switch name {
  27443. case wxcardvisit.FieldCreatedAt:
  27444. return m.CreatedAt()
  27445. case wxcardvisit.FieldUpdatedAt:
  27446. return m.UpdatedAt()
  27447. case wxcardvisit.FieldDeletedAt:
  27448. return m.DeletedAt()
  27449. case wxcardvisit.FieldUserID:
  27450. return m.UserID()
  27451. case wxcardvisit.FieldBotID:
  27452. return m.BotID()
  27453. case wxcardvisit.FieldBotType:
  27454. return m.BotType()
  27455. }
  27456. return nil, false
  27457. }
  27458. // OldField returns the old value of the field from the database. An error is
  27459. // returned if the mutation operation is not UpdateOne, or the query to the
  27460. // database failed.
  27461. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27462. switch name {
  27463. case wxcardvisit.FieldCreatedAt:
  27464. return m.OldCreatedAt(ctx)
  27465. case wxcardvisit.FieldUpdatedAt:
  27466. return m.OldUpdatedAt(ctx)
  27467. case wxcardvisit.FieldDeletedAt:
  27468. return m.OldDeletedAt(ctx)
  27469. case wxcardvisit.FieldUserID:
  27470. return m.OldUserID(ctx)
  27471. case wxcardvisit.FieldBotID:
  27472. return m.OldBotID(ctx)
  27473. case wxcardvisit.FieldBotType:
  27474. return m.OldBotType(ctx)
  27475. }
  27476. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  27477. }
  27478. // SetField sets the value of a field with the given name. It returns an error if
  27479. // the field is not defined in the schema, or if the type mismatched the field
  27480. // type.
  27481. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  27482. switch name {
  27483. case wxcardvisit.FieldCreatedAt:
  27484. v, ok := value.(time.Time)
  27485. if !ok {
  27486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27487. }
  27488. m.SetCreatedAt(v)
  27489. return nil
  27490. case wxcardvisit.FieldUpdatedAt:
  27491. v, ok := value.(time.Time)
  27492. if !ok {
  27493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27494. }
  27495. m.SetUpdatedAt(v)
  27496. return nil
  27497. case wxcardvisit.FieldDeletedAt:
  27498. v, ok := value.(time.Time)
  27499. if !ok {
  27500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27501. }
  27502. m.SetDeletedAt(v)
  27503. return nil
  27504. case wxcardvisit.FieldUserID:
  27505. v, ok := value.(uint64)
  27506. if !ok {
  27507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27508. }
  27509. m.SetUserID(v)
  27510. return nil
  27511. case wxcardvisit.FieldBotID:
  27512. v, ok := value.(uint64)
  27513. if !ok {
  27514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27515. }
  27516. m.SetBotID(v)
  27517. return nil
  27518. case wxcardvisit.FieldBotType:
  27519. v, ok := value.(uint8)
  27520. if !ok {
  27521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27522. }
  27523. m.SetBotType(v)
  27524. return nil
  27525. }
  27526. return fmt.Errorf("unknown WxCardVisit field %s", name)
  27527. }
  27528. // AddedFields returns all numeric fields that were incremented/decremented during
  27529. // this mutation.
  27530. func (m *WxCardVisitMutation) AddedFields() []string {
  27531. var fields []string
  27532. if m.adduser_id != nil {
  27533. fields = append(fields, wxcardvisit.FieldUserID)
  27534. }
  27535. if m.addbot_id != nil {
  27536. fields = append(fields, wxcardvisit.FieldBotID)
  27537. }
  27538. if m.addbot_type != nil {
  27539. fields = append(fields, wxcardvisit.FieldBotType)
  27540. }
  27541. return fields
  27542. }
  27543. // AddedField returns the numeric value that was incremented/decremented on a field
  27544. // with the given name. The second boolean return value indicates that this field
  27545. // was not set, or was not defined in the schema.
  27546. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  27547. switch name {
  27548. case wxcardvisit.FieldUserID:
  27549. return m.AddedUserID()
  27550. case wxcardvisit.FieldBotID:
  27551. return m.AddedBotID()
  27552. case wxcardvisit.FieldBotType:
  27553. return m.AddedBotType()
  27554. }
  27555. return nil, false
  27556. }
  27557. // AddField adds the value to the field with the given name. It returns an error if
  27558. // the field is not defined in the schema, or if the type mismatched the field
  27559. // type.
  27560. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  27561. switch name {
  27562. case wxcardvisit.FieldUserID:
  27563. v, ok := value.(int64)
  27564. if !ok {
  27565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27566. }
  27567. m.AddUserID(v)
  27568. return nil
  27569. case wxcardvisit.FieldBotID:
  27570. v, ok := value.(int64)
  27571. if !ok {
  27572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27573. }
  27574. m.AddBotID(v)
  27575. return nil
  27576. case wxcardvisit.FieldBotType:
  27577. v, ok := value.(int8)
  27578. if !ok {
  27579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27580. }
  27581. m.AddBotType(v)
  27582. return nil
  27583. }
  27584. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  27585. }
  27586. // ClearedFields returns all nullable fields that were cleared during this
  27587. // mutation.
  27588. func (m *WxCardVisitMutation) ClearedFields() []string {
  27589. var fields []string
  27590. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  27591. fields = append(fields, wxcardvisit.FieldDeletedAt)
  27592. }
  27593. if m.FieldCleared(wxcardvisit.FieldUserID) {
  27594. fields = append(fields, wxcardvisit.FieldUserID)
  27595. }
  27596. return fields
  27597. }
  27598. // FieldCleared returns a boolean indicating if a field with the given name was
  27599. // cleared in this mutation.
  27600. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  27601. _, ok := m.clearedFields[name]
  27602. return ok
  27603. }
  27604. // ClearField clears the value of the field with the given name. It returns an
  27605. // error if the field is not defined in the schema.
  27606. func (m *WxCardVisitMutation) ClearField(name string) error {
  27607. switch name {
  27608. case wxcardvisit.FieldDeletedAt:
  27609. m.ClearDeletedAt()
  27610. return nil
  27611. case wxcardvisit.FieldUserID:
  27612. m.ClearUserID()
  27613. return nil
  27614. }
  27615. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  27616. }
  27617. // ResetField resets all changes in the mutation for the field with the given name.
  27618. // It returns an error if the field is not defined in the schema.
  27619. func (m *WxCardVisitMutation) ResetField(name string) error {
  27620. switch name {
  27621. case wxcardvisit.FieldCreatedAt:
  27622. m.ResetCreatedAt()
  27623. return nil
  27624. case wxcardvisit.FieldUpdatedAt:
  27625. m.ResetUpdatedAt()
  27626. return nil
  27627. case wxcardvisit.FieldDeletedAt:
  27628. m.ResetDeletedAt()
  27629. return nil
  27630. case wxcardvisit.FieldUserID:
  27631. m.ResetUserID()
  27632. return nil
  27633. case wxcardvisit.FieldBotID:
  27634. m.ResetBotID()
  27635. return nil
  27636. case wxcardvisit.FieldBotType:
  27637. m.ResetBotType()
  27638. return nil
  27639. }
  27640. return fmt.Errorf("unknown WxCardVisit field %s", name)
  27641. }
  27642. // AddedEdges returns all edge names that were set/added in this mutation.
  27643. func (m *WxCardVisitMutation) AddedEdges() []string {
  27644. edges := make([]string, 0, 0)
  27645. return edges
  27646. }
  27647. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27648. // name in this mutation.
  27649. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  27650. return nil
  27651. }
  27652. // RemovedEdges returns all edge names that were removed in this mutation.
  27653. func (m *WxCardVisitMutation) RemovedEdges() []string {
  27654. edges := make([]string, 0, 0)
  27655. return edges
  27656. }
  27657. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27658. // the given name in this mutation.
  27659. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  27660. return nil
  27661. }
  27662. // ClearedEdges returns all edge names that were cleared in this mutation.
  27663. func (m *WxCardVisitMutation) ClearedEdges() []string {
  27664. edges := make([]string, 0, 0)
  27665. return edges
  27666. }
  27667. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27668. // was cleared in this mutation.
  27669. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  27670. return false
  27671. }
  27672. // ClearEdge clears the value of the edge with the given name. It returns an error
  27673. // if that edge is not defined in the schema.
  27674. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  27675. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  27676. }
  27677. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27678. // It returns an error if the edge is not defined in the schema.
  27679. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  27680. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  27681. }