mutation.go 842 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597
  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/batchmsg"
  12. "wechat-api/ent/category"
  13. "wechat-api/ent/chatrecords"
  14. "wechat-api/ent/chatsession"
  15. "wechat-api/ent/contact"
  16. "wechat-api/ent/custom_types"
  17. "wechat-api/ent/employee"
  18. "wechat-api/ent/employeeconfig"
  19. "wechat-api/ent/label"
  20. "wechat-api/ent/labelrelationship"
  21. "wechat-api/ent/message"
  22. "wechat-api/ent/messagerecords"
  23. "wechat-api/ent/msg"
  24. "wechat-api/ent/predicate"
  25. "wechat-api/ent/server"
  26. "wechat-api/ent/sopnode"
  27. "wechat-api/ent/sopstage"
  28. "wechat-api/ent/soptask"
  29. "wechat-api/ent/token"
  30. "wechat-api/ent/tutorial"
  31. "wechat-api/ent/workexperience"
  32. "wechat-api/ent/wx"
  33. "wechat-api/ent/wxcard"
  34. "wechat-api/ent/wxcarduser"
  35. "wechat-api/ent/wxcardvisit"
  36. "entgo.io/ent"
  37. "entgo.io/ent/dialect/sql"
  38. )
  39. const (
  40. // Operation types.
  41. OpCreate = ent.OpCreate
  42. OpDelete = ent.OpDelete
  43. OpDeleteOne = ent.OpDeleteOne
  44. OpUpdate = ent.OpUpdate
  45. OpUpdateOne = ent.OpUpdateOne
  46. // Node types.
  47. TypeAgent = "Agent"
  48. TypeAgentBase = "AgentBase"
  49. TypeBatchMsg = "BatchMsg"
  50. TypeCategory = "Category"
  51. TypeChatRecords = "ChatRecords"
  52. TypeChatSession = "ChatSession"
  53. TypeContact = "Contact"
  54. TypeEmployee = "Employee"
  55. TypeEmployeeConfig = "EmployeeConfig"
  56. TypeLabel = "Label"
  57. TypeLabelRelationship = "LabelRelationship"
  58. TypeMessage = "Message"
  59. TypeMessageRecords = "MessageRecords"
  60. TypeMsg = "Msg"
  61. TypeServer = "Server"
  62. TypeSopNode = "SopNode"
  63. TypeSopStage = "SopStage"
  64. TypeSopTask = "SopTask"
  65. TypeToken = "Token"
  66. TypeTutorial = "Tutorial"
  67. TypeWorkExperience = "WorkExperience"
  68. TypeWx = "Wx"
  69. TypeWxCard = "WxCard"
  70. TypeWxCardUser = "WxCardUser"
  71. TypeWxCardVisit = "WxCardVisit"
  72. )
  73. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  74. type AgentMutation struct {
  75. config
  76. op Op
  77. typ string
  78. id *uint64
  79. created_at *time.Time
  80. updated_at *time.Time
  81. deleted_at *time.Time
  82. name *string
  83. role *string
  84. status *int
  85. addstatus *int
  86. background *string
  87. examples *string
  88. organization_id *uint64
  89. addorganization_id *int64
  90. dataset_id *string
  91. collection_id *string
  92. clearedFields map[string]struct{}
  93. wx_agent map[uint64]struct{}
  94. removedwx_agent map[uint64]struct{}
  95. clearedwx_agent bool
  96. done bool
  97. oldValue func(context.Context) (*Agent, error)
  98. predicates []predicate.Agent
  99. }
  100. var _ ent.Mutation = (*AgentMutation)(nil)
  101. // agentOption allows management of the mutation configuration using functional options.
  102. type agentOption func(*AgentMutation)
  103. // newAgentMutation creates new mutation for the Agent entity.
  104. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  105. m := &AgentMutation{
  106. config: c,
  107. op: op,
  108. typ: TypeAgent,
  109. clearedFields: make(map[string]struct{}),
  110. }
  111. for _, opt := range opts {
  112. opt(m)
  113. }
  114. return m
  115. }
  116. // withAgentID sets the ID field of the mutation.
  117. func withAgentID(id uint64) agentOption {
  118. return func(m *AgentMutation) {
  119. var (
  120. err error
  121. once sync.Once
  122. value *Agent
  123. )
  124. m.oldValue = func(ctx context.Context) (*Agent, error) {
  125. once.Do(func() {
  126. if m.done {
  127. err = errors.New("querying old values post mutation is not allowed")
  128. } else {
  129. value, err = m.Client().Agent.Get(ctx, id)
  130. }
  131. })
  132. return value, err
  133. }
  134. m.id = &id
  135. }
  136. }
  137. // withAgent sets the old Agent of the mutation.
  138. func withAgent(node *Agent) agentOption {
  139. return func(m *AgentMutation) {
  140. m.oldValue = func(context.Context) (*Agent, error) {
  141. return node, nil
  142. }
  143. m.id = &node.ID
  144. }
  145. }
  146. // Client returns a new `ent.Client` from the mutation. If the mutation was
  147. // executed in a transaction (ent.Tx), a transactional client is returned.
  148. func (m AgentMutation) Client() *Client {
  149. client := &Client{config: m.config}
  150. client.init()
  151. return client
  152. }
  153. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  154. // it returns an error otherwise.
  155. func (m AgentMutation) Tx() (*Tx, error) {
  156. if _, ok := m.driver.(*txDriver); !ok {
  157. return nil, errors.New("ent: mutation is not running in a transaction")
  158. }
  159. tx := &Tx{config: m.config}
  160. tx.init()
  161. return tx, nil
  162. }
  163. // SetID sets the value of the id field. Note that this
  164. // operation is only accepted on creation of Agent entities.
  165. func (m *AgentMutation) SetID(id uint64) {
  166. m.id = &id
  167. }
  168. // ID returns the ID value in the mutation. Note that the ID is only available
  169. // if it was provided to the builder or after it was returned from the database.
  170. func (m *AgentMutation) ID() (id uint64, exists bool) {
  171. if m.id == nil {
  172. return
  173. }
  174. return *m.id, true
  175. }
  176. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  177. // That means, if the mutation is applied within a transaction with an isolation level such
  178. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  179. // or updated by the mutation.
  180. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  181. switch {
  182. case m.op.Is(OpUpdateOne | OpDeleteOne):
  183. id, exists := m.ID()
  184. if exists {
  185. return []uint64{id}, nil
  186. }
  187. fallthrough
  188. case m.op.Is(OpUpdate | OpDelete):
  189. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  190. default:
  191. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  192. }
  193. }
  194. // SetCreatedAt sets the "created_at" field.
  195. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  196. m.created_at = &t
  197. }
  198. // CreatedAt returns the value of the "created_at" field in the mutation.
  199. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  200. v := m.created_at
  201. if v == nil {
  202. return
  203. }
  204. return *v, true
  205. }
  206. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  207. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  209. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  210. if !m.op.Is(OpUpdateOne) {
  211. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  212. }
  213. if m.id == nil || m.oldValue == nil {
  214. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  215. }
  216. oldValue, err := m.oldValue(ctx)
  217. if err != nil {
  218. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  219. }
  220. return oldValue.CreatedAt, nil
  221. }
  222. // ResetCreatedAt resets all changes to the "created_at" field.
  223. func (m *AgentMutation) ResetCreatedAt() {
  224. m.created_at = nil
  225. }
  226. // SetUpdatedAt sets the "updated_at" field.
  227. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  228. m.updated_at = &t
  229. }
  230. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  231. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  232. v := m.updated_at
  233. if v == nil {
  234. return
  235. }
  236. return *v, true
  237. }
  238. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  239. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  241. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  242. if !m.op.Is(OpUpdateOne) {
  243. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  244. }
  245. if m.id == nil || m.oldValue == nil {
  246. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  247. }
  248. oldValue, err := m.oldValue(ctx)
  249. if err != nil {
  250. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  251. }
  252. return oldValue.UpdatedAt, nil
  253. }
  254. // ResetUpdatedAt resets all changes to the "updated_at" field.
  255. func (m *AgentMutation) ResetUpdatedAt() {
  256. m.updated_at = nil
  257. }
  258. // SetDeletedAt sets the "deleted_at" field.
  259. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  260. m.deleted_at = &t
  261. }
  262. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  263. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  264. v := m.deleted_at
  265. if v == nil {
  266. return
  267. }
  268. return *v, true
  269. }
  270. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  271. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  273. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  274. if !m.op.Is(OpUpdateOne) {
  275. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  276. }
  277. if m.id == nil || m.oldValue == nil {
  278. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  279. }
  280. oldValue, err := m.oldValue(ctx)
  281. if err != nil {
  282. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  283. }
  284. return oldValue.DeletedAt, nil
  285. }
  286. // ClearDeletedAt clears the value of the "deleted_at" field.
  287. func (m *AgentMutation) ClearDeletedAt() {
  288. m.deleted_at = nil
  289. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  290. }
  291. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  292. func (m *AgentMutation) DeletedAtCleared() bool {
  293. _, ok := m.clearedFields[agent.FieldDeletedAt]
  294. return ok
  295. }
  296. // ResetDeletedAt resets all changes to the "deleted_at" field.
  297. func (m *AgentMutation) ResetDeletedAt() {
  298. m.deleted_at = nil
  299. delete(m.clearedFields, agent.FieldDeletedAt)
  300. }
  301. // SetName sets the "name" field.
  302. func (m *AgentMutation) SetName(s string) {
  303. m.name = &s
  304. }
  305. // Name returns the value of the "name" field in the mutation.
  306. func (m *AgentMutation) Name() (r string, exists bool) {
  307. v := m.name
  308. if v == nil {
  309. return
  310. }
  311. return *v, true
  312. }
  313. // OldName returns the old "name" field's value of the Agent entity.
  314. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  316. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  317. if !m.op.Is(OpUpdateOne) {
  318. return v, errors.New("OldName is only allowed on UpdateOne operations")
  319. }
  320. if m.id == nil || m.oldValue == nil {
  321. return v, errors.New("OldName requires an ID field in the mutation")
  322. }
  323. oldValue, err := m.oldValue(ctx)
  324. if err != nil {
  325. return v, fmt.Errorf("querying old value for OldName: %w", err)
  326. }
  327. return oldValue.Name, nil
  328. }
  329. // ResetName resets all changes to the "name" field.
  330. func (m *AgentMutation) ResetName() {
  331. m.name = nil
  332. }
  333. // SetRole sets the "role" field.
  334. func (m *AgentMutation) SetRole(s string) {
  335. m.role = &s
  336. }
  337. // Role returns the value of the "role" field in the mutation.
  338. func (m *AgentMutation) Role() (r string, exists bool) {
  339. v := m.role
  340. if v == nil {
  341. return
  342. }
  343. return *v, true
  344. }
  345. // OldRole returns the old "role" field's value of the Agent entity.
  346. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  348. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  349. if !m.op.Is(OpUpdateOne) {
  350. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  351. }
  352. if m.id == nil || m.oldValue == nil {
  353. return v, errors.New("OldRole requires an ID field in the mutation")
  354. }
  355. oldValue, err := m.oldValue(ctx)
  356. if err != nil {
  357. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  358. }
  359. return oldValue.Role, nil
  360. }
  361. // ResetRole resets all changes to the "role" field.
  362. func (m *AgentMutation) ResetRole() {
  363. m.role = nil
  364. }
  365. // SetStatus sets the "status" field.
  366. func (m *AgentMutation) SetStatus(i int) {
  367. m.status = &i
  368. m.addstatus = nil
  369. }
  370. // Status returns the value of the "status" field in the mutation.
  371. func (m *AgentMutation) Status() (r int, exists bool) {
  372. v := m.status
  373. if v == nil {
  374. return
  375. }
  376. return *v, true
  377. }
  378. // OldStatus returns the old "status" field's value of the Agent entity.
  379. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  381. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  382. if !m.op.Is(OpUpdateOne) {
  383. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  384. }
  385. if m.id == nil || m.oldValue == nil {
  386. return v, errors.New("OldStatus requires an ID field in the mutation")
  387. }
  388. oldValue, err := m.oldValue(ctx)
  389. if err != nil {
  390. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  391. }
  392. return oldValue.Status, nil
  393. }
  394. // AddStatus adds i to the "status" field.
  395. func (m *AgentMutation) AddStatus(i int) {
  396. if m.addstatus != nil {
  397. *m.addstatus += i
  398. } else {
  399. m.addstatus = &i
  400. }
  401. }
  402. // AddedStatus returns the value that was added to the "status" field in this mutation.
  403. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  404. v := m.addstatus
  405. if v == nil {
  406. return
  407. }
  408. return *v, true
  409. }
  410. // ClearStatus clears the value of the "status" field.
  411. func (m *AgentMutation) ClearStatus() {
  412. m.status = nil
  413. m.addstatus = nil
  414. m.clearedFields[agent.FieldStatus] = struct{}{}
  415. }
  416. // StatusCleared returns if the "status" field was cleared in this mutation.
  417. func (m *AgentMutation) StatusCleared() bool {
  418. _, ok := m.clearedFields[agent.FieldStatus]
  419. return ok
  420. }
  421. // ResetStatus resets all changes to the "status" field.
  422. func (m *AgentMutation) ResetStatus() {
  423. m.status = nil
  424. m.addstatus = nil
  425. delete(m.clearedFields, agent.FieldStatus)
  426. }
  427. // SetBackground sets the "background" field.
  428. func (m *AgentMutation) SetBackground(s string) {
  429. m.background = &s
  430. }
  431. // Background returns the value of the "background" field in the mutation.
  432. func (m *AgentMutation) Background() (r string, exists bool) {
  433. v := m.background
  434. if v == nil {
  435. return
  436. }
  437. return *v, true
  438. }
  439. // OldBackground returns the old "background" field's value of the Agent entity.
  440. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  442. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  443. if !m.op.Is(OpUpdateOne) {
  444. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  445. }
  446. if m.id == nil || m.oldValue == nil {
  447. return v, errors.New("OldBackground requires an ID field in the mutation")
  448. }
  449. oldValue, err := m.oldValue(ctx)
  450. if err != nil {
  451. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  452. }
  453. return oldValue.Background, nil
  454. }
  455. // ClearBackground clears the value of the "background" field.
  456. func (m *AgentMutation) ClearBackground() {
  457. m.background = nil
  458. m.clearedFields[agent.FieldBackground] = struct{}{}
  459. }
  460. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  461. func (m *AgentMutation) BackgroundCleared() bool {
  462. _, ok := m.clearedFields[agent.FieldBackground]
  463. return ok
  464. }
  465. // ResetBackground resets all changes to the "background" field.
  466. func (m *AgentMutation) ResetBackground() {
  467. m.background = nil
  468. delete(m.clearedFields, agent.FieldBackground)
  469. }
  470. // SetExamples sets the "examples" field.
  471. func (m *AgentMutation) SetExamples(s string) {
  472. m.examples = &s
  473. }
  474. // Examples returns the value of the "examples" field in the mutation.
  475. func (m *AgentMutation) Examples() (r string, exists bool) {
  476. v := m.examples
  477. if v == nil {
  478. return
  479. }
  480. return *v, true
  481. }
  482. // OldExamples returns the old "examples" field's value of the Agent entity.
  483. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  485. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  486. if !m.op.Is(OpUpdateOne) {
  487. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  488. }
  489. if m.id == nil || m.oldValue == nil {
  490. return v, errors.New("OldExamples requires an ID field in the mutation")
  491. }
  492. oldValue, err := m.oldValue(ctx)
  493. if err != nil {
  494. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  495. }
  496. return oldValue.Examples, nil
  497. }
  498. // ClearExamples clears the value of the "examples" field.
  499. func (m *AgentMutation) ClearExamples() {
  500. m.examples = nil
  501. m.clearedFields[agent.FieldExamples] = struct{}{}
  502. }
  503. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  504. func (m *AgentMutation) ExamplesCleared() bool {
  505. _, ok := m.clearedFields[agent.FieldExamples]
  506. return ok
  507. }
  508. // ResetExamples resets all changes to the "examples" field.
  509. func (m *AgentMutation) ResetExamples() {
  510. m.examples = nil
  511. delete(m.clearedFields, agent.FieldExamples)
  512. }
  513. // SetOrganizationID sets the "organization_id" field.
  514. func (m *AgentMutation) SetOrganizationID(u uint64) {
  515. m.organization_id = &u
  516. m.addorganization_id = nil
  517. }
  518. // OrganizationID returns the value of the "organization_id" field in the mutation.
  519. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  520. v := m.organization_id
  521. if v == nil {
  522. return
  523. }
  524. return *v, true
  525. }
  526. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  527. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  529. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  530. if !m.op.Is(OpUpdateOne) {
  531. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  532. }
  533. if m.id == nil || m.oldValue == nil {
  534. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  535. }
  536. oldValue, err := m.oldValue(ctx)
  537. if err != nil {
  538. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  539. }
  540. return oldValue.OrganizationID, nil
  541. }
  542. // AddOrganizationID adds u to the "organization_id" field.
  543. func (m *AgentMutation) AddOrganizationID(u int64) {
  544. if m.addorganization_id != nil {
  545. *m.addorganization_id += u
  546. } else {
  547. m.addorganization_id = &u
  548. }
  549. }
  550. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  551. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  552. v := m.addorganization_id
  553. if v == nil {
  554. return
  555. }
  556. return *v, true
  557. }
  558. // ResetOrganizationID resets all changes to the "organization_id" field.
  559. func (m *AgentMutation) ResetOrganizationID() {
  560. m.organization_id = nil
  561. m.addorganization_id = nil
  562. }
  563. // SetDatasetID sets the "dataset_id" field.
  564. func (m *AgentMutation) SetDatasetID(s string) {
  565. m.dataset_id = &s
  566. }
  567. // DatasetID returns the value of the "dataset_id" field in the mutation.
  568. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  569. v := m.dataset_id
  570. if v == nil {
  571. return
  572. }
  573. return *v, true
  574. }
  575. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  576. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  578. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  579. if !m.op.Is(OpUpdateOne) {
  580. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  581. }
  582. if m.id == nil || m.oldValue == nil {
  583. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  584. }
  585. oldValue, err := m.oldValue(ctx)
  586. if err != nil {
  587. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  588. }
  589. return oldValue.DatasetID, nil
  590. }
  591. // ResetDatasetID resets all changes to the "dataset_id" field.
  592. func (m *AgentMutation) ResetDatasetID() {
  593. m.dataset_id = nil
  594. }
  595. // SetCollectionID sets the "collection_id" field.
  596. func (m *AgentMutation) SetCollectionID(s string) {
  597. m.collection_id = &s
  598. }
  599. // CollectionID returns the value of the "collection_id" field in the mutation.
  600. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  601. v := m.collection_id
  602. if v == nil {
  603. return
  604. }
  605. return *v, true
  606. }
  607. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  608. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  610. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  611. if !m.op.Is(OpUpdateOne) {
  612. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  613. }
  614. if m.id == nil || m.oldValue == nil {
  615. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  616. }
  617. oldValue, err := m.oldValue(ctx)
  618. if err != nil {
  619. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  620. }
  621. return oldValue.CollectionID, nil
  622. }
  623. // ResetCollectionID resets all changes to the "collection_id" field.
  624. func (m *AgentMutation) ResetCollectionID() {
  625. m.collection_id = nil
  626. }
  627. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  628. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  629. if m.wx_agent == nil {
  630. m.wx_agent = make(map[uint64]struct{})
  631. }
  632. for i := range ids {
  633. m.wx_agent[ids[i]] = struct{}{}
  634. }
  635. }
  636. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  637. func (m *AgentMutation) ClearWxAgent() {
  638. m.clearedwx_agent = true
  639. }
  640. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  641. func (m *AgentMutation) WxAgentCleared() bool {
  642. return m.clearedwx_agent
  643. }
  644. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  645. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  646. if m.removedwx_agent == nil {
  647. m.removedwx_agent = make(map[uint64]struct{})
  648. }
  649. for i := range ids {
  650. delete(m.wx_agent, ids[i])
  651. m.removedwx_agent[ids[i]] = struct{}{}
  652. }
  653. }
  654. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  655. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  656. for id := range m.removedwx_agent {
  657. ids = append(ids, id)
  658. }
  659. return
  660. }
  661. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  662. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  663. for id := range m.wx_agent {
  664. ids = append(ids, id)
  665. }
  666. return
  667. }
  668. // ResetWxAgent resets all changes to the "wx_agent" edge.
  669. func (m *AgentMutation) ResetWxAgent() {
  670. m.wx_agent = nil
  671. m.clearedwx_agent = false
  672. m.removedwx_agent = nil
  673. }
  674. // Where appends a list predicates to the AgentMutation builder.
  675. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  676. m.predicates = append(m.predicates, ps...)
  677. }
  678. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  679. // users can use type-assertion to append predicates that do not depend on any generated package.
  680. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  681. p := make([]predicate.Agent, len(ps))
  682. for i := range ps {
  683. p[i] = ps[i]
  684. }
  685. m.Where(p...)
  686. }
  687. // Op returns the operation name.
  688. func (m *AgentMutation) Op() Op {
  689. return m.op
  690. }
  691. // SetOp allows setting the mutation operation.
  692. func (m *AgentMutation) SetOp(op Op) {
  693. m.op = op
  694. }
  695. // Type returns the node type of this mutation (Agent).
  696. func (m *AgentMutation) Type() string {
  697. return m.typ
  698. }
  699. // Fields returns all fields that were changed during this mutation. Note that in
  700. // order to get all numeric fields that were incremented/decremented, call
  701. // AddedFields().
  702. func (m *AgentMutation) Fields() []string {
  703. fields := make([]string, 0, 11)
  704. if m.created_at != nil {
  705. fields = append(fields, agent.FieldCreatedAt)
  706. }
  707. if m.updated_at != nil {
  708. fields = append(fields, agent.FieldUpdatedAt)
  709. }
  710. if m.deleted_at != nil {
  711. fields = append(fields, agent.FieldDeletedAt)
  712. }
  713. if m.name != nil {
  714. fields = append(fields, agent.FieldName)
  715. }
  716. if m.role != nil {
  717. fields = append(fields, agent.FieldRole)
  718. }
  719. if m.status != nil {
  720. fields = append(fields, agent.FieldStatus)
  721. }
  722. if m.background != nil {
  723. fields = append(fields, agent.FieldBackground)
  724. }
  725. if m.examples != nil {
  726. fields = append(fields, agent.FieldExamples)
  727. }
  728. if m.organization_id != nil {
  729. fields = append(fields, agent.FieldOrganizationID)
  730. }
  731. if m.dataset_id != nil {
  732. fields = append(fields, agent.FieldDatasetID)
  733. }
  734. if m.collection_id != nil {
  735. fields = append(fields, agent.FieldCollectionID)
  736. }
  737. return fields
  738. }
  739. // Field returns the value of a field with the given name. The second boolean
  740. // return value indicates that this field was not set, or was not defined in the
  741. // schema.
  742. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  743. switch name {
  744. case agent.FieldCreatedAt:
  745. return m.CreatedAt()
  746. case agent.FieldUpdatedAt:
  747. return m.UpdatedAt()
  748. case agent.FieldDeletedAt:
  749. return m.DeletedAt()
  750. case agent.FieldName:
  751. return m.Name()
  752. case agent.FieldRole:
  753. return m.Role()
  754. case agent.FieldStatus:
  755. return m.Status()
  756. case agent.FieldBackground:
  757. return m.Background()
  758. case agent.FieldExamples:
  759. return m.Examples()
  760. case agent.FieldOrganizationID:
  761. return m.OrganizationID()
  762. case agent.FieldDatasetID:
  763. return m.DatasetID()
  764. case agent.FieldCollectionID:
  765. return m.CollectionID()
  766. }
  767. return nil, false
  768. }
  769. // OldField returns the old value of the field from the database. An error is
  770. // returned if the mutation operation is not UpdateOne, or the query to the
  771. // database failed.
  772. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  773. switch name {
  774. case agent.FieldCreatedAt:
  775. return m.OldCreatedAt(ctx)
  776. case agent.FieldUpdatedAt:
  777. return m.OldUpdatedAt(ctx)
  778. case agent.FieldDeletedAt:
  779. return m.OldDeletedAt(ctx)
  780. case agent.FieldName:
  781. return m.OldName(ctx)
  782. case agent.FieldRole:
  783. return m.OldRole(ctx)
  784. case agent.FieldStatus:
  785. return m.OldStatus(ctx)
  786. case agent.FieldBackground:
  787. return m.OldBackground(ctx)
  788. case agent.FieldExamples:
  789. return m.OldExamples(ctx)
  790. case agent.FieldOrganizationID:
  791. return m.OldOrganizationID(ctx)
  792. case agent.FieldDatasetID:
  793. return m.OldDatasetID(ctx)
  794. case agent.FieldCollectionID:
  795. return m.OldCollectionID(ctx)
  796. }
  797. return nil, fmt.Errorf("unknown Agent field %s", name)
  798. }
  799. // SetField sets the value of a field with the given name. It returns an error if
  800. // the field is not defined in the schema, or if the type mismatched the field
  801. // type.
  802. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  803. switch name {
  804. case agent.FieldCreatedAt:
  805. v, ok := value.(time.Time)
  806. if !ok {
  807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  808. }
  809. m.SetCreatedAt(v)
  810. return nil
  811. case agent.FieldUpdatedAt:
  812. v, ok := value.(time.Time)
  813. if !ok {
  814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  815. }
  816. m.SetUpdatedAt(v)
  817. return nil
  818. case agent.FieldDeletedAt:
  819. v, ok := value.(time.Time)
  820. if !ok {
  821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  822. }
  823. m.SetDeletedAt(v)
  824. return nil
  825. case agent.FieldName:
  826. v, ok := value.(string)
  827. if !ok {
  828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  829. }
  830. m.SetName(v)
  831. return nil
  832. case agent.FieldRole:
  833. v, ok := value.(string)
  834. if !ok {
  835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  836. }
  837. m.SetRole(v)
  838. return nil
  839. case agent.FieldStatus:
  840. v, ok := value.(int)
  841. if !ok {
  842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  843. }
  844. m.SetStatus(v)
  845. return nil
  846. case agent.FieldBackground:
  847. v, ok := value.(string)
  848. if !ok {
  849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  850. }
  851. m.SetBackground(v)
  852. return nil
  853. case agent.FieldExamples:
  854. v, ok := value.(string)
  855. if !ok {
  856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  857. }
  858. m.SetExamples(v)
  859. return nil
  860. case agent.FieldOrganizationID:
  861. v, ok := value.(uint64)
  862. if !ok {
  863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  864. }
  865. m.SetOrganizationID(v)
  866. return nil
  867. case agent.FieldDatasetID:
  868. v, ok := value.(string)
  869. if !ok {
  870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  871. }
  872. m.SetDatasetID(v)
  873. return nil
  874. case agent.FieldCollectionID:
  875. v, ok := value.(string)
  876. if !ok {
  877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  878. }
  879. m.SetCollectionID(v)
  880. return nil
  881. }
  882. return fmt.Errorf("unknown Agent field %s", name)
  883. }
  884. // AddedFields returns all numeric fields that were incremented/decremented during
  885. // this mutation.
  886. func (m *AgentMutation) AddedFields() []string {
  887. var fields []string
  888. if m.addstatus != nil {
  889. fields = append(fields, agent.FieldStatus)
  890. }
  891. if m.addorganization_id != nil {
  892. fields = append(fields, agent.FieldOrganizationID)
  893. }
  894. return fields
  895. }
  896. // AddedField returns the numeric value that was incremented/decremented on a field
  897. // with the given name. The second boolean return value indicates that this field
  898. // was not set, or was not defined in the schema.
  899. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  900. switch name {
  901. case agent.FieldStatus:
  902. return m.AddedStatus()
  903. case agent.FieldOrganizationID:
  904. return m.AddedOrganizationID()
  905. }
  906. return nil, false
  907. }
  908. // AddField adds the value to the field with the given name. It returns an error if
  909. // the field is not defined in the schema, or if the type mismatched the field
  910. // type.
  911. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  912. switch name {
  913. case agent.FieldStatus:
  914. v, ok := value.(int)
  915. if !ok {
  916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  917. }
  918. m.AddStatus(v)
  919. return nil
  920. case agent.FieldOrganizationID:
  921. v, ok := value.(int64)
  922. if !ok {
  923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  924. }
  925. m.AddOrganizationID(v)
  926. return nil
  927. }
  928. return fmt.Errorf("unknown Agent numeric field %s", name)
  929. }
  930. // ClearedFields returns all nullable fields that were cleared during this
  931. // mutation.
  932. func (m *AgentMutation) ClearedFields() []string {
  933. var fields []string
  934. if m.FieldCleared(agent.FieldDeletedAt) {
  935. fields = append(fields, agent.FieldDeletedAt)
  936. }
  937. if m.FieldCleared(agent.FieldStatus) {
  938. fields = append(fields, agent.FieldStatus)
  939. }
  940. if m.FieldCleared(agent.FieldBackground) {
  941. fields = append(fields, agent.FieldBackground)
  942. }
  943. if m.FieldCleared(agent.FieldExamples) {
  944. fields = append(fields, agent.FieldExamples)
  945. }
  946. return fields
  947. }
  948. // FieldCleared returns a boolean indicating if a field with the given name was
  949. // cleared in this mutation.
  950. func (m *AgentMutation) FieldCleared(name string) bool {
  951. _, ok := m.clearedFields[name]
  952. return ok
  953. }
  954. // ClearField clears the value of the field with the given name. It returns an
  955. // error if the field is not defined in the schema.
  956. func (m *AgentMutation) ClearField(name string) error {
  957. switch name {
  958. case agent.FieldDeletedAt:
  959. m.ClearDeletedAt()
  960. return nil
  961. case agent.FieldStatus:
  962. m.ClearStatus()
  963. return nil
  964. case agent.FieldBackground:
  965. m.ClearBackground()
  966. return nil
  967. case agent.FieldExamples:
  968. m.ClearExamples()
  969. return nil
  970. }
  971. return fmt.Errorf("unknown Agent nullable field %s", name)
  972. }
  973. // ResetField resets all changes in the mutation for the field with the given name.
  974. // It returns an error if the field is not defined in the schema.
  975. func (m *AgentMutation) ResetField(name string) error {
  976. switch name {
  977. case agent.FieldCreatedAt:
  978. m.ResetCreatedAt()
  979. return nil
  980. case agent.FieldUpdatedAt:
  981. m.ResetUpdatedAt()
  982. return nil
  983. case agent.FieldDeletedAt:
  984. m.ResetDeletedAt()
  985. return nil
  986. case agent.FieldName:
  987. m.ResetName()
  988. return nil
  989. case agent.FieldRole:
  990. m.ResetRole()
  991. return nil
  992. case agent.FieldStatus:
  993. m.ResetStatus()
  994. return nil
  995. case agent.FieldBackground:
  996. m.ResetBackground()
  997. return nil
  998. case agent.FieldExamples:
  999. m.ResetExamples()
  1000. return nil
  1001. case agent.FieldOrganizationID:
  1002. m.ResetOrganizationID()
  1003. return nil
  1004. case agent.FieldDatasetID:
  1005. m.ResetDatasetID()
  1006. return nil
  1007. case agent.FieldCollectionID:
  1008. m.ResetCollectionID()
  1009. return nil
  1010. }
  1011. return fmt.Errorf("unknown Agent field %s", name)
  1012. }
  1013. // AddedEdges returns all edge names that were set/added in this mutation.
  1014. func (m *AgentMutation) AddedEdges() []string {
  1015. edges := make([]string, 0, 1)
  1016. if m.wx_agent != nil {
  1017. edges = append(edges, agent.EdgeWxAgent)
  1018. }
  1019. return edges
  1020. }
  1021. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1022. // name in this mutation.
  1023. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1024. switch name {
  1025. case agent.EdgeWxAgent:
  1026. ids := make([]ent.Value, 0, len(m.wx_agent))
  1027. for id := range m.wx_agent {
  1028. ids = append(ids, id)
  1029. }
  1030. return ids
  1031. }
  1032. return nil
  1033. }
  1034. // RemovedEdges returns all edge names that were removed in this mutation.
  1035. func (m *AgentMutation) RemovedEdges() []string {
  1036. edges := make([]string, 0, 1)
  1037. if m.removedwx_agent != nil {
  1038. edges = append(edges, agent.EdgeWxAgent)
  1039. }
  1040. return edges
  1041. }
  1042. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1043. // the given name in this mutation.
  1044. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1045. switch name {
  1046. case agent.EdgeWxAgent:
  1047. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1048. for id := range m.removedwx_agent {
  1049. ids = append(ids, id)
  1050. }
  1051. return ids
  1052. }
  1053. return nil
  1054. }
  1055. // ClearedEdges returns all edge names that were cleared in this mutation.
  1056. func (m *AgentMutation) ClearedEdges() []string {
  1057. edges := make([]string, 0, 1)
  1058. if m.clearedwx_agent {
  1059. edges = append(edges, agent.EdgeWxAgent)
  1060. }
  1061. return edges
  1062. }
  1063. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1064. // was cleared in this mutation.
  1065. func (m *AgentMutation) EdgeCleared(name string) bool {
  1066. switch name {
  1067. case agent.EdgeWxAgent:
  1068. return m.clearedwx_agent
  1069. }
  1070. return false
  1071. }
  1072. // ClearEdge clears the value of the edge with the given name. It returns an error
  1073. // if that edge is not defined in the schema.
  1074. func (m *AgentMutation) ClearEdge(name string) error {
  1075. switch name {
  1076. }
  1077. return fmt.Errorf("unknown Agent unique edge %s", name)
  1078. }
  1079. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1080. // It returns an error if the edge is not defined in the schema.
  1081. func (m *AgentMutation) ResetEdge(name string) error {
  1082. switch name {
  1083. case agent.EdgeWxAgent:
  1084. m.ResetWxAgent()
  1085. return nil
  1086. }
  1087. return fmt.Errorf("unknown Agent edge %s", name)
  1088. }
  1089. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1090. type AgentBaseMutation struct {
  1091. config
  1092. op Op
  1093. typ string
  1094. id *string
  1095. q *string
  1096. a *string
  1097. chunk_index *uint64
  1098. addchunk_index *int64
  1099. indexes *[]string
  1100. appendindexes []string
  1101. dataset_id *string
  1102. collection_id *string
  1103. source_name *string
  1104. can_write *[]bool
  1105. appendcan_write []bool
  1106. is_owner *[]bool
  1107. appendis_owner []bool
  1108. clearedFields map[string]struct{}
  1109. wx_agent map[uint64]struct{}
  1110. removedwx_agent map[uint64]struct{}
  1111. clearedwx_agent bool
  1112. done bool
  1113. oldValue func(context.Context) (*AgentBase, error)
  1114. predicates []predicate.AgentBase
  1115. }
  1116. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1117. // agentbaseOption allows management of the mutation configuration using functional options.
  1118. type agentbaseOption func(*AgentBaseMutation)
  1119. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1120. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1121. m := &AgentBaseMutation{
  1122. config: c,
  1123. op: op,
  1124. typ: TypeAgentBase,
  1125. clearedFields: make(map[string]struct{}),
  1126. }
  1127. for _, opt := range opts {
  1128. opt(m)
  1129. }
  1130. return m
  1131. }
  1132. // withAgentBaseID sets the ID field of the mutation.
  1133. func withAgentBaseID(id string) agentbaseOption {
  1134. return func(m *AgentBaseMutation) {
  1135. var (
  1136. err error
  1137. once sync.Once
  1138. value *AgentBase
  1139. )
  1140. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1141. once.Do(func() {
  1142. if m.done {
  1143. err = errors.New("querying old values post mutation is not allowed")
  1144. } else {
  1145. value, err = m.Client().AgentBase.Get(ctx, id)
  1146. }
  1147. })
  1148. return value, err
  1149. }
  1150. m.id = &id
  1151. }
  1152. }
  1153. // withAgentBase sets the old AgentBase of the mutation.
  1154. func withAgentBase(node *AgentBase) agentbaseOption {
  1155. return func(m *AgentBaseMutation) {
  1156. m.oldValue = func(context.Context) (*AgentBase, error) {
  1157. return node, nil
  1158. }
  1159. m.id = &node.ID
  1160. }
  1161. }
  1162. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1163. // executed in a transaction (ent.Tx), a transactional client is returned.
  1164. func (m AgentBaseMutation) Client() *Client {
  1165. client := &Client{config: m.config}
  1166. client.init()
  1167. return client
  1168. }
  1169. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1170. // it returns an error otherwise.
  1171. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1172. if _, ok := m.driver.(*txDriver); !ok {
  1173. return nil, errors.New("ent: mutation is not running in a transaction")
  1174. }
  1175. tx := &Tx{config: m.config}
  1176. tx.init()
  1177. return tx, nil
  1178. }
  1179. // SetID sets the value of the id field. Note that this
  1180. // operation is only accepted on creation of AgentBase entities.
  1181. func (m *AgentBaseMutation) SetID(id string) {
  1182. m.id = &id
  1183. }
  1184. // ID returns the ID value in the mutation. Note that the ID is only available
  1185. // if it was provided to the builder or after it was returned from the database.
  1186. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1187. if m.id == nil {
  1188. return
  1189. }
  1190. return *m.id, true
  1191. }
  1192. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1193. // That means, if the mutation is applied within a transaction with an isolation level such
  1194. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1195. // or updated by the mutation.
  1196. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1197. switch {
  1198. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1199. id, exists := m.ID()
  1200. if exists {
  1201. return []string{id}, nil
  1202. }
  1203. fallthrough
  1204. case m.op.Is(OpUpdate | OpDelete):
  1205. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1206. default:
  1207. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1208. }
  1209. }
  1210. // SetQ sets the "q" field.
  1211. func (m *AgentBaseMutation) SetQ(s string) {
  1212. m.q = &s
  1213. }
  1214. // Q returns the value of the "q" field in the mutation.
  1215. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1216. v := m.q
  1217. if v == nil {
  1218. return
  1219. }
  1220. return *v, true
  1221. }
  1222. // OldQ returns the old "q" field's value of the AgentBase entity.
  1223. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1225. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1226. if !m.op.Is(OpUpdateOne) {
  1227. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1228. }
  1229. if m.id == nil || m.oldValue == nil {
  1230. return v, errors.New("OldQ requires an ID field in the mutation")
  1231. }
  1232. oldValue, err := m.oldValue(ctx)
  1233. if err != nil {
  1234. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1235. }
  1236. return oldValue.Q, nil
  1237. }
  1238. // ClearQ clears the value of the "q" field.
  1239. func (m *AgentBaseMutation) ClearQ() {
  1240. m.q = nil
  1241. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1242. }
  1243. // QCleared returns if the "q" field was cleared in this mutation.
  1244. func (m *AgentBaseMutation) QCleared() bool {
  1245. _, ok := m.clearedFields[agentbase.FieldQ]
  1246. return ok
  1247. }
  1248. // ResetQ resets all changes to the "q" field.
  1249. func (m *AgentBaseMutation) ResetQ() {
  1250. m.q = nil
  1251. delete(m.clearedFields, agentbase.FieldQ)
  1252. }
  1253. // SetA sets the "a" field.
  1254. func (m *AgentBaseMutation) SetA(s string) {
  1255. m.a = &s
  1256. }
  1257. // A returns the value of the "a" field in the mutation.
  1258. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1259. v := m.a
  1260. if v == nil {
  1261. return
  1262. }
  1263. return *v, true
  1264. }
  1265. // OldA returns the old "a" field's value of the AgentBase entity.
  1266. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1268. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1269. if !m.op.Is(OpUpdateOne) {
  1270. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1271. }
  1272. if m.id == nil || m.oldValue == nil {
  1273. return v, errors.New("OldA requires an ID field in the mutation")
  1274. }
  1275. oldValue, err := m.oldValue(ctx)
  1276. if err != nil {
  1277. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1278. }
  1279. return oldValue.A, nil
  1280. }
  1281. // ClearA clears the value of the "a" field.
  1282. func (m *AgentBaseMutation) ClearA() {
  1283. m.a = nil
  1284. m.clearedFields[agentbase.FieldA] = struct{}{}
  1285. }
  1286. // ACleared returns if the "a" field was cleared in this mutation.
  1287. func (m *AgentBaseMutation) ACleared() bool {
  1288. _, ok := m.clearedFields[agentbase.FieldA]
  1289. return ok
  1290. }
  1291. // ResetA resets all changes to the "a" field.
  1292. func (m *AgentBaseMutation) ResetA() {
  1293. m.a = nil
  1294. delete(m.clearedFields, agentbase.FieldA)
  1295. }
  1296. // SetChunkIndex sets the "chunk_index" field.
  1297. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1298. m.chunk_index = &u
  1299. m.addchunk_index = nil
  1300. }
  1301. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1302. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1303. v := m.chunk_index
  1304. if v == nil {
  1305. return
  1306. }
  1307. return *v, true
  1308. }
  1309. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1310. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1312. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1313. if !m.op.Is(OpUpdateOne) {
  1314. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1315. }
  1316. if m.id == nil || m.oldValue == nil {
  1317. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1318. }
  1319. oldValue, err := m.oldValue(ctx)
  1320. if err != nil {
  1321. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1322. }
  1323. return oldValue.ChunkIndex, nil
  1324. }
  1325. // AddChunkIndex adds u to the "chunk_index" field.
  1326. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1327. if m.addchunk_index != nil {
  1328. *m.addchunk_index += u
  1329. } else {
  1330. m.addchunk_index = &u
  1331. }
  1332. }
  1333. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1334. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1335. v := m.addchunk_index
  1336. if v == nil {
  1337. return
  1338. }
  1339. return *v, true
  1340. }
  1341. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1342. func (m *AgentBaseMutation) ResetChunkIndex() {
  1343. m.chunk_index = nil
  1344. m.addchunk_index = nil
  1345. }
  1346. // SetIndexes sets the "indexes" field.
  1347. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1348. m.indexes = &s
  1349. m.appendindexes = nil
  1350. }
  1351. // Indexes returns the value of the "indexes" field in the mutation.
  1352. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1353. v := m.indexes
  1354. if v == nil {
  1355. return
  1356. }
  1357. return *v, true
  1358. }
  1359. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1360. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1362. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1363. if !m.op.Is(OpUpdateOne) {
  1364. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1365. }
  1366. if m.id == nil || m.oldValue == nil {
  1367. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1368. }
  1369. oldValue, err := m.oldValue(ctx)
  1370. if err != nil {
  1371. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1372. }
  1373. return oldValue.Indexes, nil
  1374. }
  1375. // AppendIndexes adds s to the "indexes" field.
  1376. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1377. m.appendindexes = append(m.appendindexes, s...)
  1378. }
  1379. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1380. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1381. if len(m.appendindexes) == 0 {
  1382. return nil, false
  1383. }
  1384. return m.appendindexes, true
  1385. }
  1386. // ClearIndexes clears the value of the "indexes" field.
  1387. func (m *AgentBaseMutation) ClearIndexes() {
  1388. m.indexes = nil
  1389. m.appendindexes = nil
  1390. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1391. }
  1392. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1393. func (m *AgentBaseMutation) IndexesCleared() bool {
  1394. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1395. return ok
  1396. }
  1397. // ResetIndexes resets all changes to the "indexes" field.
  1398. func (m *AgentBaseMutation) ResetIndexes() {
  1399. m.indexes = nil
  1400. m.appendindexes = nil
  1401. delete(m.clearedFields, agentbase.FieldIndexes)
  1402. }
  1403. // SetDatasetID sets the "dataset_id" field.
  1404. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1405. m.dataset_id = &s
  1406. }
  1407. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1408. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1409. v := m.dataset_id
  1410. if v == nil {
  1411. return
  1412. }
  1413. return *v, true
  1414. }
  1415. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1416. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1418. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1419. if !m.op.Is(OpUpdateOne) {
  1420. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1421. }
  1422. if m.id == nil || m.oldValue == nil {
  1423. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1424. }
  1425. oldValue, err := m.oldValue(ctx)
  1426. if err != nil {
  1427. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1428. }
  1429. return oldValue.DatasetID, nil
  1430. }
  1431. // ClearDatasetID clears the value of the "dataset_id" field.
  1432. func (m *AgentBaseMutation) ClearDatasetID() {
  1433. m.dataset_id = nil
  1434. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1435. }
  1436. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1437. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1438. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1439. return ok
  1440. }
  1441. // ResetDatasetID resets all changes to the "dataset_id" field.
  1442. func (m *AgentBaseMutation) ResetDatasetID() {
  1443. m.dataset_id = nil
  1444. delete(m.clearedFields, agentbase.FieldDatasetID)
  1445. }
  1446. // SetCollectionID sets the "collection_id" field.
  1447. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1448. m.collection_id = &s
  1449. }
  1450. // CollectionID returns the value of the "collection_id" field in the mutation.
  1451. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1452. v := m.collection_id
  1453. if v == nil {
  1454. return
  1455. }
  1456. return *v, true
  1457. }
  1458. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1459. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1461. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1462. if !m.op.Is(OpUpdateOne) {
  1463. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1464. }
  1465. if m.id == nil || m.oldValue == nil {
  1466. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1467. }
  1468. oldValue, err := m.oldValue(ctx)
  1469. if err != nil {
  1470. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1471. }
  1472. return oldValue.CollectionID, nil
  1473. }
  1474. // ClearCollectionID clears the value of the "collection_id" field.
  1475. func (m *AgentBaseMutation) ClearCollectionID() {
  1476. m.collection_id = nil
  1477. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1478. }
  1479. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1480. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1481. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1482. return ok
  1483. }
  1484. // ResetCollectionID resets all changes to the "collection_id" field.
  1485. func (m *AgentBaseMutation) ResetCollectionID() {
  1486. m.collection_id = nil
  1487. delete(m.clearedFields, agentbase.FieldCollectionID)
  1488. }
  1489. // SetSourceName sets the "source_name" field.
  1490. func (m *AgentBaseMutation) SetSourceName(s string) {
  1491. m.source_name = &s
  1492. }
  1493. // SourceName returns the value of the "source_name" field in the mutation.
  1494. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1495. v := m.source_name
  1496. if v == nil {
  1497. return
  1498. }
  1499. return *v, true
  1500. }
  1501. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1502. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1504. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1505. if !m.op.Is(OpUpdateOne) {
  1506. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1507. }
  1508. if m.id == nil || m.oldValue == nil {
  1509. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1510. }
  1511. oldValue, err := m.oldValue(ctx)
  1512. if err != nil {
  1513. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1514. }
  1515. return oldValue.SourceName, nil
  1516. }
  1517. // ClearSourceName clears the value of the "source_name" field.
  1518. func (m *AgentBaseMutation) ClearSourceName() {
  1519. m.source_name = nil
  1520. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1521. }
  1522. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1523. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1524. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1525. return ok
  1526. }
  1527. // ResetSourceName resets all changes to the "source_name" field.
  1528. func (m *AgentBaseMutation) ResetSourceName() {
  1529. m.source_name = nil
  1530. delete(m.clearedFields, agentbase.FieldSourceName)
  1531. }
  1532. // SetCanWrite sets the "can_write" field.
  1533. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1534. m.can_write = &b
  1535. m.appendcan_write = nil
  1536. }
  1537. // CanWrite returns the value of the "can_write" field in the mutation.
  1538. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1539. v := m.can_write
  1540. if v == nil {
  1541. return
  1542. }
  1543. return *v, true
  1544. }
  1545. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1546. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1548. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1549. if !m.op.Is(OpUpdateOne) {
  1550. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1551. }
  1552. if m.id == nil || m.oldValue == nil {
  1553. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1554. }
  1555. oldValue, err := m.oldValue(ctx)
  1556. if err != nil {
  1557. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1558. }
  1559. return oldValue.CanWrite, nil
  1560. }
  1561. // AppendCanWrite adds b to the "can_write" field.
  1562. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1563. m.appendcan_write = append(m.appendcan_write, b...)
  1564. }
  1565. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1566. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1567. if len(m.appendcan_write) == 0 {
  1568. return nil, false
  1569. }
  1570. return m.appendcan_write, true
  1571. }
  1572. // ClearCanWrite clears the value of the "can_write" field.
  1573. func (m *AgentBaseMutation) ClearCanWrite() {
  1574. m.can_write = nil
  1575. m.appendcan_write = nil
  1576. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1577. }
  1578. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1579. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1580. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1581. return ok
  1582. }
  1583. // ResetCanWrite resets all changes to the "can_write" field.
  1584. func (m *AgentBaseMutation) ResetCanWrite() {
  1585. m.can_write = nil
  1586. m.appendcan_write = nil
  1587. delete(m.clearedFields, agentbase.FieldCanWrite)
  1588. }
  1589. // SetIsOwner sets the "is_owner" field.
  1590. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1591. m.is_owner = &b
  1592. m.appendis_owner = nil
  1593. }
  1594. // IsOwner returns the value of the "is_owner" field in the mutation.
  1595. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1596. v := m.is_owner
  1597. if v == nil {
  1598. return
  1599. }
  1600. return *v, true
  1601. }
  1602. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1603. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1605. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1606. if !m.op.Is(OpUpdateOne) {
  1607. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1608. }
  1609. if m.id == nil || m.oldValue == nil {
  1610. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1611. }
  1612. oldValue, err := m.oldValue(ctx)
  1613. if err != nil {
  1614. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1615. }
  1616. return oldValue.IsOwner, nil
  1617. }
  1618. // AppendIsOwner adds b to the "is_owner" field.
  1619. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1620. m.appendis_owner = append(m.appendis_owner, b...)
  1621. }
  1622. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1623. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1624. if len(m.appendis_owner) == 0 {
  1625. return nil, false
  1626. }
  1627. return m.appendis_owner, true
  1628. }
  1629. // ClearIsOwner clears the value of the "is_owner" field.
  1630. func (m *AgentBaseMutation) ClearIsOwner() {
  1631. m.is_owner = nil
  1632. m.appendis_owner = nil
  1633. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1634. }
  1635. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1636. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1637. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1638. return ok
  1639. }
  1640. // ResetIsOwner resets all changes to the "is_owner" field.
  1641. func (m *AgentBaseMutation) ResetIsOwner() {
  1642. m.is_owner = nil
  1643. m.appendis_owner = nil
  1644. delete(m.clearedFields, agentbase.FieldIsOwner)
  1645. }
  1646. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1647. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1648. if m.wx_agent == nil {
  1649. m.wx_agent = make(map[uint64]struct{})
  1650. }
  1651. for i := range ids {
  1652. m.wx_agent[ids[i]] = struct{}{}
  1653. }
  1654. }
  1655. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1656. func (m *AgentBaseMutation) ClearWxAgent() {
  1657. m.clearedwx_agent = true
  1658. }
  1659. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1660. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1661. return m.clearedwx_agent
  1662. }
  1663. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1664. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1665. if m.removedwx_agent == nil {
  1666. m.removedwx_agent = make(map[uint64]struct{})
  1667. }
  1668. for i := range ids {
  1669. delete(m.wx_agent, ids[i])
  1670. m.removedwx_agent[ids[i]] = struct{}{}
  1671. }
  1672. }
  1673. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1674. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1675. for id := range m.removedwx_agent {
  1676. ids = append(ids, id)
  1677. }
  1678. return
  1679. }
  1680. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1681. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1682. for id := range m.wx_agent {
  1683. ids = append(ids, id)
  1684. }
  1685. return
  1686. }
  1687. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1688. func (m *AgentBaseMutation) ResetWxAgent() {
  1689. m.wx_agent = nil
  1690. m.clearedwx_agent = false
  1691. m.removedwx_agent = nil
  1692. }
  1693. // Where appends a list predicates to the AgentBaseMutation builder.
  1694. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1695. m.predicates = append(m.predicates, ps...)
  1696. }
  1697. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1698. // users can use type-assertion to append predicates that do not depend on any generated package.
  1699. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1700. p := make([]predicate.AgentBase, len(ps))
  1701. for i := range ps {
  1702. p[i] = ps[i]
  1703. }
  1704. m.Where(p...)
  1705. }
  1706. // Op returns the operation name.
  1707. func (m *AgentBaseMutation) Op() Op {
  1708. return m.op
  1709. }
  1710. // SetOp allows setting the mutation operation.
  1711. func (m *AgentBaseMutation) SetOp(op Op) {
  1712. m.op = op
  1713. }
  1714. // Type returns the node type of this mutation (AgentBase).
  1715. func (m *AgentBaseMutation) Type() string {
  1716. return m.typ
  1717. }
  1718. // Fields returns all fields that were changed during this mutation. Note that in
  1719. // order to get all numeric fields that were incremented/decremented, call
  1720. // AddedFields().
  1721. func (m *AgentBaseMutation) Fields() []string {
  1722. fields := make([]string, 0, 9)
  1723. if m.q != nil {
  1724. fields = append(fields, agentbase.FieldQ)
  1725. }
  1726. if m.a != nil {
  1727. fields = append(fields, agentbase.FieldA)
  1728. }
  1729. if m.chunk_index != nil {
  1730. fields = append(fields, agentbase.FieldChunkIndex)
  1731. }
  1732. if m.indexes != nil {
  1733. fields = append(fields, agentbase.FieldIndexes)
  1734. }
  1735. if m.dataset_id != nil {
  1736. fields = append(fields, agentbase.FieldDatasetID)
  1737. }
  1738. if m.collection_id != nil {
  1739. fields = append(fields, agentbase.FieldCollectionID)
  1740. }
  1741. if m.source_name != nil {
  1742. fields = append(fields, agentbase.FieldSourceName)
  1743. }
  1744. if m.can_write != nil {
  1745. fields = append(fields, agentbase.FieldCanWrite)
  1746. }
  1747. if m.is_owner != nil {
  1748. fields = append(fields, agentbase.FieldIsOwner)
  1749. }
  1750. return fields
  1751. }
  1752. // Field returns the value of a field with the given name. The second boolean
  1753. // return value indicates that this field was not set, or was not defined in the
  1754. // schema.
  1755. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1756. switch name {
  1757. case agentbase.FieldQ:
  1758. return m.Q()
  1759. case agentbase.FieldA:
  1760. return m.A()
  1761. case agentbase.FieldChunkIndex:
  1762. return m.ChunkIndex()
  1763. case agentbase.FieldIndexes:
  1764. return m.Indexes()
  1765. case agentbase.FieldDatasetID:
  1766. return m.DatasetID()
  1767. case agentbase.FieldCollectionID:
  1768. return m.CollectionID()
  1769. case agentbase.FieldSourceName:
  1770. return m.SourceName()
  1771. case agentbase.FieldCanWrite:
  1772. return m.CanWrite()
  1773. case agentbase.FieldIsOwner:
  1774. return m.IsOwner()
  1775. }
  1776. return nil, false
  1777. }
  1778. // OldField returns the old value of the field from the database. An error is
  1779. // returned if the mutation operation is not UpdateOne, or the query to the
  1780. // database failed.
  1781. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1782. switch name {
  1783. case agentbase.FieldQ:
  1784. return m.OldQ(ctx)
  1785. case agentbase.FieldA:
  1786. return m.OldA(ctx)
  1787. case agentbase.FieldChunkIndex:
  1788. return m.OldChunkIndex(ctx)
  1789. case agentbase.FieldIndexes:
  1790. return m.OldIndexes(ctx)
  1791. case agentbase.FieldDatasetID:
  1792. return m.OldDatasetID(ctx)
  1793. case agentbase.FieldCollectionID:
  1794. return m.OldCollectionID(ctx)
  1795. case agentbase.FieldSourceName:
  1796. return m.OldSourceName(ctx)
  1797. case agentbase.FieldCanWrite:
  1798. return m.OldCanWrite(ctx)
  1799. case agentbase.FieldIsOwner:
  1800. return m.OldIsOwner(ctx)
  1801. }
  1802. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1803. }
  1804. // SetField sets the value of a field with the given name. It returns an error if
  1805. // the field is not defined in the schema, or if the type mismatched the field
  1806. // type.
  1807. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1808. switch name {
  1809. case agentbase.FieldQ:
  1810. v, ok := value.(string)
  1811. if !ok {
  1812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1813. }
  1814. m.SetQ(v)
  1815. return nil
  1816. case agentbase.FieldA:
  1817. v, ok := value.(string)
  1818. if !ok {
  1819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1820. }
  1821. m.SetA(v)
  1822. return nil
  1823. case agentbase.FieldChunkIndex:
  1824. v, ok := value.(uint64)
  1825. if !ok {
  1826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1827. }
  1828. m.SetChunkIndex(v)
  1829. return nil
  1830. case agentbase.FieldIndexes:
  1831. v, ok := value.([]string)
  1832. if !ok {
  1833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1834. }
  1835. m.SetIndexes(v)
  1836. return nil
  1837. case agentbase.FieldDatasetID:
  1838. v, ok := value.(string)
  1839. if !ok {
  1840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1841. }
  1842. m.SetDatasetID(v)
  1843. return nil
  1844. case agentbase.FieldCollectionID:
  1845. v, ok := value.(string)
  1846. if !ok {
  1847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1848. }
  1849. m.SetCollectionID(v)
  1850. return nil
  1851. case agentbase.FieldSourceName:
  1852. v, ok := value.(string)
  1853. if !ok {
  1854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1855. }
  1856. m.SetSourceName(v)
  1857. return nil
  1858. case agentbase.FieldCanWrite:
  1859. v, ok := value.([]bool)
  1860. if !ok {
  1861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1862. }
  1863. m.SetCanWrite(v)
  1864. return nil
  1865. case agentbase.FieldIsOwner:
  1866. v, ok := value.([]bool)
  1867. if !ok {
  1868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1869. }
  1870. m.SetIsOwner(v)
  1871. return nil
  1872. }
  1873. return fmt.Errorf("unknown AgentBase field %s", name)
  1874. }
  1875. // AddedFields returns all numeric fields that were incremented/decremented during
  1876. // this mutation.
  1877. func (m *AgentBaseMutation) AddedFields() []string {
  1878. var fields []string
  1879. if m.addchunk_index != nil {
  1880. fields = append(fields, agentbase.FieldChunkIndex)
  1881. }
  1882. return fields
  1883. }
  1884. // AddedField returns the numeric value that was incremented/decremented on a field
  1885. // with the given name. The second boolean return value indicates that this field
  1886. // was not set, or was not defined in the schema.
  1887. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1888. switch name {
  1889. case agentbase.FieldChunkIndex:
  1890. return m.AddedChunkIndex()
  1891. }
  1892. return nil, false
  1893. }
  1894. // AddField adds the value to the field with the given name. It returns an error if
  1895. // the field is not defined in the schema, or if the type mismatched the field
  1896. // type.
  1897. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1898. switch name {
  1899. case agentbase.FieldChunkIndex:
  1900. v, ok := value.(int64)
  1901. if !ok {
  1902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1903. }
  1904. m.AddChunkIndex(v)
  1905. return nil
  1906. }
  1907. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  1908. }
  1909. // ClearedFields returns all nullable fields that were cleared during this
  1910. // mutation.
  1911. func (m *AgentBaseMutation) ClearedFields() []string {
  1912. var fields []string
  1913. if m.FieldCleared(agentbase.FieldQ) {
  1914. fields = append(fields, agentbase.FieldQ)
  1915. }
  1916. if m.FieldCleared(agentbase.FieldA) {
  1917. fields = append(fields, agentbase.FieldA)
  1918. }
  1919. if m.FieldCleared(agentbase.FieldIndexes) {
  1920. fields = append(fields, agentbase.FieldIndexes)
  1921. }
  1922. if m.FieldCleared(agentbase.FieldDatasetID) {
  1923. fields = append(fields, agentbase.FieldDatasetID)
  1924. }
  1925. if m.FieldCleared(agentbase.FieldCollectionID) {
  1926. fields = append(fields, agentbase.FieldCollectionID)
  1927. }
  1928. if m.FieldCleared(agentbase.FieldSourceName) {
  1929. fields = append(fields, agentbase.FieldSourceName)
  1930. }
  1931. if m.FieldCleared(agentbase.FieldCanWrite) {
  1932. fields = append(fields, agentbase.FieldCanWrite)
  1933. }
  1934. if m.FieldCleared(agentbase.FieldIsOwner) {
  1935. fields = append(fields, agentbase.FieldIsOwner)
  1936. }
  1937. return fields
  1938. }
  1939. // FieldCleared returns a boolean indicating if a field with the given name was
  1940. // cleared in this mutation.
  1941. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  1942. _, ok := m.clearedFields[name]
  1943. return ok
  1944. }
  1945. // ClearField clears the value of the field with the given name. It returns an
  1946. // error if the field is not defined in the schema.
  1947. func (m *AgentBaseMutation) ClearField(name string) error {
  1948. switch name {
  1949. case agentbase.FieldQ:
  1950. m.ClearQ()
  1951. return nil
  1952. case agentbase.FieldA:
  1953. m.ClearA()
  1954. return nil
  1955. case agentbase.FieldIndexes:
  1956. m.ClearIndexes()
  1957. return nil
  1958. case agentbase.FieldDatasetID:
  1959. m.ClearDatasetID()
  1960. return nil
  1961. case agentbase.FieldCollectionID:
  1962. m.ClearCollectionID()
  1963. return nil
  1964. case agentbase.FieldSourceName:
  1965. m.ClearSourceName()
  1966. return nil
  1967. case agentbase.FieldCanWrite:
  1968. m.ClearCanWrite()
  1969. return nil
  1970. case agentbase.FieldIsOwner:
  1971. m.ClearIsOwner()
  1972. return nil
  1973. }
  1974. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  1975. }
  1976. // ResetField resets all changes in the mutation for the field with the given name.
  1977. // It returns an error if the field is not defined in the schema.
  1978. func (m *AgentBaseMutation) ResetField(name string) error {
  1979. switch name {
  1980. case agentbase.FieldQ:
  1981. m.ResetQ()
  1982. return nil
  1983. case agentbase.FieldA:
  1984. m.ResetA()
  1985. return nil
  1986. case agentbase.FieldChunkIndex:
  1987. m.ResetChunkIndex()
  1988. return nil
  1989. case agentbase.FieldIndexes:
  1990. m.ResetIndexes()
  1991. return nil
  1992. case agentbase.FieldDatasetID:
  1993. m.ResetDatasetID()
  1994. return nil
  1995. case agentbase.FieldCollectionID:
  1996. m.ResetCollectionID()
  1997. return nil
  1998. case agentbase.FieldSourceName:
  1999. m.ResetSourceName()
  2000. return nil
  2001. case agentbase.FieldCanWrite:
  2002. m.ResetCanWrite()
  2003. return nil
  2004. case agentbase.FieldIsOwner:
  2005. m.ResetIsOwner()
  2006. return nil
  2007. }
  2008. return fmt.Errorf("unknown AgentBase field %s", name)
  2009. }
  2010. // AddedEdges returns all edge names that were set/added in this mutation.
  2011. func (m *AgentBaseMutation) AddedEdges() []string {
  2012. edges := make([]string, 0, 1)
  2013. if m.wx_agent != nil {
  2014. edges = append(edges, agentbase.EdgeWxAgent)
  2015. }
  2016. return edges
  2017. }
  2018. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2019. // name in this mutation.
  2020. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2021. switch name {
  2022. case agentbase.EdgeWxAgent:
  2023. ids := make([]ent.Value, 0, len(m.wx_agent))
  2024. for id := range m.wx_agent {
  2025. ids = append(ids, id)
  2026. }
  2027. return ids
  2028. }
  2029. return nil
  2030. }
  2031. // RemovedEdges returns all edge names that were removed in this mutation.
  2032. func (m *AgentBaseMutation) RemovedEdges() []string {
  2033. edges := make([]string, 0, 1)
  2034. if m.removedwx_agent != nil {
  2035. edges = append(edges, agentbase.EdgeWxAgent)
  2036. }
  2037. return edges
  2038. }
  2039. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2040. // the given name in this mutation.
  2041. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2042. switch name {
  2043. case agentbase.EdgeWxAgent:
  2044. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2045. for id := range m.removedwx_agent {
  2046. ids = append(ids, id)
  2047. }
  2048. return ids
  2049. }
  2050. return nil
  2051. }
  2052. // ClearedEdges returns all edge names that were cleared in this mutation.
  2053. func (m *AgentBaseMutation) ClearedEdges() []string {
  2054. edges := make([]string, 0, 1)
  2055. if m.clearedwx_agent {
  2056. edges = append(edges, agentbase.EdgeWxAgent)
  2057. }
  2058. return edges
  2059. }
  2060. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2061. // was cleared in this mutation.
  2062. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2063. switch name {
  2064. case agentbase.EdgeWxAgent:
  2065. return m.clearedwx_agent
  2066. }
  2067. return false
  2068. }
  2069. // ClearEdge clears the value of the edge with the given name. It returns an error
  2070. // if that edge is not defined in the schema.
  2071. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2072. switch name {
  2073. }
  2074. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2075. }
  2076. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2077. // It returns an error if the edge is not defined in the schema.
  2078. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2079. switch name {
  2080. case agentbase.EdgeWxAgent:
  2081. m.ResetWxAgent()
  2082. return nil
  2083. }
  2084. return fmt.Errorf("unknown AgentBase edge %s", name)
  2085. }
  2086. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  2087. type BatchMsgMutation struct {
  2088. config
  2089. op Op
  2090. typ string
  2091. id *uint64
  2092. created_at *time.Time
  2093. updated_at *time.Time
  2094. deleted_at *time.Time
  2095. status *uint8
  2096. addstatus *int8
  2097. batch_no *string
  2098. task_name *string
  2099. fromwxid *string
  2100. msg *string
  2101. tag *string
  2102. tagids *string
  2103. total *int32
  2104. addtotal *int32
  2105. success *int32
  2106. addsuccess *int32
  2107. fail *int32
  2108. addfail *int32
  2109. start_time *time.Time
  2110. stop_time *time.Time
  2111. send_time *time.Time
  2112. _type *int32
  2113. add_type *int32
  2114. organization_id *uint64
  2115. addorganization_id *int64
  2116. clearedFields map[string]struct{}
  2117. done bool
  2118. oldValue func(context.Context) (*BatchMsg, error)
  2119. predicates []predicate.BatchMsg
  2120. }
  2121. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  2122. // batchmsgOption allows management of the mutation configuration using functional options.
  2123. type batchmsgOption func(*BatchMsgMutation)
  2124. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  2125. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  2126. m := &BatchMsgMutation{
  2127. config: c,
  2128. op: op,
  2129. typ: TypeBatchMsg,
  2130. clearedFields: make(map[string]struct{}),
  2131. }
  2132. for _, opt := range opts {
  2133. opt(m)
  2134. }
  2135. return m
  2136. }
  2137. // withBatchMsgID sets the ID field of the mutation.
  2138. func withBatchMsgID(id uint64) batchmsgOption {
  2139. return func(m *BatchMsgMutation) {
  2140. var (
  2141. err error
  2142. once sync.Once
  2143. value *BatchMsg
  2144. )
  2145. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  2146. once.Do(func() {
  2147. if m.done {
  2148. err = errors.New("querying old values post mutation is not allowed")
  2149. } else {
  2150. value, err = m.Client().BatchMsg.Get(ctx, id)
  2151. }
  2152. })
  2153. return value, err
  2154. }
  2155. m.id = &id
  2156. }
  2157. }
  2158. // withBatchMsg sets the old BatchMsg of the mutation.
  2159. func withBatchMsg(node *BatchMsg) batchmsgOption {
  2160. return func(m *BatchMsgMutation) {
  2161. m.oldValue = func(context.Context) (*BatchMsg, error) {
  2162. return node, nil
  2163. }
  2164. m.id = &node.ID
  2165. }
  2166. }
  2167. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2168. // executed in a transaction (ent.Tx), a transactional client is returned.
  2169. func (m BatchMsgMutation) Client() *Client {
  2170. client := &Client{config: m.config}
  2171. client.init()
  2172. return client
  2173. }
  2174. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2175. // it returns an error otherwise.
  2176. func (m BatchMsgMutation) Tx() (*Tx, error) {
  2177. if _, ok := m.driver.(*txDriver); !ok {
  2178. return nil, errors.New("ent: mutation is not running in a transaction")
  2179. }
  2180. tx := &Tx{config: m.config}
  2181. tx.init()
  2182. return tx, nil
  2183. }
  2184. // SetID sets the value of the id field. Note that this
  2185. // operation is only accepted on creation of BatchMsg entities.
  2186. func (m *BatchMsgMutation) SetID(id uint64) {
  2187. m.id = &id
  2188. }
  2189. // ID returns the ID value in the mutation. Note that the ID is only available
  2190. // if it was provided to the builder or after it was returned from the database.
  2191. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  2192. if m.id == nil {
  2193. return
  2194. }
  2195. return *m.id, true
  2196. }
  2197. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2198. // That means, if the mutation is applied within a transaction with an isolation level such
  2199. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2200. // or updated by the mutation.
  2201. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  2202. switch {
  2203. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2204. id, exists := m.ID()
  2205. if exists {
  2206. return []uint64{id}, nil
  2207. }
  2208. fallthrough
  2209. case m.op.Is(OpUpdate | OpDelete):
  2210. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  2211. default:
  2212. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2213. }
  2214. }
  2215. // SetCreatedAt sets the "created_at" field.
  2216. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  2217. m.created_at = &t
  2218. }
  2219. // CreatedAt returns the value of the "created_at" field in the mutation.
  2220. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  2221. v := m.created_at
  2222. if v == nil {
  2223. return
  2224. }
  2225. return *v, true
  2226. }
  2227. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  2228. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2230. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2231. if !m.op.Is(OpUpdateOne) {
  2232. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2233. }
  2234. if m.id == nil || m.oldValue == nil {
  2235. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2236. }
  2237. oldValue, err := m.oldValue(ctx)
  2238. if err != nil {
  2239. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2240. }
  2241. return oldValue.CreatedAt, nil
  2242. }
  2243. // ResetCreatedAt resets all changes to the "created_at" field.
  2244. func (m *BatchMsgMutation) ResetCreatedAt() {
  2245. m.created_at = nil
  2246. }
  2247. // SetUpdatedAt sets the "updated_at" field.
  2248. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  2249. m.updated_at = &t
  2250. }
  2251. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2252. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  2253. v := m.updated_at
  2254. if v == nil {
  2255. return
  2256. }
  2257. return *v, true
  2258. }
  2259. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  2260. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2262. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2263. if !m.op.Is(OpUpdateOne) {
  2264. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2265. }
  2266. if m.id == nil || m.oldValue == nil {
  2267. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2268. }
  2269. oldValue, err := m.oldValue(ctx)
  2270. if err != nil {
  2271. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2272. }
  2273. return oldValue.UpdatedAt, nil
  2274. }
  2275. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2276. func (m *BatchMsgMutation) ResetUpdatedAt() {
  2277. m.updated_at = nil
  2278. }
  2279. // SetDeletedAt sets the "deleted_at" field.
  2280. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  2281. m.deleted_at = &t
  2282. }
  2283. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2284. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  2285. v := m.deleted_at
  2286. if v == nil {
  2287. return
  2288. }
  2289. return *v, true
  2290. }
  2291. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  2292. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2294. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2295. if !m.op.Is(OpUpdateOne) {
  2296. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2297. }
  2298. if m.id == nil || m.oldValue == nil {
  2299. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2300. }
  2301. oldValue, err := m.oldValue(ctx)
  2302. if err != nil {
  2303. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2304. }
  2305. return oldValue.DeletedAt, nil
  2306. }
  2307. // ClearDeletedAt clears the value of the "deleted_at" field.
  2308. func (m *BatchMsgMutation) ClearDeletedAt() {
  2309. m.deleted_at = nil
  2310. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  2311. }
  2312. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2313. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  2314. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  2315. return ok
  2316. }
  2317. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2318. func (m *BatchMsgMutation) ResetDeletedAt() {
  2319. m.deleted_at = nil
  2320. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  2321. }
  2322. // SetStatus sets the "status" field.
  2323. func (m *BatchMsgMutation) SetStatus(u uint8) {
  2324. m.status = &u
  2325. m.addstatus = nil
  2326. }
  2327. // Status returns the value of the "status" field in the mutation.
  2328. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  2329. v := m.status
  2330. if v == nil {
  2331. return
  2332. }
  2333. return *v, true
  2334. }
  2335. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  2336. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2338. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  2339. if !m.op.Is(OpUpdateOne) {
  2340. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  2341. }
  2342. if m.id == nil || m.oldValue == nil {
  2343. return v, errors.New("OldStatus requires an ID field in the mutation")
  2344. }
  2345. oldValue, err := m.oldValue(ctx)
  2346. if err != nil {
  2347. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  2348. }
  2349. return oldValue.Status, nil
  2350. }
  2351. // AddStatus adds u to the "status" field.
  2352. func (m *BatchMsgMutation) AddStatus(u int8) {
  2353. if m.addstatus != nil {
  2354. *m.addstatus += u
  2355. } else {
  2356. m.addstatus = &u
  2357. }
  2358. }
  2359. // AddedStatus returns the value that was added to the "status" field in this mutation.
  2360. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  2361. v := m.addstatus
  2362. if v == nil {
  2363. return
  2364. }
  2365. return *v, true
  2366. }
  2367. // ClearStatus clears the value of the "status" field.
  2368. func (m *BatchMsgMutation) ClearStatus() {
  2369. m.status = nil
  2370. m.addstatus = nil
  2371. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  2372. }
  2373. // StatusCleared returns if the "status" field was cleared in this mutation.
  2374. func (m *BatchMsgMutation) StatusCleared() bool {
  2375. _, ok := m.clearedFields[batchmsg.FieldStatus]
  2376. return ok
  2377. }
  2378. // ResetStatus resets all changes to the "status" field.
  2379. func (m *BatchMsgMutation) ResetStatus() {
  2380. m.status = nil
  2381. m.addstatus = nil
  2382. delete(m.clearedFields, batchmsg.FieldStatus)
  2383. }
  2384. // SetBatchNo sets the "batch_no" field.
  2385. func (m *BatchMsgMutation) SetBatchNo(s string) {
  2386. m.batch_no = &s
  2387. }
  2388. // BatchNo returns the value of the "batch_no" field in the mutation.
  2389. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  2390. v := m.batch_no
  2391. if v == nil {
  2392. return
  2393. }
  2394. return *v, true
  2395. }
  2396. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  2397. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2399. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  2400. if !m.op.Is(OpUpdateOne) {
  2401. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  2402. }
  2403. if m.id == nil || m.oldValue == nil {
  2404. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  2405. }
  2406. oldValue, err := m.oldValue(ctx)
  2407. if err != nil {
  2408. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  2409. }
  2410. return oldValue.BatchNo, nil
  2411. }
  2412. // ClearBatchNo clears the value of the "batch_no" field.
  2413. func (m *BatchMsgMutation) ClearBatchNo() {
  2414. m.batch_no = nil
  2415. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  2416. }
  2417. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  2418. func (m *BatchMsgMutation) BatchNoCleared() bool {
  2419. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  2420. return ok
  2421. }
  2422. // ResetBatchNo resets all changes to the "batch_no" field.
  2423. func (m *BatchMsgMutation) ResetBatchNo() {
  2424. m.batch_no = nil
  2425. delete(m.clearedFields, batchmsg.FieldBatchNo)
  2426. }
  2427. // SetTaskName sets the "task_name" field.
  2428. func (m *BatchMsgMutation) SetTaskName(s string) {
  2429. m.task_name = &s
  2430. }
  2431. // TaskName returns the value of the "task_name" field in the mutation.
  2432. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  2433. v := m.task_name
  2434. if v == nil {
  2435. return
  2436. }
  2437. return *v, true
  2438. }
  2439. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  2440. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2442. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  2443. if !m.op.Is(OpUpdateOne) {
  2444. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  2445. }
  2446. if m.id == nil || m.oldValue == nil {
  2447. return v, errors.New("OldTaskName requires an ID field in the mutation")
  2448. }
  2449. oldValue, err := m.oldValue(ctx)
  2450. if err != nil {
  2451. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  2452. }
  2453. return oldValue.TaskName, nil
  2454. }
  2455. // ClearTaskName clears the value of the "task_name" field.
  2456. func (m *BatchMsgMutation) ClearTaskName() {
  2457. m.task_name = nil
  2458. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  2459. }
  2460. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  2461. func (m *BatchMsgMutation) TaskNameCleared() bool {
  2462. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  2463. return ok
  2464. }
  2465. // ResetTaskName resets all changes to the "task_name" field.
  2466. func (m *BatchMsgMutation) ResetTaskName() {
  2467. m.task_name = nil
  2468. delete(m.clearedFields, batchmsg.FieldTaskName)
  2469. }
  2470. // SetFromwxid sets the "fromwxid" field.
  2471. func (m *BatchMsgMutation) SetFromwxid(s string) {
  2472. m.fromwxid = &s
  2473. }
  2474. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  2475. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  2476. v := m.fromwxid
  2477. if v == nil {
  2478. return
  2479. }
  2480. return *v, true
  2481. }
  2482. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  2483. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2485. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  2486. if !m.op.Is(OpUpdateOne) {
  2487. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  2488. }
  2489. if m.id == nil || m.oldValue == nil {
  2490. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  2491. }
  2492. oldValue, err := m.oldValue(ctx)
  2493. if err != nil {
  2494. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  2495. }
  2496. return oldValue.Fromwxid, nil
  2497. }
  2498. // ClearFromwxid clears the value of the "fromwxid" field.
  2499. func (m *BatchMsgMutation) ClearFromwxid() {
  2500. m.fromwxid = nil
  2501. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  2502. }
  2503. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  2504. func (m *BatchMsgMutation) FromwxidCleared() bool {
  2505. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  2506. return ok
  2507. }
  2508. // ResetFromwxid resets all changes to the "fromwxid" field.
  2509. func (m *BatchMsgMutation) ResetFromwxid() {
  2510. m.fromwxid = nil
  2511. delete(m.clearedFields, batchmsg.FieldFromwxid)
  2512. }
  2513. // SetMsg sets the "msg" field.
  2514. func (m *BatchMsgMutation) SetMsg(s string) {
  2515. m.msg = &s
  2516. }
  2517. // Msg returns the value of the "msg" field in the mutation.
  2518. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  2519. v := m.msg
  2520. if v == nil {
  2521. return
  2522. }
  2523. return *v, true
  2524. }
  2525. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  2526. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2528. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  2529. if !m.op.Is(OpUpdateOne) {
  2530. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  2531. }
  2532. if m.id == nil || m.oldValue == nil {
  2533. return v, errors.New("OldMsg requires an ID field in the mutation")
  2534. }
  2535. oldValue, err := m.oldValue(ctx)
  2536. if err != nil {
  2537. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  2538. }
  2539. return oldValue.Msg, nil
  2540. }
  2541. // ClearMsg clears the value of the "msg" field.
  2542. func (m *BatchMsgMutation) ClearMsg() {
  2543. m.msg = nil
  2544. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  2545. }
  2546. // MsgCleared returns if the "msg" field was cleared in this mutation.
  2547. func (m *BatchMsgMutation) MsgCleared() bool {
  2548. _, ok := m.clearedFields[batchmsg.FieldMsg]
  2549. return ok
  2550. }
  2551. // ResetMsg resets all changes to the "msg" field.
  2552. func (m *BatchMsgMutation) ResetMsg() {
  2553. m.msg = nil
  2554. delete(m.clearedFields, batchmsg.FieldMsg)
  2555. }
  2556. // SetTag sets the "tag" field.
  2557. func (m *BatchMsgMutation) SetTag(s string) {
  2558. m.tag = &s
  2559. }
  2560. // Tag returns the value of the "tag" field in the mutation.
  2561. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  2562. v := m.tag
  2563. if v == nil {
  2564. return
  2565. }
  2566. return *v, true
  2567. }
  2568. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  2569. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2571. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  2572. if !m.op.Is(OpUpdateOne) {
  2573. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  2574. }
  2575. if m.id == nil || m.oldValue == nil {
  2576. return v, errors.New("OldTag requires an ID field in the mutation")
  2577. }
  2578. oldValue, err := m.oldValue(ctx)
  2579. if err != nil {
  2580. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  2581. }
  2582. return oldValue.Tag, nil
  2583. }
  2584. // ClearTag clears the value of the "tag" field.
  2585. func (m *BatchMsgMutation) ClearTag() {
  2586. m.tag = nil
  2587. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  2588. }
  2589. // TagCleared returns if the "tag" field was cleared in this mutation.
  2590. func (m *BatchMsgMutation) TagCleared() bool {
  2591. _, ok := m.clearedFields[batchmsg.FieldTag]
  2592. return ok
  2593. }
  2594. // ResetTag resets all changes to the "tag" field.
  2595. func (m *BatchMsgMutation) ResetTag() {
  2596. m.tag = nil
  2597. delete(m.clearedFields, batchmsg.FieldTag)
  2598. }
  2599. // SetTagids sets the "tagids" field.
  2600. func (m *BatchMsgMutation) SetTagids(s string) {
  2601. m.tagids = &s
  2602. }
  2603. // Tagids returns the value of the "tagids" field in the mutation.
  2604. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  2605. v := m.tagids
  2606. if v == nil {
  2607. return
  2608. }
  2609. return *v, true
  2610. }
  2611. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  2612. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2614. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  2615. if !m.op.Is(OpUpdateOne) {
  2616. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  2617. }
  2618. if m.id == nil || m.oldValue == nil {
  2619. return v, errors.New("OldTagids requires an ID field in the mutation")
  2620. }
  2621. oldValue, err := m.oldValue(ctx)
  2622. if err != nil {
  2623. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  2624. }
  2625. return oldValue.Tagids, nil
  2626. }
  2627. // ClearTagids clears the value of the "tagids" field.
  2628. func (m *BatchMsgMutation) ClearTagids() {
  2629. m.tagids = nil
  2630. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  2631. }
  2632. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  2633. func (m *BatchMsgMutation) TagidsCleared() bool {
  2634. _, ok := m.clearedFields[batchmsg.FieldTagids]
  2635. return ok
  2636. }
  2637. // ResetTagids resets all changes to the "tagids" field.
  2638. func (m *BatchMsgMutation) ResetTagids() {
  2639. m.tagids = nil
  2640. delete(m.clearedFields, batchmsg.FieldTagids)
  2641. }
  2642. // SetTotal sets the "total" field.
  2643. func (m *BatchMsgMutation) SetTotal(i int32) {
  2644. m.total = &i
  2645. m.addtotal = nil
  2646. }
  2647. // Total returns the value of the "total" field in the mutation.
  2648. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  2649. v := m.total
  2650. if v == nil {
  2651. return
  2652. }
  2653. return *v, true
  2654. }
  2655. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  2656. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2658. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  2659. if !m.op.Is(OpUpdateOne) {
  2660. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  2661. }
  2662. if m.id == nil || m.oldValue == nil {
  2663. return v, errors.New("OldTotal requires an ID field in the mutation")
  2664. }
  2665. oldValue, err := m.oldValue(ctx)
  2666. if err != nil {
  2667. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  2668. }
  2669. return oldValue.Total, nil
  2670. }
  2671. // AddTotal adds i to the "total" field.
  2672. func (m *BatchMsgMutation) AddTotal(i int32) {
  2673. if m.addtotal != nil {
  2674. *m.addtotal += i
  2675. } else {
  2676. m.addtotal = &i
  2677. }
  2678. }
  2679. // AddedTotal returns the value that was added to the "total" field in this mutation.
  2680. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  2681. v := m.addtotal
  2682. if v == nil {
  2683. return
  2684. }
  2685. return *v, true
  2686. }
  2687. // ClearTotal clears the value of the "total" field.
  2688. func (m *BatchMsgMutation) ClearTotal() {
  2689. m.total = nil
  2690. m.addtotal = nil
  2691. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  2692. }
  2693. // TotalCleared returns if the "total" field was cleared in this mutation.
  2694. func (m *BatchMsgMutation) TotalCleared() bool {
  2695. _, ok := m.clearedFields[batchmsg.FieldTotal]
  2696. return ok
  2697. }
  2698. // ResetTotal resets all changes to the "total" field.
  2699. func (m *BatchMsgMutation) ResetTotal() {
  2700. m.total = nil
  2701. m.addtotal = nil
  2702. delete(m.clearedFields, batchmsg.FieldTotal)
  2703. }
  2704. // SetSuccess sets the "success" field.
  2705. func (m *BatchMsgMutation) SetSuccess(i int32) {
  2706. m.success = &i
  2707. m.addsuccess = nil
  2708. }
  2709. // Success returns the value of the "success" field in the mutation.
  2710. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  2711. v := m.success
  2712. if v == nil {
  2713. return
  2714. }
  2715. return *v, true
  2716. }
  2717. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  2718. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2720. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  2721. if !m.op.Is(OpUpdateOne) {
  2722. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  2723. }
  2724. if m.id == nil || m.oldValue == nil {
  2725. return v, errors.New("OldSuccess requires an ID field in the mutation")
  2726. }
  2727. oldValue, err := m.oldValue(ctx)
  2728. if err != nil {
  2729. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  2730. }
  2731. return oldValue.Success, nil
  2732. }
  2733. // AddSuccess adds i to the "success" field.
  2734. func (m *BatchMsgMutation) AddSuccess(i int32) {
  2735. if m.addsuccess != nil {
  2736. *m.addsuccess += i
  2737. } else {
  2738. m.addsuccess = &i
  2739. }
  2740. }
  2741. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  2742. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  2743. v := m.addsuccess
  2744. if v == nil {
  2745. return
  2746. }
  2747. return *v, true
  2748. }
  2749. // ClearSuccess clears the value of the "success" field.
  2750. func (m *BatchMsgMutation) ClearSuccess() {
  2751. m.success = nil
  2752. m.addsuccess = nil
  2753. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  2754. }
  2755. // SuccessCleared returns if the "success" field was cleared in this mutation.
  2756. func (m *BatchMsgMutation) SuccessCleared() bool {
  2757. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  2758. return ok
  2759. }
  2760. // ResetSuccess resets all changes to the "success" field.
  2761. func (m *BatchMsgMutation) ResetSuccess() {
  2762. m.success = nil
  2763. m.addsuccess = nil
  2764. delete(m.clearedFields, batchmsg.FieldSuccess)
  2765. }
  2766. // SetFail sets the "fail" field.
  2767. func (m *BatchMsgMutation) SetFail(i int32) {
  2768. m.fail = &i
  2769. m.addfail = nil
  2770. }
  2771. // Fail returns the value of the "fail" field in the mutation.
  2772. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  2773. v := m.fail
  2774. if v == nil {
  2775. return
  2776. }
  2777. return *v, true
  2778. }
  2779. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  2780. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2782. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  2783. if !m.op.Is(OpUpdateOne) {
  2784. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  2785. }
  2786. if m.id == nil || m.oldValue == nil {
  2787. return v, errors.New("OldFail requires an ID field in the mutation")
  2788. }
  2789. oldValue, err := m.oldValue(ctx)
  2790. if err != nil {
  2791. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  2792. }
  2793. return oldValue.Fail, nil
  2794. }
  2795. // AddFail adds i to the "fail" field.
  2796. func (m *BatchMsgMutation) AddFail(i int32) {
  2797. if m.addfail != nil {
  2798. *m.addfail += i
  2799. } else {
  2800. m.addfail = &i
  2801. }
  2802. }
  2803. // AddedFail returns the value that was added to the "fail" field in this mutation.
  2804. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  2805. v := m.addfail
  2806. if v == nil {
  2807. return
  2808. }
  2809. return *v, true
  2810. }
  2811. // ClearFail clears the value of the "fail" field.
  2812. func (m *BatchMsgMutation) ClearFail() {
  2813. m.fail = nil
  2814. m.addfail = nil
  2815. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  2816. }
  2817. // FailCleared returns if the "fail" field was cleared in this mutation.
  2818. func (m *BatchMsgMutation) FailCleared() bool {
  2819. _, ok := m.clearedFields[batchmsg.FieldFail]
  2820. return ok
  2821. }
  2822. // ResetFail resets all changes to the "fail" field.
  2823. func (m *BatchMsgMutation) ResetFail() {
  2824. m.fail = nil
  2825. m.addfail = nil
  2826. delete(m.clearedFields, batchmsg.FieldFail)
  2827. }
  2828. // SetStartTime sets the "start_time" field.
  2829. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  2830. m.start_time = &t
  2831. }
  2832. // StartTime returns the value of the "start_time" field in the mutation.
  2833. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  2834. v := m.start_time
  2835. if v == nil {
  2836. return
  2837. }
  2838. return *v, true
  2839. }
  2840. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  2841. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2843. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  2844. if !m.op.Is(OpUpdateOne) {
  2845. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  2846. }
  2847. if m.id == nil || m.oldValue == nil {
  2848. return v, errors.New("OldStartTime requires an ID field in the mutation")
  2849. }
  2850. oldValue, err := m.oldValue(ctx)
  2851. if err != nil {
  2852. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  2853. }
  2854. return oldValue.StartTime, nil
  2855. }
  2856. // ClearStartTime clears the value of the "start_time" field.
  2857. func (m *BatchMsgMutation) ClearStartTime() {
  2858. m.start_time = nil
  2859. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  2860. }
  2861. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  2862. func (m *BatchMsgMutation) StartTimeCleared() bool {
  2863. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  2864. return ok
  2865. }
  2866. // ResetStartTime resets all changes to the "start_time" field.
  2867. func (m *BatchMsgMutation) ResetStartTime() {
  2868. m.start_time = nil
  2869. delete(m.clearedFields, batchmsg.FieldStartTime)
  2870. }
  2871. // SetStopTime sets the "stop_time" field.
  2872. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  2873. m.stop_time = &t
  2874. }
  2875. // StopTime returns the value of the "stop_time" field in the mutation.
  2876. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  2877. v := m.stop_time
  2878. if v == nil {
  2879. return
  2880. }
  2881. return *v, true
  2882. }
  2883. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  2884. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2886. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  2887. if !m.op.Is(OpUpdateOne) {
  2888. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  2889. }
  2890. if m.id == nil || m.oldValue == nil {
  2891. return v, errors.New("OldStopTime requires an ID field in the mutation")
  2892. }
  2893. oldValue, err := m.oldValue(ctx)
  2894. if err != nil {
  2895. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  2896. }
  2897. return oldValue.StopTime, nil
  2898. }
  2899. // ClearStopTime clears the value of the "stop_time" field.
  2900. func (m *BatchMsgMutation) ClearStopTime() {
  2901. m.stop_time = nil
  2902. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  2903. }
  2904. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  2905. func (m *BatchMsgMutation) StopTimeCleared() bool {
  2906. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  2907. return ok
  2908. }
  2909. // ResetStopTime resets all changes to the "stop_time" field.
  2910. func (m *BatchMsgMutation) ResetStopTime() {
  2911. m.stop_time = nil
  2912. delete(m.clearedFields, batchmsg.FieldStopTime)
  2913. }
  2914. // SetSendTime sets the "send_time" field.
  2915. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  2916. m.send_time = &t
  2917. }
  2918. // SendTime returns the value of the "send_time" field in the mutation.
  2919. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  2920. v := m.send_time
  2921. if v == nil {
  2922. return
  2923. }
  2924. return *v, true
  2925. }
  2926. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  2927. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2929. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  2930. if !m.op.Is(OpUpdateOne) {
  2931. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  2932. }
  2933. if m.id == nil || m.oldValue == nil {
  2934. return v, errors.New("OldSendTime requires an ID field in the mutation")
  2935. }
  2936. oldValue, err := m.oldValue(ctx)
  2937. if err != nil {
  2938. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  2939. }
  2940. return oldValue.SendTime, nil
  2941. }
  2942. // ClearSendTime clears the value of the "send_time" field.
  2943. func (m *BatchMsgMutation) ClearSendTime() {
  2944. m.send_time = nil
  2945. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  2946. }
  2947. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  2948. func (m *BatchMsgMutation) SendTimeCleared() bool {
  2949. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  2950. return ok
  2951. }
  2952. // ResetSendTime resets all changes to the "send_time" field.
  2953. func (m *BatchMsgMutation) ResetSendTime() {
  2954. m.send_time = nil
  2955. delete(m.clearedFields, batchmsg.FieldSendTime)
  2956. }
  2957. // SetType sets the "type" field.
  2958. func (m *BatchMsgMutation) SetType(i int32) {
  2959. m._type = &i
  2960. m.add_type = nil
  2961. }
  2962. // GetType returns the value of the "type" field in the mutation.
  2963. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  2964. v := m._type
  2965. if v == nil {
  2966. return
  2967. }
  2968. return *v, true
  2969. }
  2970. // OldType returns the old "type" field's value of the BatchMsg entity.
  2971. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2973. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  2974. if !m.op.Is(OpUpdateOne) {
  2975. return v, errors.New("OldType is only allowed on UpdateOne operations")
  2976. }
  2977. if m.id == nil || m.oldValue == nil {
  2978. return v, errors.New("OldType requires an ID field in the mutation")
  2979. }
  2980. oldValue, err := m.oldValue(ctx)
  2981. if err != nil {
  2982. return v, fmt.Errorf("querying old value for OldType: %w", err)
  2983. }
  2984. return oldValue.Type, nil
  2985. }
  2986. // AddType adds i to the "type" field.
  2987. func (m *BatchMsgMutation) AddType(i int32) {
  2988. if m.add_type != nil {
  2989. *m.add_type += i
  2990. } else {
  2991. m.add_type = &i
  2992. }
  2993. }
  2994. // AddedType returns the value that was added to the "type" field in this mutation.
  2995. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  2996. v := m.add_type
  2997. if v == nil {
  2998. return
  2999. }
  3000. return *v, true
  3001. }
  3002. // ClearType clears the value of the "type" field.
  3003. func (m *BatchMsgMutation) ClearType() {
  3004. m._type = nil
  3005. m.add_type = nil
  3006. m.clearedFields[batchmsg.FieldType] = struct{}{}
  3007. }
  3008. // TypeCleared returns if the "type" field was cleared in this mutation.
  3009. func (m *BatchMsgMutation) TypeCleared() bool {
  3010. _, ok := m.clearedFields[batchmsg.FieldType]
  3011. return ok
  3012. }
  3013. // ResetType resets all changes to the "type" field.
  3014. func (m *BatchMsgMutation) ResetType() {
  3015. m._type = nil
  3016. m.add_type = nil
  3017. delete(m.clearedFields, batchmsg.FieldType)
  3018. }
  3019. // SetOrganizationID sets the "organization_id" field.
  3020. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  3021. m.organization_id = &u
  3022. m.addorganization_id = nil
  3023. }
  3024. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3025. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  3026. v := m.organization_id
  3027. if v == nil {
  3028. return
  3029. }
  3030. return *v, true
  3031. }
  3032. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  3033. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3035. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3036. if !m.op.Is(OpUpdateOne) {
  3037. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3038. }
  3039. if m.id == nil || m.oldValue == nil {
  3040. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3041. }
  3042. oldValue, err := m.oldValue(ctx)
  3043. if err != nil {
  3044. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3045. }
  3046. return oldValue.OrganizationID, nil
  3047. }
  3048. // AddOrganizationID adds u to the "organization_id" field.
  3049. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  3050. if m.addorganization_id != nil {
  3051. *m.addorganization_id += u
  3052. } else {
  3053. m.addorganization_id = &u
  3054. }
  3055. }
  3056. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3057. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  3058. v := m.addorganization_id
  3059. if v == nil {
  3060. return
  3061. }
  3062. return *v, true
  3063. }
  3064. // ResetOrganizationID resets all changes to the "organization_id" field.
  3065. func (m *BatchMsgMutation) ResetOrganizationID() {
  3066. m.organization_id = nil
  3067. m.addorganization_id = nil
  3068. }
  3069. // Where appends a list predicates to the BatchMsgMutation builder.
  3070. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  3071. m.predicates = append(m.predicates, ps...)
  3072. }
  3073. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  3074. // users can use type-assertion to append predicates that do not depend on any generated package.
  3075. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  3076. p := make([]predicate.BatchMsg, len(ps))
  3077. for i := range ps {
  3078. p[i] = ps[i]
  3079. }
  3080. m.Where(p...)
  3081. }
  3082. // Op returns the operation name.
  3083. func (m *BatchMsgMutation) Op() Op {
  3084. return m.op
  3085. }
  3086. // SetOp allows setting the mutation operation.
  3087. func (m *BatchMsgMutation) SetOp(op Op) {
  3088. m.op = op
  3089. }
  3090. // Type returns the node type of this mutation (BatchMsg).
  3091. func (m *BatchMsgMutation) Type() string {
  3092. return m.typ
  3093. }
  3094. // Fields returns all fields that were changed during this mutation. Note that in
  3095. // order to get all numeric fields that were incremented/decremented, call
  3096. // AddedFields().
  3097. func (m *BatchMsgMutation) Fields() []string {
  3098. fields := make([]string, 0, 18)
  3099. if m.created_at != nil {
  3100. fields = append(fields, batchmsg.FieldCreatedAt)
  3101. }
  3102. if m.updated_at != nil {
  3103. fields = append(fields, batchmsg.FieldUpdatedAt)
  3104. }
  3105. if m.deleted_at != nil {
  3106. fields = append(fields, batchmsg.FieldDeletedAt)
  3107. }
  3108. if m.status != nil {
  3109. fields = append(fields, batchmsg.FieldStatus)
  3110. }
  3111. if m.batch_no != nil {
  3112. fields = append(fields, batchmsg.FieldBatchNo)
  3113. }
  3114. if m.task_name != nil {
  3115. fields = append(fields, batchmsg.FieldTaskName)
  3116. }
  3117. if m.fromwxid != nil {
  3118. fields = append(fields, batchmsg.FieldFromwxid)
  3119. }
  3120. if m.msg != nil {
  3121. fields = append(fields, batchmsg.FieldMsg)
  3122. }
  3123. if m.tag != nil {
  3124. fields = append(fields, batchmsg.FieldTag)
  3125. }
  3126. if m.tagids != nil {
  3127. fields = append(fields, batchmsg.FieldTagids)
  3128. }
  3129. if m.total != nil {
  3130. fields = append(fields, batchmsg.FieldTotal)
  3131. }
  3132. if m.success != nil {
  3133. fields = append(fields, batchmsg.FieldSuccess)
  3134. }
  3135. if m.fail != nil {
  3136. fields = append(fields, batchmsg.FieldFail)
  3137. }
  3138. if m.start_time != nil {
  3139. fields = append(fields, batchmsg.FieldStartTime)
  3140. }
  3141. if m.stop_time != nil {
  3142. fields = append(fields, batchmsg.FieldStopTime)
  3143. }
  3144. if m.send_time != nil {
  3145. fields = append(fields, batchmsg.FieldSendTime)
  3146. }
  3147. if m._type != nil {
  3148. fields = append(fields, batchmsg.FieldType)
  3149. }
  3150. if m.organization_id != nil {
  3151. fields = append(fields, batchmsg.FieldOrganizationID)
  3152. }
  3153. return fields
  3154. }
  3155. // Field returns the value of a field with the given name. The second boolean
  3156. // return value indicates that this field was not set, or was not defined in the
  3157. // schema.
  3158. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  3159. switch name {
  3160. case batchmsg.FieldCreatedAt:
  3161. return m.CreatedAt()
  3162. case batchmsg.FieldUpdatedAt:
  3163. return m.UpdatedAt()
  3164. case batchmsg.FieldDeletedAt:
  3165. return m.DeletedAt()
  3166. case batchmsg.FieldStatus:
  3167. return m.Status()
  3168. case batchmsg.FieldBatchNo:
  3169. return m.BatchNo()
  3170. case batchmsg.FieldTaskName:
  3171. return m.TaskName()
  3172. case batchmsg.FieldFromwxid:
  3173. return m.Fromwxid()
  3174. case batchmsg.FieldMsg:
  3175. return m.Msg()
  3176. case batchmsg.FieldTag:
  3177. return m.Tag()
  3178. case batchmsg.FieldTagids:
  3179. return m.Tagids()
  3180. case batchmsg.FieldTotal:
  3181. return m.Total()
  3182. case batchmsg.FieldSuccess:
  3183. return m.Success()
  3184. case batchmsg.FieldFail:
  3185. return m.Fail()
  3186. case batchmsg.FieldStartTime:
  3187. return m.StartTime()
  3188. case batchmsg.FieldStopTime:
  3189. return m.StopTime()
  3190. case batchmsg.FieldSendTime:
  3191. return m.SendTime()
  3192. case batchmsg.FieldType:
  3193. return m.GetType()
  3194. case batchmsg.FieldOrganizationID:
  3195. return m.OrganizationID()
  3196. }
  3197. return nil, false
  3198. }
  3199. // OldField returns the old value of the field from the database. An error is
  3200. // returned if the mutation operation is not UpdateOne, or the query to the
  3201. // database failed.
  3202. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3203. switch name {
  3204. case batchmsg.FieldCreatedAt:
  3205. return m.OldCreatedAt(ctx)
  3206. case batchmsg.FieldUpdatedAt:
  3207. return m.OldUpdatedAt(ctx)
  3208. case batchmsg.FieldDeletedAt:
  3209. return m.OldDeletedAt(ctx)
  3210. case batchmsg.FieldStatus:
  3211. return m.OldStatus(ctx)
  3212. case batchmsg.FieldBatchNo:
  3213. return m.OldBatchNo(ctx)
  3214. case batchmsg.FieldTaskName:
  3215. return m.OldTaskName(ctx)
  3216. case batchmsg.FieldFromwxid:
  3217. return m.OldFromwxid(ctx)
  3218. case batchmsg.FieldMsg:
  3219. return m.OldMsg(ctx)
  3220. case batchmsg.FieldTag:
  3221. return m.OldTag(ctx)
  3222. case batchmsg.FieldTagids:
  3223. return m.OldTagids(ctx)
  3224. case batchmsg.FieldTotal:
  3225. return m.OldTotal(ctx)
  3226. case batchmsg.FieldSuccess:
  3227. return m.OldSuccess(ctx)
  3228. case batchmsg.FieldFail:
  3229. return m.OldFail(ctx)
  3230. case batchmsg.FieldStartTime:
  3231. return m.OldStartTime(ctx)
  3232. case batchmsg.FieldStopTime:
  3233. return m.OldStopTime(ctx)
  3234. case batchmsg.FieldSendTime:
  3235. return m.OldSendTime(ctx)
  3236. case batchmsg.FieldType:
  3237. return m.OldType(ctx)
  3238. case batchmsg.FieldOrganizationID:
  3239. return m.OldOrganizationID(ctx)
  3240. }
  3241. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  3242. }
  3243. // SetField sets the value of a field with the given name. It returns an error if
  3244. // the field is not defined in the schema, or if the type mismatched the field
  3245. // type.
  3246. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  3247. switch name {
  3248. case batchmsg.FieldCreatedAt:
  3249. v, ok := value.(time.Time)
  3250. if !ok {
  3251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3252. }
  3253. m.SetCreatedAt(v)
  3254. return nil
  3255. case batchmsg.FieldUpdatedAt:
  3256. v, ok := value.(time.Time)
  3257. if !ok {
  3258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3259. }
  3260. m.SetUpdatedAt(v)
  3261. return nil
  3262. case batchmsg.FieldDeletedAt:
  3263. v, ok := value.(time.Time)
  3264. if !ok {
  3265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3266. }
  3267. m.SetDeletedAt(v)
  3268. return nil
  3269. case batchmsg.FieldStatus:
  3270. v, ok := value.(uint8)
  3271. if !ok {
  3272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3273. }
  3274. m.SetStatus(v)
  3275. return nil
  3276. case batchmsg.FieldBatchNo:
  3277. v, ok := value.(string)
  3278. if !ok {
  3279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3280. }
  3281. m.SetBatchNo(v)
  3282. return nil
  3283. case batchmsg.FieldTaskName:
  3284. v, ok := value.(string)
  3285. if !ok {
  3286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3287. }
  3288. m.SetTaskName(v)
  3289. return nil
  3290. case batchmsg.FieldFromwxid:
  3291. v, ok := value.(string)
  3292. if !ok {
  3293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3294. }
  3295. m.SetFromwxid(v)
  3296. return nil
  3297. case batchmsg.FieldMsg:
  3298. v, ok := value.(string)
  3299. if !ok {
  3300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3301. }
  3302. m.SetMsg(v)
  3303. return nil
  3304. case batchmsg.FieldTag:
  3305. v, ok := value.(string)
  3306. if !ok {
  3307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3308. }
  3309. m.SetTag(v)
  3310. return nil
  3311. case batchmsg.FieldTagids:
  3312. v, ok := value.(string)
  3313. if !ok {
  3314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3315. }
  3316. m.SetTagids(v)
  3317. return nil
  3318. case batchmsg.FieldTotal:
  3319. v, ok := value.(int32)
  3320. if !ok {
  3321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3322. }
  3323. m.SetTotal(v)
  3324. return nil
  3325. case batchmsg.FieldSuccess:
  3326. v, ok := value.(int32)
  3327. if !ok {
  3328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3329. }
  3330. m.SetSuccess(v)
  3331. return nil
  3332. case batchmsg.FieldFail:
  3333. v, ok := value.(int32)
  3334. if !ok {
  3335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3336. }
  3337. m.SetFail(v)
  3338. return nil
  3339. case batchmsg.FieldStartTime:
  3340. v, ok := value.(time.Time)
  3341. if !ok {
  3342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3343. }
  3344. m.SetStartTime(v)
  3345. return nil
  3346. case batchmsg.FieldStopTime:
  3347. v, ok := value.(time.Time)
  3348. if !ok {
  3349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3350. }
  3351. m.SetStopTime(v)
  3352. return nil
  3353. case batchmsg.FieldSendTime:
  3354. v, ok := value.(time.Time)
  3355. if !ok {
  3356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3357. }
  3358. m.SetSendTime(v)
  3359. return nil
  3360. case batchmsg.FieldType:
  3361. v, ok := value.(int32)
  3362. if !ok {
  3363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3364. }
  3365. m.SetType(v)
  3366. return nil
  3367. case batchmsg.FieldOrganizationID:
  3368. v, ok := value.(uint64)
  3369. if !ok {
  3370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3371. }
  3372. m.SetOrganizationID(v)
  3373. return nil
  3374. }
  3375. return fmt.Errorf("unknown BatchMsg field %s", name)
  3376. }
  3377. // AddedFields returns all numeric fields that were incremented/decremented during
  3378. // this mutation.
  3379. func (m *BatchMsgMutation) AddedFields() []string {
  3380. var fields []string
  3381. if m.addstatus != nil {
  3382. fields = append(fields, batchmsg.FieldStatus)
  3383. }
  3384. if m.addtotal != nil {
  3385. fields = append(fields, batchmsg.FieldTotal)
  3386. }
  3387. if m.addsuccess != nil {
  3388. fields = append(fields, batchmsg.FieldSuccess)
  3389. }
  3390. if m.addfail != nil {
  3391. fields = append(fields, batchmsg.FieldFail)
  3392. }
  3393. if m.add_type != nil {
  3394. fields = append(fields, batchmsg.FieldType)
  3395. }
  3396. if m.addorganization_id != nil {
  3397. fields = append(fields, batchmsg.FieldOrganizationID)
  3398. }
  3399. return fields
  3400. }
  3401. // AddedField returns the numeric value that was incremented/decremented on a field
  3402. // with the given name. The second boolean return value indicates that this field
  3403. // was not set, or was not defined in the schema.
  3404. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  3405. switch name {
  3406. case batchmsg.FieldStatus:
  3407. return m.AddedStatus()
  3408. case batchmsg.FieldTotal:
  3409. return m.AddedTotal()
  3410. case batchmsg.FieldSuccess:
  3411. return m.AddedSuccess()
  3412. case batchmsg.FieldFail:
  3413. return m.AddedFail()
  3414. case batchmsg.FieldType:
  3415. return m.AddedType()
  3416. case batchmsg.FieldOrganizationID:
  3417. return m.AddedOrganizationID()
  3418. }
  3419. return nil, false
  3420. }
  3421. // AddField adds the value to the field with the given name. It returns an error if
  3422. // the field is not defined in the schema, or if the type mismatched the field
  3423. // type.
  3424. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  3425. switch name {
  3426. case batchmsg.FieldStatus:
  3427. v, ok := value.(int8)
  3428. if !ok {
  3429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3430. }
  3431. m.AddStatus(v)
  3432. return nil
  3433. case batchmsg.FieldTotal:
  3434. v, ok := value.(int32)
  3435. if !ok {
  3436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3437. }
  3438. m.AddTotal(v)
  3439. return nil
  3440. case batchmsg.FieldSuccess:
  3441. v, ok := value.(int32)
  3442. if !ok {
  3443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3444. }
  3445. m.AddSuccess(v)
  3446. return nil
  3447. case batchmsg.FieldFail:
  3448. v, ok := value.(int32)
  3449. if !ok {
  3450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3451. }
  3452. m.AddFail(v)
  3453. return nil
  3454. case batchmsg.FieldType:
  3455. v, ok := value.(int32)
  3456. if !ok {
  3457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3458. }
  3459. m.AddType(v)
  3460. return nil
  3461. case batchmsg.FieldOrganizationID:
  3462. v, ok := value.(int64)
  3463. if !ok {
  3464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3465. }
  3466. m.AddOrganizationID(v)
  3467. return nil
  3468. }
  3469. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  3470. }
  3471. // ClearedFields returns all nullable fields that were cleared during this
  3472. // mutation.
  3473. func (m *BatchMsgMutation) ClearedFields() []string {
  3474. var fields []string
  3475. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  3476. fields = append(fields, batchmsg.FieldDeletedAt)
  3477. }
  3478. if m.FieldCleared(batchmsg.FieldStatus) {
  3479. fields = append(fields, batchmsg.FieldStatus)
  3480. }
  3481. if m.FieldCleared(batchmsg.FieldBatchNo) {
  3482. fields = append(fields, batchmsg.FieldBatchNo)
  3483. }
  3484. if m.FieldCleared(batchmsg.FieldTaskName) {
  3485. fields = append(fields, batchmsg.FieldTaskName)
  3486. }
  3487. if m.FieldCleared(batchmsg.FieldFromwxid) {
  3488. fields = append(fields, batchmsg.FieldFromwxid)
  3489. }
  3490. if m.FieldCleared(batchmsg.FieldMsg) {
  3491. fields = append(fields, batchmsg.FieldMsg)
  3492. }
  3493. if m.FieldCleared(batchmsg.FieldTag) {
  3494. fields = append(fields, batchmsg.FieldTag)
  3495. }
  3496. if m.FieldCleared(batchmsg.FieldTagids) {
  3497. fields = append(fields, batchmsg.FieldTagids)
  3498. }
  3499. if m.FieldCleared(batchmsg.FieldTotal) {
  3500. fields = append(fields, batchmsg.FieldTotal)
  3501. }
  3502. if m.FieldCleared(batchmsg.FieldSuccess) {
  3503. fields = append(fields, batchmsg.FieldSuccess)
  3504. }
  3505. if m.FieldCleared(batchmsg.FieldFail) {
  3506. fields = append(fields, batchmsg.FieldFail)
  3507. }
  3508. if m.FieldCleared(batchmsg.FieldStartTime) {
  3509. fields = append(fields, batchmsg.FieldStartTime)
  3510. }
  3511. if m.FieldCleared(batchmsg.FieldStopTime) {
  3512. fields = append(fields, batchmsg.FieldStopTime)
  3513. }
  3514. if m.FieldCleared(batchmsg.FieldSendTime) {
  3515. fields = append(fields, batchmsg.FieldSendTime)
  3516. }
  3517. if m.FieldCleared(batchmsg.FieldType) {
  3518. fields = append(fields, batchmsg.FieldType)
  3519. }
  3520. return fields
  3521. }
  3522. // FieldCleared returns a boolean indicating if a field with the given name was
  3523. // cleared in this mutation.
  3524. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  3525. _, ok := m.clearedFields[name]
  3526. return ok
  3527. }
  3528. // ClearField clears the value of the field with the given name. It returns an
  3529. // error if the field is not defined in the schema.
  3530. func (m *BatchMsgMutation) ClearField(name string) error {
  3531. switch name {
  3532. case batchmsg.FieldDeletedAt:
  3533. m.ClearDeletedAt()
  3534. return nil
  3535. case batchmsg.FieldStatus:
  3536. m.ClearStatus()
  3537. return nil
  3538. case batchmsg.FieldBatchNo:
  3539. m.ClearBatchNo()
  3540. return nil
  3541. case batchmsg.FieldTaskName:
  3542. m.ClearTaskName()
  3543. return nil
  3544. case batchmsg.FieldFromwxid:
  3545. m.ClearFromwxid()
  3546. return nil
  3547. case batchmsg.FieldMsg:
  3548. m.ClearMsg()
  3549. return nil
  3550. case batchmsg.FieldTag:
  3551. m.ClearTag()
  3552. return nil
  3553. case batchmsg.FieldTagids:
  3554. m.ClearTagids()
  3555. return nil
  3556. case batchmsg.FieldTotal:
  3557. m.ClearTotal()
  3558. return nil
  3559. case batchmsg.FieldSuccess:
  3560. m.ClearSuccess()
  3561. return nil
  3562. case batchmsg.FieldFail:
  3563. m.ClearFail()
  3564. return nil
  3565. case batchmsg.FieldStartTime:
  3566. m.ClearStartTime()
  3567. return nil
  3568. case batchmsg.FieldStopTime:
  3569. m.ClearStopTime()
  3570. return nil
  3571. case batchmsg.FieldSendTime:
  3572. m.ClearSendTime()
  3573. return nil
  3574. case batchmsg.FieldType:
  3575. m.ClearType()
  3576. return nil
  3577. }
  3578. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  3579. }
  3580. // ResetField resets all changes in the mutation for the field with the given name.
  3581. // It returns an error if the field is not defined in the schema.
  3582. func (m *BatchMsgMutation) ResetField(name string) error {
  3583. switch name {
  3584. case batchmsg.FieldCreatedAt:
  3585. m.ResetCreatedAt()
  3586. return nil
  3587. case batchmsg.FieldUpdatedAt:
  3588. m.ResetUpdatedAt()
  3589. return nil
  3590. case batchmsg.FieldDeletedAt:
  3591. m.ResetDeletedAt()
  3592. return nil
  3593. case batchmsg.FieldStatus:
  3594. m.ResetStatus()
  3595. return nil
  3596. case batchmsg.FieldBatchNo:
  3597. m.ResetBatchNo()
  3598. return nil
  3599. case batchmsg.FieldTaskName:
  3600. m.ResetTaskName()
  3601. return nil
  3602. case batchmsg.FieldFromwxid:
  3603. m.ResetFromwxid()
  3604. return nil
  3605. case batchmsg.FieldMsg:
  3606. m.ResetMsg()
  3607. return nil
  3608. case batchmsg.FieldTag:
  3609. m.ResetTag()
  3610. return nil
  3611. case batchmsg.FieldTagids:
  3612. m.ResetTagids()
  3613. return nil
  3614. case batchmsg.FieldTotal:
  3615. m.ResetTotal()
  3616. return nil
  3617. case batchmsg.FieldSuccess:
  3618. m.ResetSuccess()
  3619. return nil
  3620. case batchmsg.FieldFail:
  3621. m.ResetFail()
  3622. return nil
  3623. case batchmsg.FieldStartTime:
  3624. m.ResetStartTime()
  3625. return nil
  3626. case batchmsg.FieldStopTime:
  3627. m.ResetStopTime()
  3628. return nil
  3629. case batchmsg.FieldSendTime:
  3630. m.ResetSendTime()
  3631. return nil
  3632. case batchmsg.FieldType:
  3633. m.ResetType()
  3634. return nil
  3635. case batchmsg.FieldOrganizationID:
  3636. m.ResetOrganizationID()
  3637. return nil
  3638. }
  3639. return fmt.Errorf("unknown BatchMsg field %s", name)
  3640. }
  3641. // AddedEdges returns all edge names that were set/added in this mutation.
  3642. func (m *BatchMsgMutation) AddedEdges() []string {
  3643. edges := make([]string, 0, 0)
  3644. return edges
  3645. }
  3646. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3647. // name in this mutation.
  3648. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  3649. return nil
  3650. }
  3651. // RemovedEdges returns all edge names that were removed in this mutation.
  3652. func (m *BatchMsgMutation) RemovedEdges() []string {
  3653. edges := make([]string, 0, 0)
  3654. return edges
  3655. }
  3656. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3657. // the given name in this mutation.
  3658. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  3659. return nil
  3660. }
  3661. // ClearedEdges returns all edge names that were cleared in this mutation.
  3662. func (m *BatchMsgMutation) ClearedEdges() []string {
  3663. edges := make([]string, 0, 0)
  3664. return edges
  3665. }
  3666. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3667. // was cleared in this mutation.
  3668. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  3669. return false
  3670. }
  3671. // ClearEdge clears the value of the edge with the given name. It returns an error
  3672. // if that edge is not defined in the schema.
  3673. func (m *BatchMsgMutation) ClearEdge(name string) error {
  3674. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  3675. }
  3676. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3677. // It returns an error if the edge is not defined in the schema.
  3678. func (m *BatchMsgMutation) ResetEdge(name string) error {
  3679. return fmt.Errorf("unknown BatchMsg edge %s", name)
  3680. }
  3681. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  3682. type CategoryMutation struct {
  3683. config
  3684. op Op
  3685. typ string
  3686. id *uint64
  3687. created_at *time.Time
  3688. updated_at *time.Time
  3689. deleted_at *time.Time
  3690. name *string
  3691. organization_id *uint64
  3692. addorganization_id *int64
  3693. clearedFields map[string]struct{}
  3694. done bool
  3695. oldValue func(context.Context) (*Category, error)
  3696. predicates []predicate.Category
  3697. }
  3698. var _ ent.Mutation = (*CategoryMutation)(nil)
  3699. // categoryOption allows management of the mutation configuration using functional options.
  3700. type categoryOption func(*CategoryMutation)
  3701. // newCategoryMutation creates new mutation for the Category entity.
  3702. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  3703. m := &CategoryMutation{
  3704. config: c,
  3705. op: op,
  3706. typ: TypeCategory,
  3707. clearedFields: make(map[string]struct{}),
  3708. }
  3709. for _, opt := range opts {
  3710. opt(m)
  3711. }
  3712. return m
  3713. }
  3714. // withCategoryID sets the ID field of the mutation.
  3715. func withCategoryID(id uint64) categoryOption {
  3716. return func(m *CategoryMutation) {
  3717. var (
  3718. err error
  3719. once sync.Once
  3720. value *Category
  3721. )
  3722. m.oldValue = func(ctx context.Context) (*Category, error) {
  3723. once.Do(func() {
  3724. if m.done {
  3725. err = errors.New("querying old values post mutation is not allowed")
  3726. } else {
  3727. value, err = m.Client().Category.Get(ctx, id)
  3728. }
  3729. })
  3730. return value, err
  3731. }
  3732. m.id = &id
  3733. }
  3734. }
  3735. // withCategory sets the old Category of the mutation.
  3736. func withCategory(node *Category) categoryOption {
  3737. return func(m *CategoryMutation) {
  3738. m.oldValue = func(context.Context) (*Category, error) {
  3739. return node, nil
  3740. }
  3741. m.id = &node.ID
  3742. }
  3743. }
  3744. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3745. // executed in a transaction (ent.Tx), a transactional client is returned.
  3746. func (m CategoryMutation) Client() *Client {
  3747. client := &Client{config: m.config}
  3748. client.init()
  3749. return client
  3750. }
  3751. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3752. // it returns an error otherwise.
  3753. func (m CategoryMutation) Tx() (*Tx, error) {
  3754. if _, ok := m.driver.(*txDriver); !ok {
  3755. return nil, errors.New("ent: mutation is not running in a transaction")
  3756. }
  3757. tx := &Tx{config: m.config}
  3758. tx.init()
  3759. return tx, nil
  3760. }
  3761. // SetID sets the value of the id field. Note that this
  3762. // operation is only accepted on creation of Category entities.
  3763. func (m *CategoryMutation) SetID(id uint64) {
  3764. m.id = &id
  3765. }
  3766. // ID returns the ID value in the mutation. Note that the ID is only available
  3767. // if it was provided to the builder or after it was returned from the database.
  3768. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  3769. if m.id == nil {
  3770. return
  3771. }
  3772. return *m.id, true
  3773. }
  3774. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3775. // That means, if the mutation is applied within a transaction with an isolation level such
  3776. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3777. // or updated by the mutation.
  3778. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  3779. switch {
  3780. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3781. id, exists := m.ID()
  3782. if exists {
  3783. return []uint64{id}, nil
  3784. }
  3785. fallthrough
  3786. case m.op.Is(OpUpdate | OpDelete):
  3787. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  3788. default:
  3789. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3790. }
  3791. }
  3792. // SetCreatedAt sets the "created_at" field.
  3793. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  3794. m.created_at = &t
  3795. }
  3796. // CreatedAt returns the value of the "created_at" field in the mutation.
  3797. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  3798. v := m.created_at
  3799. if v == nil {
  3800. return
  3801. }
  3802. return *v, true
  3803. }
  3804. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  3805. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  3806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3807. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3808. if !m.op.Is(OpUpdateOne) {
  3809. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3810. }
  3811. if m.id == nil || m.oldValue == nil {
  3812. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3813. }
  3814. oldValue, err := m.oldValue(ctx)
  3815. if err != nil {
  3816. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3817. }
  3818. return oldValue.CreatedAt, nil
  3819. }
  3820. // ResetCreatedAt resets all changes to the "created_at" field.
  3821. func (m *CategoryMutation) ResetCreatedAt() {
  3822. m.created_at = nil
  3823. }
  3824. // SetUpdatedAt sets the "updated_at" field.
  3825. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  3826. m.updated_at = &t
  3827. }
  3828. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3829. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  3830. v := m.updated_at
  3831. if v == nil {
  3832. return
  3833. }
  3834. return *v, true
  3835. }
  3836. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  3837. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  3838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3839. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3840. if !m.op.Is(OpUpdateOne) {
  3841. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3842. }
  3843. if m.id == nil || m.oldValue == nil {
  3844. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3845. }
  3846. oldValue, err := m.oldValue(ctx)
  3847. if err != nil {
  3848. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3849. }
  3850. return oldValue.UpdatedAt, nil
  3851. }
  3852. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3853. func (m *CategoryMutation) ResetUpdatedAt() {
  3854. m.updated_at = nil
  3855. }
  3856. // SetDeletedAt sets the "deleted_at" field.
  3857. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  3858. m.deleted_at = &t
  3859. }
  3860. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3861. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  3862. v := m.deleted_at
  3863. if v == nil {
  3864. return
  3865. }
  3866. return *v, true
  3867. }
  3868. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  3869. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  3870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3871. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3872. if !m.op.Is(OpUpdateOne) {
  3873. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3874. }
  3875. if m.id == nil || m.oldValue == nil {
  3876. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3877. }
  3878. oldValue, err := m.oldValue(ctx)
  3879. if err != nil {
  3880. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3881. }
  3882. return oldValue.DeletedAt, nil
  3883. }
  3884. // ClearDeletedAt clears the value of the "deleted_at" field.
  3885. func (m *CategoryMutation) ClearDeletedAt() {
  3886. m.deleted_at = nil
  3887. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  3888. }
  3889. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3890. func (m *CategoryMutation) DeletedAtCleared() bool {
  3891. _, ok := m.clearedFields[category.FieldDeletedAt]
  3892. return ok
  3893. }
  3894. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3895. func (m *CategoryMutation) ResetDeletedAt() {
  3896. m.deleted_at = nil
  3897. delete(m.clearedFields, category.FieldDeletedAt)
  3898. }
  3899. // SetName sets the "name" field.
  3900. func (m *CategoryMutation) SetName(s string) {
  3901. m.name = &s
  3902. }
  3903. // Name returns the value of the "name" field in the mutation.
  3904. func (m *CategoryMutation) Name() (r string, exists bool) {
  3905. v := m.name
  3906. if v == nil {
  3907. return
  3908. }
  3909. return *v, true
  3910. }
  3911. // OldName returns the old "name" field's value of the Category entity.
  3912. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  3913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3914. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  3915. if !m.op.Is(OpUpdateOne) {
  3916. return v, errors.New("OldName is only allowed on UpdateOne operations")
  3917. }
  3918. if m.id == nil || m.oldValue == nil {
  3919. return v, errors.New("OldName requires an ID field in the mutation")
  3920. }
  3921. oldValue, err := m.oldValue(ctx)
  3922. if err != nil {
  3923. return v, fmt.Errorf("querying old value for OldName: %w", err)
  3924. }
  3925. return oldValue.Name, nil
  3926. }
  3927. // ResetName resets all changes to the "name" field.
  3928. func (m *CategoryMutation) ResetName() {
  3929. m.name = nil
  3930. }
  3931. // SetOrganizationID sets the "organization_id" field.
  3932. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  3933. m.organization_id = &u
  3934. m.addorganization_id = nil
  3935. }
  3936. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3937. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  3938. v := m.organization_id
  3939. if v == nil {
  3940. return
  3941. }
  3942. return *v, true
  3943. }
  3944. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  3945. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  3946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3947. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3948. if !m.op.Is(OpUpdateOne) {
  3949. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3950. }
  3951. if m.id == nil || m.oldValue == nil {
  3952. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3953. }
  3954. oldValue, err := m.oldValue(ctx)
  3955. if err != nil {
  3956. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3957. }
  3958. return oldValue.OrganizationID, nil
  3959. }
  3960. // AddOrganizationID adds u to the "organization_id" field.
  3961. func (m *CategoryMutation) AddOrganizationID(u int64) {
  3962. if m.addorganization_id != nil {
  3963. *m.addorganization_id += u
  3964. } else {
  3965. m.addorganization_id = &u
  3966. }
  3967. }
  3968. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3969. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  3970. v := m.addorganization_id
  3971. if v == nil {
  3972. return
  3973. }
  3974. return *v, true
  3975. }
  3976. // ResetOrganizationID resets all changes to the "organization_id" field.
  3977. func (m *CategoryMutation) ResetOrganizationID() {
  3978. m.organization_id = nil
  3979. m.addorganization_id = nil
  3980. }
  3981. // Where appends a list predicates to the CategoryMutation builder.
  3982. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  3983. m.predicates = append(m.predicates, ps...)
  3984. }
  3985. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  3986. // users can use type-assertion to append predicates that do not depend on any generated package.
  3987. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  3988. p := make([]predicate.Category, len(ps))
  3989. for i := range ps {
  3990. p[i] = ps[i]
  3991. }
  3992. m.Where(p...)
  3993. }
  3994. // Op returns the operation name.
  3995. func (m *CategoryMutation) Op() Op {
  3996. return m.op
  3997. }
  3998. // SetOp allows setting the mutation operation.
  3999. func (m *CategoryMutation) SetOp(op Op) {
  4000. m.op = op
  4001. }
  4002. // Type returns the node type of this mutation (Category).
  4003. func (m *CategoryMutation) Type() string {
  4004. return m.typ
  4005. }
  4006. // Fields returns all fields that were changed during this mutation. Note that in
  4007. // order to get all numeric fields that were incremented/decremented, call
  4008. // AddedFields().
  4009. func (m *CategoryMutation) Fields() []string {
  4010. fields := make([]string, 0, 5)
  4011. if m.created_at != nil {
  4012. fields = append(fields, category.FieldCreatedAt)
  4013. }
  4014. if m.updated_at != nil {
  4015. fields = append(fields, category.FieldUpdatedAt)
  4016. }
  4017. if m.deleted_at != nil {
  4018. fields = append(fields, category.FieldDeletedAt)
  4019. }
  4020. if m.name != nil {
  4021. fields = append(fields, category.FieldName)
  4022. }
  4023. if m.organization_id != nil {
  4024. fields = append(fields, category.FieldOrganizationID)
  4025. }
  4026. return fields
  4027. }
  4028. // Field returns the value of a field with the given name. The second boolean
  4029. // return value indicates that this field was not set, or was not defined in the
  4030. // schema.
  4031. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  4032. switch name {
  4033. case category.FieldCreatedAt:
  4034. return m.CreatedAt()
  4035. case category.FieldUpdatedAt:
  4036. return m.UpdatedAt()
  4037. case category.FieldDeletedAt:
  4038. return m.DeletedAt()
  4039. case category.FieldName:
  4040. return m.Name()
  4041. case category.FieldOrganizationID:
  4042. return m.OrganizationID()
  4043. }
  4044. return nil, false
  4045. }
  4046. // OldField returns the old value of the field from the database. An error is
  4047. // returned if the mutation operation is not UpdateOne, or the query to the
  4048. // database failed.
  4049. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4050. switch name {
  4051. case category.FieldCreatedAt:
  4052. return m.OldCreatedAt(ctx)
  4053. case category.FieldUpdatedAt:
  4054. return m.OldUpdatedAt(ctx)
  4055. case category.FieldDeletedAt:
  4056. return m.OldDeletedAt(ctx)
  4057. case category.FieldName:
  4058. return m.OldName(ctx)
  4059. case category.FieldOrganizationID:
  4060. return m.OldOrganizationID(ctx)
  4061. }
  4062. return nil, fmt.Errorf("unknown Category field %s", name)
  4063. }
  4064. // SetField sets the value of a field with the given name. It returns an error if
  4065. // the field is not defined in the schema, or if the type mismatched the field
  4066. // type.
  4067. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  4068. switch name {
  4069. case category.FieldCreatedAt:
  4070. v, ok := value.(time.Time)
  4071. if !ok {
  4072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4073. }
  4074. m.SetCreatedAt(v)
  4075. return nil
  4076. case category.FieldUpdatedAt:
  4077. v, ok := value.(time.Time)
  4078. if !ok {
  4079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4080. }
  4081. m.SetUpdatedAt(v)
  4082. return nil
  4083. case category.FieldDeletedAt:
  4084. v, ok := value.(time.Time)
  4085. if !ok {
  4086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4087. }
  4088. m.SetDeletedAt(v)
  4089. return nil
  4090. case category.FieldName:
  4091. v, ok := value.(string)
  4092. if !ok {
  4093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4094. }
  4095. m.SetName(v)
  4096. return nil
  4097. case category.FieldOrganizationID:
  4098. v, ok := value.(uint64)
  4099. if !ok {
  4100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4101. }
  4102. m.SetOrganizationID(v)
  4103. return nil
  4104. }
  4105. return fmt.Errorf("unknown Category field %s", name)
  4106. }
  4107. // AddedFields returns all numeric fields that were incremented/decremented during
  4108. // this mutation.
  4109. func (m *CategoryMutation) AddedFields() []string {
  4110. var fields []string
  4111. if m.addorganization_id != nil {
  4112. fields = append(fields, category.FieldOrganizationID)
  4113. }
  4114. return fields
  4115. }
  4116. // AddedField returns the numeric value that was incremented/decremented on a field
  4117. // with the given name. The second boolean return value indicates that this field
  4118. // was not set, or was not defined in the schema.
  4119. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  4120. switch name {
  4121. case category.FieldOrganizationID:
  4122. return m.AddedOrganizationID()
  4123. }
  4124. return nil, false
  4125. }
  4126. // AddField adds the value to the field with the given name. It returns an error if
  4127. // the field is not defined in the schema, or if the type mismatched the field
  4128. // type.
  4129. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  4130. switch name {
  4131. case category.FieldOrganizationID:
  4132. v, ok := value.(int64)
  4133. if !ok {
  4134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4135. }
  4136. m.AddOrganizationID(v)
  4137. return nil
  4138. }
  4139. return fmt.Errorf("unknown Category numeric field %s", name)
  4140. }
  4141. // ClearedFields returns all nullable fields that were cleared during this
  4142. // mutation.
  4143. func (m *CategoryMutation) ClearedFields() []string {
  4144. var fields []string
  4145. if m.FieldCleared(category.FieldDeletedAt) {
  4146. fields = append(fields, category.FieldDeletedAt)
  4147. }
  4148. return fields
  4149. }
  4150. // FieldCleared returns a boolean indicating if a field with the given name was
  4151. // cleared in this mutation.
  4152. func (m *CategoryMutation) FieldCleared(name string) bool {
  4153. _, ok := m.clearedFields[name]
  4154. return ok
  4155. }
  4156. // ClearField clears the value of the field with the given name. It returns an
  4157. // error if the field is not defined in the schema.
  4158. func (m *CategoryMutation) ClearField(name string) error {
  4159. switch name {
  4160. case category.FieldDeletedAt:
  4161. m.ClearDeletedAt()
  4162. return nil
  4163. }
  4164. return fmt.Errorf("unknown Category nullable field %s", name)
  4165. }
  4166. // ResetField resets all changes in the mutation for the field with the given name.
  4167. // It returns an error if the field is not defined in the schema.
  4168. func (m *CategoryMutation) ResetField(name string) error {
  4169. switch name {
  4170. case category.FieldCreatedAt:
  4171. m.ResetCreatedAt()
  4172. return nil
  4173. case category.FieldUpdatedAt:
  4174. m.ResetUpdatedAt()
  4175. return nil
  4176. case category.FieldDeletedAt:
  4177. m.ResetDeletedAt()
  4178. return nil
  4179. case category.FieldName:
  4180. m.ResetName()
  4181. return nil
  4182. case category.FieldOrganizationID:
  4183. m.ResetOrganizationID()
  4184. return nil
  4185. }
  4186. return fmt.Errorf("unknown Category field %s", name)
  4187. }
  4188. // AddedEdges returns all edge names that were set/added in this mutation.
  4189. func (m *CategoryMutation) AddedEdges() []string {
  4190. edges := make([]string, 0, 0)
  4191. return edges
  4192. }
  4193. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4194. // name in this mutation.
  4195. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  4196. return nil
  4197. }
  4198. // RemovedEdges returns all edge names that were removed in this mutation.
  4199. func (m *CategoryMutation) RemovedEdges() []string {
  4200. edges := make([]string, 0, 0)
  4201. return edges
  4202. }
  4203. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4204. // the given name in this mutation.
  4205. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  4206. return nil
  4207. }
  4208. // ClearedEdges returns all edge names that were cleared in this mutation.
  4209. func (m *CategoryMutation) ClearedEdges() []string {
  4210. edges := make([]string, 0, 0)
  4211. return edges
  4212. }
  4213. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4214. // was cleared in this mutation.
  4215. func (m *CategoryMutation) EdgeCleared(name string) bool {
  4216. return false
  4217. }
  4218. // ClearEdge clears the value of the edge with the given name. It returns an error
  4219. // if that edge is not defined in the schema.
  4220. func (m *CategoryMutation) ClearEdge(name string) error {
  4221. return fmt.Errorf("unknown Category unique edge %s", name)
  4222. }
  4223. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4224. // It returns an error if the edge is not defined in the schema.
  4225. func (m *CategoryMutation) ResetEdge(name string) error {
  4226. return fmt.Errorf("unknown Category edge %s", name)
  4227. }
  4228. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  4229. type ChatRecordsMutation struct {
  4230. config
  4231. op Op
  4232. typ string
  4233. id *uint64
  4234. created_at *time.Time
  4235. updated_at *time.Time
  4236. deleted_at *time.Time
  4237. content *string
  4238. content_type *uint8
  4239. addcontent_type *int8
  4240. session_id *uint64
  4241. addsession_id *int64
  4242. user_id *uint64
  4243. adduser_id *int64
  4244. bot_id *uint64
  4245. addbot_id *int64
  4246. bot_type *uint8
  4247. addbot_type *int8
  4248. clearedFields map[string]struct{}
  4249. done bool
  4250. oldValue func(context.Context) (*ChatRecords, error)
  4251. predicates []predicate.ChatRecords
  4252. }
  4253. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  4254. // chatrecordsOption allows management of the mutation configuration using functional options.
  4255. type chatrecordsOption func(*ChatRecordsMutation)
  4256. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  4257. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  4258. m := &ChatRecordsMutation{
  4259. config: c,
  4260. op: op,
  4261. typ: TypeChatRecords,
  4262. clearedFields: make(map[string]struct{}),
  4263. }
  4264. for _, opt := range opts {
  4265. opt(m)
  4266. }
  4267. return m
  4268. }
  4269. // withChatRecordsID sets the ID field of the mutation.
  4270. func withChatRecordsID(id uint64) chatrecordsOption {
  4271. return func(m *ChatRecordsMutation) {
  4272. var (
  4273. err error
  4274. once sync.Once
  4275. value *ChatRecords
  4276. )
  4277. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  4278. once.Do(func() {
  4279. if m.done {
  4280. err = errors.New("querying old values post mutation is not allowed")
  4281. } else {
  4282. value, err = m.Client().ChatRecords.Get(ctx, id)
  4283. }
  4284. })
  4285. return value, err
  4286. }
  4287. m.id = &id
  4288. }
  4289. }
  4290. // withChatRecords sets the old ChatRecords of the mutation.
  4291. func withChatRecords(node *ChatRecords) chatrecordsOption {
  4292. return func(m *ChatRecordsMutation) {
  4293. m.oldValue = func(context.Context) (*ChatRecords, error) {
  4294. return node, nil
  4295. }
  4296. m.id = &node.ID
  4297. }
  4298. }
  4299. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4300. // executed in a transaction (ent.Tx), a transactional client is returned.
  4301. func (m ChatRecordsMutation) Client() *Client {
  4302. client := &Client{config: m.config}
  4303. client.init()
  4304. return client
  4305. }
  4306. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4307. // it returns an error otherwise.
  4308. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  4309. if _, ok := m.driver.(*txDriver); !ok {
  4310. return nil, errors.New("ent: mutation is not running in a transaction")
  4311. }
  4312. tx := &Tx{config: m.config}
  4313. tx.init()
  4314. return tx, nil
  4315. }
  4316. // SetID sets the value of the id field. Note that this
  4317. // operation is only accepted on creation of ChatRecords entities.
  4318. func (m *ChatRecordsMutation) SetID(id uint64) {
  4319. m.id = &id
  4320. }
  4321. // ID returns the ID value in the mutation. Note that the ID is only available
  4322. // if it was provided to the builder or after it was returned from the database.
  4323. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  4324. if m.id == nil {
  4325. return
  4326. }
  4327. return *m.id, true
  4328. }
  4329. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4330. // That means, if the mutation is applied within a transaction with an isolation level such
  4331. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4332. // or updated by the mutation.
  4333. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  4334. switch {
  4335. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4336. id, exists := m.ID()
  4337. if exists {
  4338. return []uint64{id}, nil
  4339. }
  4340. fallthrough
  4341. case m.op.Is(OpUpdate | OpDelete):
  4342. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  4343. default:
  4344. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4345. }
  4346. }
  4347. // SetCreatedAt sets the "created_at" field.
  4348. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  4349. m.created_at = &t
  4350. }
  4351. // CreatedAt returns the value of the "created_at" field in the mutation.
  4352. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  4353. v := m.created_at
  4354. if v == nil {
  4355. return
  4356. }
  4357. return *v, true
  4358. }
  4359. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  4360. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4362. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4363. if !m.op.Is(OpUpdateOne) {
  4364. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4365. }
  4366. if m.id == nil || m.oldValue == nil {
  4367. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4368. }
  4369. oldValue, err := m.oldValue(ctx)
  4370. if err != nil {
  4371. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4372. }
  4373. return oldValue.CreatedAt, nil
  4374. }
  4375. // ResetCreatedAt resets all changes to the "created_at" field.
  4376. func (m *ChatRecordsMutation) ResetCreatedAt() {
  4377. m.created_at = nil
  4378. }
  4379. // SetUpdatedAt sets the "updated_at" field.
  4380. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  4381. m.updated_at = &t
  4382. }
  4383. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4384. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  4385. v := m.updated_at
  4386. if v == nil {
  4387. return
  4388. }
  4389. return *v, true
  4390. }
  4391. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  4392. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4394. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4395. if !m.op.Is(OpUpdateOne) {
  4396. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4397. }
  4398. if m.id == nil || m.oldValue == nil {
  4399. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4400. }
  4401. oldValue, err := m.oldValue(ctx)
  4402. if err != nil {
  4403. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4404. }
  4405. return oldValue.UpdatedAt, nil
  4406. }
  4407. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4408. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  4409. m.updated_at = nil
  4410. }
  4411. // SetDeletedAt sets the "deleted_at" field.
  4412. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  4413. m.deleted_at = &t
  4414. }
  4415. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4416. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  4417. v := m.deleted_at
  4418. if v == nil {
  4419. return
  4420. }
  4421. return *v, true
  4422. }
  4423. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  4424. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4426. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4427. if !m.op.Is(OpUpdateOne) {
  4428. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4429. }
  4430. if m.id == nil || m.oldValue == nil {
  4431. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4432. }
  4433. oldValue, err := m.oldValue(ctx)
  4434. if err != nil {
  4435. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4436. }
  4437. return oldValue.DeletedAt, nil
  4438. }
  4439. // ClearDeletedAt clears the value of the "deleted_at" field.
  4440. func (m *ChatRecordsMutation) ClearDeletedAt() {
  4441. m.deleted_at = nil
  4442. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  4443. }
  4444. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4445. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  4446. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  4447. return ok
  4448. }
  4449. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4450. func (m *ChatRecordsMutation) ResetDeletedAt() {
  4451. m.deleted_at = nil
  4452. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  4453. }
  4454. // SetContent sets the "content" field.
  4455. func (m *ChatRecordsMutation) SetContent(s string) {
  4456. m.content = &s
  4457. }
  4458. // Content returns the value of the "content" field in the mutation.
  4459. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  4460. v := m.content
  4461. if v == nil {
  4462. return
  4463. }
  4464. return *v, true
  4465. }
  4466. // OldContent returns the old "content" field's value of the ChatRecords entity.
  4467. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4469. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  4470. if !m.op.Is(OpUpdateOne) {
  4471. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  4472. }
  4473. if m.id == nil || m.oldValue == nil {
  4474. return v, errors.New("OldContent requires an ID field in the mutation")
  4475. }
  4476. oldValue, err := m.oldValue(ctx)
  4477. if err != nil {
  4478. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  4479. }
  4480. return oldValue.Content, nil
  4481. }
  4482. // ResetContent resets all changes to the "content" field.
  4483. func (m *ChatRecordsMutation) ResetContent() {
  4484. m.content = nil
  4485. }
  4486. // SetContentType sets the "content_type" field.
  4487. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  4488. m.content_type = &u
  4489. m.addcontent_type = nil
  4490. }
  4491. // ContentType returns the value of the "content_type" field in the mutation.
  4492. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  4493. v := m.content_type
  4494. if v == nil {
  4495. return
  4496. }
  4497. return *v, true
  4498. }
  4499. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  4500. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4502. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  4503. if !m.op.Is(OpUpdateOne) {
  4504. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  4505. }
  4506. if m.id == nil || m.oldValue == nil {
  4507. return v, errors.New("OldContentType requires an ID field in the mutation")
  4508. }
  4509. oldValue, err := m.oldValue(ctx)
  4510. if err != nil {
  4511. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  4512. }
  4513. return oldValue.ContentType, nil
  4514. }
  4515. // AddContentType adds u to the "content_type" field.
  4516. func (m *ChatRecordsMutation) AddContentType(u int8) {
  4517. if m.addcontent_type != nil {
  4518. *m.addcontent_type += u
  4519. } else {
  4520. m.addcontent_type = &u
  4521. }
  4522. }
  4523. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  4524. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  4525. v := m.addcontent_type
  4526. if v == nil {
  4527. return
  4528. }
  4529. return *v, true
  4530. }
  4531. // ResetContentType resets all changes to the "content_type" field.
  4532. func (m *ChatRecordsMutation) ResetContentType() {
  4533. m.content_type = nil
  4534. m.addcontent_type = nil
  4535. }
  4536. // SetSessionID sets the "session_id" field.
  4537. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  4538. m.session_id = &u
  4539. m.addsession_id = nil
  4540. }
  4541. // SessionID returns the value of the "session_id" field in the mutation.
  4542. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  4543. v := m.session_id
  4544. if v == nil {
  4545. return
  4546. }
  4547. return *v, true
  4548. }
  4549. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  4550. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4552. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  4553. if !m.op.Is(OpUpdateOne) {
  4554. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  4555. }
  4556. if m.id == nil || m.oldValue == nil {
  4557. return v, errors.New("OldSessionID requires an ID field in the mutation")
  4558. }
  4559. oldValue, err := m.oldValue(ctx)
  4560. if err != nil {
  4561. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  4562. }
  4563. return oldValue.SessionID, nil
  4564. }
  4565. // AddSessionID adds u to the "session_id" field.
  4566. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  4567. if m.addsession_id != nil {
  4568. *m.addsession_id += u
  4569. } else {
  4570. m.addsession_id = &u
  4571. }
  4572. }
  4573. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  4574. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  4575. v := m.addsession_id
  4576. if v == nil {
  4577. return
  4578. }
  4579. return *v, true
  4580. }
  4581. // ResetSessionID resets all changes to the "session_id" field.
  4582. func (m *ChatRecordsMutation) ResetSessionID() {
  4583. m.session_id = nil
  4584. m.addsession_id = nil
  4585. }
  4586. // SetUserID sets the "user_id" field.
  4587. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  4588. m.user_id = &u
  4589. m.adduser_id = nil
  4590. }
  4591. // UserID returns the value of the "user_id" field in the mutation.
  4592. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  4593. v := m.user_id
  4594. if v == nil {
  4595. return
  4596. }
  4597. return *v, true
  4598. }
  4599. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  4600. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4602. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  4603. if !m.op.Is(OpUpdateOne) {
  4604. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  4605. }
  4606. if m.id == nil || m.oldValue == nil {
  4607. return v, errors.New("OldUserID requires an ID field in the mutation")
  4608. }
  4609. oldValue, err := m.oldValue(ctx)
  4610. if err != nil {
  4611. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  4612. }
  4613. return oldValue.UserID, nil
  4614. }
  4615. // AddUserID adds u to the "user_id" field.
  4616. func (m *ChatRecordsMutation) AddUserID(u int64) {
  4617. if m.adduser_id != nil {
  4618. *m.adduser_id += u
  4619. } else {
  4620. m.adduser_id = &u
  4621. }
  4622. }
  4623. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  4624. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  4625. v := m.adduser_id
  4626. if v == nil {
  4627. return
  4628. }
  4629. return *v, true
  4630. }
  4631. // ResetUserID resets all changes to the "user_id" field.
  4632. func (m *ChatRecordsMutation) ResetUserID() {
  4633. m.user_id = nil
  4634. m.adduser_id = nil
  4635. }
  4636. // SetBotID sets the "bot_id" field.
  4637. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  4638. m.bot_id = &u
  4639. m.addbot_id = nil
  4640. }
  4641. // BotID returns the value of the "bot_id" field in the mutation.
  4642. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  4643. v := m.bot_id
  4644. if v == nil {
  4645. return
  4646. }
  4647. return *v, true
  4648. }
  4649. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  4650. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4652. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  4653. if !m.op.Is(OpUpdateOne) {
  4654. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  4655. }
  4656. if m.id == nil || m.oldValue == nil {
  4657. return v, errors.New("OldBotID requires an ID field in the mutation")
  4658. }
  4659. oldValue, err := m.oldValue(ctx)
  4660. if err != nil {
  4661. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  4662. }
  4663. return oldValue.BotID, nil
  4664. }
  4665. // AddBotID adds u to the "bot_id" field.
  4666. func (m *ChatRecordsMutation) AddBotID(u int64) {
  4667. if m.addbot_id != nil {
  4668. *m.addbot_id += u
  4669. } else {
  4670. m.addbot_id = &u
  4671. }
  4672. }
  4673. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  4674. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  4675. v := m.addbot_id
  4676. if v == nil {
  4677. return
  4678. }
  4679. return *v, true
  4680. }
  4681. // ResetBotID resets all changes to the "bot_id" field.
  4682. func (m *ChatRecordsMutation) ResetBotID() {
  4683. m.bot_id = nil
  4684. m.addbot_id = nil
  4685. }
  4686. // SetBotType sets the "bot_type" field.
  4687. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  4688. m.bot_type = &u
  4689. m.addbot_type = nil
  4690. }
  4691. // BotType returns the value of the "bot_type" field in the mutation.
  4692. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  4693. v := m.bot_type
  4694. if v == nil {
  4695. return
  4696. }
  4697. return *v, true
  4698. }
  4699. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  4700. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4702. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  4703. if !m.op.Is(OpUpdateOne) {
  4704. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  4705. }
  4706. if m.id == nil || m.oldValue == nil {
  4707. return v, errors.New("OldBotType requires an ID field in the mutation")
  4708. }
  4709. oldValue, err := m.oldValue(ctx)
  4710. if err != nil {
  4711. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  4712. }
  4713. return oldValue.BotType, nil
  4714. }
  4715. // AddBotType adds u to the "bot_type" field.
  4716. func (m *ChatRecordsMutation) AddBotType(u int8) {
  4717. if m.addbot_type != nil {
  4718. *m.addbot_type += u
  4719. } else {
  4720. m.addbot_type = &u
  4721. }
  4722. }
  4723. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  4724. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  4725. v := m.addbot_type
  4726. if v == nil {
  4727. return
  4728. }
  4729. return *v, true
  4730. }
  4731. // ResetBotType resets all changes to the "bot_type" field.
  4732. func (m *ChatRecordsMutation) ResetBotType() {
  4733. m.bot_type = nil
  4734. m.addbot_type = nil
  4735. }
  4736. // Where appends a list predicates to the ChatRecordsMutation builder.
  4737. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  4738. m.predicates = append(m.predicates, ps...)
  4739. }
  4740. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  4741. // users can use type-assertion to append predicates that do not depend on any generated package.
  4742. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  4743. p := make([]predicate.ChatRecords, len(ps))
  4744. for i := range ps {
  4745. p[i] = ps[i]
  4746. }
  4747. m.Where(p...)
  4748. }
  4749. // Op returns the operation name.
  4750. func (m *ChatRecordsMutation) Op() Op {
  4751. return m.op
  4752. }
  4753. // SetOp allows setting the mutation operation.
  4754. func (m *ChatRecordsMutation) SetOp(op Op) {
  4755. m.op = op
  4756. }
  4757. // Type returns the node type of this mutation (ChatRecords).
  4758. func (m *ChatRecordsMutation) Type() string {
  4759. return m.typ
  4760. }
  4761. // Fields returns all fields that were changed during this mutation. Note that in
  4762. // order to get all numeric fields that were incremented/decremented, call
  4763. // AddedFields().
  4764. func (m *ChatRecordsMutation) Fields() []string {
  4765. fields := make([]string, 0, 9)
  4766. if m.created_at != nil {
  4767. fields = append(fields, chatrecords.FieldCreatedAt)
  4768. }
  4769. if m.updated_at != nil {
  4770. fields = append(fields, chatrecords.FieldUpdatedAt)
  4771. }
  4772. if m.deleted_at != nil {
  4773. fields = append(fields, chatrecords.FieldDeletedAt)
  4774. }
  4775. if m.content != nil {
  4776. fields = append(fields, chatrecords.FieldContent)
  4777. }
  4778. if m.content_type != nil {
  4779. fields = append(fields, chatrecords.FieldContentType)
  4780. }
  4781. if m.session_id != nil {
  4782. fields = append(fields, chatrecords.FieldSessionID)
  4783. }
  4784. if m.user_id != nil {
  4785. fields = append(fields, chatrecords.FieldUserID)
  4786. }
  4787. if m.bot_id != nil {
  4788. fields = append(fields, chatrecords.FieldBotID)
  4789. }
  4790. if m.bot_type != nil {
  4791. fields = append(fields, chatrecords.FieldBotType)
  4792. }
  4793. return fields
  4794. }
  4795. // Field returns the value of a field with the given name. The second boolean
  4796. // return value indicates that this field was not set, or was not defined in the
  4797. // schema.
  4798. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  4799. switch name {
  4800. case chatrecords.FieldCreatedAt:
  4801. return m.CreatedAt()
  4802. case chatrecords.FieldUpdatedAt:
  4803. return m.UpdatedAt()
  4804. case chatrecords.FieldDeletedAt:
  4805. return m.DeletedAt()
  4806. case chatrecords.FieldContent:
  4807. return m.Content()
  4808. case chatrecords.FieldContentType:
  4809. return m.ContentType()
  4810. case chatrecords.FieldSessionID:
  4811. return m.SessionID()
  4812. case chatrecords.FieldUserID:
  4813. return m.UserID()
  4814. case chatrecords.FieldBotID:
  4815. return m.BotID()
  4816. case chatrecords.FieldBotType:
  4817. return m.BotType()
  4818. }
  4819. return nil, false
  4820. }
  4821. // OldField returns the old value of the field from the database. An error is
  4822. // returned if the mutation operation is not UpdateOne, or the query to the
  4823. // database failed.
  4824. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4825. switch name {
  4826. case chatrecords.FieldCreatedAt:
  4827. return m.OldCreatedAt(ctx)
  4828. case chatrecords.FieldUpdatedAt:
  4829. return m.OldUpdatedAt(ctx)
  4830. case chatrecords.FieldDeletedAt:
  4831. return m.OldDeletedAt(ctx)
  4832. case chatrecords.FieldContent:
  4833. return m.OldContent(ctx)
  4834. case chatrecords.FieldContentType:
  4835. return m.OldContentType(ctx)
  4836. case chatrecords.FieldSessionID:
  4837. return m.OldSessionID(ctx)
  4838. case chatrecords.FieldUserID:
  4839. return m.OldUserID(ctx)
  4840. case chatrecords.FieldBotID:
  4841. return m.OldBotID(ctx)
  4842. case chatrecords.FieldBotType:
  4843. return m.OldBotType(ctx)
  4844. }
  4845. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  4846. }
  4847. // SetField sets the value of a field with the given name. It returns an error if
  4848. // the field is not defined in the schema, or if the type mismatched the field
  4849. // type.
  4850. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  4851. switch name {
  4852. case chatrecords.FieldCreatedAt:
  4853. v, ok := value.(time.Time)
  4854. if !ok {
  4855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4856. }
  4857. m.SetCreatedAt(v)
  4858. return nil
  4859. case chatrecords.FieldUpdatedAt:
  4860. v, ok := value.(time.Time)
  4861. if !ok {
  4862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4863. }
  4864. m.SetUpdatedAt(v)
  4865. return nil
  4866. case chatrecords.FieldDeletedAt:
  4867. v, ok := value.(time.Time)
  4868. if !ok {
  4869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4870. }
  4871. m.SetDeletedAt(v)
  4872. return nil
  4873. case chatrecords.FieldContent:
  4874. v, ok := value.(string)
  4875. if !ok {
  4876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4877. }
  4878. m.SetContent(v)
  4879. return nil
  4880. case chatrecords.FieldContentType:
  4881. v, ok := value.(uint8)
  4882. if !ok {
  4883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4884. }
  4885. m.SetContentType(v)
  4886. return nil
  4887. case chatrecords.FieldSessionID:
  4888. v, ok := value.(uint64)
  4889. if !ok {
  4890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4891. }
  4892. m.SetSessionID(v)
  4893. return nil
  4894. case chatrecords.FieldUserID:
  4895. v, ok := value.(uint64)
  4896. if !ok {
  4897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4898. }
  4899. m.SetUserID(v)
  4900. return nil
  4901. case chatrecords.FieldBotID:
  4902. v, ok := value.(uint64)
  4903. if !ok {
  4904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4905. }
  4906. m.SetBotID(v)
  4907. return nil
  4908. case chatrecords.FieldBotType:
  4909. v, ok := value.(uint8)
  4910. if !ok {
  4911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4912. }
  4913. m.SetBotType(v)
  4914. return nil
  4915. }
  4916. return fmt.Errorf("unknown ChatRecords field %s", name)
  4917. }
  4918. // AddedFields returns all numeric fields that were incremented/decremented during
  4919. // this mutation.
  4920. func (m *ChatRecordsMutation) AddedFields() []string {
  4921. var fields []string
  4922. if m.addcontent_type != nil {
  4923. fields = append(fields, chatrecords.FieldContentType)
  4924. }
  4925. if m.addsession_id != nil {
  4926. fields = append(fields, chatrecords.FieldSessionID)
  4927. }
  4928. if m.adduser_id != nil {
  4929. fields = append(fields, chatrecords.FieldUserID)
  4930. }
  4931. if m.addbot_id != nil {
  4932. fields = append(fields, chatrecords.FieldBotID)
  4933. }
  4934. if m.addbot_type != nil {
  4935. fields = append(fields, chatrecords.FieldBotType)
  4936. }
  4937. return fields
  4938. }
  4939. // AddedField returns the numeric value that was incremented/decremented on a field
  4940. // with the given name. The second boolean return value indicates that this field
  4941. // was not set, or was not defined in the schema.
  4942. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  4943. switch name {
  4944. case chatrecords.FieldContentType:
  4945. return m.AddedContentType()
  4946. case chatrecords.FieldSessionID:
  4947. return m.AddedSessionID()
  4948. case chatrecords.FieldUserID:
  4949. return m.AddedUserID()
  4950. case chatrecords.FieldBotID:
  4951. return m.AddedBotID()
  4952. case chatrecords.FieldBotType:
  4953. return m.AddedBotType()
  4954. }
  4955. return nil, false
  4956. }
  4957. // AddField adds the value to the field with the given name. It returns an error if
  4958. // the field is not defined in the schema, or if the type mismatched the field
  4959. // type.
  4960. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  4961. switch name {
  4962. case chatrecords.FieldContentType:
  4963. v, ok := value.(int8)
  4964. if !ok {
  4965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4966. }
  4967. m.AddContentType(v)
  4968. return nil
  4969. case chatrecords.FieldSessionID:
  4970. v, ok := value.(int64)
  4971. if !ok {
  4972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4973. }
  4974. m.AddSessionID(v)
  4975. return nil
  4976. case chatrecords.FieldUserID:
  4977. v, ok := value.(int64)
  4978. if !ok {
  4979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4980. }
  4981. m.AddUserID(v)
  4982. return nil
  4983. case chatrecords.FieldBotID:
  4984. v, ok := value.(int64)
  4985. if !ok {
  4986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4987. }
  4988. m.AddBotID(v)
  4989. return nil
  4990. case chatrecords.FieldBotType:
  4991. v, ok := value.(int8)
  4992. if !ok {
  4993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4994. }
  4995. m.AddBotType(v)
  4996. return nil
  4997. }
  4998. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  4999. }
  5000. // ClearedFields returns all nullable fields that were cleared during this
  5001. // mutation.
  5002. func (m *ChatRecordsMutation) ClearedFields() []string {
  5003. var fields []string
  5004. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  5005. fields = append(fields, chatrecords.FieldDeletedAt)
  5006. }
  5007. return fields
  5008. }
  5009. // FieldCleared returns a boolean indicating if a field with the given name was
  5010. // cleared in this mutation.
  5011. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  5012. _, ok := m.clearedFields[name]
  5013. return ok
  5014. }
  5015. // ClearField clears the value of the field with the given name. It returns an
  5016. // error if the field is not defined in the schema.
  5017. func (m *ChatRecordsMutation) ClearField(name string) error {
  5018. switch name {
  5019. case chatrecords.FieldDeletedAt:
  5020. m.ClearDeletedAt()
  5021. return nil
  5022. }
  5023. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  5024. }
  5025. // ResetField resets all changes in the mutation for the field with the given name.
  5026. // It returns an error if the field is not defined in the schema.
  5027. func (m *ChatRecordsMutation) ResetField(name string) error {
  5028. switch name {
  5029. case chatrecords.FieldCreatedAt:
  5030. m.ResetCreatedAt()
  5031. return nil
  5032. case chatrecords.FieldUpdatedAt:
  5033. m.ResetUpdatedAt()
  5034. return nil
  5035. case chatrecords.FieldDeletedAt:
  5036. m.ResetDeletedAt()
  5037. return nil
  5038. case chatrecords.FieldContent:
  5039. m.ResetContent()
  5040. return nil
  5041. case chatrecords.FieldContentType:
  5042. m.ResetContentType()
  5043. return nil
  5044. case chatrecords.FieldSessionID:
  5045. m.ResetSessionID()
  5046. return nil
  5047. case chatrecords.FieldUserID:
  5048. m.ResetUserID()
  5049. return nil
  5050. case chatrecords.FieldBotID:
  5051. m.ResetBotID()
  5052. return nil
  5053. case chatrecords.FieldBotType:
  5054. m.ResetBotType()
  5055. return nil
  5056. }
  5057. return fmt.Errorf("unknown ChatRecords field %s", name)
  5058. }
  5059. // AddedEdges returns all edge names that were set/added in this mutation.
  5060. func (m *ChatRecordsMutation) AddedEdges() []string {
  5061. edges := make([]string, 0, 0)
  5062. return edges
  5063. }
  5064. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5065. // name in this mutation.
  5066. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  5067. return nil
  5068. }
  5069. // RemovedEdges returns all edge names that were removed in this mutation.
  5070. func (m *ChatRecordsMutation) RemovedEdges() []string {
  5071. edges := make([]string, 0, 0)
  5072. return edges
  5073. }
  5074. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5075. // the given name in this mutation.
  5076. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  5077. return nil
  5078. }
  5079. // ClearedEdges returns all edge names that were cleared in this mutation.
  5080. func (m *ChatRecordsMutation) ClearedEdges() []string {
  5081. edges := make([]string, 0, 0)
  5082. return edges
  5083. }
  5084. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5085. // was cleared in this mutation.
  5086. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  5087. return false
  5088. }
  5089. // ClearEdge clears the value of the edge with the given name. It returns an error
  5090. // if that edge is not defined in the schema.
  5091. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  5092. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  5093. }
  5094. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5095. // It returns an error if the edge is not defined in the schema.
  5096. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  5097. return fmt.Errorf("unknown ChatRecords edge %s", name)
  5098. }
  5099. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  5100. type ChatSessionMutation struct {
  5101. config
  5102. op Op
  5103. typ string
  5104. id *uint64
  5105. created_at *time.Time
  5106. updated_at *time.Time
  5107. deleted_at *time.Time
  5108. name *string
  5109. user_id *uint64
  5110. adduser_id *int64
  5111. bot_id *uint64
  5112. addbot_id *int64
  5113. bot_type *uint8
  5114. addbot_type *int8
  5115. clearedFields map[string]struct{}
  5116. done bool
  5117. oldValue func(context.Context) (*ChatSession, error)
  5118. predicates []predicate.ChatSession
  5119. }
  5120. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  5121. // chatsessionOption allows management of the mutation configuration using functional options.
  5122. type chatsessionOption func(*ChatSessionMutation)
  5123. // newChatSessionMutation creates new mutation for the ChatSession entity.
  5124. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  5125. m := &ChatSessionMutation{
  5126. config: c,
  5127. op: op,
  5128. typ: TypeChatSession,
  5129. clearedFields: make(map[string]struct{}),
  5130. }
  5131. for _, opt := range opts {
  5132. opt(m)
  5133. }
  5134. return m
  5135. }
  5136. // withChatSessionID sets the ID field of the mutation.
  5137. func withChatSessionID(id uint64) chatsessionOption {
  5138. return func(m *ChatSessionMutation) {
  5139. var (
  5140. err error
  5141. once sync.Once
  5142. value *ChatSession
  5143. )
  5144. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  5145. once.Do(func() {
  5146. if m.done {
  5147. err = errors.New("querying old values post mutation is not allowed")
  5148. } else {
  5149. value, err = m.Client().ChatSession.Get(ctx, id)
  5150. }
  5151. })
  5152. return value, err
  5153. }
  5154. m.id = &id
  5155. }
  5156. }
  5157. // withChatSession sets the old ChatSession of the mutation.
  5158. func withChatSession(node *ChatSession) chatsessionOption {
  5159. return func(m *ChatSessionMutation) {
  5160. m.oldValue = func(context.Context) (*ChatSession, error) {
  5161. return node, nil
  5162. }
  5163. m.id = &node.ID
  5164. }
  5165. }
  5166. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5167. // executed in a transaction (ent.Tx), a transactional client is returned.
  5168. func (m ChatSessionMutation) Client() *Client {
  5169. client := &Client{config: m.config}
  5170. client.init()
  5171. return client
  5172. }
  5173. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5174. // it returns an error otherwise.
  5175. func (m ChatSessionMutation) Tx() (*Tx, error) {
  5176. if _, ok := m.driver.(*txDriver); !ok {
  5177. return nil, errors.New("ent: mutation is not running in a transaction")
  5178. }
  5179. tx := &Tx{config: m.config}
  5180. tx.init()
  5181. return tx, nil
  5182. }
  5183. // SetID sets the value of the id field. Note that this
  5184. // operation is only accepted on creation of ChatSession entities.
  5185. func (m *ChatSessionMutation) SetID(id uint64) {
  5186. m.id = &id
  5187. }
  5188. // ID returns the ID value in the mutation. Note that the ID is only available
  5189. // if it was provided to the builder or after it was returned from the database.
  5190. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  5191. if m.id == nil {
  5192. return
  5193. }
  5194. return *m.id, true
  5195. }
  5196. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5197. // That means, if the mutation is applied within a transaction with an isolation level such
  5198. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5199. // or updated by the mutation.
  5200. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  5201. switch {
  5202. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5203. id, exists := m.ID()
  5204. if exists {
  5205. return []uint64{id}, nil
  5206. }
  5207. fallthrough
  5208. case m.op.Is(OpUpdate | OpDelete):
  5209. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  5210. default:
  5211. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5212. }
  5213. }
  5214. // SetCreatedAt sets the "created_at" field.
  5215. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  5216. m.created_at = &t
  5217. }
  5218. // CreatedAt returns the value of the "created_at" field in the mutation.
  5219. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  5220. v := m.created_at
  5221. if v == nil {
  5222. return
  5223. }
  5224. return *v, true
  5225. }
  5226. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  5227. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  5228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5229. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5230. if !m.op.Is(OpUpdateOne) {
  5231. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5232. }
  5233. if m.id == nil || m.oldValue == nil {
  5234. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5235. }
  5236. oldValue, err := m.oldValue(ctx)
  5237. if err != nil {
  5238. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5239. }
  5240. return oldValue.CreatedAt, nil
  5241. }
  5242. // ResetCreatedAt resets all changes to the "created_at" field.
  5243. func (m *ChatSessionMutation) ResetCreatedAt() {
  5244. m.created_at = nil
  5245. }
  5246. // SetUpdatedAt sets the "updated_at" field.
  5247. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  5248. m.updated_at = &t
  5249. }
  5250. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5251. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  5252. v := m.updated_at
  5253. if v == nil {
  5254. return
  5255. }
  5256. return *v, true
  5257. }
  5258. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  5259. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  5260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5261. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5262. if !m.op.Is(OpUpdateOne) {
  5263. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5264. }
  5265. if m.id == nil || m.oldValue == nil {
  5266. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5267. }
  5268. oldValue, err := m.oldValue(ctx)
  5269. if err != nil {
  5270. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5271. }
  5272. return oldValue.UpdatedAt, nil
  5273. }
  5274. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5275. func (m *ChatSessionMutation) ResetUpdatedAt() {
  5276. m.updated_at = nil
  5277. }
  5278. // SetDeletedAt sets the "deleted_at" field.
  5279. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  5280. m.deleted_at = &t
  5281. }
  5282. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5283. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  5284. v := m.deleted_at
  5285. if v == nil {
  5286. return
  5287. }
  5288. return *v, true
  5289. }
  5290. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  5291. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  5292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5293. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5294. if !m.op.Is(OpUpdateOne) {
  5295. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5296. }
  5297. if m.id == nil || m.oldValue == nil {
  5298. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5299. }
  5300. oldValue, err := m.oldValue(ctx)
  5301. if err != nil {
  5302. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5303. }
  5304. return oldValue.DeletedAt, nil
  5305. }
  5306. // ClearDeletedAt clears the value of the "deleted_at" field.
  5307. func (m *ChatSessionMutation) ClearDeletedAt() {
  5308. m.deleted_at = nil
  5309. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  5310. }
  5311. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5312. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  5313. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  5314. return ok
  5315. }
  5316. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5317. func (m *ChatSessionMutation) ResetDeletedAt() {
  5318. m.deleted_at = nil
  5319. delete(m.clearedFields, chatsession.FieldDeletedAt)
  5320. }
  5321. // SetName sets the "name" field.
  5322. func (m *ChatSessionMutation) SetName(s string) {
  5323. m.name = &s
  5324. }
  5325. // Name returns the value of the "name" field in the mutation.
  5326. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  5327. v := m.name
  5328. if v == nil {
  5329. return
  5330. }
  5331. return *v, true
  5332. }
  5333. // OldName returns the old "name" field's value of the ChatSession entity.
  5334. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  5335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5336. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  5337. if !m.op.Is(OpUpdateOne) {
  5338. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5339. }
  5340. if m.id == nil || m.oldValue == nil {
  5341. return v, errors.New("OldName requires an ID field in the mutation")
  5342. }
  5343. oldValue, err := m.oldValue(ctx)
  5344. if err != nil {
  5345. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5346. }
  5347. return oldValue.Name, nil
  5348. }
  5349. // ResetName resets all changes to the "name" field.
  5350. func (m *ChatSessionMutation) ResetName() {
  5351. m.name = nil
  5352. }
  5353. // SetUserID sets the "user_id" field.
  5354. func (m *ChatSessionMutation) SetUserID(u uint64) {
  5355. m.user_id = &u
  5356. m.adduser_id = nil
  5357. }
  5358. // UserID returns the value of the "user_id" field in the mutation.
  5359. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  5360. v := m.user_id
  5361. if v == nil {
  5362. return
  5363. }
  5364. return *v, true
  5365. }
  5366. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  5367. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  5368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5369. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  5370. if !m.op.Is(OpUpdateOne) {
  5371. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  5372. }
  5373. if m.id == nil || m.oldValue == nil {
  5374. return v, errors.New("OldUserID requires an ID field in the mutation")
  5375. }
  5376. oldValue, err := m.oldValue(ctx)
  5377. if err != nil {
  5378. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  5379. }
  5380. return oldValue.UserID, nil
  5381. }
  5382. // AddUserID adds u to the "user_id" field.
  5383. func (m *ChatSessionMutation) AddUserID(u int64) {
  5384. if m.adduser_id != nil {
  5385. *m.adduser_id += u
  5386. } else {
  5387. m.adduser_id = &u
  5388. }
  5389. }
  5390. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  5391. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  5392. v := m.adduser_id
  5393. if v == nil {
  5394. return
  5395. }
  5396. return *v, true
  5397. }
  5398. // ResetUserID resets all changes to the "user_id" field.
  5399. func (m *ChatSessionMutation) ResetUserID() {
  5400. m.user_id = nil
  5401. m.adduser_id = nil
  5402. }
  5403. // SetBotID sets the "bot_id" field.
  5404. func (m *ChatSessionMutation) SetBotID(u uint64) {
  5405. m.bot_id = &u
  5406. m.addbot_id = nil
  5407. }
  5408. // BotID returns the value of the "bot_id" field in the mutation.
  5409. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  5410. v := m.bot_id
  5411. if v == nil {
  5412. return
  5413. }
  5414. return *v, true
  5415. }
  5416. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  5417. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  5418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5419. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  5420. if !m.op.Is(OpUpdateOne) {
  5421. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  5422. }
  5423. if m.id == nil || m.oldValue == nil {
  5424. return v, errors.New("OldBotID requires an ID field in the mutation")
  5425. }
  5426. oldValue, err := m.oldValue(ctx)
  5427. if err != nil {
  5428. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  5429. }
  5430. return oldValue.BotID, nil
  5431. }
  5432. // AddBotID adds u to the "bot_id" field.
  5433. func (m *ChatSessionMutation) AddBotID(u int64) {
  5434. if m.addbot_id != nil {
  5435. *m.addbot_id += u
  5436. } else {
  5437. m.addbot_id = &u
  5438. }
  5439. }
  5440. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  5441. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  5442. v := m.addbot_id
  5443. if v == nil {
  5444. return
  5445. }
  5446. return *v, true
  5447. }
  5448. // ResetBotID resets all changes to the "bot_id" field.
  5449. func (m *ChatSessionMutation) ResetBotID() {
  5450. m.bot_id = nil
  5451. m.addbot_id = nil
  5452. }
  5453. // SetBotType sets the "bot_type" field.
  5454. func (m *ChatSessionMutation) SetBotType(u uint8) {
  5455. m.bot_type = &u
  5456. m.addbot_type = nil
  5457. }
  5458. // BotType returns the value of the "bot_type" field in the mutation.
  5459. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  5460. v := m.bot_type
  5461. if v == nil {
  5462. return
  5463. }
  5464. return *v, true
  5465. }
  5466. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  5467. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  5468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5469. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  5470. if !m.op.Is(OpUpdateOne) {
  5471. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  5472. }
  5473. if m.id == nil || m.oldValue == nil {
  5474. return v, errors.New("OldBotType requires an ID field in the mutation")
  5475. }
  5476. oldValue, err := m.oldValue(ctx)
  5477. if err != nil {
  5478. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  5479. }
  5480. return oldValue.BotType, nil
  5481. }
  5482. // AddBotType adds u to the "bot_type" field.
  5483. func (m *ChatSessionMutation) AddBotType(u int8) {
  5484. if m.addbot_type != nil {
  5485. *m.addbot_type += u
  5486. } else {
  5487. m.addbot_type = &u
  5488. }
  5489. }
  5490. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  5491. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  5492. v := m.addbot_type
  5493. if v == nil {
  5494. return
  5495. }
  5496. return *v, true
  5497. }
  5498. // ResetBotType resets all changes to the "bot_type" field.
  5499. func (m *ChatSessionMutation) ResetBotType() {
  5500. m.bot_type = nil
  5501. m.addbot_type = nil
  5502. }
  5503. // Where appends a list predicates to the ChatSessionMutation builder.
  5504. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  5505. m.predicates = append(m.predicates, ps...)
  5506. }
  5507. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  5508. // users can use type-assertion to append predicates that do not depend on any generated package.
  5509. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  5510. p := make([]predicate.ChatSession, len(ps))
  5511. for i := range ps {
  5512. p[i] = ps[i]
  5513. }
  5514. m.Where(p...)
  5515. }
  5516. // Op returns the operation name.
  5517. func (m *ChatSessionMutation) Op() Op {
  5518. return m.op
  5519. }
  5520. // SetOp allows setting the mutation operation.
  5521. func (m *ChatSessionMutation) SetOp(op Op) {
  5522. m.op = op
  5523. }
  5524. // Type returns the node type of this mutation (ChatSession).
  5525. func (m *ChatSessionMutation) Type() string {
  5526. return m.typ
  5527. }
  5528. // Fields returns all fields that were changed during this mutation. Note that in
  5529. // order to get all numeric fields that were incremented/decremented, call
  5530. // AddedFields().
  5531. func (m *ChatSessionMutation) Fields() []string {
  5532. fields := make([]string, 0, 7)
  5533. if m.created_at != nil {
  5534. fields = append(fields, chatsession.FieldCreatedAt)
  5535. }
  5536. if m.updated_at != nil {
  5537. fields = append(fields, chatsession.FieldUpdatedAt)
  5538. }
  5539. if m.deleted_at != nil {
  5540. fields = append(fields, chatsession.FieldDeletedAt)
  5541. }
  5542. if m.name != nil {
  5543. fields = append(fields, chatsession.FieldName)
  5544. }
  5545. if m.user_id != nil {
  5546. fields = append(fields, chatsession.FieldUserID)
  5547. }
  5548. if m.bot_id != nil {
  5549. fields = append(fields, chatsession.FieldBotID)
  5550. }
  5551. if m.bot_type != nil {
  5552. fields = append(fields, chatsession.FieldBotType)
  5553. }
  5554. return fields
  5555. }
  5556. // Field returns the value of a field with the given name. The second boolean
  5557. // return value indicates that this field was not set, or was not defined in the
  5558. // schema.
  5559. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  5560. switch name {
  5561. case chatsession.FieldCreatedAt:
  5562. return m.CreatedAt()
  5563. case chatsession.FieldUpdatedAt:
  5564. return m.UpdatedAt()
  5565. case chatsession.FieldDeletedAt:
  5566. return m.DeletedAt()
  5567. case chatsession.FieldName:
  5568. return m.Name()
  5569. case chatsession.FieldUserID:
  5570. return m.UserID()
  5571. case chatsession.FieldBotID:
  5572. return m.BotID()
  5573. case chatsession.FieldBotType:
  5574. return m.BotType()
  5575. }
  5576. return nil, false
  5577. }
  5578. // OldField returns the old value of the field from the database. An error is
  5579. // returned if the mutation operation is not UpdateOne, or the query to the
  5580. // database failed.
  5581. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5582. switch name {
  5583. case chatsession.FieldCreatedAt:
  5584. return m.OldCreatedAt(ctx)
  5585. case chatsession.FieldUpdatedAt:
  5586. return m.OldUpdatedAt(ctx)
  5587. case chatsession.FieldDeletedAt:
  5588. return m.OldDeletedAt(ctx)
  5589. case chatsession.FieldName:
  5590. return m.OldName(ctx)
  5591. case chatsession.FieldUserID:
  5592. return m.OldUserID(ctx)
  5593. case chatsession.FieldBotID:
  5594. return m.OldBotID(ctx)
  5595. case chatsession.FieldBotType:
  5596. return m.OldBotType(ctx)
  5597. }
  5598. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  5599. }
  5600. // SetField sets the value of a field with the given name. It returns an error if
  5601. // the field is not defined in the schema, or if the type mismatched the field
  5602. // type.
  5603. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  5604. switch name {
  5605. case chatsession.FieldCreatedAt:
  5606. v, ok := value.(time.Time)
  5607. if !ok {
  5608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5609. }
  5610. m.SetCreatedAt(v)
  5611. return nil
  5612. case chatsession.FieldUpdatedAt:
  5613. v, ok := value.(time.Time)
  5614. if !ok {
  5615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5616. }
  5617. m.SetUpdatedAt(v)
  5618. return nil
  5619. case chatsession.FieldDeletedAt:
  5620. v, ok := value.(time.Time)
  5621. if !ok {
  5622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5623. }
  5624. m.SetDeletedAt(v)
  5625. return nil
  5626. case chatsession.FieldName:
  5627. v, ok := value.(string)
  5628. if !ok {
  5629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5630. }
  5631. m.SetName(v)
  5632. return nil
  5633. case chatsession.FieldUserID:
  5634. v, ok := value.(uint64)
  5635. if !ok {
  5636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5637. }
  5638. m.SetUserID(v)
  5639. return nil
  5640. case chatsession.FieldBotID:
  5641. v, ok := value.(uint64)
  5642. if !ok {
  5643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5644. }
  5645. m.SetBotID(v)
  5646. return nil
  5647. case chatsession.FieldBotType:
  5648. v, ok := value.(uint8)
  5649. if !ok {
  5650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5651. }
  5652. m.SetBotType(v)
  5653. return nil
  5654. }
  5655. return fmt.Errorf("unknown ChatSession field %s", name)
  5656. }
  5657. // AddedFields returns all numeric fields that were incremented/decremented during
  5658. // this mutation.
  5659. func (m *ChatSessionMutation) AddedFields() []string {
  5660. var fields []string
  5661. if m.adduser_id != nil {
  5662. fields = append(fields, chatsession.FieldUserID)
  5663. }
  5664. if m.addbot_id != nil {
  5665. fields = append(fields, chatsession.FieldBotID)
  5666. }
  5667. if m.addbot_type != nil {
  5668. fields = append(fields, chatsession.FieldBotType)
  5669. }
  5670. return fields
  5671. }
  5672. // AddedField returns the numeric value that was incremented/decremented on a field
  5673. // with the given name. The second boolean return value indicates that this field
  5674. // was not set, or was not defined in the schema.
  5675. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  5676. switch name {
  5677. case chatsession.FieldUserID:
  5678. return m.AddedUserID()
  5679. case chatsession.FieldBotID:
  5680. return m.AddedBotID()
  5681. case chatsession.FieldBotType:
  5682. return m.AddedBotType()
  5683. }
  5684. return nil, false
  5685. }
  5686. // AddField adds the value to the field with the given name. It returns an error if
  5687. // the field is not defined in the schema, or if the type mismatched the field
  5688. // type.
  5689. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  5690. switch name {
  5691. case chatsession.FieldUserID:
  5692. v, ok := value.(int64)
  5693. if !ok {
  5694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5695. }
  5696. m.AddUserID(v)
  5697. return nil
  5698. case chatsession.FieldBotID:
  5699. v, ok := value.(int64)
  5700. if !ok {
  5701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5702. }
  5703. m.AddBotID(v)
  5704. return nil
  5705. case chatsession.FieldBotType:
  5706. v, ok := value.(int8)
  5707. if !ok {
  5708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5709. }
  5710. m.AddBotType(v)
  5711. return nil
  5712. }
  5713. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  5714. }
  5715. // ClearedFields returns all nullable fields that were cleared during this
  5716. // mutation.
  5717. func (m *ChatSessionMutation) ClearedFields() []string {
  5718. var fields []string
  5719. if m.FieldCleared(chatsession.FieldDeletedAt) {
  5720. fields = append(fields, chatsession.FieldDeletedAt)
  5721. }
  5722. return fields
  5723. }
  5724. // FieldCleared returns a boolean indicating if a field with the given name was
  5725. // cleared in this mutation.
  5726. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  5727. _, ok := m.clearedFields[name]
  5728. return ok
  5729. }
  5730. // ClearField clears the value of the field with the given name. It returns an
  5731. // error if the field is not defined in the schema.
  5732. func (m *ChatSessionMutation) ClearField(name string) error {
  5733. switch name {
  5734. case chatsession.FieldDeletedAt:
  5735. m.ClearDeletedAt()
  5736. return nil
  5737. }
  5738. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  5739. }
  5740. // ResetField resets all changes in the mutation for the field with the given name.
  5741. // It returns an error if the field is not defined in the schema.
  5742. func (m *ChatSessionMutation) ResetField(name string) error {
  5743. switch name {
  5744. case chatsession.FieldCreatedAt:
  5745. m.ResetCreatedAt()
  5746. return nil
  5747. case chatsession.FieldUpdatedAt:
  5748. m.ResetUpdatedAt()
  5749. return nil
  5750. case chatsession.FieldDeletedAt:
  5751. m.ResetDeletedAt()
  5752. return nil
  5753. case chatsession.FieldName:
  5754. m.ResetName()
  5755. return nil
  5756. case chatsession.FieldUserID:
  5757. m.ResetUserID()
  5758. return nil
  5759. case chatsession.FieldBotID:
  5760. m.ResetBotID()
  5761. return nil
  5762. case chatsession.FieldBotType:
  5763. m.ResetBotType()
  5764. return nil
  5765. }
  5766. return fmt.Errorf("unknown ChatSession field %s", name)
  5767. }
  5768. // AddedEdges returns all edge names that were set/added in this mutation.
  5769. func (m *ChatSessionMutation) AddedEdges() []string {
  5770. edges := make([]string, 0, 0)
  5771. return edges
  5772. }
  5773. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5774. // name in this mutation.
  5775. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  5776. return nil
  5777. }
  5778. // RemovedEdges returns all edge names that were removed in this mutation.
  5779. func (m *ChatSessionMutation) RemovedEdges() []string {
  5780. edges := make([]string, 0, 0)
  5781. return edges
  5782. }
  5783. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5784. // the given name in this mutation.
  5785. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  5786. return nil
  5787. }
  5788. // ClearedEdges returns all edge names that were cleared in this mutation.
  5789. func (m *ChatSessionMutation) ClearedEdges() []string {
  5790. edges := make([]string, 0, 0)
  5791. return edges
  5792. }
  5793. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5794. // was cleared in this mutation.
  5795. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  5796. return false
  5797. }
  5798. // ClearEdge clears the value of the edge with the given name. It returns an error
  5799. // if that edge is not defined in the schema.
  5800. func (m *ChatSessionMutation) ClearEdge(name string) error {
  5801. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  5802. }
  5803. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5804. // It returns an error if the edge is not defined in the schema.
  5805. func (m *ChatSessionMutation) ResetEdge(name string) error {
  5806. return fmt.Errorf("unknown ChatSession edge %s", name)
  5807. }
  5808. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  5809. type ContactMutation struct {
  5810. config
  5811. op Op
  5812. typ string
  5813. id *uint64
  5814. created_at *time.Time
  5815. updated_at *time.Time
  5816. status *uint8
  5817. addstatus *int8
  5818. deleted_at *time.Time
  5819. wx_wxid *string
  5820. _type *int
  5821. add_type *int
  5822. wxid *string
  5823. account *string
  5824. nickname *string
  5825. markname *string
  5826. headimg *string
  5827. sex *int
  5828. addsex *int
  5829. starrole *string
  5830. dontseeit *int
  5831. adddontseeit *int
  5832. dontseeme *int
  5833. adddontseeme *int
  5834. lag *string
  5835. gid *string
  5836. gname *string
  5837. v3 *string
  5838. organization_id *uint64
  5839. addorganization_id *int64
  5840. clearedFields map[string]struct{}
  5841. contact_relationships map[uint64]struct{}
  5842. removedcontact_relationships map[uint64]struct{}
  5843. clearedcontact_relationships bool
  5844. contact_messages map[uint64]struct{}
  5845. removedcontact_messages map[uint64]struct{}
  5846. clearedcontact_messages bool
  5847. done bool
  5848. oldValue func(context.Context) (*Contact, error)
  5849. predicates []predicate.Contact
  5850. }
  5851. var _ ent.Mutation = (*ContactMutation)(nil)
  5852. // contactOption allows management of the mutation configuration using functional options.
  5853. type contactOption func(*ContactMutation)
  5854. // newContactMutation creates new mutation for the Contact entity.
  5855. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  5856. m := &ContactMutation{
  5857. config: c,
  5858. op: op,
  5859. typ: TypeContact,
  5860. clearedFields: make(map[string]struct{}),
  5861. }
  5862. for _, opt := range opts {
  5863. opt(m)
  5864. }
  5865. return m
  5866. }
  5867. // withContactID sets the ID field of the mutation.
  5868. func withContactID(id uint64) contactOption {
  5869. return func(m *ContactMutation) {
  5870. var (
  5871. err error
  5872. once sync.Once
  5873. value *Contact
  5874. )
  5875. m.oldValue = func(ctx context.Context) (*Contact, error) {
  5876. once.Do(func() {
  5877. if m.done {
  5878. err = errors.New("querying old values post mutation is not allowed")
  5879. } else {
  5880. value, err = m.Client().Contact.Get(ctx, id)
  5881. }
  5882. })
  5883. return value, err
  5884. }
  5885. m.id = &id
  5886. }
  5887. }
  5888. // withContact sets the old Contact of the mutation.
  5889. func withContact(node *Contact) contactOption {
  5890. return func(m *ContactMutation) {
  5891. m.oldValue = func(context.Context) (*Contact, error) {
  5892. return node, nil
  5893. }
  5894. m.id = &node.ID
  5895. }
  5896. }
  5897. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5898. // executed in a transaction (ent.Tx), a transactional client is returned.
  5899. func (m ContactMutation) Client() *Client {
  5900. client := &Client{config: m.config}
  5901. client.init()
  5902. return client
  5903. }
  5904. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5905. // it returns an error otherwise.
  5906. func (m ContactMutation) Tx() (*Tx, error) {
  5907. if _, ok := m.driver.(*txDriver); !ok {
  5908. return nil, errors.New("ent: mutation is not running in a transaction")
  5909. }
  5910. tx := &Tx{config: m.config}
  5911. tx.init()
  5912. return tx, nil
  5913. }
  5914. // SetID sets the value of the id field. Note that this
  5915. // operation is only accepted on creation of Contact entities.
  5916. func (m *ContactMutation) SetID(id uint64) {
  5917. m.id = &id
  5918. }
  5919. // ID returns the ID value in the mutation. Note that the ID is only available
  5920. // if it was provided to the builder or after it was returned from the database.
  5921. func (m *ContactMutation) ID() (id uint64, exists bool) {
  5922. if m.id == nil {
  5923. return
  5924. }
  5925. return *m.id, true
  5926. }
  5927. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5928. // That means, if the mutation is applied within a transaction with an isolation level such
  5929. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5930. // or updated by the mutation.
  5931. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  5932. switch {
  5933. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5934. id, exists := m.ID()
  5935. if exists {
  5936. return []uint64{id}, nil
  5937. }
  5938. fallthrough
  5939. case m.op.Is(OpUpdate | OpDelete):
  5940. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  5941. default:
  5942. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5943. }
  5944. }
  5945. // SetCreatedAt sets the "created_at" field.
  5946. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  5947. m.created_at = &t
  5948. }
  5949. // CreatedAt returns the value of the "created_at" field in the mutation.
  5950. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  5951. v := m.created_at
  5952. if v == nil {
  5953. return
  5954. }
  5955. return *v, true
  5956. }
  5957. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  5958. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  5959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5960. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5961. if !m.op.Is(OpUpdateOne) {
  5962. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5963. }
  5964. if m.id == nil || m.oldValue == nil {
  5965. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5966. }
  5967. oldValue, err := m.oldValue(ctx)
  5968. if err != nil {
  5969. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5970. }
  5971. return oldValue.CreatedAt, nil
  5972. }
  5973. // ResetCreatedAt resets all changes to the "created_at" field.
  5974. func (m *ContactMutation) ResetCreatedAt() {
  5975. m.created_at = nil
  5976. }
  5977. // SetUpdatedAt sets the "updated_at" field.
  5978. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  5979. m.updated_at = &t
  5980. }
  5981. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5982. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  5983. v := m.updated_at
  5984. if v == nil {
  5985. return
  5986. }
  5987. return *v, true
  5988. }
  5989. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  5990. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  5991. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5992. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5993. if !m.op.Is(OpUpdateOne) {
  5994. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5995. }
  5996. if m.id == nil || m.oldValue == nil {
  5997. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5998. }
  5999. oldValue, err := m.oldValue(ctx)
  6000. if err != nil {
  6001. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6002. }
  6003. return oldValue.UpdatedAt, nil
  6004. }
  6005. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6006. func (m *ContactMutation) ResetUpdatedAt() {
  6007. m.updated_at = nil
  6008. }
  6009. // SetStatus sets the "status" field.
  6010. func (m *ContactMutation) SetStatus(u uint8) {
  6011. m.status = &u
  6012. m.addstatus = nil
  6013. }
  6014. // Status returns the value of the "status" field in the mutation.
  6015. func (m *ContactMutation) Status() (r uint8, exists bool) {
  6016. v := m.status
  6017. if v == nil {
  6018. return
  6019. }
  6020. return *v, true
  6021. }
  6022. // OldStatus returns the old "status" field's value of the Contact entity.
  6023. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6025. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6026. if !m.op.Is(OpUpdateOne) {
  6027. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6028. }
  6029. if m.id == nil || m.oldValue == nil {
  6030. return v, errors.New("OldStatus requires an ID field in the mutation")
  6031. }
  6032. oldValue, err := m.oldValue(ctx)
  6033. if err != nil {
  6034. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6035. }
  6036. return oldValue.Status, nil
  6037. }
  6038. // AddStatus adds u to the "status" field.
  6039. func (m *ContactMutation) AddStatus(u int8) {
  6040. if m.addstatus != nil {
  6041. *m.addstatus += u
  6042. } else {
  6043. m.addstatus = &u
  6044. }
  6045. }
  6046. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6047. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  6048. v := m.addstatus
  6049. if v == nil {
  6050. return
  6051. }
  6052. return *v, true
  6053. }
  6054. // ClearStatus clears the value of the "status" field.
  6055. func (m *ContactMutation) ClearStatus() {
  6056. m.status = nil
  6057. m.addstatus = nil
  6058. m.clearedFields[contact.FieldStatus] = struct{}{}
  6059. }
  6060. // StatusCleared returns if the "status" field was cleared in this mutation.
  6061. func (m *ContactMutation) StatusCleared() bool {
  6062. _, ok := m.clearedFields[contact.FieldStatus]
  6063. return ok
  6064. }
  6065. // ResetStatus resets all changes to the "status" field.
  6066. func (m *ContactMutation) ResetStatus() {
  6067. m.status = nil
  6068. m.addstatus = nil
  6069. delete(m.clearedFields, contact.FieldStatus)
  6070. }
  6071. // SetDeletedAt sets the "deleted_at" field.
  6072. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  6073. m.deleted_at = &t
  6074. }
  6075. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6076. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  6077. v := m.deleted_at
  6078. if v == nil {
  6079. return
  6080. }
  6081. return *v, true
  6082. }
  6083. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  6084. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6086. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6087. if !m.op.Is(OpUpdateOne) {
  6088. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6089. }
  6090. if m.id == nil || m.oldValue == nil {
  6091. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6092. }
  6093. oldValue, err := m.oldValue(ctx)
  6094. if err != nil {
  6095. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6096. }
  6097. return oldValue.DeletedAt, nil
  6098. }
  6099. // ClearDeletedAt clears the value of the "deleted_at" field.
  6100. func (m *ContactMutation) ClearDeletedAt() {
  6101. m.deleted_at = nil
  6102. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  6103. }
  6104. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6105. func (m *ContactMutation) DeletedAtCleared() bool {
  6106. _, ok := m.clearedFields[contact.FieldDeletedAt]
  6107. return ok
  6108. }
  6109. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6110. func (m *ContactMutation) ResetDeletedAt() {
  6111. m.deleted_at = nil
  6112. delete(m.clearedFields, contact.FieldDeletedAt)
  6113. }
  6114. // SetWxWxid sets the "wx_wxid" field.
  6115. func (m *ContactMutation) SetWxWxid(s string) {
  6116. m.wx_wxid = &s
  6117. }
  6118. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  6119. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  6120. v := m.wx_wxid
  6121. if v == nil {
  6122. return
  6123. }
  6124. return *v, true
  6125. }
  6126. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  6127. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6129. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  6130. if !m.op.Is(OpUpdateOne) {
  6131. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  6132. }
  6133. if m.id == nil || m.oldValue == nil {
  6134. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  6135. }
  6136. oldValue, err := m.oldValue(ctx)
  6137. if err != nil {
  6138. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  6139. }
  6140. return oldValue.WxWxid, nil
  6141. }
  6142. // ClearWxWxid clears the value of the "wx_wxid" field.
  6143. func (m *ContactMutation) ClearWxWxid() {
  6144. m.wx_wxid = nil
  6145. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  6146. }
  6147. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  6148. func (m *ContactMutation) WxWxidCleared() bool {
  6149. _, ok := m.clearedFields[contact.FieldWxWxid]
  6150. return ok
  6151. }
  6152. // ResetWxWxid resets all changes to the "wx_wxid" field.
  6153. func (m *ContactMutation) ResetWxWxid() {
  6154. m.wx_wxid = nil
  6155. delete(m.clearedFields, contact.FieldWxWxid)
  6156. }
  6157. // SetType sets the "type" field.
  6158. func (m *ContactMutation) SetType(i int) {
  6159. m._type = &i
  6160. m.add_type = nil
  6161. }
  6162. // GetType returns the value of the "type" field in the mutation.
  6163. func (m *ContactMutation) GetType() (r int, exists bool) {
  6164. v := m._type
  6165. if v == nil {
  6166. return
  6167. }
  6168. return *v, true
  6169. }
  6170. // OldType returns the old "type" field's value of the Contact entity.
  6171. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6173. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  6174. if !m.op.Is(OpUpdateOne) {
  6175. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6176. }
  6177. if m.id == nil || m.oldValue == nil {
  6178. return v, errors.New("OldType requires an ID field in the mutation")
  6179. }
  6180. oldValue, err := m.oldValue(ctx)
  6181. if err != nil {
  6182. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6183. }
  6184. return oldValue.Type, nil
  6185. }
  6186. // AddType adds i to the "type" field.
  6187. func (m *ContactMutation) AddType(i int) {
  6188. if m.add_type != nil {
  6189. *m.add_type += i
  6190. } else {
  6191. m.add_type = &i
  6192. }
  6193. }
  6194. // AddedType returns the value that was added to the "type" field in this mutation.
  6195. func (m *ContactMutation) AddedType() (r int, exists bool) {
  6196. v := m.add_type
  6197. if v == nil {
  6198. return
  6199. }
  6200. return *v, true
  6201. }
  6202. // ClearType clears the value of the "type" field.
  6203. func (m *ContactMutation) ClearType() {
  6204. m._type = nil
  6205. m.add_type = nil
  6206. m.clearedFields[contact.FieldType] = struct{}{}
  6207. }
  6208. // TypeCleared returns if the "type" field was cleared in this mutation.
  6209. func (m *ContactMutation) TypeCleared() bool {
  6210. _, ok := m.clearedFields[contact.FieldType]
  6211. return ok
  6212. }
  6213. // ResetType resets all changes to the "type" field.
  6214. func (m *ContactMutation) ResetType() {
  6215. m._type = nil
  6216. m.add_type = nil
  6217. delete(m.clearedFields, contact.FieldType)
  6218. }
  6219. // SetWxid sets the "wxid" field.
  6220. func (m *ContactMutation) SetWxid(s string) {
  6221. m.wxid = &s
  6222. }
  6223. // Wxid returns the value of the "wxid" field in the mutation.
  6224. func (m *ContactMutation) Wxid() (r string, exists bool) {
  6225. v := m.wxid
  6226. if v == nil {
  6227. return
  6228. }
  6229. return *v, true
  6230. }
  6231. // OldWxid returns the old "wxid" field's value of the Contact entity.
  6232. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6234. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  6235. if !m.op.Is(OpUpdateOne) {
  6236. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  6237. }
  6238. if m.id == nil || m.oldValue == nil {
  6239. return v, errors.New("OldWxid requires an ID field in the mutation")
  6240. }
  6241. oldValue, err := m.oldValue(ctx)
  6242. if err != nil {
  6243. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  6244. }
  6245. return oldValue.Wxid, nil
  6246. }
  6247. // ResetWxid resets all changes to the "wxid" field.
  6248. func (m *ContactMutation) ResetWxid() {
  6249. m.wxid = nil
  6250. }
  6251. // SetAccount sets the "account" field.
  6252. func (m *ContactMutation) SetAccount(s string) {
  6253. m.account = &s
  6254. }
  6255. // Account returns the value of the "account" field in the mutation.
  6256. func (m *ContactMutation) Account() (r string, exists bool) {
  6257. v := m.account
  6258. if v == nil {
  6259. return
  6260. }
  6261. return *v, true
  6262. }
  6263. // OldAccount returns the old "account" field's value of the Contact entity.
  6264. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6266. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  6267. if !m.op.Is(OpUpdateOne) {
  6268. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  6269. }
  6270. if m.id == nil || m.oldValue == nil {
  6271. return v, errors.New("OldAccount requires an ID field in the mutation")
  6272. }
  6273. oldValue, err := m.oldValue(ctx)
  6274. if err != nil {
  6275. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  6276. }
  6277. return oldValue.Account, nil
  6278. }
  6279. // ResetAccount resets all changes to the "account" field.
  6280. func (m *ContactMutation) ResetAccount() {
  6281. m.account = nil
  6282. }
  6283. // SetNickname sets the "nickname" field.
  6284. func (m *ContactMutation) SetNickname(s string) {
  6285. m.nickname = &s
  6286. }
  6287. // Nickname returns the value of the "nickname" field in the mutation.
  6288. func (m *ContactMutation) Nickname() (r string, exists bool) {
  6289. v := m.nickname
  6290. if v == nil {
  6291. return
  6292. }
  6293. return *v, true
  6294. }
  6295. // OldNickname returns the old "nickname" field's value of the Contact entity.
  6296. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6298. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  6299. if !m.op.Is(OpUpdateOne) {
  6300. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  6301. }
  6302. if m.id == nil || m.oldValue == nil {
  6303. return v, errors.New("OldNickname requires an ID field in the mutation")
  6304. }
  6305. oldValue, err := m.oldValue(ctx)
  6306. if err != nil {
  6307. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  6308. }
  6309. return oldValue.Nickname, nil
  6310. }
  6311. // ResetNickname resets all changes to the "nickname" field.
  6312. func (m *ContactMutation) ResetNickname() {
  6313. m.nickname = nil
  6314. }
  6315. // SetMarkname sets the "markname" field.
  6316. func (m *ContactMutation) SetMarkname(s string) {
  6317. m.markname = &s
  6318. }
  6319. // Markname returns the value of the "markname" field in the mutation.
  6320. func (m *ContactMutation) Markname() (r string, exists bool) {
  6321. v := m.markname
  6322. if v == nil {
  6323. return
  6324. }
  6325. return *v, true
  6326. }
  6327. // OldMarkname returns the old "markname" field's value of the Contact entity.
  6328. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6330. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  6331. if !m.op.Is(OpUpdateOne) {
  6332. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  6333. }
  6334. if m.id == nil || m.oldValue == nil {
  6335. return v, errors.New("OldMarkname requires an ID field in the mutation")
  6336. }
  6337. oldValue, err := m.oldValue(ctx)
  6338. if err != nil {
  6339. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  6340. }
  6341. return oldValue.Markname, nil
  6342. }
  6343. // ResetMarkname resets all changes to the "markname" field.
  6344. func (m *ContactMutation) ResetMarkname() {
  6345. m.markname = nil
  6346. }
  6347. // SetHeadimg sets the "headimg" field.
  6348. func (m *ContactMutation) SetHeadimg(s string) {
  6349. m.headimg = &s
  6350. }
  6351. // Headimg returns the value of the "headimg" field in the mutation.
  6352. func (m *ContactMutation) Headimg() (r string, exists bool) {
  6353. v := m.headimg
  6354. if v == nil {
  6355. return
  6356. }
  6357. return *v, true
  6358. }
  6359. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  6360. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6362. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  6363. if !m.op.Is(OpUpdateOne) {
  6364. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  6365. }
  6366. if m.id == nil || m.oldValue == nil {
  6367. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  6368. }
  6369. oldValue, err := m.oldValue(ctx)
  6370. if err != nil {
  6371. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  6372. }
  6373. return oldValue.Headimg, nil
  6374. }
  6375. // ResetHeadimg resets all changes to the "headimg" field.
  6376. func (m *ContactMutation) ResetHeadimg() {
  6377. m.headimg = nil
  6378. }
  6379. // SetSex sets the "sex" field.
  6380. func (m *ContactMutation) SetSex(i int) {
  6381. m.sex = &i
  6382. m.addsex = nil
  6383. }
  6384. // Sex returns the value of the "sex" field in the mutation.
  6385. func (m *ContactMutation) Sex() (r int, exists bool) {
  6386. v := m.sex
  6387. if v == nil {
  6388. return
  6389. }
  6390. return *v, true
  6391. }
  6392. // OldSex returns the old "sex" field's value of the Contact entity.
  6393. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6395. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  6396. if !m.op.Is(OpUpdateOne) {
  6397. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  6398. }
  6399. if m.id == nil || m.oldValue == nil {
  6400. return v, errors.New("OldSex requires an ID field in the mutation")
  6401. }
  6402. oldValue, err := m.oldValue(ctx)
  6403. if err != nil {
  6404. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  6405. }
  6406. return oldValue.Sex, nil
  6407. }
  6408. // AddSex adds i to the "sex" field.
  6409. func (m *ContactMutation) AddSex(i int) {
  6410. if m.addsex != nil {
  6411. *m.addsex += i
  6412. } else {
  6413. m.addsex = &i
  6414. }
  6415. }
  6416. // AddedSex returns the value that was added to the "sex" field in this mutation.
  6417. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  6418. v := m.addsex
  6419. if v == nil {
  6420. return
  6421. }
  6422. return *v, true
  6423. }
  6424. // ResetSex resets all changes to the "sex" field.
  6425. func (m *ContactMutation) ResetSex() {
  6426. m.sex = nil
  6427. m.addsex = nil
  6428. }
  6429. // SetStarrole sets the "starrole" field.
  6430. func (m *ContactMutation) SetStarrole(s string) {
  6431. m.starrole = &s
  6432. }
  6433. // Starrole returns the value of the "starrole" field in the mutation.
  6434. func (m *ContactMutation) Starrole() (r string, exists bool) {
  6435. v := m.starrole
  6436. if v == nil {
  6437. return
  6438. }
  6439. return *v, true
  6440. }
  6441. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  6442. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6444. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  6445. if !m.op.Is(OpUpdateOne) {
  6446. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  6447. }
  6448. if m.id == nil || m.oldValue == nil {
  6449. return v, errors.New("OldStarrole requires an ID field in the mutation")
  6450. }
  6451. oldValue, err := m.oldValue(ctx)
  6452. if err != nil {
  6453. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  6454. }
  6455. return oldValue.Starrole, nil
  6456. }
  6457. // ResetStarrole resets all changes to the "starrole" field.
  6458. func (m *ContactMutation) ResetStarrole() {
  6459. m.starrole = nil
  6460. }
  6461. // SetDontseeit sets the "dontseeit" field.
  6462. func (m *ContactMutation) SetDontseeit(i int) {
  6463. m.dontseeit = &i
  6464. m.adddontseeit = nil
  6465. }
  6466. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  6467. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  6468. v := m.dontseeit
  6469. if v == nil {
  6470. return
  6471. }
  6472. return *v, true
  6473. }
  6474. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  6475. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6477. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  6478. if !m.op.Is(OpUpdateOne) {
  6479. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  6480. }
  6481. if m.id == nil || m.oldValue == nil {
  6482. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  6483. }
  6484. oldValue, err := m.oldValue(ctx)
  6485. if err != nil {
  6486. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  6487. }
  6488. return oldValue.Dontseeit, nil
  6489. }
  6490. // AddDontseeit adds i to the "dontseeit" field.
  6491. func (m *ContactMutation) AddDontseeit(i int) {
  6492. if m.adddontseeit != nil {
  6493. *m.adddontseeit += i
  6494. } else {
  6495. m.adddontseeit = &i
  6496. }
  6497. }
  6498. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  6499. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  6500. v := m.adddontseeit
  6501. if v == nil {
  6502. return
  6503. }
  6504. return *v, true
  6505. }
  6506. // ResetDontseeit resets all changes to the "dontseeit" field.
  6507. func (m *ContactMutation) ResetDontseeit() {
  6508. m.dontseeit = nil
  6509. m.adddontseeit = nil
  6510. }
  6511. // SetDontseeme sets the "dontseeme" field.
  6512. func (m *ContactMutation) SetDontseeme(i int) {
  6513. m.dontseeme = &i
  6514. m.adddontseeme = nil
  6515. }
  6516. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  6517. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  6518. v := m.dontseeme
  6519. if v == nil {
  6520. return
  6521. }
  6522. return *v, true
  6523. }
  6524. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  6525. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6527. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  6528. if !m.op.Is(OpUpdateOne) {
  6529. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  6530. }
  6531. if m.id == nil || m.oldValue == nil {
  6532. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  6533. }
  6534. oldValue, err := m.oldValue(ctx)
  6535. if err != nil {
  6536. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  6537. }
  6538. return oldValue.Dontseeme, nil
  6539. }
  6540. // AddDontseeme adds i to the "dontseeme" field.
  6541. func (m *ContactMutation) AddDontseeme(i int) {
  6542. if m.adddontseeme != nil {
  6543. *m.adddontseeme += i
  6544. } else {
  6545. m.adddontseeme = &i
  6546. }
  6547. }
  6548. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  6549. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  6550. v := m.adddontseeme
  6551. if v == nil {
  6552. return
  6553. }
  6554. return *v, true
  6555. }
  6556. // ResetDontseeme resets all changes to the "dontseeme" field.
  6557. func (m *ContactMutation) ResetDontseeme() {
  6558. m.dontseeme = nil
  6559. m.adddontseeme = nil
  6560. }
  6561. // SetLag sets the "lag" field.
  6562. func (m *ContactMutation) SetLag(s string) {
  6563. m.lag = &s
  6564. }
  6565. // Lag returns the value of the "lag" field in the mutation.
  6566. func (m *ContactMutation) Lag() (r string, exists bool) {
  6567. v := m.lag
  6568. if v == nil {
  6569. return
  6570. }
  6571. return *v, true
  6572. }
  6573. // OldLag returns the old "lag" field's value of the Contact entity.
  6574. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6576. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  6577. if !m.op.Is(OpUpdateOne) {
  6578. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  6579. }
  6580. if m.id == nil || m.oldValue == nil {
  6581. return v, errors.New("OldLag requires an ID field in the mutation")
  6582. }
  6583. oldValue, err := m.oldValue(ctx)
  6584. if err != nil {
  6585. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  6586. }
  6587. return oldValue.Lag, nil
  6588. }
  6589. // ResetLag resets all changes to the "lag" field.
  6590. func (m *ContactMutation) ResetLag() {
  6591. m.lag = nil
  6592. }
  6593. // SetGid sets the "gid" field.
  6594. func (m *ContactMutation) SetGid(s string) {
  6595. m.gid = &s
  6596. }
  6597. // Gid returns the value of the "gid" field in the mutation.
  6598. func (m *ContactMutation) Gid() (r string, exists bool) {
  6599. v := m.gid
  6600. if v == nil {
  6601. return
  6602. }
  6603. return *v, true
  6604. }
  6605. // OldGid returns the old "gid" field's value of the Contact entity.
  6606. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6608. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  6609. if !m.op.Is(OpUpdateOne) {
  6610. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  6611. }
  6612. if m.id == nil || m.oldValue == nil {
  6613. return v, errors.New("OldGid requires an ID field in the mutation")
  6614. }
  6615. oldValue, err := m.oldValue(ctx)
  6616. if err != nil {
  6617. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  6618. }
  6619. return oldValue.Gid, nil
  6620. }
  6621. // ResetGid resets all changes to the "gid" field.
  6622. func (m *ContactMutation) ResetGid() {
  6623. m.gid = nil
  6624. }
  6625. // SetGname sets the "gname" field.
  6626. func (m *ContactMutation) SetGname(s string) {
  6627. m.gname = &s
  6628. }
  6629. // Gname returns the value of the "gname" field in the mutation.
  6630. func (m *ContactMutation) Gname() (r string, exists bool) {
  6631. v := m.gname
  6632. if v == nil {
  6633. return
  6634. }
  6635. return *v, true
  6636. }
  6637. // OldGname returns the old "gname" field's value of the Contact entity.
  6638. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6640. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  6641. if !m.op.Is(OpUpdateOne) {
  6642. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  6643. }
  6644. if m.id == nil || m.oldValue == nil {
  6645. return v, errors.New("OldGname requires an ID field in the mutation")
  6646. }
  6647. oldValue, err := m.oldValue(ctx)
  6648. if err != nil {
  6649. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  6650. }
  6651. return oldValue.Gname, nil
  6652. }
  6653. // ResetGname resets all changes to the "gname" field.
  6654. func (m *ContactMutation) ResetGname() {
  6655. m.gname = nil
  6656. }
  6657. // SetV3 sets the "v3" field.
  6658. func (m *ContactMutation) SetV3(s string) {
  6659. m.v3 = &s
  6660. }
  6661. // V3 returns the value of the "v3" field in the mutation.
  6662. func (m *ContactMutation) V3() (r string, exists bool) {
  6663. v := m.v3
  6664. if v == nil {
  6665. return
  6666. }
  6667. return *v, true
  6668. }
  6669. // OldV3 returns the old "v3" field's value of the Contact entity.
  6670. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6672. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  6673. if !m.op.Is(OpUpdateOne) {
  6674. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  6675. }
  6676. if m.id == nil || m.oldValue == nil {
  6677. return v, errors.New("OldV3 requires an ID field in the mutation")
  6678. }
  6679. oldValue, err := m.oldValue(ctx)
  6680. if err != nil {
  6681. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  6682. }
  6683. return oldValue.V3, nil
  6684. }
  6685. // ResetV3 resets all changes to the "v3" field.
  6686. func (m *ContactMutation) ResetV3() {
  6687. m.v3 = nil
  6688. }
  6689. // SetOrganizationID sets the "organization_id" field.
  6690. func (m *ContactMutation) SetOrganizationID(u uint64) {
  6691. m.organization_id = &u
  6692. m.addorganization_id = nil
  6693. }
  6694. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6695. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  6696. v := m.organization_id
  6697. if v == nil {
  6698. return
  6699. }
  6700. return *v, true
  6701. }
  6702. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  6703. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6705. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6706. if !m.op.Is(OpUpdateOne) {
  6707. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6708. }
  6709. if m.id == nil || m.oldValue == nil {
  6710. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6711. }
  6712. oldValue, err := m.oldValue(ctx)
  6713. if err != nil {
  6714. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6715. }
  6716. return oldValue.OrganizationID, nil
  6717. }
  6718. // AddOrganizationID adds u to the "organization_id" field.
  6719. func (m *ContactMutation) AddOrganizationID(u int64) {
  6720. if m.addorganization_id != nil {
  6721. *m.addorganization_id += u
  6722. } else {
  6723. m.addorganization_id = &u
  6724. }
  6725. }
  6726. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6727. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  6728. v := m.addorganization_id
  6729. if v == nil {
  6730. return
  6731. }
  6732. return *v, true
  6733. }
  6734. // ClearOrganizationID clears the value of the "organization_id" field.
  6735. func (m *ContactMutation) ClearOrganizationID() {
  6736. m.organization_id = nil
  6737. m.addorganization_id = nil
  6738. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  6739. }
  6740. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6741. func (m *ContactMutation) OrganizationIDCleared() bool {
  6742. _, ok := m.clearedFields[contact.FieldOrganizationID]
  6743. return ok
  6744. }
  6745. // ResetOrganizationID resets all changes to the "organization_id" field.
  6746. func (m *ContactMutation) ResetOrganizationID() {
  6747. m.organization_id = nil
  6748. m.addorganization_id = nil
  6749. delete(m.clearedFields, contact.FieldOrganizationID)
  6750. }
  6751. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  6752. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  6753. if m.contact_relationships == nil {
  6754. m.contact_relationships = make(map[uint64]struct{})
  6755. }
  6756. for i := range ids {
  6757. m.contact_relationships[ids[i]] = struct{}{}
  6758. }
  6759. }
  6760. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  6761. func (m *ContactMutation) ClearContactRelationships() {
  6762. m.clearedcontact_relationships = true
  6763. }
  6764. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  6765. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  6766. return m.clearedcontact_relationships
  6767. }
  6768. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  6769. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  6770. if m.removedcontact_relationships == nil {
  6771. m.removedcontact_relationships = make(map[uint64]struct{})
  6772. }
  6773. for i := range ids {
  6774. delete(m.contact_relationships, ids[i])
  6775. m.removedcontact_relationships[ids[i]] = struct{}{}
  6776. }
  6777. }
  6778. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  6779. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  6780. for id := range m.removedcontact_relationships {
  6781. ids = append(ids, id)
  6782. }
  6783. return
  6784. }
  6785. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  6786. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  6787. for id := range m.contact_relationships {
  6788. ids = append(ids, id)
  6789. }
  6790. return
  6791. }
  6792. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  6793. func (m *ContactMutation) ResetContactRelationships() {
  6794. m.contact_relationships = nil
  6795. m.clearedcontact_relationships = false
  6796. m.removedcontact_relationships = nil
  6797. }
  6798. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  6799. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  6800. if m.contact_messages == nil {
  6801. m.contact_messages = make(map[uint64]struct{})
  6802. }
  6803. for i := range ids {
  6804. m.contact_messages[ids[i]] = struct{}{}
  6805. }
  6806. }
  6807. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  6808. func (m *ContactMutation) ClearContactMessages() {
  6809. m.clearedcontact_messages = true
  6810. }
  6811. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  6812. func (m *ContactMutation) ContactMessagesCleared() bool {
  6813. return m.clearedcontact_messages
  6814. }
  6815. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  6816. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  6817. if m.removedcontact_messages == nil {
  6818. m.removedcontact_messages = make(map[uint64]struct{})
  6819. }
  6820. for i := range ids {
  6821. delete(m.contact_messages, ids[i])
  6822. m.removedcontact_messages[ids[i]] = struct{}{}
  6823. }
  6824. }
  6825. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  6826. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  6827. for id := range m.removedcontact_messages {
  6828. ids = append(ids, id)
  6829. }
  6830. return
  6831. }
  6832. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  6833. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  6834. for id := range m.contact_messages {
  6835. ids = append(ids, id)
  6836. }
  6837. return
  6838. }
  6839. // ResetContactMessages resets all changes to the "contact_messages" edge.
  6840. func (m *ContactMutation) ResetContactMessages() {
  6841. m.contact_messages = nil
  6842. m.clearedcontact_messages = false
  6843. m.removedcontact_messages = nil
  6844. }
  6845. // Where appends a list predicates to the ContactMutation builder.
  6846. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  6847. m.predicates = append(m.predicates, ps...)
  6848. }
  6849. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  6850. // users can use type-assertion to append predicates that do not depend on any generated package.
  6851. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  6852. p := make([]predicate.Contact, len(ps))
  6853. for i := range ps {
  6854. p[i] = ps[i]
  6855. }
  6856. m.Where(p...)
  6857. }
  6858. // Op returns the operation name.
  6859. func (m *ContactMutation) Op() Op {
  6860. return m.op
  6861. }
  6862. // SetOp allows setting the mutation operation.
  6863. func (m *ContactMutation) SetOp(op Op) {
  6864. m.op = op
  6865. }
  6866. // Type returns the node type of this mutation (Contact).
  6867. func (m *ContactMutation) Type() string {
  6868. return m.typ
  6869. }
  6870. // Fields returns all fields that were changed during this mutation. Note that in
  6871. // order to get all numeric fields that were incremented/decremented, call
  6872. // AddedFields().
  6873. func (m *ContactMutation) Fields() []string {
  6874. fields := make([]string, 0, 20)
  6875. if m.created_at != nil {
  6876. fields = append(fields, contact.FieldCreatedAt)
  6877. }
  6878. if m.updated_at != nil {
  6879. fields = append(fields, contact.FieldUpdatedAt)
  6880. }
  6881. if m.status != nil {
  6882. fields = append(fields, contact.FieldStatus)
  6883. }
  6884. if m.deleted_at != nil {
  6885. fields = append(fields, contact.FieldDeletedAt)
  6886. }
  6887. if m.wx_wxid != nil {
  6888. fields = append(fields, contact.FieldWxWxid)
  6889. }
  6890. if m._type != nil {
  6891. fields = append(fields, contact.FieldType)
  6892. }
  6893. if m.wxid != nil {
  6894. fields = append(fields, contact.FieldWxid)
  6895. }
  6896. if m.account != nil {
  6897. fields = append(fields, contact.FieldAccount)
  6898. }
  6899. if m.nickname != nil {
  6900. fields = append(fields, contact.FieldNickname)
  6901. }
  6902. if m.markname != nil {
  6903. fields = append(fields, contact.FieldMarkname)
  6904. }
  6905. if m.headimg != nil {
  6906. fields = append(fields, contact.FieldHeadimg)
  6907. }
  6908. if m.sex != nil {
  6909. fields = append(fields, contact.FieldSex)
  6910. }
  6911. if m.starrole != nil {
  6912. fields = append(fields, contact.FieldStarrole)
  6913. }
  6914. if m.dontseeit != nil {
  6915. fields = append(fields, contact.FieldDontseeit)
  6916. }
  6917. if m.dontseeme != nil {
  6918. fields = append(fields, contact.FieldDontseeme)
  6919. }
  6920. if m.lag != nil {
  6921. fields = append(fields, contact.FieldLag)
  6922. }
  6923. if m.gid != nil {
  6924. fields = append(fields, contact.FieldGid)
  6925. }
  6926. if m.gname != nil {
  6927. fields = append(fields, contact.FieldGname)
  6928. }
  6929. if m.v3 != nil {
  6930. fields = append(fields, contact.FieldV3)
  6931. }
  6932. if m.organization_id != nil {
  6933. fields = append(fields, contact.FieldOrganizationID)
  6934. }
  6935. return fields
  6936. }
  6937. // Field returns the value of a field with the given name. The second boolean
  6938. // return value indicates that this field was not set, or was not defined in the
  6939. // schema.
  6940. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  6941. switch name {
  6942. case contact.FieldCreatedAt:
  6943. return m.CreatedAt()
  6944. case contact.FieldUpdatedAt:
  6945. return m.UpdatedAt()
  6946. case contact.FieldStatus:
  6947. return m.Status()
  6948. case contact.FieldDeletedAt:
  6949. return m.DeletedAt()
  6950. case contact.FieldWxWxid:
  6951. return m.WxWxid()
  6952. case contact.FieldType:
  6953. return m.GetType()
  6954. case contact.FieldWxid:
  6955. return m.Wxid()
  6956. case contact.FieldAccount:
  6957. return m.Account()
  6958. case contact.FieldNickname:
  6959. return m.Nickname()
  6960. case contact.FieldMarkname:
  6961. return m.Markname()
  6962. case contact.FieldHeadimg:
  6963. return m.Headimg()
  6964. case contact.FieldSex:
  6965. return m.Sex()
  6966. case contact.FieldStarrole:
  6967. return m.Starrole()
  6968. case contact.FieldDontseeit:
  6969. return m.Dontseeit()
  6970. case contact.FieldDontseeme:
  6971. return m.Dontseeme()
  6972. case contact.FieldLag:
  6973. return m.Lag()
  6974. case contact.FieldGid:
  6975. return m.Gid()
  6976. case contact.FieldGname:
  6977. return m.Gname()
  6978. case contact.FieldV3:
  6979. return m.V3()
  6980. case contact.FieldOrganizationID:
  6981. return m.OrganizationID()
  6982. }
  6983. return nil, false
  6984. }
  6985. // OldField returns the old value of the field from the database. An error is
  6986. // returned if the mutation operation is not UpdateOne, or the query to the
  6987. // database failed.
  6988. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6989. switch name {
  6990. case contact.FieldCreatedAt:
  6991. return m.OldCreatedAt(ctx)
  6992. case contact.FieldUpdatedAt:
  6993. return m.OldUpdatedAt(ctx)
  6994. case contact.FieldStatus:
  6995. return m.OldStatus(ctx)
  6996. case contact.FieldDeletedAt:
  6997. return m.OldDeletedAt(ctx)
  6998. case contact.FieldWxWxid:
  6999. return m.OldWxWxid(ctx)
  7000. case contact.FieldType:
  7001. return m.OldType(ctx)
  7002. case contact.FieldWxid:
  7003. return m.OldWxid(ctx)
  7004. case contact.FieldAccount:
  7005. return m.OldAccount(ctx)
  7006. case contact.FieldNickname:
  7007. return m.OldNickname(ctx)
  7008. case contact.FieldMarkname:
  7009. return m.OldMarkname(ctx)
  7010. case contact.FieldHeadimg:
  7011. return m.OldHeadimg(ctx)
  7012. case contact.FieldSex:
  7013. return m.OldSex(ctx)
  7014. case contact.FieldStarrole:
  7015. return m.OldStarrole(ctx)
  7016. case contact.FieldDontseeit:
  7017. return m.OldDontseeit(ctx)
  7018. case contact.FieldDontseeme:
  7019. return m.OldDontseeme(ctx)
  7020. case contact.FieldLag:
  7021. return m.OldLag(ctx)
  7022. case contact.FieldGid:
  7023. return m.OldGid(ctx)
  7024. case contact.FieldGname:
  7025. return m.OldGname(ctx)
  7026. case contact.FieldV3:
  7027. return m.OldV3(ctx)
  7028. case contact.FieldOrganizationID:
  7029. return m.OldOrganizationID(ctx)
  7030. }
  7031. return nil, fmt.Errorf("unknown Contact field %s", name)
  7032. }
  7033. // SetField sets the value of a field with the given name. It returns an error if
  7034. // the field is not defined in the schema, or if the type mismatched the field
  7035. // type.
  7036. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  7037. switch name {
  7038. case contact.FieldCreatedAt:
  7039. v, ok := value.(time.Time)
  7040. if !ok {
  7041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7042. }
  7043. m.SetCreatedAt(v)
  7044. return nil
  7045. case contact.FieldUpdatedAt:
  7046. v, ok := value.(time.Time)
  7047. if !ok {
  7048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7049. }
  7050. m.SetUpdatedAt(v)
  7051. return nil
  7052. case contact.FieldStatus:
  7053. v, ok := value.(uint8)
  7054. if !ok {
  7055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7056. }
  7057. m.SetStatus(v)
  7058. return nil
  7059. case contact.FieldDeletedAt:
  7060. v, ok := value.(time.Time)
  7061. if !ok {
  7062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7063. }
  7064. m.SetDeletedAt(v)
  7065. return nil
  7066. case contact.FieldWxWxid:
  7067. v, ok := value.(string)
  7068. if !ok {
  7069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7070. }
  7071. m.SetWxWxid(v)
  7072. return nil
  7073. case contact.FieldType:
  7074. v, ok := value.(int)
  7075. if !ok {
  7076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7077. }
  7078. m.SetType(v)
  7079. return nil
  7080. case contact.FieldWxid:
  7081. v, ok := value.(string)
  7082. if !ok {
  7083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7084. }
  7085. m.SetWxid(v)
  7086. return nil
  7087. case contact.FieldAccount:
  7088. v, ok := value.(string)
  7089. if !ok {
  7090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7091. }
  7092. m.SetAccount(v)
  7093. return nil
  7094. case contact.FieldNickname:
  7095. v, ok := value.(string)
  7096. if !ok {
  7097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7098. }
  7099. m.SetNickname(v)
  7100. return nil
  7101. case contact.FieldMarkname:
  7102. v, ok := value.(string)
  7103. if !ok {
  7104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7105. }
  7106. m.SetMarkname(v)
  7107. return nil
  7108. case contact.FieldHeadimg:
  7109. v, ok := value.(string)
  7110. if !ok {
  7111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7112. }
  7113. m.SetHeadimg(v)
  7114. return nil
  7115. case contact.FieldSex:
  7116. v, ok := value.(int)
  7117. if !ok {
  7118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7119. }
  7120. m.SetSex(v)
  7121. return nil
  7122. case contact.FieldStarrole:
  7123. v, ok := value.(string)
  7124. if !ok {
  7125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7126. }
  7127. m.SetStarrole(v)
  7128. return nil
  7129. case contact.FieldDontseeit:
  7130. v, ok := value.(int)
  7131. if !ok {
  7132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7133. }
  7134. m.SetDontseeit(v)
  7135. return nil
  7136. case contact.FieldDontseeme:
  7137. v, ok := value.(int)
  7138. if !ok {
  7139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7140. }
  7141. m.SetDontseeme(v)
  7142. return nil
  7143. case contact.FieldLag:
  7144. v, ok := value.(string)
  7145. if !ok {
  7146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7147. }
  7148. m.SetLag(v)
  7149. return nil
  7150. case contact.FieldGid:
  7151. v, ok := value.(string)
  7152. if !ok {
  7153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7154. }
  7155. m.SetGid(v)
  7156. return nil
  7157. case contact.FieldGname:
  7158. v, ok := value.(string)
  7159. if !ok {
  7160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7161. }
  7162. m.SetGname(v)
  7163. return nil
  7164. case contact.FieldV3:
  7165. v, ok := value.(string)
  7166. if !ok {
  7167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7168. }
  7169. m.SetV3(v)
  7170. return nil
  7171. case contact.FieldOrganizationID:
  7172. v, ok := value.(uint64)
  7173. if !ok {
  7174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7175. }
  7176. m.SetOrganizationID(v)
  7177. return nil
  7178. }
  7179. return fmt.Errorf("unknown Contact field %s", name)
  7180. }
  7181. // AddedFields returns all numeric fields that were incremented/decremented during
  7182. // this mutation.
  7183. func (m *ContactMutation) AddedFields() []string {
  7184. var fields []string
  7185. if m.addstatus != nil {
  7186. fields = append(fields, contact.FieldStatus)
  7187. }
  7188. if m.add_type != nil {
  7189. fields = append(fields, contact.FieldType)
  7190. }
  7191. if m.addsex != nil {
  7192. fields = append(fields, contact.FieldSex)
  7193. }
  7194. if m.adddontseeit != nil {
  7195. fields = append(fields, contact.FieldDontseeit)
  7196. }
  7197. if m.adddontseeme != nil {
  7198. fields = append(fields, contact.FieldDontseeme)
  7199. }
  7200. if m.addorganization_id != nil {
  7201. fields = append(fields, contact.FieldOrganizationID)
  7202. }
  7203. return fields
  7204. }
  7205. // AddedField returns the numeric value that was incremented/decremented on a field
  7206. // with the given name. The second boolean return value indicates that this field
  7207. // was not set, or was not defined in the schema.
  7208. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  7209. switch name {
  7210. case contact.FieldStatus:
  7211. return m.AddedStatus()
  7212. case contact.FieldType:
  7213. return m.AddedType()
  7214. case contact.FieldSex:
  7215. return m.AddedSex()
  7216. case contact.FieldDontseeit:
  7217. return m.AddedDontseeit()
  7218. case contact.FieldDontseeme:
  7219. return m.AddedDontseeme()
  7220. case contact.FieldOrganizationID:
  7221. return m.AddedOrganizationID()
  7222. }
  7223. return nil, false
  7224. }
  7225. // AddField adds the value to the field with the given name. It returns an error if
  7226. // the field is not defined in the schema, or if the type mismatched the field
  7227. // type.
  7228. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  7229. switch name {
  7230. case contact.FieldStatus:
  7231. v, ok := value.(int8)
  7232. if !ok {
  7233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7234. }
  7235. m.AddStatus(v)
  7236. return nil
  7237. case contact.FieldType:
  7238. v, ok := value.(int)
  7239. if !ok {
  7240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7241. }
  7242. m.AddType(v)
  7243. return nil
  7244. case contact.FieldSex:
  7245. v, ok := value.(int)
  7246. if !ok {
  7247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7248. }
  7249. m.AddSex(v)
  7250. return nil
  7251. case contact.FieldDontseeit:
  7252. v, ok := value.(int)
  7253. if !ok {
  7254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7255. }
  7256. m.AddDontseeit(v)
  7257. return nil
  7258. case contact.FieldDontseeme:
  7259. v, ok := value.(int)
  7260. if !ok {
  7261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7262. }
  7263. m.AddDontseeme(v)
  7264. return nil
  7265. case contact.FieldOrganizationID:
  7266. v, ok := value.(int64)
  7267. if !ok {
  7268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7269. }
  7270. m.AddOrganizationID(v)
  7271. return nil
  7272. }
  7273. return fmt.Errorf("unknown Contact numeric field %s", name)
  7274. }
  7275. // ClearedFields returns all nullable fields that were cleared during this
  7276. // mutation.
  7277. func (m *ContactMutation) ClearedFields() []string {
  7278. var fields []string
  7279. if m.FieldCleared(contact.FieldStatus) {
  7280. fields = append(fields, contact.FieldStatus)
  7281. }
  7282. if m.FieldCleared(contact.FieldDeletedAt) {
  7283. fields = append(fields, contact.FieldDeletedAt)
  7284. }
  7285. if m.FieldCleared(contact.FieldWxWxid) {
  7286. fields = append(fields, contact.FieldWxWxid)
  7287. }
  7288. if m.FieldCleared(contact.FieldType) {
  7289. fields = append(fields, contact.FieldType)
  7290. }
  7291. if m.FieldCleared(contact.FieldOrganizationID) {
  7292. fields = append(fields, contact.FieldOrganizationID)
  7293. }
  7294. return fields
  7295. }
  7296. // FieldCleared returns a boolean indicating if a field with the given name was
  7297. // cleared in this mutation.
  7298. func (m *ContactMutation) FieldCleared(name string) bool {
  7299. _, ok := m.clearedFields[name]
  7300. return ok
  7301. }
  7302. // ClearField clears the value of the field with the given name. It returns an
  7303. // error if the field is not defined in the schema.
  7304. func (m *ContactMutation) ClearField(name string) error {
  7305. switch name {
  7306. case contact.FieldStatus:
  7307. m.ClearStatus()
  7308. return nil
  7309. case contact.FieldDeletedAt:
  7310. m.ClearDeletedAt()
  7311. return nil
  7312. case contact.FieldWxWxid:
  7313. m.ClearWxWxid()
  7314. return nil
  7315. case contact.FieldType:
  7316. m.ClearType()
  7317. return nil
  7318. case contact.FieldOrganizationID:
  7319. m.ClearOrganizationID()
  7320. return nil
  7321. }
  7322. return fmt.Errorf("unknown Contact nullable field %s", name)
  7323. }
  7324. // ResetField resets all changes in the mutation for the field with the given name.
  7325. // It returns an error if the field is not defined in the schema.
  7326. func (m *ContactMutation) ResetField(name string) error {
  7327. switch name {
  7328. case contact.FieldCreatedAt:
  7329. m.ResetCreatedAt()
  7330. return nil
  7331. case contact.FieldUpdatedAt:
  7332. m.ResetUpdatedAt()
  7333. return nil
  7334. case contact.FieldStatus:
  7335. m.ResetStatus()
  7336. return nil
  7337. case contact.FieldDeletedAt:
  7338. m.ResetDeletedAt()
  7339. return nil
  7340. case contact.FieldWxWxid:
  7341. m.ResetWxWxid()
  7342. return nil
  7343. case contact.FieldType:
  7344. m.ResetType()
  7345. return nil
  7346. case contact.FieldWxid:
  7347. m.ResetWxid()
  7348. return nil
  7349. case contact.FieldAccount:
  7350. m.ResetAccount()
  7351. return nil
  7352. case contact.FieldNickname:
  7353. m.ResetNickname()
  7354. return nil
  7355. case contact.FieldMarkname:
  7356. m.ResetMarkname()
  7357. return nil
  7358. case contact.FieldHeadimg:
  7359. m.ResetHeadimg()
  7360. return nil
  7361. case contact.FieldSex:
  7362. m.ResetSex()
  7363. return nil
  7364. case contact.FieldStarrole:
  7365. m.ResetStarrole()
  7366. return nil
  7367. case contact.FieldDontseeit:
  7368. m.ResetDontseeit()
  7369. return nil
  7370. case contact.FieldDontseeme:
  7371. m.ResetDontseeme()
  7372. return nil
  7373. case contact.FieldLag:
  7374. m.ResetLag()
  7375. return nil
  7376. case contact.FieldGid:
  7377. m.ResetGid()
  7378. return nil
  7379. case contact.FieldGname:
  7380. m.ResetGname()
  7381. return nil
  7382. case contact.FieldV3:
  7383. m.ResetV3()
  7384. return nil
  7385. case contact.FieldOrganizationID:
  7386. m.ResetOrganizationID()
  7387. return nil
  7388. }
  7389. return fmt.Errorf("unknown Contact field %s", name)
  7390. }
  7391. // AddedEdges returns all edge names that were set/added in this mutation.
  7392. func (m *ContactMutation) AddedEdges() []string {
  7393. edges := make([]string, 0, 2)
  7394. if m.contact_relationships != nil {
  7395. edges = append(edges, contact.EdgeContactRelationships)
  7396. }
  7397. if m.contact_messages != nil {
  7398. edges = append(edges, contact.EdgeContactMessages)
  7399. }
  7400. return edges
  7401. }
  7402. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7403. // name in this mutation.
  7404. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  7405. switch name {
  7406. case contact.EdgeContactRelationships:
  7407. ids := make([]ent.Value, 0, len(m.contact_relationships))
  7408. for id := range m.contact_relationships {
  7409. ids = append(ids, id)
  7410. }
  7411. return ids
  7412. case contact.EdgeContactMessages:
  7413. ids := make([]ent.Value, 0, len(m.contact_messages))
  7414. for id := range m.contact_messages {
  7415. ids = append(ids, id)
  7416. }
  7417. return ids
  7418. }
  7419. return nil
  7420. }
  7421. // RemovedEdges returns all edge names that were removed in this mutation.
  7422. func (m *ContactMutation) RemovedEdges() []string {
  7423. edges := make([]string, 0, 2)
  7424. if m.removedcontact_relationships != nil {
  7425. edges = append(edges, contact.EdgeContactRelationships)
  7426. }
  7427. if m.removedcontact_messages != nil {
  7428. edges = append(edges, contact.EdgeContactMessages)
  7429. }
  7430. return edges
  7431. }
  7432. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7433. // the given name in this mutation.
  7434. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  7435. switch name {
  7436. case contact.EdgeContactRelationships:
  7437. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  7438. for id := range m.removedcontact_relationships {
  7439. ids = append(ids, id)
  7440. }
  7441. return ids
  7442. case contact.EdgeContactMessages:
  7443. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  7444. for id := range m.removedcontact_messages {
  7445. ids = append(ids, id)
  7446. }
  7447. return ids
  7448. }
  7449. return nil
  7450. }
  7451. // ClearedEdges returns all edge names that were cleared in this mutation.
  7452. func (m *ContactMutation) ClearedEdges() []string {
  7453. edges := make([]string, 0, 2)
  7454. if m.clearedcontact_relationships {
  7455. edges = append(edges, contact.EdgeContactRelationships)
  7456. }
  7457. if m.clearedcontact_messages {
  7458. edges = append(edges, contact.EdgeContactMessages)
  7459. }
  7460. return edges
  7461. }
  7462. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7463. // was cleared in this mutation.
  7464. func (m *ContactMutation) EdgeCleared(name string) bool {
  7465. switch name {
  7466. case contact.EdgeContactRelationships:
  7467. return m.clearedcontact_relationships
  7468. case contact.EdgeContactMessages:
  7469. return m.clearedcontact_messages
  7470. }
  7471. return false
  7472. }
  7473. // ClearEdge clears the value of the edge with the given name. It returns an error
  7474. // if that edge is not defined in the schema.
  7475. func (m *ContactMutation) ClearEdge(name string) error {
  7476. switch name {
  7477. }
  7478. return fmt.Errorf("unknown Contact unique edge %s", name)
  7479. }
  7480. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7481. // It returns an error if the edge is not defined in the schema.
  7482. func (m *ContactMutation) ResetEdge(name string) error {
  7483. switch name {
  7484. case contact.EdgeContactRelationships:
  7485. m.ResetContactRelationships()
  7486. return nil
  7487. case contact.EdgeContactMessages:
  7488. m.ResetContactMessages()
  7489. return nil
  7490. }
  7491. return fmt.Errorf("unknown Contact edge %s", name)
  7492. }
  7493. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  7494. type EmployeeMutation struct {
  7495. config
  7496. op Op
  7497. typ string
  7498. id *uint64
  7499. created_at *time.Time
  7500. updated_at *time.Time
  7501. deleted_at *time.Time
  7502. title *string
  7503. avatar *string
  7504. tags *string
  7505. hire_count *int
  7506. addhire_count *int
  7507. service_count *int
  7508. addservice_count *int
  7509. achievement_count *int
  7510. addachievement_count *int
  7511. intro *string
  7512. estimate *string
  7513. skill *string
  7514. ability_type *string
  7515. scene *string
  7516. switch_in *string
  7517. video_url *string
  7518. organization_id *uint64
  7519. addorganization_id *int64
  7520. category_id *uint64
  7521. addcategory_id *int64
  7522. api_base *string
  7523. api_key *string
  7524. ai_info *string
  7525. is_vip *int
  7526. addis_vip *int
  7527. clearedFields map[string]struct{}
  7528. em_work_experiences map[uint64]struct{}
  7529. removedem_work_experiences map[uint64]struct{}
  7530. clearedem_work_experiences bool
  7531. em_tutorial map[uint64]struct{}
  7532. removedem_tutorial map[uint64]struct{}
  7533. clearedem_tutorial bool
  7534. done bool
  7535. oldValue func(context.Context) (*Employee, error)
  7536. predicates []predicate.Employee
  7537. }
  7538. var _ ent.Mutation = (*EmployeeMutation)(nil)
  7539. // employeeOption allows management of the mutation configuration using functional options.
  7540. type employeeOption func(*EmployeeMutation)
  7541. // newEmployeeMutation creates new mutation for the Employee entity.
  7542. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  7543. m := &EmployeeMutation{
  7544. config: c,
  7545. op: op,
  7546. typ: TypeEmployee,
  7547. clearedFields: make(map[string]struct{}),
  7548. }
  7549. for _, opt := range opts {
  7550. opt(m)
  7551. }
  7552. return m
  7553. }
  7554. // withEmployeeID sets the ID field of the mutation.
  7555. func withEmployeeID(id uint64) employeeOption {
  7556. return func(m *EmployeeMutation) {
  7557. var (
  7558. err error
  7559. once sync.Once
  7560. value *Employee
  7561. )
  7562. m.oldValue = func(ctx context.Context) (*Employee, error) {
  7563. once.Do(func() {
  7564. if m.done {
  7565. err = errors.New("querying old values post mutation is not allowed")
  7566. } else {
  7567. value, err = m.Client().Employee.Get(ctx, id)
  7568. }
  7569. })
  7570. return value, err
  7571. }
  7572. m.id = &id
  7573. }
  7574. }
  7575. // withEmployee sets the old Employee of the mutation.
  7576. func withEmployee(node *Employee) employeeOption {
  7577. return func(m *EmployeeMutation) {
  7578. m.oldValue = func(context.Context) (*Employee, error) {
  7579. return node, nil
  7580. }
  7581. m.id = &node.ID
  7582. }
  7583. }
  7584. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7585. // executed in a transaction (ent.Tx), a transactional client is returned.
  7586. func (m EmployeeMutation) Client() *Client {
  7587. client := &Client{config: m.config}
  7588. client.init()
  7589. return client
  7590. }
  7591. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7592. // it returns an error otherwise.
  7593. func (m EmployeeMutation) Tx() (*Tx, error) {
  7594. if _, ok := m.driver.(*txDriver); !ok {
  7595. return nil, errors.New("ent: mutation is not running in a transaction")
  7596. }
  7597. tx := &Tx{config: m.config}
  7598. tx.init()
  7599. return tx, nil
  7600. }
  7601. // SetID sets the value of the id field. Note that this
  7602. // operation is only accepted on creation of Employee entities.
  7603. func (m *EmployeeMutation) SetID(id uint64) {
  7604. m.id = &id
  7605. }
  7606. // ID returns the ID value in the mutation. Note that the ID is only available
  7607. // if it was provided to the builder or after it was returned from the database.
  7608. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  7609. if m.id == nil {
  7610. return
  7611. }
  7612. return *m.id, true
  7613. }
  7614. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7615. // That means, if the mutation is applied within a transaction with an isolation level such
  7616. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7617. // or updated by the mutation.
  7618. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  7619. switch {
  7620. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7621. id, exists := m.ID()
  7622. if exists {
  7623. return []uint64{id}, nil
  7624. }
  7625. fallthrough
  7626. case m.op.Is(OpUpdate | OpDelete):
  7627. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  7628. default:
  7629. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7630. }
  7631. }
  7632. // SetCreatedAt sets the "created_at" field.
  7633. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  7634. m.created_at = &t
  7635. }
  7636. // CreatedAt returns the value of the "created_at" field in the mutation.
  7637. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  7638. v := m.created_at
  7639. if v == nil {
  7640. return
  7641. }
  7642. return *v, true
  7643. }
  7644. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  7645. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7647. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7648. if !m.op.Is(OpUpdateOne) {
  7649. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7650. }
  7651. if m.id == nil || m.oldValue == nil {
  7652. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7653. }
  7654. oldValue, err := m.oldValue(ctx)
  7655. if err != nil {
  7656. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7657. }
  7658. return oldValue.CreatedAt, nil
  7659. }
  7660. // ResetCreatedAt resets all changes to the "created_at" field.
  7661. func (m *EmployeeMutation) ResetCreatedAt() {
  7662. m.created_at = nil
  7663. }
  7664. // SetUpdatedAt sets the "updated_at" field.
  7665. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  7666. m.updated_at = &t
  7667. }
  7668. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7669. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  7670. v := m.updated_at
  7671. if v == nil {
  7672. return
  7673. }
  7674. return *v, true
  7675. }
  7676. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  7677. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7679. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7680. if !m.op.Is(OpUpdateOne) {
  7681. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7682. }
  7683. if m.id == nil || m.oldValue == nil {
  7684. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7685. }
  7686. oldValue, err := m.oldValue(ctx)
  7687. if err != nil {
  7688. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7689. }
  7690. return oldValue.UpdatedAt, nil
  7691. }
  7692. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7693. func (m *EmployeeMutation) ResetUpdatedAt() {
  7694. m.updated_at = nil
  7695. }
  7696. // SetDeletedAt sets the "deleted_at" field.
  7697. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  7698. m.deleted_at = &t
  7699. }
  7700. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7701. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  7702. v := m.deleted_at
  7703. if v == nil {
  7704. return
  7705. }
  7706. return *v, true
  7707. }
  7708. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  7709. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7711. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7712. if !m.op.Is(OpUpdateOne) {
  7713. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7714. }
  7715. if m.id == nil || m.oldValue == nil {
  7716. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7717. }
  7718. oldValue, err := m.oldValue(ctx)
  7719. if err != nil {
  7720. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7721. }
  7722. return oldValue.DeletedAt, nil
  7723. }
  7724. // ClearDeletedAt clears the value of the "deleted_at" field.
  7725. func (m *EmployeeMutation) ClearDeletedAt() {
  7726. m.deleted_at = nil
  7727. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  7728. }
  7729. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7730. func (m *EmployeeMutation) DeletedAtCleared() bool {
  7731. _, ok := m.clearedFields[employee.FieldDeletedAt]
  7732. return ok
  7733. }
  7734. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7735. func (m *EmployeeMutation) ResetDeletedAt() {
  7736. m.deleted_at = nil
  7737. delete(m.clearedFields, employee.FieldDeletedAt)
  7738. }
  7739. // SetTitle sets the "title" field.
  7740. func (m *EmployeeMutation) SetTitle(s string) {
  7741. m.title = &s
  7742. }
  7743. // Title returns the value of the "title" field in the mutation.
  7744. func (m *EmployeeMutation) Title() (r string, exists bool) {
  7745. v := m.title
  7746. if v == nil {
  7747. return
  7748. }
  7749. return *v, true
  7750. }
  7751. // OldTitle returns the old "title" field's value of the Employee entity.
  7752. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7754. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  7755. if !m.op.Is(OpUpdateOne) {
  7756. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  7757. }
  7758. if m.id == nil || m.oldValue == nil {
  7759. return v, errors.New("OldTitle requires an ID field in the mutation")
  7760. }
  7761. oldValue, err := m.oldValue(ctx)
  7762. if err != nil {
  7763. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  7764. }
  7765. return oldValue.Title, nil
  7766. }
  7767. // ResetTitle resets all changes to the "title" field.
  7768. func (m *EmployeeMutation) ResetTitle() {
  7769. m.title = nil
  7770. }
  7771. // SetAvatar sets the "avatar" field.
  7772. func (m *EmployeeMutation) SetAvatar(s string) {
  7773. m.avatar = &s
  7774. }
  7775. // Avatar returns the value of the "avatar" field in the mutation.
  7776. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  7777. v := m.avatar
  7778. if v == nil {
  7779. return
  7780. }
  7781. return *v, true
  7782. }
  7783. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  7784. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7786. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  7787. if !m.op.Is(OpUpdateOne) {
  7788. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  7789. }
  7790. if m.id == nil || m.oldValue == nil {
  7791. return v, errors.New("OldAvatar requires an ID field in the mutation")
  7792. }
  7793. oldValue, err := m.oldValue(ctx)
  7794. if err != nil {
  7795. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  7796. }
  7797. return oldValue.Avatar, nil
  7798. }
  7799. // ResetAvatar resets all changes to the "avatar" field.
  7800. func (m *EmployeeMutation) ResetAvatar() {
  7801. m.avatar = nil
  7802. }
  7803. // SetTags sets the "tags" field.
  7804. func (m *EmployeeMutation) SetTags(s string) {
  7805. m.tags = &s
  7806. }
  7807. // Tags returns the value of the "tags" field in the mutation.
  7808. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  7809. v := m.tags
  7810. if v == nil {
  7811. return
  7812. }
  7813. return *v, true
  7814. }
  7815. // OldTags returns the old "tags" field's value of the Employee entity.
  7816. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7818. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  7819. if !m.op.Is(OpUpdateOne) {
  7820. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  7821. }
  7822. if m.id == nil || m.oldValue == nil {
  7823. return v, errors.New("OldTags requires an ID field in the mutation")
  7824. }
  7825. oldValue, err := m.oldValue(ctx)
  7826. if err != nil {
  7827. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  7828. }
  7829. return oldValue.Tags, nil
  7830. }
  7831. // ResetTags resets all changes to the "tags" field.
  7832. func (m *EmployeeMutation) ResetTags() {
  7833. m.tags = nil
  7834. }
  7835. // SetHireCount sets the "hire_count" field.
  7836. func (m *EmployeeMutation) SetHireCount(i int) {
  7837. m.hire_count = &i
  7838. m.addhire_count = nil
  7839. }
  7840. // HireCount returns the value of the "hire_count" field in the mutation.
  7841. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  7842. v := m.hire_count
  7843. if v == nil {
  7844. return
  7845. }
  7846. return *v, true
  7847. }
  7848. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  7849. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7851. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  7852. if !m.op.Is(OpUpdateOne) {
  7853. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  7854. }
  7855. if m.id == nil || m.oldValue == nil {
  7856. return v, errors.New("OldHireCount requires an ID field in the mutation")
  7857. }
  7858. oldValue, err := m.oldValue(ctx)
  7859. if err != nil {
  7860. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  7861. }
  7862. return oldValue.HireCount, nil
  7863. }
  7864. // AddHireCount adds i to the "hire_count" field.
  7865. func (m *EmployeeMutation) AddHireCount(i int) {
  7866. if m.addhire_count != nil {
  7867. *m.addhire_count += i
  7868. } else {
  7869. m.addhire_count = &i
  7870. }
  7871. }
  7872. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  7873. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  7874. v := m.addhire_count
  7875. if v == nil {
  7876. return
  7877. }
  7878. return *v, true
  7879. }
  7880. // ResetHireCount resets all changes to the "hire_count" field.
  7881. func (m *EmployeeMutation) ResetHireCount() {
  7882. m.hire_count = nil
  7883. m.addhire_count = nil
  7884. }
  7885. // SetServiceCount sets the "service_count" field.
  7886. func (m *EmployeeMutation) SetServiceCount(i int) {
  7887. m.service_count = &i
  7888. m.addservice_count = nil
  7889. }
  7890. // ServiceCount returns the value of the "service_count" field in the mutation.
  7891. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  7892. v := m.service_count
  7893. if v == nil {
  7894. return
  7895. }
  7896. return *v, true
  7897. }
  7898. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  7899. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7901. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  7902. if !m.op.Is(OpUpdateOne) {
  7903. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  7904. }
  7905. if m.id == nil || m.oldValue == nil {
  7906. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  7907. }
  7908. oldValue, err := m.oldValue(ctx)
  7909. if err != nil {
  7910. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  7911. }
  7912. return oldValue.ServiceCount, nil
  7913. }
  7914. // AddServiceCount adds i to the "service_count" field.
  7915. func (m *EmployeeMutation) AddServiceCount(i int) {
  7916. if m.addservice_count != nil {
  7917. *m.addservice_count += i
  7918. } else {
  7919. m.addservice_count = &i
  7920. }
  7921. }
  7922. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  7923. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  7924. v := m.addservice_count
  7925. if v == nil {
  7926. return
  7927. }
  7928. return *v, true
  7929. }
  7930. // ResetServiceCount resets all changes to the "service_count" field.
  7931. func (m *EmployeeMutation) ResetServiceCount() {
  7932. m.service_count = nil
  7933. m.addservice_count = nil
  7934. }
  7935. // SetAchievementCount sets the "achievement_count" field.
  7936. func (m *EmployeeMutation) SetAchievementCount(i int) {
  7937. m.achievement_count = &i
  7938. m.addachievement_count = nil
  7939. }
  7940. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  7941. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  7942. v := m.achievement_count
  7943. if v == nil {
  7944. return
  7945. }
  7946. return *v, true
  7947. }
  7948. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  7949. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7951. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  7952. if !m.op.Is(OpUpdateOne) {
  7953. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  7954. }
  7955. if m.id == nil || m.oldValue == nil {
  7956. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  7957. }
  7958. oldValue, err := m.oldValue(ctx)
  7959. if err != nil {
  7960. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  7961. }
  7962. return oldValue.AchievementCount, nil
  7963. }
  7964. // AddAchievementCount adds i to the "achievement_count" field.
  7965. func (m *EmployeeMutation) AddAchievementCount(i int) {
  7966. if m.addachievement_count != nil {
  7967. *m.addachievement_count += i
  7968. } else {
  7969. m.addachievement_count = &i
  7970. }
  7971. }
  7972. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  7973. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  7974. v := m.addachievement_count
  7975. if v == nil {
  7976. return
  7977. }
  7978. return *v, true
  7979. }
  7980. // ResetAchievementCount resets all changes to the "achievement_count" field.
  7981. func (m *EmployeeMutation) ResetAchievementCount() {
  7982. m.achievement_count = nil
  7983. m.addachievement_count = nil
  7984. }
  7985. // SetIntro sets the "intro" field.
  7986. func (m *EmployeeMutation) SetIntro(s string) {
  7987. m.intro = &s
  7988. }
  7989. // Intro returns the value of the "intro" field in the mutation.
  7990. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  7991. v := m.intro
  7992. if v == nil {
  7993. return
  7994. }
  7995. return *v, true
  7996. }
  7997. // OldIntro returns the old "intro" field's value of the Employee entity.
  7998. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8000. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  8001. if !m.op.Is(OpUpdateOne) {
  8002. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  8003. }
  8004. if m.id == nil || m.oldValue == nil {
  8005. return v, errors.New("OldIntro requires an ID field in the mutation")
  8006. }
  8007. oldValue, err := m.oldValue(ctx)
  8008. if err != nil {
  8009. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  8010. }
  8011. return oldValue.Intro, nil
  8012. }
  8013. // ResetIntro resets all changes to the "intro" field.
  8014. func (m *EmployeeMutation) ResetIntro() {
  8015. m.intro = nil
  8016. }
  8017. // SetEstimate sets the "estimate" field.
  8018. func (m *EmployeeMutation) SetEstimate(s string) {
  8019. m.estimate = &s
  8020. }
  8021. // Estimate returns the value of the "estimate" field in the mutation.
  8022. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  8023. v := m.estimate
  8024. if v == nil {
  8025. return
  8026. }
  8027. return *v, true
  8028. }
  8029. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  8030. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8032. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  8033. if !m.op.Is(OpUpdateOne) {
  8034. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  8035. }
  8036. if m.id == nil || m.oldValue == nil {
  8037. return v, errors.New("OldEstimate requires an ID field in the mutation")
  8038. }
  8039. oldValue, err := m.oldValue(ctx)
  8040. if err != nil {
  8041. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  8042. }
  8043. return oldValue.Estimate, nil
  8044. }
  8045. // ResetEstimate resets all changes to the "estimate" field.
  8046. func (m *EmployeeMutation) ResetEstimate() {
  8047. m.estimate = nil
  8048. }
  8049. // SetSkill sets the "skill" field.
  8050. func (m *EmployeeMutation) SetSkill(s string) {
  8051. m.skill = &s
  8052. }
  8053. // Skill returns the value of the "skill" field in the mutation.
  8054. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  8055. v := m.skill
  8056. if v == nil {
  8057. return
  8058. }
  8059. return *v, true
  8060. }
  8061. // OldSkill returns the old "skill" field's value of the Employee entity.
  8062. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8064. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  8065. if !m.op.Is(OpUpdateOne) {
  8066. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  8067. }
  8068. if m.id == nil || m.oldValue == nil {
  8069. return v, errors.New("OldSkill requires an ID field in the mutation")
  8070. }
  8071. oldValue, err := m.oldValue(ctx)
  8072. if err != nil {
  8073. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  8074. }
  8075. return oldValue.Skill, nil
  8076. }
  8077. // ResetSkill resets all changes to the "skill" field.
  8078. func (m *EmployeeMutation) ResetSkill() {
  8079. m.skill = nil
  8080. }
  8081. // SetAbilityType sets the "ability_type" field.
  8082. func (m *EmployeeMutation) SetAbilityType(s string) {
  8083. m.ability_type = &s
  8084. }
  8085. // AbilityType returns the value of the "ability_type" field in the mutation.
  8086. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  8087. v := m.ability_type
  8088. if v == nil {
  8089. return
  8090. }
  8091. return *v, true
  8092. }
  8093. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  8094. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8096. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  8097. if !m.op.Is(OpUpdateOne) {
  8098. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  8099. }
  8100. if m.id == nil || m.oldValue == nil {
  8101. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  8102. }
  8103. oldValue, err := m.oldValue(ctx)
  8104. if err != nil {
  8105. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  8106. }
  8107. return oldValue.AbilityType, nil
  8108. }
  8109. // ResetAbilityType resets all changes to the "ability_type" field.
  8110. func (m *EmployeeMutation) ResetAbilityType() {
  8111. m.ability_type = nil
  8112. }
  8113. // SetScene sets the "scene" field.
  8114. func (m *EmployeeMutation) SetScene(s string) {
  8115. m.scene = &s
  8116. }
  8117. // Scene returns the value of the "scene" field in the mutation.
  8118. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  8119. v := m.scene
  8120. if v == nil {
  8121. return
  8122. }
  8123. return *v, true
  8124. }
  8125. // OldScene returns the old "scene" field's value of the Employee entity.
  8126. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8128. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  8129. if !m.op.Is(OpUpdateOne) {
  8130. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  8131. }
  8132. if m.id == nil || m.oldValue == nil {
  8133. return v, errors.New("OldScene requires an ID field in the mutation")
  8134. }
  8135. oldValue, err := m.oldValue(ctx)
  8136. if err != nil {
  8137. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  8138. }
  8139. return oldValue.Scene, nil
  8140. }
  8141. // ResetScene resets all changes to the "scene" field.
  8142. func (m *EmployeeMutation) ResetScene() {
  8143. m.scene = nil
  8144. }
  8145. // SetSwitchIn sets the "switch_in" field.
  8146. func (m *EmployeeMutation) SetSwitchIn(s string) {
  8147. m.switch_in = &s
  8148. }
  8149. // SwitchIn returns the value of the "switch_in" field in the mutation.
  8150. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  8151. v := m.switch_in
  8152. if v == nil {
  8153. return
  8154. }
  8155. return *v, true
  8156. }
  8157. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  8158. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8160. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  8161. if !m.op.Is(OpUpdateOne) {
  8162. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  8163. }
  8164. if m.id == nil || m.oldValue == nil {
  8165. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  8166. }
  8167. oldValue, err := m.oldValue(ctx)
  8168. if err != nil {
  8169. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  8170. }
  8171. return oldValue.SwitchIn, nil
  8172. }
  8173. // ResetSwitchIn resets all changes to the "switch_in" field.
  8174. func (m *EmployeeMutation) ResetSwitchIn() {
  8175. m.switch_in = nil
  8176. }
  8177. // SetVideoURL sets the "video_url" field.
  8178. func (m *EmployeeMutation) SetVideoURL(s string) {
  8179. m.video_url = &s
  8180. }
  8181. // VideoURL returns the value of the "video_url" field in the mutation.
  8182. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  8183. v := m.video_url
  8184. if v == nil {
  8185. return
  8186. }
  8187. return *v, true
  8188. }
  8189. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  8190. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8192. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  8193. if !m.op.Is(OpUpdateOne) {
  8194. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  8195. }
  8196. if m.id == nil || m.oldValue == nil {
  8197. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  8198. }
  8199. oldValue, err := m.oldValue(ctx)
  8200. if err != nil {
  8201. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  8202. }
  8203. return oldValue.VideoURL, nil
  8204. }
  8205. // ResetVideoURL resets all changes to the "video_url" field.
  8206. func (m *EmployeeMutation) ResetVideoURL() {
  8207. m.video_url = nil
  8208. }
  8209. // SetOrganizationID sets the "organization_id" field.
  8210. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  8211. m.organization_id = &u
  8212. m.addorganization_id = nil
  8213. }
  8214. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8215. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  8216. v := m.organization_id
  8217. if v == nil {
  8218. return
  8219. }
  8220. return *v, true
  8221. }
  8222. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  8223. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8225. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8226. if !m.op.Is(OpUpdateOne) {
  8227. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8228. }
  8229. if m.id == nil || m.oldValue == nil {
  8230. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8231. }
  8232. oldValue, err := m.oldValue(ctx)
  8233. if err != nil {
  8234. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8235. }
  8236. return oldValue.OrganizationID, nil
  8237. }
  8238. // AddOrganizationID adds u to the "organization_id" field.
  8239. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  8240. if m.addorganization_id != nil {
  8241. *m.addorganization_id += u
  8242. } else {
  8243. m.addorganization_id = &u
  8244. }
  8245. }
  8246. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8247. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  8248. v := m.addorganization_id
  8249. if v == nil {
  8250. return
  8251. }
  8252. return *v, true
  8253. }
  8254. // ResetOrganizationID resets all changes to the "organization_id" field.
  8255. func (m *EmployeeMutation) ResetOrganizationID() {
  8256. m.organization_id = nil
  8257. m.addorganization_id = nil
  8258. }
  8259. // SetCategoryID sets the "category_id" field.
  8260. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  8261. m.category_id = &u
  8262. m.addcategory_id = nil
  8263. }
  8264. // CategoryID returns the value of the "category_id" field in the mutation.
  8265. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  8266. v := m.category_id
  8267. if v == nil {
  8268. return
  8269. }
  8270. return *v, true
  8271. }
  8272. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  8273. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8275. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  8276. if !m.op.Is(OpUpdateOne) {
  8277. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  8278. }
  8279. if m.id == nil || m.oldValue == nil {
  8280. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  8281. }
  8282. oldValue, err := m.oldValue(ctx)
  8283. if err != nil {
  8284. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  8285. }
  8286. return oldValue.CategoryID, nil
  8287. }
  8288. // AddCategoryID adds u to the "category_id" field.
  8289. func (m *EmployeeMutation) AddCategoryID(u int64) {
  8290. if m.addcategory_id != nil {
  8291. *m.addcategory_id += u
  8292. } else {
  8293. m.addcategory_id = &u
  8294. }
  8295. }
  8296. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  8297. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  8298. v := m.addcategory_id
  8299. if v == nil {
  8300. return
  8301. }
  8302. return *v, true
  8303. }
  8304. // ResetCategoryID resets all changes to the "category_id" field.
  8305. func (m *EmployeeMutation) ResetCategoryID() {
  8306. m.category_id = nil
  8307. m.addcategory_id = nil
  8308. }
  8309. // SetAPIBase sets the "api_base" field.
  8310. func (m *EmployeeMutation) SetAPIBase(s string) {
  8311. m.api_base = &s
  8312. }
  8313. // APIBase returns the value of the "api_base" field in the mutation.
  8314. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  8315. v := m.api_base
  8316. if v == nil {
  8317. return
  8318. }
  8319. return *v, true
  8320. }
  8321. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  8322. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8324. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  8325. if !m.op.Is(OpUpdateOne) {
  8326. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  8327. }
  8328. if m.id == nil || m.oldValue == nil {
  8329. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  8330. }
  8331. oldValue, err := m.oldValue(ctx)
  8332. if err != nil {
  8333. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  8334. }
  8335. return oldValue.APIBase, nil
  8336. }
  8337. // ResetAPIBase resets all changes to the "api_base" field.
  8338. func (m *EmployeeMutation) ResetAPIBase() {
  8339. m.api_base = nil
  8340. }
  8341. // SetAPIKey sets the "api_key" field.
  8342. func (m *EmployeeMutation) SetAPIKey(s string) {
  8343. m.api_key = &s
  8344. }
  8345. // APIKey returns the value of the "api_key" field in the mutation.
  8346. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  8347. v := m.api_key
  8348. if v == nil {
  8349. return
  8350. }
  8351. return *v, true
  8352. }
  8353. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  8354. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8356. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  8357. if !m.op.Is(OpUpdateOne) {
  8358. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  8359. }
  8360. if m.id == nil || m.oldValue == nil {
  8361. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  8362. }
  8363. oldValue, err := m.oldValue(ctx)
  8364. if err != nil {
  8365. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  8366. }
  8367. return oldValue.APIKey, nil
  8368. }
  8369. // ResetAPIKey resets all changes to the "api_key" field.
  8370. func (m *EmployeeMutation) ResetAPIKey() {
  8371. m.api_key = nil
  8372. }
  8373. // SetAiInfo sets the "ai_info" field.
  8374. func (m *EmployeeMutation) SetAiInfo(s string) {
  8375. m.ai_info = &s
  8376. }
  8377. // AiInfo returns the value of the "ai_info" field in the mutation.
  8378. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  8379. v := m.ai_info
  8380. if v == nil {
  8381. return
  8382. }
  8383. return *v, true
  8384. }
  8385. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  8386. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8388. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  8389. if !m.op.Is(OpUpdateOne) {
  8390. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  8391. }
  8392. if m.id == nil || m.oldValue == nil {
  8393. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  8394. }
  8395. oldValue, err := m.oldValue(ctx)
  8396. if err != nil {
  8397. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  8398. }
  8399. return oldValue.AiInfo, nil
  8400. }
  8401. // ClearAiInfo clears the value of the "ai_info" field.
  8402. func (m *EmployeeMutation) ClearAiInfo() {
  8403. m.ai_info = nil
  8404. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  8405. }
  8406. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  8407. func (m *EmployeeMutation) AiInfoCleared() bool {
  8408. _, ok := m.clearedFields[employee.FieldAiInfo]
  8409. return ok
  8410. }
  8411. // ResetAiInfo resets all changes to the "ai_info" field.
  8412. func (m *EmployeeMutation) ResetAiInfo() {
  8413. m.ai_info = nil
  8414. delete(m.clearedFields, employee.FieldAiInfo)
  8415. }
  8416. // SetIsVip sets the "is_vip" field.
  8417. func (m *EmployeeMutation) SetIsVip(i int) {
  8418. m.is_vip = &i
  8419. m.addis_vip = nil
  8420. }
  8421. // IsVip returns the value of the "is_vip" field in the mutation.
  8422. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  8423. v := m.is_vip
  8424. if v == nil {
  8425. return
  8426. }
  8427. return *v, true
  8428. }
  8429. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  8430. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8432. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  8433. if !m.op.Is(OpUpdateOne) {
  8434. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  8435. }
  8436. if m.id == nil || m.oldValue == nil {
  8437. return v, errors.New("OldIsVip requires an ID field in the mutation")
  8438. }
  8439. oldValue, err := m.oldValue(ctx)
  8440. if err != nil {
  8441. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  8442. }
  8443. return oldValue.IsVip, nil
  8444. }
  8445. // AddIsVip adds i to the "is_vip" field.
  8446. func (m *EmployeeMutation) AddIsVip(i int) {
  8447. if m.addis_vip != nil {
  8448. *m.addis_vip += i
  8449. } else {
  8450. m.addis_vip = &i
  8451. }
  8452. }
  8453. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  8454. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  8455. v := m.addis_vip
  8456. if v == nil {
  8457. return
  8458. }
  8459. return *v, true
  8460. }
  8461. // ResetIsVip resets all changes to the "is_vip" field.
  8462. func (m *EmployeeMutation) ResetIsVip() {
  8463. m.is_vip = nil
  8464. m.addis_vip = nil
  8465. }
  8466. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  8467. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  8468. if m.em_work_experiences == nil {
  8469. m.em_work_experiences = make(map[uint64]struct{})
  8470. }
  8471. for i := range ids {
  8472. m.em_work_experiences[ids[i]] = struct{}{}
  8473. }
  8474. }
  8475. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  8476. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  8477. m.clearedem_work_experiences = true
  8478. }
  8479. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  8480. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  8481. return m.clearedem_work_experiences
  8482. }
  8483. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  8484. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  8485. if m.removedem_work_experiences == nil {
  8486. m.removedem_work_experiences = make(map[uint64]struct{})
  8487. }
  8488. for i := range ids {
  8489. delete(m.em_work_experiences, ids[i])
  8490. m.removedem_work_experiences[ids[i]] = struct{}{}
  8491. }
  8492. }
  8493. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  8494. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  8495. for id := range m.removedem_work_experiences {
  8496. ids = append(ids, id)
  8497. }
  8498. return
  8499. }
  8500. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  8501. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  8502. for id := range m.em_work_experiences {
  8503. ids = append(ids, id)
  8504. }
  8505. return
  8506. }
  8507. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  8508. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  8509. m.em_work_experiences = nil
  8510. m.clearedem_work_experiences = false
  8511. m.removedem_work_experiences = nil
  8512. }
  8513. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  8514. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  8515. if m.em_tutorial == nil {
  8516. m.em_tutorial = make(map[uint64]struct{})
  8517. }
  8518. for i := range ids {
  8519. m.em_tutorial[ids[i]] = struct{}{}
  8520. }
  8521. }
  8522. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  8523. func (m *EmployeeMutation) ClearEmTutorial() {
  8524. m.clearedem_tutorial = true
  8525. }
  8526. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  8527. func (m *EmployeeMutation) EmTutorialCleared() bool {
  8528. return m.clearedem_tutorial
  8529. }
  8530. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  8531. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  8532. if m.removedem_tutorial == nil {
  8533. m.removedem_tutorial = make(map[uint64]struct{})
  8534. }
  8535. for i := range ids {
  8536. delete(m.em_tutorial, ids[i])
  8537. m.removedem_tutorial[ids[i]] = struct{}{}
  8538. }
  8539. }
  8540. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  8541. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  8542. for id := range m.removedem_tutorial {
  8543. ids = append(ids, id)
  8544. }
  8545. return
  8546. }
  8547. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  8548. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  8549. for id := range m.em_tutorial {
  8550. ids = append(ids, id)
  8551. }
  8552. return
  8553. }
  8554. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  8555. func (m *EmployeeMutation) ResetEmTutorial() {
  8556. m.em_tutorial = nil
  8557. m.clearedem_tutorial = false
  8558. m.removedem_tutorial = nil
  8559. }
  8560. // Where appends a list predicates to the EmployeeMutation builder.
  8561. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  8562. m.predicates = append(m.predicates, ps...)
  8563. }
  8564. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  8565. // users can use type-assertion to append predicates that do not depend on any generated package.
  8566. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  8567. p := make([]predicate.Employee, len(ps))
  8568. for i := range ps {
  8569. p[i] = ps[i]
  8570. }
  8571. m.Where(p...)
  8572. }
  8573. // Op returns the operation name.
  8574. func (m *EmployeeMutation) Op() Op {
  8575. return m.op
  8576. }
  8577. // SetOp allows setting the mutation operation.
  8578. func (m *EmployeeMutation) SetOp(op Op) {
  8579. m.op = op
  8580. }
  8581. // Type returns the node type of this mutation (Employee).
  8582. func (m *EmployeeMutation) Type() string {
  8583. return m.typ
  8584. }
  8585. // Fields returns all fields that were changed during this mutation. Note that in
  8586. // order to get all numeric fields that were incremented/decremented, call
  8587. // AddedFields().
  8588. func (m *EmployeeMutation) Fields() []string {
  8589. fields := make([]string, 0, 22)
  8590. if m.created_at != nil {
  8591. fields = append(fields, employee.FieldCreatedAt)
  8592. }
  8593. if m.updated_at != nil {
  8594. fields = append(fields, employee.FieldUpdatedAt)
  8595. }
  8596. if m.deleted_at != nil {
  8597. fields = append(fields, employee.FieldDeletedAt)
  8598. }
  8599. if m.title != nil {
  8600. fields = append(fields, employee.FieldTitle)
  8601. }
  8602. if m.avatar != nil {
  8603. fields = append(fields, employee.FieldAvatar)
  8604. }
  8605. if m.tags != nil {
  8606. fields = append(fields, employee.FieldTags)
  8607. }
  8608. if m.hire_count != nil {
  8609. fields = append(fields, employee.FieldHireCount)
  8610. }
  8611. if m.service_count != nil {
  8612. fields = append(fields, employee.FieldServiceCount)
  8613. }
  8614. if m.achievement_count != nil {
  8615. fields = append(fields, employee.FieldAchievementCount)
  8616. }
  8617. if m.intro != nil {
  8618. fields = append(fields, employee.FieldIntro)
  8619. }
  8620. if m.estimate != nil {
  8621. fields = append(fields, employee.FieldEstimate)
  8622. }
  8623. if m.skill != nil {
  8624. fields = append(fields, employee.FieldSkill)
  8625. }
  8626. if m.ability_type != nil {
  8627. fields = append(fields, employee.FieldAbilityType)
  8628. }
  8629. if m.scene != nil {
  8630. fields = append(fields, employee.FieldScene)
  8631. }
  8632. if m.switch_in != nil {
  8633. fields = append(fields, employee.FieldSwitchIn)
  8634. }
  8635. if m.video_url != nil {
  8636. fields = append(fields, employee.FieldVideoURL)
  8637. }
  8638. if m.organization_id != nil {
  8639. fields = append(fields, employee.FieldOrganizationID)
  8640. }
  8641. if m.category_id != nil {
  8642. fields = append(fields, employee.FieldCategoryID)
  8643. }
  8644. if m.api_base != nil {
  8645. fields = append(fields, employee.FieldAPIBase)
  8646. }
  8647. if m.api_key != nil {
  8648. fields = append(fields, employee.FieldAPIKey)
  8649. }
  8650. if m.ai_info != nil {
  8651. fields = append(fields, employee.FieldAiInfo)
  8652. }
  8653. if m.is_vip != nil {
  8654. fields = append(fields, employee.FieldIsVip)
  8655. }
  8656. return fields
  8657. }
  8658. // Field returns the value of a field with the given name. The second boolean
  8659. // return value indicates that this field was not set, or was not defined in the
  8660. // schema.
  8661. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  8662. switch name {
  8663. case employee.FieldCreatedAt:
  8664. return m.CreatedAt()
  8665. case employee.FieldUpdatedAt:
  8666. return m.UpdatedAt()
  8667. case employee.FieldDeletedAt:
  8668. return m.DeletedAt()
  8669. case employee.FieldTitle:
  8670. return m.Title()
  8671. case employee.FieldAvatar:
  8672. return m.Avatar()
  8673. case employee.FieldTags:
  8674. return m.Tags()
  8675. case employee.FieldHireCount:
  8676. return m.HireCount()
  8677. case employee.FieldServiceCount:
  8678. return m.ServiceCount()
  8679. case employee.FieldAchievementCount:
  8680. return m.AchievementCount()
  8681. case employee.FieldIntro:
  8682. return m.Intro()
  8683. case employee.FieldEstimate:
  8684. return m.Estimate()
  8685. case employee.FieldSkill:
  8686. return m.Skill()
  8687. case employee.FieldAbilityType:
  8688. return m.AbilityType()
  8689. case employee.FieldScene:
  8690. return m.Scene()
  8691. case employee.FieldSwitchIn:
  8692. return m.SwitchIn()
  8693. case employee.FieldVideoURL:
  8694. return m.VideoURL()
  8695. case employee.FieldOrganizationID:
  8696. return m.OrganizationID()
  8697. case employee.FieldCategoryID:
  8698. return m.CategoryID()
  8699. case employee.FieldAPIBase:
  8700. return m.APIBase()
  8701. case employee.FieldAPIKey:
  8702. return m.APIKey()
  8703. case employee.FieldAiInfo:
  8704. return m.AiInfo()
  8705. case employee.FieldIsVip:
  8706. return m.IsVip()
  8707. }
  8708. return nil, false
  8709. }
  8710. // OldField returns the old value of the field from the database. An error is
  8711. // returned if the mutation operation is not UpdateOne, or the query to the
  8712. // database failed.
  8713. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8714. switch name {
  8715. case employee.FieldCreatedAt:
  8716. return m.OldCreatedAt(ctx)
  8717. case employee.FieldUpdatedAt:
  8718. return m.OldUpdatedAt(ctx)
  8719. case employee.FieldDeletedAt:
  8720. return m.OldDeletedAt(ctx)
  8721. case employee.FieldTitle:
  8722. return m.OldTitle(ctx)
  8723. case employee.FieldAvatar:
  8724. return m.OldAvatar(ctx)
  8725. case employee.FieldTags:
  8726. return m.OldTags(ctx)
  8727. case employee.FieldHireCount:
  8728. return m.OldHireCount(ctx)
  8729. case employee.FieldServiceCount:
  8730. return m.OldServiceCount(ctx)
  8731. case employee.FieldAchievementCount:
  8732. return m.OldAchievementCount(ctx)
  8733. case employee.FieldIntro:
  8734. return m.OldIntro(ctx)
  8735. case employee.FieldEstimate:
  8736. return m.OldEstimate(ctx)
  8737. case employee.FieldSkill:
  8738. return m.OldSkill(ctx)
  8739. case employee.FieldAbilityType:
  8740. return m.OldAbilityType(ctx)
  8741. case employee.FieldScene:
  8742. return m.OldScene(ctx)
  8743. case employee.FieldSwitchIn:
  8744. return m.OldSwitchIn(ctx)
  8745. case employee.FieldVideoURL:
  8746. return m.OldVideoURL(ctx)
  8747. case employee.FieldOrganizationID:
  8748. return m.OldOrganizationID(ctx)
  8749. case employee.FieldCategoryID:
  8750. return m.OldCategoryID(ctx)
  8751. case employee.FieldAPIBase:
  8752. return m.OldAPIBase(ctx)
  8753. case employee.FieldAPIKey:
  8754. return m.OldAPIKey(ctx)
  8755. case employee.FieldAiInfo:
  8756. return m.OldAiInfo(ctx)
  8757. case employee.FieldIsVip:
  8758. return m.OldIsVip(ctx)
  8759. }
  8760. return nil, fmt.Errorf("unknown Employee field %s", name)
  8761. }
  8762. // SetField sets the value of a field with the given name. It returns an error if
  8763. // the field is not defined in the schema, or if the type mismatched the field
  8764. // type.
  8765. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  8766. switch name {
  8767. case employee.FieldCreatedAt:
  8768. v, ok := value.(time.Time)
  8769. if !ok {
  8770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8771. }
  8772. m.SetCreatedAt(v)
  8773. return nil
  8774. case employee.FieldUpdatedAt:
  8775. v, ok := value.(time.Time)
  8776. if !ok {
  8777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8778. }
  8779. m.SetUpdatedAt(v)
  8780. return nil
  8781. case employee.FieldDeletedAt:
  8782. v, ok := value.(time.Time)
  8783. if !ok {
  8784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8785. }
  8786. m.SetDeletedAt(v)
  8787. return nil
  8788. case employee.FieldTitle:
  8789. v, ok := value.(string)
  8790. if !ok {
  8791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8792. }
  8793. m.SetTitle(v)
  8794. return nil
  8795. case employee.FieldAvatar:
  8796. v, ok := value.(string)
  8797. if !ok {
  8798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8799. }
  8800. m.SetAvatar(v)
  8801. return nil
  8802. case employee.FieldTags:
  8803. v, ok := value.(string)
  8804. if !ok {
  8805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8806. }
  8807. m.SetTags(v)
  8808. return nil
  8809. case employee.FieldHireCount:
  8810. v, ok := value.(int)
  8811. if !ok {
  8812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8813. }
  8814. m.SetHireCount(v)
  8815. return nil
  8816. case employee.FieldServiceCount:
  8817. v, ok := value.(int)
  8818. if !ok {
  8819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8820. }
  8821. m.SetServiceCount(v)
  8822. return nil
  8823. case employee.FieldAchievementCount:
  8824. v, ok := value.(int)
  8825. if !ok {
  8826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8827. }
  8828. m.SetAchievementCount(v)
  8829. return nil
  8830. case employee.FieldIntro:
  8831. v, ok := value.(string)
  8832. if !ok {
  8833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8834. }
  8835. m.SetIntro(v)
  8836. return nil
  8837. case employee.FieldEstimate:
  8838. v, ok := value.(string)
  8839. if !ok {
  8840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8841. }
  8842. m.SetEstimate(v)
  8843. return nil
  8844. case employee.FieldSkill:
  8845. v, ok := value.(string)
  8846. if !ok {
  8847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8848. }
  8849. m.SetSkill(v)
  8850. return nil
  8851. case employee.FieldAbilityType:
  8852. v, ok := value.(string)
  8853. if !ok {
  8854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8855. }
  8856. m.SetAbilityType(v)
  8857. return nil
  8858. case employee.FieldScene:
  8859. v, ok := value.(string)
  8860. if !ok {
  8861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8862. }
  8863. m.SetScene(v)
  8864. return nil
  8865. case employee.FieldSwitchIn:
  8866. v, ok := value.(string)
  8867. if !ok {
  8868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8869. }
  8870. m.SetSwitchIn(v)
  8871. return nil
  8872. case employee.FieldVideoURL:
  8873. v, ok := value.(string)
  8874. if !ok {
  8875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8876. }
  8877. m.SetVideoURL(v)
  8878. return nil
  8879. case employee.FieldOrganizationID:
  8880. v, ok := value.(uint64)
  8881. if !ok {
  8882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8883. }
  8884. m.SetOrganizationID(v)
  8885. return nil
  8886. case employee.FieldCategoryID:
  8887. v, ok := value.(uint64)
  8888. if !ok {
  8889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8890. }
  8891. m.SetCategoryID(v)
  8892. return nil
  8893. case employee.FieldAPIBase:
  8894. v, ok := value.(string)
  8895. if !ok {
  8896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8897. }
  8898. m.SetAPIBase(v)
  8899. return nil
  8900. case employee.FieldAPIKey:
  8901. v, ok := value.(string)
  8902. if !ok {
  8903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8904. }
  8905. m.SetAPIKey(v)
  8906. return nil
  8907. case employee.FieldAiInfo:
  8908. v, ok := value.(string)
  8909. if !ok {
  8910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8911. }
  8912. m.SetAiInfo(v)
  8913. return nil
  8914. case employee.FieldIsVip:
  8915. v, ok := value.(int)
  8916. if !ok {
  8917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8918. }
  8919. m.SetIsVip(v)
  8920. return nil
  8921. }
  8922. return fmt.Errorf("unknown Employee field %s", name)
  8923. }
  8924. // AddedFields returns all numeric fields that were incremented/decremented during
  8925. // this mutation.
  8926. func (m *EmployeeMutation) AddedFields() []string {
  8927. var fields []string
  8928. if m.addhire_count != nil {
  8929. fields = append(fields, employee.FieldHireCount)
  8930. }
  8931. if m.addservice_count != nil {
  8932. fields = append(fields, employee.FieldServiceCount)
  8933. }
  8934. if m.addachievement_count != nil {
  8935. fields = append(fields, employee.FieldAchievementCount)
  8936. }
  8937. if m.addorganization_id != nil {
  8938. fields = append(fields, employee.FieldOrganizationID)
  8939. }
  8940. if m.addcategory_id != nil {
  8941. fields = append(fields, employee.FieldCategoryID)
  8942. }
  8943. if m.addis_vip != nil {
  8944. fields = append(fields, employee.FieldIsVip)
  8945. }
  8946. return fields
  8947. }
  8948. // AddedField returns the numeric value that was incremented/decremented on a field
  8949. // with the given name. The second boolean return value indicates that this field
  8950. // was not set, or was not defined in the schema.
  8951. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  8952. switch name {
  8953. case employee.FieldHireCount:
  8954. return m.AddedHireCount()
  8955. case employee.FieldServiceCount:
  8956. return m.AddedServiceCount()
  8957. case employee.FieldAchievementCount:
  8958. return m.AddedAchievementCount()
  8959. case employee.FieldOrganizationID:
  8960. return m.AddedOrganizationID()
  8961. case employee.FieldCategoryID:
  8962. return m.AddedCategoryID()
  8963. case employee.FieldIsVip:
  8964. return m.AddedIsVip()
  8965. }
  8966. return nil, false
  8967. }
  8968. // AddField adds the value to the field with the given name. It returns an error if
  8969. // the field is not defined in the schema, or if the type mismatched the field
  8970. // type.
  8971. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  8972. switch name {
  8973. case employee.FieldHireCount:
  8974. v, ok := value.(int)
  8975. if !ok {
  8976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8977. }
  8978. m.AddHireCount(v)
  8979. return nil
  8980. case employee.FieldServiceCount:
  8981. v, ok := value.(int)
  8982. if !ok {
  8983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8984. }
  8985. m.AddServiceCount(v)
  8986. return nil
  8987. case employee.FieldAchievementCount:
  8988. v, ok := value.(int)
  8989. if !ok {
  8990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8991. }
  8992. m.AddAchievementCount(v)
  8993. return nil
  8994. case employee.FieldOrganizationID:
  8995. v, ok := value.(int64)
  8996. if !ok {
  8997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8998. }
  8999. m.AddOrganizationID(v)
  9000. return nil
  9001. case employee.FieldCategoryID:
  9002. v, ok := value.(int64)
  9003. if !ok {
  9004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9005. }
  9006. m.AddCategoryID(v)
  9007. return nil
  9008. case employee.FieldIsVip:
  9009. v, ok := value.(int)
  9010. if !ok {
  9011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9012. }
  9013. m.AddIsVip(v)
  9014. return nil
  9015. }
  9016. return fmt.Errorf("unknown Employee numeric field %s", name)
  9017. }
  9018. // ClearedFields returns all nullable fields that were cleared during this
  9019. // mutation.
  9020. func (m *EmployeeMutation) ClearedFields() []string {
  9021. var fields []string
  9022. if m.FieldCleared(employee.FieldDeletedAt) {
  9023. fields = append(fields, employee.FieldDeletedAt)
  9024. }
  9025. if m.FieldCleared(employee.FieldAiInfo) {
  9026. fields = append(fields, employee.FieldAiInfo)
  9027. }
  9028. return fields
  9029. }
  9030. // FieldCleared returns a boolean indicating if a field with the given name was
  9031. // cleared in this mutation.
  9032. func (m *EmployeeMutation) FieldCleared(name string) bool {
  9033. _, ok := m.clearedFields[name]
  9034. return ok
  9035. }
  9036. // ClearField clears the value of the field with the given name. It returns an
  9037. // error if the field is not defined in the schema.
  9038. func (m *EmployeeMutation) ClearField(name string) error {
  9039. switch name {
  9040. case employee.FieldDeletedAt:
  9041. m.ClearDeletedAt()
  9042. return nil
  9043. case employee.FieldAiInfo:
  9044. m.ClearAiInfo()
  9045. return nil
  9046. }
  9047. return fmt.Errorf("unknown Employee nullable field %s", name)
  9048. }
  9049. // ResetField resets all changes in the mutation for the field with the given name.
  9050. // It returns an error if the field is not defined in the schema.
  9051. func (m *EmployeeMutation) ResetField(name string) error {
  9052. switch name {
  9053. case employee.FieldCreatedAt:
  9054. m.ResetCreatedAt()
  9055. return nil
  9056. case employee.FieldUpdatedAt:
  9057. m.ResetUpdatedAt()
  9058. return nil
  9059. case employee.FieldDeletedAt:
  9060. m.ResetDeletedAt()
  9061. return nil
  9062. case employee.FieldTitle:
  9063. m.ResetTitle()
  9064. return nil
  9065. case employee.FieldAvatar:
  9066. m.ResetAvatar()
  9067. return nil
  9068. case employee.FieldTags:
  9069. m.ResetTags()
  9070. return nil
  9071. case employee.FieldHireCount:
  9072. m.ResetHireCount()
  9073. return nil
  9074. case employee.FieldServiceCount:
  9075. m.ResetServiceCount()
  9076. return nil
  9077. case employee.FieldAchievementCount:
  9078. m.ResetAchievementCount()
  9079. return nil
  9080. case employee.FieldIntro:
  9081. m.ResetIntro()
  9082. return nil
  9083. case employee.FieldEstimate:
  9084. m.ResetEstimate()
  9085. return nil
  9086. case employee.FieldSkill:
  9087. m.ResetSkill()
  9088. return nil
  9089. case employee.FieldAbilityType:
  9090. m.ResetAbilityType()
  9091. return nil
  9092. case employee.FieldScene:
  9093. m.ResetScene()
  9094. return nil
  9095. case employee.FieldSwitchIn:
  9096. m.ResetSwitchIn()
  9097. return nil
  9098. case employee.FieldVideoURL:
  9099. m.ResetVideoURL()
  9100. return nil
  9101. case employee.FieldOrganizationID:
  9102. m.ResetOrganizationID()
  9103. return nil
  9104. case employee.FieldCategoryID:
  9105. m.ResetCategoryID()
  9106. return nil
  9107. case employee.FieldAPIBase:
  9108. m.ResetAPIBase()
  9109. return nil
  9110. case employee.FieldAPIKey:
  9111. m.ResetAPIKey()
  9112. return nil
  9113. case employee.FieldAiInfo:
  9114. m.ResetAiInfo()
  9115. return nil
  9116. case employee.FieldIsVip:
  9117. m.ResetIsVip()
  9118. return nil
  9119. }
  9120. return fmt.Errorf("unknown Employee field %s", name)
  9121. }
  9122. // AddedEdges returns all edge names that were set/added in this mutation.
  9123. func (m *EmployeeMutation) AddedEdges() []string {
  9124. edges := make([]string, 0, 2)
  9125. if m.em_work_experiences != nil {
  9126. edges = append(edges, employee.EdgeEmWorkExperiences)
  9127. }
  9128. if m.em_tutorial != nil {
  9129. edges = append(edges, employee.EdgeEmTutorial)
  9130. }
  9131. return edges
  9132. }
  9133. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9134. // name in this mutation.
  9135. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  9136. switch name {
  9137. case employee.EdgeEmWorkExperiences:
  9138. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  9139. for id := range m.em_work_experiences {
  9140. ids = append(ids, id)
  9141. }
  9142. return ids
  9143. case employee.EdgeEmTutorial:
  9144. ids := make([]ent.Value, 0, len(m.em_tutorial))
  9145. for id := range m.em_tutorial {
  9146. ids = append(ids, id)
  9147. }
  9148. return ids
  9149. }
  9150. return nil
  9151. }
  9152. // RemovedEdges returns all edge names that were removed in this mutation.
  9153. func (m *EmployeeMutation) RemovedEdges() []string {
  9154. edges := make([]string, 0, 2)
  9155. if m.removedem_work_experiences != nil {
  9156. edges = append(edges, employee.EdgeEmWorkExperiences)
  9157. }
  9158. if m.removedem_tutorial != nil {
  9159. edges = append(edges, employee.EdgeEmTutorial)
  9160. }
  9161. return edges
  9162. }
  9163. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9164. // the given name in this mutation.
  9165. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  9166. switch name {
  9167. case employee.EdgeEmWorkExperiences:
  9168. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  9169. for id := range m.removedem_work_experiences {
  9170. ids = append(ids, id)
  9171. }
  9172. return ids
  9173. case employee.EdgeEmTutorial:
  9174. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  9175. for id := range m.removedem_tutorial {
  9176. ids = append(ids, id)
  9177. }
  9178. return ids
  9179. }
  9180. return nil
  9181. }
  9182. // ClearedEdges returns all edge names that were cleared in this mutation.
  9183. func (m *EmployeeMutation) ClearedEdges() []string {
  9184. edges := make([]string, 0, 2)
  9185. if m.clearedem_work_experiences {
  9186. edges = append(edges, employee.EdgeEmWorkExperiences)
  9187. }
  9188. if m.clearedem_tutorial {
  9189. edges = append(edges, employee.EdgeEmTutorial)
  9190. }
  9191. return edges
  9192. }
  9193. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9194. // was cleared in this mutation.
  9195. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  9196. switch name {
  9197. case employee.EdgeEmWorkExperiences:
  9198. return m.clearedem_work_experiences
  9199. case employee.EdgeEmTutorial:
  9200. return m.clearedem_tutorial
  9201. }
  9202. return false
  9203. }
  9204. // ClearEdge clears the value of the edge with the given name. It returns an error
  9205. // if that edge is not defined in the schema.
  9206. func (m *EmployeeMutation) ClearEdge(name string) error {
  9207. switch name {
  9208. }
  9209. return fmt.Errorf("unknown Employee unique edge %s", name)
  9210. }
  9211. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9212. // It returns an error if the edge is not defined in the schema.
  9213. func (m *EmployeeMutation) ResetEdge(name string) error {
  9214. switch name {
  9215. case employee.EdgeEmWorkExperiences:
  9216. m.ResetEmWorkExperiences()
  9217. return nil
  9218. case employee.EdgeEmTutorial:
  9219. m.ResetEmTutorial()
  9220. return nil
  9221. }
  9222. return fmt.Errorf("unknown Employee edge %s", name)
  9223. }
  9224. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  9225. type EmployeeConfigMutation struct {
  9226. config
  9227. op Op
  9228. typ string
  9229. id *uint64
  9230. created_at *time.Time
  9231. updated_at *time.Time
  9232. deleted_at *time.Time
  9233. stype *string
  9234. title *string
  9235. photo *string
  9236. organization_id *uint64
  9237. addorganization_id *int64
  9238. clearedFields map[string]struct{}
  9239. done bool
  9240. oldValue func(context.Context) (*EmployeeConfig, error)
  9241. predicates []predicate.EmployeeConfig
  9242. }
  9243. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  9244. // employeeconfigOption allows management of the mutation configuration using functional options.
  9245. type employeeconfigOption func(*EmployeeConfigMutation)
  9246. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  9247. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  9248. m := &EmployeeConfigMutation{
  9249. config: c,
  9250. op: op,
  9251. typ: TypeEmployeeConfig,
  9252. clearedFields: make(map[string]struct{}),
  9253. }
  9254. for _, opt := range opts {
  9255. opt(m)
  9256. }
  9257. return m
  9258. }
  9259. // withEmployeeConfigID sets the ID field of the mutation.
  9260. func withEmployeeConfigID(id uint64) employeeconfigOption {
  9261. return func(m *EmployeeConfigMutation) {
  9262. var (
  9263. err error
  9264. once sync.Once
  9265. value *EmployeeConfig
  9266. )
  9267. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  9268. once.Do(func() {
  9269. if m.done {
  9270. err = errors.New("querying old values post mutation is not allowed")
  9271. } else {
  9272. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  9273. }
  9274. })
  9275. return value, err
  9276. }
  9277. m.id = &id
  9278. }
  9279. }
  9280. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  9281. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  9282. return func(m *EmployeeConfigMutation) {
  9283. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  9284. return node, nil
  9285. }
  9286. m.id = &node.ID
  9287. }
  9288. }
  9289. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9290. // executed in a transaction (ent.Tx), a transactional client is returned.
  9291. func (m EmployeeConfigMutation) Client() *Client {
  9292. client := &Client{config: m.config}
  9293. client.init()
  9294. return client
  9295. }
  9296. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9297. // it returns an error otherwise.
  9298. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  9299. if _, ok := m.driver.(*txDriver); !ok {
  9300. return nil, errors.New("ent: mutation is not running in a transaction")
  9301. }
  9302. tx := &Tx{config: m.config}
  9303. tx.init()
  9304. return tx, nil
  9305. }
  9306. // SetID sets the value of the id field. Note that this
  9307. // operation is only accepted on creation of EmployeeConfig entities.
  9308. func (m *EmployeeConfigMutation) SetID(id uint64) {
  9309. m.id = &id
  9310. }
  9311. // ID returns the ID value in the mutation. Note that the ID is only available
  9312. // if it was provided to the builder or after it was returned from the database.
  9313. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  9314. if m.id == nil {
  9315. return
  9316. }
  9317. return *m.id, true
  9318. }
  9319. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9320. // That means, if the mutation is applied within a transaction with an isolation level such
  9321. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9322. // or updated by the mutation.
  9323. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  9324. switch {
  9325. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9326. id, exists := m.ID()
  9327. if exists {
  9328. return []uint64{id}, nil
  9329. }
  9330. fallthrough
  9331. case m.op.Is(OpUpdate | OpDelete):
  9332. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  9333. default:
  9334. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9335. }
  9336. }
  9337. // SetCreatedAt sets the "created_at" field.
  9338. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  9339. m.created_at = &t
  9340. }
  9341. // CreatedAt returns the value of the "created_at" field in the mutation.
  9342. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  9343. v := m.created_at
  9344. if v == nil {
  9345. return
  9346. }
  9347. return *v, true
  9348. }
  9349. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  9350. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9352. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9353. if !m.op.Is(OpUpdateOne) {
  9354. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9355. }
  9356. if m.id == nil || m.oldValue == nil {
  9357. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9358. }
  9359. oldValue, err := m.oldValue(ctx)
  9360. if err != nil {
  9361. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9362. }
  9363. return oldValue.CreatedAt, nil
  9364. }
  9365. // ResetCreatedAt resets all changes to the "created_at" field.
  9366. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  9367. m.created_at = nil
  9368. }
  9369. // SetUpdatedAt sets the "updated_at" field.
  9370. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  9371. m.updated_at = &t
  9372. }
  9373. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9374. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  9375. v := m.updated_at
  9376. if v == nil {
  9377. return
  9378. }
  9379. return *v, true
  9380. }
  9381. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  9382. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9384. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9385. if !m.op.Is(OpUpdateOne) {
  9386. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9387. }
  9388. if m.id == nil || m.oldValue == nil {
  9389. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9390. }
  9391. oldValue, err := m.oldValue(ctx)
  9392. if err != nil {
  9393. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9394. }
  9395. return oldValue.UpdatedAt, nil
  9396. }
  9397. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9398. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  9399. m.updated_at = nil
  9400. }
  9401. // SetDeletedAt sets the "deleted_at" field.
  9402. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  9403. m.deleted_at = &t
  9404. }
  9405. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9406. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  9407. v := m.deleted_at
  9408. if v == nil {
  9409. return
  9410. }
  9411. return *v, true
  9412. }
  9413. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  9414. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9416. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9417. if !m.op.Is(OpUpdateOne) {
  9418. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9419. }
  9420. if m.id == nil || m.oldValue == nil {
  9421. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9422. }
  9423. oldValue, err := m.oldValue(ctx)
  9424. if err != nil {
  9425. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9426. }
  9427. return oldValue.DeletedAt, nil
  9428. }
  9429. // ClearDeletedAt clears the value of the "deleted_at" field.
  9430. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  9431. m.deleted_at = nil
  9432. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  9433. }
  9434. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9435. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  9436. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  9437. return ok
  9438. }
  9439. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9440. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  9441. m.deleted_at = nil
  9442. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  9443. }
  9444. // SetStype sets the "stype" field.
  9445. func (m *EmployeeConfigMutation) SetStype(s string) {
  9446. m.stype = &s
  9447. }
  9448. // Stype returns the value of the "stype" field in the mutation.
  9449. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  9450. v := m.stype
  9451. if v == nil {
  9452. return
  9453. }
  9454. return *v, true
  9455. }
  9456. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  9457. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9459. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  9460. if !m.op.Is(OpUpdateOne) {
  9461. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  9462. }
  9463. if m.id == nil || m.oldValue == nil {
  9464. return v, errors.New("OldStype requires an ID field in the mutation")
  9465. }
  9466. oldValue, err := m.oldValue(ctx)
  9467. if err != nil {
  9468. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  9469. }
  9470. return oldValue.Stype, nil
  9471. }
  9472. // ResetStype resets all changes to the "stype" field.
  9473. func (m *EmployeeConfigMutation) ResetStype() {
  9474. m.stype = nil
  9475. }
  9476. // SetTitle sets the "title" field.
  9477. func (m *EmployeeConfigMutation) SetTitle(s string) {
  9478. m.title = &s
  9479. }
  9480. // Title returns the value of the "title" field in the mutation.
  9481. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  9482. v := m.title
  9483. if v == nil {
  9484. return
  9485. }
  9486. return *v, true
  9487. }
  9488. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  9489. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9491. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  9492. if !m.op.Is(OpUpdateOne) {
  9493. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  9494. }
  9495. if m.id == nil || m.oldValue == nil {
  9496. return v, errors.New("OldTitle requires an ID field in the mutation")
  9497. }
  9498. oldValue, err := m.oldValue(ctx)
  9499. if err != nil {
  9500. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  9501. }
  9502. return oldValue.Title, nil
  9503. }
  9504. // ResetTitle resets all changes to the "title" field.
  9505. func (m *EmployeeConfigMutation) ResetTitle() {
  9506. m.title = nil
  9507. }
  9508. // SetPhoto sets the "photo" field.
  9509. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  9510. m.photo = &s
  9511. }
  9512. // Photo returns the value of the "photo" field in the mutation.
  9513. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  9514. v := m.photo
  9515. if v == nil {
  9516. return
  9517. }
  9518. return *v, true
  9519. }
  9520. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  9521. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9523. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  9524. if !m.op.Is(OpUpdateOne) {
  9525. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  9526. }
  9527. if m.id == nil || m.oldValue == nil {
  9528. return v, errors.New("OldPhoto requires an ID field in the mutation")
  9529. }
  9530. oldValue, err := m.oldValue(ctx)
  9531. if err != nil {
  9532. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  9533. }
  9534. return oldValue.Photo, nil
  9535. }
  9536. // ResetPhoto resets all changes to the "photo" field.
  9537. func (m *EmployeeConfigMutation) ResetPhoto() {
  9538. m.photo = nil
  9539. }
  9540. // SetOrganizationID sets the "organization_id" field.
  9541. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  9542. m.organization_id = &u
  9543. m.addorganization_id = nil
  9544. }
  9545. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9546. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  9547. v := m.organization_id
  9548. if v == nil {
  9549. return
  9550. }
  9551. return *v, true
  9552. }
  9553. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  9554. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9556. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9557. if !m.op.Is(OpUpdateOne) {
  9558. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9559. }
  9560. if m.id == nil || m.oldValue == nil {
  9561. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9562. }
  9563. oldValue, err := m.oldValue(ctx)
  9564. if err != nil {
  9565. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9566. }
  9567. return oldValue.OrganizationID, nil
  9568. }
  9569. // AddOrganizationID adds u to the "organization_id" field.
  9570. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  9571. if m.addorganization_id != nil {
  9572. *m.addorganization_id += u
  9573. } else {
  9574. m.addorganization_id = &u
  9575. }
  9576. }
  9577. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9578. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  9579. v := m.addorganization_id
  9580. if v == nil {
  9581. return
  9582. }
  9583. return *v, true
  9584. }
  9585. // ClearOrganizationID clears the value of the "organization_id" field.
  9586. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  9587. m.organization_id = nil
  9588. m.addorganization_id = nil
  9589. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  9590. }
  9591. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9592. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  9593. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  9594. return ok
  9595. }
  9596. // ResetOrganizationID resets all changes to the "organization_id" field.
  9597. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  9598. m.organization_id = nil
  9599. m.addorganization_id = nil
  9600. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  9601. }
  9602. // Where appends a list predicates to the EmployeeConfigMutation builder.
  9603. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  9604. m.predicates = append(m.predicates, ps...)
  9605. }
  9606. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  9607. // users can use type-assertion to append predicates that do not depend on any generated package.
  9608. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  9609. p := make([]predicate.EmployeeConfig, len(ps))
  9610. for i := range ps {
  9611. p[i] = ps[i]
  9612. }
  9613. m.Where(p...)
  9614. }
  9615. // Op returns the operation name.
  9616. func (m *EmployeeConfigMutation) Op() Op {
  9617. return m.op
  9618. }
  9619. // SetOp allows setting the mutation operation.
  9620. func (m *EmployeeConfigMutation) SetOp(op Op) {
  9621. m.op = op
  9622. }
  9623. // Type returns the node type of this mutation (EmployeeConfig).
  9624. func (m *EmployeeConfigMutation) Type() string {
  9625. return m.typ
  9626. }
  9627. // Fields returns all fields that were changed during this mutation. Note that in
  9628. // order to get all numeric fields that were incremented/decremented, call
  9629. // AddedFields().
  9630. func (m *EmployeeConfigMutation) Fields() []string {
  9631. fields := make([]string, 0, 7)
  9632. if m.created_at != nil {
  9633. fields = append(fields, employeeconfig.FieldCreatedAt)
  9634. }
  9635. if m.updated_at != nil {
  9636. fields = append(fields, employeeconfig.FieldUpdatedAt)
  9637. }
  9638. if m.deleted_at != nil {
  9639. fields = append(fields, employeeconfig.FieldDeletedAt)
  9640. }
  9641. if m.stype != nil {
  9642. fields = append(fields, employeeconfig.FieldStype)
  9643. }
  9644. if m.title != nil {
  9645. fields = append(fields, employeeconfig.FieldTitle)
  9646. }
  9647. if m.photo != nil {
  9648. fields = append(fields, employeeconfig.FieldPhoto)
  9649. }
  9650. if m.organization_id != nil {
  9651. fields = append(fields, employeeconfig.FieldOrganizationID)
  9652. }
  9653. return fields
  9654. }
  9655. // Field returns the value of a field with the given name. The second boolean
  9656. // return value indicates that this field was not set, or was not defined in the
  9657. // schema.
  9658. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  9659. switch name {
  9660. case employeeconfig.FieldCreatedAt:
  9661. return m.CreatedAt()
  9662. case employeeconfig.FieldUpdatedAt:
  9663. return m.UpdatedAt()
  9664. case employeeconfig.FieldDeletedAt:
  9665. return m.DeletedAt()
  9666. case employeeconfig.FieldStype:
  9667. return m.Stype()
  9668. case employeeconfig.FieldTitle:
  9669. return m.Title()
  9670. case employeeconfig.FieldPhoto:
  9671. return m.Photo()
  9672. case employeeconfig.FieldOrganizationID:
  9673. return m.OrganizationID()
  9674. }
  9675. return nil, false
  9676. }
  9677. // OldField returns the old value of the field from the database. An error is
  9678. // returned if the mutation operation is not UpdateOne, or the query to the
  9679. // database failed.
  9680. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9681. switch name {
  9682. case employeeconfig.FieldCreatedAt:
  9683. return m.OldCreatedAt(ctx)
  9684. case employeeconfig.FieldUpdatedAt:
  9685. return m.OldUpdatedAt(ctx)
  9686. case employeeconfig.FieldDeletedAt:
  9687. return m.OldDeletedAt(ctx)
  9688. case employeeconfig.FieldStype:
  9689. return m.OldStype(ctx)
  9690. case employeeconfig.FieldTitle:
  9691. return m.OldTitle(ctx)
  9692. case employeeconfig.FieldPhoto:
  9693. return m.OldPhoto(ctx)
  9694. case employeeconfig.FieldOrganizationID:
  9695. return m.OldOrganizationID(ctx)
  9696. }
  9697. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  9698. }
  9699. // SetField sets the value of a field with the given name. It returns an error if
  9700. // the field is not defined in the schema, or if the type mismatched the field
  9701. // type.
  9702. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  9703. switch name {
  9704. case employeeconfig.FieldCreatedAt:
  9705. v, ok := value.(time.Time)
  9706. if !ok {
  9707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9708. }
  9709. m.SetCreatedAt(v)
  9710. return nil
  9711. case employeeconfig.FieldUpdatedAt:
  9712. v, ok := value.(time.Time)
  9713. if !ok {
  9714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9715. }
  9716. m.SetUpdatedAt(v)
  9717. return nil
  9718. case employeeconfig.FieldDeletedAt:
  9719. v, ok := value.(time.Time)
  9720. if !ok {
  9721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9722. }
  9723. m.SetDeletedAt(v)
  9724. return nil
  9725. case employeeconfig.FieldStype:
  9726. v, ok := value.(string)
  9727. if !ok {
  9728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9729. }
  9730. m.SetStype(v)
  9731. return nil
  9732. case employeeconfig.FieldTitle:
  9733. v, ok := value.(string)
  9734. if !ok {
  9735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9736. }
  9737. m.SetTitle(v)
  9738. return nil
  9739. case employeeconfig.FieldPhoto:
  9740. v, ok := value.(string)
  9741. if !ok {
  9742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9743. }
  9744. m.SetPhoto(v)
  9745. return nil
  9746. case employeeconfig.FieldOrganizationID:
  9747. v, ok := value.(uint64)
  9748. if !ok {
  9749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9750. }
  9751. m.SetOrganizationID(v)
  9752. return nil
  9753. }
  9754. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  9755. }
  9756. // AddedFields returns all numeric fields that were incremented/decremented during
  9757. // this mutation.
  9758. func (m *EmployeeConfigMutation) AddedFields() []string {
  9759. var fields []string
  9760. if m.addorganization_id != nil {
  9761. fields = append(fields, employeeconfig.FieldOrganizationID)
  9762. }
  9763. return fields
  9764. }
  9765. // AddedField returns the numeric value that was incremented/decremented on a field
  9766. // with the given name. The second boolean return value indicates that this field
  9767. // was not set, or was not defined in the schema.
  9768. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  9769. switch name {
  9770. case employeeconfig.FieldOrganizationID:
  9771. return m.AddedOrganizationID()
  9772. }
  9773. return nil, false
  9774. }
  9775. // AddField adds the value to the field with the given name. It returns an error if
  9776. // the field is not defined in the schema, or if the type mismatched the field
  9777. // type.
  9778. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  9779. switch name {
  9780. case employeeconfig.FieldOrganizationID:
  9781. v, ok := value.(int64)
  9782. if !ok {
  9783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9784. }
  9785. m.AddOrganizationID(v)
  9786. return nil
  9787. }
  9788. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  9789. }
  9790. // ClearedFields returns all nullable fields that were cleared during this
  9791. // mutation.
  9792. func (m *EmployeeConfigMutation) ClearedFields() []string {
  9793. var fields []string
  9794. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  9795. fields = append(fields, employeeconfig.FieldDeletedAt)
  9796. }
  9797. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  9798. fields = append(fields, employeeconfig.FieldOrganizationID)
  9799. }
  9800. return fields
  9801. }
  9802. // FieldCleared returns a boolean indicating if a field with the given name was
  9803. // cleared in this mutation.
  9804. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  9805. _, ok := m.clearedFields[name]
  9806. return ok
  9807. }
  9808. // ClearField clears the value of the field with the given name. It returns an
  9809. // error if the field is not defined in the schema.
  9810. func (m *EmployeeConfigMutation) ClearField(name string) error {
  9811. switch name {
  9812. case employeeconfig.FieldDeletedAt:
  9813. m.ClearDeletedAt()
  9814. return nil
  9815. case employeeconfig.FieldOrganizationID:
  9816. m.ClearOrganizationID()
  9817. return nil
  9818. }
  9819. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  9820. }
  9821. // ResetField resets all changes in the mutation for the field with the given name.
  9822. // It returns an error if the field is not defined in the schema.
  9823. func (m *EmployeeConfigMutation) ResetField(name string) error {
  9824. switch name {
  9825. case employeeconfig.FieldCreatedAt:
  9826. m.ResetCreatedAt()
  9827. return nil
  9828. case employeeconfig.FieldUpdatedAt:
  9829. m.ResetUpdatedAt()
  9830. return nil
  9831. case employeeconfig.FieldDeletedAt:
  9832. m.ResetDeletedAt()
  9833. return nil
  9834. case employeeconfig.FieldStype:
  9835. m.ResetStype()
  9836. return nil
  9837. case employeeconfig.FieldTitle:
  9838. m.ResetTitle()
  9839. return nil
  9840. case employeeconfig.FieldPhoto:
  9841. m.ResetPhoto()
  9842. return nil
  9843. case employeeconfig.FieldOrganizationID:
  9844. m.ResetOrganizationID()
  9845. return nil
  9846. }
  9847. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  9848. }
  9849. // AddedEdges returns all edge names that were set/added in this mutation.
  9850. func (m *EmployeeConfigMutation) AddedEdges() []string {
  9851. edges := make([]string, 0, 0)
  9852. return edges
  9853. }
  9854. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9855. // name in this mutation.
  9856. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  9857. return nil
  9858. }
  9859. // RemovedEdges returns all edge names that were removed in this mutation.
  9860. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  9861. edges := make([]string, 0, 0)
  9862. return edges
  9863. }
  9864. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9865. // the given name in this mutation.
  9866. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  9867. return nil
  9868. }
  9869. // ClearedEdges returns all edge names that were cleared in this mutation.
  9870. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  9871. edges := make([]string, 0, 0)
  9872. return edges
  9873. }
  9874. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9875. // was cleared in this mutation.
  9876. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  9877. return false
  9878. }
  9879. // ClearEdge clears the value of the edge with the given name. It returns an error
  9880. // if that edge is not defined in the schema.
  9881. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  9882. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  9883. }
  9884. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9885. // It returns an error if the edge is not defined in the schema.
  9886. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  9887. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  9888. }
  9889. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  9890. type LabelMutation struct {
  9891. config
  9892. op Op
  9893. typ string
  9894. id *uint64
  9895. created_at *time.Time
  9896. updated_at *time.Time
  9897. status *uint8
  9898. addstatus *int8
  9899. _type *int
  9900. add_type *int
  9901. name *string
  9902. from *int
  9903. addfrom *int
  9904. mode *int
  9905. addmode *int
  9906. conditions *string
  9907. organization_id *uint64
  9908. addorganization_id *int64
  9909. clearedFields map[string]struct{}
  9910. label_relationships map[uint64]struct{}
  9911. removedlabel_relationships map[uint64]struct{}
  9912. clearedlabel_relationships bool
  9913. done bool
  9914. oldValue func(context.Context) (*Label, error)
  9915. predicates []predicate.Label
  9916. }
  9917. var _ ent.Mutation = (*LabelMutation)(nil)
  9918. // labelOption allows management of the mutation configuration using functional options.
  9919. type labelOption func(*LabelMutation)
  9920. // newLabelMutation creates new mutation for the Label entity.
  9921. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  9922. m := &LabelMutation{
  9923. config: c,
  9924. op: op,
  9925. typ: TypeLabel,
  9926. clearedFields: make(map[string]struct{}),
  9927. }
  9928. for _, opt := range opts {
  9929. opt(m)
  9930. }
  9931. return m
  9932. }
  9933. // withLabelID sets the ID field of the mutation.
  9934. func withLabelID(id uint64) labelOption {
  9935. return func(m *LabelMutation) {
  9936. var (
  9937. err error
  9938. once sync.Once
  9939. value *Label
  9940. )
  9941. m.oldValue = func(ctx context.Context) (*Label, error) {
  9942. once.Do(func() {
  9943. if m.done {
  9944. err = errors.New("querying old values post mutation is not allowed")
  9945. } else {
  9946. value, err = m.Client().Label.Get(ctx, id)
  9947. }
  9948. })
  9949. return value, err
  9950. }
  9951. m.id = &id
  9952. }
  9953. }
  9954. // withLabel sets the old Label of the mutation.
  9955. func withLabel(node *Label) labelOption {
  9956. return func(m *LabelMutation) {
  9957. m.oldValue = func(context.Context) (*Label, error) {
  9958. return node, nil
  9959. }
  9960. m.id = &node.ID
  9961. }
  9962. }
  9963. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9964. // executed in a transaction (ent.Tx), a transactional client is returned.
  9965. func (m LabelMutation) Client() *Client {
  9966. client := &Client{config: m.config}
  9967. client.init()
  9968. return client
  9969. }
  9970. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9971. // it returns an error otherwise.
  9972. func (m LabelMutation) Tx() (*Tx, error) {
  9973. if _, ok := m.driver.(*txDriver); !ok {
  9974. return nil, errors.New("ent: mutation is not running in a transaction")
  9975. }
  9976. tx := &Tx{config: m.config}
  9977. tx.init()
  9978. return tx, nil
  9979. }
  9980. // SetID sets the value of the id field. Note that this
  9981. // operation is only accepted on creation of Label entities.
  9982. func (m *LabelMutation) SetID(id uint64) {
  9983. m.id = &id
  9984. }
  9985. // ID returns the ID value in the mutation. Note that the ID is only available
  9986. // if it was provided to the builder or after it was returned from the database.
  9987. func (m *LabelMutation) ID() (id uint64, exists bool) {
  9988. if m.id == nil {
  9989. return
  9990. }
  9991. return *m.id, true
  9992. }
  9993. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9994. // That means, if the mutation is applied within a transaction with an isolation level such
  9995. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9996. // or updated by the mutation.
  9997. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  9998. switch {
  9999. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10000. id, exists := m.ID()
  10001. if exists {
  10002. return []uint64{id}, nil
  10003. }
  10004. fallthrough
  10005. case m.op.Is(OpUpdate | OpDelete):
  10006. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  10007. default:
  10008. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10009. }
  10010. }
  10011. // SetCreatedAt sets the "created_at" field.
  10012. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  10013. m.created_at = &t
  10014. }
  10015. // CreatedAt returns the value of the "created_at" field in the mutation.
  10016. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  10017. v := m.created_at
  10018. if v == nil {
  10019. return
  10020. }
  10021. return *v, true
  10022. }
  10023. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  10024. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10026. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10027. if !m.op.Is(OpUpdateOne) {
  10028. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10029. }
  10030. if m.id == nil || m.oldValue == nil {
  10031. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10032. }
  10033. oldValue, err := m.oldValue(ctx)
  10034. if err != nil {
  10035. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10036. }
  10037. return oldValue.CreatedAt, nil
  10038. }
  10039. // ResetCreatedAt resets all changes to the "created_at" field.
  10040. func (m *LabelMutation) ResetCreatedAt() {
  10041. m.created_at = nil
  10042. }
  10043. // SetUpdatedAt sets the "updated_at" field.
  10044. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  10045. m.updated_at = &t
  10046. }
  10047. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10048. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  10049. v := m.updated_at
  10050. if v == nil {
  10051. return
  10052. }
  10053. return *v, true
  10054. }
  10055. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  10056. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10058. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10059. if !m.op.Is(OpUpdateOne) {
  10060. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10061. }
  10062. if m.id == nil || m.oldValue == nil {
  10063. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10064. }
  10065. oldValue, err := m.oldValue(ctx)
  10066. if err != nil {
  10067. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10068. }
  10069. return oldValue.UpdatedAt, nil
  10070. }
  10071. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10072. func (m *LabelMutation) ResetUpdatedAt() {
  10073. m.updated_at = nil
  10074. }
  10075. // SetStatus sets the "status" field.
  10076. func (m *LabelMutation) SetStatus(u uint8) {
  10077. m.status = &u
  10078. m.addstatus = nil
  10079. }
  10080. // Status returns the value of the "status" field in the mutation.
  10081. func (m *LabelMutation) Status() (r uint8, exists bool) {
  10082. v := m.status
  10083. if v == nil {
  10084. return
  10085. }
  10086. return *v, true
  10087. }
  10088. // OldStatus returns the old "status" field's value of the Label entity.
  10089. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10091. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10092. if !m.op.Is(OpUpdateOne) {
  10093. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10094. }
  10095. if m.id == nil || m.oldValue == nil {
  10096. return v, errors.New("OldStatus requires an ID field in the mutation")
  10097. }
  10098. oldValue, err := m.oldValue(ctx)
  10099. if err != nil {
  10100. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10101. }
  10102. return oldValue.Status, nil
  10103. }
  10104. // AddStatus adds u to the "status" field.
  10105. func (m *LabelMutation) AddStatus(u int8) {
  10106. if m.addstatus != nil {
  10107. *m.addstatus += u
  10108. } else {
  10109. m.addstatus = &u
  10110. }
  10111. }
  10112. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10113. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  10114. v := m.addstatus
  10115. if v == nil {
  10116. return
  10117. }
  10118. return *v, true
  10119. }
  10120. // ClearStatus clears the value of the "status" field.
  10121. func (m *LabelMutation) ClearStatus() {
  10122. m.status = nil
  10123. m.addstatus = nil
  10124. m.clearedFields[label.FieldStatus] = struct{}{}
  10125. }
  10126. // StatusCleared returns if the "status" field was cleared in this mutation.
  10127. func (m *LabelMutation) StatusCleared() bool {
  10128. _, ok := m.clearedFields[label.FieldStatus]
  10129. return ok
  10130. }
  10131. // ResetStatus resets all changes to the "status" field.
  10132. func (m *LabelMutation) ResetStatus() {
  10133. m.status = nil
  10134. m.addstatus = nil
  10135. delete(m.clearedFields, label.FieldStatus)
  10136. }
  10137. // SetType sets the "type" field.
  10138. func (m *LabelMutation) SetType(i int) {
  10139. m._type = &i
  10140. m.add_type = nil
  10141. }
  10142. // GetType returns the value of the "type" field in the mutation.
  10143. func (m *LabelMutation) GetType() (r int, exists bool) {
  10144. v := m._type
  10145. if v == nil {
  10146. return
  10147. }
  10148. return *v, true
  10149. }
  10150. // OldType returns the old "type" field's value of the Label entity.
  10151. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10153. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  10154. if !m.op.Is(OpUpdateOne) {
  10155. return v, errors.New("OldType is only allowed on UpdateOne operations")
  10156. }
  10157. if m.id == nil || m.oldValue == nil {
  10158. return v, errors.New("OldType requires an ID field in the mutation")
  10159. }
  10160. oldValue, err := m.oldValue(ctx)
  10161. if err != nil {
  10162. return v, fmt.Errorf("querying old value for OldType: %w", err)
  10163. }
  10164. return oldValue.Type, nil
  10165. }
  10166. // AddType adds i to the "type" field.
  10167. func (m *LabelMutation) AddType(i int) {
  10168. if m.add_type != nil {
  10169. *m.add_type += i
  10170. } else {
  10171. m.add_type = &i
  10172. }
  10173. }
  10174. // AddedType returns the value that was added to the "type" field in this mutation.
  10175. func (m *LabelMutation) AddedType() (r int, exists bool) {
  10176. v := m.add_type
  10177. if v == nil {
  10178. return
  10179. }
  10180. return *v, true
  10181. }
  10182. // ResetType resets all changes to the "type" field.
  10183. func (m *LabelMutation) ResetType() {
  10184. m._type = nil
  10185. m.add_type = nil
  10186. }
  10187. // SetName sets the "name" field.
  10188. func (m *LabelMutation) SetName(s string) {
  10189. m.name = &s
  10190. }
  10191. // Name returns the value of the "name" field in the mutation.
  10192. func (m *LabelMutation) Name() (r string, exists bool) {
  10193. v := m.name
  10194. if v == nil {
  10195. return
  10196. }
  10197. return *v, true
  10198. }
  10199. // OldName returns the old "name" field's value of the Label entity.
  10200. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10202. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  10203. if !m.op.Is(OpUpdateOne) {
  10204. return v, errors.New("OldName is only allowed on UpdateOne operations")
  10205. }
  10206. if m.id == nil || m.oldValue == nil {
  10207. return v, errors.New("OldName requires an ID field in the mutation")
  10208. }
  10209. oldValue, err := m.oldValue(ctx)
  10210. if err != nil {
  10211. return v, fmt.Errorf("querying old value for OldName: %w", err)
  10212. }
  10213. return oldValue.Name, nil
  10214. }
  10215. // ResetName resets all changes to the "name" field.
  10216. func (m *LabelMutation) ResetName() {
  10217. m.name = nil
  10218. }
  10219. // SetFrom sets the "from" field.
  10220. func (m *LabelMutation) SetFrom(i int) {
  10221. m.from = &i
  10222. m.addfrom = nil
  10223. }
  10224. // From returns the value of the "from" field in the mutation.
  10225. func (m *LabelMutation) From() (r int, exists bool) {
  10226. v := m.from
  10227. if v == nil {
  10228. return
  10229. }
  10230. return *v, true
  10231. }
  10232. // OldFrom returns the old "from" field's value of the Label entity.
  10233. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10235. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  10236. if !m.op.Is(OpUpdateOne) {
  10237. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  10238. }
  10239. if m.id == nil || m.oldValue == nil {
  10240. return v, errors.New("OldFrom requires an ID field in the mutation")
  10241. }
  10242. oldValue, err := m.oldValue(ctx)
  10243. if err != nil {
  10244. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  10245. }
  10246. return oldValue.From, nil
  10247. }
  10248. // AddFrom adds i to the "from" field.
  10249. func (m *LabelMutation) AddFrom(i int) {
  10250. if m.addfrom != nil {
  10251. *m.addfrom += i
  10252. } else {
  10253. m.addfrom = &i
  10254. }
  10255. }
  10256. // AddedFrom returns the value that was added to the "from" field in this mutation.
  10257. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  10258. v := m.addfrom
  10259. if v == nil {
  10260. return
  10261. }
  10262. return *v, true
  10263. }
  10264. // ResetFrom resets all changes to the "from" field.
  10265. func (m *LabelMutation) ResetFrom() {
  10266. m.from = nil
  10267. m.addfrom = nil
  10268. }
  10269. // SetMode sets the "mode" field.
  10270. func (m *LabelMutation) SetMode(i int) {
  10271. m.mode = &i
  10272. m.addmode = nil
  10273. }
  10274. // Mode returns the value of the "mode" field in the mutation.
  10275. func (m *LabelMutation) Mode() (r int, exists bool) {
  10276. v := m.mode
  10277. if v == nil {
  10278. return
  10279. }
  10280. return *v, true
  10281. }
  10282. // OldMode returns the old "mode" field's value of the Label entity.
  10283. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10285. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  10286. if !m.op.Is(OpUpdateOne) {
  10287. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  10288. }
  10289. if m.id == nil || m.oldValue == nil {
  10290. return v, errors.New("OldMode requires an ID field in the mutation")
  10291. }
  10292. oldValue, err := m.oldValue(ctx)
  10293. if err != nil {
  10294. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  10295. }
  10296. return oldValue.Mode, nil
  10297. }
  10298. // AddMode adds i to the "mode" field.
  10299. func (m *LabelMutation) AddMode(i int) {
  10300. if m.addmode != nil {
  10301. *m.addmode += i
  10302. } else {
  10303. m.addmode = &i
  10304. }
  10305. }
  10306. // AddedMode returns the value that was added to the "mode" field in this mutation.
  10307. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  10308. v := m.addmode
  10309. if v == nil {
  10310. return
  10311. }
  10312. return *v, true
  10313. }
  10314. // ResetMode resets all changes to the "mode" field.
  10315. func (m *LabelMutation) ResetMode() {
  10316. m.mode = nil
  10317. m.addmode = nil
  10318. }
  10319. // SetConditions sets the "conditions" field.
  10320. func (m *LabelMutation) SetConditions(s string) {
  10321. m.conditions = &s
  10322. }
  10323. // Conditions returns the value of the "conditions" field in the mutation.
  10324. func (m *LabelMutation) Conditions() (r string, exists bool) {
  10325. v := m.conditions
  10326. if v == nil {
  10327. return
  10328. }
  10329. return *v, true
  10330. }
  10331. // OldConditions returns the old "conditions" field's value of the Label entity.
  10332. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10334. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  10335. if !m.op.Is(OpUpdateOne) {
  10336. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  10337. }
  10338. if m.id == nil || m.oldValue == nil {
  10339. return v, errors.New("OldConditions requires an ID field in the mutation")
  10340. }
  10341. oldValue, err := m.oldValue(ctx)
  10342. if err != nil {
  10343. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  10344. }
  10345. return oldValue.Conditions, nil
  10346. }
  10347. // ClearConditions clears the value of the "conditions" field.
  10348. func (m *LabelMutation) ClearConditions() {
  10349. m.conditions = nil
  10350. m.clearedFields[label.FieldConditions] = struct{}{}
  10351. }
  10352. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  10353. func (m *LabelMutation) ConditionsCleared() bool {
  10354. _, ok := m.clearedFields[label.FieldConditions]
  10355. return ok
  10356. }
  10357. // ResetConditions resets all changes to the "conditions" field.
  10358. func (m *LabelMutation) ResetConditions() {
  10359. m.conditions = nil
  10360. delete(m.clearedFields, label.FieldConditions)
  10361. }
  10362. // SetOrganizationID sets the "organization_id" field.
  10363. func (m *LabelMutation) SetOrganizationID(u uint64) {
  10364. m.organization_id = &u
  10365. m.addorganization_id = nil
  10366. }
  10367. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10368. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  10369. v := m.organization_id
  10370. if v == nil {
  10371. return
  10372. }
  10373. return *v, true
  10374. }
  10375. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  10376. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10378. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10379. if !m.op.Is(OpUpdateOne) {
  10380. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10381. }
  10382. if m.id == nil || m.oldValue == nil {
  10383. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10384. }
  10385. oldValue, err := m.oldValue(ctx)
  10386. if err != nil {
  10387. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10388. }
  10389. return oldValue.OrganizationID, nil
  10390. }
  10391. // AddOrganizationID adds u to the "organization_id" field.
  10392. func (m *LabelMutation) AddOrganizationID(u int64) {
  10393. if m.addorganization_id != nil {
  10394. *m.addorganization_id += u
  10395. } else {
  10396. m.addorganization_id = &u
  10397. }
  10398. }
  10399. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10400. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  10401. v := m.addorganization_id
  10402. if v == nil {
  10403. return
  10404. }
  10405. return *v, true
  10406. }
  10407. // ClearOrganizationID clears the value of the "organization_id" field.
  10408. func (m *LabelMutation) ClearOrganizationID() {
  10409. m.organization_id = nil
  10410. m.addorganization_id = nil
  10411. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  10412. }
  10413. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10414. func (m *LabelMutation) OrganizationIDCleared() bool {
  10415. _, ok := m.clearedFields[label.FieldOrganizationID]
  10416. return ok
  10417. }
  10418. // ResetOrganizationID resets all changes to the "organization_id" field.
  10419. func (m *LabelMutation) ResetOrganizationID() {
  10420. m.organization_id = nil
  10421. m.addorganization_id = nil
  10422. delete(m.clearedFields, label.FieldOrganizationID)
  10423. }
  10424. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  10425. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  10426. if m.label_relationships == nil {
  10427. m.label_relationships = make(map[uint64]struct{})
  10428. }
  10429. for i := range ids {
  10430. m.label_relationships[ids[i]] = struct{}{}
  10431. }
  10432. }
  10433. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  10434. func (m *LabelMutation) ClearLabelRelationships() {
  10435. m.clearedlabel_relationships = true
  10436. }
  10437. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  10438. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  10439. return m.clearedlabel_relationships
  10440. }
  10441. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  10442. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  10443. if m.removedlabel_relationships == nil {
  10444. m.removedlabel_relationships = make(map[uint64]struct{})
  10445. }
  10446. for i := range ids {
  10447. delete(m.label_relationships, ids[i])
  10448. m.removedlabel_relationships[ids[i]] = struct{}{}
  10449. }
  10450. }
  10451. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  10452. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  10453. for id := range m.removedlabel_relationships {
  10454. ids = append(ids, id)
  10455. }
  10456. return
  10457. }
  10458. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  10459. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  10460. for id := range m.label_relationships {
  10461. ids = append(ids, id)
  10462. }
  10463. return
  10464. }
  10465. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  10466. func (m *LabelMutation) ResetLabelRelationships() {
  10467. m.label_relationships = nil
  10468. m.clearedlabel_relationships = false
  10469. m.removedlabel_relationships = nil
  10470. }
  10471. // Where appends a list predicates to the LabelMutation builder.
  10472. func (m *LabelMutation) Where(ps ...predicate.Label) {
  10473. m.predicates = append(m.predicates, ps...)
  10474. }
  10475. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  10476. // users can use type-assertion to append predicates that do not depend on any generated package.
  10477. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  10478. p := make([]predicate.Label, len(ps))
  10479. for i := range ps {
  10480. p[i] = ps[i]
  10481. }
  10482. m.Where(p...)
  10483. }
  10484. // Op returns the operation name.
  10485. func (m *LabelMutation) Op() Op {
  10486. return m.op
  10487. }
  10488. // SetOp allows setting the mutation operation.
  10489. func (m *LabelMutation) SetOp(op Op) {
  10490. m.op = op
  10491. }
  10492. // Type returns the node type of this mutation (Label).
  10493. func (m *LabelMutation) Type() string {
  10494. return m.typ
  10495. }
  10496. // Fields returns all fields that were changed during this mutation. Note that in
  10497. // order to get all numeric fields that were incremented/decremented, call
  10498. // AddedFields().
  10499. func (m *LabelMutation) Fields() []string {
  10500. fields := make([]string, 0, 9)
  10501. if m.created_at != nil {
  10502. fields = append(fields, label.FieldCreatedAt)
  10503. }
  10504. if m.updated_at != nil {
  10505. fields = append(fields, label.FieldUpdatedAt)
  10506. }
  10507. if m.status != nil {
  10508. fields = append(fields, label.FieldStatus)
  10509. }
  10510. if m._type != nil {
  10511. fields = append(fields, label.FieldType)
  10512. }
  10513. if m.name != nil {
  10514. fields = append(fields, label.FieldName)
  10515. }
  10516. if m.from != nil {
  10517. fields = append(fields, label.FieldFrom)
  10518. }
  10519. if m.mode != nil {
  10520. fields = append(fields, label.FieldMode)
  10521. }
  10522. if m.conditions != nil {
  10523. fields = append(fields, label.FieldConditions)
  10524. }
  10525. if m.organization_id != nil {
  10526. fields = append(fields, label.FieldOrganizationID)
  10527. }
  10528. return fields
  10529. }
  10530. // Field returns the value of a field with the given name. The second boolean
  10531. // return value indicates that this field was not set, or was not defined in the
  10532. // schema.
  10533. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  10534. switch name {
  10535. case label.FieldCreatedAt:
  10536. return m.CreatedAt()
  10537. case label.FieldUpdatedAt:
  10538. return m.UpdatedAt()
  10539. case label.FieldStatus:
  10540. return m.Status()
  10541. case label.FieldType:
  10542. return m.GetType()
  10543. case label.FieldName:
  10544. return m.Name()
  10545. case label.FieldFrom:
  10546. return m.From()
  10547. case label.FieldMode:
  10548. return m.Mode()
  10549. case label.FieldConditions:
  10550. return m.Conditions()
  10551. case label.FieldOrganizationID:
  10552. return m.OrganizationID()
  10553. }
  10554. return nil, false
  10555. }
  10556. // OldField returns the old value of the field from the database. An error is
  10557. // returned if the mutation operation is not UpdateOne, or the query to the
  10558. // database failed.
  10559. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10560. switch name {
  10561. case label.FieldCreatedAt:
  10562. return m.OldCreatedAt(ctx)
  10563. case label.FieldUpdatedAt:
  10564. return m.OldUpdatedAt(ctx)
  10565. case label.FieldStatus:
  10566. return m.OldStatus(ctx)
  10567. case label.FieldType:
  10568. return m.OldType(ctx)
  10569. case label.FieldName:
  10570. return m.OldName(ctx)
  10571. case label.FieldFrom:
  10572. return m.OldFrom(ctx)
  10573. case label.FieldMode:
  10574. return m.OldMode(ctx)
  10575. case label.FieldConditions:
  10576. return m.OldConditions(ctx)
  10577. case label.FieldOrganizationID:
  10578. return m.OldOrganizationID(ctx)
  10579. }
  10580. return nil, fmt.Errorf("unknown Label field %s", name)
  10581. }
  10582. // SetField sets the value of a field with the given name. It returns an error if
  10583. // the field is not defined in the schema, or if the type mismatched the field
  10584. // type.
  10585. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  10586. switch name {
  10587. case label.FieldCreatedAt:
  10588. v, ok := value.(time.Time)
  10589. if !ok {
  10590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10591. }
  10592. m.SetCreatedAt(v)
  10593. return nil
  10594. case label.FieldUpdatedAt:
  10595. v, ok := value.(time.Time)
  10596. if !ok {
  10597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10598. }
  10599. m.SetUpdatedAt(v)
  10600. return nil
  10601. case label.FieldStatus:
  10602. v, ok := value.(uint8)
  10603. if !ok {
  10604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10605. }
  10606. m.SetStatus(v)
  10607. return nil
  10608. case label.FieldType:
  10609. v, ok := value.(int)
  10610. if !ok {
  10611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10612. }
  10613. m.SetType(v)
  10614. return nil
  10615. case label.FieldName:
  10616. v, ok := value.(string)
  10617. if !ok {
  10618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10619. }
  10620. m.SetName(v)
  10621. return nil
  10622. case label.FieldFrom:
  10623. v, ok := value.(int)
  10624. if !ok {
  10625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10626. }
  10627. m.SetFrom(v)
  10628. return nil
  10629. case label.FieldMode:
  10630. v, ok := value.(int)
  10631. if !ok {
  10632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10633. }
  10634. m.SetMode(v)
  10635. return nil
  10636. case label.FieldConditions:
  10637. v, ok := value.(string)
  10638. if !ok {
  10639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10640. }
  10641. m.SetConditions(v)
  10642. return nil
  10643. case label.FieldOrganizationID:
  10644. v, ok := value.(uint64)
  10645. if !ok {
  10646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10647. }
  10648. m.SetOrganizationID(v)
  10649. return nil
  10650. }
  10651. return fmt.Errorf("unknown Label field %s", name)
  10652. }
  10653. // AddedFields returns all numeric fields that were incremented/decremented during
  10654. // this mutation.
  10655. func (m *LabelMutation) AddedFields() []string {
  10656. var fields []string
  10657. if m.addstatus != nil {
  10658. fields = append(fields, label.FieldStatus)
  10659. }
  10660. if m.add_type != nil {
  10661. fields = append(fields, label.FieldType)
  10662. }
  10663. if m.addfrom != nil {
  10664. fields = append(fields, label.FieldFrom)
  10665. }
  10666. if m.addmode != nil {
  10667. fields = append(fields, label.FieldMode)
  10668. }
  10669. if m.addorganization_id != nil {
  10670. fields = append(fields, label.FieldOrganizationID)
  10671. }
  10672. return fields
  10673. }
  10674. // AddedField returns the numeric value that was incremented/decremented on a field
  10675. // with the given name. The second boolean return value indicates that this field
  10676. // was not set, or was not defined in the schema.
  10677. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  10678. switch name {
  10679. case label.FieldStatus:
  10680. return m.AddedStatus()
  10681. case label.FieldType:
  10682. return m.AddedType()
  10683. case label.FieldFrom:
  10684. return m.AddedFrom()
  10685. case label.FieldMode:
  10686. return m.AddedMode()
  10687. case label.FieldOrganizationID:
  10688. return m.AddedOrganizationID()
  10689. }
  10690. return nil, false
  10691. }
  10692. // AddField adds the value to the field with the given name. It returns an error if
  10693. // the field is not defined in the schema, or if the type mismatched the field
  10694. // type.
  10695. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  10696. switch name {
  10697. case label.FieldStatus:
  10698. v, ok := value.(int8)
  10699. if !ok {
  10700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10701. }
  10702. m.AddStatus(v)
  10703. return nil
  10704. case label.FieldType:
  10705. v, ok := value.(int)
  10706. if !ok {
  10707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10708. }
  10709. m.AddType(v)
  10710. return nil
  10711. case label.FieldFrom:
  10712. v, ok := value.(int)
  10713. if !ok {
  10714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10715. }
  10716. m.AddFrom(v)
  10717. return nil
  10718. case label.FieldMode:
  10719. v, ok := value.(int)
  10720. if !ok {
  10721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10722. }
  10723. m.AddMode(v)
  10724. return nil
  10725. case label.FieldOrganizationID:
  10726. v, ok := value.(int64)
  10727. if !ok {
  10728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10729. }
  10730. m.AddOrganizationID(v)
  10731. return nil
  10732. }
  10733. return fmt.Errorf("unknown Label numeric field %s", name)
  10734. }
  10735. // ClearedFields returns all nullable fields that were cleared during this
  10736. // mutation.
  10737. func (m *LabelMutation) ClearedFields() []string {
  10738. var fields []string
  10739. if m.FieldCleared(label.FieldStatus) {
  10740. fields = append(fields, label.FieldStatus)
  10741. }
  10742. if m.FieldCleared(label.FieldConditions) {
  10743. fields = append(fields, label.FieldConditions)
  10744. }
  10745. if m.FieldCleared(label.FieldOrganizationID) {
  10746. fields = append(fields, label.FieldOrganizationID)
  10747. }
  10748. return fields
  10749. }
  10750. // FieldCleared returns a boolean indicating if a field with the given name was
  10751. // cleared in this mutation.
  10752. func (m *LabelMutation) FieldCleared(name string) bool {
  10753. _, ok := m.clearedFields[name]
  10754. return ok
  10755. }
  10756. // ClearField clears the value of the field with the given name. It returns an
  10757. // error if the field is not defined in the schema.
  10758. func (m *LabelMutation) ClearField(name string) error {
  10759. switch name {
  10760. case label.FieldStatus:
  10761. m.ClearStatus()
  10762. return nil
  10763. case label.FieldConditions:
  10764. m.ClearConditions()
  10765. return nil
  10766. case label.FieldOrganizationID:
  10767. m.ClearOrganizationID()
  10768. return nil
  10769. }
  10770. return fmt.Errorf("unknown Label nullable field %s", name)
  10771. }
  10772. // ResetField resets all changes in the mutation for the field with the given name.
  10773. // It returns an error if the field is not defined in the schema.
  10774. func (m *LabelMutation) ResetField(name string) error {
  10775. switch name {
  10776. case label.FieldCreatedAt:
  10777. m.ResetCreatedAt()
  10778. return nil
  10779. case label.FieldUpdatedAt:
  10780. m.ResetUpdatedAt()
  10781. return nil
  10782. case label.FieldStatus:
  10783. m.ResetStatus()
  10784. return nil
  10785. case label.FieldType:
  10786. m.ResetType()
  10787. return nil
  10788. case label.FieldName:
  10789. m.ResetName()
  10790. return nil
  10791. case label.FieldFrom:
  10792. m.ResetFrom()
  10793. return nil
  10794. case label.FieldMode:
  10795. m.ResetMode()
  10796. return nil
  10797. case label.FieldConditions:
  10798. m.ResetConditions()
  10799. return nil
  10800. case label.FieldOrganizationID:
  10801. m.ResetOrganizationID()
  10802. return nil
  10803. }
  10804. return fmt.Errorf("unknown Label field %s", name)
  10805. }
  10806. // AddedEdges returns all edge names that were set/added in this mutation.
  10807. func (m *LabelMutation) AddedEdges() []string {
  10808. edges := make([]string, 0, 1)
  10809. if m.label_relationships != nil {
  10810. edges = append(edges, label.EdgeLabelRelationships)
  10811. }
  10812. return edges
  10813. }
  10814. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10815. // name in this mutation.
  10816. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  10817. switch name {
  10818. case label.EdgeLabelRelationships:
  10819. ids := make([]ent.Value, 0, len(m.label_relationships))
  10820. for id := range m.label_relationships {
  10821. ids = append(ids, id)
  10822. }
  10823. return ids
  10824. }
  10825. return nil
  10826. }
  10827. // RemovedEdges returns all edge names that were removed in this mutation.
  10828. func (m *LabelMutation) RemovedEdges() []string {
  10829. edges := make([]string, 0, 1)
  10830. if m.removedlabel_relationships != nil {
  10831. edges = append(edges, label.EdgeLabelRelationships)
  10832. }
  10833. return edges
  10834. }
  10835. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10836. // the given name in this mutation.
  10837. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  10838. switch name {
  10839. case label.EdgeLabelRelationships:
  10840. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  10841. for id := range m.removedlabel_relationships {
  10842. ids = append(ids, id)
  10843. }
  10844. return ids
  10845. }
  10846. return nil
  10847. }
  10848. // ClearedEdges returns all edge names that were cleared in this mutation.
  10849. func (m *LabelMutation) ClearedEdges() []string {
  10850. edges := make([]string, 0, 1)
  10851. if m.clearedlabel_relationships {
  10852. edges = append(edges, label.EdgeLabelRelationships)
  10853. }
  10854. return edges
  10855. }
  10856. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10857. // was cleared in this mutation.
  10858. func (m *LabelMutation) EdgeCleared(name string) bool {
  10859. switch name {
  10860. case label.EdgeLabelRelationships:
  10861. return m.clearedlabel_relationships
  10862. }
  10863. return false
  10864. }
  10865. // ClearEdge clears the value of the edge with the given name. It returns an error
  10866. // if that edge is not defined in the schema.
  10867. func (m *LabelMutation) ClearEdge(name string) error {
  10868. switch name {
  10869. }
  10870. return fmt.Errorf("unknown Label unique edge %s", name)
  10871. }
  10872. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10873. // It returns an error if the edge is not defined in the schema.
  10874. func (m *LabelMutation) ResetEdge(name string) error {
  10875. switch name {
  10876. case label.EdgeLabelRelationships:
  10877. m.ResetLabelRelationships()
  10878. return nil
  10879. }
  10880. return fmt.Errorf("unknown Label edge %s", name)
  10881. }
  10882. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  10883. type LabelRelationshipMutation struct {
  10884. config
  10885. op Op
  10886. typ string
  10887. id *uint64
  10888. created_at *time.Time
  10889. updated_at *time.Time
  10890. status *uint8
  10891. addstatus *int8
  10892. deleted_at *time.Time
  10893. organization_id *uint64
  10894. addorganization_id *int64
  10895. clearedFields map[string]struct{}
  10896. contacts *uint64
  10897. clearedcontacts bool
  10898. labels *uint64
  10899. clearedlabels bool
  10900. done bool
  10901. oldValue func(context.Context) (*LabelRelationship, error)
  10902. predicates []predicate.LabelRelationship
  10903. }
  10904. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  10905. // labelrelationshipOption allows management of the mutation configuration using functional options.
  10906. type labelrelationshipOption func(*LabelRelationshipMutation)
  10907. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  10908. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  10909. m := &LabelRelationshipMutation{
  10910. config: c,
  10911. op: op,
  10912. typ: TypeLabelRelationship,
  10913. clearedFields: make(map[string]struct{}),
  10914. }
  10915. for _, opt := range opts {
  10916. opt(m)
  10917. }
  10918. return m
  10919. }
  10920. // withLabelRelationshipID sets the ID field of the mutation.
  10921. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  10922. return func(m *LabelRelationshipMutation) {
  10923. var (
  10924. err error
  10925. once sync.Once
  10926. value *LabelRelationship
  10927. )
  10928. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  10929. once.Do(func() {
  10930. if m.done {
  10931. err = errors.New("querying old values post mutation is not allowed")
  10932. } else {
  10933. value, err = m.Client().LabelRelationship.Get(ctx, id)
  10934. }
  10935. })
  10936. return value, err
  10937. }
  10938. m.id = &id
  10939. }
  10940. }
  10941. // withLabelRelationship sets the old LabelRelationship of the mutation.
  10942. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  10943. return func(m *LabelRelationshipMutation) {
  10944. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  10945. return node, nil
  10946. }
  10947. m.id = &node.ID
  10948. }
  10949. }
  10950. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10951. // executed in a transaction (ent.Tx), a transactional client is returned.
  10952. func (m LabelRelationshipMutation) Client() *Client {
  10953. client := &Client{config: m.config}
  10954. client.init()
  10955. return client
  10956. }
  10957. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10958. // it returns an error otherwise.
  10959. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  10960. if _, ok := m.driver.(*txDriver); !ok {
  10961. return nil, errors.New("ent: mutation is not running in a transaction")
  10962. }
  10963. tx := &Tx{config: m.config}
  10964. tx.init()
  10965. return tx, nil
  10966. }
  10967. // SetID sets the value of the id field. Note that this
  10968. // operation is only accepted on creation of LabelRelationship entities.
  10969. func (m *LabelRelationshipMutation) SetID(id uint64) {
  10970. m.id = &id
  10971. }
  10972. // ID returns the ID value in the mutation. Note that the ID is only available
  10973. // if it was provided to the builder or after it was returned from the database.
  10974. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  10975. if m.id == nil {
  10976. return
  10977. }
  10978. return *m.id, true
  10979. }
  10980. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10981. // That means, if the mutation is applied within a transaction with an isolation level such
  10982. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10983. // or updated by the mutation.
  10984. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  10985. switch {
  10986. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10987. id, exists := m.ID()
  10988. if exists {
  10989. return []uint64{id}, nil
  10990. }
  10991. fallthrough
  10992. case m.op.Is(OpUpdate | OpDelete):
  10993. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  10994. default:
  10995. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10996. }
  10997. }
  10998. // SetCreatedAt sets the "created_at" field.
  10999. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  11000. m.created_at = &t
  11001. }
  11002. // CreatedAt returns the value of the "created_at" field in the mutation.
  11003. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  11004. v := m.created_at
  11005. if v == nil {
  11006. return
  11007. }
  11008. return *v, true
  11009. }
  11010. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  11011. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11013. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11014. if !m.op.Is(OpUpdateOne) {
  11015. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11016. }
  11017. if m.id == nil || m.oldValue == nil {
  11018. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11019. }
  11020. oldValue, err := m.oldValue(ctx)
  11021. if err != nil {
  11022. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11023. }
  11024. return oldValue.CreatedAt, nil
  11025. }
  11026. // ResetCreatedAt resets all changes to the "created_at" field.
  11027. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  11028. m.created_at = nil
  11029. }
  11030. // SetUpdatedAt sets the "updated_at" field.
  11031. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  11032. m.updated_at = &t
  11033. }
  11034. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11035. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  11036. v := m.updated_at
  11037. if v == nil {
  11038. return
  11039. }
  11040. return *v, true
  11041. }
  11042. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  11043. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11045. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11046. if !m.op.Is(OpUpdateOne) {
  11047. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11048. }
  11049. if m.id == nil || m.oldValue == nil {
  11050. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11051. }
  11052. oldValue, err := m.oldValue(ctx)
  11053. if err != nil {
  11054. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11055. }
  11056. return oldValue.UpdatedAt, nil
  11057. }
  11058. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11059. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  11060. m.updated_at = nil
  11061. }
  11062. // SetStatus sets the "status" field.
  11063. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  11064. m.status = &u
  11065. m.addstatus = nil
  11066. }
  11067. // Status returns the value of the "status" field in the mutation.
  11068. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  11069. v := m.status
  11070. if v == nil {
  11071. return
  11072. }
  11073. return *v, true
  11074. }
  11075. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  11076. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11078. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11079. if !m.op.Is(OpUpdateOne) {
  11080. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11081. }
  11082. if m.id == nil || m.oldValue == nil {
  11083. return v, errors.New("OldStatus requires an ID field in the mutation")
  11084. }
  11085. oldValue, err := m.oldValue(ctx)
  11086. if err != nil {
  11087. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11088. }
  11089. return oldValue.Status, nil
  11090. }
  11091. // AddStatus adds u to the "status" field.
  11092. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  11093. if m.addstatus != nil {
  11094. *m.addstatus += u
  11095. } else {
  11096. m.addstatus = &u
  11097. }
  11098. }
  11099. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11100. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  11101. v := m.addstatus
  11102. if v == nil {
  11103. return
  11104. }
  11105. return *v, true
  11106. }
  11107. // ClearStatus clears the value of the "status" field.
  11108. func (m *LabelRelationshipMutation) ClearStatus() {
  11109. m.status = nil
  11110. m.addstatus = nil
  11111. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  11112. }
  11113. // StatusCleared returns if the "status" field was cleared in this mutation.
  11114. func (m *LabelRelationshipMutation) StatusCleared() bool {
  11115. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  11116. return ok
  11117. }
  11118. // ResetStatus resets all changes to the "status" field.
  11119. func (m *LabelRelationshipMutation) ResetStatus() {
  11120. m.status = nil
  11121. m.addstatus = nil
  11122. delete(m.clearedFields, labelrelationship.FieldStatus)
  11123. }
  11124. // SetDeletedAt sets the "deleted_at" field.
  11125. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  11126. m.deleted_at = &t
  11127. }
  11128. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11129. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  11130. v := m.deleted_at
  11131. if v == nil {
  11132. return
  11133. }
  11134. return *v, true
  11135. }
  11136. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  11137. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11139. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11140. if !m.op.Is(OpUpdateOne) {
  11141. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11142. }
  11143. if m.id == nil || m.oldValue == nil {
  11144. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11145. }
  11146. oldValue, err := m.oldValue(ctx)
  11147. if err != nil {
  11148. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11149. }
  11150. return oldValue.DeletedAt, nil
  11151. }
  11152. // ClearDeletedAt clears the value of the "deleted_at" field.
  11153. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  11154. m.deleted_at = nil
  11155. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  11156. }
  11157. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11158. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  11159. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  11160. return ok
  11161. }
  11162. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11163. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  11164. m.deleted_at = nil
  11165. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  11166. }
  11167. // SetLabelID sets the "label_id" field.
  11168. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  11169. m.labels = &u
  11170. }
  11171. // LabelID returns the value of the "label_id" field in the mutation.
  11172. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  11173. v := m.labels
  11174. if v == nil {
  11175. return
  11176. }
  11177. return *v, true
  11178. }
  11179. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  11180. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11182. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  11183. if !m.op.Is(OpUpdateOne) {
  11184. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  11185. }
  11186. if m.id == nil || m.oldValue == nil {
  11187. return v, errors.New("OldLabelID requires an ID field in the mutation")
  11188. }
  11189. oldValue, err := m.oldValue(ctx)
  11190. if err != nil {
  11191. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  11192. }
  11193. return oldValue.LabelID, nil
  11194. }
  11195. // ResetLabelID resets all changes to the "label_id" field.
  11196. func (m *LabelRelationshipMutation) ResetLabelID() {
  11197. m.labels = nil
  11198. }
  11199. // SetContactID sets the "contact_id" field.
  11200. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  11201. m.contacts = &u
  11202. }
  11203. // ContactID returns the value of the "contact_id" field in the mutation.
  11204. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  11205. v := m.contacts
  11206. if v == nil {
  11207. return
  11208. }
  11209. return *v, true
  11210. }
  11211. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  11212. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11214. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  11215. if !m.op.Is(OpUpdateOne) {
  11216. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  11217. }
  11218. if m.id == nil || m.oldValue == nil {
  11219. return v, errors.New("OldContactID requires an ID field in the mutation")
  11220. }
  11221. oldValue, err := m.oldValue(ctx)
  11222. if err != nil {
  11223. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  11224. }
  11225. return oldValue.ContactID, nil
  11226. }
  11227. // ResetContactID resets all changes to the "contact_id" field.
  11228. func (m *LabelRelationshipMutation) ResetContactID() {
  11229. m.contacts = nil
  11230. }
  11231. // SetOrganizationID sets the "organization_id" field.
  11232. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  11233. m.organization_id = &u
  11234. m.addorganization_id = nil
  11235. }
  11236. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11237. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  11238. v := m.organization_id
  11239. if v == nil {
  11240. return
  11241. }
  11242. return *v, true
  11243. }
  11244. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  11245. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11247. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11248. if !m.op.Is(OpUpdateOne) {
  11249. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11250. }
  11251. if m.id == nil || m.oldValue == nil {
  11252. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11253. }
  11254. oldValue, err := m.oldValue(ctx)
  11255. if err != nil {
  11256. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11257. }
  11258. return oldValue.OrganizationID, nil
  11259. }
  11260. // AddOrganizationID adds u to the "organization_id" field.
  11261. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  11262. if m.addorganization_id != nil {
  11263. *m.addorganization_id += u
  11264. } else {
  11265. m.addorganization_id = &u
  11266. }
  11267. }
  11268. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11269. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  11270. v := m.addorganization_id
  11271. if v == nil {
  11272. return
  11273. }
  11274. return *v, true
  11275. }
  11276. // ClearOrganizationID clears the value of the "organization_id" field.
  11277. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  11278. m.organization_id = nil
  11279. m.addorganization_id = nil
  11280. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  11281. }
  11282. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11283. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  11284. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  11285. return ok
  11286. }
  11287. // ResetOrganizationID resets all changes to the "organization_id" field.
  11288. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  11289. m.organization_id = nil
  11290. m.addorganization_id = nil
  11291. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  11292. }
  11293. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  11294. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  11295. m.contacts = &id
  11296. }
  11297. // ClearContacts clears the "contacts" edge to the Contact entity.
  11298. func (m *LabelRelationshipMutation) ClearContacts() {
  11299. m.clearedcontacts = true
  11300. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  11301. }
  11302. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  11303. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  11304. return m.clearedcontacts
  11305. }
  11306. // ContactsID returns the "contacts" edge ID in the mutation.
  11307. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  11308. if m.contacts != nil {
  11309. return *m.contacts, true
  11310. }
  11311. return
  11312. }
  11313. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  11314. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11315. // ContactsID instead. It exists only for internal usage by the builders.
  11316. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  11317. if id := m.contacts; id != nil {
  11318. ids = append(ids, *id)
  11319. }
  11320. return
  11321. }
  11322. // ResetContacts resets all changes to the "contacts" edge.
  11323. func (m *LabelRelationshipMutation) ResetContacts() {
  11324. m.contacts = nil
  11325. m.clearedcontacts = false
  11326. }
  11327. // SetLabelsID sets the "labels" edge to the Label entity by id.
  11328. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  11329. m.labels = &id
  11330. }
  11331. // ClearLabels clears the "labels" edge to the Label entity.
  11332. func (m *LabelRelationshipMutation) ClearLabels() {
  11333. m.clearedlabels = true
  11334. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  11335. }
  11336. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  11337. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  11338. return m.clearedlabels
  11339. }
  11340. // LabelsID returns the "labels" edge ID in the mutation.
  11341. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  11342. if m.labels != nil {
  11343. return *m.labels, true
  11344. }
  11345. return
  11346. }
  11347. // LabelsIDs returns the "labels" edge IDs in the mutation.
  11348. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11349. // LabelsID instead. It exists only for internal usage by the builders.
  11350. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  11351. if id := m.labels; id != nil {
  11352. ids = append(ids, *id)
  11353. }
  11354. return
  11355. }
  11356. // ResetLabels resets all changes to the "labels" edge.
  11357. func (m *LabelRelationshipMutation) ResetLabels() {
  11358. m.labels = nil
  11359. m.clearedlabels = false
  11360. }
  11361. // Where appends a list predicates to the LabelRelationshipMutation builder.
  11362. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  11363. m.predicates = append(m.predicates, ps...)
  11364. }
  11365. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  11366. // users can use type-assertion to append predicates that do not depend on any generated package.
  11367. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  11368. p := make([]predicate.LabelRelationship, len(ps))
  11369. for i := range ps {
  11370. p[i] = ps[i]
  11371. }
  11372. m.Where(p...)
  11373. }
  11374. // Op returns the operation name.
  11375. func (m *LabelRelationshipMutation) Op() Op {
  11376. return m.op
  11377. }
  11378. // SetOp allows setting the mutation operation.
  11379. func (m *LabelRelationshipMutation) SetOp(op Op) {
  11380. m.op = op
  11381. }
  11382. // Type returns the node type of this mutation (LabelRelationship).
  11383. func (m *LabelRelationshipMutation) Type() string {
  11384. return m.typ
  11385. }
  11386. // Fields returns all fields that were changed during this mutation. Note that in
  11387. // order to get all numeric fields that were incremented/decremented, call
  11388. // AddedFields().
  11389. func (m *LabelRelationshipMutation) Fields() []string {
  11390. fields := make([]string, 0, 7)
  11391. if m.created_at != nil {
  11392. fields = append(fields, labelrelationship.FieldCreatedAt)
  11393. }
  11394. if m.updated_at != nil {
  11395. fields = append(fields, labelrelationship.FieldUpdatedAt)
  11396. }
  11397. if m.status != nil {
  11398. fields = append(fields, labelrelationship.FieldStatus)
  11399. }
  11400. if m.deleted_at != nil {
  11401. fields = append(fields, labelrelationship.FieldDeletedAt)
  11402. }
  11403. if m.labels != nil {
  11404. fields = append(fields, labelrelationship.FieldLabelID)
  11405. }
  11406. if m.contacts != nil {
  11407. fields = append(fields, labelrelationship.FieldContactID)
  11408. }
  11409. if m.organization_id != nil {
  11410. fields = append(fields, labelrelationship.FieldOrganizationID)
  11411. }
  11412. return fields
  11413. }
  11414. // Field returns the value of a field with the given name. The second boolean
  11415. // return value indicates that this field was not set, or was not defined in the
  11416. // schema.
  11417. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  11418. switch name {
  11419. case labelrelationship.FieldCreatedAt:
  11420. return m.CreatedAt()
  11421. case labelrelationship.FieldUpdatedAt:
  11422. return m.UpdatedAt()
  11423. case labelrelationship.FieldStatus:
  11424. return m.Status()
  11425. case labelrelationship.FieldDeletedAt:
  11426. return m.DeletedAt()
  11427. case labelrelationship.FieldLabelID:
  11428. return m.LabelID()
  11429. case labelrelationship.FieldContactID:
  11430. return m.ContactID()
  11431. case labelrelationship.FieldOrganizationID:
  11432. return m.OrganizationID()
  11433. }
  11434. return nil, false
  11435. }
  11436. // OldField returns the old value of the field from the database. An error is
  11437. // returned if the mutation operation is not UpdateOne, or the query to the
  11438. // database failed.
  11439. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11440. switch name {
  11441. case labelrelationship.FieldCreatedAt:
  11442. return m.OldCreatedAt(ctx)
  11443. case labelrelationship.FieldUpdatedAt:
  11444. return m.OldUpdatedAt(ctx)
  11445. case labelrelationship.FieldStatus:
  11446. return m.OldStatus(ctx)
  11447. case labelrelationship.FieldDeletedAt:
  11448. return m.OldDeletedAt(ctx)
  11449. case labelrelationship.FieldLabelID:
  11450. return m.OldLabelID(ctx)
  11451. case labelrelationship.FieldContactID:
  11452. return m.OldContactID(ctx)
  11453. case labelrelationship.FieldOrganizationID:
  11454. return m.OldOrganizationID(ctx)
  11455. }
  11456. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  11457. }
  11458. // SetField sets the value of a field with the given name. It returns an error if
  11459. // the field is not defined in the schema, or if the type mismatched the field
  11460. // type.
  11461. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  11462. switch name {
  11463. case labelrelationship.FieldCreatedAt:
  11464. v, ok := value.(time.Time)
  11465. if !ok {
  11466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11467. }
  11468. m.SetCreatedAt(v)
  11469. return nil
  11470. case labelrelationship.FieldUpdatedAt:
  11471. v, ok := value.(time.Time)
  11472. if !ok {
  11473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11474. }
  11475. m.SetUpdatedAt(v)
  11476. return nil
  11477. case labelrelationship.FieldStatus:
  11478. v, ok := value.(uint8)
  11479. if !ok {
  11480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11481. }
  11482. m.SetStatus(v)
  11483. return nil
  11484. case labelrelationship.FieldDeletedAt:
  11485. v, ok := value.(time.Time)
  11486. if !ok {
  11487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11488. }
  11489. m.SetDeletedAt(v)
  11490. return nil
  11491. case labelrelationship.FieldLabelID:
  11492. v, ok := value.(uint64)
  11493. if !ok {
  11494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11495. }
  11496. m.SetLabelID(v)
  11497. return nil
  11498. case labelrelationship.FieldContactID:
  11499. v, ok := value.(uint64)
  11500. if !ok {
  11501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11502. }
  11503. m.SetContactID(v)
  11504. return nil
  11505. case labelrelationship.FieldOrganizationID:
  11506. v, ok := value.(uint64)
  11507. if !ok {
  11508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11509. }
  11510. m.SetOrganizationID(v)
  11511. return nil
  11512. }
  11513. return fmt.Errorf("unknown LabelRelationship field %s", name)
  11514. }
  11515. // AddedFields returns all numeric fields that were incremented/decremented during
  11516. // this mutation.
  11517. func (m *LabelRelationshipMutation) AddedFields() []string {
  11518. var fields []string
  11519. if m.addstatus != nil {
  11520. fields = append(fields, labelrelationship.FieldStatus)
  11521. }
  11522. if m.addorganization_id != nil {
  11523. fields = append(fields, labelrelationship.FieldOrganizationID)
  11524. }
  11525. return fields
  11526. }
  11527. // AddedField returns the numeric value that was incremented/decremented on a field
  11528. // with the given name. The second boolean return value indicates that this field
  11529. // was not set, or was not defined in the schema.
  11530. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  11531. switch name {
  11532. case labelrelationship.FieldStatus:
  11533. return m.AddedStatus()
  11534. case labelrelationship.FieldOrganizationID:
  11535. return m.AddedOrganizationID()
  11536. }
  11537. return nil, false
  11538. }
  11539. // AddField adds the value to the field with the given name. It returns an error if
  11540. // the field is not defined in the schema, or if the type mismatched the field
  11541. // type.
  11542. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  11543. switch name {
  11544. case labelrelationship.FieldStatus:
  11545. v, ok := value.(int8)
  11546. if !ok {
  11547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11548. }
  11549. m.AddStatus(v)
  11550. return nil
  11551. case labelrelationship.FieldOrganizationID:
  11552. v, ok := value.(int64)
  11553. if !ok {
  11554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11555. }
  11556. m.AddOrganizationID(v)
  11557. return nil
  11558. }
  11559. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  11560. }
  11561. // ClearedFields returns all nullable fields that were cleared during this
  11562. // mutation.
  11563. func (m *LabelRelationshipMutation) ClearedFields() []string {
  11564. var fields []string
  11565. if m.FieldCleared(labelrelationship.FieldStatus) {
  11566. fields = append(fields, labelrelationship.FieldStatus)
  11567. }
  11568. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  11569. fields = append(fields, labelrelationship.FieldDeletedAt)
  11570. }
  11571. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  11572. fields = append(fields, labelrelationship.FieldOrganizationID)
  11573. }
  11574. return fields
  11575. }
  11576. // FieldCleared returns a boolean indicating if a field with the given name was
  11577. // cleared in this mutation.
  11578. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  11579. _, ok := m.clearedFields[name]
  11580. return ok
  11581. }
  11582. // ClearField clears the value of the field with the given name. It returns an
  11583. // error if the field is not defined in the schema.
  11584. func (m *LabelRelationshipMutation) ClearField(name string) error {
  11585. switch name {
  11586. case labelrelationship.FieldStatus:
  11587. m.ClearStatus()
  11588. return nil
  11589. case labelrelationship.FieldDeletedAt:
  11590. m.ClearDeletedAt()
  11591. return nil
  11592. case labelrelationship.FieldOrganizationID:
  11593. m.ClearOrganizationID()
  11594. return nil
  11595. }
  11596. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  11597. }
  11598. // ResetField resets all changes in the mutation for the field with the given name.
  11599. // It returns an error if the field is not defined in the schema.
  11600. func (m *LabelRelationshipMutation) ResetField(name string) error {
  11601. switch name {
  11602. case labelrelationship.FieldCreatedAt:
  11603. m.ResetCreatedAt()
  11604. return nil
  11605. case labelrelationship.FieldUpdatedAt:
  11606. m.ResetUpdatedAt()
  11607. return nil
  11608. case labelrelationship.FieldStatus:
  11609. m.ResetStatus()
  11610. return nil
  11611. case labelrelationship.FieldDeletedAt:
  11612. m.ResetDeletedAt()
  11613. return nil
  11614. case labelrelationship.FieldLabelID:
  11615. m.ResetLabelID()
  11616. return nil
  11617. case labelrelationship.FieldContactID:
  11618. m.ResetContactID()
  11619. return nil
  11620. case labelrelationship.FieldOrganizationID:
  11621. m.ResetOrganizationID()
  11622. return nil
  11623. }
  11624. return fmt.Errorf("unknown LabelRelationship field %s", name)
  11625. }
  11626. // AddedEdges returns all edge names that were set/added in this mutation.
  11627. func (m *LabelRelationshipMutation) AddedEdges() []string {
  11628. edges := make([]string, 0, 2)
  11629. if m.contacts != nil {
  11630. edges = append(edges, labelrelationship.EdgeContacts)
  11631. }
  11632. if m.labels != nil {
  11633. edges = append(edges, labelrelationship.EdgeLabels)
  11634. }
  11635. return edges
  11636. }
  11637. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11638. // name in this mutation.
  11639. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  11640. switch name {
  11641. case labelrelationship.EdgeContacts:
  11642. if id := m.contacts; id != nil {
  11643. return []ent.Value{*id}
  11644. }
  11645. case labelrelationship.EdgeLabels:
  11646. if id := m.labels; id != nil {
  11647. return []ent.Value{*id}
  11648. }
  11649. }
  11650. return nil
  11651. }
  11652. // RemovedEdges returns all edge names that were removed in this mutation.
  11653. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  11654. edges := make([]string, 0, 2)
  11655. return edges
  11656. }
  11657. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11658. // the given name in this mutation.
  11659. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  11660. return nil
  11661. }
  11662. // ClearedEdges returns all edge names that were cleared in this mutation.
  11663. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  11664. edges := make([]string, 0, 2)
  11665. if m.clearedcontacts {
  11666. edges = append(edges, labelrelationship.EdgeContacts)
  11667. }
  11668. if m.clearedlabels {
  11669. edges = append(edges, labelrelationship.EdgeLabels)
  11670. }
  11671. return edges
  11672. }
  11673. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11674. // was cleared in this mutation.
  11675. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  11676. switch name {
  11677. case labelrelationship.EdgeContacts:
  11678. return m.clearedcontacts
  11679. case labelrelationship.EdgeLabels:
  11680. return m.clearedlabels
  11681. }
  11682. return false
  11683. }
  11684. // ClearEdge clears the value of the edge with the given name. It returns an error
  11685. // if that edge is not defined in the schema.
  11686. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  11687. switch name {
  11688. case labelrelationship.EdgeContacts:
  11689. m.ClearContacts()
  11690. return nil
  11691. case labelrelationship.EdgeLabels:
  11692. m.ClearLabels()
  11693. return nil
  11694. }
  11695. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  11696. }
  11697. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11698. // It returns an error if the edge is not defined in the schema.
  11699. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  11700. switch name {
  11701. case labelrelationship.EdgeContacts:
  11702. m.ResetContacts()
  11703. return nil
  11704. case labelrelationship.EdgeLabels:
  11705. m.ResetLabels()
  11706. return nil
  11707. }
  11708. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  11709. }
  11710. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  11711. type MessageMutation struct {
  11712. config
  11713. op Op
  11714. typ string
  11715. id *int
  11716. wx_wxid *string
  11717. wxid *string
  11718. content *string
  11719. clearedFields map[string]struct{}
  11720. done bool
  11721. oldValue func(context.Context) (*Message, error)
  11722. predicates []predicate.Message
  11723. }
  11724. var _ ent.Mutation = (*MessageMutation)(nil)
  11725. // messageOption allows management of the mutation configuration using functional options.
  11726. type messageOption func(*MessageMutation)
  11727. // newMessageMutation creates new mutation for the Message entity.
  11728. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  11729. m := &MessageMutation{
  11730. config: c,
  11731. op: op,
  11732. typ: TypeMessage,
  11733. clearedFields: make(map[string]struct{}),
  11734. }
  11735. for _, opt := range opts {
  11736. opt(m)
  11737. }
  11738. return m
  11739. }
  11740. // withMessageID sets the ID field of the mutation.
  11741. func withMessageID(id int) messageOption {
  11742. return func(m *MessageMutation) {
  11743. var (
  11744. err error
  11745. once sync.Once
  11746. value *Message
  11747. )
  11748. m.oldValue = func(ctx context.Context) (*Message, error) {
  11749. once.Do(func() {
  11750. if m.done {
  11751. err = errors.New("querying old values post mutation is not allowed")
  11752. } else {
  11753. value, err = m.Client().Message.Get(ctx, id)
  11754. }
  11755. })
  11756. return value, err
  11757. }
  11758. m.id = &id
  11759. }
  11760. }
  11761. // withMessage sets the old Message of the mutation.
  11762. func withMessage(node *Message) messageOption {
  11763. return func(m *MessageMutation) {
  11764. m.oldValue = func(context.Context) (*Message, error) {
  11765. return node, nil
  11766. }
  11767. m.id = &node.ID
  11768. }
  11769. }
  11770. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11771. // executed in a transaction (ent.Tx), a transactional client is returned.
  11772. func (m MessageMutation) Client() *Client {
  11773. client := &Client{config: m.config}
  11774. client.init()
  11775. return client
  11776. }
  11777. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11778. // it returns an error otherwise.
  11779. func (m MessageMutation) Tx() (*Tx, error) {
  11780. if _, ok := m.driver.(*txDriver); !ok {
  11781. return nil, errors.New("ent: mutation is not running in a transaction")
  11782. }
  11783. tx := &Tx{config: m.config}
  11784. tx.init()
  11785. return tx, nil
  11786. }
  11787. // ID returns the ID value in the mutation. Note that the ID is only available
  11788. // if it was provided to the builder or after it was returned from the database.
  11789. func (m *MessageMutation) ID() (id int, exists bool) {
  11790. if m.id == nil {
  11791. return
  11792. }
  11793. return *m.id, true
  11794. }
  11795. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11796. // That means, if the mutation is applied within a transaction with an isolation level such
  11797. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11798. // or updated by the mutation.
  11799. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  11800. switch {
  11801. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11802. id, exists := m.ID()
  11803. if exists {
  11804. return []int{id}, nil
  11805. }
  11806. fallthrough
  11807. case m.op.Is(OpUpdate | OpDelete):
  11808. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  11809. default:
  11810. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11811. }
  11812. }
  11813. // SetWxWxid sets the "wx_wxid" field.
  11814. func (m *MessageMutation) SetWxWxid(s string) {
  11815. m.wx_wxid = &s
  11816. }
  11817. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  11818. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  11819. v := m.wx_wxid
  11820. if v == nil {
  11821. return
  11822. }
  11823. return *v, true
  11824. }
  11825. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  11826. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  11827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11828. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  11829. if !m.op.Is(OpUpdateOne) {
  11830. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  11831. }
  11832. if m.id == nil || m.oldValue == nil {
  11833. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  11834. }
  11835. oldValue, err := m.oldValue(ctx)
  11836. if err != nil {
  11837. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  11838. }
  11839. return oldValue.WxWxid, nil
  11840. }
  11841. // ClearWxWxid clears the value of the "wx_wxid" field.
  11842. func (m *MessageMutation) ClearWxWxid() {
  11843. m.wx_wxid = nil
  11844. m.clearedFields[message.FieldWxWxid] = struct{}{}
  11845. }
  11846. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  11847. func (m *MessageMutation) WxWxidCleared() bool {
  11848. _, ok := m.clearedFields[message.FieldWxWxid]
  11849. return ok
  11850. }
  11851. // ResetWxWxid resets all changes to the "wx_wxid" field.
  11852. func (m *MessageMutation) ResetWxWxid() {
  11853. m.wx_wxid = nil
  11854. delete(m.clearedFields, message.FieldWxWxid)
  11855. }
  11856. // SetWxid sets the "wxid" field.
  11857. func (m *MessageMutation) SetWxid(s string) {
  11858. m.wxid = &s
  11859. }
  11860. // Wxid returns the value of the "wxid" field in the mutation.
  11861. func (m *MessageMutation) Wxid() (r string, exists bool) {
  11862. v := m.wxid
  11863. if v == nil {
  11864. return
  11865. }
  11866. return *v, true
  11867. }
  11868. // OldWxid returns the old "wxid" field's value of the Message entity.
  11869. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  11870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11871. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  11872. if !m.op.Is(OpUpdateOne) {
  11873. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  11874. }
  11875. if m.id == nil || m.oldValue == nil {
  11876. return v, errors.New("OldWxid requires an ID field in the mutation")
  11877. }
  11878. oldValue, err := m.oldValue(ctx)
  11879. if err != nil {
  11880. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  11881. }
  11882. return oldValue.Wxid, nil
  11883. }
  11884. // ResetWxid resets all changes to the "wxid" field.
  11885. func (m *MessageMutation) ResetWxid() {
  11886. m.wxid = nil
  11887. }
  11888. // SetContent sets the "content" field.
  11889. func (m *MessageMutation) SetContent(s string) {
  11890. m.content = &s
  11891. }
  11892. // Content returns the value of the "content" field in the mutation.
  11893. func (m *MessageMutation) Content() (r string, exists bool) {
  11894. v := m.content
  11895. if v == nil {
  11896. return
  11897. }
  11898. return *v, true
  11899. }
  11900. // OldContent returns the old "content" field's value of the Message entity.
  11901. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  11902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11903. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  11904. if !m.op.Is(OpUpdateOne) {
  11905. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  11906. }
  11907. if m.id == nil || m.oldValue == nil {
  11908. return v, errors.New("OldContent requires an ID field in the mutation")
  11909. }
  11910. oldValue, err := m.oldValue(ctx)
  11911. if err != nil {
  11912. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  11913. }
  11914. return oldValue.Content, nil
  11915. }
  11916. // ResetContent resets all changes to the "content" field.
  11917. func (m *MessageMutation) ResetContent() {
  11918. m.content = nil
  11919. }
  11920. // Where appends a list predicates to the MessageMutation builder.
  11921. func (m *MessageMutation) Where(ps ...predicate.Message) {
  11922. m.predicates = append(m.predicates, ps...)
  11923. }
  11924. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  11925. // users can use type-assertion to append predicates that do not depend on any generated package.
  11926. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  11927. p := make([]predicate.Message, len(ps))
  11928. for i := range ps {
  11929. p[i] = ps[i]
  11930. }
  11931. m.Where(p...)
  11932. }
  11933. // Op returns the operation name.
  11934. func (m *MessageMutation) Op() Op {
  11935. return m.op
  11936. }
  11937. // SetOp allows setting the mutation operation.
  11938. func (m *MessageMutation) SetOp(op Op) {
  11939. m.op = op
  11940. }
  11941. // Type returns the node type of this mutation (Message).
  11942. func (m *MessageMutation) Type() string {
  11943. return m.typ
  11944. }
  11945. // Fields returns all fields that were changed during this mutation. Note that in
  11946. // order to get all numeric fields that were incremented/decremented, call
  11947. // AddedFields().
  11948. func (m *MessageMutation) Fields() []string {
  11949. fields := make([]string, 0, 3)
  11950. if m.wx_wxid != nil {
  11951. fields = append(fields, message.FieldWxWxid)
  11952. }
  11953. if m.wxid != nil {
  11954. fields = append(fields, message.FieldWxid)
  11955. }
  11956. if m.content != nil {
  11957. fields = append(fields, message.FieldContent)
  11958. }
  11959. return fields
  11960. }
  11961. // Field returns the value of a field with the given name. The second boolean
  11962. // return value indicates that this field was not set, or was not defined in the
  11963. // schema.
  11964. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  11965. switch name {
  11966. case message.FieldWxWxid:
  11967. return m.WxWxid()
  11968. case message.FieldWxid:
  11969. return m.Wxid()
  11970. case message.FieldContent:
  11971. return m.Content()
  11972. }
  11973. return nil, false
  11974. }
  11975. // OldField returns the old value of the field from the database. An error is
  11976. // returned if the mutation operation is not UpdateOne, or the query to the
  11977. // database failed.
  11978. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11979. switch name {
  11980. case message.FieldWxWxid:
  11981. return m.OldWxWxid(ctx)
  11982. case message.FieldWxid:
  11983. return m.OldWxid(ctx)
  11984. case message.FieldContent:
  11985. return m.OldContent(ctx)
  11986. }
  11987. return nil, fmt.Errorf("unknown Message field %s", name)
  11988. }
  11989. // SetField sets the value of a field with the given name. It returns an error if
  11990. // the field is not defined in the schema, or if the type mismatched the field
  11991. // type.
  11992. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  11993. switch name {
  11994. case message.FieldWxWxid:
  11995. v, ok := value.(string)
  11996. if !ok {
  11997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11998. }
  11999. m.SetWxWxid(v)
  12000. return nil
  12001. case message.FieldWxid:
  12002. v, ok := value.(string)
  12003. if !ok {
  12004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12005. }
  12006. m.SetWxid(v)
  12007. return nil
  12008. case message.FieldContent:
  12009. v, ok := value.(string)
  12010. if !ok {
  12011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12012. }
  12013. m.SetContent(v)
  12014. return nil
  12015. }
  12016. return fmt.Errorf("unknown Message field %s", name)
  12017. }
  12018. // AddedFields returns all numeric fields that were incremented/decremented during
  12019. // this mutation.
  12020. func (m *MessageMutation) AddedFields() []string {
  12021. return nil
  12022. }
  12023. // AddedField returns the numeric value that was incremented/decremented on a field
  12024. // with the given name. The second boolean return value indicates that this field
  12025. // was not set, or was not defined in the schema.
  12026. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  12027. return nil, false
  12028. }
  12029. // AddField adds the value to the field with the given name. It returns an error if
  12030. // the field is not defined in the schema, or if the type mismatched the field
  12031. // type.
  12032. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  12033. switch name {
  12034. }
  12035. return fmt.Errorf("unknown Message numeric field %s", name)
  12036. }
  12037. // ClearedFields returns all nullable fields that were cleared during this
  12038. // mutation.
  12039. func (m *MessageMutation) ClearedFields() []string {
  12040. var fields []string
  12041. if m.FieldCleared(message.FieldWxWxid) {
  12042. fields = append(fields, message.FieldWxWxid)
  12043. }
  12044. return fields
  12045. }
  12046. // FieldCleared returns a boolean indicating if a field with the given name was
  12047. // cleared in this mutation.
  12048. func (m *MessageMutation) FieldCleared(name string) bool {
  12049. _, ok := m.clearedFields[name]
  12050. return ok
  12051. }
  12052. // ClearField clears the value of the field with the given name. It returns an
  12053. // error if the field is not defined in the schema.
  12054. func (m *MessageMutation) ClearField(name string) error {
  12055. switch name {
  12056. case message.FieldWxWxid:
  12057. m.ClearWxWxid()
  12058. return nil
  12059. }
  12060. return fmt.Errorf("unknown Message nullable field %s", name)
  12061. }
  12062. // ResetField resets all changes in the mutation for the field with the given name.
  12063. // It returns an error if the field is not defined in the schema.
  12064. func (m *MessageMutation) ResetField(name string) error {
  12065. switch name {
  12066. case message.FieldWxWxid:
  12067. m.ResetWxWxid()
  12068. return nil
  12069. case message.FieldWxid:
  12070. m.ResetWxid()
  12071. return nil
  12072. case message.FieldContent:
  12073. m.ResetContent()
  12074. return nil
  12075. }
  12076. return fmt.Errorf("unknown Message field %s", name)
  12077. }
  12078. // AddedEdges returns all edge names that were set/added in this mutation.
  12079. func (m *MessageMutation) AddedEdges() []string {
  12080. edges := make([]string, 0, 0)
  12081. return edges
  12082. }
  12083. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12084. // name in this mutation.
  12085. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  12086. return nil
  12087. }
  12088. // RemovedEdges returns all edge names that were removed in this mutation.
  12089. func (m *MessageMutation) RemovedEdges() []string {
  12090. edges := make([]string, 0, 0)
  12091. return edges
  12092. }
  12093. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12094. // the given name in this mutation.
  12095. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  12096. return nil
  12097. }
  12098. // ClearedEdges returns all edge names that were cleared in this mutation.
  12099. func (m *MessageMutation) ClearedEdges() []string {
  12100. edges := make([]string, 0, 0)
  12101. return edges
  12102. }
  12103. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12104. // was cleared in this mutation.
  12105. func (m *MessageMutation) EdgeCleared(name string) bool {
  12106. return false
  12107. }
  12108. // ClearEdge clears the value of the edge with the given name. It returns an error
  12109. // if that edge is not defined in the schema.
  12110. func (m *MessageMutation) ClearEdge(name string) error {
  12111. return fmt.Errorf("unknown Message unique edge %s", name)
  12112. }
  12113. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12114. // It returns an error if the edge is not defined in the schema.
  12115. func (m *MessageMutation) ResetEdge(name string) error {
  12116. return fmt.Errorf("unknown Message edge %s", name)
  12117. }
  12118. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  12119. type MessageRecordsMutation struct {
  12120. config
  12121. op Op
  12122. typ string
  12123. id *uint64
  12124. created_at *time.Time
  12125. updated_at *time.Time
  12126. status *uint8
  12127. addstatus *int8
  12128. bot_wxid *string
  12129. contact_type *int
  12130. addcontact_type *int
  12131. contact_wxid *string
  12132. content_type *int
  12133. addcontent_type *int
  12134. content *string
  12135. meta *custom_types.Meta
  12136. error_detail *string
  12137. send_time *time.Time
  12138. source_type *int
  12139. addsource_type *int
  12140. organization_id *uint64
  12141. addorganization_id *int64
  12142. clearedFields map[string]struct{}
  12143. sop_stage *uint64
  12144. clearedsop_stage bool
  12145. sop_node *uint64
  12146. clearedsop_node bool
  12147. message_contact *uint64
  12148. clearedmessage_contact bool
  12149. done bool
  12150. oldValue func(context.Context) (*MessageRecords, error)
  12151. predicates []predicate.MessageRecords
  12152. }
  12153. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  12154. // messagerecordsOption allows management of the mutation configuration using functional options.
  12155. type messagerecordsOption func(*MessageRecordsMutation)
  12156. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  12157. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  12158. m := &MessageRecordsMutation{
  12159. config: c,
  12160. op: op,
  12161. typ: TypeMessageRecords,
  12162. clearedFields: make(map[string]struct{}),
  12163. }
  12164. for _, opt := range opts {
  12165. opt(m)
  12166. }
  12167. return m
  12168. }
  12169. // withMessageRecordsID sets the ID field of the mutation.
  12170. func withMessageRecordsID(id uint64) messagerecordsOption {
  12171. return func(m *MessageRecordsMutation) {
  12172. var (
  12173. err error
  12174. once sync.Once
  12175. value *MessageRecords
  12176. )
  12177. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  12178. once.Do(func() {
  12179. if m.done {
  12180. err = errors.New("querying old values post mutation is not allowed")
  12181. } else {
  12182. value, err = m.Client().MessageRecords.Get(ctx, id)
  12183. }
  12184. })
  12185. return value, err
  12186. }
  12187. m.id = &id
  12188. }
  12189. }
  12190. // withMessageRecords sets the old MessageRecords of the mutation.
  12191. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  12192. return func(m *MessageRecordsMutation) {
  12193. m.oldValue = func(context.Context) (*MessageRecords, error) {
  12194. return node, nil
  12195. }
  12196. m.id = &node.ID
  12197. }
  12198. }
  12199. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12200. // executed in a transaction (ent.Tx), a transactional client is returned.
  12201. func (m MessageRecordsMutation) Client() *Client {
  12202. client := &Client{config: m.config}
  12203. client.init()
  12204. return client
  12205. }
  12206. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12207. // it returns an error otherwise.
  12208. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  12209. if _, ok := m.driver.(*txDriver); !ok {
  12210. return nil, errors.New("ent: mutation is not running in a transaction")
  12211. }
  12212. tx := &Tx{config: m.config}
  12213. tx.init()
  12214. return tx, nil
  12215. }
  12216. // SetID sets the value of the id field. Note that this
  12217. // operation is only accepted on creation of MessageRecords entities.
  12218. func (m *MessageRecordsMutation) SetID(id uint64) {
  12219. m.id = &id
  12220. }
  12221. // ID returns the ID value in the mutation. Note that the ID is only available
  12222. // if it was provided to the builder or after it was returned from the database.
  12223. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  12224. if m.id == nil {
  12225. return
  12226. }
  12227. return *m.id, true
  12228. }
  12229. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12230. // That means, if the mutation is applied within a transaction with an isolation level such
  12231. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12232. // or updated by the mutation.
  12233. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  12234. switch {
  12235. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12236. id, exists := m.ID()
  12237. if exists {
  12238. return []uint64{id}, nil
  12239. }
  12240. fallthrough
  12241. case m.op.Is(OpUpdate | OpDelete):
  12242. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  12243. default:
  12244. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12245. }
  12246. }
  12247. // SetCreatedAt sets the "created_at" field.
  12248. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  12249. m.created_at = &t
  12250. }
  12251. // CreatedAt returns the value of the "created_at" field in the mutation.
  12252. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  12253. v := m.created_at
  12254. if v == nil {
  12255. return
  12256. }
  12257. return *v, true
  12258. }
  12259. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  12260. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12262. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12263. if !m.op.Is(OpUpdateOne) {
  12264. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12265. }
  12266. if m.id == nil || m.oldValue == nil {
  12267. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12268. }
  12269. oldValue, err := m.oldValue(ctx)
  12270. if err != nil {
  12271. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12272. }
  12273. return oldValue.CreatedAt, nil
  12274. }
  12275. // ResetCreatedAt resets all changes to the "created_at" field.
  12276. func (m *MessageRecordsMutation) ResetCreatedAt() {
  12277. m.created_at = nil
  12278. }
  12279. // SetUpdatedAt sets the "updated_at" field.
  12280. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  12281. m.updated_at = &t
  12282. }
  12283. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12284. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  12285. v := m.updated_at
  12286. if v == nil {
  12287. return
  12288. }
  12289. return *v, true
  12290. }
  12291. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  12292. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12294. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12295. if !m.op.Is(OpUpdateOne) {
  12296. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12297. }
  12298. if m.id == nil || m.oldValue == nil {
  12299. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12300. }
  12301. oldValue, err := m.oldValue(ctx)
  12302. if err != nil {
  12303. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12304. }
  12305. return oldValue.UpdatedAt, nil
  12306. }
  12307. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12308. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  12309. m.updated_at = nil
  12310. }
  12311. // SetStatus sets the "status" field.
  12312. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  12313. m.status = &u
  12314. m.addstatus = nil
  12315. }
  12316. // Status returns the value of the "status" field in the mutation.
  12317. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  12318. v := m.status
  12319. if v == nil {
  12320. return
  12321. }
  12322. return *v, true
  12323. }
  12324. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  12325. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12327. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12328. if !m.op.Is(OpUpdateOne) {
  12329. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12330. }
  12331. if m.id == nil || m.oldValue == nil {
  12332. return v, errors.New("OldStatus requires an ID field in the mutation")
  12333. }
  12334. oldValue, err := m.oldValue(ctx)
  12335. if err != nil {
  12336. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12337. }
  12338. return oldValue.Status, nil
  12339. }
  12340. // AddStatus adds u to the "status" field.
  12341. func (m *MessageRecordsMutation) AddStatus(u int8) {
  12342. if m.addstatus != nil {
  12343. *m.addstatus += u
  12344. } else {
  12345. m.addstatus = &u
  12346. }
  12347. }
  12348. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12349. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  12350. v := m.addstatus
  12351. if v == nil {
  12352. return
  12353. }
  12354. return *v, true
  12355. }
  12356. // ClearStatus clears the value of the "status" field.
  12357. func (m *MessageRecordsMutation) ClearStatus() {
  12358. m.status = nil
  12359. m.addstatus = nil
  12360. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  12361. }
  12362. // StatusCleared returns if the "status" field was cleared in this mutation.
  12363. func (m *MessageRecordsMutation) StatusCleared() bool {
  12364. _, ok := m.clearedFields[messagerecords.FieldStatus]
  12365. return ok
  12366. }
  12367. // ResetStatus resets all changes to the "status" field.
  12368. func (m *MessageRecordsMutation) ResetStatus() {
  12369. m.status = nil
  12370. m.addstatus = nil
  12371. delete(m.clearedFields, messagerecords.FieldStatus)
  12372. }
  12373. // SetBotWxid sets the "bot_wxid" field.
  12374. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  12375. m.bot_wxid = &s
  12376. }
  12377. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  12378. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  12379. v := m.bot_wxid
  12380. if v == nil {
  12381. return
  12382. }
  12383. return *v, true
  12384. }
  12385. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  12386. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12388. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  12389. if !m.op.Is(OpUpdateOne) {
  12390. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  12391. }
  12392. if m.id == nil || m.oldValue == nil {
  12393. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  12394. }
  12395. oldValue, err := m.oldValue(ctx)
  12396. if err != nil {
  12397. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  12398. }
  12399. return oldValue.BotWxid, nil
  12400. }
  12401. // ResetBotWxid resets all changes to the "bot_wxid" field.
  12402. func (m *MessageRecordsMutation) ResetBotWxid() {
  12403. m.bot_wxid = nil
  12404. }
  12405. // SetContactID sets the "contact_id" field.
  12406. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  12407. m.message_contact = &u
  12408. }
  12409. // ContactID returns the value of the "contact_id" field in the mutation.
  12410. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  12411. v := m.message_contact
  12412. if v == nil {
  12413. return
  12414. }
  12415. return *v, true
  12416. }
  12417. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  12418. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12420. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  12421. if !m.op.Is(OpUpdateOne) {
  12422. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  12423. }
  12424. if m.id == nil || m.oldValue == nil {
  12425. return v, errors.New("OldContactID requires an ID field in the mutation")
  12426. }
  12427. oldValue, err := m.oldValue(ctx)
  12428. if err != nil {
  12429. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  12430. }
  12431. return oldValue.ContactID, nil
  12432. }
  12433. // ClearContactID clears the value of the "contact_id" field.
  12434. func (m *MessageRecordsMutation) ClearContactID() {
  12435. m.message_contact = nil
  12436. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  12437. }
  12438. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  12439. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  12440. _, ok := m.clearedFields[messagerecords.FieldContactID]
  12441. return ok
  12442. }
  12443. // ResetContactID resets all changes to the "contact_id" field.
  12444. func (m *MessageRecordsMutation) ResetContactID() {
  12445. m.message_contact = nil
  12446. delete(m.clearedFields, messagerecords.FieldContactID)
  12447. }
  12448. // SetContactType sets the "contact_type" field.
  12449. func (m *MessageRecordsMutation) SetContactType(i int) {
  12450. m.contact_type = &i
  12451. m.addcontact_type = nil
  12452. }
  12453. // ContactType returns the value of the "contact_type" field in the mutation.
  12454. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  12455. v := m.contact_type
  12456. if v == nil {
  12457. return
  12458. }
  12459. return *v, true
  12460. }
  12461. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  12462. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12464. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  12465. if !m.op.Is(OpUpdateOne) {
  12466. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  12467. }
  12468. if m.id == nil || m.oldValue == nil {
  12469. return v, errors.New("OldContactType requires an ID field in the mutation")
  12470. }
  12471. oldValue, err := m.oldValue(ctx)
  12472. if err != nil {
  12473. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  12474. }
  12475. return oldValue.ContactType, nil
  12476. }
  12477. // AddContactType adds i to the "contact_type" field.
  12478. func (m *MessageRecordsMutation) AddContactType(i int) {
  12479. if m.addcontact_type != nil {
  12480. *m.addcontact_type += i
  12481. } else {
  12482. m.addcontact_type = &i
  12483. }
  12484. }
  12485. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  12486. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  12487. v := m.addcontact_type
  12488. if v == nil {
  12489. return
  12490. }
  12491. return *v, true
  12492. }
  12493. // ResetContactType resets all changes to the "contact_type" field.
  12494. func (m *MessageRecordsMutation) ResetContactType() {
  12495. m.contact_type = nil
  12496. m.addcontact_type = nil
  12497. }
  12498. // SetContactWxid sets the "contact_wxid" field.
  12499. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  12500. m.contact_wxid = &s
  12501. }
  12502. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  12503. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  12504. v := m.contact_wxid
  12505. if v == nil {
  12506. return
  12507. }
  12508. return *v, true
  12509. }
  12510. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  12511. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12513. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  12514. if !m.op.Is(OpUpdateOne) {
  12515. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  12516. }
  12517. if m.id == nil || m.oldValue == nil {
  12518. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  12519. }
  12520. oldValue, err := m.oldValue(ctx)
  12521. if err != nil {
  12522. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  12523. }
  12524. return oldValue.ContactWxid, nil
  12525. }
  12526. // ResetContactWxid resets all changes to the "contact_wxid" field.
  12527. func (m *MessageRecordsMutation) ResetContactWxid() {
  12528. m.contact_wxid = nil
  12529. }
  12530. // SetContentType sets the "content_type" field.
  12531. func (m *MessageRecordsMutation) SetContentType(i int) {
  12532. m.content_type = &i
  12533. m.addcontent_type = nil
  12534. }
  12535. // ContentType returns the value of the "content_type" field in the mutation.
  12536. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  12537. v := m.content_type
  12538. if v == nil {
  12539. return
  12540. }
  12541. return *v, true
  12542. }
  12543. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  12544. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12546. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  12547. if !m.op.Is(OpUpdateOne) {
  12548. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  12549. }
  12550. if m.id == nil || m.oldValue == nil {
  12551. return v, errors.New("OldContentType requires an ID field in the mutation")
  12552. }
  12553. oldValue, err := m.oldValue(ctx)
  12554. if err != nil {
  12555. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  12556. }
  12557. return oldValue.ContentType, nil
  12558. }
  12559. // AddContentType adds i to the "content_type" field.
  12560. func (m *MessageRecordsMutation) AddContentType(i int) {
  12561. if m.addcontent_type != nil {
  12562. *m.addcontent_type += i
  12563. } else {
  12564. m.addcontent_type = &i
  12565. }
  12566. }
  12567. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  12568. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  12569. v := m.addcontent_type
  12570. if v == nil {
  12571. return
  12572. }
  12573. return *v, true
  12574. }
  12575. // ResetContentType resets all changes to the "content_type" field.
  12576. func (m *MessageRecordsMutation) ResetContentType() {
  12577. m.content_type = nil
  12578. m.addcontent_type = nil
  12579. }
  12580. // SetContent sets the "content" field.
  12581. func (m *MessageRecordsMutation) SetContent(s string) {
  12582. m.content = &s
  12583. }
  12584. // Content returns the value of the "content" field in the mutation.
  12585. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  12586. v := m.content
  12587. if v == nil {
  12588. return
  12589. }
  12590. return *v, true
  12591. }
  12592. // OldContent returns the old "content" field's value of the MessageRecords entity.
  12593. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12595. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  12596. if !m.op.Is(OpUpdateOne) {
  12597. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  12598. }
  12599. if m.id == nil || m.oldValue == nil {
  12600. return v, errors.New("OldContent requires an ID field in the mutation")
  12601. }
  12602. oldValue, err := m.oldValue(ctx)
  12603. if err != nil {
  12604. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  12605. }
  12606. return oldValue.Content, nil
  12607. }
  12608. // ResetContent resets all changes to the "content" field.
  12609. func (m *MessageRecordsMutation) ResetContent() {
  12610. m.content = nil
  12611. }
  12612. // SetMeta sets the "meta" field.
  12613. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  12614. m.meta = &ct
  12615. }
  12616. // Meta returns the value of the "meta" field in the mutation.
  12617. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  12618. v := m.meta
  12619. if v == nil {
  12620. return
  12621. }
  12622. return *v, true
  12623. }
  12624. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  12625. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12627. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  12628. if !m.op.Is(OpUpdateOne) {
  12629. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  12630. }
  12631. if m.id == nil || m.oldValue == nil {
  12632. return v, errors.New("OldMeta requires an ID field in the mutation")
  12633. }
  12634. oldValue, err := m.oldValue(ctx)
  12635. if err != nil {
  12636. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  12637. }
  12638. return oldValue.Meta, nil
  12639. }
  12640. // ClearMeta clears the value of the "meta" field.
  12641. func (m *MessageRecordsMutation) ClearMeta() {
  12642. m.meta = nil
  12643. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  12644. }
  12645. // MetaCleared returns if the "meta" field was cleared in this mutation.
  12646. func (m *MessageRecordsMutation) MetaCleared() bool {
  12647. _, ok := m.clearedFields[messagerecords.FieldMeta]
  12648. return ok
  12649. }
  12650. // ResetMeta resets all changes to the "meta" field.
  12651. func (m *MessageRecordsMutation) ResetMeta() {
  12652. m.meta = nil
  12653. delete(m.clearedFields, messagerecords.FieldMeta)
  12654. }
  12655. // SetErrorDetail sets the "error_detail" field.
  12656. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  12657. m.error_detail = &s
  12658. }
  12659. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  12660. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  12661. v := m.error_detail
  12662. if v == nil {
  12663. return
  12664. }
  12665. return *v, true
  12666. }
  12667. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  12668. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12670. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  12671. if !m.op.Is(OpUpdateOne) {
  12672. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  12673. }
  12674. if m.id == nil || m.oldValue == nil {
  12675. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  12676. }
  12677. oldValue, err := m.oldValue(ctx)
  12678. if err != nil {
  12679. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  12680. }
  12681. return oldValue.ErrorDetail, nil
  12682. }
  12683. // ResetErrorDetail resets all changes to the "error_detail" field.
  12684. func (m *MessageRecordsMutation) ResetErrorDetail() {
  12685. m.error_detail = nil
  12686. }
  12687. // SetSendTime sets the "send_time" field.
  12688. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  12689. m.send_time = &t
  12690. }
  12691. // SendTime returns the value of the "send_time" field in the mutation.
  12692. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  12693. v := m.send_time
  12694. if v == nil {
  12695. return
  12696. }
  12697. return *v, true
  12698. }
  12699. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  12700. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12702. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  12703. if !m.op.Is(OpUpdateOne) {
  12704. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  12705. }
  12706. if m.id == nil || m.oldValue == nil {
  12707. return v, errors.New("OldSendTime requires an ID field in the mutation")
  12708. }
  12709. oldValue, err := m.oldValue(ctx)
  12710. if err != nil {
  12711. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  12712. }
  12713. return oldValue.SendTime, nil
  12714. }
  12715. // ClearSendTime clears the value of the "send_time" field.
  12716. func (m *MessageRecordsMutation) ClearSendTime() {
  12717. m.send_time = nil
  12718. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  12719. }
  12720. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  12721. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  12722. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  12723. return ok
  12724. }
  12725. // ResetSendTime resets all changes to the "send_time" field.
  12726. func (m *MessageRecordsMutation) ResetSendTime() {
  12727. m.send_time = nil
  12728. delete(m.clearedFields, messagerecords.FieldSendTime)
  12729. }
  12730. // SetSourceType sets the "source_type" field.
  12731. func (m *MessageRecordsMutation) SetSourceType(i int) {
  12732. m.source_type = &i
  12733. m.addsource_type = nil
  12734. }
  12735. // SourceType returns the value of the "source_type" field in the mutation.
  12736. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  12737. v := m.source_type
  12738. if v == nil {
  12739. return
  12740. }
  12741. return *v, true
  12742. }
  12743. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  12744. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12746. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  12747. if !m.op.Is(OpUpdateOne) {
  12748. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  12749. }
  12750. if m.id == nil || m.oldValue == nil {
  12751. return v, errors.New("OldSourceType requires an ID field in the mutation")
  12752. }
  12753. oldValue, err := m.oldValue(ctx)
  12754. if err != nil {
  12755. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  12756. }
  12757. return oldValue.SourceType, nil
  12758. }
  12759. // AddSourceType adds i to the "source_type" field.
  12760. func (m *MessageRecordsMutation) AddSourceType(i int) {
  12761. if m.addsource_type != nil {
  12762. *m.addsource_type += i
  12763. } else {
  12764. m.addsource_type = &i
  12765. }
  12766. }
  12767. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  12768. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  12769. v := m.addsource_type
  12770. if v == nil {
  12771. return
  12772. }
  12773. return *v, true
  12774. }
  12775. // ResetSourceType resets all changes to the "source_type" field.
  12776. func (m *MessageRecordsMutation) ResetSourceType() {
  12777. m.source_type = nil
  12778. m.addsource_type = nil
  12779. }
  12780. // SetSourceID sets the "source_id" field.
  12781. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  12782. m.sop_stage = &u
  12783. }
  12784. // SourceID returns the value of the "source_id" field in the mutation.
  12785. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  12786. v := m.sop_stage
  12787. if v == nil {
  12788. return
  12789. }
  12790. return *v, true
  12791. }
  12792. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  12793. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12795. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  12796. if !m.op.Is(OpUpdateOne) {
  12797. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  12798. }
  12799. if m.id == nil || m.oldValue == nil {
  12800. return v, errors.New("OldSourceID requires an ID field in the mutation")
  12801. }
  12802. oldValue, err := m.oldValue(ctx)
  12803. if err != nil {
  12804. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  12805. }
  12806. return oldValue.SourceID, nil
  12807. }
  12808. // ClearSourceID clears the value of the "source_id" field.
  12809. func (m *MessageRecordsMutation) ClearSourceID() {
  12810. m.sop_stage = nil
  12811. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  12812. }
  12813. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  12814. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  12815. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  12816. return ok
  12817. }
  12818. // ResetSourceID resets all changes to the "source_id" field.
  12819. func (m *MessageRecordsMutation) ResetSourceID() {
  12820. m.sop_stage = nil
  12821. delete(m.clearedFields, messagerecords.FieldSourceID)
  12822. }
  12823. // SetSubSourceID sets the "sub_source_id" field.
  12824. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  12825. m.sop_node = &u
  12826. }
  12827. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  12828. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  12829. v := m.sop_node
  12830. if v == nil {
  12831. return
  12832. }
  12833. return *v, true
  12834. }
  12835. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  12836. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12838. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  12839. if !m.op.Is(OpUpdateOne) {
  12840. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  12841. }
  12842. if m.id == nil || m.oldValue == nil {
  12843. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  12844. }
  12845. oldValue, err := m.oldValue(ctx)
  12846. if err != nil {
  12847. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  12848. }
  12849. return oldValue.SubSourceID, nil
  12850. }
  12851. // ClearSubSourceID clears the value of the "sub_source_id" field.
  12852. func (m *MessageRecordsMutation) ClearSubSourceID() {
  12853. m.sop_node = nil
  12854. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  12855. }
  12856. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  12857. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  12858. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  12859. return ok
  12860. }
  12861. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  12862. func (m *MessageRecordsMutation) ResetSubSourceID() {
  12863. m.sop_node = nil
  12864. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  12865. }
  12866. // SetOrganizationID sets the "organization_id" field.
  12867. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  12868. m.organization_id = &u
  12869. m.addorganization_id = nil
  12870. }
  12871. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12872. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  12873. v := m.organization_id
  12874. if v == nil {
  12875. return
  12876. }
  12877. return *v, true
  12878. }
  12879. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  12880. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12882. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12883. if !m.op.Is(OpUpdateOne) {
  12884. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12885. }
  12886. if m.id == nil || m.oldValue == nil {
  12887. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12888. }
  12889. oldValue, err := m.oldValue(ctx)
  12890. if err != nil {
  12891. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12892. }
  12893. return oldValue.OrganizationID, nil
  12894. }
  12895. // AddOrganizationID adds u to the "organization_id" field.
  12896. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  12897. if m.addorganization_id != nil {
  12898. *m.addorganization_id += u
  12899. } else {
  12900. m.addorganization_id = &u
  12901. }
  12902. }
  12903. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12904. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  12905. v := m.addorganization_id
  12906. if v == nil {
  12907. return
  12908. }
  12909. return *v, true
  12910. }
  12911. // ClearOrganizationID clears the value of the "organization_id" field.
  12912. func (m *MessageRecordsMutation) ClearOrganizationID() {
  12913. m.organization_id = nil
  12914. m.addorganization_id = nil
  12915. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  12916. }
  12917. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12918. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  12919. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  12920. return ok
  12921. }
  12922. // ResetOrganizationID resets all changes to the "organization_id" field.
  12923. func (m *MessageRecordsMutation) ResetOrganizationID() {
  12924. m.organization_id = nil
  12925. m.addorganization_id = nil
  12926. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  12927. }
  12928. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  12929. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  12930. m.sop_stage = &id
  12931. }
  12932. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  12933. func (m *MessageRecordsMutation) ClearSopStage() {
  12934. m.clearedsop_stage = true
  12935. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  12936. }
  12937. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  12938. func (m *MessageRecordsMutation) SopStageCleared() bool {
  12939. return m.SourceIDCleared() || m.clearedsop_stage
  12940. }
  12941. // SopStageID returns the "sop_stage" edge ID in the mutation.
  12942. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  12943. if m.sop_stage != nil {
  12944. return *m.sop_stage, true
  12945. }
  12946. return
  12947. }
  12948. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  12949. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12950. // SopStageID instead. It exists only for internal usage by the builders.
  12951. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  12952. if id := m.sop_stage; id != nil {
  12953. ids = append(ids, *id)
  12954. }
  12955. return
  12956. }
  12957. // ResetSopStage resets all changes to the "sop_stage" edge.
  12958. func (m *MessageRecordsMutation) ResetSopStage() {
  12959. m.sop_stage = nil
  12960. m.clearedsop_stage = false
  12961. }
  12962. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  12963. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  12964. m.sop_node = &id
  12965. }
  12966. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  12967. func (m *MessageRecordsMutation) ClearSopNode() {
  12968. m.clearedsop_node = true
  12969. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  12970. }
  12971. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  12972. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  12973. return m.SubSourceIDCleared() || m.clearedsop_node
  12974. }
  12975. // SopNodeID returns the "sop_node" edge ID in the mutation.
  12976. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  12977. if m.sop_node != nil {
  12978. return *m.sop_node, true
  12979. }
  12980. return
  12981. }
  12982. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  12983. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12984. // SopNodeID instead. It exists only for internal usage by the builders.
  12985. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  12986. if id := m.sop_node; id != nil {
  12987. ids = append(ids, *id)
  12988. }
  12989. return
  12990. }
  12991. // ResetSopNode resets all changes to the "sop_node" edge.
  12992. func (m *MessageRecordsMutation) ResetSopNode() {
  12993. m.sop_node = nil
  12994. m.clearedsop_node = false
  12995. }
  12996. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  12997. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  12998. m.message_contact = &id
  12999. }
  13000. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  13001. func (m *MessageRecordsMutation) ClearMessageContact() {
  13002. m.clearedmessage_contact = true
  13003. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  13004. }
  13005. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  13006. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  13007. return m.ContactIDCleared() || m.clearedmessage_contact
  13008. }
  13009. // MessageContactID returns the "message_contact" edge ID in the mutation.
  13010. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  13011. if m.message_contact != nil {
  13012. return *m.message_contact, true
  13013. }
  13014. return
  13015. }
  13016. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  13017. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13018. // MessageContactID instead. It exists only for internal usage by the builders.
  13019. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  13020. if id := m.message_contact; id != nil {
  13021. ids = append(ids, *id)
  13022. }
  13023. return
  13024. }
  13025. // ResetMessageContact resets all changes to the "message_contact" edge.
  13026. func (m *MessageRecordsMutation) ResetMessageContact() {
  13027. m.message_contact = nil
  13028. m.clearedmessage_contact = false
  13029. }
  13030. // Where appends a list predicates to the MessageRecordsMutation builder.
  13031. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  13032. m.predicates = append(m.predicates, ps...)
  13033. }
  13034. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  13035. // users can use type-assertion to append predicates that do not depend on any generated package.
  13036. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  13037. p := make([]predicate.MessageRecords, len(ps))
  13038. for i := range ps {
  13039. p[i] = ps[i]
  13040. }
  13041. m.Where(p...)
  13042. }
  13043. // Op returns the operation name.
  13044. func (m *MessageRecordsMutation) Op() Op {
  13045. return m.op
  13046. }
  13047. // SetOp allows setting the mutation operation.
  13048. func (m *MessageRecordsMutation) SetOp(op Op) {
  13049. m.op = op
  13050. }
  13051. // Type returns the node type of this mutation (MessageRecords).
  13052. func (m *MessageRecordsMutation) Type() string {
  13053. return m.typ
  13054. }
  13055. // Fields returns all fields that were changed during this mutation. Note that in
  13056. // order to get all numeric fields that were incremented/decremented, call
  13057. // AddedFields().
  13058. func (m *MessageRecordsMutation) Fields() []string {
  13059. fields := make([]string, 0, 16)
  13060. if m.created_at != nil {
  13061. fields = append(fields, messagerecords.FieldCreatedAt)
  13062. }
  13063. if m.updated_at != nil {
  13064. fields = append(fields, messagerecords.FieldUpdatedAt)
  13065. }
  13066. if m.status != nil {
  13067. fields = append(fields, messagerecords.FieldStatus)
  13068. }
  13069. if m.bot_wxid != nil {
  13070. fields = append(fields, messagerecords.FieldBotWxid)
  13071. }
  13072. if m.message_contact != nil {
  13073. fields = append(fields, messagerecords.FieldContactID)
  13074. }
  13075. if m.contact_type != nil {
  13076. fields = append(fields, messagerecords.FieldContactType)
  13077. }
  13078. if m.contact_wxid != nil {
  13079. fields = append(fields, messagerecords.FieldContactWxid)
  13080. }
  13081. if m.content_type != nil {
  13082. fields = append(fields, messagerecords.FieldContentType)
  13083. }
  13084. if m.content != nil {
  13085. fields = append(fields, messagerecords.FieldContent)
  13086. }
  13087. if m.meta != nil {
  13088. fields = append(fields, messagerecords.FieldMeta)
  13089. }
  13090. if m.error_detail != nil {
  13091. fields = append(fields, messagerecords.FieldErrorDetail)
  13092. }
  13093. if m.send_time != nil {
  13094. fields = append(fields, messagerecords.FieldSendTime)
  13095. }
  13096. if m.source_type != nil {
  13097. fields = append(fields, messagerecords.FieldSourceType)
  13098. }
  13099. if m.sop_stage != nil {
  13100. fields = append(fields, messagerecords.FieldSourceID)
  13101. }
  13102. if m.sop_node != nil {
  13103. fields = append(fields, messagerecords.FieldSubSourceID)
  13104. }
  13105. if m.organization_id != nil {
  13106. fields = append(fields, messagerecords.FieldOrganizationID)
  13107. }
  13108. return fields
  13109. }
  13110. // Field returns the value of a field with the given name. The second boolean
  13111. // return value indicates that this field was not set, or was not defined in the
  13112. // schema.
  13113. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  13114. switch name {
  13115. case messagerecords.FieldCreatedAt:
  13116. return m.CreatedAt()
  13117. case messagerecords.FieldUpdatedAt:
  13118. return m.UpdatedAt()
  13119. case messagerecords.FieldStatus:
  13120. return m.Status()
  13121. case messagerecords.FieldBotWxid:
  13122. return m.BotWxid()
  13123. case messagerecords.FieldContactID:
  13124. return m.ContactID()
  13125. case messagerecords.FieldContactType:
  13126. return m.ContactType()
  13127. case messagerecords.FieldContactWxid:
  13128. return m.ContactWxid()
  13129. case messagerecords.FieldContentType:
  13130. return m.ContentType()
  13131. case messagerecords.FieldContent:
  13132. return m.Content()
  13133. case messagerecords.FieldMeta:
  13134. return m.Meta()
  13135. case messagerecords.FieldErrorDetail:
  13136. return m.ErrorDetail()
  13137. case messagerecords.FieldSendTime:
  13138. return m.SendTime()
  13139. case messagerecords.FieldSourceType:
  13140. return m.SourceType()
  13141. case messagerecords.FieldSourceID:
  13142. return m.SourceID()
  13143. case messagerecords.FieldSubSourceID:
  13144. return m.SubSourceID()
  13145. case messagerecords.FieldOrganizationID:
  13146. return m.OrganizationID()
  13147. }
  13148. return nil, false
  13149. }
  13150. // OldField returns the old value of the field from the database. An error is
  13151. // returned if the mutation operation is not UpdateOne, or the query to the
  13152. // database failed.
  13153. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13154. switch name {
  13155. case messagerecords.FieldCreatedAt:
  13156. return m.OldCreatedAt(ctx)
  13157. case messagerecords.FieldUpdatedAt:
  13158. return m.OldUpdatedAt(ctx)
  13159. case messagerecords.FieldStatus:
  13160. return m.OldStatus(ctx)
  13161. case messagerecords.FieldBotWxid:
  13162. return m.OldBotWxid(ctx)
  13163. case messagerecords.FieldContactID:
  13164. return m.OldContactID(ctx)
  13165. case messagerecords.FieldContactType:
  13166. return m.OldContactType(ctx)
  13167. case messagerecords.FieldContactWxid:
  13168. return m.OldContactWxid(ctx)
  13169. case messagerecords.FieldContentType:
  13170. return m.OldContentType(ctx)
  13171. case messagerecords.FieldContent:
  13172. return m.OldContent(ctx)
  13173. case messagerecords.FieldMeta:
  13174. return m.OldMeta(ctx)
  13175. case messagerecords.FieldErrorDetail:
  13176. return m.OldErrorDetail(ctx)
  13177. case messagerecords.FieldSendTime:
  13178. return m.OldSendTime(ctx)
  13179. case messagerecords.FieldSourceType:
  13180. return m.OldSourceType(ctx)
  13181. case messagerecords.FieldSourceID:
  13182. return m.OldSourceID(ctx)
  13183. case messagerecords.FieldSubSourceID:
  13184. return m.OldSubSourceID(ctx)
  13185. case messagerecords.FieldOrganizationID:
  13186. return m.OldOrganizationID(ctx)
  13187. }
  13188. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  13189. }
  13190. // SetField sets the value of a field with the given name. It returns an error if
  13191. // the field is not defined in the schema, or if the type mismatched the field
  13192. // type.
  13193. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  13194. switch name {
  13195. case messagerecords.FieldCreatedAt:
  13196. v, ok := value.(time.Time)
  13197. if !ok {
  13198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13199. }
  13200. m.SetCreatedAt(v)
  13201. return nil
  13202. case messagerecords.FieldUpdatedAt:
  13203. v, ok := value.(time.Time)
  13204. if !ok {
  13205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13206. }
  13207. m.SetUpdatedAt(v)
  13208. return nil
  13209. case messagerecords.FieldStatus:
  13210. v, ok := value.(uint8)
  13211. if !ok {
  13212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13213. }
  13214. m.SetStatus(v)
  13215. return nil
  13216. case messagerecords.FieldBotWxid:
  13217. v, ok := value.(string)
  13218. if !ok {
  13219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13220. }
  13221. m.SetBotWxid(v)
  13222. return nil
  13223. case messagerecords.FieldContactID:
  13224. v, ok := value.(uint64)
  13225. if !ok {
  13226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13227. }
  13228. m.SetContactID(v)
  13229. return nil
  13230. case messagerecords.FieldContactType:
  13231. v, ok := value.(int)
  13232. if !ok {
  13233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13234. }
  13235. m.SetContactType(v)
  13236. return nil
  13237. case messagerecords.FieldContactWxid:
  13238. v, ok := value.(string)
  13239. if !ok {
  13240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13241. }
  13242. m.SetContactWxid(v)
  13243. return nil
  13244. case messagerecords.FieldContentType:
  13245. v, ok := value.(int)
  13246. if !ok {
  13247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13248. }
  13249. m.SetContentType(v)
  13250. return nil
  13251. case messagerecords.FieldContent:
  13252. v, ok := value.(string)
  13253. if !ok {
  13254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13255. }
  13256. m.SetContent(v)
  13257. return nil
  13258. case messagerecords.FieldMeta:
  13259. v, ok := value.(custom_types.Meta)
  13260. if !ok {
  13261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13262. }
  13263. m.SetMeta(v)
  13264. return nil
  13265. case messagerecords.FieldErrorDetail:
  13266. v, ok := value.(string)
  13267. if !ok {
  13268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13269. }
  13270. m.SetErrorDetail(v)
  13271. return nil
  13272. case messagerecords.FieldSendTime:
  13273. v, ok := value.(time.Time)
  13274. if !ok {
  13275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13276. }
  13277. m.SetSendTime(v)
  13278. return nil
  13279. case messagerecords.FieldSourceType:
  13280. v, ok := value.(int)
  13281. if !ok {
  13282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13283. }
  13284. m.SetSourceType(v)
  13285. return nil
  13286. case messagerecords.FieldSourceID:
  13287. v, ok := value.(uint64)
  13288. if !ok {
  13289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13290. }
  13291. m.SetSourceID(v)
  13292. return nil
  13293. case messagerecords.FieldSubSourceID:
  13294. v, ok := value.(uint64)
  13295. if !ok {
  13296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13297. }
  13298. m.SetSubSourceID(v)
  13299. return nil
  13300. case messagerecords.FieldOrganizationID:
  13301. v, ok := value.(uint64)
  13302. if !ok {
  13303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13304. }
  13305. m.SetOrganizationID(v)
  13306. return nil
  13307. }
  13308. return fmt.Errorf("unknown MessageRecords field %s", name)
  13309. }
  13310. // AddedFields returns all numeric fields that were incremented/decremented during
  13311. // this mutation.
  13312. func (m *MessageRecordsMutation) AddedFields() []string {
  13313. var fields []string
  13314. if m.addstatus != nil {
  13315. fields = append(fields, messagerecords.FieldStatus)
  13316. }
  13317. if m.addcontact_type != nil {
  13318. fields = append(fields, messagerecords.FieldContactType)
  13319. }
  13320. if m.addcontent_type != nil {
  13321. fields = append(fields, messagerecords.FieldContentType)
  13322. }
  13323. if m.addsource_type != nil {
  13324. fields = append(fields, messagerecords.FieldSourceType)
  13325. }
  13326. if m.addorganization_id != nil {
  13327. fields = append(fields, messagerecords.FieldOrganizationID)
  13328. }
  13329. return fields
  13330. }
  13331. // AddedField returns the numeric value that was incremented/decremented on a field
  13332. // with the given name. The second boolean return value indicates that this field
  13333. // was not set, or was not defined in the schema.
  13334. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  13335. switch name {
  13336. case messagerecords.FieldStatus:
  13337. return m.AddedStatus()
  13338. case messagerecords.FieldContactType:
  13339. return m.AddedContactType()
  13340. case messagerecords.FieldContentType:
  13341. return m.AddedContentType()
  13342. case messagerecords.FieldSourceType:
  13343. return m.AddedSourceType()
  13344. case messagerecords.FieldOrganizationID:
  13345. return m.AddedOrganizationID()
  13346. }
  13347. return nil, false
  13348. }
  13349. // AddField adds the value to the field with the given name. It returns an error if
  13350. // the field is not defined in the schema, or if the type mismatched the field
  13351. // type.
  13352. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  13353. switch name {
  13354. case messagerecords.FieldStatus:
  13355. v, ok := value.(int8)
  13356. if !ok {
  13357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13358. }
  13359. m.AddStatus(v)
  13360. return nil
  13361. case messagerecords.FieldContactType:
  13362. v, ok := value.(int)
  13363. if !ok {
  13364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13365. }
  13366. m.AddContactType(v)
  13367. return nil
  13368. case messagerecords.FieldContentType:
  13369. v, ok := value.(int)
  13370. if !ok {
  13371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13372. }
  13373. m.AddContentType(v)
  13374. return nil
  13375. case messagerecords.FieldSourceType:
  13376. v, ok := value.(int)
  13377. if !ok {
  13378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13379. }
  13380. m.AddSourceType(v)
  13381. return nil
  13382. case messagerecords.FieldOrganizationID:
  13383. v, ok := value.(int64)
  13384. if !ok {
  13385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13386. }
  13387. m.AddOrganizationID(v)
  13388. return nil
  13389. }
  13390. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  13391. }
  13392. // ClearedFields returns all nullable fields that were cleared during this
  13393. // mutation.
  13394. func (m *MessageRecordsMutation) ClearedFields() []string {
  13395. var fields []string
  13396. if m.FieldCleared(messagerecords.FieldStatus) {
  13397. fields = append(fields, messagerecords.FieldStatus)
  13398. }
  13399. if m.FieldCleared(messagerecords.FieldContactID) {
  13400. fields = append(fields, messagerecords.FieldContactID)
  13401. }
  13402. if m.FieldCleared(messagerecords.FieldMeta) {
  13403. fields = append(fields, messagerecords.FieldMeta)
  13404. }
  13405. if m.FieldCleared(messagerecords.FieldSendTime) {
  13406. fields = append(fields, messagerecords.FieldSendTime)
  13407. }
  13408. if m.FieldCleared(messagerecords.FieldSourceID) {
  13409. fields = append(fields, messagerecords.FieldSourceID)
  13410. }
  13411. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  13412. fields = append(fields, messagerecords.FieldSubSourceID)
  13413. }
  13414. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  13415. fields = append(fields, messagerecords.FieldOrganizationID)
  13416. }
  13417. return fields
  13418. }
  13419. // FieldCleared returns a boolean indicating if a field with the given name was
  13420. // cleared in this mutation.
  13421. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  13422. _, ok := m.clearedFields[name]
  13423. return ok
  13424. }
  13425. // ClearField clears the value of the field with the given name. It returns an
  13426. // error if the field is not defined in the schema.
  13427. func (m *MessageRecordsMutation) ClearField(name string) error {
  13428. switch name {
  13429. case messagerecords.FieldStatus:
  13430. m.ClearStatus()
  13431. return nil
  13432. case messagerecords.FieldContactID:
  13433. m.ClearContactID()
  13434. return nil
  13435. case messagerecords.FieldMeta:
  13436. m.ClearMeta()
  13437. return nil
  13438. case messagerecords.FieldSendTime:
  13439. m.ClearSendTime()
  13440. return nil
  13441. case messagerecords.FieldSourceID:
  13442. m.ClearSourceID()
  13443. return nil
  13444. case messagerecords.FieldSubSourceID:
  13445. m.ClearSubSourceID()
  13446. return nil
  13447. case messagerecords.FieldOrganizationID:
  13448. m.ClearOrganizationID()
  13449. return nil
  13450. }
  13451. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  13452. }
  13453. // ResetField resets all changes in the mutation for the field with the given name.
  13454. // It returns an error if the field is not defined in the schema.
  13455. func (m *MessageRecordsMutation) ResetField(name string) error {
  13456. switch name {
  13457. case messagerecords.FieldCreatedAt:
  13458. m.ResetCreatedAt()
  13459. return nil
  13460. case messagerecords.FieldUpdatedAt:
  13461. m.ResetUpdatedAt()
  13462. return nil
  13463. case messagerecords.FieldStatus:
  13464. m.ResetStatus()
  13465. return nil
  13466. case messagerecords.FieldBotWxid:
  13467. m.ResetBotWxid()
  13468. return nil
  13469. case messagerecords.FieldContactID:
  13470. m.ResetContactID()
  13471. return nil
  13472. case messagerecords.FieldContactType:
  13473. m.ResetContactType()
  13474. return nil
  13475. case messagerecords.FieldContactWxid:
  13476. m.ResetContactWxid()
  13477. return nil
  13478. case messagerecords.FieldContentType:
  13479. m.ResetContentType()
  13480. return nil
  13481. case messagerecords.FieldContent:
  13482. m.ResetContent()
  13483. return nil
  13484. case messagerecords.FieldMeta:
  13485. m.ResetMeta()
  13486. return nil
  13487. case messagerecords.FieldErrorDetail:
  13488. m.ResetErrorDetail()
  13489. return nil
  13490. case messagerecords.FieldSendTime:
  13491. m.ResetSendTime()
  13492. return nil
  13493. case messagerecords.FieldSourceType:
  13494. m.ResetSourceType()
  13495. return nil
  13496. case messagerecords.FieldSourceID:
  13497. m.ResetSourceID()
  13498. return nil
  13499. case messagerecords.FieldSubSourceID:
  13500. m.ResetSubSourceID()
  13501. return nil
  13502. case messagerecords.FieldOrganizationID:
  13503. m.ResetOrganizationID()
  13504. return nil
  13505. }
  13506. return fmt.Errorf("unknown MessageRecords field %s", name)
  13507. }
  13508. // AddedEdges returns all edge names that were set/added in this mutation.
  13509. func (m *MessageRecordsMutation) AddedEdges() []string {
  13510. edges := make([]string, 0, 3)
  13511. if m.sop_stage != nil {
  13512. edges = append(edges, messagerecords.EdgeSopStage)
  13513. }
  13514. if m.sop_node != nil {
  13515. edges = append(edges, messagerecords.EdgeSopNode)
  13516. }
  13517. if m.message_contact != nil {
  13518. edges = append(edges, messagerecords.EdgeMessageContact)
  13519. }
  13520. return edges
  13521. }
  13522. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13523. // name in this mutation.
  13524. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  13525. switch name {
  13526. case messagerecords.EdgeSopStage:
  13527. if id := m.sop_stage; id != nil {
  13528. return []ent.Value{*id}
  13529. }
  13530. case messagerecords.EdgeSopNode:
  13531. if id := m.sop_node; id != nil {
  13532. return []ent.Value{*id}
  13533. }
  13534. case messagerecords.EdgeMessageContact:
  13535. if id := m.message_contact; id != nil {
  13536. return []ent.Value{*id}
  13537. }
  13538. }
  13539. return nil
  13540. }
  13541. // RemovedEdges returns all edge names that were removed in this mutation.
  13542. func (m *MessageRecordsMutation) RemovedEdges() []string {
  13543. edges := make([]string, 0, 3)
  13544. return edges
  13545. }
  13546. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13547. // the given name in this mutation.
  13548. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  13549. return nil
  13550. }
  13551. // ClearedEdges returns all edge names that were cleared in this mutation.
  13552. func (m *MessageRecordsMutation) ClearedEdges() []string {
  13553. edges := make([]string, 0, 3)
  13554. if m.clearedsop_stage {
  13555. edges = append(edges, messagerecords.EdgeSopStage)
  13556. }
  13557. if m.clearedsop_node {
  13558. edges = append(edges, messagerecords.EdgeSopNode)
  13559. }
  13560. if m.clearedmessage_contact {
  13561. edges = append(edges, messagerecords.EdgeMessageContact)
  13562. }
  13563. return edges
  13564. }
  13565. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13566. // was cleared in this mutation.
  13567. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  13568. switch name {
  13569. case messagerecords.EdgeSopStage:
  13570. return m.clearedsop_stage
  13571. case messagerecords.EdgeSopNode:
  13572. return m.clearedsop_node
  13573. case messagerecords.EdgeMessageContact:
  13574. return m.clearedmessage_contact
  13575. }
  13576. return false
  13577. }
  13578. // ClearEdge clears the value of the edge with the given name. It returns an error
  13579. // if that edge is not defined in the schema.
  13580. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  13581. switch name {
  13582. case messagerecords.EdgeSopStage:
  13583. m.ClearSopStage()
  13584. return nil
  13585. case messagerecords.EdgeSopNode:
  13586. m.ClearSopNode()
  13587. return nil
  13588. case messagerecords.EdgeMessageContact:
  13589. m.ClearMessageContact()
  13590. return nil
  13591. }
  13592. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  13593. }
  13594. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13595. // It returns an error if the edge is not defined in the schema.
  13596. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  13597. switch name {
  13598. case messagerecords.EdgeSopStage:
  13599. m.ResetSopStage()
  13600. return nil
  13601. case messagerecords.EdgeSopNode:
  13602. m.ResetSopNode()
  13603. return nil
  13604. case messagerecords.EdgeMessageContact:
  13605. m.ResetMessageContact()
  13606. return nil
  13607. }
  13608. return fmt.Errorf("unknown MessageRecords edge %s", name)
  13609. }
  13610. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  13611. type MsgMutation struct {
  13612. config
  13613. op Op
  13614. typ string
  13615. id *uint64
  13616. created_at *time.Time
  13617. updated_at *time.Time
  13618. deleted_at *time.Time
  13619. status *uint8
  13620. addstatus *int8
  13621. fromwxid *string
  13622. toid *string
  13623. msgtype *int32
  13624. addmsgtype *int32
  13625. msg *string
  13626. batch_no *string
  13627. clearedFields map[string]struct{}
  13628. done bool
  13629. oldValue func(context.Context) (*Msg, error)
  13630. predicates []predicate.Msg
  13631. }
  13632. var _ ent.Mutation = (*MsgMutation)(nil)
  13633. // msgOption allows management of the mutation configuration using functional options.
  13634. type msgOption func(*MsgMutation)
  13635. // newMsgMutation creates new mutation for the Msg entity.
  13636. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  13637. m := &MsgMutation{
  13638. config: c,
  13639. op: op,
  13640. typ: TypeMsg,
  13641. clearedFields: make(map[string]struct{}),
  13642. }
  13643. for _, opt := range opts {
  13644. opt(m)
  13645. }
  13646. return m
  13647. }
  13648. // withMsgID sets the ID field of the mutation.
  13649. func withMsgID(id uint64) msgOption {
  13650. return func(m *MsgMutation) {
  13651. var (
  13652. err error
  13653. once sync.Once
  13654. value *Msg
  13655. )
  13656. m.oldValue = func(ctx context.Context) (*Msg, error) {
  13657. once.Do(func() {
  13658. if m.done {
  13659. err = errors.New("querying old values post mutation is not allowed")
  13660. } else {
  13661. value, err = m.Client().Msg.Get(ctx, id)
  13662. }
  13663. })
  13664. return value, err
  13665. }
  13666. m.id = &id
  13667. }
  13668. }
  13669. // withMsg sets the old Msg of the mutation.
  13670. func withMsg(node *Msg) msgOption {
  13671. return func(m *MsgMutation) {
  13672. m.oldValue = func(context.Context) (*Msg, error) {
  13673. return node, nil
  13674. }
  13675. m.id = &node.ID
  13676. }
  13677. }
  13678. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13679. // executed in a transaction (ent.Tx), a transactional client is returned.
  13680. func (m MsgMutation) Client() *Client {
  13681. client := &Client{config: m.config}
  13682. client.init()
  13683. return client
  13684. }
  13685. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13686. // it returns an error otherwise.
  13687. func (m MsgMutation) Tx() (*Tx, error) {
  13688. if _, ok := m.driver.(*txDriver); !ok {
  13689. return nil, errors.New("ent: mutation is not running in a transaction")
  13690. }
  13691. tx := &Tx{config: m.config}
  13692. tx.init()
  13693. return tx, nil
  13694. }
  13695. // SetID sets the value of the id field. Note that this
  13696. // operation is only accepted on creation of Msg entities.
  13697. func (m *MsgMutation) SetID(id uint64) {
  13698. m.id = &id
  13699. }
  13700. // ID returns the ID value in the mutation. Note that the ID is only available
  13701. // if it was provided to the builder or after it was returned from the database.
  13702. func (m *MsgMutation) ID() (id uint64, exists bool) {
  13703. if m.id == nil {
  13704. return
  13705. }
  13706. return *m.id, true
  13707. }
  13708. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13709. // That means, if the mutation is applied within a transaction with an isolation level such
  13710. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13711. // or updated by the mutation.
  13712. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  13713. switch {
  13714. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13715. id, exists := m.ID()
  13716. if exists {
  13717. return []uint64{id}, nil
  13718. }
  13719. fallthrough
  13720. case m.op.Is(OpUpdate | OpDelete):
  13721. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  13722. default:
  13723. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13724. }
  13725. }
  13726. // SetCreatedAt sets the "created_at" field.
  13727. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  13728. m.created_at = &t
  13729. }
  13730. // CreatedAt returns the value of the "created_at" field in the mutation.
  13731. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  13732. v := m.created_at
  13733. if v == nil {
  13734. return
  13735. }
  13736. return *v, true
  13737. }
  13738. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  13739. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13741. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13742. if !m.op.Is(OpUpdateOne) {
  13743. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13744. }
  13745. if m.id == nil || m.oldValue == nil {
  13746. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13747. }
  13748. oldValue, err := m.oldValue(ctx)
  13749. if err != nil {
  13750. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13751. }
  13752. return oldValue.CreatedAt, nil
  13753. }
  13754. // ResetCreatedAt resets all changes to the "created_at" field.
  13755. func (m *MsgMutation) ResetCreatedAt() {
  13756. m.created_at = nil
  13757. }
  13758. // SetUpdatedAt sets the "updated_at" field.
  13759. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  13760. m.updated_at = &t
  13761. }
  13762. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13763. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  13764. v := m.updated_at
  13765. if v == nil {
  13766. return
  13767. }
  13768. return *v, true
  13769. }
  13770. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  13771. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13773. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13774. if !m.op.Is(OpUpdateOne) {
  13775. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13776. }
  13777. if m.id == nil || m.oldValue == nil {
  13778. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13779. }
  13780. oldValue, err := m.oldValue(ctx)
  13781. if err != nil {
  13782. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13783. }
  13784. return oldValue.UpdatedAt, nil
  13785. }
  13786. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13787. func (m *MsgMutation) ResetUpdatedAt() {
  13788. m.updated_at = nil
  13789. }
  13790. // SetDeletedAt sets the "deleted_at" field.
  13791. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  13792. m.deleted_at = &t
  13793. }
  13794. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13795. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  13796. v := m.deleted_at
  13797. if v == nil {
  13798. return
  13799. }
  13800. return *v, true
  13801. }
  13802. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  13803. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13805. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13806. if !m.op.Is(OpUpdateOne) {
  13807. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13808. }
  13809. if m.id == nil || m.oldValue == nil {
  13810. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13811. }
  13812. oldValue, err := m.oldValue(ctx)
  13813. if err != nil {
  13814. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13815. }
  13816. return oldValue.DeletedAt, nil
  13817. }
  13818. // ClearDeletedAt clears the value of the "deleted_at" field.
  13819. func (m *MsgMutation) ClearDeletedAt() {
  13820. m.deleted_at = nil
  13821. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  13822. }
  13823. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13824. func (m *MsgMutation) DeletedAtCleared() bool {
  13825. _, ok := m.clearedFields[msg.FieldDeletedAt]
  13826. return ok
  13827. }
  13828. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13829. func (m *MsgMutation) ResetDeletedAt() {
  13830. m.deleted_at = nil
  13831. delete(m.clearedFields, msg.FieldDeletedAt)
  13832. }
  13833. // SetStatus sets the "status" field.
  13834. func (m *MsgMutation) SetStatus(u uint8) {
  13835. m.status = &u
  13836. m.addstatus = nil
  13837. }
  13838. // Status returns the value of the "status" field in the mutation.
  13839. func (m *MsgMutation) Status() (r uint8, exists bool) {
  13840. v := m.status
  13841. if v == nil {
  13842. return
  13843. }
  13844. return *v, true
  13845. }
  13846. // OldStatus returns the old "status" field's value of the Msg entity.
  13847. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13849. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13850. if !m.op.Is(OpUpdateOne) {
  13851. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13852. }
  13853. if m.id == nil || m.oldValue == nil {
  13854. return v, errors.New("OldStatus requires an ID field in the mutation")
  13855. }
  13856. oldValue, err := m.oldValue(ctx)
  13857. if err != nil {
  13858. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13859. }
  13860. return oldValue.Status, nil
  13861. }
  13862. // AddStatus adds u to the "status" field.
  13863. func (m *MsgMutation) AddStatus(u int8) {
  13864. if m.addstatus != nil {
  13865. *m.addstatus += u
  13866. } else {
  13867. m.addstatus = &u
  13868. }
  13869. }
  13870. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13871. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  13872. v := m.addstatus
  13873. if v == nil {
  13874. return
  13875. }
  13876. return *v, true
  13877. }
  13878. // ClearStatus clears the value of the "status" field.
  13879. func (m *MsgMutation) ClearStatus() {
  13880. m.status = nil
  13881. m.addstatus = nil
  13882. m.clearedFields[msg.FieldStatus] = struct{}{}
  13883. }
  13884. // StatusCleared returns if the "status" field was cleared in this mutation.
  13885. func (m *MsgMutation) StatusCleared() bool {
  13886. _, ok := m.clearedFields[msg.FieldStatus]
  13887. return ok
  13888. }
  13889. // ResetStatus resets all changes to the "status" field.
  13890. func (m *MsgMutation) ResetStatus() {
  13891. m.status = nil
  13892. m.addstatus = nil
  13893. delete(m.clearedFields, msg.FieldStatus)
  13894. }
  13895. // SetFromwxid sets the "fromwxid" field.
  13896. func (m *MsgMutation) SetFromwxid(s string) {
  13897. m.fromwxid = &s
  13898. }
  13899. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  13900. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  13901. v := m.fromwxid
  13902. if v == nil {
  13903. return
  13904. }
  13905. return *v, true
  13906. }
  13907. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  13908. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13910. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  13911. if !m.op.Is(OpUpdateOne) {
  13912. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  13913. }
  13914. if m.id == nil || m.oldValue == nil {
  13915. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  13916. }
  13917. oldValue, err := m.oldValue(ctx)
  13918. if err != nil {
  13919. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  13920. }
  13921. return oldValue.Fromwxid, nil
  13922. }
  13923. // ClearFromwxid clears the value of the "fromwxid" field.
  13924. func (m *MsgMutation) ClearFromwxid() {
  13925. m.fromwxid = nil
  13926. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  13927. }
  13928. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  13929. func (m *MsgMutation) FromwxidCleared() bool {
  13930. _, ok := m.clearedFields[msg.FieldFromwxid]
  13931. return ok
  13932. }
  13933. // ResetFromwxid resets all changes to the "fromwxid" field.
  13934. func (m *MsgMutation) ResetFromwxid() {
  13935. m.fromwxid = nil
  13936. delete(m.clearedFields, msg.FieldFromwxid)
  13937. }
  13938. // SetToid sets the "toid" field.
  13939. func (m *MsgMutation) SetToid(s string) {
  13940. m.toid = &s
  13941. }
  13942. // Toid returns the value of the "toid" field in the mutation.
  13943. func (m *MsgMutation) Toid() (r string, exists bool) {
  13944. v := m.toid
  13945. if v == nil {
  13946. return
  13947. }
  13948. return *v, true
  13949. }
  13950. // OldToid returns the old "toid" field's value of the Msg entity.
  13951. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13953. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  13954. if !m.op.Is(OpUpdateOne) {
  13955. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  13956. }
  13957. if m.id == nil || m.oldValue == nil {
  13958. return v, errors.New("OldToid requires an ID field in the mutation")
  13959. }
  13960. oldValue, err := m.oldValue(ctx)
  13961. if err != nil {
  13962. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  13963. }
  13964. return oldValue.Toid, nil
  13965. }
  13966. // ClearToid clears the value of the "toid" field.
  13967. func (m *MsgMutation) ClearToid() {
  13968. m.toid = nil
  13969. m.clearedFields[msg.FieldToid] = struct{}{}
  13970. }
  13971. // ToidCleared returns if the "toid" field was cleared in this mutation.
  13972. func (m *MsgMutation) ToidCleared() bool {
  13973. _, ok := m.clearedFields[msg.FieldToid]
  13974. return ok
  13975. }
  13976. // ResetToid resets all changes to the "toid" field.
  13977. func (m *MsgMutation) ResetToid() {
  13978. m.toid = nil
  13979. delete(m.clearedFields, msg.FieldToid)
  13980. }
  13981. // SetMsgtype sets the "msgtype" field.
  13982. func (m *MsgMutation) SetMsgtype(i int32) {
  13983. m.msgtype = &i
  13984. m.addmsgtype = nil
  13985. }
  13986. // Msgtype returns the value of the "msgtype" field in the mutation.
  13987. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  13988. v := m.msgtype
  13989. if v == nil {
  13990. return
  13991. }
  13992. return *v, true
  13993. }
  13994. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  13995. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13997. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  13998. if !m.op.Is(OpUpdateOne) {
  13999. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  14000. }
  14001. if m.id == nil || m.oldValue == nil {
  14002. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  14003. }
  14004. oldValue, err := m.oldValue(ctx)
  14005. if err != nil {
  14006. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  14007. }
  14008. return oldValue.Msgtype, nil
  14009. }
  14010. // AddMsgtype adds i to the "msgtype" field.
  14011. func (m *MsgMutation) AddMsgtype(i int32) {
  14012. if m.addmsgtype != nil {
  14013. *m.addmsgtype += i
  14014. } else {
  14015. m.addmsgtype = &i
  14016. }
  14017. }
  14018. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  14019. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  14020. v := m.addmsgtype
  14021. if v == nil {
  14022. return
  14023. }
  14024. return *v, true
  14025. }
  14026. // ClearMsgtype clears the value of the "msgtype" field.
  14027. func (m *MsgMutation) ClearMsgtype() {
  14028. m.msgtype = nil
  14029. m.addmsgtype = nil
  14030. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  14031. }
  14032. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  14033. func (m *MsgMutation) MsgtypeCleared() bool {
  14034. _, ok := m.clearedFields[msg.FieldMsgtype]
  14035. return ok
  14036. }
  14037. // ResetMsgtype resets all changes to the "msgtype" field.
  14038. func (m *MsgMutation) ResetMsgtype() {
  14039. m.msgtype = nil
  14040. m.addmsgtype = nil
  14041. delete(m.clearedFields, msg.FieldMsgtype)
  14042. }
  14043. // SetMsg sets the "msg" field.
  14044. func (m *MsgMutation) SetMsg(s string) {
  14045. m.msg = &s
  14046. }
  14047. // Msg returns the value of the "msg" field in the mutation.
  14048. func (m *MsgMutation) Msg() (r string, exists bool) {
  14049. v := m.msg
  14050. if v == nil {
  14051. return
  14052. }
  14053. return *v, true
  14054. }
  14055. // OldMsg returns the old "msg" field's value of the Msg entity.
  14056. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14058. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  14059. if !m.op.Is(OpUpdateOne) {
  14060. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  14061. }
  14062. if m.id == nil || m.oldValue == nil {
  14063. return v, errors.New("OldMsg requires an ID field in the mutation")
  14064. }
  14065. oldValue, err := m.oldValue(ctx)
  14066. if err != nil {
  14067. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  14068. }
  14069. return oldValue.Msg, nil
  14070. }
  14071. // ClearMsg clears the value of the "msg" field.
  14072. func (m *MsgMutation) ClearMsg() {
  14073. m.msg = nil
  14074. m.clearedFields[msg.FieldMsg] = struct{}{}
  14075. }
  14076. // MsgCleared returns if the "msg" field was cleared in this mutation.
  14077. func (m *MsgMutation) MsgCleared() bool {
  14078. _, ok := m.clearedFields[msg.FieldMsg]
  14079. return ok
  14080. }
  14081. // ResetMsg resets all changes to the "msg" field.
  14082. func (m *MsgMutation) ResetMsg() {
  14083. m.msg = nil
  14084. delete(m.clearedFields, msg.FieldMsg)
  14085. }
  14086. // SetBatchNo sets the "batch_no" field.
  14087. func (m *MsgMutation) SetBatchNo(s string) {
  14088. m.batch_no = &s
  14089. }
  14090. // BatchNo returns the value of the "batch_no" field in the mutation.
  14091. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  14092. v := m.batch_no
  14093. if v == nil {
  14094. return
  14095. }
  14096. return *v, true
  14097. }
  14098. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  14099. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14101. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  14102. if !m.op.Is(OpUpdateOne) {
  14103. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  14104. }
  14105. if m.id == nil || m.oldValue == nil {
  14106. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  14107. }
  14108. oldValue, err := m.oldValue(ctx)
  14109. if err != nil {
  14110. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  14111. }
  14112. return oldValue.BatchNo, nil
  14113. }
  14114. // ClearBatchNo clears the value of the "batch_no" field.
  14115. func (m *MsgMutation) ClearBatchNo() {
  14116. m.batch_no = nil
  14117. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  14118. }
  14119. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  14120. func (m *MsgMutation) BatchNoCleared() bool {
  14121. _, ok := m.clearedFields[msg.FieldBatchNo]
  14122. return ok
  14123. }
  14124. // ResetBatchNo resets all changes to the "batch_no" field.
  14125. func (m *MsgMutation) ResetBatchNo() {
  14126. m.batch_no = nil
  14127. delete(m.clearedFields, msg.FieldBatchNo)
  14128. }
  14129. // Where appends a list predicates to the MsgMutation builder.
  14130. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  14131. m.predicates = append(m.predicates, ps...)
  14132. }
  14133. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  14134. // users can use type-assertion to append predicates that do not depend on any generated package.
  14135. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  14136. p := make([]predicate.Msg, len(ps))
  14137. for i := range ps {
  14138. p[i] = ps[i]
  14139. }
  14140. m.Where(p...)
  14141. }
  14142. // Op returns the operation name.
  14143. func (m *MsgMutation) Op() Op {
  14144. return m.op
  14145. }
  14146. // SetOp allows setting the mutation operation.
  14147. func (m *MsgMutation) SetOp(op Op) {
  14148. m.op = op
  14149. }
  14150. // Type returns the node type of this mutation (Msg).
  14151. func (m *MsgMutation) Type() string {
  14152. return m.typ
  14153. }
  14154. // Fields returns all fields that were changed during this mutation. Note that in
  14155. // order to get all numeric fields that were incremented/decremented, call
  14156. // AddedFields().
  14157. func (m *MsgMutation) Fields() []string {
  14158. fields := make([]string, 0, 9)
  14159. if m.created_at != nil {
  14160. fields = append(fields, msg.FieldCreatedAt)
  14161. }
  14162. if m.updated_at != nil {
  14163. fields = append(fields, msg.FieldUpdatedAt)
  14164. }
  14165. if m.deleted_at != nil {
  14166. fields = append(fields, msg.FieldDeletedAt)
  14167. }
  14168. if m.status != nil {
  14169. fields = append(fields, msg.FieldStatus)
  14170. }
  14171. if m.fromwxid != nil {
  14172. fields = append(fields, msg.FieldFromwxid)
  14173. }
  14174. if m.toid != nil {
  14175. fields = append(fields, msg.FieldToid)
  14176. }
  14177. if m.msgtype != nil {
  14178. fields = append(fields, msg.FieldMsgtype)
  14179. }
  14180. if m.msg != nil {
  14181. fields = append(fields, msg.FieldMsg)
  14182. }
  14183. if m.batch_no != nil {
  14184. fields = append(fields, msg.FieldBatchNo)
  14185. }
  14186. return fields
  14187. }
  14188. // Field returns the value of a field with the given name. The second boolean
  14189. // return value indicates that this field was not set, or was not defined in the
  14190. // schema.
  14191. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  14192. switch name {
  14193. case msg.FieldCreatedAt:
  14194. return m.CreatedAt()
  14195. case msg.FieldUpdatedAt:
  14196. return m.UpdatedAt()
  14197. case msg.FieldDeletedAt:
  14198. return m.DeletedAt()
  14199. case msg.FieldStatus:
  14200. return m.Status()
  14201. case msg.FieldFromwxid:
  14202. return m.Fromwxid()
  14203. case msg.FieldToid:
  14204. return m.Toid()
  14205. case msg.FieldMsgtype:
  14206. return m.Msgtype()
  14207. case msg.FieldMsg:
  14208. return m.Msg()
  14209. case msg.FieldBatchNo:
  14210. return m.BatchNo()
  14211. }
  14212. return nil, false
  14213. }
  14214. // OldField returns the old value of the field from the database. An error is
  14215. // returned if the mutation operation is not UpdateOne, or the query to the
  14216. // database failed.
  14217. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14218. switch name {
  14219. case msg.FieldCreatedAt:
  14220. return m.OldCreatedAt(ctx)
  14221. case msg.FieldUpdatedAt:
  14222. return m.OldUpdatedAt(ctx)
  14223. case msg.FieldDeletedAt:
  14224. return m.OldDeletedAt(ctx)
  14225. case msg.FieldStatus:
  14226. return m.OldStatus(ctx)
  14227. case msg.FieldFromwxid:
  14228. return m.OldFromwxid(ctx)
  14229. case msg.FieldToid:
  14230. return m.OldToid(ctx)
  14231. case msg.FieldMsgtype:
  14232. return m.OldMsgtype(ctx)
  14233. case msg.FieldMsg:
  14234. return m.OldMsg(ctx)
  14235. case msg.FieldBatchNo:
  14236. return m.OldBatchNo(ctx)
  14237. }
  14238. return nil, fmt.Errorf("unknown Msg field %s", name)
  14239. }
  14240. // SetField sets the value of a field with the given name. It returns an error if
  14241. // the field is not defined in the schema, or if the type mismatched the field
  14242. // type.
  14243. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  14244. switch name {
  14245. case msg.FieldCreatedAt:
  14246. v, ok := value.(time.Time)
  14247. if !ok {
  14248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14249. }
  14250. m.SetCreatedAt(v)
  14251. return nil
  14252. case msg.FieldUpdatedAt:
  14253. v, ok := value.(time.Time)
  14254. if !ok {
  14255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14256. }
  14257. m.SetUpdatedAt(v)
  14258. return nil
  14259. case msg.FieldDeletedAt:
  14260. v, ok := value.(time.Time)
  14261. if !ok {
  14262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14263. }
  14264. m.SetDeletedAt(v)
  14265. return nil
  14266. case msg.FieldStatus:
  14267. v, ok := value.(uint8)
  14268. if !ok {
  14269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14270. }
  14271. m.SetStatus(v)
  14272. return nil
  14273. case msg.FieldFromwxid:
  14274. v, ok := value.(string)
  14275. if !ok {
  14276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14277. }
  14278. m.SetFromwxid(v)
  14279. return nil
  14280. case msg.FieldToid:
  14281. v, ok := value.(string)
  14282. if !ok {
  14283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14284. }
  14285. m.SetToid(v)
  14286. return nil
  14287. case msg.FieldMsgtype:
  14288. v, ok := value.(int32)
  14289. if !ok {
  14290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14291. }
  14292. m.SetMsgtype(v)
  14293. return nil
  14294. case msg.FieldMsg:
  14295. v, ok := value.(string)
  14296. if !ok {
  14297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14298. }
  14299. m.SetMsg(v)
  14300. return nil
  14301. case msg.FieldBatchNo:
  14302. v, ok := value.(string)
  14303. if !ok {
  14304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14305. }
  14306. m.SetBatchNo(v)
  14307. return nil
  14308. }
  14309. return fmt.Errorf("unknown Msg field %s", name)
  14310. }
  14311. // AddedFields returns all numeric fields that were incremented/decremented during
  14312. // this mutation.
  14313. func (m *MsgMutation) AddedFields() []string {
  14314. var fields []string
  14315. if m.addstatus != nil {
  14316. fields = append(fields, msg.FieldStatus)
  14317. }
  14318. if m.addmsgtype != nil {
  14319. fields = append(fields, msg.FieldMsgtype)
  14320. }
  14321. return fields
  14322. }
  14323. // AddedField returns the numeric value that was incremented/decremented on a field
  14324. // with the given name. The second boolean return value indicates that this field
  14325. // was not set, or was not defined in the schema.
  14326. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  14327. switch name {
  14328. case msg.FieldStatus:
  14329. return m.AddedStatus()
  14330. case msg.FieldMsgtype:
  14331. return m.AddedMsgtype()
  14332. }
  14333. return nil, false
  14334. }
  14335. // AddField adds the value to the field with the given name. It returns an error if
  14336. // the field is not defined in the schema, or if the type mismatched the field
  14337. // type.
  14338. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  14339. switch name {
  14340. case msg.FieldStatus:
  14341. v, ok := value.(int8)
  14342. if !ok {
  14343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14344. }
  14345. m.AddStatus(v)
  14346. return nil
  14347. case msg.FieldMsgtype:
  14348. v, ok := value.(int32)
  14349. if !ok {
  14350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14351. }
  14352. m.AddMsgtype(v)
  14353. return nil
  14354. }
  14355. return fmt.Errorf("unknown Msg numeric field %s", name)
  14356. }
  14357. // ClearedFields returns all nullable fields that were cleared during this
  14358. // mutation.
  14359. func (m *MsgMutation) ClearedFields() []string {
  14360. var fields []string
  14361. if m.FieldCleared(msg.FieldDeletedAt) {
  14362. fields = append(fields, msg.FieldDeletedAt)
  14363. }
  14364. if m.FieldCleared(msg.FieldStatus) {
  14365. fields = append(fields, msg.FieldStatus)
  14366. }
  14367. if m.FieldCleared(msg.FieldFromwxid) {
  14368. fields = append(fields, msg.FieldFromwxid)
  14369. }
  14370. if m.FieldCleared(msg.FieldToid) {
  14371. fields = append(fields, msg.FieldToid)
  14372. }
  14373. if m.FieldCleared(msg.FieldMsgtype) {
  14374. fields = append(fields, msg.FieldMsgtype)
  14375. }
  14376. if m.FieldCleared(msg.FieldMsg) {
  14377. fields = append(fields, msg.FieldMsg)
  14378. }
  14379. if m.FieldCleared(msg.FieldBatchNo) {
  14380. fields = append(fields, msg.FieldBatchNo)
  14381. }
  14382. return fields
  14383. }
  14384. // FieldCleared returns a boolean indicating if a field with the given name was
  14385. // cleared in this mutation.
  14386. func (m *MsgMutation) FieldCleared(name string) bool {
  14387. _, ok := m.clearedFields[name]
  14388. return ok
  14389. }
  14390. // ClearField clears the value of the field with the given name. It returns an
  14391. // error if the field is not defined in the schema.
  14392. func (m *MsgMutation) ClearField(name string) error {
  14393. switch name {
  14394. case msg.FieldDeletedAt:
  14395. m.ClearDeletedAt()
  14396. return nil
  14397. case msg.FieldStatus:
  14398. m.ClearStatus()
  14399. return nil
  14400. case msg.FieldFromwxid:
  14401. m.ClearFromwxid()
  14402. return nil
  14403. case msg.FieldToid:
  14404. m.ClearToid()
  14405. return nil
  14406. case msg.FieldMsgtype:
  14407. m.ClearMsgtype()
  14408. return nil
  14409. case msg.FieldMsg:
  14410. m.ClearMsg()
  14411. return nil
  14412. case msg.FieldBatchNo:
  14413. m.ClearBatchNo()
  14414. return nil
  14415. }
  14416. return fmt.Errorf("unknown Msg nullable field %s", name)
  14417. }
  14418. // ResetField resets all changes in the mutation for the field with the given name.
  14419. // It returns an error if the field is not defined in the schema.
  14420. func (m *MsgMutation) ResetField(name string) error {
  14421. switch name {
  14422. case msg.FieldCreatedAt:
  14423. m.ResetCreatedAt()
  14424. return nil
  14425. case msg.FieldUpdatedAt:
  14426. m.ResetUpdatedAt()
  14427. return nil
  14428. case msg.FieldDeletedAt:
  14429. m.ResetDeletedAt()
  14430. return nil
  14431. case msg.FieldStatus:
  14432. m.ResetStatus()
  14433. return nil
  14434. case msg.FieldFromwxid:
  14435. m.ResetFromwxid()
  14436. return nil
  14437. case msg.FieldToid:
  14438. m.ResetToid()
  14439. return nil
  14440. case msg.FieldMsgtype:
  14441. m.ResetMsgtype()
  14442. return nil
  14443. case msg.FieldMsg:
  14444. m.ResetMsg()
  14445. return nil
  14446. case msg.FieldBatchNo:
  14447. m.ResetBatchNo()
  14448. return nil
  14449. }
  14450. return fmt.Errorf("unknown Msg field %s", name)
  14451. }
  14452. // AddedEdges returns all edge names that were set/added in this mutation.
  14453. func (m *MsgMutation) AddedEdges() []string {
  14454. edges := make([]string, 0, 0)
  14455. return edges
  14456. }
  14457. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14458. // name in this mutation.
  14459. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  14460. return nil
  14461. }
  14462. // RemovedEdges returns all edge names that were removed in this mutation.
  14463. func (m *MsgMutation) RemovedEdges() []string {
  14464. edges := make([]string, 0, 0)
  14465. return edges
  14466. }
  14467. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14468. // the given name in this mutation.
  14469. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  14470. return nil
  14471. }
  14472. // ClearedEdges returns all edge names that were cleared in this mutation.
  14473. func (m *MsgMutation) ClearedEdges() []string {
  14474. edges := make([]string, 0, 0)
  14475. return edges
  14476. }
  14477. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14478. // was cleared in this mutation.
  14479. func (m *MsgMutation) EdgeCleared(name string) bool {
  14480. return false
  14481. }
  14482. // ClearEdge clears the value of the edge with the given name. It returns an error
  14483. // if that edge is not defined in the schema.
  14484. func (m *MsgMutation) ClearEdge(name string) error {
  14485. return fmt.Errorf("unknown Msg unique edge %s", name)
  14486. }
  14487. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14488. // It returns an error if the edge is not defined in the schema.
  14489. func (m *MsgMutation) ResetEdge(name string) error {
  14490. return fmt.Errorf("unknown Msg edge %s", name)
  14491. }
  14492. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  14493. type ServerMutation struct {
  14494. config
  14495. op Op
  14496. typ string
  14497. id *uint64
  14498. created_at *time.Time
  14499. updated_at *time.Time
  14500. status *uint8
  14501. addstatus *int8
  14502. deleted_at *time.Time
  14503. name *string
  14504. public_ip *string
  14505. private_ip *string
  14506. admin_port *string
  14507. clearedFields map[string]struct{}
  14508. wxs map[uint64]struct{}
  14509. removedwxs map[uint64]struct{}
  14510. clearedwxs bool
  14511. done bool
  14512. oldValue func(context.Context) (*Server, error)
  14513. predicates []predicate.Server
  14514. }
  14515. var _ ent.Mutation = (*ServerMutation)(nil)
  14516. // serverOption allows management of the mutation configuration using functional options.
  14517. type serverOption func(*ServerMutation)
  14518. // newServerMutation creates new mutation for the Server entity.
  14519. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  14520. m := &ServerMutation{
  14521. config: c,
  14522. op: op,
  14523. typ: TypeServer,
  14524. clearedFields: make(map[string]struct{}),
  14525. }
  14526. for _, opt := range opts {
  14527. opt(m)
  14528. }
  14529. return m
  14530. }
  14531. // withServerID sets the ID field of the mutation.
  14532. func withServerID(id uint64) serverOption {
  14533. return func(m *ServerMutation) {
  14534. var (
  14535. err error
  14536. once sync.Once
  14537. value *Server
  14538. )
  14539. m.oldValue = func(ctx context.Context) (*Server, error) {
  14540. once.Do(func() {
  14541. if m.done {
  14542. err = errors.New("querying old values post mutation is not allowed")
  14543. } else {
  14544. value, err = m.Client().Server.Get(ctx, id)
  14545. }
  14546. })
  14547. return value, err
  14548. }
  14549. m.id = &id
  14550. }
  14551. }
  14552. // withServer sets the old Server of the mutation.
  14553. func withServer(node *Server) serverOption {
  14554. return func(m *ServerMutation) {
  14555. m.oldValue = func(context.Context) (*Server, error) {
  14556. return node, nil
  14557. }
  14558. m.id = &node.ID
  14559. }
  14560. }
  14561. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14562. // executed in a transaction (ent.Tx), a transactional client is returned.
  14563. func (m ServerMutation) Client() *Client {
  14564. client := &Client{config: m.config}
  14565. client.init()
  14566. return client
  14567. }
  14568. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14569. // it returns an error otherwise.
  14570. func (m ServerMutation) Tx() (*Tx, error) {
  14571. if _, ok := m.driver.(*txDriver); !ok {
  14572. return nil, errors.New("ent: mutation is not running in a transaction")
  14573. }
  14574. tx := &Tx{config: m.config}
  14575. tx.init()
  14576. return tx, nil
  14577. }
  14578. // SetID sets the value of the id field. Note that this
  14579. // operation is only accepted on creation of Server entities.
  14580. func (m *ServerMutation) SetID(id uint64) {
  14581. m.id = &id
  14582. }
  14583. // ID returns the ID value in the mutation. Note that the ID is only available
  14584. // if it was provided to the builder or after it was returned from the database.
  14585. func (m *ServerMutation) ID() (id uint64, exists bool) {
  14586. if m.id == nil {
  14587. return
  14588. }
  14589. return *m.id, true
  14590. }
  14591. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14592. // That means, if the mutation is applied within a transaction with an isolation level such
  14593. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14594. // or updated by the mutation.
  14595. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  14596. switch {
  14597. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14598. id, exists := m.ID()
  14599. if exists {
  14600. return []uint64{id}, nil
  14601. }
  14602. fallthrough
  14603. case m.op.Is(OpUpdate | OpDelete):
  14604. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  14605. default:
  14606. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14607. }
  14608. }
  14609. // SetCreatedAt sets the "created_at" field.
  14610. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  14611. m.created_at = &t
  14612. }
  14613. // CreatedAt returns the value of the "created_at" field in the mutation.
  14614. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  14615. v := m.created_at
  14616. if v == nil {
  14617. return
  14618. }
  14619. return *v, true
  14620. }
  14621. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  14622. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14624. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14625. if !m.op.Is(OpUpdateOne) {
  14626. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14627. }
  14628. if m.id == nil || m.oldValue == nil {
  14629. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14630. }
  14631. oldValue, err := m.oldValue(ctx)
  14632. if err != nil {
  14633. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14634. }
  14635. return oldValue.CreatedAt, nil
  14636. }
  14637. // ResetCreatedAt resets all changes to the "created_at" field.
  14638. func (m *ServerMutation) ResetCreatedAt() {
  14639. m.created_at = nil
  14640. }
  14641. // SetUpdatedAt sets the "updated_at" field.
  14642. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  14643. m.updated_at = &t
  14644. }
  14645. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14646. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  14647. v := m.updated_at
  14648. if v == nil {
  14649. return
  14650. }
  14651. return *v, true
  14652. }
  14653. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  14654. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14656. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14657. if !m.op.Is(OpUpdateOne) {
  14658. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14659. }
  14660. if m.id == nil || m.oldValue == nil {
  14661. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14662. }
  14663. oldValue, err := m.oldValue(ctx)
  14664. if err != nil {
  14665. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14666. }
  14667. return oldValue.UpdatedAt, nil
  14668. }
  14669. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14670. func (m *ServerMutation) ResetUpdatedAt() {
  14671. m.updated_at = nil
  14672. }
  14673. // SetStatus sets the "status" field.
  14674. func (m *ServerMutation) SetStatus(u uint8) {
  14675. m.status = &u
  14676. m.addstatus = nil
  14677. }
  14678. // Status returns the value of the "status" field in the mutation.
  14679. func (m *ServerMutation) Status() (r uint8, exists bool) {
  14680. v := m.status
  14681. if v == nil {
  14682. return
  14683. }
  14684. return *v, true
  14685. }
  14686. // OldStatus returns the old "status" field's value of the Server entity.
  14687. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14689. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14690. if !m.op.Is(OpUpdateOne) {
  14691. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14692. }
  14693. if m.id == nil || m.oldValue == nil {
  14694. return v, errors.New("OldStatus requires an ID field in the mutation")
  14695. }
  14696. oldValue, err := m.oldValue(ctx)
  14697. if err != nil {
  14698. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14699. }
  14700. return oldValue.Status, nil
  14701. }
  14702. // AddStatus adds u to the "status" field.
  14703. func (m *ServerMutation) AddStatus(u int8) {
  14704. if m.addstatus != nil {
  14705. *m.addstatus += u
  14706. } else {
  14707. m.addstatus = &u
  14708. }
  14709. }
  14710. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14711. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  14712. v := m.addstatus
  14713. if v == nil {
  14714. return
  14715. }
  14716. return *v, true
  14717. }
  14718. // ClearStatus clears the value of the "status" field.
  14719. func (m *ServerMutation) ClearStatus() {
  14720. m.status = nil
  14721. m.addstatus = nil
  14722. m.clearedFields[server.FieldStatus] = struct{}{}
  14723. }
  14724. // StatusCleared returns if the "status" field was cleared in this mutation.
  14725. func (m *ServerMutation) StatusCleared() bool {
  14726. _, ok := m.clearedFields[server.FieldStatus]
  14727. return ok
  14728. }
  14729. // ResetStatus resets all changes to the "status" field.
  14730. func (m *ServerMutation) ResetStatus() {
  14731. m.status = nil
  14732. m.addstatus = nil
  14733. delete(m.clearedFields, server.FieldStatus)
  14734. }
  14735. // SetDeletedAt sets the "deleted_at" field.
  14736. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  14737. m.deleted_at = &t
  14738. }
  14739. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14740. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  14741. v := m.deleted_at
  14742. if v == nil {
  14743. return
  14744. }
  14745. return *v, true
  14746. }
  14747. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  14748. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14750. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14751. if !m.op.Is(OpUpdateOne) {
  14752. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14753. }
  14754. if m.id == nil || m.oldValue == nil {
  14755. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14756. }
  14757. oldValue, err := m.oldValue(ctx)
  14758. if err != nil {
  14759. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14760. }
  14761. return oldValue.DeletedAt, nil
  14762. }
  14763. // ClearDeletedAt clears the value of the "deleted_at" field.
  14764. func (m *ServerMutation) ClearDeletedAt() {
  14765. m.deleted_at = nil
  14766. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  14767. }
  14768. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14769. func (m *ServerMutation) DeletedAtCleared() bool {
  14770. _, ok := m.clearedFields[server.FieldDeletedAt]
  14771. return ok
  14772. }
  14773. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14774. func (m *ServerMutation) ResetDeletedAt() {
  14775. m.deleted_at = nil
  14776. delete(m.clearedFields, server.FieldDeletedAt)
  14777. }
  14778. // SetName sets the "name" field.
  14779. func (m *ServerMutation) SetName(s string) {
  14780. m.name = &s
  14781. }
  14782. // Name returns the value of the "name" field in the mutation.
  14783. func (m *ServerMutation) Name() (r string, exists bool) {
  14784. v := m.name
  14785. if v == nil {
  14786. return
  14787. }
  14788. return *v, true
  14789. }
  14790. // OldName returns the old "name" field's value of the Server entity.
  14791. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14793. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  14794. if !m.op.Is(OpUpdateOne) {
  14795. return v, errors.New("OldName is only allowed on UpdateOne operations")
  14796. }
  14797. if m.id == nil || m.oldValue == nil {
  14798. return v, errors.New("OldName requires an ID field in the mutation")
  14799. }
  14800. oldValue, err := m.oldValue(ctx)
  14801. if err != nil {
  14802. return v, fmt.Errorf("querying old value for OldName: %w", err)
  14803. }
  14804. return oldValue.Name, nil
  14805. }
  14806. // ResetName resets all changes to the "name" field.
  14807. func (m *ServerMutation) ResetName() {
  14808. m.name = nil
  14809. }
  14810. // SetPublicIP sets the "public_ip" field.
  14811. func (m *ServerMutation) SetPublicIP(s string) {
  14812. m.public_ip = &s
  14813. }
  14814. // PublicIP returns the value of the "public_ip" field in the mutation.
  14815. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  14816. v := m.public_ip
  14817. if v == nil {
  14818. return
  14819. }
  14820. return *v, true
  14821. }
  14822. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  14823. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14825. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  14826. if !m.op.Is(OpUpdateOne) {
  14827. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  14828. }
  14829. if m.id == nil || m.oldValue == nil {
  14830. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  14831. }
  14832. oldValue, err := m.oldValue(ctx)
  14833. if err != nil {
  14834. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  14835. }
  14836. return oldValue.PublicIP, nil
  14837. }
  14838. // ResetPublicIP resets all changes to the "public_ip" field.
  14839. func (m *ServerMutation) ResetPublicIP() {
  14840. m.public_ip = nil
  14841. }
  14842. // SetPrivateIP sets the "private_ip" field.
  14843. func (m *ServerMutation) SetPrivateIP(s string) {
  14844. m.private_ip = &s
  14845. }
  14846. // PrivateIP returns the value of the "private_ip" field in the mutation.
  14847. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  14848. v := m.private_ip
  14849. if v == nil {
  14850. return
  14851. }
  14852. return *v, true
  14853. }
  14854. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  14855. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14857. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  14858. if !m.op.Is(OpUpdateOne) {
  14859. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  14860. }
  14861. if m.id == nil || m.oldValue == nil {
  14862. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  14863. }
  14864. oldValue, err := m.oldValue(ctx)
  14865. if err != nil {
  14866. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  14867. }
  14868. return oldValue.PrivateIP, nil
  14869. }
  14870. // ResetPrivateIP resets all changes to the "private_ip" field.
  14871. func (m *ServerMutation) ResetPrivateIP() {
  14872. m.private_ip = nil
  14873. }
  14874. // SetAdminPort sets the "admin_port" field.
  14875. func (m *ServerMutation) SetAdminPort(s string) {
  14876. m.admin_port = &s
  14877. }
  14878. // AdminPort returns the value of the "admin_port" field in the mutation.
  14879. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  14880. v := m.admin_port
  14881. if v == nil {
  14882. return
  14883. }
  14884. return *v, true
  14885. }
  14886. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  14887. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14889. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  14890. if !m.op.Is(OpUpdateOne) {
  14891. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  14892. }
  14893. if m.id == nil || m.oldValue == nil {
  14894. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  14895. }
  14896. oldValue, err := m.oldValue(ctx)
  14897. if err != nil {
  14898. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  14899. }
  14900. return oldValue.AdminPort, nil
  14901. }
  14902. // ResetAdminPort resets all changes to the "admin_port" field.
  14903. func (m *ServerMutation) ResetAdminPort() {
  14904. m.admin_port = nil
  14905. }
  14906. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  14907. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  14908. if m.wxs == nil {
  14909. m.wxs = make(map[uint64]struct{})
  14910. }
  14911. for i := range ids {
  14912. m.wxs[ids[i]] = struct{}{}
  14913. }
  14914. }
  14915. // ClearWxs clears the "wxs" edge to the Wx entity.
  14916. func (m *ServerMutation) ClearWxs() {
  14917. m.clearedwxs = true
  14918. }
  14919. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  14920. func (m *ServerMutation) WxsCleared() bool {
  14921. return m.clearedwxs
  14922. }
  14923. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  14924. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  14925. if m.removedwxs == nil {
  14926. m.removedwxs = make(map[uint64]struct{})
  14927. }
  14928. for i := range ids {
  14929. delete(m.wxs, ids[i])
  14930. m.removedwxs[ids[i]] = struct{}{}
  14931. }
  14932. }
  14933. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  14934. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  14935. for id := range m.removedwxs {
  14936. ids = append(ids, id)
  14937. }
  14938. return
  14939. }
  14940. // WxsIDs returns the "wxs" edge IDs in the mutation.
  14941. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  14942. for id := range m.wxs {
  14943. ids = append(ids, id)
  14944. }
  14945. return
  14946. }
  14947. // ResetWxs resets all changes to the "wxs" edge.
  14948. func (m *ServerMutation) ResetWxs() {
  14949. m.wxs = nil
  14950. m.clearedwxs = false
  14951. m.removedwxs = nil
  14952. }
  14953. // Where appends a list predicates to the ServerMutation builder.
  14954. func (m *ServerMutation) Where(ps ...predicate.Server) {
  14955. m.predicates = append(m.predicates, ps...)
  14956. }
  14957. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  14958. // users can use type-assertion to append predicates that do not depend on any generated package.
  14959. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  14960. p := make([]predicate.Server, len(ps))
  14961. for i := range ps {
  14962. p[i] = ps[i]
  14963. }
  14964. m.Where(p...)
  14965. }
  14966. // Op returns the operation name.
  14967. func (m *ServerMutation) Op() Op {
  14968. return m.op
  14969. }
  14970. // SetOp allows setting the mutation operation.
  14971. func (m *ServerMutation) SetOp(op Op) {
  14972. m.op = op
  14973. }
  14974. // Type returns the node type of this mutation (Server).
  14975. func (m *ServerMutation) Type() string {
  14976. return m.typ
  14977. }
  14978. // Fields returns all fields that were changed during this mutation. Note that in
  14979. // order to get all numeric fields that were incremented/decremented, call
  14980. // AddedFields().
  14981. func (m *ServerMutation) Fields() []string {
  14982. fields := make([]string, 0, 8)
  14983. if m.created_at != nil {
  14984. fields = append(fields, server.FieldCreatedAt)
  14985. }
  14986. if m.updated_at != nil {
  14987. fields = append(fields, server.FieldUpdatedAt)
  14988. }
  14989. if m.status != nil {
  14990. fields = append(fields, server.FieldStatus)
  14991. }
  14992. if m.deleted_at != nil {
  14993. fields = append(fields, server.FieldDeletedAt)
  14994. }
  14995. if m.name != nil {
  14996. fields = append(fields, server.FieldName)
  14997. }
  14998. if m.public_ip != nil {
  14999. fields = append(fields, server.FieldPublicIP)
  15000. }
  15001. if m.private_ip != nil {
  15002. fields = append(fields, server.FieldPrivateIP)
  15003. }
  15004. if m.admin_port != nil {
  15005. fields = append(fields, server.FieldAdminPort)
  15006. }
  15007. return fields
  15008. }
  15009. // Field returns the value of a field with the given name. The second boolean
  15010. // return value indicates that this field was not set, or was not defined in the
  15011. // schema.
  15012. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  15013. switch name {
  15014. case server.FieldCreatedAt:
  15015. return m.CreatedAt()
  15016. case server.FieldUpdatedAt:
  15017. return m.UpdatedAt()
  15018. case server.FieldStatus:
  15019. return m.Status()
  15020. case server.FieldDeletedAt:
  15021. return m.DeletedAt()
  15022. case server.FieldName:
  15023. return m.Name()
  15024. case server.FieldPublicIP:
  15025. return m.PublicIP()
  15026. case server.FieldPrivateIP:
  15027. return m.PrivateIP()
  15028. case server.FieldAdminPort:
  15029. return m.AdminPort()
  15030. }
  15031. return nil, false
  15032. }
  15033. // OldField returns the old value of the field from the database. An error is
  15034. // returned if the mutation operation is not UpdateOne, or the query to the
  15035. // database failed.
  15036. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15037. switch name {
  15038. case server.FieldCreatedAt:
  15039. return m.OldCreatedAt(ctx)
  15040. case server.FieldUpdatedAt:
  15041. return m.OldUpdatedAt(ctx)
  15042. case server.FieldStatus:
  15043. return m.OldStatus(ctx)
  15044. case server.FieldDeletedAt:
  15045. return m.OldDeletedAt(ctx)
  15046. case server.FieldName:
  15047. return m.OldName(ctx)
  15048. case server.FieldPublicIP:
  15049. return m.OldPublicIP(ctx)
  15050. case server.FieldPrivateIP:
  15051. return m.OldPrivateIP(ctx)
  15052. case server.FieldAdminPort:
  15053. return m.OldAdminPort(ctx)
  15054. }
  15055. return nil, fmt.Errorf("unknown Server field %s", name)
  15056. }
  15057. // SetField sets the value of a field with the given name. It returns an error if
  15058. // the field is not defined in the schema, or if the type mismatched the field
  15059. // type.
  15060. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  15061. switch name {
  15062. case server.FieldCreatedAt:
  15063. v, ok := value.(time.Time)
  15064. if !ok {
  15065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15066. }
  15067. m.SetCreatedAt(v)
  15068. return nil
  15069. case server.FieldUpdatedAt:
  15070. v, ok := value.(time.Time)
  15071. if !ok {
  15072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15073. }
  15074. m.SetUpdatedAt(v)
  15075. return nil
  15076. case server.FieldStatus:
  15077. v, ok := value.(uint8)
  15078. if !ok {
  15079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15080. }
  15081. m.SetStatus(v)
  15082. return nil
  15083. case server.FieldDeletedAt:
  15084. v, ok := value.(time.Time)
  15085. if !ok {
  15086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15087. }
  15088. m.SetDeletedAt(v)
  15089. return nil
  15090. case server.FieldName:
  15091. v, ok := value.(string)
  15092. if !ok {
  15093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15094. }
  15095. m.SetName(v)
  15096. return nil
  15097. case server.FieldPublicIP:
  15098. v, ok := value.(string)
  15099. if !ok {
  15100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15101. }
  15102. m.SetPublicIP(v)
  15103. return nil
  15104. case server.FieldPrivateIP:
  15105. v, ok := value.(string)
  15106. if !ok {
  15107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15108. }
  15109. m.SetPrivateIP(v)
  15110. return nil
  15111. case server.FieldAdminPort:
  15112. v, ok := value.(string)
  15113. if !ok {
  15114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15115. }
  15116. m.SetAdminPort(v)
  15117. return nil
  15118. }
  15119. return fmt.Errorf("unknown Server field %s", name)
  15120. }
  15121. // AddedFields returns all numeric fields that were incremented/decremented during
  15122. // this mutation.
  15123. func (m *ServerMutation) AddedFields() []string {
  15124. var fields []string
  15125. if m.addstatus != nil {
  15126. fields = append(fields, server.FieldStatus)
  15127. }
  15128. return fields
  15129. }
  15130. // AddedField returns the numeric value that was incremented/decremented on a field
  15131. // with the given name. The second boolean return value indicates that this field
  15132. // was not set, or was not defined in the schema.
  15133. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  15134. switch name {
  15135. case server.FieldStatus:
  15136. return m.AddedStatus()
  15137. }
  15138. return nil, false
  15139. }
  15140. // AddField adds the value to the field with the given name. It returns an error if
  15141. // the field is not defined in the schema, or if the type mismatched the field
  15142. // type.
  15143. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  15144. switch name {
  15145. case server.FieldStatus:
  15146. v, ok := value.(int8)
  15147. if !ok {
  15148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15149. }
  15150. m.AddStatus(v)
  15151. return nil
  15152. }
  15153. return fmt.Errorf("unknown Server numeric field %s", name)
  15154. }
  15155. // ClearedFields returns all nullable fields that were cleared during this
  15156. // mutation.
  15157. func (m *ServerMutation) ClearedFields() []string {
  15158. var fields []string
  15159. if m.FieldCleared(server.FieldStatus) {
  15160. fields = append(fields, server.FieldStatus)
  15161. }
  15162. if m.FieldCleared(server.FieldDeletedAt) {
  15163. fields = append(fields, server.FieldDeletedAt)
  15164. }
  15165. return fields
  15166. }
  15167. // FieldCleared returns a boolean indicating if a field with the given name was
  15168. // cleared in this mutation.
  15169. func (m *ServerMutation) FieldCleared(name string) bool {
  15170. _, ok := m.clearedFields[name]
  15171. return ok
  15172. }
  15173. // ClearField clears the value of the field with the given name. It returns an
  15174. // error if the field is not defined in the schema.
  15175. func (m *ServerMutation) ClearField(name string) error {
  15176. switch name {
  15177. case server.FieldStatus:
  15178. m.ClearStatus()
  15179. return nil
  15180. case server.FieldDeletedAt:
  15181. m.ClearDeletedAt()
  15182. return nil
  15183. }
  15184. return fmt.Errorf("unknown Server nullable field %s", name)
  15185. }
  15186. // ResetField resets all changes in the mutation for the field with the given name.
  15187. // It returns an error if the field is not defined in the schema.
  15188. func (m *ServerMutation) ResetField(name string) error {
  15189. switch name {
  15190. case server.FieldCreatedAt:
  15191. m.ResetCreatedAt()
  15192. return nil
  15193. case server.FieldUpdatedAt:
  15194. m.ResetUpdatedAt()
  15195. return nil
  15196. case server.FieldStatus:
  15197. m.ResetStatus()
  15198. return nil
  15199. case server.FieldDeletedAt:
  15200. m.ResetDeletedAt()
  15201. return nil
  15202. case server.FieldName:
  15203. m.ResetName()
  15204. return nil
  15205. case server.FieldPublicIP:
  15206. m.ResetPublicIP()
  15207. return nil
  15208. case server.FieldPrivateIP:
  15209. m.ResetPrivateIP()
  15210. return nil
  15211. case server.FieldAdminPort:
  15212. m.ResetAdminPort()
  15213. return nil
  15214. }
  15215. return fmt.Errorf("unknown Server field %s", name)
  15216. }
  15217. // AddedEdges returns all edge names that were set/added in this mutation.
  15218. func (m *ServerMutation) AddedEdges() []string {
  15219. edges := make([]string, 0, 1)
  15220. if m.wxs != nil {
  15221. edges = append(edges, server.EdgeWxs)
  15222. }
  15223. return edges
  15224. }
  15225. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15226. // name in this mutation.
  15227. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  15228. switch name {
  15229. case server.EdgeWxs:
  15230. ids := make([]ent.Value, 0, len(m.wxs))
  15231. for id := range m.wxs {
  15232. ids = append(ids, id)
  15233. }
  15234. return ids
  15235. }
  15236. return nil
  15237. }
  15238. // RemovedEdges returns all edge names that were removed in this mutation.
  15239. func (m *ServerMutation) RemovedEdges() []string {
  15240. edges := make([]string, 0, 1)
  15241. if m.removedwxs != nil {
  15242. edges = append(edges, server.EdgeWxs)
  15243. }
  15244. return edges
  15245. }
  15246. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15247. // the given name in this mutation.
  15248. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  15249. switch name {
  15250. case server.EdgeWxs:
  15251. ids := make([]ent.Value, 0, len(m.removedwxs))
  15252. for id := range m.removedwxs {
  15253. ids = append(ids, id)
  15254. }
  15255. return ids
  15256. }
  15257. return nil
  15258. }
  15259. // ClearedEdges returns all edge names that were cleared in this mutation.
  15260. func (m *ServerMutation) ClearedEdges() []string {
  15261. edges := make([]string, 0, 1)
  15262. if m.clearedwxs {
  15263. edges = append(edges, server.EdgeWxs)
  15264. }
  15265. return edges
  15266. }
  15267. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15268. // was cleared in this mutation.
  15269. func (m *ServerMutation) EdgeCleared(name string) bool {
  15270. switch name {
  15271. case server.EdgeWxs:
  15272. return m.clearedwxs
  15273. }
  15274. return false
  15275. }
  15276. // ClearEdge clears the value of the edge with the given name. It returns an error
  15277. // if that edge is not defined in the schema.
  15278. func (m *ServerMutation) ClearEdge(name string) error {
  15279. switch name {
  15280. }
  15281. return fmt.Errorf("unknown Server unique edge %s", name)
  15282. }
  15283. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15284. // It returns an error if the edge is not defined in the schema.
  15285. func (m *ServerMutation) ResetEdge(name string) error {
  15286. switch name {
  15287. case server.EdgeWxs:
  15288. m.ResetWxs()
  15289. return nil
  15290. }
  15291. return fmt.Errorf("unknown Server edge %s", name)
  15292. }
  15293. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  15294. type SopNodeMutation struct {
  15295. config
  15296. op Op
  15297. typ string
  15298. id *uint64
  15299. created_at *time.Time
  15300. updated_at *time.Time
  15301. status *uint8
  15302. addstatus *int8
  15303. deleted_at *time.Time
  15304. parent_id *uint64
  15305. addparent_id *int64
  15306. name *string
  15307. condition_type *int
  15308. addcondition_type *int
  15309. condition_list *[]string
  15310. appendcondition_list []string
  15311. no_reply_condition *uint64
  15312. addno_reply_condition *int64
  15313. no_reply_unit *string
  15314. action_message *[]custom_types.Action
  15315. appendaction_message []custom_types.Action
  15316. action_label_add *[]uint64
  15317. appendaction_label_add []uint64
  15318. action_label_del *[]uint64
  15319. appendaction_label_del []uint64
  15320. action_forward **custom_types.ActionForward
  15321. clearedFields map[string]struct{}
  15322. sop_stage *uint64
  15323. clearedsop_stage bool
  15324. node_messages map[uint64]struct{}
  15325. removednode_messages map[uint64]struct{}
  15326. clearednode_messages bool
  15327. done bool
  15328. oldValue func(context.Context) (*SopNode, error)
  15329. predicates []predicate.SopNode
  15330. }
  15331. var _ ent.Mutation = (*SopNodeMutation)(nil)
  15332. // sopnodeOption allows management of the mutation configuration using functional options.
  15333. type sopnodeOption func(*SopNodeMutation)
  15334. // newSopNodeMutation creates new mutation for the SopNode entity.
  15335. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  15336. m := &SopNodeMutation{
  15337. config: c,
  15338. op: op,
  15339. typ: TypeSopNode,
  15340. clearedFields: make(map[string]struct{}),
  15341. }
  15342. for _, opt := range opts {
  15343. opt(m)
  15344. }
  15345. return m
  15346. }
  15347. // withSopNodeID sets the ID field of the mutation.
  15348. func withSopNodeID(id uint64) sopnodeOption {
  15349. return func(m *SopNodeMutation) {
  15350. var (
  15351. err error
  15352. once sync.Once
  15353. value *SopNode
  15354. )
  15355. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  15356. once.Do(func() {
  15357. if m.done {
  15358. err = errors.New("querying old values post mutation is not allowed")
  15359. } else {
  15360. value, err = m.Client().SopNode.Get(ctx, id)
  15361. }
  15362. })
  15363. return value, err
  15364. }
  15365. m.id = &id
  15366. }
  15367. }
  15368. // withSopNode sets the old SopNode of the mutation.
  15369. func withSopNode(node *SopNode) sopnodeOption {
  15370. return func(m *SopNodeMutation) {
  15371. m.oldValue = func(context.Context) (*SopNode, error) {
  15372. return node, nil
  15373. }
  15374. m.id = &node.ID
  15375. }
  15376. }
  15377. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15378. // executed in a transaction (ent.Tx), a transactional client is returned.
  15379. func (m SopNodeMutation) Client() *Client {
  15380. client := &Client{config: m.config}
  15381. client.init()
  15382. return client
  15383. }
  15384. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15385. // it returns an error otherwise.
  15386. func (m SopNodeMutation) Tx() (*Tx, error) {
  15387. if _, ok := m.driver.(*txDriver); !ok {
  15388. return nil, errors.New("ent: mutation is not running in a transaction")
  15389. }
  15390. tx := &Tx{config: m.config}
  15391. tx.init()
  15392. return tx, nil
  15393. }
  15394. // SetID sets the value of the id field. Note that this
  15395. // operation is only accepted on creation of SopNode entities.
  15396. func (m *SopNodeMutation) SetID(id uint64) {
  15397. m.id = &id
  15398. }
  15399. // ID returns the ID value in the mutation. Note that the ID is only available
  15400. // if it was provided to the builder or after it was returned from the database.
  15401. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  15402. if m.id == nil {
  15403. return
  15404. }
  15405. return *m.id, true
  15406. }
  15407. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15408. // That means, if the mutation is applied within a transaction with an isolation level such
  15409. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15410. // or updated by the mutation.
  15411. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  15412. switch {
  15413. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15414. id, exists := m.ID()
  15415. if exists {
  15416. return []uint64{id}, nil
  15417. }
  15418. fallthrough
  15419. case m.op.Is(OpUpdate | OpDelete):
  15420. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  15421. default:
  15422. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15423. }
  15424. }
  15425. // SetCreatedAt sets the "created_at" field.
  15426. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  15427. m.created_at = &t
  15428. }
  15429. // CreatedAt returns the value of the "created_at" field in the mutation.
  15430. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  15431. v := m.created_at
  15432. if v == nil {
  15433. return
  15434. }
  15435. return *v, true
  15436. }
  15437. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  15438. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15440. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15441. if !m.op.Is(OpUpdateOne) {
  15442. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15443. }
  15444. if m.id == nil || m.oldValue == nil {
  15445. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15446. }
  15447. oldValue, err := m.oldValue(ctx)
  15448. if err != nil {
  15449. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15450. }
  15451. return oldValue.CreatedAt, nil
  15452. }
  15453. // ResetCreatedAt resets all changes to the "created_at" field.
  15454. func (m *SopNodeMutation) ResetCreatedAt() {
  15455. m.created_at = nil
  15456. }
  15457. // SetUpdatedAt sets the "updated_at" field.
  15458. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  15459. m.updated_at = &t
  15460. }
  15461. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15462. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  15463. v := m.updated_at
  15464. if v == nil {
  15465. return
  15466. }
  15467. return *v, true
  15468. }
  15469. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  15470. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15472. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15473. if !m.op.Is(OpUpdateOne) {
  15474. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15475. }
  15476. if m.id == nil || m.oldValue == nil {
  15477. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15478. }
  15479. oldValue, err := m.oldValue(ctx)
  15480. if err != nil {
  15481. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15482. }
  15483. return oldValue.UpdatedAt, nil
  15484. }
  15485. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15486. func (m *SopNodeMutation) ResetUpdatedAt() {
  15487. m.updated_at = nil
  15488. }
  15489. // SetStatus sets the "status" field.
  15490. func (m *SopNodeMutation) SetStatus(u uint8) {
  15491. m.status = &u
  15492. m.addstatus = nil
  15493. }
  15494. // Status returns the value of the "status" field in the mutation.
  15495. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  15496. v := m.status
  15497. if v == nil {
  15498. return
  15499. }
  15500. return *v, true
  15501. }
  15502. // OldStatus returns the old "status" field's value of the SopNode entity.
  15503. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15505. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15506. if !m.op.Is(OpUpdateOne) {
  15507. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15508. }
  15509. if m.id == nil || m.oldValue == nil {
  15510. return v, errors.New("OldStatus requires an ID field in the mutation")
  15511. }
  15512. oldValue, err := m.oldValue(ctx)
  15513. if err != nil {
  15514. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15515. }
  15516. return oldValue.Status, nil
  15517. }
  15518. // AddStatus adds u to the "status" field.
  15519. func (m *SopNodeMutation) AddStatus(u int8) {
  15520. if m.addstatus != nil {
  15521. *m.addstatus += u
  15522. } else {
  15523. m.addstatus = &u
  15524. }
  15525. }
  15526. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15527. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  15528. v := m.addstatus
  15529. if v == nil {
  15530. return
  15531. }
  15532. return *v, true
  15533. }
  15534. // ClearStatus clears the value of the "status" field.
  15535. func (m *SopNodeMutation) ClearStatus() {
  15536. m.status = nil
  15537. m.addstatus = nil
  15538. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  15539. }
  15540. // StatusCleared returns if the "status" field was cleared in this mutation.
  15541. func (m *SopNodeMutation) StatusCleared() bool {
  15542. _, ok := m.clearedFields[sopnode.FieldStatus]
  15543. return ok
  15544. }
  15545. // ResetStatus resets all changes to the "status" field.
  15546. func (m *SopNodeMutation) ResetStatus() {
  15547. m.status = nil
  15548. m.addstatus = nil
  15549. delete(m.clearedFields, sopnode.FieldStatus)
  15550. }
  15551. // SetDeletedAt sets the "deleted_at" field.
  15552. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  15553. m.deleted_at = &t
  15554. }
  15555. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15556. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  15557. v := m.deleted_at
  15558. if v == nil {
  15559. return
  15560. }
  15561. return *v, true
  15562. }
  15563. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  15564. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15566. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15567. if !m.op.Is(OpUpdateOne) {
  15568. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15569. }
  15570. if m.id == nil || m.oldValue == nil {
  15571. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15572. }
  15573. oldValue, err := m.oldValue(ctx)
  15574. if err != nil {
  15575. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15576. }
  15577. return oldValue.DeletedAt, nil
  15578. }
  15579. // ClearDeletedAt clears the value of the "deleted_at" field.
  15580. func (m *SopNodeMutation) ClearDeletedAt() {
  15581. m.deleted_at = nil
  15582. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  15583. }
  15584. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15585. func (m *SopNodeMutation) DeletedAtCleared() bool {
  15586. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  15587. return ok
  15588. }
  15589. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15590. func (m *SopNodeMutation) ResetDeletedAt() {
  15591. m.deleted_at = nil
  15592. delete(m.clearedFields, sopnode.FieldDeletedAt)
  15593. }
  15594. // SetStageID sets the "stage_id" field.
  15595. func (m *SopNodeMutation) SetStageID(u uint64) {
  15596. m.sop_stage = &u
  15597. }
  15598. // StageID returns the value of the "stage_id" field in the mutation.
  15599. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  15600. v := m.sop_stage
  15601. if v == nil {
  15602. return
  15603. }
  15604. return *v, true
  15605. }
  15606. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  15607. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15609. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  15610. if !m.op.Is(OpUpdateOne) {
  15611. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  15612. }
  15613. if m.id == nil || m.oldValue == nil {
  15614. return v, errors.New("OldStageID requires an ID field in the mutation")
  15615. }
  15616. oldValue, err := m.oldValue(ctx)
  15617. if err != nil {
  15618. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  15619. }
  15620. return oldValue.StageID, nil
  15621. }
  15622. // ResetStageID resets all changes to the "stage_id" field.
  15623. func (m *SopNodeMutation) ResetStageID() {
  15624. m.sop_stage = nil
  15625. }
  15626. // SetParentID sets the "parent_id" field.
  15627. func (m *SopNodeMutation) SetParentID(u uint64) {
  15628. m.parent_id = &u
  15629. m.addparent_id = nil
  15630. }
  15631. // ParentID returns the value of the "parent_id" field in the mutation.
  15632. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  15633. v := m.parent_id
  15634. if v == nil {
  15635. return
  15636. }
  15637. return *v, true
  15638. }
  15639. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  15640. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15642. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  15643. if !m.op.Is(OpUpdateOne) {
  15644. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  15645. }
  15646. if m.id == nil || m.oldValue == nil {
  15647. return v, errors.New("OldParentID requires an ID field in the mutation")
  15648. }
  15649. oldValue, err := m.oldValue(ctx)
  15650. if err != nil {
  15651. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  15652. }
  15653. return oldValue.ParentID, nil
  15654. }
  15655. // AddParentID adds u to the "parent_id" field.
  15656. func (m *SopNodeMutation) AddParentID(u int64) {
  15657. if m.addparent_id != nil {
  15658. *m.addparent_id += u
  15659. } else {
  15660. m.addparent_id = &u
  15661. }
  15662. }
  15663. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  15664. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  15665. v := m.addparent_id
  15666. if v == nil {
  15667. return
  15668. }
  15669. return *v, true
  15670. }
  15671. // ResetParentID resets all changes to the "parent_id" field.
  15672. func (m *SopNodeMutation) ResetParentID() {
  15673. m.parent_id = nil
  15674. m.addparent_id = nil
  15675. }
  15676. // SetName sets the "name" field.
  15677. func (m *SopNodeMutation) SetName(s string) {
  15678. m.name = &s
  15679. }
  15680. // Name returns the value of the "name" field in the mutation.
  15681. func (m *SopNodeMutation) Name() (r string, exists bool) {
  15682. v := m.name
  15683. if v == nil {
  15684. return
  15685. }
  15686. return *v, true
  15687. }
  15688. // OldName returns the old "name" field's value of the SopNode entity.
  15689. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15691. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  15692. if !m.op.Is(OpUpdateOne) {
  15693. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15694. }
  15695. if m.id == nil || m.oldValue == nil {
  15696. return v, errors.New("OldName requires an ID field in the mutation")
  15697. }
  15698. oldValue, err := m.oldValue(ctx)
  15699. if err != nil {
  15700. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15701. }
  15702. return oldValue.Name, nil
  15703. }
  15704. // ResetName resets all changes to the "name" field.
  15705. func (m *SopNodeMutation) ResetName() {
  15706. m.name = nil
  15707. }
  15708. // SetConditionType sets the "condition_type" field.
  15709. func (m *SopNodeMutation) SetConditionType(i int) {
  15710. m.condition_type = &i
  15711. m.addcondition_type = nil
  15712. }
  15713. // ConditionType returns the value of the "condition_type" field in the mutation.
  15714. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  15715. v := m.condition_type
  15716. if v == nil {
  15717. return
  15718. }
  15719. return *v, true
  15720. }
  15721. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  15722. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15724. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  15725. if !m.op.Is(OpUpdateOne) {
  15726. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  15727. }
  15728. if m.id == nil || m.oldValue == nil {
  15729. return v, errors.New("OldConditionType requires an ID field in the mutation")
  15730. }
  15731. oldValue, err := m.oldValue(ctx)
  15732. if err != nil {
  15733. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  15734. }
  15735. return oldValue.ConditionType, nil
  15736. }
  15737. // AddConditionType adds i to the "condition_type" field.
  15738. func (m *SopNodeMutation) AddConditionType(i int) {
  15739. if m.addcondition_type != nil {
  15740. *m.addcondition_type += i
  15741. } else {
  15742. m.addcondition_type = &i
  15743. }
  15744. }
  15745. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  15746. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  15747. v := m.addcondition_type
  15748. if v == nil {
  15749. return
  15750. }
  15751. return *v, true
  15752. }
  15753. // ResetConditionType resets all changes to the "condition_type" field.
  15754. func (m *SopNodeMutation) ResetConditionType() {
  15755. m.condition_type = nil
  15756. m.addcondition_type = nil
  15757. }
  15758. // SetConditionList sets the "condition_list" field.
  15759. func (m *SopNodeMutation) SetConditionList(s []string) {
  15760. m.condition_list = &s
  15761. m.appendcondition_list = nil
  15762. }
  15763. // ConditionList returns the value of the "condition_list" field in the mutation.
  15764. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  15765. v := m.condition_list
  15766. if v == nil {
  15767. return
  15768. }
  15769. return *v, true
  15770. }
  15771. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  15772. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15774. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  15775. if !m.op.Is(OpUpdateOne) {
  15776. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  15777. }
  15778. if m.id == nil || m.oldValue == nil {
  15779. return v, errors.New("OldConditionList requires an ID field in the mutation")
  15780. }
  15781. oldValue, err := m.oldValue(ctx)
  15782. if err != nil {
  15783. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  15784. }
  15785. return oldValue.ConditionList, nil
  15786. }
  15787. // AppendConditionList adds s to the "condition_list" field.
  15788. func (m *SopNodeMutation) AppendConditionList(s []string) {
  15789. m.appendcondition_list = append(m.appendcondition_list, s...)
  15790. }
  15791. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  15792. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  15793. if len(m.appendcondition_list) == 0 {
  15794. return nil, false
  15795. }
  15796. return m.appendcondition_list, true
  15797. }
  15798. // ClearConditionList clears the value of the "condition_list" field.
  15799. func (m *SopNodeMutation) ClearConditionList() {
  15800. m.condition_list = nil
  15801. m.appendcondition_list = nil
  15802. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  15803. }
  15804. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  15805. func (m *SopNodeMutation) ConditionListCleared() bool {
  15806. _, ok := m.clearedFields[sopnode.FieldConditionList]
  15807. return ok
  15808. }
  15809. // ResetConditionList resets all changes to the "condition_list" field.
  15810. func (m *SopNodeMutation) ResetConditionList() {
  15811. m.condition_list = nil
  15812. m.appendcondition_list = nil
  15813. delete(m.clearedFields, sopnode.FieldConditionList)
  15814. }
  15815. // SetNoReplyCondition sets the "no_reply_condition" field.
  15816. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  15817. m.no_reply_condition = &u
  15818. m.addno_reply_condition = nil
  15819. }
  15820. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  15821. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  15822. v := m.no_reply_condition
  15823. if v == nil {
  15824. return
  15825. }
  15826. return *v, true
  15827. }
  15828. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  15829. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15831. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  15832. if !m.op.Is(OpUpdateOne) {
  15833. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  15834. }
  15835. if m.id == nil || m.oldValue == nil {
  15836. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  15837. }
  15838. oldValue, err := m.oldValue(ctx)
  15839. if err != nil {
  15840. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  15841. }
  15842. return oldValue.NoReplyCondition, nil
  15843. }
  15844. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  15845. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  15846. if m.addno_reply_condition != nil {
  15847. *m.addno_reply_condition += u
  15848. } else {
  15849. m.addno_reply_condition = &u
  15850. }
  15851. }
  15852. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  15853. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  15854. v := m.addno_reply_condition
  15855. if v == nil {
  15856. return
  15857. }
  15858. return *v, true
  15859. }
  15860. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  15861. func (m *SopNodeMutation) ResetNoReplyCondition() {
  15862. m.no_reply_condition = nil
  15863. m.addno_reply_condition = nil
  15864. }
  15865. // SetNoReplyUnit sets the "no_reply_unit" field.
  15866. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  15867. m.no_reply_unit = &s
  15868. }
  15869. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  15870. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  15871. v := m.no_reply_unit
  15872. if v == nil {
  15873. return
  15874. }
  15875. return *v, true
  15876. }
  15877. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  15878. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15880. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  15881. if !m.op.Is(OpUpdateOne) {
  15882. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  15883. }
  15884. if m.id == nil || m.oldValue == nil {
  15885. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  15886. }
  15887. oldValue, err := m.oldValue(ctx)
  15888. if err != nil {
  15889. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  15890. }
  15891. return oldValue.NoReplyUnit, nil
  15892. }
  15893. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  15894. func (m *SopNodeMutation) ResetNoReplyUnit() {
  15895. m.no_reply_unit = nil
  15896. }
  15897. // SetActionMessage sets the "action_message" field.
  15898. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  15899. m.action_message = &ct
  15900. m.appendaction_message = nil
  15901. }
  15902. // ActionMessage returns the value of the "action_message" field in the mutation.
  15903. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  15904. v := m.action_message
  15905. if v == nil {
  15906. return
  15907. }
  15908. return *v, true
  15909. }
  15910. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  15911. // If the SopNode 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 *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  15914. if !m.op.Is(OpUpdateOne) {
  15915. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  15916. }
  15917. if m.id == nil || m.oldValue == nil {
  15918. return v, errors.New("OldActionMessage 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 OldActionMessage: %w", err)
  15923. }
  15924. return oldValue.ActionMessage, nil
  15925. }
  15926. // AppendActionMessage adds ct to the "action_message" field.
  15927. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  15928. m.appendaction_message = append(m.appendaction_message, ct...)
  15929. }
  15930. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  15931. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  15932. if len(m.appendaction_message) == 0 {
  15933. return nil, false
  15934. }
  15935. return m.appendaction_message, true
  15936. }
  15937. // ClearActionMessage clears the value of the "action_message" field.
  15938. func (m *SopNodeMutation) ClearActionMessage() {
  15939. m.action_message = nil
  15940. m.appendaction_message = nil
  15941. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  15942. }
  15943. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  15944. func (m *SopNodeMutation) ActionMessageCleared() bool {
  15945. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  15946. return ok
  15947. }
  15948. // ResetActionMessage resets all changes to the "action_message" field.
  15949. func (m *SopNodeMutation) ResetActionMessage() {
  15950. m.action_message = nil
  15951. m.appendaction_message = nil
  15952. delete(m.clearedFields, sopnode.FieldActionMessage)
  15953. }
  15954. // SetActionLabelAdd sets the "action_label_add" field.
  15955. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  15956. m.action_label_add = &u
  15957. m.appendaction_label_add = nil
  15958. }
  15959. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  15960. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  15961. v := m.action_label_add
  15962. if v == nil {
  15963. return
  15964. }
  15965. return *v, true
  15966. }
  15967. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  15968. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15970. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  15971. if !m.op.Is(OpUpdateOne) {
  15972. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  15973. }
  15974. if m.id == nil || m.oldValue == nil {
  15975. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  15976. }
  15977. oldValue, err := m.oldValue(ctx)
  15978. if err != nil {
  15979. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  15980. }
  15981. return oldValue.ActionLabelAdd, nil
  15982. }
  15983. // AppendActionLabelAdd adds u to the "action_label_add" field.
  15984. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  15985. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  15986. }
  15987. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  15988. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  15989. if len(m.appendaction_label_add) == 0 {
  15990. return nil, false
  15991. }
  15992. return m.appendaction_label_add, true
  15993. }
  15994. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  15995. func (m *SopNodeMutation) ClearActionLabelAdd() {
  15996. m.action_label_add = nil
  15997. m.appendaction_label_add = nil
  15998. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  15999. }
  16000. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  16001. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  16002. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  16003. return ok
  16004. }
  16005. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  16006. func (m *SopNodeMutation) ResetActionLabelAdd() {
  16007. m.action_label_add = nil
  16008. m.appendaction_label_add = nil
  16009. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  16010. }
  16011. // SetActionLabelDel sets the "action_label_del" field.
  16012. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  16013. m.action_label_del = &u
  16014. m.appendaction_label_del = nil
  16015. }
  16016. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  16017. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  16018. v := m.action_label_del
  16019. if v == nil {
  16020. return
  16021. }
  16022. return *v, true
  16023. }
  16024. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  16025. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16027. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  16028. if !m.op.Is(OpUpdateOne) {
  16029. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  16030. }
  16031. if m.id == nil || m.oldValue == nil {
  16032. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  16033. }
  16034. oldValue, err := m.oldValue(ctx)
  16035. if err != nil {
  16036. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  16037. }
  16038. return oldValue.ActionLabelDel, nil
  16039. }
  16040. // AppendActionLabelDel adds u to the "action_label_del" field.
  16041. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  16042. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  16043. }
  16044. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  16045. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  16046. if len(m.appendaction_label_del) == 0 {
  16047. return nil, false
  16048. }
  16049. return m.appendaction_label_del, true
  16050. }
  16051. // ClearActionLabelDel clears the value of the "action_label_del" field.
  16052. func (m *SopNodeMutation) ClearActionLabelDel() {
  16053. m.action_label_del = nil
  16054. m.appendaction_label_del = nil
  16055. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  16056. }
  16057. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  16058. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  16059. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  16060. return ok
  16061. }
  16062. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  16063. func (m *SopNodeMutation) ResetActionLabelDel() {
  16064. m.action_label_del = nil
  16065. m.appendaction_label_del = nil
  16066. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  16067. }
  16068. // SetActionForward sets the "action_forward" field.
  16069. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  16070. m.action_forward = &ctf
  16071. }
  16072. // ActionForward returns the value of the "action_forward" field in the mutation.
  16073. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  16074. v := m.action_forward
  16075. if v == nil {
  16076. return
  16077. }
  16078. return *v, true
  16079. }
  16080. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  16081. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16083. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  16084. if !m.op.Is(OpUpdateOne) {
  16085. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  16086. }
  16087. if m.id == nil || m.oldValue == nil {
  16088. return v, errors.New("OldActionForward requires an ID field in the mutation")
  16089. }
  16090. oldValue, err := m.oldValue(ctx)
  16091. if err != nil {
  16092. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  16093. }
  16094. return oldValue.ActionForward, nil
  16095. }
  16096. // ClearActionForward clears the value of the "action_forward" field.
  16097. func (m *SopNodeMutation) ClearActionForward() {
  16098. m.action_forward = nil
  16099. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  16100. }
  16101. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  16102. func (m *SopNodeMutation) ActionForwardCleared() bool {
  16103. _, ok := m.clearedFields[sopnode.FieldActionForward]
  16104. return ok
  16105. }
  16106. // ResetActionForward resets all changes to the "action_forward" field.
  16107. func (m *SopNodeMutation) ResetActionForward() {
  16108. m.action_forward = nil
  16109. delete(m.clearedFields, sopnode.FieldActionForward)
  16110. }
  16111. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  16112. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  16113. m.sop_stage = &id
  16114. }
  16115. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  16116. func (m *SopNodeMutation) ClearSopStage() {
  16117. m.clearedsop_stage = true
  16118. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  16119. }
  16120. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  16121. func (m *SopNodeMutation) SopStageCleared() bool {
  16122. return m.clearedsop_stage
  16123. }
  16124. // SopStageID returns the "sop_stage" edge ID in the mutation.
  16125. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  16126. if m.sop_stage != nil {
  16127. return *m.sop_stage, true
  16128. }
  16129. return
  16130. }
  16131. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  16132. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16133. // SopStageID instead. It exists only for internal usage by the builders.
  16134. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  16135. if id := m.sop_stage; id != nil {
  16136. ids = append(ids, *id)
  16137. }
  16138. return
  16139. }
  16140. // ResetSopStage resets all changes to the "sop_stage" edge.
  16141. func (m *SopNodeMutation) ResetSopStage() {
  16142. m.sop_stage = nil
  16143. m.clearedsop_stage = false
  16144. }
  16145. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  16146. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  16147. if m.node_messages == nil {
  16148. m.node_messages = make(map[uint64]struct{})
  16149. }
  16150. for i := range ids {
  16151. m.node_messages[ids[i]] = struct{}{}
  16152. }
  16153. }
  16154. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  16155. func (m *SopNodeMutation) ClearNodeMessages() {
  16156. m.clearednode_messages = true
  16157. }
  16158. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  16159. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  16160. return m.clearednode_messages
  16161. }
  16162. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  16163. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  16164. if m.removednode_messages == nil {
  16165. m.removednode_messages = make(map[uint64]struct{})
  16166. }
  16167. for i := range ids {
  16168. delete(m.node_messages, ids[i])
  16169. m.removednode_messages[ids[i]] = struct{}{}
  16170. }
  16171. }
  16172. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  16173. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  16174. for id := range m.removednode_messages {
  16175. ids = append(ids, id)
  16176. }
  16177. return
  16178. }
  16179. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  16180. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  16181. for id := range m.node_messages {
  16182. ids = append(ids, id)
  16183. }
  16184. return
  16185. }
  16186. // ResetNodeMessages resets all changes to the "node_messages" edge.
  16187. func (m *SopNodeMutation) ResetNodeMessages() {
  16188. m.node_messages = nil
  16189. m.clearednode_messages = false
  16190. m.removednode_messages = nil
  16191. }
  16192. // Where appends a list predicates to the SopNodeMutation builder.
  16193. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  16194. m.predicates = append(m.predicates, ps...)
  16195. }
  16196. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  16197. // users can use type-assertion to append predicates that do not depend on any generated package.
  16198. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  16199. p := make([]predicate.SopNode, len(ps))
  16200. for i := range ps {
  16201. p[i] = ps[i]
  16202. }
  16203. m.Where(p...)
  16204. }
  16205. // Op returns the operation name.
  16206. func (m *SopNodeMutation) Op() Op {
  16207. return m.op
  16208. }
  16209. // SetOp allows setting the mutation operation.
  16210. func (m *SopNodeMutation) SetOp(op Op) {
  16211. m.op = op
  16212. }
  16213. // Type returns the node type of this mutation (SopNode).
  16214. func (m *SopNodeMutation) Type() string {
  16215. return m.typ
  16216. }
  16217. // Fields returns all fields that were changed during this mutation. Note that in
  16218. // order to get all numeric fields that were incremented/decremented, call
  16219. // AddedFields().
  16220. func (m *SopNodeMutation) Fields() []string {
  16221. fields := make([]string, 0, 15)
  16222. if m.created_at != nil {
  16223. fields = append(fields, sopnode.FieldCreatedAt)
  16224. }
  16225. if m.updated_at != nil {
  16226. fields = append(fields, sopnode.FieldUpdatedAt)
  16227. }
  16228. if m.status != nil {
  16229. fields = append(fields, sopnode.FieldStatus)
  16230. }
  16231. if m.deleted_at != nil {
  16232. fields = append(fields, sopnode.FieldDeletedAt)
  16233. }
  16234. if m.sop_stage != nil {
  16235. fields = append(fields, sopnode.FieldStageID)
  16236. }
  16237. if m.parent_id != nil {
  16238. fields = append(fields, sopnode.FieldParentID)
  16239. }
  16240. if m.name != nil {
  16241. fields = append(fields, sopnode.FieldName)
  16242. }
  16243. if m.condition_type != nil {
  16244. fields = append(fields, sopnode.FieldConditionType)
  16245. }
  16246. if m.condition_list != nil {
  16247. fields = append(fields, sopnode.FieldConditionList)
  16248. }
  16249. if m.no_reply_condition != nil {
  16250. fields = append(fields, sopnode.FieldNoReplyCondition)
  16251. }
  16252. if m.no_reply_unit != nil {
  16253. fields = append(fields, sopnode.FieldNoReplyUnit)
  16254. }
  16255. if m.action_message != nil {
  16256. fields = append(fields, sopnode.FieldActionMessage)
  16257. }
  16258. if m.action_label_add != nil {
  16259. fields = append(fields, sopnode.FieldActionLabelAdd)
  16260. }
  16261. if m.action_label_del != nil {
  16262. fields = append(fields, sopnode.FieldActionLabelDel)
  16263. }
  16264. if m.action_forward != nil {
  16265. fields = append(fields, sopnode.FieldActionForward)
  16266. }
  16267. return fields
  16268. }
  16269. // Field returns the value of a field with the given name. The second boolean
  16270. // return value indicates that this field was not set, or was not defined in the
  16271. // schema.
  16272. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  16273. switch name {
  16274. case sopnode.FieldCreatedAt:
  16275. return m.CreatedAt()
  16276. case sopnode.FieldUpdatedAt:
  16277. return m.UpdatedAt()
  16278. case sopnode.FieldStatus:
  16279. return m.Status()
  16280. case sopnode.FieldDeletedAt:
  16281. return m.DeletedAt()
  16282. case sopnode.FieldStageID:
  16283. return m.StageID()
  16284. case sopnode.FieldParentID:
  16285. return m.ParentID()
  16286. case sopnode.FieldName:
  16287. return m.Name()
  16288. case sopnode.FieldConditionType:
  16289. return m.ConditionType()
  16290. case sopnode.FieldConditionList:
  16291. return m.ConditionList()
  16292. case sopnode.FieldNoReplyCondition:
  16293. return m.NoReplyCondition()
  16294. case sopnode.FieldNoReplyUnit:
  16295. return m.NoReplyUnit()
  16296. case sopnode.FieldActionMessage:
  16297. return m.ActionMessage()
  16298. case sopnode.FieldActionLabelAdd:
  16299. return m.ActionLabelAdd()
  16300. case sopnode.FieldActionLabelDel:
  16301. return m.ActionLabelDel()
  16302. case sopnode.FieldActionForward:
  16303. return m.ActionForward()
  16304. }
  16305. return nil, false
  16306. }
  16307. // OldField returns the old value of the field from the database. An error is
  16308. // returned if the mutation operation is not UpdateOne, or the query to the
  16309. // database failed.
  16310. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16311. switch name {
  16312. case sopnode.FieldCreatedAt:
  16313. return m.OldCreatedAt(ctx)
  16314. case sopnode.FieldUpdatedAt:
  16315. return m.OldUpdatedAt(ctx)
  16316. case sopnode.FieldStatus:
  16317. return m.OldStatus(ctx)
  16318. case sopnode.FieldDeletedAt:
  16319. return m.OldDeletedAt(ctx)
  16320. case sopnode.FieldStageID:
  16321. return m.OldStageID(ctx)
  16322. case sopnode.FieldParentID:
  16323. return m.OldParentID(ctx)
  16324. case sopnode.FieldName:
  16325. return m.OldName(ctx)
  16326. case sopnode.FieldConditionType:
  16327. return m.OldConditionType(ctx)
  16328. case sopnode.FieldConditionList:
  16329. return m.OldConditionList(ctx)
  16330. case sopnode.FieldNoReplyCondition:
  16331. return m.OldNoReplyCondition(ctx)
  16332. case sopnode.FieldNoReplyUnit:
  16333. return m.OldNoReplyUnit(ctx)
  16334. case sopnode.FieldActionMessage:
  16335. return m.OldActionMessage(ctx)
  16336. case sopnode.FieldActionLabelAdd:
  16337. return m.OldActionLabelAdd(ctx)
  16338. case sopnode.FieldActionLabelDel:
  16339. return m.OldActionLabelDel(ctx)
  16340. case sopnode.FieldActionForward:
  16341. return m.OldActionForward(ctx)
  16342. }
  16343. return nil, fmt.Errorf("unknown SopNode field %s", name)
  16344. }
  16345. // SetField sets the value of a field with the given name. It returns an error if
  16346. // the field is not defined in the schema, or if the type mismatched the field
  16347. // type.
  16348. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  16349. switch name {
  16350. case sopnode.FieldCreatedAt:
  16351. v, ok := value.(time.Time)
  16352. if !ok {
  16353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16354. }
  16355. m.SetCreatedAt(v)
  16356. return nil
  16357. case sopnode.FieldUpdatedAt:
  16358. v, ok := value.(time.Time)
  16359. if !ok {
  16360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16361. }
  16362. m.SetUpdatedAt(v)
  16363. return nil
  16364. case sopnode.FieldStatus:
  16365. v, ok := value.(uint8)
  16366. if !ok {
  16367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16368. }
  16369. m.SetStatus(v)
  16370. return nil
  16371. case sopnode.FieldDeletedAt:
  16372. v, ok := value.(time.Time)
  16373. if !ok {
  16374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16375. }
  16376. m.SetDeletedAt(v)
  16377. return nil
  16378. case sopnode.FieldStageID:
  16379. v, ok := value.(uint64)
  16380. if !ok {
  16381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16382. }
  16383. m.SetStageID(v)
  16384. return nil
  16385. case sopnode.FieldParentID:
  16386. v, ok := value.(uint64)
  16387. if !ok {
  16388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16389. }
  16390. m.SetParentID(v)
  16391. return nil
  16392. case sopnode.FieldName:
  16393. v, ok := value.(string)
  16394. if !ok {
  16395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16396. }
  16397. m.SetName(v)
  16398. return nil
  16399. case sopnode.FieldConditionType:
  16400. v, ok := value.(int)
  16401. if !ok {
  16402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16403. }
  16404. m.SetConditionType(v)
  16405. return nil
  16406. case sopnode.FieldConditionList:
  16407. v, ok := value.([]string)
  16408. if !ok {
  16409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16410. }
  16411. m.SetConditionList(v)
  16412. return nil
  16413. case sopnode.FieldNoReplyCondition:
  16414. v, ok := value.(uint64)
  16415. if !ok {
  16416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16417. }
  16418. m.SetNoReplyCondition(v)
  16419. return nil
  16420. case sopnode.FieldNoReplyUnit:
  16421. v, ok := value.(string)
  16422. if !ok {
  16423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16424. }
  16425. m.SetNoReplyUnit(v)
  16426. return nil
  16427. case sopnode.FieldActionMessage:
  16428. v, ok := value.([]custom_types.Action)
  16429. if !ok {
  16430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16431. }
  16432. m.SetActionMessage(v)
  16433. return nil
  16434. case sopnode.FieldActionLabelAdd:
  16435. v, ok := value.([]uint64)
  16436. if !ok {
  16437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16438. }
  16439. m.SetActionLabelAdd(v)
  16440. return nil
  16441. case sopnode.FieldActionLabelDel:
  16442. v, ok := value.([]uint64)
  16443. if !ok {
  16444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16445. }
  16446. m.SetActionLabelDel(v)
  16447. return nil
  16448. case sopnode.FieldActionForward:
  16449. v, ok := value.(*custom_types.ActionForward)
  16450. if !ok {
  16451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16452. }
  16453. m.SetActionForward(v)
  16454. return nil
  16455. }
  16456. return fmt.Errorf("unknown SopNode field %s", name)
  16457. }
  16458. // AddedFields returns all numeric fields that were incremented/decremented during
  16459. // this mutation.
  16460. func (m *SopNodeMutation) AddedFields() []string {
  16461. var fields []string
  16462. if m.addstatus != nil {
  16463. fields = append(fields, sopnode.FieldStatus)
  16464. }
  16465. if m.addparent_id != nil {
  16466. fields = append(fields, sopnode.FieldParentID)
  16467. }
  16468. if m.addcondition_type != nil {
  16469. fields = append(fields, sopnode.FieldConditionType)
  16470. }
  16471. if m.addno_reply_condition != nil {
  16472. fields = append(fields, sopnode.FieldNoReplyCondition)
  16473. }
  16474. return fields
  16475. }
  16476. // AddedField returns the numeric value that was incremented/decremented on a field
  16477. // with the given name. The second boolean return value indicates that this field
  16478. // was not set, or was not defined in the schema.
  16479. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  16480. switch name {
  16481. case sopnode.FieldStatus:
  16482. return m.AddedStatus()
  16483. case sopnode.FieldParentID:
  16484. return m.AddedParentID()
  16485. case sopnode.FieldConditionType:
  16486. return m.AddedConditionType()
  16487. case sopnode.FieldNoReplyCondition:
  16488. return m.AddedNoReplyCondition()
  16489. }
  16490. return nil, false
  16491. }
  16492. // AddField adds the value to the field with the given name. It returns an error if
  16493. // the field is not defined in the schema, or if the type mismatched the field
  16494. // type.
  16495. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  16496. switch name {
  16497. case sopnode.FieldStatus:
  16498. v, ok := value.(int8)
  16499. if !ok {
  16500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16501. }
  16502. m.AddStatus(v)
  16503. return nil
  16504. case sopnode.FieldParentID:
  16505. v, ok := value.(int64)
  16506. if !ok {
  16507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16508. }
  16509. m.AddParentID(v)
  16510. return nil
  16511. case sopnode.FieldConditionType:
  16512. v, ok := value.(int)
  16513. if !ok {
  16514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16515. }
  16516. m.AddConditionType(v)
  16517. return nil
  16518. case sopnode.FieldNoReplyCondition:
  16519. v, ok := value.(int64)
  16520. if !ok {
  16521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16522. }
  16523. m.AddNoReplyCondition(v)
  16524. return nil
  16525. }
  16526. return fmt.Errorf("unknown SopNode numeric field %s", name)
  16527. }
  16528. // ClearedFields returns all nullable fields that were cleared during this
  16529. // mutation.
  16530. func (m *SopNodeMutation) ClearedFields() []string {
  16531. var fields []string
  16532. if m.FieldCleared(sopnode.FieldStatus) {
  16533. fields = append(fields, sopnode.FieldStatus)
  16534. }
  16535. if m.FieldCleared(sopnode.FieldDeletedAt) {
  16536. fields = append(fields, sopnode.FieldDeletedAt)
  16537. }
  16538. if m.FieldCleared(sopnode.FieldConditionList) {
  16539. fields = append(fields, sopnode.FieldConditionList)
  16540. }
  16541. if m.FieldCleared(sopnode.FieldActionMessage) {
  16542. fields = append(fields, sopnode.FieldActionMessage)
  16543. }
  16544. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  16545. fields = append(fields, sopnode.FieldActionLabelAdd)
  16546. }
  16547. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  16548. fields = append(fields, sopnode.FieldActionLabelDel)
  16549. }
  16550. if m.FieldCleared(sopnode.FieldActionForward) {
  16551. fields = append(fields, sopnode.FieldActionForward)
  16552. }
  16553. return fields
  16554. }
  16555. // FieldCleared returns a boolean indicating if a field with the given name was
  16556. // cleared in this mutation.
  16557. func (m *SopNodeMutation) FieldCleared(name string) bool {
  16558. _, ok := m.clearedFields[name]
  16559. return ok
  16560. }
  16561. // ClearField clears the value of the field with the given name. It returns an
  16562. // error if the field is not defined in the schema.
  16563. func (m *SopNodeMutation) ClearField(name string) error {
  16564. switch name {
  16565. case sopnode.FieldStatus:
  16566. m.ClearStatus()
  16567. return nil
  16568. case sopnode.FieldDeletedAt:
  16569. m.ClearDeletedAt()
  16570. return nil
  16571. case sopnode.FieldConditionList:
  16572. m.ClearConditionList()
  16573. return nil
  16574. case sopnode.FieldActionMessage:
  16575. m.ClearActionMessage()
  16576. return nil
  16577. case sopnode.FieldActionLabelAdd:
  16578. m.ClearActionLabelAdd()
  16579. return nil
  16580. case sopnode.FieldActionLabelDel:
  16581. m.ClearActionLabelDel()
  16582. return nil
  16583. case sopnode.FieldActionForward:
  16584. m.ClearActionForward()
  16585. return nil
  16586. }
  16587. return fmt.Errorf("unknown SopNode nullable field %s", name)
  16588. }
  16589. // ResetField resets all changes in the mutation for the field with the given name.
  16590. // It returns an error if the field is not defined in the schema.
  16591. func (m *SopNodeMutation) ResetField(name string) error {
  16592. switch name {
  16593. case sopnode.FieldCreatedAt:
  16594. m.ResetCreatedAt()
  16595. return nil
  16596. case sopnode.FieldUpdatedAt:
  16597. m.ResetUpdatedAt()
  16598. return nil
  16599. case sopnode.FieldStatus:
  16600. m.ResetStatus()
  16601. return nil
  16602. case sopnode.FieldDeletedAt:
  16603. m.ResetDeletedAt()
  16604. return nil
  16605. case sopnode.FieldStageID:
  16606. m.ResetStageID()
  16607. return nil
  16608. case sopnode.FieldParentID:
  16609. m.ResetParentID()
  16610. return nil
  16611. case sopnode.FieldName:
  16612. m.ResetName()
  16613. return nil
  16614. case sopnode.FieldConditionType:
  16615. m.ResetConditionType()
  16616. return nil
  16617. case sopnode.FieldConditionList:
  16618. m.ResetConditionList()
  16619. return nil
  16620. case sopnode.FieldNoReplyCondition:
  16621. m.ResetNoReplyCondition()
  16622. return nil
  16623. case sopnode.FieldNoReplyUnit:
  16624. m.ResetNoReplyUnit()
  16625. return nil
  16626. case sopnode.FieldActionMessage:
  16627. m.ResetActionMessage()
  16628. return nil
  16629. case sopnode.FieldActionLabelAdd:
  16630. m.ResetActionLabelAdd()
  16631. return nil
  16632. case sopnode.FieldActionLabelDel:
  16633. m.ResetActionLabelDel()
  16634. return nil
  16635. case sopnode.FieldActionForward:
  16636. m.ResetActionForward()
  16637. return nil
  16638. }
  16639. return fmt.Errorf("unknown SopNode field %s", name)
  16640. }
  16641. // AddedEdges returns all edge names that were set/added in this mutation.
  16642. func (m *SopNodeMutation) AddedEdges() []string {
  16643. edges := make([]string, 0, 2)
  16644. if m.sop_stage != nil {
  16645. edges = append(edges, sopnode.EdgeSopStage)
  16646. }
  16647. if m.node_messages != nil {
  16648. edges = append(edges, sopnode.EdgeNodeMessages)
  16649. }
  16650. return edges
  16651. }
  16652. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16653. // name in this mutation.
  16654. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  16655. switch name {
  16656. case sopnode.EdgeSopStage:
  16657. if id := m.sop_stage; id != nil {
  16658. return []ent.Value{*id}
  16659. }
  16660. case sopnode.EdgeNodeMessages:
  16661. ids := make([]ent.Value, 0, len(m.node_messages))
  16662. for id := range m.node_messages {
  16663. ids = append(ids, id)
  16664. }
  16665. return ids
  16666. }
  16667. return nil
  16668. }
  16669. // RemovedEdges returns all edge names that were removed in this mutation.
  16670. func (m *SopNodeMutation) RemovedEdges() []string {
  16671. edges := make([]string, 0, 2)
  16672. if m.removednode_messages != nil {
  16673. edges = append(edges, sopnode.EdgeNodeMessages)
  16674. }
  16675. return edges
  16676. }
  16677. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16678. // the given name in this mutation.
  16679. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  16680. switch name {
  16681. case sopnode.EdgeNodeMessages:
  16682. ids := make([]ent.Value, 0, len(m.removednode_messages))
  16683. for id := range m.removednode_messages {
  16684. ids = append(ids, id)
  16685. }
  16686. return ids
  16687. }
  16688. return nil
  16689. }
  16690. // ClearedEdges returns all edge names that were cleared in this mutation.
  16691. func (m *SopNodeMutation) ClearedEdges() []string {
  16692. edges := make([]string, 0, 2)
  16693. if m.clearedsop_stage {
  16694. edges = append(edges, sopnode.EdgeSopStage)
  16695. }
  16696. if m.clearednode_messages {
  16697. edges = append(edges, sopnode.EdgeNodeMessages)
  16698. }
  16699. return edges
  16700. }
  16701. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16702. // was cleared in this mutation.
  16703. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  16704. switch name {
  16705. case sopnode.EdgeSopStage:
  16706. return m.clearedsop_stage
  16707. case sopnode.EdgeNodeMessages:
  16708. return m.clearednode_messages
  16709. }
  16710. return false
  16711. }
  16712. // ClearEdge clears the value of the edge with the given name. It returns an error
  16713. // if that edge is not defined in the schema.
  16714. func (m *SopNodeMutation) ClearEdge(name string) error {
  16715. switch name {
  16716. case sopnode.EdgeSopStage:
  16717. m.ClearSopStage()
  16718. return nil
  16719. }
  16720. return fmt.Errorf("unknown SopNode unique edge %s", name)
  16721. }
  16722. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16723. // It returns an error if the edge is not defined in the schema.
  16724. func (m *SopNodeMutation) ResetEdge(name string) error {
  16725. switch name {
  16726. case sopnode.EdgeSopStage:
  16727. m.ResetSopStage()
  16728. return nil
  16729. case sopnode.EdgeNodeMessages:
  16730. m.ResetNodeMessages()
  16731. return nil
  16732. }
  16733. return fmt.Errorf("unknown SopNode edge %s", name)
  16734. }
  16735. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  16736. type SopStageMutation struct {
  16737. config
  16738. op Op
  16739. typ string
  16740. id *uint64
  16741. created_at *time.Time
  16742. updated_at *time.Time
  16743. status *uint8
  16744. addstatus *int8
  16745. deleted_at *time.Time
  16746. name *string
  16747. condition_type *int
  16748. addcondition_type *int
  16749. condition_operator *int
  16750. addcondition_operator *int
  16751. condition_list *[]custom_types.Condition
  16752. appendcondition_list []custom_types.Condition
  16753. action_message *[]custom_types.Action
  16754. appendaction_message []custom_types.Action
  16755. action_label_add *[]uint64
  16756. appendaction_label_add []uint64
  16757. action_label_del *[]uint64
  16758. appendaction_label_del []uint64
  16759. action_forward **custom_types.ActionForward
  16760. index_sort *int
  16761. addindex_sort *int
  16762. clearedFields map[string]struct{}
  16763. sop_task *uint64
  16764. clearedsop_task bool
  16765. stage_nodes map[uint64]struct{}
  16766. removedstage_nodes map[uint64]struct{}
  16767. clearedstage_nodes bool
  16768. stage_messages map[uint64]struct{}
  16769. removedstage_messages map[uint64]struct{}
  16770. clearedstage_messages bool
  16771. done bool
  16772. oldValue func(context.Context) (*SopStage, error)
  16773. predicates []predicate.SopStage
  16774. }
  16775. var _ ent.Mutation = (*SopStageMutation)(nil)
  16776. // sopstageOption allows management of the mutation configuration using functional options.
  16777. type sopstageOption func(*SopStageMutation)
  16778. // newSopStageMutation creates new mutation for the SopStage entity.
  16779. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  16780. m := &SopStageMutation{
  16781. config: c,
  16782. op: op,
  16783. typ: TypeSopStage,
  16784. clearedFields: make(map[string]struct{}),
  16785. }
  16786. for _, opt := range opts {
  16787. opt(m)
  16788. }
  16789. return m
  16790. }
  16791. // withSopStageID sets the ID field of the mutation.
  16792. func withSopStageID(id uint64) sopstageOption {
  16793. return func(m *SopStageMutation) {
  16794. var (
  16795. err error
  16796. once sync.Once
  16797. value *SopStage
  16798. )
  16799. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  16800. once.Do(func() {
  16801. if m.done {
  16802. err = errors.New("querying old values post mutation is not allowed")
  16803. } else {
  16804. value, err = m.Client().SopStage.Get(ctx, id)
  16805. }
  16806. })
  16807. return value, err
  16808. }
  16809. m.id = &id
  16810. }
  16811. }
  16812. // withSopStage sets the old SopStage of the mutation.
  16813. func withSopStage(node *SopStage) sopstageOption {
  16814. return func(m *SopStageMutation) {
  16815. m.oldValue = func(context.Context) (*SopStage, error) {
  16816. return node, nil
  16817. }
  16818. m.id = &node.ID
  16819. }
  16820. }
  16821. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16822. // executed in a transaction (ent.Tx), a transactional client is returned.
  16823. func (m SopStageMutation) Client() *Client {
  16824. client := &Client{config: m.config}
  16825. client.init()
  16826. return client
  16827. }
  16828. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16829. // it returns an error otherwise.
  16830. func (m SopStageMutation) Tx() (*Tx, error) {
  16831. if _, ok := m.driver.(*txDriver); !ok {
  16832. return nil, errors.New("ent: mutation is not running in a transaction")
  16833. }
  16834. tx := &Tx{config: m.config}
  16835. tx.init()
  16836. return tx, nil
  16837. }
  16838. // SetID sets the value of the id field. Note that this
  16839. // operation is only accepted on creation of SopStage entities.
  16840. func (m *SopStageMutation) SetID(id uint64) {
  16841. m.id = &id
  16842. }
  16843. // ID returns the ID value in the mutation. Note that the ID is only available
  16844. // if it was provided to the builder or after it was returned from the database.
  16845. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  16846. if m.id == nil {
  16847. return
  16848. }
  16849. return *m.id, true
  16850. }
  16851. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16852. // That means, if the mutation is applied within a transaction with an isolation level such
  16853. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16854. // or updated by the mutation.
  16855. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  16856. switch {
  16857. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16858. id, exists := m.ID()
  16859. if exists {
  16860. return []uint64{id}, nil
  16861. }
  16862. fallthrough
  16863. case m.op.Is(OpUpdate | OpDelete):
  16864. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  16865. default:
  16866. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16867. }
  16868. }
  16869. // SetCreatedAt sets the "created_at" field.
  16870. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  16871. m.created_at = &t
  16872. }
  16873. // CreatedAt returns the value of the "created_at" field in the mutation.
  16874. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  16875. v := m.created_at
  16876. if v == nil {
  16877. return
  16878. }
  16879. return *v, true
  16880. }
  16881. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  16882. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  16883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16884. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16885. if !m.op.Is(OpUpdateOne) {
  16886. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16887. }
  16888. if m.id == nil || m.oldValue == nil {
  16889. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16890. }
  16891. oldValue, err := m.oldValue(ctx)
  16892. if err != nil {
  16893. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16894. }
  16895. return oldValue.CreatedAt, nil
  16896. }
  16897. // ResetCreatedAt resets all changes to the "created_at" field.
  16898. func (m *SopStageMutation) ResetCreatedAt() {
  16899. m.created_at = nil
  16900. }
  16901. // SetUpdatedAt sets the "updated_at" field.
  16902. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  16903. m.updated_at = &t
  16904. }
  16905. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16906. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  16907. v := m.updated_at
  16908. if v == nil {
  16909. return
  16910. }
  16911. return *v, true
  16912. }
  16913. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  16914. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  16915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16916. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16917. if !m.op.Is(OpUpdateOne) {
  16918. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16919. }
  16920. if m.id == nil || m.oldValue == nil {
  16921. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16922. }
  16923. oldValue, err := m.oldValue(ctx)
  16924. if err != nil {
  16925. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16926. }
  16927. return oldValue.UpdatedAt, nil
  16928. }
  16929. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16930. func (m *SopStageMutation) ResetUpdatedAt() {
  16931. m.updated_at = nil
  16932. }
  16933. // SetStatus sets the "status" field.
  16934. func (m *SopStageMutation) SetStatus(u uint8) {
  16935. m.status = &u
  16936. m.addstatus = nil
  16937. }
  16938. // Status returns the value of the "status" field in the mutation.
  16939. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  16940. v := m.status
  16941. if v == nil {
  16942. return
  16943. }
  16944. return *v, true
  16945. }
  16946. // OldStatus returns the old "status" field's value of the SopStage entity.
  16947. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  16948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16949. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16950. if !m.op.Is(OpUpdateOne) {
  16951. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16952. }
  16953. if m.id == nil || m.oldValue == nil {
  16954. return v, errors.New("OldStatus requires an ID field in the mutation")
  16955. }
  16956. oldValue, err := m.oldValue(ctx)
  16957. if err != nil {
  16958. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16959. }
  16960. return oldValue.Status, nil
  16961. }
  16962. // AddStatus adds u to the "status" field.
  16963. func (m *SopStageMutation) AddStatus(u int8) {
  16964. if m.addstatus != nil {
  16965. *m.addstatus += u
  16966. } else {
  16967. m.addstatus = &u
  16968. }
  16969. }
  16970. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16971. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  16972. v := m.addstatus
  16973. if v == nil {
  16974. return
  16975. }
  16976. return *v, true
  16977. }
  16978. // ClearStatus clears the value of the "status" field.
  16979. func (m *SopStageMutation) ClearStatus() {
  16980. m.status = nil
  16981. m.addstatus = nil
  16982. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  16983. }
  16984. // StatusCleared returns if the "status" field was cleared in this mutation.
  16985. func (m *SopStageMutation) StatusCleared() bool {
  16986. _, ok := m.clearedFields[sopstage.FieldStatus]
  16987. return ok
  16988. }
  16989. // ResetStatus resets all changes to the "status" field.
  16990. func (m *SopStageMutation) ResetStatus() {
  16991. m.status = nil
  16992. m.addstatus = nil
  16993. delete(m.clearedFields, sopstage.FieldStatus)
  16994. }
  16995. // SetDeletedAt sets the "deleted_at" field.
  16996. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  16997. m.deleted_at = &t
  16998. }
  16999. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17000. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  17001. v := m.deleted_at
  17002. if v == nil {
  17003. return
  17004. }
  17005. return *v, true
  17006. }
  17007. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  17008. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17010. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17011. if !m.op.Is(OpUpdateOne) {
  17012. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17013. }
  17014. if m.id == nil || m.oldValue == nil {
  17015. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17016. }
  17017. oldValue, err := m.oldValue(ctx)
  17018. if err != nil {
  17019. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17020. }
  17021. return oldValue.DeletedAt, nil
  17022. }
  17023. // ClearDeletedAt clears the value of the "deleted_at" field.
  17024. func (m *SopStageMutation) ClearDeletedAt() {
  17025. m.deleted_at = nil
  17026. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  17027. }
  17028. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17029. func (m *SopStageMutation) DeletedAtCleared() bool {
  17030. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  17031. return ok
  17032. }
  17033. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17034. func (m *SopStageMutation) ResetDeletedAt() {
  17035. m.deleted_at = nil
  17036. delete(m.clearedFields, sopstage.FieldDeletedAt)
  17037. }
  17038. // SetTaskID sets the "task_id" field.
  17039. func (m *SopStageMutation) SetTaskID(u uint64) {
  17040. m.sop_task = &u
  17041. }
  17042. // TaskID returns the value of the "task_id" field in the mutation.
  17043. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  17044. v := m.sop_task
  17045. if v == nil {
  17046. return
  17047. }
  17048. return *v, true
  17049. }
  17050. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  17051. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17053. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  17054. if !m.op.Is(OpUpdateOne) {
  17055. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  17056. }
  17057. if m.id == nil || m.oldValue == nil {
  17058. return v, errors.New("OldTaskID requires an ID field in the mutation")
  17059. }
  17060. oldValue, err := m.oldValue(ctx)
  17061. if err != nil {
  17062. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  17063. }
  17064. return oldValue.TaskID, nil
  17065. }
  17066. // ResetTaskID resets all changes to the "task_id" field.
  17067. func (m *SopStageMutation) ResetTaskID() {
  17068. m.sop_task = nil
  17069. }
  17070. // SetName sets the "name" field.
  17071. func (m *SopStageMutation) SetName(s string) {
  17072. m.name = &s
  17073. }
  17074. // Name returns the value of the "name" field in the mutation.
  17075. func (m *SopStageMutation) Name() (r string, exists bool) {
  17076. v := m.name
  17077. if v == nil {
  17078. return
  17079. }
  17080. return *v, true
  17081. }
  17082. // OldName returns the old "name" field's value of the SopStage entity.
  17083. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17085. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  17086. if !m.op.Is(OpUpdateOne) {
  17087. return v, errors.New("OldName is only allowed on UpdateOne operations")
  17088. }
  17089. if m.id == nil || m.oldValue == nil {
  17090. return v, errors.New("OldName requires an ID field in the mutation")
  17091. }
  17092. oldValue, err := m.oldValue(ctx)
  17093. if err != nil {
  17094. return v, fmt.Errorf("querying old value for OldName: %w", err)
  17095. }
  17096. return oldValue.Name, nil
  17097. }
  17098. // ResetName resets all changes to the "name" field.
  17099. func (m *SopStageMutation) ResetName() {
  17100. m.name = nil
  17101. }
  17102. // SetConditionType sets the "condition_type" field.
  17103. func (m *SopStageMutation) SetConditionType(i int) {
  17104. m.condition_type = &i
  17105. m.addcondition_type = nil
  17106. }
  17107. // ConditionType returns the value of the "condition_type" field in the mutation.
  17108. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  17109. v := m.condition_type
  17110. if v == nil {
  17111. return
  17112. }
  17113. return *v, true
  17114. }
  17115. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  17116. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17118. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  17119. if !m.op.Is(OpUpdateOne) {
  17120. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  17121. }
  17122. if m.id == nil || m.oldValue == nil {
  17123. return v, errors.New("OldConditionType requires an ID field in the mutation")
  17124. }
  17125. oldValue, err := m.oldValue(ctx)
  17126. if err != nil {
  17127. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  17128. }
  17129. return oldValue.ConditionType, nil
  17130. }
  17131. // AddConditionType adds i to the "condition_type" field.
  17132. func (m *SopStageMutation) AddConditionType(i int) {
  17133. if m.addcondition_type != nil {
  17134. *m.addcondition_type += i
  17135. } else {
  17136. m.addcondition_type = &i
  17137. }
  17138. }
  17139. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  17140. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  17141. v := m.addcondition_type
  17142. if v == nil {
  17143. return
  17144. }
  17145. return *v, true
  17146. }
  17147. // ResetConditionType resets all changes to the "condition_type" field.
  17148. func (m *SopStageMutation) ResetConditionType() {
  17149. m.condition_type = nil
  17150. m.addcondition_type = nil
  17151. }
  17152. // SetConditionOperator sets the "condition_operator" field.
  17153. func (m *SopStageMutation) SetConditionOperator(i int) {
  17154. m.condition_operator = &i
  17155. m.addcondition_operator = nil
  17156. }
  17157. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  17158. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  17159. v := m.condition_operator
  17160. if v == nil {
  17161. return
  17162. }
  17163. return *v, true
  17164. }
  17165. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  17166. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17168. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  17169. if !m.op.Is(OpUpdateOne) {
  17170. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  17171. }
  17172. if m.id == nil || m.oldValue == nil {
  17173. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  17174. }
  17175. oldValue, err := m.oldValue(ctx)
  17176. if err != nil {
  17177. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  17178. }
  17179. return oldValue.ConditionOperator, nil
  17180. }
  17181. // AddConditionOperator adds i to the "condition_operator" field.
  17182. func (m *SopStageMutation) AddConditionOperator(i int) {
  17183. if m.addcondition_operator != nil {
  17184. *m.addcondition_operator += i
  17185. } else {
  17186. m.addcondition_operator = &i
  17187. }
  17188. }
  17189. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  17190. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  17191. v := m.addcondition_operator
  17192. if v == nil {
  17193. return
  17194. }
  17195. return *v, true
  17196. }
  17197. // ResetConditionOperator resets all changes to the "condition_operator" field.
  17198. func (m *SopStageMutation) ResetConditionOperator() {
  17199. m.condition_operator = nil
  17200. m.addcondition_operator = nil
  17201. }
  17202. // SetConditionList sets the "condition_list" field.
  17203. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  17204. m.condition_list = &ct
  17205. m.appendcondition_list = nil
  17206. }
  17207. // ConditionList returns the value of the "condition_list" field in the mutation.
  17208. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  17209. v := m.condition_list
  17210. if v == nil {
  17211. return
  17212. }
  17213. return *v, true
  17214. }
  17215. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  17216. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17218. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  17219. if !m.op.Is(OpUpdateOne) {
  17220. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  17221. }
  17222. if m.id == nil || m.oldValue == nil {
  17223. return v, errors.New("OldConditionList requires an ID field in the mutation")
  17224. }
  17225. oldValue, err := m.oldValue(ctx)
  17226. if err != nil {
  17227. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  17228. }
  17229. return oldValue.ConditionList, nil
  17230. }
  17231. // AppendConditionList adds ct to the "condition_list" field.
  17232. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  17233. m.appendcondition_list = append(m.appendcondition_list, ct...)
  17234. }
  17235. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  17236. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  17237. if len(m.appendcondition_list) == 0 {
  17238. return nil, false
  17239. }
  17240. return m.appendcondition_list, true
  17241. }
  17242. // ResetConditionList resets all changes to the "condition_list" field.
  17243. func (m *SopStageMutation) ResetConditionList() {
  17244. m.condition_list = nil
  17245. m.appendcondition_list = nil
  17246. }
  17247. // SetActionMessage sets the "action_message" field.
  17248. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  17249. m.action_message = &ct
  17250. m.appendaction_message = nil
  17251. }
  17252. // ActionMessage returns the value of the "action_message" field in the mutation.
  17253. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  17254. v := m.action_message
  17255. if v == nil {
  17256. return
  17257. }
  17258. return *v, true
  17259. }
  17260. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  17261. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17263. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  17264. if !m.op.Is(OpUpdateOne) {
  17265. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  17266. }
  17267. if m.id == nil || m.oldValue == nil {
  17268. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  17269. }
  17270. oldValue, err := m.oldValue(ctx)
  17271. if err != nil {
  17272. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  17273. }
  17274. return oldValue.ActionMessage, nil
  17275. }
  17276. // AppendActionMessage adds ct to the "action_message" field.
  17277. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  17278. m.appendaction_message = append(m.appendaction_message, ct...)
  17279. }
  17280. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  17281. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  17282. if len(m.appendaction_message) == 0 {
  17283. return nil, false
  17284. }
  17285. return m.appendaction_message, true
  17286. }
  17287. // ClearActionMessage clears the value of the "action_message" field.
  17288. func (m *SopStageMutation) ClearActionMessage() {
  17289. m.action_message = nil
  17290. m.appendaction_message = nil
  17291. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  17292. }
  17293. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  17294. func (m *SopStageMutation) ActionMessageCleared() bool {
  17295. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  17296. return ok
  17297. }
  17298. // ResetActionMessage resets all changes to the "action_message" field.
  17299. func (m *SopStageMutation) ResetActionMessage() {
  17300. m.action_message = nil
  17301. m.appendaction_message = nil
  17302. delete(m.clearedFields, sopstage.FieldActionMessage)
  17303. }
  17304. // SetActionLabelAdd sets the "action_label_add" field.
  17305. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  17306. m.action_label_add = &u
  17307. m.appendaction_label_add = nil
  17308. }
  17309. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17310. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17311. v := m.action_label_add
  17312. if v == nil {
  17313. return
  17314. }
  17315. return *v, true
  17316. }
  17317. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  17318. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17320. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17321. if !m.op.Is(OpUpdateOne) {
  17322. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17323. }
  17324. if m.id == nil || m.oldValue == nil {
  17325. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17326. }
  17327. oldValue, err := m.oldValue(ctx)
  17328. if err != nil {
  17329. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17330. }
  17331. return oldValue.ActionLabelAdd, nil
  17332. }
  17333. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17334. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  17335. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17336. }
  17337. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17338. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17339. if len(m.appendaction_label_add) == 0 {
  17340. return nil, false
  17341. }
  17342. return m.appendaction_label_add, true
  17343. }
  17344. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17345. func (m *SopStageMutation) ClearActionLabelAdd() {
  17346. m.action_label_add = nil
  17347. m.appendaction_label_add = nil
  17348. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  17349. }
  17350. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17351. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  17352. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  17353. return ok
  17354. }
  17355. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17356. func (m *SopStageMutation) ResetActionLabelAdd() {
  17357. m.action_label_add = nil
  17358. m.appendaction_label_add = nil
  17359. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  17360. }
  17361. // SetActionLabelDel sets the "action_label_del" field.
  17362. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  17363. m.action_label_del = &u
  17364. m.appendaction_label_del = nil
  17365. }
  17366. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  17367. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  17368. v := m.action_label_del
  17369. if v == nil {
  17370. return
  17371. }
  17372. return *v, true
  17373. }
  17374. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  17375. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17377. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  17378. if !m.op.Is(OpUpdateOne) {
  17379. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  17380. }
  17381. if m.id == nil || m.oldValue == nil {
  17382. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  17383. }
  17384. oldValue, err := m.oldValue(ctx)
  17385. if err != nil {
  17386. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  17387. }
  17388. return oldValue.ActionLabelDel, nil
  17389. }
  17390. // AppendActionLabelDel adds u to the "action_label_del" field.
  17391. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  17392. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  17393. }
  17394. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  17395. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  17396. if len(m.appendaction_label_del) == 0 {
  17397. return nil, false
  17398. }
  17399. return m.appendaction_label_del, true
  17400. }
  17401. // ClearActionLabelDel clears the value of the "action_label_del" field.
  17402. func (m *SopStageMutation) ClearActionLabelDel() {
  17403. m.action_label_del = nil
  17404. m.appendaction_label_del = nil
  17405. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  17406. }
  17407. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  17408. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  17409. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  17410. return ok
  17411. }
  17412. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  17413. func (m *SopStageMutation) ResetActionLabelDel() {
  17414. m.action_label_del = nil
  17415. m.appendaction_label_del = nil
  17416. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  17417. }
  17418. // SetActionForward sets the "action_forward" field.
  17419. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  17420. m.action_forward = &ctf
  17421. }
  17422. // ActionForward returns the value of the "action_forward" field in the mutation.
  17423. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  17424. v := m.action_forward
  17425. if v == nil {
  17426. return
  17427. }
  17428. return *v, true
  17429. }
  17430. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  17431. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17433. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  17434. if !m.op.Is(OpUpdateOne) {
  17435. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  17436. }
  17437. if m.id == nil || m.oldValue == nil {
  17438. return v, errors.New("OldActionForward requires an ID field in the mutation")
  17439. }
  17440. oldValue, err := m.oldValue(ctx)
  17441. if err != nil {
  17442. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  17443. }
  17444. return oldValue.ActionForward, nil
  17445. }
  17446. // ClearActionForward clears the value of the "action_forward" field.
  17447. func (m *SopStageMutation) ClearActionForward() {
  17448. m.action_forward = nil
  17449. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  17450. }
  17451. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  17452. func (m *SopStageMutation) ActionForwardCleared() bool {
  17453. _, ok := m.clearedFields[sopstage.FieldActionForward]
  17454. return ok
  17455. }
  17456. // ResetActionForward resets all changes to the "action_forward" field.
  17457. func (m *SopStageMutation) ResetActionForward() {
  17458. m.action_forward = nil
  17459. delete(m.clearedFields, sopstage.FieldActionForward)
  17460. }
  17461. // SetIndexSort sets the "index_sort" field.
  17462. func (m *SopStageMutation) SetIndexSort(i int) {
  17463. m.index_sort = &i
  17464. m.addindex_sort = nil
  17465. }
  17466. // IndexSort returns the value of the "index_sort" field in the mutation.
  17467. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  17468. v := m.index_sort
  17469. if v == nil {
  17470. return
  17471. }
  17472. return *v, true
  17473. }
  17474. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  17475. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17477. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  17478. if !m.op.Is(OpUpdateOne) {
  17479. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  17480. }
  17481. if m.id == nil || m.oldValue == nil {
  17482. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  17483. }
  17484. oldValue, err := m.oldValue(ctx)
  17485. if err != nil {
  17486. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  17487. }
  17488. return oldValue.IndexSort, nil
  17489. }
  17490. // AddIndexSort adds i to the "index_sort" field.
  17491. func (m *SopStageMutation) AddIndexSort(i int) {
  17492. if m.addindex_sort != nil {
  17493. *m.addindex_sort += i
  17494. } else {
  17495. m.addindex_sort = &i
  17496. }
  17497. }
  17498. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  17499. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  17500. v := m.addindex_sort
  17501. if v == nil {
  17502. return
  17503. }
  17504. return *v, true
  17505. }
  17506. // ClearIndexSort clears the value of the "index_sort" field.
  17507. func (m *SopStageMutation) ClearIndexSort() {
  17508. m.index_sort = nil
  17509. m.addindex_sort = nil
  17510. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  17511. }
  17512. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  17513. func (m *SopStageMutation) IndexSortCleared() bool {
  17514. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  17515. return ok
  17516. }
  17517. // ResetIndexSort resets all changes to the "index_sort" field.
  17518. func (m *SopStageMutation) ResetIndexSort() {
  17519. m.index_sort = nil
  17520. m.addindex_sort = nil
  17521. delete(m.clearedFields, sopstage.FieldIndexSort)
  17522. }
  17523. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  17524. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  17525. m.sop_task = &id
  17526. }
  17527. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  17528. func (m *SopStageMutation) ClearSopTask() {
  17529. m.clearedsop_task = true
  17530. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  17531. }
  17532. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  17533. func (m *SopStageMutation) SopTaskCleared() bool {
  17534. return m.clearedsop_task
  17535. }
  17536. // SopTaskID returns the "sop_task" edge ID in the mutation.
  17537. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  17538. if m.sop_task != nil {
  17539. return *m.sop_task, true
  17540. }
  17541. return
  17542. }
  17543. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  17544. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17545. // SopTaskID instead. It exists only for internal usage by the builders.
  17546. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  17547. if id := m.sop_task; id != nil {
  17548. ids = append(ids, *id)
  17549. }
  17550. return
  17551. }
  17552. // ResetSopTask resets all changes to the "sop_task" edge.
  17553. func (m *SopStageMutation) ResetSopTask() {
  17554. m.sop_task = nil
  17555. m.clearedsop_task = false
  17556. }
  17557. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  17558. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  17559. if m.stage_nodes == nil {
  17560. m.stage_nodes = make(map[uint64]struct{})
  17561. }
  17562. for i := range ids {
  17563. m.stage_nodes[ids[i]] = struct{}{}
  17564. }
  17565. }
  17566. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  17567. func (m *SopStageMutation) ClearStageNodes() {
  17568. m.clearedstage_nodes = true
  17569. }
  17570. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  17571. func (m *SopStageMutation) StageNodesCleared() bool {
  17572. return m.clearedstage_nodes
  17573. }
  17574. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  17575. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  17576. if m.removedstage_nodes == nil {
  17577. m.removedstage_nodes = make(map[uint64]struct{})
  17578. }
  17579. for i := range ids {
  17580. delete(m.stage_nodes, ids[i])
  17581. m.removedstage_nodes[ids[i]] = struct{}{}
  17582. }
  17583. }
  17584. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  17585. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  17586. for id := range m.removedstage_nodes {
  17587. ids = append(ids, id)
  17588. }
  17589. return
  17590. }
  17591. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  17592. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  17593. for id := range m.stage_nodes {
  17594. ids = append(ids, id)
  17595. }
  17596. return
  17597. }
  17598. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  17599. func (m *SopStageMutation) ResetStageNodes() {
  17600. m.stage_nodes = nil
  17601. m.clearedstage_nodes = false
  17602. m.removedstage_nodes = nil
  17603. }
  17604. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  17605. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  17606. if m.stage_messages == nil {
  17607. m.stage_messages = make(map[uint64]struct{})
  17608. }
  17609. for i := range ids {
  17610. m.stage_messages[ids[i]] = struct{}{}
  17611. }
  17612. }
  17613. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  17614. func (m *SopStageMutation) ClearStageMessages() {
  17615. m.clearedstage_messages = true
  17616. }
  17617. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  17618. func (m *SopStageMutation) StageMessagesCleared() bool {
  17619. return m.clearedstage_messages
  17620. }
  17621. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  17622. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  17623. if m.removedstage_messages == nil {
  17624. m.removedstage_messages = make(map[uint64]struct{})
  17625. }
  17626. for i := range ids {
  17627. delete(m.stage_messages, ids[i])
  17628. m.removedstage_messages[ids[i]] = struct{}{}
  17629. }
  17630. }
  17631. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  17632. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  17633. for id := range m.removedstage_messages {
  17634. ids = append(ids, id)
  17635. }
  17636. return
  17637. }
  17638. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  17639. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  17640. for id := range m.stage_messages {
  17641. ids = append(ids, id)
  17642. }
  17643. return
  17644. }
  17645. // ResetStageMessages resets all changes to the "stage_messages" edge.
  17646. func (m *SopStageMutation) ResetStageMessages() {
  17647. m.stage_messages = nil
  17648. m.clearedstage_messages = false
  17649. m.removedstage_messages = nil
  17650. }
  17651. // Where appends a list predicates to the SopStageMutation builder.
  17652. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  17653. m.predicates = append(m.predicates, ps...)
  17654. }
  17655. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  17656. // users can use type-assertion to append predicates that do not depend on any generated package.
  17657. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  17658. p := make([]predicate.SopStage, len(ps))
  17659. for i := range ps {
  17660. p[i] = ps[i]
  17661. }
  17662. m.Where(p...)
  17663. }
  17664. // Op returns the operation name.
  17665. func (m *SopStageMutation) Op() Op {
  17666. return m.op
  17667. }
  17668. // SetOp allows setting the mutation operation.
  17669. func (m *SopStageMutation) SetOp(op Op) {
  17670. m.op = op
  17671. }
  17672. // Type returns the node type of this mutation (SopStage).
  17673. func (m *SopStageMutation) Type() string {
  17674. return m.typ
  17675. }
  17676. // Fields returns all fields that were changed during this mutation. Note that in
  17677. // order to get all numeric fields that were incremented/decremented, call
  17678. // AddedFields().
  17679. func (m *SopStageMutation) Fields() []string {
  17680. fields := make([]string, 0, 14)
  17681. if m.created_at != nil {
  17682. fields = append(fields, sopstage.FieldCreatedAt)
  17683. }
  17684. if m.updated_at != nil {
  17685. fields = append(fields, sopstage.FieldUpdatedAt)
  17686. }
  17687. if m.status != nil {
  17688. fields = append(fields, sopstage.FieldStatus)
  17689. }
  17690. if m.deleted_at != nil {
  17691. fields = append(fields, sopstage.FieldDeletedAt)
  17692. }
  17693. if m.sop_task != nil {
  17694. fields = append(fields, sopstage.FieldTaskID)
  17695. }
  17696. if m.name != nil {
  17697. fields = append(fields, sopstage.FieldName)
  17698. }
  17699. if m.condition_type != nil {
  17700. fields = append(fields, sopstage.FieldConditionType)
  17701. }
  17702. if m.condition_operator != nil {
  17703. fields = append(fields, sopstage.FieldConditionOperator)
  17704. }
  17705. if m.condition_list != nil {
  17706. fields = append(fields, sopstage.FieldConditionList)
  17707. }
  17708. if m.action_message != nil {
  17709. fields = append(fields, sopstage.FieldActionMessage)
  17710. }
  17711. if m.action_label_add != nil {
  17712. fields = append(fields, sopstage.FieldActionLabelAdd)
  17713. }
  17714. if m.action_label_del != nil {
  17715. fields = append(fields, sopstage.FieldActionLabelDel)
  17716. }
  17717. if m.action_forward != nil {
  17718. fields = append(fields, sopstage.FieldActionForward)
  17719. }
  17720. if m.index_sort != nil {
  17721. fields = append(fields, sopstage.FieldIndexSort)
  17722. }
  17723. return fields
  17724. }
  17725. // Field returns the value of a field with the given name. The second boolean
  17726. // return value indicates that this field was not set, or was not defined in the
  17727. // schema.
  17728. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  17729. switch name {
  17730. case sopstage.FieldCreatedAt:
  17731. return m.CreatedAt()
  17732. case sopstage.FieldUpdatedAt:
  17733. return m.UpdatedAt()
  17734. case sopstage.FieldStatus:
  17735. return m.Status()
  17736. case sopstage.FieldDeletedAt:
  17737. return m.DeletedAt()
  17738. case sopstage.FieldTaskID:
  17739. return m.TaskID()
  17740. case sopstage.FieldName:
  17741. return m.Name()
  17742. case sopstage.FieldConditionType:
  17743. return m.ConditionType()
  17744. case sopstage.FieldConditionOperator:
  17745. return m.ConditionOperator()
  17746. case sopstage.FieldConditionList:
  17747. return m.ConditionList()
  17748. case sopstage.FieldActionMessage:
  17749. return m.ActionMessage()
  17750. case sopstage.FieldActionLabelAdd:
  17751. return m.ActionLabelAdd()
  17752. case sopstage.FieldActionLabelDel:
  17753. return m.ActionLabelDel()
  17754. case sopstage.FieldActionForward:
  17755. return m.ActionForward()
  17756. case sopstage.FieldIndexSort:
  17757. return m.IndexSort()
  17758. }
  17759. return nil, false
  17760. }
  17761. // OldField returns the old value of the field from the database. An error is
  17762. // returned if the mutation operation is not UpdateOne, or the query to the
  17763. // database failed.
  17764. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17765. switch name {
  17766. case sopstage.FieldCreatedAt:
  17767. return m.OldCreatedAt(ctx)
  17768. case sopstage.FieldUpdatedAt:
  17769. return m.OldUpdatedAt(ctx)
  17770. case sopstage.FieldStatus:
  17771. return m.OldStatus(ctx)
  17772. case sopstage.FieldDeletedAt:
  17773. return m.OldDeletedAt(ctx)
  17774. case sopstage.FieldTaskID:
  17775. return m.OldTaskID(ctx)
  17776. case sopstage.FieldName:
  17777. return m.OldName(ctx)
  17778. case sopstage.FieldConditionType:
  17779. return m.OldConditionType(ctx)
  17780. case sopstage.FieldConditionOperator:
  17781. return m.OldConditionOperator(ctx)
  17782. case sopstage.FieldConditionList:
  17783. return m.OldConditionList(ctx)
  17784. case sopstage.FieldActionMessage:
  17785. return m.OldActionMessage(ctx)
  17786. case sopstage.FieldActionLabelAdd:
  17787. return m.OldActionLabelAdd(ctx)
  17788. case sopstage.FieldActionLabelDel:
  17789. return m.OldActionLabelDel(ctx)
  17790. case sopstage.FieldActionForward:
  17791. return m.OldActionForward(ctx)
  17792. case sopstage.FieldIndexSort:
  17793. return m.OldIndexSort(ctx)
  17794. }
  17795. return nil, fmt.Errorf("unknown SopStage field %s", name)
  17796. }
  17797. // SetField sets the value of a field with the given name. It returns an error if
  17798. // the field is not defined in the schema, or if the type mismatched the field
  17799. // type.
  17800. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  17801. switch name {
  17802. case sopstage.FieldCreatedAt:
  17803. v, ok := value.(time.Time)
  17804. if !ok {
  17805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17806. }
  17807. m.SetCreatedAt(v)
  17808. return nil
  17809. case sopstage.FieldUpdatedAt:
  17810. v, ok := value.(time.Time)
  17811. if !ok {
  17812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17813. }
  17814. m.SetUpdatedAt(v)
  17815. return nil
  17816. case sopstage.FieldStatus:
  17817. v, ok := value.(uint8)
  17818. if !ok {
  17819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17820. }
  17821. m.SetStatus(v)
  17822. return nil
  17823. case sopstage.FieldDeletedAt:
  17824. v, ok := value.(time.Time)
  17825. if !ok {
  17826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17827. }
  17828. m.SetDeletedAt(v)
  17829. return nil
  17830. case sopstage.FieldTaskID:
  17831. v, ok := value.(uint64)
  17832. if !ok {
  17833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17834. }
  17835. m.SetTaskID(v)
  17836. return nil
  17837. case sopstage.FieldName:
  17838. v, ok := value.(string)
  17839. if !ok {
  17840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17841. }
  17842. m.SetName(v)
  17843. return nil
  17844. case sopstage.FieldConditionType:
  17845. v, ok := value.(int)
  17846. if !ok {
  17847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17848. }
  17849. m.SetConditionType(v)
  17850. return nil
  17851. case sopstage.FieldConditionOperator:
  17852. v, ok := value.(int)
  17853. if !ok {
  17854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17855. }
  17856. m.SetConditionOperator(v)
  17857. return nil
  17858. case sopstage.FieldConditionList:
  17859. v, ok := value.([]custom_types.Condition)
  17860. if !ok {
  17861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17862. }
  17863. m.SetConditionList(v)
  17864. return nil
  17865. case sopstage.FieldActionMessage:
  17866. v, ok := value.([]custom_types.Action)
  17867. if !ok {
  17868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17869. }
  17870. m.SetActionMessage(v)
  17871. return nil
  17872. case sopstage.FieldActionLabelAdd:
  17873. v, ok := value.([]uint64)
  17874. if !ok {
  17875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17876. }
  17877. m.SetActionLabelAdd(v)
  17878. return nil
  17879. case sopstage.FieldActionLabelDel:
  17880. v, ok := value.([]uint64)
  17881. if !ok {
  17882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17883. }
  17884. m.SetActionLabelDel(v)
  17885. return nil
  17886. case sopstage.FieldActionForward:
  17887. v, ok := value.(*custom_types.ActionForward)
  17888. if !ok {
  17889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17890. }
  17891. m.SetActionForward(v)
  17892. return nil
  17893. case sopstage.FieldIndexSort:
  17894. v, ok := value.(int)
  17895. if !ok {
  17896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17897. }
  17898. m.SetIndexSort(v)
  17899. return nil
  17900. }
  17901. return fmt.Errorf("unknown SopStage field %s", name)
  17902. }
  17903. // AddedFields returns all numeric fields that were incremented/decremented during
  17904. // this mutation.
  17905. func (m *SopStageMutation) AddedFields() []string {
  17906. var fields []string
  17907. if m.addstatus != nil {
  17908. fields = append(fields, sopstage.FieldStatus)
  17909. }
  17910. if m.addcondition_type != nil {
  17911. fields = append(fields, sopstage.FieldConditionType)
  17912. }
  17913. if m.addcondition_operator != nil {
  17914. fields = append(fields, sopstage.FieldConditionOperator)
  17915. }
  17916. if m.addindex_sort != nil {
  17917. fields = append(fields, sopstage.FieldIndexSort)
  17918. }
  17919. return fields
  17920. }
  17921. // AddedField returns the numeric value that was incremented/decremented on a field
  17922. // with the given name. The second boolean return value indicates that this field
  17923. // was not set, or was not defined in the schema.
  17924. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  17925. switch name {
  17926. case sopstage.FieldStatus:
  17927. return m.AddedStatus()
  17928. case sopstage.FieldConditionType:
  17929. return m.AddedConditionType()
  17930. case sopstage.FieldConditionOperator:
  17931. return m.AddedConditionOperator()
  17932. case sopstage.FieldIndexSort:
  17933. return m.AddedIndexSort()
  17934. }
  17935. return nil, false
  17936. }
  17937. // AddField adds the value to the field with the given name. It returns an error if
  17938. // the field is not defined in the schema, or if the type mismatched the field
  17939. // type.
  17940. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  17941. switch name {
  17942. case sopstage.FieldStatus:
  17943. v, ok := value.(int8)
  17944. if !ok {
  17945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17946. }
  17947. m.AddStatus(v)
  17948. return nil
  17949. case sopstage.FieldConditionType:
  17950. v, ok := value.(int)
  17951. if !ok {
  17952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17953. }
  17954. m.AddConditionType(v)
  17955. return nil
  17956. case sopstage.FieldConditionOperator:
  17957. v, ok := value.(int)
  17958. if !ok {
  17959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17960. }
  17961. m.AddConditionOperator(v)
  17962. return nil
  17963. case sopstage.FieldIndexSort:
  17964. v, ok := value.(int)
  17965. if !ok {
  17966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17967. }
  17968. m.AddIndexSort(v)
  17969. return nil
  17970. }
  17971. return fmt.Errorf("unknown SopStage numeric field %s", name)
  17972. }
  17973. // ClearedFields returns all nullable fields that were cleared during this
  17974. // mutation.
  17975. func (m *SopStageMutation) ClearedFields() []string {
  17976. var fields []string
  17977. if m.FieldCleared(sopstage.FieldStatus) {
  17978. fields = append(fields, sopstage.FieldStatus)
  17979. }
  17980. if m.FieldCleared(sopstage.FieldDeletedAt) {
  17981. fields = append(fields, sopstage.FieldDeletedAt)
  17982. }
  17983. if m.FieldCleared(sopstage.FieldActionMessage) {
  17984. fields = append(fields, sopstage.FieldActionMessage)
  17985. }
  17986. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  17987. fields = append(fields, sopstage.FieldActionLabelAdd)
  17988. }
  17989. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  17990. fields = append(fields, sopstage.FieldActionLabelDel)
  17991. }
  17992. if m.FieldCleared(sopstage.FieldActionForward) {
  17993. fields = append(fields, sopstage.FieldActionForward)
  17994. }
  17995. if m.FieldCleared(sopstage.FieldIndexSort) {
  17996. fields = append(fields, sopstage.FieldIndexSort)
  17997. }
  17998. return fields
  17999. }
  18000. // FieldCleared returns a boolean indicating if a field with the given name was
  18001. // cleared in this mutation.
  18002. func (m *SopStageMutation) FieldCleared(name string) bool {
  18003. _, ok := m.clearedFields[name]
  18004. return ok
  18005. }
  18006. // ClearField clears the value of the field with the given name. It returns an
  18007. // error if the field is not defined in the schema.
  18008. func (m *SopStageMutation) ClearField(name string) error {
  18009. switch name {
  18010. case sopstage.FieldStatus:
  18011. m.ClearStatus()
  18012. return nil
  18013. case sopstage.FieldDeletedAt:
  18014. m.ClearDeletedAt()
  18015. return nil
  18016. case sopstage.FieldActionMessage:
  18017. m.ClearActionMessage()
  18018. return nil
  18019. case sopstage.FieldActionLabelAdd:
  18020. m.ClearActionLabelAdd()
  18021. return nil
  18022. case sopstage.FieldActionLabelDel:
  18023. m.ClearActionLabelDel()
  18024. return nil
  18025. case sopstage.FieldActionForward:
  18026. m.ClearActionForward()
  18027. return nil
  18028. case sopstage.FieldIndexSort:
  18029. m.ClearIndexSort()
  18030. return nil
  18031. }
  18032. return fmt.Errorf("unknown SopStage nullable field %s", name)
  18033. }
  18034. // ResetField resets all changes in the mutation for the field with the given name.
  18035. // It returns an error if the field is not defined in the schema.
  18036. func (m *SopStageMutation) ResetField(name string) error {
  18037. switch name {
  18038. case sopstage.FieldCreatedAt:
  18039. m.ResetCreatedAt()
  18040. return nil
  18041. case sopstage.FieldUpdatedAt:
  18042. m.ResetUpdatedAt()
  18043. return nil
  18044. case sopstage.FieldStatus:
  18045. m.ResetStatus()
  18046. return nil
  18047. case sopstage.FieldDeletedAt:
  18048. m.ResetDeletedAt()
  18049. return nil
  18050. case sopstage.FieldTaskID:
  18051. m.ResetTaskID()
  18052. return nil
  18053. case sopstage.FieldName:
  18054. m.ResetName()
  18055. return nil
  18056. case sopstage.FieldConditionType:
  18057. m.ResetConditionType()
  18058. return nil
  18059. case sopstage.FieldConditionOperator:
  18060. m.ResetConditionOperator()
  18061. return nil
  18062. case sopstage.FieldConditionList:
  18063. m.ResetConditionList()
  18064. return nil
  18065. case sopstage.FieldActionMessage:
  18066. m.ResetActionMessage()
  18067. return nil
  18068. case sopstage.FieldActionLabelAdd:
  18069. m.ResetActionLabelAdd()
  18070. return nil
  18071. case sopstage.FieldActionLabelDel:
  18072. m.ResetActionLabelDel()
  18073. return nil
  18074. case sopstage.FieldActionForward:
  18075. m.ResetActionForward()
  18076. return nil
  18077. case sopstage.FieldIndexSort:
  18078. m.ResetIndexSort()
  18079. return nil
  18080. }
  18081. return fmt.Errorf("unknown SopStage field %s", name)
  18082. }
  18083. // AddedEdges returns all edge names that were set/added in this mutation.
  18084. func (m *SopStageMutation) AddedEdges() []string {
  18085. edges := make([]string, 0, 3)
  18086. if m.sop_task != nil {
  18087. edges = append(edges, sopstage.EdgeSopTask)
  18088. }
  18089. if m.stage_nodes != nil {
  18090. edges = append(edges, sopstage.EdgeStageNodes)
  18091. }
  18092. if m.stage_messages != nil {
  18093. edges = append(edges, sopstage.EdgeStageMessages)
  18094. }
  18095. return edges
  18096. }
  18097. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18098. // name in this mutation.
  18099. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  18100. switch name {
  18101. case sopstage.EdgeSopTask:
  18102. if id := m.sop_task; id != nil {
  18103. return []ent.Value{*id}
  18104. }
  18105. case sopstage.EdgeStageNodes:
  18106. ids := make([]ent.Value, 0, len(m.stage_nodes))
  18107. for id := range m.stage_nodes {
  18108. ids = append(ids, id)
  18109. }
  18110. return ids
  18111. case sopstage.EdgeStageMessages:
  18112. ids := make([]ent.Value, 0, len(m.stage_messages))
  18113. for id := range m.stage_messages {
  18114. ids = append(ids, id)
  18115. }
  18116. return ids
  18117. }
  18118. return nil
  18119. }
  18120. // RemovedEdges returns all edge names that were removed in this mutation.
  18121. func (m *SopStageMutation) RemovedEdges() []string {
  18122. edges := make([]string, 0, 3)
  18123. if m.removedstage_nodes != nil {
  18124. edges = append(edges, sopstage.EdgeStageNodes)
  18125. }
  18126. if m.removedstage_messages != nil {
  18127. edges = append(edges, sopstage.EdgeStageMessages)
  18128. }
  18129. return edges
  18130. }
  18131. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18132. // the given name in this mutation.
  18133. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  18134. switch name {
  18135. case sopstage.EdgeStageNodes:
  18136. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  18137. for id := range m.removedstage_nodes {
  18138. ids = append(ids, id)
  18139. }
  18140. return ids
  18141. case sopstage.EdgeStageMessages:
  18142. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  18143. for id := range m.removedstage_messages {
  18144. ids = append(ids, id)
  18145. }
  18146. return ids
  18147. }
  18148. return nil
  18149. }
  18150. // ClearedEdges returns all edge names that were cleared in this mutation.
  18151. func (m *SopStageMutation) ClearedEdges() []string {
  18152. edges := make([]string, 0, 3)
  18153. if m.clearedsop_task {
  18154. edges = append(edges, sopstage.EdgeSopTask)
  18155. }
  18156. if m.clearedstage_nodes {
  18157. edges = append(edges, sopstage.EdgeStageNodes)
  18158. }
  18159. if m.clearedstage_messages {
  18160. edges = append(edges, sopstage.EdgeStageMessages)
  18161. }
  18162. return edges
  18163. }
  18164. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18165. // was cleared in this mutation.
  18166. func (m *SopStageMutation) EdgeCleared(name string) bool {
  18167. switch name {
  18168. case sopstage.EdgeSopTask:
  18169. return m.clearedsop_task
  18170. case sopstage.EdgeStageNodes:
  18171. return m.clearedstage_nodes
  18172. case sopstage.EdgeStageMessages:
  18173. return m.clearedstage_messages
  18174. }
  18175. return false
  18176. }
  18177. // ClearEdge clears the value of the edge with the given name. It returns an error
  18178. // if that edge is not defined in the schema.
  18179. func (m *SopStageMutation) ClearEdge(name string) error {
  18180. switch name {
  18181. case sopstage.EdgeSopTask:
  18182. m.ClearSopTask()
  18183. return nil
  18184. }
  18185. return fmt.Errorf("unknown SopStage unique edge %s", name)
  18186. }
  18187. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18188. // It returns an error if the edge is not defined in the schema.
  18189. func (m *SopStageMutation) ResetEdge(name string) error {
  18190. switch name {
  18191. case sopstage.EdgeSopTask:
  18192. m.ResetSopTask()
  18193. return nil
  18194. case sopstage.EdgeStageNodes:
  18195. m.ResetStageNodes()
  18196. return nil
  18197. case sopstage.EdgeStageMessages:
  18198. m.ResetStageMessages()
  18199. return nil
  18200. }
  18201. return fmt.Errorf("unknown SopStage edge %s", name)
  18202. }
  18203. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  18204. type SopTaskMutation struct {
  18205. config
  18206. op Op
  18207. typ string
  18208. id *uint64
  18209. created_at *time.Time
  18210. updated_at *time.Time
  18211. status *uint8
  18212. addstatus *int8
  18213. deleted_at *time.Time
  18214. name *string
  18215. bot_wxid_list *[]string
  18216. appendbot_wxid_list []string
  18217. _type *int
  18218. add_type *int
  18219. plan_start_time *time.Time
  18220. plan_end_time *time.Time
  18221. creator_id *string
  18222. organization_id *uint64
  18223. addorganization_id *int64
  18224. clearedFields map[string]struct{}
  18225. task_stages map[uint64]struct{}
  18226. removedtask_stages map[uint64]struct{}
  18227. clearedtask_stages bool
  18228. done bool
  18229. oldValue func(context.Context) (*SopTask, error)
  18230. predicates []predicate.SopTask
  18231. }
  18232. var _ ent.Mutation = (*SopTaskMutation)(nil)
  18233. // soptaskOption allows management of the mutation configuration using functional options.
  18234. type soptaskOption func(*SopTaskMutation)
  18235. // newSopTaskMutation creates new mutation for the SopTask entity.
  18236. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  18237. m := &SopTaskMutation{
  18238. config: c,
  18239. op: op,
  18240. typ: TypeSopTask,
  18241. clearedFields: make(map[string]struct{}),
  18242. }
  18243. for _, opt := range opts {
  18244. opt(m)
  18245. }
  18246. return m
  18247. }
  18248. // withSopTaskID sets the ID field of the mutation.
  18249. func withSopTaskID(id uint64) soptaskOption {
  18250. return func(m *SopTaskMutation) {
  18251. var (
  18252. err error
  18253. once sync.Once
  18254. value *SopTask
  18255. )
  18256. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  18257. once.Do(func() {
  18258. if m.done {
  18259. err = errors.New("querying old values post mutation is not allowed")
  18260. } else {
  18261. value, err = m.Client().SopTask.Get(ctx, id)
  18262. }
  18263. })
  18264. return value, err
  18265. }
  18266. m.id = &id
  18267. }
  18268. }
  18269. // withSopTask sets the old SopTask of the mutation.
  18270. func withSopTask(node *SopTask) soptaskOption {
  18271. return func(m *SopTaskMutation) {
  18272. m.oldValue = func(context.Context) (*SopTask, error) {
  18273. return node, nil
  18274. }
  18275. m.id = &node.ID
  18276. }
  18277. }
  18278. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18279. // executed in a transaction (ent.Tx), a transactional client is returned.
  18280. func (m SopTaskMutation) Client() *Client {
  18281. client := &Client{config: m.config}
  18282. client.init()
  18283. return client
  18284. }
  18285. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18286. // it returns an error otherwise.
  18287. func (m SopTaskMutation) Tx() (*Tx, error) {
  18288. if _, ok := m.driver.(*txDriver); !ok {
  18289. return nil, errors.New("ent: mutation is not running in a transaction")
  18290. }
  18291. tx := &Tx{config: m.config}
  18292. tx.init()
  18293. return tx, nil
  18294. }
  18295. // SetID sets the value of the id field. Note that this
  18296. // operation is only accepted on creation of SopTask entities.
  18297. func (m *SopTaskMutation) SetID(id uint64) {
  18298. m.id = &id
  18299. }
  18300. // ID returns the ID value in the mutation. Note that the ID is only available
  18301. // if it was provided to the builder or after it was returned from the database.
  18302. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  18303. if m.id == nil {
  18304. return
  18305. }
  18306. return *m.id, true
  18307. }
  18308. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18309. // That means, if the mutation is applied within a transaction with an isolation level such
  18310. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18311. // or updated by the mutation.
  18312. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  18313. switch {
  18314. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18315. id, exists := m.ID()
  18316. if exists {
  18317. return []uint64{id}, nil
  18318. }
  18319. fallthrough
  18320. case m.op.Is(OpUpdate | OpDelete):
  18321. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  18322. default:
  18323. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18324. }
  18325. }
  18326. // SetCreatedAt sets the "created_at" field.
  18327. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  18328. m.created_at = &t
  18329. }
  18330. // CreatedAt returns the value of the "created_at" field in the mutation.
  18331. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  18332. v := m.created_at
  18333. if v == nil {
  18334. return
  18335. }
  18336. return *v, true
  18337. }
  18338. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  18339. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18341. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18342. if !m.op.Is(OpUpdateOne) {
  18343. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18344. }
  18345. if m.id == nil || m.oldValue == nil {
  18346. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18347. }
  18348. oldValue, err := m.oldValue(ctx)
  18349. if err != nil {
  18350. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18351. }
  18352. return oldValue.CreatedAt, nil
  18353. }
  18354. // ResetCreatedAt resets all changes to the "created_at" field.
  18355. func (m *SopTaskMutation) ResetCreatedAt() {
  18356. m.created_at = nil
  18357. }
  18358. // SetUpdatedAt sets the "updated_at" field.
  18359. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  18360. m.updated_at = &t
  18361. }
  18362. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18363. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  18364. v := m.updated_at
  18365. if v == nil {
  18366. return
  18367. }
  18368. return *v, true
  18369. }
  18370. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  18371. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18373. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18374. if !m.op.Is(OpUpdateOne) {
  18375. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18376. }
  18377. if m.id == nil || m.oldValue == nil {
  18378. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18379. }
  18380. oldValue, err := m.oldValue(ctx)
  18381. if err != nil {
  18382. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18383. }
  18384. return oldValue.UpdatedAt, nil
  18385. }
  18386. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18387. func (m *SopTaskMutation) ResetUpdatedAt() {
  18388. m.updated_at = nil
  18389. }
  18390. // SetStatus sets the "status" field.
  18391. func (m *SopTaskMutation) SetStatus(u uint8) {
  18392. m.status = &u
  18393. m.addstatus = nil
  18394. }
  18395. // Status returns the value of the "status" field in the mutation.
  18396. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  18397. v := m.status
  18398. if v == nil {
  18399. return
  18400. }
  18401. return *v, true
  18402. }
  18403. // OldStatus returns the old "status" field's value of the SopTask entity.
  18404. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18406. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18407. if !m.op.Is(OpUpdateOne) {
  18408. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18409. }
  18410. if m.id == nil || m.oldValue == nil {
  18411. return v, errors.New("OldStatus requires an ID field in the mutation")
  18412. }
  18413. oldValue, err := m.oldValue(ctx)
  18414. if err != nil {
  18415. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18416. }
  18417. return oldValue.Status, nil
  18418. }
  18419. // AddStatus adds u to the "status" field.
  18420. func (m *SopTaskMutation) AddStatus(u int8) {
  18421. if m.addstatus != nil {
  18422. *m.addstatus += u
  18423. } else {
  18424. m.addstatus = &u
  18425. }
  18426. }
  18427. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18428. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  18429. v := m.addstatus
  18430. if v == nil {
  18431. return
  18432. }
  18433. return *v, true
  18434. }
  18435. // ClearStatus clears the value of the "status" field.
  18436. func (m *SopTaskMutation) ClearStatus() {
  18437. m.status = nil
  18438. m.addstatus = nil
  18439. m.clearedFields[soptask.FieldStatus] = struct{}{}
  18440. }
  18441. // StatusCleared returns if the "status" field was cleared in this mutation.
  18442. func (m *SopTaskMutation) StatusCleared() bool {
  18443. _, ok := m.clearedFields[soptask.FieldStatus]
  18444. return ok
  18445. }
  18446. // ResetStatus resets all changes to the "status" field.
  18447. func (m *SopTaskMutation) ResetStatus() {
  18448. m.status = nil
  18449. m.addstatus = nil
  18450. delete(m.clearedFields, soptask.FieldStatus)
  18451. }
  18452. // SetDeletedAt sets the "deleted_at" field.
  18453. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  18454. m.deleted_at = &t
  18455. }
  18456. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18457. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  18458. v := m.deleted_at
  18459. if v == nil {
  18460. return
  18461. }
  18462. return *v, true
  18463. }
  18464. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  18465. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18467. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18468. if !m.op.Is(OpUpdateOne) {
  18469. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18470. }
  18471. if m.id == nil || m.oldValue == nil {
  18472. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18473. }
  18474. oldValue, err := m.oldValue(ctx)
  18475. if err != nil {
  18476. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18477. }
  18478. return oldValue.DeletedAt, nil
  18479. }
  18480. // ClearDeletedAt clears the value of the "deleted_at" field.
  18481. func (m *SopTaskMutation) ClearDeletedAt() {
  18482. m.deleted_at = nil
  18483. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  18484. }
  18485. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18486. func (m *SopTaskMutation) DeletedAtCleared() bool {
  18487. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  18488. return ok
  18489. }
  18490. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18491. func (m *SopTaskMutation) ResetDeletedAt() {
  18492. m.deleted_at = nil
  18493. delete(m.clearedFields, soptask.FieldDeletedAt)
  18494. }
  18495. // SetName sets the "name" field.
  18496. func (m *SopTaskMutation) SetName(s string) {
  18497. m.name = &s
  18498. }
  18499. // Name returns the value of the "name" field in the mutation.
  18500. func (m *SopTaskMutation) Name() (r string, exists bool) {
  18501. v := m.name
  18502. if v == nil {
  18503. return
  18504. }
  18505. return *v, true
  18506. }
  18507. // OldName returns the old "name" field's value of the SopTask entity.
  18508. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18510. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  18511. if !m.op.Is(OpUpdateOne) {
  18512. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18513. }
  18514. if m.id == nil || m.oldValue == nil {
  18515. return v, errors.New("OldName requires an ID field in the mutation")
  18516. }
  18517. oldValue, err := m.oldValue(ctx)
  18518. if err != nil {
  18519. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18520. }
  18521. return oldValue.Name, nil
  18522. }
  18523. // ResetName resets all changes to the "name" field.
  18524. func (m *SopTaskMutation) ResetName() {
  18525. m.name = nil
  18526. }
  18527. // SetBotWxidList sets the "bot_wxid_list" field.
  18528. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  18529. m.bot_wxid_list = &s
  18530. m.appendbot_wxid_list = nil
  18531. }
  18532. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  18533. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  18534. v := m.bot_wxid_list
  18535. if v == nil {
  18536. return
  18537. }
  18538. return *v, true
  18539. }
  18540. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  18541. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18543. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  18544. if !m.op.Is(OpUpdateOne) {
  18545. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  18546. }
  18547. if m.id == nil || m.oldValue == nil {
  18548. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  18549. }
  18550. oldValue, err := m.oldValue(ctx)
  18551. if err != nil {
  18552. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  18553. }
  18554. return oldValue.BotWxidList, nil
  18555. }
  18556. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  18557. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  18558. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  18559. }
  18560. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  18561. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  18562. if len(m.appendbot_wxid_list) == 0 {
  18563. return nil, false
  18564. }
  18565. return m.appendbot_wxid_list, true
  18566. }
  18567. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  18568. func (m *SopTaskMutation) ClearBotWxidList() {
  18569. m.bot_wxid_list = nil
  18570. m.appendbot_wxid_list = nil
  18571. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  18572. }
  18573. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  18574. func (m *SopTaskMutation) BotWxidListCleared() bool {
  18575. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  18576. return ok
  18577. }
  18578. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  18579. func (m *SopTaskMutation) ResetBotWxidList() {
  18580. m.bot_wxid_list = nil
  18581. m.appendbot_wxid_list = nil
  18582. delete(m.clearedFields, soptask.FieldBotWxidList)
  18583. }
  18584. // SetType sets the "type" field.
  18585. func (m *SopTaskMutation) SetType(i int) {
  18586. m._type = &i
  18587. m.add_type = nil
  18588. }
  18589. // GetType returns the value of the "type" field in the mutation.
  18590. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  18591. v := m._type
  18592. if v == nil {
  18593. return
  18594. }
  18595. return *v, true
  18596. }
  18597. // OldType returns the old "type" field's value of the SopTask entity.
  18598. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18600. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  18601. if !m.op.Is(OpUpdateOne) {
  18602. return v, errors.New("OldType is only allowed on UpdateOne operations")
  18603. }
  18604. if m.id == nil || m.oldValue == nil {
  18605. return v, errors.New("OldType requires an ID field in the mutation")
  18606. }
  18607. oldValue, err := m.oldValue(ctx)
  18608. if err != nil {
  18609. return v, fmt.Errorf("querying old value for OldType: %w", err)
  18610. }
  18611. return oldValue.Type, nil
  18612. }
  18613. // AddType adds i to the "type" field.
  18614. func (m *SopTaskMutation) AddType(i int) {
  18615. if m.add_type != nil {
  18616. *m.add_type += i
  18617. } else {
  18618. m.add_type = &i
  18619. }
  18620. }
  18621. // AddedType returns the value that was added to the "type" field in this mutation.
  18622. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  18623. v := m.add_type
  18624. if v == nil {
  18625. return
  18626. }
  18627. return *v, true
  18628. }
  18629. // ResetType resets all changes to the "type" field.
  18630. func (m *SopTaskMutation) ResetType() {
  18631. m._type = nil
  18632. m.add_type = nil
  18633. }
  18634. // SetPlanStartTime sets the "plan_start_time" field.
  18635. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  18636. m.plan_start_time = &t
  18637. }
  18638. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  18639. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  18640. v := m.plan_start_time
  18641. if v == nil {
  18642. return
  18643. }
  18644. return *v, true
  18645. }
  18646. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  18647. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18649. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  18650. if !m.op.Is(OpUpdateOne) {
  18651. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  18652. }
  18653. if m.id == nil || m.oldValue == nil {
  18654. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  18655. }
  18656. oldValue, err := m.oldValue(ctx)
  18657. if err != nil {
  18658. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  18659. }
  18660. return oldValue.PlanStartTime, nil
  18661. }
  18662. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  18663. func (m *SopTaskMutation) ClearPlanStartTime() {
  18664. m.plan_start_time = nil
  18665. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  18666. }
  18667. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  18668. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  18669. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  18670. return ok
  18671. }
  18672. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  18673. func (m *SopTaskMutation) ResetPlanStartTime() {
  18674. m.plan_start_time = nil
  18675. delete(m.clearedFields, soptask.FieldPlanStartTime)
  18676. }
  18677. // SetPlanEndTime sets the "plan_end_time" field.
  18678. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  18679. m.plan_end_time = &t
  18680. }
  18681. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  18682. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  18683. v := m.plan_end_time
  18684. if v == nil {
  18685. return
  18686. }
  18687. return *v, true
  18688. }
  18689. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  18690. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18692. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  18693. if !m.op.Is(OpUpdateOne) {
  18694. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  18695. }
  18696. if m.id == nil || m.oldValue == nil {
  18697. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  18698. }
  18699. oldValue, err := m.oldValue(ctx)
  18700. if err != nil {
  18701. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  18702. }
  18703. return oldValue.PlanEndTime, nil
  18704. }
  18705. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  18706. func (m *SopTaskMutation) ClearPlanEndTime() {
  18707. m.plan_end_time = nil
  18708. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  18709. }
  18710. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  18711. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  18712. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  18713. return ok
  18714. }
  18715. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  18716. func (m *SopTaskMutation) ResetPlanEndTime() {
  18717. m.plan_end_time = nil
  18718. delete(m.clearedFields, soptask.FieldPlanEndTime)
  18719. }
  18720. // SetCreatorID sets the "creator_id" field.
  18721. func (m *SopTaskMutation) SetCreatorID(s string) {
  18722. m.creator_id = &s
  18723. }
  18724. // CreatorID returns the value of the "creator_id" field in the mutation.
  18725. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  18726. v := m.creator_id
  18727. if v == nil {
  18728. return
  18729. }
  18730. return *v, true
  18731. }
  18732. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  18733. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18735. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  18736. if !m.op.Is(OpUpdateOne) {
  18737. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  18738. }
  18739. if m.id == nil || m.oldValue == nil {
  18740. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  18741. }
  18742. oldValue, err := m.oldValue(ctx)
  18743. if err != nil {
  18744. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  18745. }
  18746. return oldValue.CreatorID, nil
  18747. }
  18748. // ClearCreatorID clears the value of the "creator_id" field.
  18749. func (m *SopTaskMutation) ClearCreatorID() {
  18750. m.creator_id = nil
  18751. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  18752. }
  18753. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  18754. func (m *SopTaskMutation) CreatorIDCleared() bool {
  18755. _, ok := m.clearedFields[soptask.FieldCreatorID]
  18756. return ok
  18757. }
  18758. // ResetCreatorID resets all changes to the "creator_id" field.
  18759. func (m *SopTaskMutation) ResetCreatorID() {
  18760. m.creator_id = nil
  18761. delete(m.clearedFields, soptask.FieldCreatorID)
  18762. }
  18763. // SetOrganizationID sets the "organization_id" field.
  18764. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  18765. m.organization_id = &u
  18766. m.addorganization_id = nil
  18767. }
  18768. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18769. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  18770. v := m.organization_id
  18771. if v == nil {
  18772. return
  18773. }
  18774. return *v, true
  18775. }
  18776. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  18777. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18779. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18780. if !m.op.Is(OpUpdateOne) {
  18781. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18782. }
  18783. if m.id == nil || m.oldValue == nil {
  18784. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18785. }
  18786. oldValue, err := m.oldValue(ctx)
  18787. if err != nil {
  18788. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18789. }
  18790. return oldValue.OrganizationID, nil
  18791. }
  18792. // AddOrganizationID adds u to the "organization_id" field.
  18793. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  18794. if m.addorganization_id != nil {
  18795. *m.addorganization_id += u
  18796. } else {
  18797. m.addorganization_id = &u
  18798. }
  18799. }
  18800. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18801. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  18802. v := m.addorganization_id
  18803. if v == nil {
  18804. return
  18805. }
  18806. return *v, true
  18807. }
  18808. // ClearOrganizationID clears the value of the "organization_id" field.
  18809. func (m *SopTaskMutation) ClearOrganizationID() {
  18810. m.organization_id = nil
  18811. m.addorganization_id = nil
  18812. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  18813. }
  18814. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18815. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  18816. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  18817. return ok
  18818. }
  18819. // ResetOrganizationID resets all changes to the "organization_id" field.
  18820. func (m *SopTaskMutation) ResetOrganizationID() {
  18821. m.organization_id = nil
  18822. m.addorganization_id = nil
  18823. delete(m.clearedFields, soptask.FieldOrganizationID)
  18824. }
  18825. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  18826. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  18827. if m.task_stages == nil {
  18828. m.task_stages = make(map[uint64]struct{})
  18829. }
  18830. for i := range ids {
  18831. m.task_stages[ids[i]] = struct{}{}
  18832. }
  18833. }
  18834. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  18835. func (m *SopTaskMutation) ClearTaskStages() {
  18836. m.clearedtask_stages = true
  18837. }
  18838. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  18839. func (m *SopTaskMutation) TaskStagesCleared() bool {
  18840. return m.clearedtask_stages
  18841. }
  18842. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  18843. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  18844. if m.removedtask_stages == nil {
  18845. m.removedtask_stages = make(map[uint64]struct{})
  18846. }
  18847. for i := range ids {
  18848. delete(m.task_stages, ids[i])
  18849. m.removedtask_stages[ids[i]] = struct{}{}
  18850. }
  18851. }
  18852. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  18853. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  18854. for id := range m.removedtask_stages {
  18855. ids = append(ids, id)
  18856. }
  18857. return
  18858. }
  18859. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  18860. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  18861. for id := range m.task_stages {
  18862. ids = append(ids, id)
  18863. }
  18864. return
  18865. }
  18866. // ResetTaskStages resets all changes to the "task_stages" edge.
  18867. func (m *SopTaskMutation) ResetTaskStages() {
  18868. m.task_stages = nil
  18869. m.clearedtask_stages = false
  18870. m.removedtask_stages = nil
  18871. }
  18872. // Where appends a list predicates to the SopTaskMutation builder.
  18873. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  18874. m.predicates = append(m.predicates, ps...)
  18875. }
  18876. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  18877. // users can use type-assertion to append predicates that do not depend on any generated package.
  18878. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  18879. p := make([]predicate.SopTask, len(ps))
  18880. for i := range ps {
  18881. p[i] = ps[i]
  18882. }
  18883. m.Where(p...)
  18884. }
  18885. // Op returns the operation name.
  18886. func (m *SopTaskMutation) Op() Op {
  18887. return m.op
  18888. }
  18889. // SetOp allows setting the mutation operation.
  18890. func (m *SopTaskMutation) SetOp(op Op) {
  18891. m.op = op
  18892. }
  18893. // Type returns the node type of this mutation (SopTask).
  18894. func (m *SopTaskMutation) Type() string {
  18895. return m.typ
  18896. }
  18897. // Fields returns all fields that were changed during this mutation. Note that in
  18898. // order to get all numeric fields that were incremented/decremented, call
  18899. // AddedFields().
  18900. func (m *SopTaskMutation) Fields() []string {
  18901. fields := make([]string, 0, 11)
  18902. if m.created_at != nil {
  18903. fields = append(fields, soptask.FieldCreatedAt)
  18904. }
  18905. if m.updated_at != nil {
  18906. fields = append(fields, soptask.FieldUpdatedAt)
  18907. }
  18908. if m.status != nil {
  18909. fields = append(fields, soptask.FieldStatus)
  18910. }
  18911. if m.deleted_at != nil {
  18912. fields = append(fields, soptask.FieldDeletedAt)
  18913. }
  18914. if m.name != nil {
  18915. fields = append(fields, soptask.FieldName)
  18916. }
  18917. if m.bot_wxid_list != nil {
  18918. fields = append(fields, soptask.FieldBotWxidList)
  18919. }
  18920. if m._type != nil {
  18921. fields = append(fields, soptask.FieldType)
  18922. }
  18923. if m.plan_start_time != nil {
  18924. fields = append(fields, soptask.FieldPlanStartTime)
  18925. }
  18926. if m.plan_end_time != nil {
  18927. fields = append(fields, soptask.FieldPlanEndTime)
  18928. }
  18929. if m.creator_id != nil {
  18930. fields = append(fields, soptask.FieldCreatorID)
  18931. }
  18932. if m.organization_id != nil {
  18933. fields = append(fields, soptask.FieldOrganizationID)
  18934. }
  18935. return fields
  18936. }
  18937. // Field returns the value of a field with the given name. The second boolean
  18938. // return value indicates that this field was not set, or was not defined in the
  18939. // schema.
  18940. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  18941. switch name {
  18942. case soptask.FieldCreatedAt:
  18943. return m.CreatedAt()
  18944. case soptask.FieldUpdatedAt:
  18945. return m.UpdatedAt()
  18946. case soptask.FieldStatus:
  18947. return m.Status()
  18948. case soptask.FieldDeletedAt:
  18949. return m.DeletedAt()
  18950. case soptask.FieldName:
  18951. return m.Name()
  18952. case soptask.FieldBotWxidList:
  18953. return m.BotWxidList()
  18954. case soptask.FieldType:
  18955. return m.GetType()
  18956. case soptask.FieldPlanStartTime:
  18957. return m.PlanStartTime()
  18958. case soptask.FieldPlanEndTime:
  18959. return m.PlanEndTime()
  18960. case soptask.FieldCreatorID:
  18961. return m.CreatorID()
  18962. case soptask.FieldOrganizationID:
  18963. return m.OrganizationID()
  18964. }
  18965. return nil, false
  18966. }
  18967. // OldField returns the old value of the field from the database. An error is
  18968. // returned if the mutation operation is not UpdateOne, or the query to the
  18969. // database failed.
  18970. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18971. switch name {
  18972. case soptask.FieldCreatedAt:
  18973. return m.OldCreatedAt(ctx)
  18974. case soptask.FieldUpdatedAt:
  18975. return m.OldUpdatedAt(ctx)
  18976. case soptask.FieldStatus:
  18977. return m.OldStatus(ctx)
  18978. case soptask.FieldDeletedAt:
  18979. return m.OldDeletedAt(ctx)
  18980. case soptask.FieldName:
  18981. return m.OldName(ctx)
  18982. case soptask.FieldBotWxidList:
  18983. return m.OldBotWxidList(ctx)
  18984. case soptask.FieldType:
  18985. return m.OldType(ctx)
  18986. case soptask.FieldPlanStartTime:
  18987. return m.OldPlanStartTime(ctx)
  18988. case soptask.FieldPlanEndTime:
  18989. return m.OldPlanEndTime(ctx)
  18990. case soptask.FieldCreatorID:
  18991. return m.OldCreatorID(ctx)
  18992. case soptask.FieldOrganizationID:
  18993. return m.OldOrganizationID(ctx)
  18994. }
  18995. return nil, fmt.Errorf("unknown SopTask field %s", name)
  18996. }
  18997. // SetField sets the value of a field with the given name. It returns an error if
  18998. // the field is not defined in the schema, or if the type mismatched the field
  18999. // type.
  19000. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  19001. switch name {
  19002. case soptask.FieldCreatedAt:
  19003. v, ok := value.(time.Time)
  19004. if !ok {
  19005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19006. }
  19007. m.SetCreatedAt(v)
  19008. return nil
  19009. case soptask.FieldUpdatedAt:
  19010. v, ok := value.(time.Time)
  19011. if !ok {
  19012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19013. }
  19014. m.SetUpdatedAt(v)
  19015. return nil
  19016. case soptask.FieldStatus:
  19017. v, ok := value.(uint8)
  19018. if !ok {
  19019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19020. }
  19021. m.SetStatus(v)
  19022. return nil
  19023. case soptask.FieldDeletedAt:
  19024. v, ok := value.(time.Time)
  19025. if !ok {
  19026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19027. }
  19028. m.SetDeletedAt(v)
  19029. return nil
  19030. case soptask.FieldName:
  19031. v, ok := value.(string)
  19032. if !ok {
  19033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19034. }
  19035. m.SetName(v)
  19036. return nil
  19037. case soptask.FieldBotWxidList:
  19038. v, ok := value.([]string)
  19039. if !ok {
  19040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19041. }
  19042. m.SetBotWxidList(v)
  19043. return nil
  19044. case soptask.FieldType:
  19045. v, ok := value.(int)
  19046. if !ok {
  19047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19048. }
  19049. m.SetType(v)
  19050. return nil
  19051. case soptask.FieldPlanStartTime:
  19052. v, ok := value.(time.Time)
  19053. if !ok {
  19054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19055. }
  19056. m.SetPlanStartTime(v)
  19057. return nil
  19058. case soptask.FieldPlanEndTime:
  19059. v, ok := value.(time.Time)
  19060. if !ok {
  19061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19062. }
  19063. m.SetPlanEndTime(v)
  19064. return nil
  19065. case soptask.FieldCreatorID:
  19066. v, ok := value.(string)
  19067. if !ok {
  19068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19069. }
  19070. m.SetCreatorID(v)
  19071. return nil
  19072. case soptask.FieldOrganizationID:
  19073. v, ok := value.(uint64)
  19074. if !ok {
  19075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19076. }
  19077. m.SetOrganizationID(v)
  19078. return nil
  19079. }
  19080. return fmt.Errorf("unknown SopTask field %s", name)
  19081. }
  19082. // AddedFields returns all numeric fields that were incremented/decremented during
  19083. // this mutation.
  19084. func (m *SopTaskMutation) AddedFields() []string {
  19085. var fields []string
  19086. if m.addstatus != nil {
  19087. fields = append(fields, soptask.FieldStatus)
  19088. }
  19089. if m.add_type != nil {
  19090. fields = append(fields, soptask.FieldType)
  19091. }
  19092. if m.addorganization_id != nil {
  19093. fields = append(fields, soptask.FieldOrganizationID)
  19094. }
  19095. return fields
  19096. }
  19097. // AddedField returns the numeric value that was incremented/decremented on a field
  19098. // with the given name. The second boolean return value indicates that this field
  19099. // was not set, or was not defined in the schema.
  19100. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  19101. switch name {
  19102. case soptask.FieldStatus:
  19103. return m.AddedStatus()
  19104. case soptask.FieldType:
  19105. return m.AddedType()
  19106. case soptask.FieldOrganizationID:
  19107. return m.AddedOrganizationID()
  19108. }
  19109. return nil, false
  19110. }
  19111. // AddField adds the value to the field with the given name. It returns an error if
  19112. // the field is not defined in the schema, or if the type mismatched the field
  19113. // type.
  19114. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  19115. switch name {
  19116. case soptask.FieldStatus:
  19117. v, ok := value.(int8)
  19118. if !ok {
  19119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19120. }
  19121. m.AddStatus(v)
  19122. return nil
  19123. case soptask.FieldType:
  19124. v, ok := value.(int)
  19125. if !ok {
  19126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19127. }
  19128. m.AddType(v)
  19129. return nil
  19130. case soptask.FieldOrganizationID:
  19131. v, ok := value.(int64)
  19132. if !ok {
  19133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19134. }
  19135. m.AddOrganizationID(v)
  19136. return nil
  19137. }
  19138. return fmt.Errorf("unknown SopTask numeric field %s", name)
  19139. }
  19140. // ClearedFields returns all nullable fields that were cleared during this
  19141. // mutation.
  19142. func (m *SopTaskMutation) ClearedFields() []string {
  19143. var fields []string
  19144. if m.FieldCleared(soptask.FieldStatus) {
  19145. fields = append(fields, soptask.FieldStatus)
  19146. }
  19147. if m.FieldCleared(soptask.FieldDeletedAt) {
  19148. fields = append(fields, soptask.FieldDeletedAt)
  19149. }
  19150. if m.FieldCleared(soptask.FieldBotWxidList) {
  19151. fields = append(fields, soptask.FieldBotWxidList)
  19152. }
  19153. if m.FieldCleared(soptask.FieldPlanStartTime) {
  19154. fields = append(fields, soptask.FieldPlanStartTime)
  19155. }
  19156. if m.FieldCleared(soptask.FieldPlanEndTime) {
  19157. fields = append(fields, soptask.FieldPlanEndTime)
  19158. }
  19159. if m.FieldCleared(soptask.FieldCreatorID) {
  19160. fields = append(fields, soptask.FieldCreatorID)
  19161. }
  19162. if m.FieldCleared(soptask.FieldOrganizationID) {
  19163. fields = append(fields, soptask.FieldOrganizationID)
  19164. }
  19165. return fields
  19166. }
  19167. // FieldCleared returns a boolean indicating if a field with the given name was
  19168. // cleared in this mutation.
  19169. func (m *SopTaskMutation) FieldCleared(name string) bool {
  19170. _, ok := m.clearedFields[name]
  19171. return ok
  19172. }
  19173. // ClearField clears the value of the field with the given name. It returns an
  19174. // error if the field is not defined in the schema.
  19175. func (m *SopTaskMutation) ClearField(name string) error {
  19176. switch name {
  19177. case soptask.FieldStatus:
  19178. m.ClearStatus()
  19179. return nil
  19180. case soptask.FieldDeletedAt:
  19181. m.ClearDeletedAt()
  19182. return nil
  19183. case soptask.FieldBotWxidList:
  19184. m.ClearBotWxidList()
  19185. return nil
  19186. case soptask.FieldPlanStartTime:
  19187. m.ClearPlanStartTime()
  19188. return nil
  19189. case soptask.FieldPlanEndTime:
  19190. m.ClearPlanEndTime()
  19191. return nil
  19192. case soptask.FieldCreatorID:
  19193. m.ClearCreatorID()
  19194. return nil
  19195. case soptask.FieldOrganizationID:
  19196. m.ClearOrganizationID()
  19197. return nil
  19198. }
  19199. return fmt.Errorf("unknown SopTask nullable field %s", name)
  19200. }
  19201. // ResetField resets all changes in the mutation for the field with the given name.
  19202. // It returns an error if the field is not defined in the schema.
  19203. func (m *SopTaskMutation) ResetField(name string) error {
  19204. switch name {
  19205. case soptask.FieldCreatedAt:
  19206. m.ResetCreatedAt()
  19207. return nil
  19208. case soptask.FieldUpdatedAt:
  19209. m.ResetUpdatedAt()
  19210. return nil
  19211. case soptask.FieldStatus:
  19212. m.ResetStatus()
  19213. return nil
  19214. case soptask.FieldDeletedAt:
  19215. m.ResetDeletedAt()
  19216. return nil
  19217. case soptask.FieldName:
  19218. m.ResetName()
  19219. return nil
  19220. case soptask.FieldBotWxidList:
  19221. m.ResetBotWxidList()
  19222. return nil
  19223. case soptask.FieldType:
  19224. m.ResetType()
  19225. return nil
  19226. case soptask.FieldPlanStartTime:
  19227. m.ResetPlanStartTime()
  19228. return nil
  19229. case soptask.FieldPlanEndTime:
  19230. m.ResetPlanEndTime()
  19231. return nil
  19232. case soptask.FieldCreatorID:
  19233. m.ResetCreatorID()
  19234. return nil
  19235. case soptask.FieldOrganizationID:
  19236. m.ResetOrganizationID()
  19237. return nil
  19238. }
  19239. return fmt.Errorf("unknown SopTask field %s", name)
  19240. }
  19241. // AddedEdges returns all edge names that were set/added in this mutation.
  19242. func (m *SopTaskMutation) AddedEdges() []string {
  19243. edges := make([]string, 0, 1)
  19244. if m.task_stages != nil {
  19245. edges = append(edges, soptask.EdgeTaskStages)
  19246. }
  19247. return edges
  19248. }
  19249. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19250. // name in this mutation.
  19251. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  19252. switch name {
  19253. case soptask.EdgeTaskStages:
  19254. ids := make([]ent.Value, 0, len(m.task_stages))
  19255. for id := range m.task_stages {
  19256. ids = append(ids, id)
  19257. }
  19258. return ids
  19259. }
  19260. return nil
  19261. }
  19262. // RemovedEdges returns all edge names that were removed in this mutation.
  19263. func (m *SopTaskMutation) RemovedEdges() []string {
  19264. edges := make([]string, 0, 1)
  19265. if m.removedtask_stages != nil {
  19266. edges = append(edges, soptask.EdgeTaskStages)
  19267. }
  19268. return edges
  19269. }
  19270. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19271. // the given name in this mutation.
  19272. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  19273. switch name {
  19274. case soptask.EdgeTaskStages:
  19275. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  19276. for id := range m.removedtask_stages {
  19277. ids = append(ids, id)
  19278. }
  19279. return ids
  19280. }
  19281. return nil
  19282. }
  19283. // ClearedEdges returns all edge names that were cleared in this mutation.
  19284. func (m *SopTaskMutation) ClearedEdges() []string {
  19285. edges := make([]string, 0, 1)
  19286. if m.clearedtask_stages {
  19287. edges = append(edges, soptask.EdgeTaskStages)
  19288. }
  19289. return edges
  19290. }
  19291. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19292. // was cleared in this mutation.
  19293. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  19294. switch name {
  19295. case soptask.EdgeTaskStages:
  19296. return m.clearedtask_stages
  19297. }
  19298. return false
  19299. }
  19300. // ClearEdge clears the value of the edge with the given name. It returns an error
  19301. // if that edge is not defined in the schema.
  19302. func (m *SopTaskMutation) ClearEdge(name string) error {
  19303. switch name {
  19304. }
  19305. return fmt.Errorf("unknown SopTask unique edge %s", name)
  19306. }
  19307. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19308. // It returns an error if the edge is not defined in the schema.
  19309. func (m *SopTaskMutation) ResetEdge(name string) error {
  19310. switch name {
  19311. case soptask.EdgeTaskStages:
  19312. m.ResetTaskStages()
  19313. return nil
  19314. }
  19315. return fmt.Errorf("unknown SopTask edge %s", name)
  19316. }
  19317. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  19318. type TokenMutation struct {
  19319. config
  19320. op Op
  19321. typ string
  19322. id *uint64
  19323. created_at *time.Time
  19324. updated_at *time.Time
  19325. deleted_at *time.Time
  19326. expire_at *time.Time
  19327. token *string
  19328. mac *string
  19329. clearedFields map[string]struct{}
  19330. done bool
  19331. oldValue func(context.Context) (*Token, error)
  19332. predicates []predicate.Token
  19333. }
  19334. var _ ent.Mutation = (*TokenMutation)(nil)
  19335. // tokenOption allows management of the mutation configuration using functional options.
  19336. type tokenOption func(*TokenMutation)
  19337. // newTokenMutation creates new mutation for the Token entity.
  19338. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  19339. m := &TokenMutation{
  19340. config: c,
  19341. op: op,
  19342. typ: TypeToken,
  19343. clearedFields: make(map[string]struct{}),
  19344. }
  19345. for _, opt := range opts {
  19346. opt(m)
  19347. }
  19348. return m
  19349. }
  19350. // withTokenID sets the ID field of the mutation.
  19351. func withTokenID(id uint64) tokenOption {
  19352. return func(m *TokenMutation) {
  19353. var (
  19354. err error
  19355. once sync.Once
  19356. value *Token
  19357. )
  19358. m.oldValue = func(ctx context.Context) (*Token, error) {
  19359. once.Do(func() {
  19360. if m.done {
  19361. err = errors.New("querying old values post mutation is not allowed")
  19362. } else {
  19363. value, err = m.Client().Token.Get(ctx, id)
  19364. }
  19365. })
  19366. return value, err
  19367. }
  19368. m.id = &id
  19369. }
  19370. }
  19371. // withToken sets the old Token of the mutation.
  19372. func withToken(node *Token) tokenOption {
  19373. return func(m *TokenMutation) {
  19374. m.oldValue = func(context.Context) (*Token, error) {
  19375. return node, nil
  19376. }
  19377. m.id = &node.ID
  19378. }
  19379. }
  19380. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19381. // executed in a transaction (ent.Tx), a transactional client is returned.
  19382. func (m TokenMutation) Client() *Client {
  19383. client := &Client{config: m.config}
  19384. client.init()
  19385. return client
  19386. }
  19387. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19388. // it returns an error otherwise.
  19389. func (m TokenMutation) Tx() (*Tx, error) {
  19390. if _, ok := m.driver.(*txDriver); !ok {
  19391. return nil, errors.New("ent: mutation is not running in a transaction")
  19392. }
  19393. tx := &Tx{config: m.config}
  19394. tx.init()
  19395. return tx, nil
  19396. }
  19397. // SetID sets the value of the id field. Note that this
  19398. // operation is only accepted on creation of Token entities.
  19399. func (m *TokenMutation) SetID(id uint64) {
  19400. m.id = &id
  19401. }
  19402. // ID returns the ID value in the mutation. Note that the ID is only available
  19403. // if it was provided to the builder or after it was returned from the database.
  19404. func (m *TokenMutation) ID() (id uint64, exists bool) {
  19405. if m.id == nil {
  19406. return
  19407. }
  19408. return *m.id, true
  19409. }
  19410. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19411. // That means, if the mutation is applied within a transaction with an isolation level such
  19412. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19413. // or updated by the mutation.
  19414. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  19415. switch {
  19416. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19417. id, exists := m.ID()
  19418. if exists {
  19419. return []uint64{id}, nil
  19420. }
  19421. fallthrough
  19422. case m.op.Is(OpUpdate | OpDelete):
  19423. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  19424. default:
  19425. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19426. }
  19427. }
  19428. // SetCreatedAt sets the "created_at" field.
  19429. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  19430. m.created_at = &t
  19431. }
  19432. // CreatedAt returns the value of the "created_at" field in the mutation.
  19433. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  19434. v := m.created_at
  19435. if v == nil {
  19436. return
  19437. }
  19438. return *v, true
  19439. }
  19440. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  19441. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19443. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19444. if !m.op.Is(OpUpdateOne) {
  19445. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19446. }
  19447. if m.id == nil || m.oldValue == nil {
  19448. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19449. }
  19450. oldValue, err := m.oldValue(ctx)
  19451. if err != nil {
  19452. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19453. }
  19454. return oldValue.CreatedAt, nil
  19455. }
  19456. // ResetCreatedAt resets all changes to the "created_at" field.
  19457. func (m *TokenMutation) ResetCreatedAt() {
  19458. m.created_at = nil
  19459. }
  19460. // SetUpdatedAt sets the "updated_at" field.
  19461. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  19462. m.updated_at = &t
  19463. }
  19464. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19465. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  19466. v := m.updated_at
  19467. if v == nil {
  19468. return
  19469. }
  19470. return *v, true
  19471. }
  19472. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  19473. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19475. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19476. if !m.op.Is(OpUpdateOne) {
  19477. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19478. }
  19479. if m.id == nil || m.oldValue == nil {
  19480. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19481. }
  19482. oldValue, err := m.oldValue(ctx)
  19483. if err != nil {
  19484. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19485. }
  19486. return oldValue.UpdatedAt, nil
  19487. }
  19488. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19489. func (m *TokenMutation) ResetUpdatedAt() {
  19490. m.updated_at = nil
  19491. }
  19492. // SetDeletedAt sets the "deleted_at" field.
  19493. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  19494. m.deleted_at = &t
  19495. }
  19496. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19497. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  19498. v := m.deleted_at
  19499. if v == nil {
  19500. return
  19501. }
  19502. return *v, true
  19503. }
  19504. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  19505. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19507. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19508. if !m.op.Is(OpUpdateOne) {
  19509. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19510. }
  19511. if m.id == nil || m.oldValue == nil {
  19512. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19513. }
  19514. oldValue, err := m.oldValue(ctx)
  19515. if err != nil {
  19516. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19517. }
  19518. return oldValue.DeletedAt, nil
  19519. }
  19520. // ClearDeletedAt clears the value of the "deleted_at" field.
  19521. func (m *TokenMutation) ClearDeletedAt() {
  19522. m.deleted_at = nil
  19523. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  19524. }
  19525. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19526. func (m *TokenMutation) DeletedAtCleared() bool {
  19527. _, ok := m.clearedFields[token.FieldDeletedAt]
  19528. return ok
  19529. }
  19530. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19531. func (m *TokenMutation) ResetDeletedAt() {
  19532. m.deleted_at = nil
  19533. delete(m.clearedFields, token.FieldDeletedAt)
  19534. }
  19535. // SetExpireAt sets the "expire_at" field.
  19536. func (m *TokenMutation) SetExpireAt(t time.Time) {
  19537. m.expire_at = &t
  19538. }
  19539. // ExpireAt returns the value of the "expire_at" field in the mutation.
  19540. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  19541. v := m.expire_at
  19542. if v == nil {
  19543. return
  19544. }
  19545. return *v, true
  19546. }
  19547. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  19548. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19550. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  19551. if !m.op.Is(OpUpdateOne) {
  19552. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  19553. }
  19554. if m.id == nil || m.oldValue == nil {
  19555. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  19556. }
  19557. oldValue, err := m.oldValue(ctx)
  19558. if err != nil {
  19559. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  19560. }
  19561. return oldValue.ExpireAt, nil
  19562. }
  19563. // ClearExpireAt clears the value of the "expire_at" field.
  19564. func (m *TokenMutation) ClearExpireAt() {
  19565. m.expire_at = nil
  19566. m.clearedFields[token.FieldExpireAt] = struct{}{}
  19567. }
  19568. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  19569. func (m *TokenMutation) ExpireAtCleared() bool {
  19570. _, ok := m.clearedFields[token.FieldExpireAt]
  19571. return ok
  19572. }
  19573. // ResetExpireAt resets all changes to the "expire_at" field.
  19574. func (m *TokenMutation) ResetExpireAt() {
  19575. m.expire_at = nil
  19576. delete(m.clearedFields, token.FieldExpireAt)
  19577. }
  19578. // SetToken sets the "token" field.
  19579. func (m *TokenMutation) SetToken(s string) {
  19580. m.token = &s
  19581. }
  19582. // Token returns the value of the "token" field in the mutation.
  19583. func (m *TokenMutation) Token() (r string, exists bool) {
  19584. v := m.token
  19585. if v == nil {
  19586. return
  19587. }
  19588. return *v, true
  19589. }
  19590. // OldToken returns the old "token" field's value of the Token entity.
  19591. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19593. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  19594. if !m.op.Is(OpUpdateOne) {
  19595. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  19596. }
  19597. if m.id == nil || m.oldValue == nil {
  19598. return v, errors.New("OldToken requires an ID field in the mutation")
  19599. }
  19600. oldValue, err := m.oldValue(ctx)
  19601. if err != nil {
  19602. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  19603. }
  19604. return oldValue.Token, nil
  19605. }
  19606. // ClearToken clears the value of the "token" field.
  19607. func (m *TokenMutation) ClearToken() {
  19608. m.token = nil
  19609. m.clearedFields[token.FieldToken] = struct{}{}
  19610. }
  19611. // TokenCleared returns if the "token" field was cleared in this mutation.
  19612. func (m *TokenMutation) TokenCleared() bool {
  19613. _, ok := m.clearedFields[token.FieldToken]
  19614. return ok
  19615. }
  19616. // ResetToken resets all changes to the "token" field.
  19617. func (m *TokenMutation) ResetToken() {
  19618. m.token = nil
  19619. delete(m.clearedFields, token.FieldToken)
  19620. }
  19621. // SetMAC sets the "mac" field.
  19622. func (m *TokenMutation) SetMAC(s string) {
  19623. m.mac = &s
  19624. }
  19625. // MAC returns the value of the "mac" field in the mutation.
  19626. func (m *TokenMutation) MAC() (r string, exists bool) {
  19627. v := m.mac
  19628. if v == nil {
  19629. return
  19630. }
  19631. return *v, true
  19632. }
  19633. // OldMAC returns the old "mac" field's value of the Token entity.
  19634. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19636. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  19637. if !m.op.Is(OpUpdateOne) {
  19638. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  19639. }
  19640. if m.id == nil || m.oldValue == nil {
  19641. return v, errors.New("OldMAC requires an ID field in the mutation")
  19642. }
  19643. oldValue, err := m.oldValue(ctx)
  19644. if err != nil {
  19645. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  19646. }
  19647. return oldValue.MAC, nil
  19648. }
  19649. // ResetMAC resets all changes to the "mac" field.
  19650. func (m *TokenMutation) ResetMAC() {
  19651. m.mac = nil
  19652. }
  19653. // Where appends a list predicates to the TokenMutation builder.
  19654. func (m *TokenMutation) Where(ps ...predicate.Token) {
  19655. m.predicates = append(m.predicates, ps...)
  19656. }
  19657. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  19658. // users can use type-assertion to append predicates that do not depend on any generated package.
  19659. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  19660. p := make([]predicate.Token, len(ps))
  19661. for i := range ps {
  19662. p[i] = ps[i]
  19663. }
  19664. m.Where(p...)
  19665. }
  19666. // Op returns the operation name.
  19667. func (m *TokenMutation) Op() Op {
  19668. return m.op
  19669. }
  19670. // SetOp allows setting the mutation operation.
  19671. func (m *TokenMutation) SetOp(op Op) {
  19672. m.op = op
  19673. }
  19674. // Type returns the node type of this mutation (Token).
  19675. func (m *TokenMutation) Type() string {
  19676. return m.typ
  19677. }
  19678. // Fields returns all fields that were changed during this mutation. Note that in
  19679. // order to get all numeric fields that were incremented/decremented, call
  19680. // AddedFields().
  19681. func (m *TokenMutation) Fields() []string {
  19682. fields := make([]string, 0, 6)
  19683. if m.created_at != nil {
  19684. fields = append(fields, token.FieldCreatedAt)
  19685. }
  19686. if m.updated_at != nil {
  19687. fields = append(fields, token.FieldUpdatedAt)
  19688. }
  19689. if m.deleted_at != nil {
  19690. fields = append(fields, token.FieldDeletedAt)
  19691. }
  19692. if m.expire_at != nil {
  19693. fields = append(fields, token.FieldExpireAt)
  19694. }
  19695. if m.token != nil {
  19696. fields = append(fields, token.FieldToken)
  19697. }
  19698. if m.mac != nil {
  19699. fields = append(fields, token.FieldMAC)
  19700. }
  19701. return fields
  19702. }
  19703. // Field returns the value of a field with the given name. The second boolean
  19704. // return value indicates that this field was not set, or was not defined in the
  19705. // schema.
  19706. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  19707. switch name {
  19708. case token.FieldCreatedAt:
  19709. return m.CreatedAt()
  19710. case token.FieldUpdatedAt:
  19711. return m.UpdatedAt()
  19712. case token.FieldDeletedAt:
  19713. return m.DeletedAt()
  19714. case token.FieldExpireAt:
  19715. return m.ExpireAt()
  19716. case token.FieldToken:
  19717. return m.Token()
  19718. case token.FieldMAC:
  19719. return m.MAC()
  19720. }
  19721. return nil, false
  19722. }
  19723. // OldField returns the old value of the field from the database. An error is
  19724. // returned if the mutation operation is not UpdateOne, or the query to the
  19725. // database failed.
  19726. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19727. switch name {
  19728. case token.FieldCreatedAt:
  19729. return m.OldCreatedAt(ctx)
  19730. case token.FieldUpdatedAt:
  19731. return m.OldUpdatedAt(ctx)
  19732. case token.FieldDeletedAt:
  19733. return m.OldDeletedAt(ctx)
  19734. case token.FieldExpireAt:
  19735. return m.OldExpireAt(ctx)
  19736. case token.FieldToken:
  19737. return m.OldToken(ctx)
  19738. case token.FieldMAC:
  19739. return m.OldMAC(ctx)
  19740. }
  19741. return nil, fmt.Errorf("unknown Token field %s", name)
  19742. }
  19743. // SetField sets the value of a field with the given name. It returns an error if
  19744. // the field is not defined in the schema, or if the type mismatched the field
  19745. // type.
  19746. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  19747. switch name {
  19748. case token.FieldCreatedAt:
  19749. v, ok := value.(time.Time)
  19750. if !ok {
  19751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19752. }
  19753. m.SetCreatedAt(v)
  19754. return nil
  19755. case token.FieldUpdatedAt:
  19756. v, ok := value.(time.Time)
  19757. if !ok {
  19758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19759. }
  19760. m.SetUpdatedAt(v)
  19761. return nil
  19762. case token.FieldDeletedAt:
  19763. v, ok := value.(time.Time)
  19764. if !ok {
  19765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19766. }
  19767. m.SetDeletedAt(v)
  19768. return nil
  19769. case token.FieldExpireAt:
  19770. v, ok := value.(time.Time)
  19771. if !ok {
  19772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19773. }
  19774. m.SetExpireAt(v)
  19775. return nil
  19776. case token.FieldToken:
  19777. v, ok := value.(string)
  19778. if !ok {
  19779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19780. }
  19781. m.SetToken(v)
  19782. return nil
  19783. case token.FieldMAC:
  19784. v, ok := value.(string)
  19785. if !ok {
  19786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19787. }
  19788. m.SetMAC(v)
  19789. return nil
  19790. }
  19791. return fmt.Errorf("unknown Token field %s", name)
  19792. }
  19793. // AddedFields returns all numeric fields that were incremented/decremented during
  19794. // this mutation.
  19795. func (m *TokenMutation) AddedFields() []string {
  19796. return nil
  19797. }
  19798. // AddedField returns the numeric value that was incremented/decremented on a field
  19799. // with the given name. The second boolean return value indicates that this field
  19800. // was not set, or was not defined in the schema.
  19801. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  19802. return nil, false
  19803. }
  19804. // AddField adds the value to the field with the given name. It returns an error if
  19805. // the field is not defined in the schema, or if the type mismatched the field
  19806. // type.
  19807. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  19808. switch name {
  19809. }
  19810. return fmt.Errorf("unknown Token numeric field %s", name)
  19811. }
  19812. // ClearedFields returns all nullable fields that were cleared during this
  19813. // mutation.
  19814. func (m *TokenMutation) ClearedFields() []string {
  19815. var fields []string
  19816. if m.FieldCleared(token.FieldDeletedAt) {
  19817. fields = append(fields, token.FieldDeletedAt)
  19818. }
  19819. if m.FieldCleared(token.FieldExpireAt) {
  19820. fields = append(fields, token.FieldExpireAt)
  19821. }
  19822. if m.FieldCleared(token.FieldToken) {
  19823. fields = append(fields, token.FieldToken)
  19824. }
  19825. return fields
  19826. }
  19827. // FieldCleared returns a boolean indicating if a field with the given name was
  19828. // cleared in this mutation.
  19829. func (m *TokenMutation) FieldCleared(name string) bool {
  19830. _, ok := m.clearedFields[name]
  19831. return ok
  19832. }
  19833. // ClearField clears the value of the field with the given name. It returns an
  19834. // error if the field is not defined in the schema.
  19835. func (m *TokenMutation) ClearField(name string) error {
  19836. switch name {
  19837. case token.FieldDeletedAt:
  19838. m.ClearDeletedAt()
  19839. return nil
  19840. case token.FieldExpireAt:
  19841. m.ClearExpireAt()
  19842. return nil
  19843. case token.FieldToken:
  19844. m.ClearToken()
  19845. return nil
  19846. }
  19847. return fmt.Errorf("unknown Token nullable field %s", name)
  19848. }
  19849. // ResetField resets all changes in the mutation for the field with the given name.
  19850. // It returns an error if the field is not defined in the schema.
  19851. func (m *TokenMutation) ResetField(name string) error {
  19852. switch name {
  19853. case token.FieldCreatedAt:
  19854. m.ResetCreatedAt()
  19855. return nil
  19856. case token.FieldUpdatedAt:
  19857. m.ResetUpdatedAt()
  19858. return nil
  19859. case token.FieldDeletedAt:
  19860. m.ResetDeletedAt()
  19861. return nil
  19862. case token.FieldExpireAt:
  19863. m.ResetExpireAt()
  19864. return nil
  19865. case token.FieldToken:
  19866. m.ResetToken()
  19867. return nil
  19868. case token.FieldMAC:
  19869. m.ResetMAC()
  19870. return nil
  19871. }
  19872. return fmt.Errorf("unknown Token field %s", name)
  19873. }
  19874. // AddedEdges returns all edge names that were set/added in this mutation.
  19875. func (m *TokenMutation) AddedEdges() []string {
  19876. edges := make([]string, 0, 0)
  19877. return edges
  19878. }
  19879. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19880. // name in this mutation.
  19881. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  19882. return nil
  19883. }
  19884. // RemovedEdges returns all edge names that were removed in this mutation.
  19885. func (m *TokenMutation) RemovedEdges() []string {
  19886. edges := make([]string, 0, 0)
  19887. return edges
  19888. }
  19889. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19890. // the given name in this mutation.
  19891. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  19892. return nil
  19893. }
  19894. // ClearedEdges returns all edge names that were cleared in this mutation.
  19895. func (m *TokenMutation) ClearedEdges() []string {
  19896. edges := make([]string, 0, 0)
  19897. return edges
  19898. }
  19899. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19900. // was cleared in this mutation.
  19901. func (m *TokenMutation) EdgeCleared(name string) bool {
  19902. return false
  19903. }
  19904. // ClearEdge clears the value of the edge with the given name. It returns an error
  19905. // if that edge is not defined in the schema.
  19906. func (m *TokenMutation) ClearEdge(name string) error {
  19907. return fmt.Errorf("unknown Token unique edge %s", name)
  19908. }
  19909. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19910. // It returns an error if the edge is not defined in the schema.
  19911. func (m *TokenMutation) ResetEdge(name string) error {
  19912. return fmt.Errorf("unknown Token edge %s", name)
  19913. }
  19914. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  19915. type TutorialMutation struct {
  19916. config
  19917. op Op
  19918. typ string
  19919. id *uint64
  19920. created_at *time.Time
  19921. updated_at *time.Time
  19922. deleted_at *time.Time
  19923. index *int
  19924. addindex *int
  19925. title *string
  19926. content *string
  19927. organization_id *uint64
  19928. addorganization_id *int64
  19929. clearedFields map[string]struct{}
  19930. employee *uint64
  19931. clearedemployee bool
  19932. done bool
  19933. oldValue func(context.Context) (*Tutorial, error)
  19934. predicates []predicate.Tutorial
  19935. }
  19936. var _ ent.Mutation = (*TutorialMutation)(nil)
  19937. // tutorialOption allows management of the mutation configuration using functional options.
  19938. type tutorialOption func(*TutorialMutation)
  19939. // newTutorialMutation creates new mutation for the Tutorial entity.
  19940. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  19941. m := &TutorialMutation{
  19942. config: c,
  19943. op: op,
  19944. typ: TypeTutorial,
  19945. clearedFields: make(map[string]struct{}),
  19946. }
  19947. for _, opt := range opts {
  19948. opt(m)
  19949. }
  19950. return m
  19951. }
  19952. // withTutorialID sets the ID field of the mutation.
  19953. func withTutorialID(id uint64) tutorialOption {
  19954. return func(m *TutorialMutation) {
  19955. var (
  19956. err error
  19957. once sync.Once
  19958. value *Tutorial
  19959. )
  19960. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  19961. once.Do(func() {
  19962. if m.done {
  19963. err = errors.New("querying old values post mutation is not allowed")
  19964. } else {
  19965. value, err = m.Client().Tutorial.Get(ctx, id)
  19966. }
  19967. })
  19968. return value, err
  19969. }
  19970. m.id = &id
  19971. }
  19972. }
  19973. // withTutorial sets the old Tutorial of the mutation.
  19974. func withTutorial(node *Tutorial) tutorialOption {
  19975. return func(m *TutorialMutation) {
  19976. m.oldValue = func(context.Context) (*Tutorial, error) {
  19977. return node, nil
  19978. }
  19979. m.id = &node.ID
  19980. }
  19981. }
  19982. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19983. // executed in a transaction (ent.Tx), a transactional client is returned.
  19984. func (m TutorialMutation) Client() *Client {
  19985. client := &Client{config: m.config}
  19986. client.init()
  19987. return client
  19988. }
  19989. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19990. // it returns an error otherwise.
  19991. func (m TutorialMutation) Tx() (*Tx, error) {
  19992. if _, ok := m.driver.(*txDriver); !ok {
  19993. return nil, errors.New("ent: mutation is not running in a transaction")
  19994. }
  19995. tx := &Tx{config: m.config}
  19996. tx.init()
  19997. return tx, nil
  19998. }
  19999. // SetID sets the value of the id field. Note that this
  20000. // operation is only accepted on creation of Tutorial entities.
  20001. func (m *TutorialMutation) SetID(id uint64) {
  20002. m.id = &id
  20003. }
  20004. // ID returns the ID value in the mutation. Note that the ID is only available
  20005. // if it was provided to the builder or after it was returned from the database.
  20006. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  20007. if m.id == nil {
  20008. return
  20009. }
  20010. return *m.id, true
  20011. }
  20012. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20013. // That means, if the mutation is applied within a transaction with an isolation level such
  20014. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20015. // or updated by the mutation.
  20016. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  20017. switch {
  20018. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20019. id, exists := m.ID()
  20020. if exists {
  20021. return []uint64{id}, nil
  20022. }
  20023. fallthrough
  20024. case m.op.Is(OpUpdate | OpDelete):
  20025. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  20026. default:
  20027. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20028. }
  20029. }
  20030. // SetCreatedAt sets the "created_at" field.
  20031. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  20032. m.created_at = &t
  20033. }
  20034. // CreatedAt returns the value of the "created_at" field in the mutation.
  20035. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  20036. v := m.created_at
  20037. if v == nil {
  20038. return
  20039. }
  20040. return *v, true
  20041. }
  20042. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  20043. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20045. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20046. if !m.op.Is(OpUpdateOne) {
  20047. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20048. }
  20049. if m.id == nil || m.oldValue == nil {
  20050. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20051. }
  20052. oldValue, err := m.oldValue(ctx)
  20053. if err != nil {
  20054. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20055. }
  20056. return oldValue.CreatedAt, nil
  20057. }
  20058. // ResetCreatedAt resets all changes to the "created_at" field.
  20059. func (m *TutorialMutation) ResetCreatedAt() {
  20060. m.created_at = nil
  20061. }
  20062. // SetUpdatedAt sets the "updated_at" field.
  20063. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  20064. m.updated_at = &t
  20065. }
  20066. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20067. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  20068. v := m.updated_at
  20069. if v == nil {
  20070. return
  20071. }
  20072. return *v, true
  20073. }
  20074. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  20075. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20077. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20078. if !m.op.Is(OpUpdateOne) {
  20079. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20080. }
  20081. if m.id == nil || m.oldValue == nil {
  20082. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20083. }
  20084. oldValue, err := m.oldValue(ctx)
  20085. if err != nil {
  20086. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20087. }
  20088. return oldValue.UpdatedAt, nil
  20089. }
  20090. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20091. func (m *TutorialMutation) ResetUpdatedAt() {
  20092. m.updated_at = nil
  20093. }
  20094. // SetDeletedAt sets the "deleted_at" field.
  20095. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  20096. m.deleted_at = &t
  20097. }
  20098. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20099. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  20100. v := m.deleted_at
  20101. if v == nil {
  20102. return
  20103. }
  20104. return *v, true
  20105. }
  20106. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  20107. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20109. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20110. if !m.op.Is(OpUpdateOne) {
  20111. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20112. }
  20113. if m.id == nil || m.oldValue == nil {
  20114. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20115. }
  20116. oldValue, err := m.oldValue(ctx)
  20117. if err != nil {
  20118. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20119. }
  20120. return oldValue.DeletedAt, nil
  20121. }
  20122. // ClearDeletedAt clears the value of the "deleted_at" field.
  20123. func (m *TutorialMutation) ClearDeletedAt() {
  20124. m.deleted_at = nil
  20125. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  20126. }
  20127. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20128. func (m *TutorialMutation) DeletedAtCleared() bool {
  20129. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  20130. return ok
  20131. }
  20132. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20133. func (m *TutorialMutation) ResetDeletedAt() {
  20134. m.deleted_at = nil
  20135. delete(m.clearedFields, tutorial.FieldDeletedAt)
  20136. }
  20137. // SetEmployeeID sets the "employee_id" field.
  20138. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  20139. m.employee = &u
  20140. }
  20141. // EmployeeID returns the value of the "employee_id" field in the mutation.
  20142. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  20143. v := m.employee
  20144. if v == nil {
  20145. return
  20146. }
  20147. return *v, true
  20148. }
  20149. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  20150. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20152. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  20153. if !m.op.Is(OpUpdateOne) {
  20154. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  20155. }
  20156. if m.id == nil || m.oldValue == nil {
  20157. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  20158. }
  20159. oldValue, err := m.oldValue(ctx)
  20160. if err != nil {
  20161. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  20162. }
  20163. return oldValue.EmployeeID, nil
  20164. }
  20165. // ResetEmployeeID resets all changes to the "employee_id" field.
  20166. func (m *TutorialMutation) ResetEmployeeID() {
  20167. m.employee = nil
  20168. }
  20169. // SetIndex sets the "index" field.
  20170. func (m *TutorialMutation) SetIndex(i int) {
  20171. m.index = &i
  20172. m.addindex = nil
  20173. }
  20174. // Index returns the value of the "index" field in the mutation.
  20175. func (m *TutorialMutation) Index() (r int, exists bool) {
  20176. v := m.index
  20177. if v == nil {
  20178. return
  20179. }
  20180. return *v, true
  20181. }
  20182. // OldIndex returns the old "index" field's value of the Tutorial entity.
  20183. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20185. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  20186. if !m.op.Is(OpUpdateOne) {
  20187. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  20188. }
  20189. if m.id == nil || m.oldValue == nil {
  20190. return v, errors.New("OldIndex requires an ID field in the mutation")
  20191. }
  20192. oldValue, err := m.oldValue(ctx)
  20193. if err != nil {
  20194. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  20195. }
  20196. return oldValue.Index, nil
  20197. }
  20198. // AddIndex adds i to the "index" field.
  20199. func (m *TutorialMutation) AddIndex(i int) {
  20200. if m.addindex != nil {
  20201. *m.addindex += i
  20202. } else {
  20203. m.addindex = &i
  20204. }
  20205. }
  20206. // AddedIndex returns the value that was added to the "index" field in this mutation.
  20207. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  20208. v := m.addindex
  20209. if v == nil {
  20210. return
  20211. }
  20212. return *v, true
  20213. }
  20214. // ResetIndex resets all changes to the "index" field.
  20215. func (m *TutorialMutation) ResetIndex() {
  20216. m.index = nil
  20217. m.addindex = nil
  20218. }
  20219. // SetTitle sets the "title" field.
  20220. func (m *TutorialMutation) SetTitle(s string) {
  20221. m.title = &s
  20222. }
  20223. // Title returns the value of the "title" field in the mutation.
  20224. func (m *TutorialMutation) Title() (r string, exists bool) {
  20225. v := m.title
  20226. if v == nil {
  20227. return
  20228. }
  20229. return *v, true
  20230. }
  20231. // OldTitle returns the old "title" field's value of the Tutorial entity.
  20232. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20234. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  20235. if !m.op.Is(OpUpdateOne) {
  20236. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  20237. }
  20238. if m.id == nil || m.oldValue == nil {
  20239. return v, errors.New("OldTitle requires an ID field in the mutation")
  20240. }
  20241. oldValue, err := m.oldValue(ctx)
  20242. if err != nil {
  20243. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  20244. }
  20245. return oldValue.Title, nil
  20246. }
  20247. // ResetTitle resets all changes to the "title" field.
  20248. func (m *TutorialMutation) ResetTitle() {
  20249. m.title = nil
  20250. }
  20251. // SetContent sets the "content" field.
  20252. func (m *TutorialMutation) SetContent(s string) {
  20253. m.content = &s
  20254. }
  20255. // Content returns the value of the "content" field in the mutation.
  20256. func (m *TutorialMutation) Content() (r string, exists bool) {
  20257. v := m.content
  20258. if v == nil {
  20259. return
  20260. }
  20261. return *v, true
  20262. }
  20263. // OldContent returns the old "content" field's value of the Tutorial entity.
  20264. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20266. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  20267. if !m.op.Is(OpUpdateOne) {
  20268. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  20269. }
  20270. if m.id == nil || m.oldValue == nil {
  20271. return v, errors.New("OldContent requires an ID field in the mutation")
  20272. }
  20273. oldValue, err := m.oldValue(ctx)
  20274. if err != nil {
  20275. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  20276. }
  20277. return oldValue.Content, nil
  20278. }
  20279. // ResetContent resets all changes to the "content" field.
  20280. func (m *TutorialMutation) ResetContent() {
  20281. m.content = nil
  20282. }
  20283. // SetOrganizationID sets the "organization_id" field.
  20284. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  20285. m.organization_id = &u
  20286. m.addorganization_id = nil
  20287. }
  20288. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20289. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  20290. v := m.organization_id
  20291. if v == nil {
  20292. return
  20293. }
  20294. return *v, true
  20295. }
  20296. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  20297. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20299. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20300. if !m.op.Is(OpUpdateOne) {
  20301. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20302. }
  20303. if m.id == nil || m.oldValue == nil {
  20304. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20305. }
  20306. oldValue, err := m.oldValue(ctx)
  20307. if err != nil {
  20308. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20309. }
  20310. return oldValue.OrganizationID, nil
  20311. }
  20312. // AddOrganizationID adds u to the "organization_id" field.
  20313. func (m *TutorialMutation) AddOrganizationID(u int64) {
  20314. if m.addorganization_id != nil {
  20315. *m.addorganization_id += u
  20316. } else {
  20317. m.addorganization_id = &u
  20318. }
  20319. }
  20320. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20321. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  20322. v := m.addorganization_id
  20323. if v == nil {
  20324. return
  20325. }
  20326. return *v, true
  20327. }
  20328. // ResetOrganizationID resets all changes to the "organization_id" field.
  20329. func (m *TutorialMutation) ResetOrganizationID() {
  20330. m.organization_id = nil
  20331. m.addorganization_id = nil
  20332. }
  20333. // ClearEmployee clears the "employee" edge to the Employee entity.
  20334. func (m *TutorialMutation) ClearEmployee() {
  20335. m.clearedemployee = true
  20336. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  20337. }
  20338. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  20339. func (m *TutorialMutation) EmployeeCleared() bool {
  20340. return m.clearedemployee
  20341. }
  20342. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  20343. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20344. // EmployeeID instead. It exists only for internal usage by the builders.
  20345. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  20346. if id := m.employee; id != nil {
  20347. ids = append(ids, *id)
  20348. }
  20349. return
  20350. }
  20351. // ResetEmployee resets all changes to the "employee" edge.
  20352. func (m *TutorialMutation) ResetEmployee() {
  20353. m.employee = nil
  20354. m.clearedemployee = false
  20355. }
  20356. // Where appends a list predicates to the TutorialMutation builder.
  20357. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  20358. m.predicates = append(m.predicates, ps...)
  20359. }
  20360. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  20361. // users can use type-assertion to append predicates that do not depend on any generated package.
  20362. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  20363. p := make([]predicate.Tutorial, len(ps))
  20364. for i := range ps {
  20365. p[i] = ps[i]
  20366. }
  20367. m.Where(p...)
  20368. }
  20369. // Op returns the operation name.
  20370. func (m *TutorialMutation) Op() Op {
  20371. return m.op
  20372. }
  20373. // SetOp allows setting the mutation operation.
  20374. func (m *TutorialMutation) SetOp(op Op) {
  20375. m.op = op
  20376. }
  20377. // Type returns the node type of this mutation (Tutorial).
  20378. func (m *TutorialMutation) Type() string {
  20379. return m.typ
  20380. }
  20381. // Fields returns all fields that were changed during this mutation. Note that in
  20382. // order to get all numeric fields that were incremented/decremented, call
  20383. // AddedFields().
  20384. func (m *TutorialMutation) Fields() []string {
  20385. fields := make([]string, 0, 8)
  20386. if m.created_at != nil {
  20387. fields = append(fields, tutorial.FieldCreatedAt)
  20388. }
  20389. if m.updated_at != nil {
  20390. fields = append(fields, tutorial.FieldUpdatedAt)
  20391. }
  20392. if m.deleted_at != nil {
  20393. fields = append(fields, tutorial.FieldDeletedAt)
  20394. }
  20395. if m.employee != nil {
  20396. fields = append(fields, tutorial.FieldEmployeeID)
  20397. }
  20398. if m.index != nil {
  20399. fields = append(fields, tutorial.FieldIndex)
  20400. }
  20401. if m.title != nil {
  20402. fields = append(fields, tutorial.FieldTitle)
  20403. }
  20404. if m.content != nil {
  20405. fields = append(fields, tutorial.FieldContent)
  20406. }
  20407. if m.organization_id != nil {
  20408. fields = append(fields, tutorial.FieldOrganizationID)
  20409. }
  20410. return fields
  20411. }
  20412. // Field returns the value of a field with the given name. The second boolean
  20413. // return value indicates that this field was not set, or was not defined in the
  20414. // schema.
  20415. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  20416. switch name {
  20417. case tutorial.FieldCreatedAt:
  20418. return m.CreatedAt()
  20419. case tutorial.FieldUpdatedAt:
  20420. return m.UpdatedAt()
  20421. case tutorial.FieldDeletedAt:
  20422. return m.DeletedAt()
  20423. case tutorial.FieldEmployeeID:
  20424. return m.EmployeeID()
  20425. case tutorial.FieldIndex:
  20426. return m.Index()
  20427. case tutorial.FieldTitle:
  20428. return m.Title()
  20429. case tutorial.FieldContent:
  20430. return m.Content()
  20431. case tutorial.FieldOrganizationID:
  20432. return m.OrganizationID()
  20433. }
  20434. return nil, false
  20435. }
  20436. // OldField returns the old value of the field from the database. An error is
  20437. // returned if the mutation operation is not UpdateOne, or the query to the
  20438. // database failed.
  20439. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20440. switch name {
  20441. case tutorial.FieldCreatedAt:
  20442. return m.OldCreatedAt(ctx)
  20443. case tutorial.FieldUpdatedAt:
  20444. return m.OldUpdatedAt(ctx)
  20445. case tutorial.FieldDeletedAt:
  20446. return m.OldDeletedAt(ctx)
  20447. case tutorial.FieldEmployeeID:
  20448. return m.OldEmployeeID(ctx)
  20449. case tutorial.FieldIndex:
  20450. return m.OldIndex(ctx)
  20451. case tutorial.FieldTitle:
  20452. return m.OldTitle(ctx)
  20453. case tutorial.FieldContent:
  20454. return m.OldContent(ctx)
  20455. case tutorial.FieldOrganizationID:
  20456. return m.OldOrganizationID(ctx)
  20457. }
  20458. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  20459. }
  20460. // SetField sets the value of a field with the given name. It returns an error if
  20461. // the field is not defined in the schema, or if the type mismatched the field
  20462. // type.
  20463. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  20464. switch name {
  20465. case tutorial.FieldCreatedAt:
  20466. v, ok := value.(time.Time)
  20467. if !ok {
  20468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20469. }
  20470. m.SetCreatedAt(v)
  20471. return nil
  20472. case tutorial.FieldUpdatedAt:
  20473. v, ok := value.(time.Time)
  20474. if !ok {
  20475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20476. }
  20477. m.SetUpdatedAt(v)
  20478. return nil
  20479. case tutorial.FieldDeletedAt:
  20480. v, ok := value.(time.Time)
  20481. if !ok {
  20482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20483. }
  20484. m.SetDeletedAt(v)
  20485. return nil
  20486. case tutorial.FieldEmployeeID:
  20487. v, ok := value.(uint64)
  20488. if !ok {
  20489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20490. }
  20491. m.SetEmployeeID(v)
  20492. return nil
  20493. case tutorial.FieldIndex:
  20494. v, ok := value.(int)
  20495. if !ok {
  20496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20497. }
  20498. m.SetIndex(v)
  20499. return nil
  20500. case tutorial.FieldTitle:
  20501. v, ok := value.(string)
  20502. if !ok {
  20503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20504. }
  20505. m.SetTitle(v)
  20506. return nil
  20507. case tutorial.FieldContent:
  20508. v, ok := value.(string)
  20509. if !ok {
  20510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20511. }
  20512. m.SetContent(v)
  20513. return nil
  20514. case tutorial.FieldOrganizationID:
  20515. v, ok := value.(uint64)
  20516. if !ok {
  20517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20518. }
  20519. m.SetOrganizationID(v)
  20520. return nil
  20521. }
  20522. return fmt.Errorf("unknown Tutorial field %s", name)
  20523. }
  20524. // AddedFields returns all numeric fields that were incremented/decremented during
  20525. // this mutation.
  20526. func (m *TutorialMutation) AddedFields() []string {
  20527. var fields []string
  20528. if m.addindex != nil {
  20529. fields = append(fields, tutorial.FieldIndex)
  20530. }
  20531. if m.addorganization_id != nil {
  20532. fields = append(fields, tutorial.FieldOrganizationID)
  20533. }
  20534. return fields
  20535. }
  20536. // AddedField returns the numeric value that was incremented/decremented on a field
  20537. // with the given name. The second boolean return value indicates that this field
  20538. // was not set, or was not defined in the schema.
  20539. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  20540. switch name {
  20541. case tutorial.FieldIndex:
  20542. return m.AddedIndex()
  20543. case tutorial.FieldOrganizationID:
  20544. return m.AddedOrganizationID()
  20545. }
  20546. return nil, false
  20547. }
  20548. // AddField adds the value to the field with the given name. It returns an error if
  20549. // the field is not defined in the schema, or if the type mismatched the field
  20550. // type.
  20551. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  20552. switch name {
  20553. case tutorial.FieldIndex:
  20554. v, ok := value.(int)
  20555. if !ok {
  20556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20557. }
  20558. m.AddIndex(v)
  20559. return nil
  20560. case tutorial.FieldOrganizationID:
  20561. v, ok := value.(int64)
  20562. if !ok {
  20563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20564. }
  20565. m.AddOrganizationID(v)
  20566. return nil
  20567. }
  20568. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  20569. }
  20570. // ClearedFields returns all nullable fields that were cleared during this
  20571. // mutation.
  20572. func (m *TutorialMutation) ClearedFields() []string {
  20573. var fields []string
  20574. if m.FieldCleared(tutorial.FieldDeletedAt) {
  20575. fields = append(fields, tutorial.FieldDeletedAt)
  20576. }
  20577. return fields
  20578. }
  20579. // FieldCleared returns a boolean indicating if a field with the given name was
  20580. // cleared in this mutation.
  20581. func (m *TutorialMutation) FieldCleared(name string) bool {
  20582. _, ok := m.clearedFields[name]
  20583. return ok
  20584. }
  20585. // ClearField clears the value of the field with the given name. It returns an
  20586. // error if the field is not defined in the schema.
  20587. func (m *TutorialMutation) ClearField(name string) error {
  20588. switch name {
  20589. case tutorial.FieldDeletedAt:
  20590. m.ClearDeletedAt()
  20591. return nil
  20592. }
  20593. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  20594. }
  20595. // ResetField resets all changes in the mutation for the field with the given name.
  20596. // It returns an error if the field is not defined in the schema.
  20597. func (m *TutorialMutation) ResetField(name string) error {
  20598. switch name {
  20599. case tutorial.FieldCreatedAt:
  20600. m.ResetCreatedAt()
  20601. return nil
  20602. case tutorial.FieldUpdatedAt:
  20603. m.ResetUpdatedAt()
  20604. return nil
  20605. case tutorial.FieldDeletedAt:
  20606. m.ResetDeletedAt()
  20607. return nil
  20608. case tutorial.FieldEmployeeID:
  20609. m.ResetEmployeeID()
  20610. return nil
  20611. case tutorial.FieldIndex:
  20612. m.ResetIndex()
  20613. return nil
  20614. case tutorial.FieldTitle:
  20615. m.ResetTitle()
  20616. return nil
  20617. case tutorial.FieldContent:
  20618. m.ResetContent()
  20619. return nil
  20620. case tutorial.FieldOrganizationID:
  20621. m.ResetOrganizationID()
  20622. return nil
  20623. }
  20624. return fmt.Errorf("unknown Tutorial field %s", name)
  20625. }
  20626. // AddedEdges returns all edge names that were set/added in this mutation.
  20627. func (m *TutorialMutation) AddedEdges() []string {
  20628. edges := make([]string, 0, 1)
  20629. if m.employee != nil {
  20630. edges = append(edges, tutorial.EdgeEmployee)
  20631. }
  20632. return edges
  20633. }
  20634. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20635. // name in this mutation.
  20636. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  20637. switch name {
  20638. case tutorial.EdgeEmployee:
  20639. if id := m.employee; id != nil {
  20640. return []ent.Value{*id}
  20641. }
  20642. }
  20643. return nil
  20644. }
  20645. // RemovedEdges returns all edge names that were removed in this mutation.
  20646. func (m *TutorialMutation) RemovedEdges() []string {
  20647. edges := make([]string, 0, 1)
  20648. return edges
  20649. }
  20650. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20651. // the given name in this mutation.
  20652. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  20653. return nil
  20654. }
  20655. // ClearedEdges returns all edge names that were cleared in this mutation.
  20656. func (m *TutorialMutation) ClearedEdges() []string {
  20657. edges := make([]string, 0, 1)
  20658. if m.clearedemployee {
  20659. edges = append(edges, tutorial.EdgeEmployee)
  20660. }
  20661. return edges
  20662. }
  20663. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20664. // was cleared in this mutation.
  20665. func (m *TutorialMutation) EdgeCleared(name string) bool {
  20666. switch name {
  20667. case tutorial.EdgeEmployee:
  20668. return m.clearedemployee
  20669. }
  20670. return false
  20671. }
  20672. // ClearEdge clears the value of the edge with the given name. It returns an error
  20673. // if that edge is not defined in the schema.
  20674. func (m *TutorialMutation) ClearEdge(name string) error {
  20675. switch name {
  20676. case tutorial.EdgeEmployee:
  20677. m.ClearEmployee()
  20678. return nil
  20679. }
  20680. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  20681. }
  20682. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20683. // It returns an error if the edge is not defined in the schema.
  20684. func (m *TutorialMutation) ResetEdge(name string) error {
  20685. switch name {
  20686. case tutorial.EdgeEmployee:
  20687. m.ResetEmployee()
  20688. return nil
  20689. }
  20690. return fmt.Errorf("unknown Tutorial edge %s", name)
  20691. }
  20692. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  20693. type WorkExperienceMutation struct {
  20694. config
  20695. op Op
  20696. typ string
  20697. id *uint64
  20698. created_at *time.Time
  20699. updated_at *time.Time
  20700. deleted_at *time.Time
  20701. start_date *time.Time
  20702. end_date *time.Time
  20703. company *string
  20704. experience *string
  20705. organization_id *uint64
  20706. addorganization_id *int64
  20707. clearedFields map[string]struct{}
  20708. employee *uint64
  20709. clearedemployee bool
  20710. done bool
  20711. oldValue func(context.Context) (*WorkExperience, error)
  20712. predicates []predicate.WorkExperience
  20713. }
  20714. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  20715. // workexperienceOption allows management of the mutation configuration using functional options.
  20716. type workexperienceOption func(*WorkExperienceMutation)
  20717. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  20718. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  20719. m := &WorkExperienceMutation{
  20720. config: c,
  20721. op: op,
  20722. typ: TypeWorkExperience,
  20723. clearedFields: make(map[string]struct{}),
  20724. }
  20725. for _, opt := range opts {
  20726. opt(m)
  20727. }
  20728. return m
  20729. }
  20730. // withWorkExperienceID sets the ID field of the mutation.
  20731. func withWorkExperienceID(id uint64) workexperienceOption {
  20732. return func(m *WorkExperienceMutation) {
  20733. var (
  20734. err error
  20735. once sync.Once
  20736. value *WorkExperience
  20737. )
  20738. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  20739. once.Do(func() {
  20740. if m.done {
  20741. err = errors.New("querying old values post mutation is not allowed")
  20742. } else {
  20743. value, err = m.Client().WorkExperience.Get(ctx, id)
  20744. }
  20745. })
  20746. return value, err
  20747. }
  20748. m.id = &id
  20749. }
  20750. }
  20751. // withWorkExperience sets the old WorkExperience of the mutation.
  20752. func withWorkExperience(node *WorkExperience) workexperienceOption {
  20753. return func(m *WorkExperienceMutation) {
  20754. m.oldValue = func(context.Context) (*WorkExperience, error) {
  20755. return node, nil
  20756. }
  20757. m.id = &node.ID
  20758. }
  20759. }
  20760. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20761. // executed in a transaction (ent.Tx), a transactional client is returned.
  20762. func (m WorkExperienceMutation) Client() *Client {
  20763. client := &Client{config: m.config}
  20764. client.init()
  20765. return client
  20766. }
  20767. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20768. // it returns an error otherwise.
  20769. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  20770. if _, ok := m.driver.(*txDriver); !ok {
  20771. return nil, errors.New("ent: mutation is not running in a transaction")
  20772. }
  20773. tx := &Tx{config: m.config}
  20774. tx.init()
  20775. return tx, nil
  20776. }
  20777. // SetID sets the value of the id field. Note that this
  20778. // operation is only accepted on creation of WorkExperience entities.
  20779. func (m *WorkExperienceMutation) SetID(id uint64) {
  20780. m.id = &id
  20781. }
  20782. // ID returns the ID value in the mutation. Note that the ID is only available
  20783. // if it was provided to the builder or after it was returned from the database.
  20784. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  20785. if m.id == nil {
  20786. return
  20787. }
  20788. return *m.id, true
  20789. }
  20790. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20791. // That means, if the mutation is applied within a transaction with an isolation level such
  20792. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20793. // or updated by the mutation.
  20794. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  20795. switch {
  20796. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20797. id, exists := m.ID()
  20798. if exists {
  20799. return []uint64{id}, nil
  20800. }
  20801. fallthrough
  20802. case m.op.Is(OpUpdate | OpDelete):
  20803. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  20804. default:
  20805. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20806. }
  20807. }
  20808. // SetCreatedAt sets the "created_at" field.
  20809. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  20810. m.created_at = &t
  20811. }
  20812. // CreatedAt returns the value of the "created_at" field in the mutation.
  20813. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  20814. v := m.created_at
  20815. if v == nil {
  20816. return
  20817. }
  20818. return *v, true
  20819. }
  20820. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  20821. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20823. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20824. if !m.op.Is(OpUpdateOne) {
  20825. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20826. }
  20827. if m.id == nil || m.oldValue == nil {
  20828. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20829. }
  20830. oldValue, err := m.oldValue(ctx)
  20831. if err != nil {
  20832. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20833. }
  20834. return oldValue.CreatedAt, nil
  20835. }
  20836. // ResetCreatedAt resets all changes to the "created_at" field.
  20837. func (m *WorkExperienceMutation) ResetCreatedAt() {
  20838. m.created_at = nil
  20839. }
  20840. // SetUpdatedAt sets the "updated_at" field.
  20841. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  20842. m.updated_at = &t
  20843. }
  20844. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20845. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  20846. v := m.updated_at
  20847. if v == nil {
  20848. return
  20849. }
  20850. return *v, true
  20851. }
  20852. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  20853. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20855. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20856. if !m.op.Is(OpUpdateOne) {
  20857. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20858. }
  20859. if m.id == nil || m.oldValue == nil {
  20860. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20861. }
  20862. oldValue, err := m.oldValue(ctx)
  20863. if err != nil {
  20864. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20865. }
  20866. return oldValue.UpdatedAt, nil
  20867. }
  20868. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20869. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  20870. m.updated_at = nil
  20871. }
  20872. // SetDeletedAt sets the "deleted_at" field.
  20873. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  20874. m.deleted_at = &t
  20875. }
  20876. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20877. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  20878. v := m.deleted_at
  20879. if v == nil {
  20880. return
  20881. }
  20882. return *v, true
  20883. }
  20884. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  20885. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20887. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20888. if !m.op.Is(OpUpdateOne) {
  20889. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20890. }
  20891. if m.id == nil || m.oldValue == nil {
  20892. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20893. }
  20894. oldValue, err := m.oldValue(ctx)
  20895. if err != nil {
  20896. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20897. }
  20898. return oldValue.DeletedAt, nil
  20899. }
  20900. // ClearDeletedAt clears the value of the "deleted_at" field.
  20901. func (m *WorkExperienceMutation) ClearDeletedAt() {
  20902. m.deleted_at = nil
  20903. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  20904. }
  20905. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20906. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  20907. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  20908. return ok
  20909. }
  20910. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20911. func (m *WorkExperienceMutation) ResetDeletedAt() {
  20912. m.deleted_at = nil
  20913. delete(m.clearedFields, workexperience.FieldDeletedAt)
  20914. }
  20915. // SetEmployeeID sets the "employee_id" field.
  20916. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  20917. m.employee = &u
  20918. }
  20919. // EmployeeID returns the value of the "employee_id" field in the mutation.
  20920. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  20921. v := m.employee
  20922. if v == nil {
  20923. return
  20924. }
  20925. return *v, true
  20926. }
  20927. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  20928. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20930. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  20931. if !m.op.Is(OpUpdateOne) {
  20932. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  20933. }
  20934. if m.id == nil || m.oldValue == nil {
  20935. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  20936. }
  20937. oldValue, err := m.oldValue(ctx)
  20938. if err != nil {
  20939. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  20940. }
  20941. return oldValue.EmployeeID, nil
  20942. }
  20943. // ResetEmployeeID resets all changes to the "employee_id" field.
  20944. func (m *WorkExperienceMutation) ResetEmployeeID() {
  20945. m.employee = nil
  20946. }
  20947. // SetStartDate sets the "start_date" field.
  20948. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  20949. m.start_date = &t
  20950. }
  20951. // StartDate returns the value of the "start_date" field in the mutation.
  20952. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  20953. v := m.start_date
  20954. if v == nil {
  20955. return
  20956. }
  20957. return *v, true
  20958. }
  20959. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  20960. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20962. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  20963. if !m.op.Is(OpUpdateOne) {
  20964. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  20965. }
  20966. if m.id == nil || m.oldValue == nil {
  20967. return v, errors.New("OldStartDate requires an ID field in the mutation")
  20968. }
  20969. oldValue, err := m.oldValue(ctx)
  20970. if err != nil {
  20971. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  20972. }
  20973. return oldValue.StartDate, nil
  20974. }
  20975. // ResetStartDate resets all changes to the "start_date" field.
  20976. func (m *WorkExperienceMutation) ResetStartDate() {
  20977. m.start_date = nil
  20978. }
  20979. // SetEndDate sets the "end_date" field.
  20980. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  20981. m.end_date = &t
  20982. }
  20983. // EndDate returns the value of the "end_date" field in the mutation.
  20984. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  20985. v := m.end_date
  20986. if v == nil {
  20987. return
  20988. }
  20989. return *v, true
  20990. }
  20991. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  20992. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20994. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  20995. if !m.op.Is(OpUpdateOne) {
  20996. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  20997. }
  20998. if m.id == nil || m.oldValue == nil {
  20999. return v, errors.New("OldEndDate requires an ID field in the mutation")
  21000. }
  21001. oldValue, err := m.oldValue(ctx)
  21002. if err != nil {
  21003. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  21004. }
  21005. return oldValue.EndDate, nil
  21006. }
  21007. // ResetEndDate resets all changes to the "end_date" field.
  21008. func (m *WorkExperienceMutation) ResetEndDate() {
  21009. m.end_date = nil
  21010. }
  21011. // SetCompany sets the "company" field.
  21012. func (m *WorkExperienceMutation) SetCompany(s string) {
  21013. m.company = &s
  21014. }
  21015. // Company returns the value of the "company" field in the mutation.
  21016. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  21017. v := m.company
  21018. if v == nil {
  21019. return
  21020. }
  21021. return *v, true
  21022. }
  21023. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  21024. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  21025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21026. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  21027. if !m.op.Is(OpUpdateOne) {
  21028. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  21029. }
  21030. if m.id == nil || m.oldValue == nil {
  21031. return v, errors.New("OldCompany requires an ID field in the mutation")
  21032. }
  21033. oldValue, err := m.oldValue(ctx)
  21034. if err != nil {
  21035. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  21036. }
  21037. return oldValue.Company, nil
  21038. }
  21039. // ResetCompany resets all changes to the "company" field.
  21040. func (m *WorkExperienceMutation) ResetCompany() {
  21041. m.company = nil
  21042. }
  21043. // SetExperience sets the "experience" field.
  21044. func (m *WorkExperienceMutation) SetExperience(s string) {
  21045. m.experience = &s
  21046. }
  21047. // Experience returns the value of the "experience" field in the mutation.
  21048. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  21049. v := m.experience
  21050. if v == nil {
  21051. return
  21052. }
  21053. return *v, true
  21054. }
  21055. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  21056. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  21057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21058. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  21059. if !m.op.Is(OpUpdateOne) {
  21060. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  21061. }
  21062. if m.id == nil || m.oldValue == nil {
  21063. return v, errors.New("OldExperience requires an ID field in the mutation")
  21064. }
  21065. oldValue, err := m.oldValue(ctx)
  21066. if err != nil {
  21067. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  21068. }
  21069. return oldValue.Experience, nil
  21070. }
  21071. // ResetExperience resets all changes to the "experience" field.
  21072. func (m *WorkExperienceMutation) ResetExperience() {
  21073. m.experience = nil
  21074. }
  21075. // SetOrganizationID sets the "organization_id" field.
  21076. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  21077. m.organization_id = &u
  21078. m.addorganization_id = nil
  21079. }
  21080. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21081. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  21082. v := m.organization_id
  21083. if v == nil {
  21084. return
  21085. }
  21086. return *v, true
  21087. }
  21088. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  21089. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  21090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21091. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21092. if !m.op.Is(OpUpdateOne) {
  21093. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21094. }
  21095. if m.id == nil || m.oldValue == nil {
  21096. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21097. }
  21098. oldValue, err := m.oldValue(ctx)
  21099. if err != nil {
  21100. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21101. }
  21102. return oldValue.OrganizationID, nil
  21103. }
  21104. // AddOrganizationID adds u to the "organization_id" field.
  21105. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  21106. if m.addorganization_id != nil {
  21107. *m.addorganization_id += u
  21108. } else {
  21109. m.addorganization_id = &u
  21110. }
  21111. }
  21112. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21113. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  21114. v := m.addorganization_id
  21115. if v == nil {
  21116. return
  21117. }
  21118. return *v, true
  21119. }
  21120. // ResetOrganizationID resets all changes to the "organization_id" field.
  21121. func (m *WorkExperienceMutation) ResetOrganizationID() {
  21122. m.organization_id = nil
  21123. m.addorganization_id = nil
  21124. }
  21125. // ClearEmployee clears the "employee" edge to the Employee entity.
  21126. func (m *WorkExperienceMutation) ClearEmployee() {
  21127. m.clearedemployee = true
  21128. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  21129. }
  21130. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  21131. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  21132. return m.clearedemployee
  21133. }
  21134. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  21135. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21136. // EmployeeID instead. It exists only for internal usage by the builders.
  21137. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  21138. if id := m.employee; id != nil {
  21139. ids = append(ids, *id)
  21140. }
  21141. return
  21142. }
  21143. // ResetEmployee resets all changes to the "employee" edge.
  21144. func (m *WorkExperienceMutation) ResetEmployee() {
  21145. m.employee = nil
  21146. m.clearedemployee = false
  21147. }
  21148. // Where appends a list predicates to the WorkExperienceMutation builder.
  21149. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  21150. m.predicates = append(m.predicates, ps...)
  21151. }
  21152. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  21153. // users can use type-assertion to append predicates that do not depend on any generated package.
  21154. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  21155. p := make([]predicate.WorkExperience, len(ps))
  21156. for i := range ps {
  21157. p[i] = ps[i]
  21158. }
  21159. m.Where(p...)
  21160. }
  21161. // Op returns the operation name.
  21162. func (m *WorkExperienceMutation) Op() Op {
  21163. return m.op
  21164. }
  21165. // SetOp allows setting the mutation operation.
  21166. func (m *WorkExperienceMutation) SetOp(op Op) {
  21167. m.op = op
  21168. }
  21169. // Type returns the node type of this mutation (WorkExperience).
  21170. func (m *WorkExperienceMutation) Type() string {
  21171. return m.typ
  21172. }
  21173. // Fields returns all fields that were changed during this mutation. Note that in
  21174. // order to get all numeric fields that were incremented/decremented, call
  21175. // AddedFields().
  21176. func (m *WorkExperienceMutation) Fields() []string {
  21177. fields := make([]string, 0, 9)
  21178. if m.created_at != nil {
  21179. fields = append(fields, workexperience.FieldCreatedAt)
  21180. }
  21181. if m.updated_at != nil {
  21182. fields = append(fields, workexperience.FieldUpdatedAt)
  21183. }
  21184. if m.deleted_at != nil {
  21185. fields = append(fields, workexperience.FieldDeletedAt)
  21186. }
  21187. if m.employee != nil {
  21188. fields = append(fields, workexperience.FieldEmployeeID)
  21189. }
  21190. if m.start_date != nil {
  21191. fields = append(fields, workexperience.FieldStartDate)
  21192. }
  21193. if m.end_date != nil {
  21194. fields = append(fields, workexperience.FieldEndDate)
  21195. }
  21196. if m.company != nil {
  21197. fields = append(fields, workexperience.FieldCompany)
  21198. }
  21199. if m.experience != nil {
  21200. fields = append(fields, workexperience.FieldExperience)
  21201. }
  21202. if m.organization_id != nil {
  21203. fields = append(fields, workexperience.FieldOrganizationID)
  21204. }
  21205. return fields
  21206. }
  21207. // Field returns the value of a field with the given name. The second boolean
  21208. // return value indicates that this field was not set, or was not defined in the
  21209. // schema.
  21210. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  21211. switch name {
  21212. case workexperience.FieldCreatedAt:
  21213. return m.CreatedAt()
  21214. case workexperience.FieldUpdatedAt:
  21215. return m.UpdatedAt()
  21216. case workexperience.FieldDeletedAt:
  21217. return m.DeletedAt()
  21218. case workexperience.FieldEmployeeID:
  21219. return m.EmployeeID()
  21220. case workexperience.FieldStartDate:
  21221. return m.StartDate()
  21222. case workexperience.FieldEndDate:
  21223. return m.EndDate()
  21224. case workexperience.FieldCompany:
  21225. return m.Company()
  21226. case workexperience.FieldExperience:
  21227. return m.Experience()
  21228. case workexperience.FieldOrganizationID:
  21229. return m.OrganizationID()
  21230. }
  21231. return nil, false
  21232. }
  21233. // OldField returns the old value of the field from the database. An error is
  21234. // returned if the mutation operation is not UpdateOne, or the query to the
  21235. // database failed.
  21236. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21237. switch name {
  21238. case workexperience.FieldCreatedAt:
  21239. return m.OldCreatedAt(ctx)
  21240. case workexperience.FieldUpdatedAt:
  21241. return m.OldUpdatedAt(ctx)
  21242. case workexperience.FieldDeletedAt:
  21243. return m.OldDeletedAt(ctx)
  21244. case workexperience.FieldEmployeeID:
  21245. return m.OldEmployeeID(ctx)
  21246. case workexperience.FieldStartDate:
  21247. return m.OldStartDate(ctx)
  21248. case workexperience.FieldEndDate:
  21249. return m.OldEndDate(ctx)
  21250. case workexperience.FieldCompany:
  21251. return m.OldCompany(ctx)
  21252. case workexperience.FieldExperience:
  21253. return m.OldExperience(ctx)
  21254. case workexperience.FieldOrganizationID:
  21255. return m.OldOrganizationID(ctx)
  21256. }
  21257. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  21258. }
  21259. // SetField sets the value of a field with the given name. It returns an error if
  21260. // the field is not defined in the schema, or if the type mismatched the field
  21261. // type.
  21262. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  21263. switch name {
  21264. case workexperience.FieldCreatedAt:
  21265. v, ok := value.(time.Time)
  21266. if !ok {
  21267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21268. }
  21269. m.SetCreatedAt(v)
  21270. return nil
  21271. case workexperience.FieldUpdatedAt:
  21272. v, ok := value.(time.Time)
  21273. if !ok {
  21274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21275. }
  21276. m.SetUpdatedAt(v)
  21277. return nil
  21278. case workexperience.FieldDeletedAt:
  21279. v, ok := value.(time.Time)
  21280. if !ok {
  21281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21282. }
  21283. m.SetDeletedAt(v)
  21284. return nil
  21285. case workexperience.FieldEmployeeID:
  21286. v, ok := value.(uint64)
  21287. if !ok {
  21288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21289. }
  21290. m.SetEmployeeID(v)
  21291. return nil
  21292. case workexperience.FieldStartDate:
  21293. v, ok := value.(time.Time)
  21294. if !ok {
  21295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21296. }
  21297. m.SetStartDate(v)
  21298. return nil
  21299. case workexperience.FieldEndDate:
  21300. v, ok := value.(time.Time)
  21301. if !ok {
  21302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21303. }
  21304. m.SetEndDate(v)
  21305. return nil
  21306. case workexperience.FieldCompany:
  21307. v, ok := value.(string)
  21308. if !ok {
  21309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21310. }
  21311. m.SetCompany(v)
  21312. return nil
  21313. case workexperience.FieldExperience:
  21314. v, ok := value.(string)
  21315. if !ok {
  21316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21317. }
  21318. m.SetExperience(v)
  21319. return nil
  21320. case workexperience.FieldOrganizationID:
  21321. v, ok := value.(uint64)
  21322. if !ok {
  21323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21324. }
  21325. m.SetOrganizationID(v)
  21326. return nil
  21327. }
  21328. return fmt.Errorf("unknown WorkExperience field %s", name)
  21329. }
  21330. // AddedFields returns all numeric fields that were incremented/decremented during
  21331. // this mutation.
  21332. func (m *WorkExperienceMutation) AddedFields() []string {
  21333. var fields []string
  21334. if m.addorganization_id != nil {
  21335. fields = append(fields, workexperience.FieldOrganizationID)
  21336. }
  21337. return fields
  21338. }
  21339. // AddedField returns the numeric value that was incremented/decremented on a field
  21340. // with the given name. The second boolean return value indicates that this field
  21341. // was not set, or was not defined in the schema.
  21342. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  21343. switch name {
  21344. case workexperience.FieldOrganizationID:
  21345. return m.AddedOrganizationID()
  21346. }
  21347. return nil, false
  21348. }
  21349. // AddField adds the value to the field with the given name. It returns an error if
  21350. // the field is not defined in the schema, or if the type mismatched the field
  21351. // type.
  21352. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  21353. switch name {
  21354. case workexperience.FieldOrganizationID:
  21355. v, ok := value.(int64)
  21356. if !ok {
  21357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21358. }
  21359. m.AddOrganizationID(v)
  21360. return nil
  21361. }
  21362. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  21363. }
  21364. // ClearedFields returns all nullable fields that were cleared during this
  21365. // mutation.
  21366. func (m *WorkExperienceMutation) ClearedFields() []string {
  21367. var fields []string
  21368. if m.FieldCleared(workexperience.FieldDeletedAt) {
  21369. fields = append(fields, workexperience.FieldDeletedAt)
  21370. }
  21371. return fields
  21372. }
  21373. // FieldCleared returns a boolean indicating if a field with the given name was
  21374. // cleared in this mutation.
  21375. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  21376. _, ok := m.clearedFields[name]
  21377. return ok
  21378. }
  21379. // ClearField clears the value of the field with the given name. It returns an
  21380. // error if the field is not defined in the schema.
  21381. func (m *WorkExperienceMutation) ClearField(name string) error {
  21382. switch name {
  21383. case workexperience.FieldDeletedAt:
  21384. m.ClearDeletedAt()
  21385. return nil
  21386. }
  21387. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  21388. }
  21389. // ResetField resets all changes in the mutation for the field with the given name.
  21390. // It returns an error if the field is not defined in the schema.
  21391. func (m *WorkExperienceMutation) ResetField(name string) error {
  21392. switch name {
  21393. case workexperience.FieldCreatedAt:
  21394. m.ResetCreatedAt()
  21395. return nil
  21396. case workexperience.FieldUpdatedAt:
  21397. m.ResetUpdatedAt()
  21398. return nil
  21399. case workexperience.FieldDeletedAt:
  21400. m.ResetDeletedAt()
  21401. return nil
  21402. case workexperience.FieldEmployeeID:
  21403. m.ResetEmployeeID()
  21404. return nil
  21405. case workexperience.FieldStartDate:
  21406. m.ResetStartDate()
  21407. return nil
  21408. case workexperience.FieldEndDate:
  21409. m.ResetEndDate()
  21410. return nil
  21411. case workexperience.FieldCompany:
  21412. m.ResetCompany()
  21413. return nil
  21414. case workexperience.FieldExperience:
  21415. m.ResetExperience()
  21416. return nil
  21417. case workexperience.FieldOrganizationID:
  21418. m.ResetOrganizationID()
  21419. return nil
  21420. }
  21421. return fmt.Errorf("unknown WorkExperience field %s", name)
  21422. }
  21423. // AddedEdges returns all edge names that were set/added in this mutation.
  21424. func (m *WorkExperienceMutation) AddedEdges() []string {
  21425. edges := make([]string, 0, 1)
  21426. if m.employee != nil {
  21427. edges = append(edges, workexperience.EdgeEmployee)
  21428. }
  21429. return edges
  21430. }
  21431. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21432. // name in this mutation.
  21433. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  21434. switch name {
  21435. case workexperience.EdgeEmployee:
  21436. if id := m.employee; id != nil {
  21437. return []ent.Value{*id}
  21438. }
  21439. }
  21440. return nil
  21441. }
  21442. // RemovedEdges returns all edge names that were removed in this mutation.
  21443. func (m *WorkExperienceMutation) RemovedEdges() []string {
  21444. edges := make([]string, 0, 1)
  21445. return edges
  21446. }
  21447. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21448. // the given name in this mutation.
  21449. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  21450. return nil
  21451. }
  21452. // ClearedEdges returns all edge names that were cleared in this mutation.
  21453. func (m *WorkExperienceMutation) ClearedEdges() []string {
  21454. edges := make([]string, 0, 1)
  21455. if m.clearedemployee {
  21456. edges = append(edges, workexperience.EdgeEmployee)
  21457. }
  21458. return edges
  21459. }
  21460. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21461. // was cleared in this mutation.
  21462. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  21463. switch name {
  21464. case workexperience.EdgeEmployee:
  21465. return m.clearedemployee
  21466. }
  21467. return false
  21468. }
  21469. // ClearEdge clears the value of the edge with the given name. It returns an error
  21470. // if that edge is not defined in the schema.
  21471. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  21472. switch name {
  21473. case workexperience.EdgeEmployee:
  21474. m.ClearEmployee()
  21475. return nil
  21476. }
  21477. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  21478. }
  21479. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21480. // It returns an error if the edge is not defined in the schema.
  21481. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  21482. switch name {
  21483. case workexperience.EdgeEmployee:
  21484. m.ResetEmployee()
  21485. return nil
  21486. }
  21487. return fmt.Errorf("unknown WorkExperience edge %s", name)
  21488. }
  21489. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  21490. type WxMutation struct {
  21491. config
  21492. op Op
  21493. typ string
  21494. id *uint64
  21495. created_at *time.Time
  21496. updated_at *time.Time
  21497. status *uint8
  21498. addstatus *int8
  21499. deleted_at *time.Time
  21500. port *string
  21501. process_id *string
  21502. callback *string
  21503. wxid *string
  21504. account *string
  21505. nickname *string
  21506. tel *string
  21507. head_big *string
  21508. organization_id *uint64
  21509. addorganization_id *int64
  21510. api_base *string
  21511. api_key *string
  21512. allow_list *[]string
  21513. appendallow_list []string
  21514. group_allow_list *[]string
  21515. appendgroup_allow_list []string
  21516. block_list *[]string
  21517. appendblock_list []string
  21518. group_block_list *[]string
  21519. appendgroup_block_list []string
  21520. clearedFields map[string]struct{}
  21521. server *uint64
  21522. clearedserver bool
  21523. agent *uint64
  21524. clearedagent bool
  21525. done bool
  21526. oldValue func(context.Context) (*Wx, error)
  21527. predicates []predicate.Wx
  21528. }
  21529. var _ ent.Mutation = (*WxMutation)(nil)
  21530. // wxOption allows management of the mutation configuration using functional options.
  21531. type wxOption func(*WxMutation)
  21532. // newWxMutation creates new mutation for the Wx entity.
  21533. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  21534. m := &WxMutation{
  21535. config: c,
  21536. op: op,
  21537. typ: TypeWx,
  21538. clearedFields: make(map[string]struct{}),
  21539. }
  21540. for _, opt := range opts {
  21541. opt(m)
  21542. }
  21543. return m
  21544. }
  21545. // withWxID sets the ID field of the mutation.
  21546. func withWxID(id uint64) wxOption {
  21547. return func(m *WxMutation) {
  21548. var (
  21549. err error
  21550. once sync.Once
  21551. value *Wx
  21552. )
  21553. m.oldValue = func(ctx context.Context) (*Wx, error) {
  21554. once.Do(func() {
  21555. if m.done {
  21556. err = errors.New("querying old values post mutation is not allowed")
  21557. } else {
  21558. value, err = m.Client().Wx.Get(ctx, id)
  21559. }
  21560. })
  21561. return value, err
  21562. }
  21563. m.id = &id
  21564. }
  21565. }
  21566. // withWx sets the old Wx of the mutation.
  21567. func withWx(node *Wx) wxOption {
  21568. return func(m *WxMutation) {
  21569. m.oldValue = func(context.Context) (*Wx, error) {
  21570. return node, nil
  21571. }
  21572. m.id = &node.ID
  21573. }
  21574. }
  21575. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21576. // executed in a transaction (ent.Tx), a transactional client is returned.
  21577. func (m WxMutation) Client() *Client {
  21578. client := &Client{config: m.config}
  21579. client.init()
  21580. return client
  21581. }
  21582. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21583. // it returns an error otherwise.
  21584. func (m WxMutation) Tx() (*Tx, error) {
  21585. if _, ok := m.driver.(*txDriver); !ok {
  21586. return nil, errors.New("ent: mutation is not running in a transaction")
  21587. }
  21588. tx := &Tx{config: m.config}
  21589. tx.init()
  21590. return tx, nil
  21591. }
  21592. // SetID sets the value of the id field. Note that this
  21593. // operation is only accepted on creation of Wx entities.
  21594. func (m *WxMutation) SetID(id uint64) {
  21595. m.id = &id
  21596. }
  21597. // ID returns the ID value in the mutation. Note that the ID is only available
  21598. // if it was provided to the builder or after it was returned from the database.
  21599. func (m *WxMutation) ID() (id uint64, exists bool) {
  21600. if m.id == nil {
  21601. return
  21602. }
  21603. return *m.id, true
  21604. }
  21605. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21606. // That means, if the mutation is applied within a transaction with an isolation level such
  21607. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21608. // or updated by the mutation.
  21609. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  21610. switch {
  21611. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21612. id, exists := m.ID()
  21613. if exists {
  21614. return []uint64{id}, nil
  21615. }
  21616. fallthrough
  21617. case m.op.Is(OpUpdate | OpDelete):
  21618. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  21619. default:
  21620. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21621. }
  21622. }
  21623. // SetCreatedAt sets the "created_at" field.
  21624. func (m *WxMutation) SetCreatedAt(t time.Time) {
  21625. m.created_at = &t
  21626. }
  21627. // CreatedAt returns the value of the "created_at" field in the mutation.
  21628. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  21629. v := m.created_at
  21630. if v == nil {
  21631. return
  21632. }
  21633. return *v, true
  21634. }
  21635. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  21636. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21638. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21639. if !m.op.Is(OpUpdateOne) {
  21640. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21641. }
  21642. if m.id == nil || m.oldValue == nil {
  21643. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21644. }
  21645. oldValue, err := m.oldValue(ctx)
  21646. if err != nil {
  21647. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21648. }
  21649. return oldValue.CreatedAt, nil
  21650. }
  21651. // ResetCreatedAt resets all changes to the "created_at" field.
  21652. func (m *WxMutation) ResetCreatedAt() {
  21653. m.created_at = nil
  21654. }
  21655. // SetUpdatedAt sets the "updated_at" field.
  21656. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  21657. m.updated_at = &t
  21658. }
  21659. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21660. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  21661. v := m.updated_at
  21662. if v == nil {
  21663. return
  21664. }
  21665. return *v, true
  21666. }
  21667. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  21668. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21670. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21671. if !m.op.Is(OpUpdateOne) {
  21672. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21673. }
  21674. if m.id == nil || m.oldValue == nil {
  21675. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21676. }
  21677. oldValue, err := m.oldValue(ctx)
  21678. if err != nil {
  21679. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21680. }
  21681. return oldValue.UpdatedAt, nil
  21682. }
  21683. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21684. func (m *WxMutation) ResetUpdatedAt() {
  21685. m.updated_at = nil
  21686. }
  21687. // SetStatus sets the "status" field.
  21688. func (m *WxMutation) SetStatus(u uint8) {
  21689. m.status = &u
  21690. m.addstatus = nil
  21691. }
  21692. // Status returns the value of the "status" field in the mutation.
  21693. func (m *WxMutation) Status() (r uint8, exists bool) {
  21694. v := m.status
  21695. if v == nil {
  21696. return
  21697. }
  21698. return *v, true
  21699. }
  21700. // OldStatus returns the old "status" field's value of the Wx entity.
  21701. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21703. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21704. if !m.op.Is(OpUpdateOne) {
  21705. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21706. }
  21707. if m.id == nil || m.oldValue == nil {
  21708. return v, errors.New("OldStatus requires an ID field in the mutation")
  21709. }
  21710. oldValue, err := m.oldValue(ctx)
  21711. if err != nil {
  21712. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21713. }
  21714. return oldValue.Status, nil
  21715. }
  21716. // AddStatus adds u to the "status" field.
  21717. func (m *WxMutation) AddStatus(u int8) {
  21718. if m.addstatus != nil {
  21719. *m.addstatus += u
  21720. } else {
  21721. m.addstatus = &u
  21722. }
  21723. }
  21724. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21725. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  21726. v := m.addstatus
  21727. if v == nil {
  21728. return
  21729. }
  21730. return *v, true
  21731. }
  21732. // ClearStatus clears the value of the "status" field.
  21733. func (m *WxMutation) ClearStatus() {
  21734. m.status = nil
  21735. m.addstatus = nil
  21736. m.clearedFields[wx.FieldStatus] = struct{}{}
  21737. }
  21738. // StatusCleared returns if the "status" field was cleared in this mutation.
  21739. func (m *WxMutation) StatusCleared() bool {
  21740. _, ok := m.clearedFields[wx.FieldStatus]
  21741. return ok
  21742. }
  21743. // ResetStatus resets all changes to the "status" field.
  21744. func (m *WxMutation) ResetStatus() {
  21745. m.status = nil
  21746. m.addstatus = nil
  21747. delete(m.clearedFields, wx.FieldStatus)
  21748. }
  21749. // SetDeletedAt sets the "deleted_at" field.
  21750. func (m *WxMutation) SetDeletedAt(t time.Time) {
  21751. m.deleted_at = &t
  21752. }
  21753. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21754. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  21755. v := m.deleted_at
  21756. if v == nil {
  21757. return
  21758. }
  21759. return *v, true
  21760. }
  21761. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  21762. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21764. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21765. if !m.op.Is(OpUpdateOne) {
  21766. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21767. }
  21768. if m.id == nil || m.oldValue == nil {
  21769. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21770. }
  21771. oldValue, err := m.oldValue(ctx)
  21772. if err != nil {
  21773. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21774. }
  21775. return oldValue.DeletedAt, nil
  21776. }
  21777. // ClearDeletedAt clears the value of the "deleted_at" field.
  21778. func (m *WxMutation) ClearDeletedAt() {
  21779. m.deleted_at = nil
  21780. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  21781. }
  21782. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21783. func (m *WxMutation) DeletedAtCleared() bool {
  21784. _, ok := m.clearedFields[wx.FieldDeletedAt]
  21785. return ok
  21786. }
  21787. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21788. func (m *WxMutation) ResetDeletedAt() {
  21789. m.deleted_at = nil
  21790. delete(m.clearedFields, wx.FieldDeletedAt)
  21791. }
  21792. // SetServerID sets the "server_id" field.
  21793. func (m *WxMutation) SetServerID(u uint64) {
  21794. m.server = &u
  21795. }
  21796. // ServerID returns the value of the "server_id" field in the mutation.
  21797. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  21798. v := m.server
  21799. if v == nil {
  21800. return
  21801. }
  21802. return *v, true
  21803. }
  21804. // OldServerID returns the old "server_id" field's value of the Wx entity.
  21805. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21807. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  21808. if !m.op.Is(OpUpdateOne) {
  21809. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  21810. }
  21811. if m.id == nil || m.oldValue == nil {
  21812. return v, errors.New("OldServerID requires an ID field in the mutation")
  21813. }
  21814. oldValue, err := m.oldValue(ctx)
  21815. if err != nil {
  21816. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  21817. }
  21818. return oldValue.ServerID, nil
  21819. }
  21820. // ClearServerID clears the value of the "server_id" field.
  21821. func (m *WxMutation) ClearServerID() {
  21822. m.server = nil
  21823. m.clearedFields[wx.FieldServerID] = struct{}{}
  21824. }
  21825. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  21826. func (m *WxMutation) ServerIDCleared() bool {
  21827. _, ok := m.clearedFields[wx.FieldServerID]
  21828. return ok
  21829. }
  21830. // ResetServerID resets all changes to the "server_id" field.
  21831. func (m *WxMutation) ResetServerID() {
  21832. m.server = nil
  21833. delete(m.clearedFields, wx.FieldServerID)
  21834. }
  21835. // SetPort sets the "port" field.
  21836. func (m *WxMutation) SetPort(s string) {
  21837. m.port = &s
  21838. }
  21839. // Port returns the value of the "port" field in the mutation.
  21840. func (m *WxMutation) Port() (r string, exists bool) {
  21841. v := m.port
  21842. if v == nil {
  21843. return
  21844. }
  21845. return *v, true
  21846. }
  21847. // OldPort returns the old "port" field's value of the Wx entity.
  21848. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21850. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  21851. if !m.op.Is(OpUpdateOne) {
  21852. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  21853. }
  21854. if m.id == nil || m.oldValue == nil {
  21855. return v, errors.New("OldPort requires an ID field in the mutation")
  21856. }
  21857. oldValue, err := m.oldValue(ctx)
  21858. if err != nil {
  21859. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  21860. }
  21861. return oldValue.Port, nil
  21862. }
  21863. // ResetPort resets all changes to the "port" field.
  21864. func (m *WxMutation) ResetPort() {
  21865. m.port = nil
  21866. }
  21867. // SetProcessID sets the "process_id" field.
  21868. func (m *WxMutation) SetProcessID(s string) {
  21869. m.process_id = &s
  21870. }
  21871. // ProcessID returns the value of the "process_id" field in the mutation.
  21872. func (m *WxMutation) ProcessID() (r string, exists bool) {
  21873. v := m.process_id
  21874. if v == nil {
  21875. return
  21876. }
  21877. return *v, true
  21878. }
  21879. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  21880. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21882. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  21883. if !m.op.Is(OpUpdateOne) {
  21884. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  21885. }
  21886. if m.id == nil || m.oldValue == nil {
  21887. return v, errors.New("OldProcessID requires an ID field in the mutation")
  21888. }
  21889. oldValue, err := m.oldValue(ctx)
  21890. if err != nil {
  21891. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  21892. }
  21893. return oldValue.ProcessID, nil
  21894. }
  21895. // ResetProcessID resets all changes to the "process_id" field.
  21896. func (m *WxMutation) ResetProcessID() {
  21897. m.process_id = nil
  21898. }
  21899. // SetCallback sets the "callback" field.
  21900. func (m *WxMutation) SetCallback(s string) {
  21901. m.callback = &s
  21902. }
  21903. // Callback returns the value of the "callback" field in the mutation.
  21904. func (m *WxMutation) Callback() (r string, exists bool) {
  21905. v := m.callback
  21906. if v == nil {
  21907. return
  21908. }
  21909. return *v, true
  21910. }
  21911. // OldCallback returns the old "callback" field's value of the Wx entity.
  21912. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21914. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  21915. if !m.op.Is(OpUpdateOne) {
  21916. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  21917. }
  21918. if m.id == nil || m.oldValue == nil {
  21919. return v, errors.New("OldCallback requires an ID field in the mutation")
  21920. }
  21921. oldValue, err := m.oldValue(ctx)
  21922. if err != nil {
  21923. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  21924. }
  21925. return oldValue.Callback, nil
  21926. }
  21927. // ResetCallback resets all changes to the "callback" field.
  21928. func (m *WxMutation) ResetCallback() {
  21929. m.callback = nil
  21930. }
  21931. // SetWxid sets the "wxid" field.
  21932. func (m *WxMutation) SetWxid(s string) {
  21933. m.wxid = &s
  21934. }
  21935. // Wxid returns the value of the "wxid" field in the mutation.
  21936. func (m *WxMutation) Wxid() (r string, exists bool) {
  21937. v := m.wxid
  21938. if v == nil {
  21939. return
  21940. }
  21941. return *v, true
  21942. }
  21943. // OldWxid returns the old "wxid" field's value of the Wx entity.
  21944. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21946. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  21947. if !m.op.Is(OpUpdateOne) {
  21948. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  21949. }
  21950. if m.id == nil || m.oldValue == nil {
  21951. return v, errors.New("OldWxid requires an ID field in the mutation")
  21952. }
  21953. oldValue, err := m.oldValue(ctx)
  21954. if err != nil {
  21955. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  21956. }
  21957. return oldValue.Wxid, nil
  21958. }
  21959. // ResetWxid resets all changes to the "wxid" field.
  21960. func (m *WxMutation) ResetWxid() {
  21961. m.wxid = nil
  21962. }
  21963. // SetAccount sets the "account" field.
  21964. func (m *WxMutation) SetAccount(s string) {
  21965. m.account = &s
  21966. }
  21967. // Account returns the value of the "account" field in the mutation.
  21968. func (m *WxMutation) Account() (r string, exists bool) {
  21969. v := m.account
  21970. if v == nil {
  21971. return
  21972. }
  21973. return *v, true
  21974. }
  21975. // OldAccount returns the old "account" field's value of the Wx entity.
  21976. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21978. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  21979. if !m.op.Is(OpUpdateOne) {
  21980. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  21981. }
  21982. if m.id == nil || m.oldValue == nil {
  21983. return v, errors.New("OldAccount requires an ID field in the mutation")
  21984. }
  21985. oldValue, err := m.oldValue(ctx)
  21986. if err != nil {
  21987. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  21988. }
  21989. return oldValue.Account, nil
  21990. }
  21991. // ResetAccount resets all changes to the "account" field.
  21992. func (m *WxMutation) ResetAccount() {
  21993. m.account = nil
  21994. }
  21995. // SetNickname sets the "nickname" field.
  21996. func (m *WxMutation) SetNickname(s string) {
  21997. m.nickname = &s
  21998. }
  21999. // Nickname returns the value of the "nickname" field in the mutation.
  22000. func (m *WxMutation) Nickname() (r string, exists bool) {
  22001. v := m.nickname
  22002. if v == nil {
  22003. return
  22004. }
  22005. return *v, true
  22006. }
  22007. // OldNickname returns the old "nickname" field's value of the Wx entity.
  22008. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22010. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  22011. if !m.op.Is(OpUpdateOne) {
  22012. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  22013. }
  22014. if m.id == nil || m.oldValue == nil {
  22015. return v, errors.New("OldNickname requires an ID field in the mutation")
  22016. }
  22017. oldValue, err := m.oldValue(ctx)
  22018. if err != nil {
  22019. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  22020. }
  22021. return oldValue.Nickname, nil
  22022. }
  22023. // ResetNickname resets all changes to the "nickname" field.
  22024. func (m *WxMutation) ResetNickname() {
  22025. m.nickname = nil
  22026. }
  22027. // SetTel sets the "tel" field.
  22028. func (m *WxMutation) SetTel(s string) {
  22029. m.tel = &s
  22030. }
  22031. // Tel returns the value of the "tel" field in the mutation.
  22032. func (m *WxMutation) Tel() (r string, exists bool) {
  22033. v := m.tel
  22034. if v == nil {
  22035. return
  22036. }
  22037. return *v, true
  22038. }
  22039. // OldTel returns the old "tel" field's value of the Wx entity.
  22040. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22042. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  22043. if !m.op.Is(OpUpdateOne) {
  22044. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  22045. }
  22046. if m.id == nil || m.oldValue == nil {
  22047. return v, errors.New("OldTel requires an ID field in the mutation")
  22048. }
  22049. oldValue, err := m.oldValue(ctx)
  22050. if err != nil {
  22051. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  22052. }
  22053. return oldValue.Tel, nil
  22054. }
  22055. // ResetTel resets all changes to the "tel" field.
  22056. func (m *WxMutation) ResetTel() {
  22057. m.tel = nil
  22058. }
  22059. // SetHeadBig sets the "head_big" field.
  22060. func (m *WxMutation) SetHeadBig(s string) {
  22061. m.head_big = &s
  22062. }
  22063. // HeadBig returns the value of the "head_big" field in the mutation.
  22064. func (m *WxMutation) HeadBig() (r string, exists bool) {
  22065. v := m.head_big
  22066. if v == nil {
  22067. return
  22068. }
  22069. return *v, true
  22070. }
  22071. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  22072. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22074. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  22075. if !m.op.Is(OpUpdateOne) {
  22076. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  22077. }
  22078. if m.id == nil || m.oldValue == nil {
  22079. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  22080. }
  22081. oldValue, err := m.oldValue(ctx)
  22082. if err != nil {
  22083. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  22084. }
  22085. return oldValue.HeadBig, nil
  22086. }
  22087. // ResetHeadBig resets all changes to the "head_big" field.
  22088. func (m *WxMutation) ResetHeadBig() {
  22089. m.head_big = nil
  22090. }
  22091. // SetOrganizationID sets the "organization_id" field.
  22092. func (m *WxMutation) SetOrganizationID(u uint64) {
  22093. m.organization_id = &u
  22094. m.addorganization_id = nil
  22095. }
  22096. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22097. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  22098. v := m.organization_id
  22099. if v == nil {
  22100. return
  22101. }
  22102. return *v, true
  22103. }
  22104. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  22105. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22107. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22108. if !m.op.Is(OpUpdateOne) {
  22109. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22110. }
  22111. if m.id == nil || m.oldValue == nil {
  22112. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22113. }
  22114. oldValue, err := m.oldValue(ctx)
  22115. if err != nil {
  22116. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22117. }
  22118. return oldValue.OrganizationID, nil
  22119. }
  22120. // AddOrganizationID adds u to the "organization_id" field.
  22121. func (m *WxMutation) AddOrganizationID(u int64) {
  22122. if m.addorganization_id != nil {
  22123. *m.addorganization_id += u
  22124. } else {
  22125. m.addorganization_id = &u
  22126. }
  22127. }
  22128. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22129. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  22130. v := m.addorganization_id
  22131. if v == nil {
  22132. return
  22133. }
  22134. return *v, true
  22135. }
  22136. // ClearOrganizationID clears the value of the "organization_id" field.
  22137. func (m *WxMutation) ClearOrganizationID() {
  22138. m.organization_id = nil
  22139. m.addorganization_id = nil
  22140. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  22141. }
  22142. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  22143. func (m *WxMutation) OrganizationIDCleared() bool {
  22144. _, ok := m.clearedFields[wx.FieldOrganizationID]
  22145. return ok
  22146. }
  22147. // ResetOrganizationID resets all changes to the "organization_id" field.
  22148. func (m *WxMutation) ResetOrganizationID() {
  22149. m.organization_id = nil
  22150. m.addorganization_id = nil
  22151. delete(m.clearedFields, wx.FieldOrganizationID)
  22152. }
  22153. // SetAgentID sets the "agent_id" field.
  22154. func (m *WxMutation) SetAgentID(u uint64) {
  22155. m.agent = &u
  22156. }
  22157. // AgentID returns the value of the "agent_id" field in the mutation.
  22158. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  22159. v := m.agent
  22160. if v == nil {
  22161. return
  22162. }
  22163. return *v, true
  22164. }
  22165. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  22166. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22168. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  22169. if !m.op.Is(OpUpdateOne) {
  22170. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  22171. }
  22172. if m.id == nil || m.oldValue == nil {
  22173. return v, errors.New("OldAgentID requires an ID field in the mutation")
  22174. }
  22175. oldValue, err := m.oldValue(ctx)
  22176. if err != nil {
  22177. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  22178. }
  22179. return oldValue.AgentID, nil
  22180. }
  22181. // ResetAgentID resets all changes to the "agent_id" field.
  22182. func (m *WxMutation) ResetAgentID() {
  22183. m.agent = nil
  22184. }
  22185. // SetAPIBase sets the "api_base" field.
  22186. func (m *WxMutation) SetAPIBase(s string) {
  22187. m.api_base = &s
  22188. }
  22189. // APIBase returns the value of the "api_base" field in the mutation.
  22190. func (m *WxMutation) APIBase() (r string, exists bool) {
  22191. v := m.api_base
  22192. if v == nil {
  22193. return
  22194. }
  22195. return *v, true
  22196. }
  22197. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  22198. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22200. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  22201. if !m.op.Is(OpUpdateOne) {
  22202. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  22203. }
  22204. if m.id == nil || m.oldValue == nil {
  22205. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  22206. }
  22207. oldValue, err := m.oldValue(ctx)
  22208. if err != nil {
  22209. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  22210. }
  22211. return oldValue.APIBase, nil
  22212. }
  22213. // ClearAPIBase clears the value of the "api_base" field.
  22214. func (m *WxMutation) ClearAPIBase() {
  22215. m.api_base = nil
  22216. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  22217. }
  22218. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  22219. func (m *WxMutation) APIBaseCleared() bool {
  22220. _, ok := m.clearedFields[wx.FieldAPIBase]
  22221. return ok
  22222. }
  22223. // ResetAPIBase resets all changes to the "api_base" field.
  22224. func (m *WxMutation) ResetAPIBase() {
  22225. m.api_base = nil
  22226. delete(m.clearedFields, wx.FieldAPIBase)
  22227. }
  22228. // SetAPIKey sets the "api_key" field.
  22229. func (m *WxMutation) SetAPIKey(s string) {
  22230. m.api_key = &s
  22231. }
  22232. // APIKey returns the value of the "api_key" field in the mutation.
  22233. func (m *WxMutation) APIKey() (r string, exists bool) {
  22234. v := m.api_key
  22235. if v == nil {
  22236. return
  22237. }
  22238. return *v, true
  22239. }
  22240. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  22241. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22243. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  22244. if !m.op.Is(OpUpdateOne) {
  22245. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  22246. }
  22247. if m.id == nil || m.oldValue == nil {
  22248. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  22249. }
  22250. oldValue, err := m.oldValue(ctx)
  22251. if err != nil {
  22252. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  22253. }
  22254. return oldValue.APIKey, nil
  22255. }
  22256. // ClearAPIKey clears the value of the "api_key" field.
  22257. func (m *WxMutation) ClearAPIKey() {
  22258. m.api_key = nil
  22259. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  22260. }
  22261. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  22262. func (m *WxMutation) APIKeyCleared() bool {
  22263. _, ok := m.clearedFields[wx.FieldAPIKey]
  22264. return ok
  22265. }
  22266. // ResetAPIKey resets all changes to the "api_key" field.
  22267. func (m *WxMutation) ResetAPIKey() {
  22268. m.api_key = nil
  22269. delete(m.clearedFields, wx.FieldAPIKey)
  22270. }
  22271. // SetAllowList sets the "allow_list" field.
  22272. func (m *WxMutation) SetAllowList(s []string) {
  22273. m.allow_list = &s
  22274. m.appendallow_list = nil
  22275. }
  22276. // AllowList returns the value of the "allow_list" field in the mutation.
  22277. func (m *WxMutation) AllowList() (r []string, exists bool) {
  22278. v := m.allow_list
  22279. if v == nil {
  22280. return
  22281. }
  22282. return *v, true
  22283. }
  22284. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  22285. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22287. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  22288. if !m.op.Is(OpUpdateOne) {
  22289. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  22290. }
  22291. if m.id == nil || m.oldValue == nil {
  22292. return v, errors.New("OldAllowList requires an ID field in the mutation")
  22293. }
  22294. oldValue, err := m.oldValue(ctx)
  22295. if err != nil {
  22296. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  22297. }
  22298. return oldValue.AllowList, nil
  22299. }
  22300. // AppendAllowList adds s to the "allow_list" field.
  22301. func (m *WxMutation) AppendAllowList(s []string) {
  22302. m.appendallow_list = append(m.appendallow_list, s...)
  22303. }
  22304. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  22305. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  22306. if len(m.appendallow_list) == 0 {
  22307. return nil, false
  22308. }
  22309. return m.appendallow_list, true
  22310. }
  22311. // ResetAllowList resets all changes to the "allow_list" field.
  22312. func (m *WxMutation) ResetAllowList() {
  22313. m.allow_list = nil
  22314. m.appendallow_list = nil
  22315. }
  22316. // SetGroupAllowList sets the "group_allow_list" field.
  22317. func (m *WxMutation) SetGroupAllowList(s []string) {
  22318. m.group_allow_list = &s
  22319. m.appendgroup_allow_list = nil
  22320. }
  22321. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  22322. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  22323. v := m.group_allow_list
  22324. if v == nil {
  22325. return
  22326. }
  22327. return *v, true
  22328. }
  22329. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  22330. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22332. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  22333. if !m.op.Is(OpUpdateOne) {
  22334. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  22335. }
  22336. if m.id == nil || m.oldValue == nil {
  22337. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  22338. }
  22339. oldValue, err := m.oldValue(ctx)
  22340. if err != nil {
  22341. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  22342. }
  22343. return oldValue.GroupAllowList, nil
  22344. }
  22345. // AppendGroupAllowList adds s to the "group_allow_list" field.
  22346. func (m *WxMutation) AppendGroupAllowList(s []string) {
  22347. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  22348. }
  22349. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  22350. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  22351. if len(m.appendgroup_allow_list) == 0 {
  22352. return nil, false
  22353. }
  22354. return m.appendgroup_allow_list, true
  22355. }
  22356. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  22357. func (m *WxMutation) ResetGroupAllowList() {
  22358. m.group_allow_list = nil
  22359. m.appendgroup_allow_list = nil
  22360. }
  22361. // SetBlockList sets the "block_list" field.
  22362. func (m *WxMutation) SetBlockList(s []string) {
  22363. m.block_list = &s
  22364. m.appendblock_list = nil
  22365. }
  22366. // BlockList returns the value of the "block_list" field in the mutation.
  22367. func (m *WxMutation) BlockList() (r []string, exists bool) {
  22368. v := m.block_list
  22369. if v == nil {
  22370. return
  22371. }
  22372. return *v, true
  22373. }
  22374. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  22375. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22377. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  22378. if !m.op.Is(OpUpdateOne) {
  22379. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  22380. }
  22381. if m.id == nil || m.oldValue == nil {
  22382. return v, errors.New("OldBlockList requires an ID field in the mutation")
  22383. }
  22384. oldValue, err := m.oldValue(ctx)
  22385. if err != nil {
  22386. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  22387. }
  22388. return oldValue.BlockList, nil
  22389. }
  22390. // AppendBlockList adds s to the "block_list" field.
  22391. func (m *WxMutation) AppendBlockList(s []string) {
  22392. m.appendblock_list = append(m.appendblock_list, s...)
  22393. }
  22394. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  22395. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  22396. if len(m.appendblock_list) == 0 {
  22397. return nil, false
  22398. }
  22399. return m.appendblock_list, true
  22400. }
  22401. // ResetBlockList resets all changes to the "block_list" field.
  22402. func (m *WxMutation) ResetBlockList() {
  22403. m.block_list = nil
  22404. m.appendblock_list = nil
  22405. }
  22406. // SetGroupBlockList sets the "group_block_list" field.
  22407. func (m *WxMutation) SetGroupBlockList(s []string) {
  22408. m.group_block_list = &s
  22409. m.appendgroup_block_list = nil
  22410. }
  22411. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  22412. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  22413. v := m.group_block_list
  22414. if v == nil {
  22415. return
  22416. }
  22417. return *v, true
  22418. }
  22419. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  22420. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22422. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  22423. if !m.op.Is(OpUpdateOne) {
  22424. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  22425. }
  22426. if m.id == nil || m.oldValue == nil {
  22427. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  22428. }
  22429. oldValue, err := m.oldValue(ctx)
  22430. if err != nil {
  22431. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  22432. }
  22433. return oldValue.GroupBlockList, nil
  22434. }
  22435. // AppendGroupBlockList adds s to the "group_block_list" field.
  22436. func (m *WxMutation) AppendGroupBlockList(s []string) {
  22437. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  22438. }
  22439. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  22440. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  22441. if len(m.appendgroup_block_list) == 0 {
  22442. return nil, false
  22443. }
  22444. return m.appendgroup_block_list, true
  22445. }
  22446. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  22447. func (m *WxMutation) ResetGroupBlockList() {
  22448. m.group_block_list = nil
  22449. m.appendgroup_block_list = nil
  22450. }
  22451. // ClearServer clears the "server" edge to the Server entity.
  22452. func (m *WxMutation) ClearServer() {
  22453. m.clearedserver = true
  22454. m.clearedFields[wx.FieldServerID] = struct{}{}
  22455. }
  22456. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  22457. func (m *WxMutation) ServerCleared() bool {
  22458. return m.ServerIDCleared() || m.clearedserver
  22459. }
  22460. // ServerIDs returns the "server" edge IDs in the mutation.
  22461. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22462. // ServerID instead. It exists only for internal usage by the builders.
  22463. func (m *WxMutation) ServerIDs() (ids []uint64) {
  22464. if id := m.server; id != nil {
  22465. ids = append(ids, *id)
  22466. }
  22467. return
  22468. }
  22469. // ResetServer resets all changes to the "server" edge.
  22470. func (m *WxMutation) ResetServer() {
  22471. m.server = nil
  22472. m.clearedserver = false
  22473. }
  22474. // ClearAgent clears the "agent" edge to the Agent entity.
  22475. func (m *WxMutation) ClearAgent() {
  22476. m.clearedagent = true
  22477. m.clearedFields[wx.FieldAgentID] = struct{}{}
  22478. }
  22479. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  22480. func (m *WxMutation) AgentCleared() bool {
  22481. return m.clearedagent
  22482. }
  22483. // AgentIDs returns the "agent" edge IDs in the mutation.
  22484. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22485. // AgentID instead. It exists only for internal usage by the builders.
  22486. func (m *WxMutation) AgentIDs() (ids []uint64) {
  22487. if id := m.agent; id != nil {
  22488. ids = append(ids, *id)
  22489. }
  22490. return
  22491. }
  22492. // ResetAgent resets all changes to the "agent" edge.
  22493. func (m *WxMutation) ResetAgent() {
  22494. m.agent = nil
  22495. m.clearedagent = false
  22496. }
  22497. // Where appends a list predicates to the WxMutation builder.
  22498. func (m *WxMutation) Where(ps ...predicate.Wx) {
  22499. m.predicates = append(m.predicates, ps...)
  22500. }
  22501. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  22502. // users can use type-assertion to append predicates that do not depend on any generated package.
  22503. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  22504. p := make([]predicate.Wx, len(ps))
  22505. for i := range ps {
  22506. p[i] = ps[i]
  22507. }
  22508. m.Where(p...)
  22509. }
  22510. // Op returns the operation name.
  22511. func (m *WxMutation) Op() Op {
  22512. return m.op
  22513. }
  22514. // SetOp allows setting the mutation operation.
  22515. func (m *WxMutation) SetOp(op Op) {
  22516. m.op = op
  22517. }
  22518. // Type returns the node type of this mutation (Wx).
  22519. func (m *WxMutation) Type() string {
  22520. return m.typ
  22521. }
  22522. // Fields returns all fields that were changed during this mutation. Note that in
  22523. // order to get all numeric fields that were incremented/decremented, call
  22524. // AddedFields().
  22525. func (m *WxMutation) Fields() []string {
  22526. fields := make([]string, 0, 21)
  22527. if m.created_at != nil {
  22528. fields = append(fields, wx.FieldCreatedAt)
  22529. }
  22530. if m.updated_at != nil {
  22531. fields = append(fields, wx.FieldUpdatedAt)
  22532. }
  22533. if m.status != nil {
  22534. fields = append(fields, wx.FieldStatus)
  22535. }
  22536. if m.deleted_at != nil {
  22537. fields = append(fields, wx.FieldDeletedAt)
  22538. }
  22539. if m.server != nil {
  22540. fields = append(fields, wx.FieldServerID)
  22541. }
  22542. if m.port != nil {
  22543. fields = append(fields, wx.FieldPort)
  22544. }
  22545. if m.process_id != nil {
  22546. fields = append(fields, wx.FieldProcessID)
  22547. }
  22548. if m.callback != nil {
  22549. fields = append(fields, wx.FieldCallback)
  22550. }
  22551. if m.wxid != nil {
  22552. fields = append(fields, wx.FieldWxid)
  22553. }
  22554. if m.account != nil {
  22555. fields = append(fields, wx.FieldAccount)
  22556. }
  22557. if m.nickname != nil {
  22558. fields = append(fields, wx.FieldNickname)
  22559. }
  22560. if m.tel != nil {
  22561. fields = append(fields, wx.FieldTel)
  22562. }
  22563. if m.head_big != nil {
  22564. fields = append(fields, wx.FieldHeadBig)
  22565. }
  22566. if m.organization_id != nil {
  22567. fields = append(fields, wx.FieldOrganizationID)
  22568. }
  22569. if m.agent != nil {
  22570. fields = append(fields, wx.FieldAgentID)
  22571. }
  22572. if m.api_base != nil {
  22573. fields = append(fields, wx.FieldAPIBase)
  22574. }
  22575. if m.api_key != nil {
  22576. fields = append(fields, wx.FieldAPIKey)
  22577. }
  22578. if m.allow_list != nil {
  22579. fields = append(fields, wx.FieldAllowList)
  22580. }
  22581. if m.group_allow_list != nil {
  22582. fields = append(fields, wx.FieldGroupAllowList)
  22583. }
  22584. if m.block_list != nil {
  22585. fields = append(fields, wx.FieldBlockList)
  22586. }
  22587. if m.group_block_list != nil {
  22588. fields = append(fields, wx.FieldGroupBlockList)
  22589. }
  22590. return fields
  22591. }
  22592. // Field returns the value of a field with the given name. The second boolean
  22593. // return value indicates that this field was not set, or was not defined in the
  22594. // schema.
  22595. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  22596. switch name {
  22597. case wx.FieldCreatedAt:
  22598. return m.CreatedAt()
  22599. case wx.FieldUpdatedAt:
  22600. return m.UpdatedAt()
  22601. case wx.FieldStatus:
  22602. return m.Status()
  22603. case wx.FieldDeletedAt:
  22604. return m.DeletedAt()
  22605. case wx.FieldServerID:
  22606. return m.ServerID()
  22607. case wx.FieldPort:
  22608. return m.Port()
  22609. case wx.FieldProcessID:
  22610. return m.ProcessID()
  22611. case wx.FieldCallback:
  22612. return m.Callback()
  22613. case wx.FieldWxid:
  22614. return m.Wxid()
  22615. case wx.FieldAccount:
  22616. return m.Account()
  22617. case wx.FieldNickname:
  22618. return m.Nickname()
  22619. case wx.FieldTel:
  22620. return m.Tel()
  22621. case wx.FieldHeadBig:
  22622. return m.HeadBig()
  22623. case wx.FieldOrganizationID:
  22624. return m.OrganizationID()
  22625. case wx.FieldAgentID:
  22626. return m.AgentID()
  22627. case wx.FieldAPIBase:
  22628. return m.APIBase()
  22629. case wx.FieldAPIKey:
  22630. return m.APIKey()
  22631. case wx.FieldAllowList:
  22632. return m.AllowList()
  22633. case wx.FieldGroupAllowList:
  22634. return m.GroupAllowList()
  22635. case wx.FieldBlockList:
  22636. return m.BlockList()
  22637. case wx.FieldGroupBlockList:
  22638. return m.GroupBlockList()
  22639. }
  22640. return nil, false
  22641. }
  22642. // OldField returns the old value of the field from the database. An error is
  22643. // returned if the mutation operation is not UpdateOne, or the query to the
  22644. // database failed.
  22645. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22646. switch name {
  22647. case wx.FieldCreatedAt:
  22648. return m.OldCreatedAt(ctx)
  22649. case wx.FieldUpdatedAt:
  22650. return m.OldUpdatedAt(ctx)
  22651. case wx.FieldStatus:
  22652. return m.OldStatus(ctx)
  22653. case wx.FieldDeletedAt:
  22654. return m.OldDeletedAt(ctx)
  22655. case wx.FieldServerID:
  22656. return m.OldServerID(ctx)
  22657. case wx.FieldPort:
  22658. return m.OldPort(ctx)
  22659. case wx.FieldProcessID:
  22660. return m.OldProcessID(ctx)
  22661. case wx.FieldCallback:
  22662. return m.OldCallback(ctx)
  22663. case wx.FieldWxid:
  22664. return m.OldWxid(ctx)
  22665. case wx.FieldAccount:
  22666. return m.OldAccount(ctx)
  22667. case wx.FieldNickname:
  22668. return m.OldNickname(ctx)
  22669. case wx.FieldTel:
  22670. return m.OldTel(ctx)
  22671. case wx.FieldHeadBig:
  22672. return m.OldHeadBig(ctx)
  22673. case wx.FieldOrganizationID:
  22674. return m.OldOrganizationID(ctx)
  22675. case wx.FieldAgentID:
  22676. return m.OldAgentID(ctx)
  22677. case wx.FieldAPIBase:
  22678. return m.OldAPIBase(ctx)
  22679. case wx.FieldAPIKey:
  22680. return m.OldAPIKey(ctx)
  22681. case wx.FieldAllowList:
  22682. return m.OldAllowList(ctx)
  22683. case wx.FieldGroupAllowList:
  22684. return m.OldGroupAllowList(ctx)
  22685. case wx.FieldBlockList:
  22686. return m.OldBlockList(ctx)
  22687. case wx.FieldGroupBlockList:
  22688. return m.OldGroupBlockList(ctx)
  22689. }
  22690. return nil, fmt.Errorf("unknown Wx field %s", name)
  22691. }
  22692. // SetField sets the value of a field with the given name. It returns an error if
  22693. // the field is not defined in the schema, or if the type mismatched the field
  22694. // type.
  22695. func (m *WxMutation) SetField(name string, value ent.Value) error {
  22696. switch name {
  22697. case wx.FieldCreatedAt:
  22698. v, ok := value.(time.Time)
  22699. if !ok {
  22700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22701. }
  22702. m.SetCreatedAt(v)
  22703. return nil
  22704. case wx.FieldUpdatedAt:
  22705. v, ok := value.(time.Time)
  22706. if !ok {
  22707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22708. }
  22709. m.SetUpdatedAt(v)
  22710. return nil
  22711. case wx.FieldStatus:
  22712. v, ok := value.(uint8)
  22713. if !ok {
  22714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22715. }
  22716. m.SetStatus(v)
  22717. return nil
  22718. case wx.FieldDeletedAt:
  22719. v, ok := value.(time.Time)
  22720. if !ok {
  22721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22722. }
  22723. m.SetDeletedAt(v)
  22724. return nil
  22725. case wx.FieldServerID:
  22726. v, ok := value.(uint64)
  22727. if !ok {
  22728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22729. }
  22730. m.SetServerID(v)
  22731. return nil
  22732. case wx.FieldPort:
  22733. v, ok := value.(string)
  22734. if !ok {
  22735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22736. }
  22737. m.SetPort(v)
  22738. return nil
  22739. case wx.FieldProcessID:
  22740. v, ok := value.(string)
  22741. if !ok {
  22742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22743. }
  22744. m.SetProcessID(v)
  22745. return nil
  22746. case wx.FieldCallback:
  22747. v, ok := value.(string)
  22748. if !ok {
  22749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22750. }
  22751. m.SetCallback(v)
  22752. return nil
  22753. case wx.FieldWxid:
  22754. v, ok := value.(string)
  22755. if !ok {
  22756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22757. }
  22758. m.SetWxid(v)
  22759. return nil
  22760. case wx.FieldAccount:
  22761. v, ok := value.(string)
  22762. if !ok {
  22763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22764. }
  22765. m.SetAccount(v)
  22766. return nil
  22767. case wx.FieldNickname:
  22768. v, ok := value.(string)
  22769. if !ok {
  22770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22771. }
  22772. m.SetNickname(v)
  22773. return nil
  22774. case wx.FieldTel:
  22775. v, ok := value.(string)
  22776. if !ok {
  22777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22778. }
  22779. m.SetTel(v)
  22780. return nil
  22781. case wx.FieldHeadBig:
  22782. v, ok := value.(string)
  22783. if !ok {
  22784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22785. }
  22786. m.SetHeadBig(v)
  22787. return nil
  22788. case wx.FieldOrganizationID:
  22789. v, ok := value.(uint64)
  22790. if !ok {
  22791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22792. }
  22793. m.SetOrganizationID(v)
  22794. return nil
  22795. case wx.FieldAgentID:
  22796. v, ok := value.(uint64)
  22797. if !ok {
  22798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22799. }
  22800. m.SetAgentID(v)
  22801. return nil
  22802. case wx.FieldAPIBase:
  22803. v, ok := value.(string)
  22804. if !ok {
  22805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22806. }
  22807. m.SetAPIBase(v)
  22808. return nil
  22809. case wx.FieldAPIKey:
  22810. v, ok := value.(string)
  22811. if !ok {
  22812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22813. }
  22814. m.SetAPIKey(v)
  22815. return nil
  22816. case wx.FieldAllowList:
  22817. v, ok := value.([]string)
  22818. if !ok {
  22819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22820. }
  22821. m.SetAllowList(v)
  22822. return nil
  22823. case wx.FieldGroupAllowList:
  22824. v, ok := value.([]string)
  22825. if !ok {
  22826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22827. }
  22828. m.SetGroupAllowList(v)
  22829. return nil
  22830. case wx.FieldBlockList:
  22831. v, ok := value.([]string)
  22832. if !ok {
  22833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22834. }
  22835. m.SetBlockList(v)
  22836. return nil
  22837. case wx.FieldGroupBlockList:
  22838. v, ok := value.([]string)
  22839. if !ok {
  22840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22841. }
  22842. m.SetGroupBlockList(v)
  22843. return nil
  22844. }
  22845. return fmt.Errorf("unknown Wx field %s", name)
  22846. }
  22847. // AddedFields returns all numeric fields that were incremented/decremented during
  22848. // this mutation.
  22849. func (m *WxMutation) AddedFields() []string {
  22850. var fields []string
  22851. if m.addstatus != nil {
  22852. fields = append(fields, wx.FieldStatus)
  22853. }
  22854. if m.addorganization_id != nil {
  22855. fields = append(fields, wx.FieldOrganizationID)
  22856. }
  22857. return fields
  22858. }
  22859. // AddedField returns the numeric value that was incremented/decremented on a field
  22860. // with the given name. The second boolean return value indicates that this field
  22861. // was not set, or was not defined in the schema.
  22862. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  22863. switch name {
  22864. case wx.FieldStatus:
  22865. return m.AddedStatus()
  22866. case wx.FieldOrganizationID:
  22867. return m.AddedOrganizationID()
  22868. }
  22869. return nil, false
  22870. }
  22871. // AddField adds the value to the field with the given name. It returns an error if
  22872. // the field is not defined in the schema, or if the type mismatched the field
  22873. // type.
  22874. func (m *WxMutation) AddField(name string, value ent.Value) error {
  22875. switch name {
  22876. case wx.FieldStatus:
  22877. v, ok := value.(int8)
  22878. if !ok {
  22879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22880. }
  22881. m.AddStatus(v)
  22882. return nil
  22883. case wx.FieldOrganizationID:
  22884. v, ok := value.(int64)
  22885. if !ok {
  22886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22887. }
  22888. m.AddOrganizationID(v)
  22889. return nil
  22890. }
  22891. return fmt.Errorf("unknown Wx numeric field %s", name)
  22892. }
  22893. // ClearedFields returns all nullable fields that were cleared during this
  22894. // mutation.
  22895. func (m *WxMutation) ClearedFields() []string {
  22896. var fields []string
  22897. if m.FieldCleared(wx.FieldStatus) {
  22898. fields = append(fields, wx.FieldStatus)
  22899. }
  22900. if m.FieldCleared(wx.FieldDeletedAt) {
  22901. fields = append(fields, wx.FieldDeletedAt)
  22902. }
  22903. if m.FieldCleared(wx.FieldServerID) {
  22904. fields = append(fields, wx.FieldServerID)
  22905. }
  22906. if m.FieldCleared(wx.FieldOrganizationID) {
  22907. fields = append(fields, wx.FieldOrganizationID)
  22908. }
  22909. if m.FieldCleared(wx.FieldAPIBase) {
  22910. fields = append(fields, wx.FieldAPIBase)
  22911. }
  22912. if m.FieldCleared(wx.FieldAPIKey) {
  22913. fields = append(fields, wx.FieldAPIKey)
  22914. }
  22915. return fields
  22916. }
  22917. // FieldCleared returns a boolean indicating if a field with the given name was
  22918. // cleared in this mutation.
  22919. func (m *WxMutation) FieldCleared(name string) bool {
  22920. _, ok := m.clearedFields[name]
  22921. return ok
  22922. }
  22923. // ClearField clears the value of the field with the given name. It returns an
  22924. // error if the field is not defined in the schema.
  22925. func (m *WxMutation) ClearField(name string) error {
  22926. switch name {
  22927. case wx.FieldStatus:
  22928. m.ClearStatus()
  22929. return nil
  22930. case wx.FieldDeletedAt:
  22931. m.ClearDeletedAt()
  22932. return nil
  22933. case wx.FieldServerID:
  22934. m.ClearServerID()
  22935. return nil
  22936. case wx.FieldOrganizationID:
  22937. m.ClearOrganizationID()
  22938. return nil
  22939. case wx.FieldAPIBase:
  22940. m.ClearAPIBase()
  22941. return nil
  22942. case wx.FieldAPIKey:
  22943. m.ClearAPIKey()
  22944. return nil
  22945. }
  22946. return fmt.Errorf("unknown Wx nullable field %s", name)
  22947. }
  22948. // ResetField resets all changes in the mutation for the field with the given name.
  22949. // It returns an error if the field is not defined in the schema.
  22950. func (m *WxMutation) ResetField(name string) error {
  22951. switch name {
  22952. case wx.FieldCreatedAt:
  22953. m.ResetCreatedAt()
  22954. return nil
  22955. case wx.FieldUpdatedAt:
  22956. m.ResetUpdatedAt()
  22957. return nil
  22958. case wx.FieldStatus:
  22959. m.ResetStatus()
  22960. return nil
  22961. case wx.FieldDeletedAt:
  22962. m.ResetDeletedAt()
  22963. return nil
  22964. case wx.FieldServerID:
  22965. m.ResetServerID()
  22966. return nil
  22967. case wx.FieldPort:
  22968. m.ResetPort()
  22969. return nil
  22970. case wx.FieldProcessID:
  22971. m.ResetProcessID()
  22972. return nil
  22973. case wx.FieldCallback:
  22974. m.ResetCallback()
  22975. return nil
  22976. case wx.FieldWxid:
  22977. m.ResetWxid()
  22978. return nil
  22979. case wx.FieldAccount:
  22980. m.ResetAccount()
  22981. return nil
  22982. case wx.FieldNickname:
  22983. m.ResetNickname()
  22984. return nil
  22985. case wx.FieldTel:
  22986. m.ResetTel()
  22987. return nil
  22988. case wx.FieldHeadBig:
  22989. m.ResetHeadBig()
  22990. return nil
  22991. case wx.FieldOrganizationID:
  22992. m.ResetOrganizationID()
  22993. return nil
  22994. case wx.FieldAgentID:
  22995. m.ResetAgentID()
  22996. return nil
  22997. case wx.FieldAPIBase:
  22998. m.ResetAPIBase()
  22999. return nil
  23000. case wx.FieldAPIKey:
  23001. m.ResetAPIKey()
  23002. return nil
  23003. case wx.FieldAllowList:
  23004. m.ResetAllowList()
  23005. return nil
  23006. case wx.FieldGroupAllowList:
  23007. m.ResetGroupAllowList()
  23008. return nil
  23009. case wx.FieldBlockList:
  23010. m.ResetBlockList()
  23011. return nil
  23012. case wx.FieldGroupBlockList:
  23013. m.ResetGroupBlockList()
  23014. return nil
  23015. }
  23016. return fmt.Errorf("unknown Wx field %s", name)
  23017. }
  23018. // AddedEdges returns all edge names that were set/added in this mutation.
  23019. func (m *WxMutation) AddedEdges() []string {
  23020. edges := make([]string, 0, 2)
  23021. if m.server != nil {
  23022. edges = append(edges, wx.EdgeServer)
  23023. }
  23024. if m.agent != nil {
  23025. edges = append(edges, wx.EdgeAgent)
  23026. }
  23027. return edges
  23028. }
  23029. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23030. // name in this mutation.
  23031. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  23032. switch name {
  23033. case wx.EdgeServer:
  23034. if id := m.server; id != nil {
  23035. return []ent.Value{*id}
  23036. }
  23037. case wx.EdgeAgent:
  23038. if id := m.agent; id != nil {
  23039. return []ent.Value{*id}
  23040. }
  23041. }
  23042. return nil
  23043. }
  23044. // RemovedEdges returns all edge names that were removed in this mutation.
  23045. func (m *WxMutation) RemovedEdges() []string {
  23046. edges := make([]string, 0, 2)
  23047. return edges
  23048. }
  23049. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23050. // the given name in this mutation.
  23051. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  23052. return nil
  23053. }
  23054. // ClearedEdges returns all edge names that were cleared in this mutation.
  23055. func (m *WxMutation) ClearedEdges() []string {
  23056. edges := make([]string, 0, 2)
  23057. if m.clearedserver {
  23058. edges = append(edges, wx.EdgeServer)
  23059. }
  23060. if m.clearedagent {
  23061. edges = append(edges, wx.EdgeAgent)
  23062. }
  23063. return edges
  23064. }
  23065. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23066. // was cleared in this mutation.
  23067. func (m *WxMutation) EdgeCleared(name string) bool {
  23068. switch name {
  23069. case wx.EdgeServer:
  23070. return m.clearedserver
  23071. case wx.EdgeAgent:
  23072. return m.clearedagent
  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 *WxMutation) ClearEdge(name string) error {
  23079. switch name {
  23080. case wx.EdgeServer:
  23081. m.ClearServer()
  23082. return nil
  23083. case wx.EdgeAgent:
  23084. m.ClearAgent()
  23085. return nil
  23086. }
  23087. return fmt.Errorf("unknown Wx unique edge %s", name)
  23088. }
  23089. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23090. // It returns an error if the edge is not defined in the schema.
  23091. func (m *WxMutation) ResetEdge(name string) error {
  23092. switch name {
  23093. case wx.EdgeServer:
  23094. m.ResetServer()
  23095. return nil
  23096. case wx.EdgeAgent:
  23097. m.ResetAgent()
  23098. return nil
  23099. }
  23100. return fmt.Errorf("unknown Wx edge %s", name)
  23101. }
  23102. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  23103. type WxCardMutation struct {
  23104. config
  23105. op Op
  23106. typ string
  23107. id *uint64
  23108. created_at *time.Time
  23109. updated_at *time.Time
  23110. deleted_at *time.Time
  23111. user_id *uint64
  23112. adduser_id *int64
  23113. wx_user_id *uint64
  23114. addwx_user_id *int64
  23115. avatar *string
  23116. logo *string
  23117. name *string
  23118. company *string
  23119. address *string
  23120. phone *string
  23121. official_account *string
  23122. wechat_account *string
  23123. email *string
  23124. api_base *string
  23125. api_key *string
  23126. ai_info *string
  23127. intro *string
  23128. clearedFields map[string]struct{}
  23129. done bool
  23130. oldValue func(context.Context) (*WxCard, error)
  23131. predicates []predicate.WxCard
  23132. }
  23133. var _ ent.Mutation = (*WxCardMutation)(nil)
  23134. // wxcardOption allows management of the mutation configuration using functional options.
  23135. type wxcardOption func(*WxCardMutation)
  23136. // newWxCardMutation creates new mutation for the WxCard entity.
  23137. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  23138. m := &WxCardMutation{
  23139. config: c,
  23140. op: op,
  23141. typ: TypeWxCard,
  23142. clearedFields: make(map[string]struct{}),
  23143. }
  23144. for _, opt := range opts {
  23145. opt(m)
  23146. }
  23147. return m
  23148. }
  23149. // withWxCardID sets the ID field of the mutation.
  23150. func withWxCardID(id uint64) wxcardOption {
  23151. return func(m *WxCardMutation) {
  23152. var (
  23153. err error
  23154. once sync.Once
  23155. value *WxCard
  23156. )
  23157. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  23158. once.Do(func() {
  23159. if m.done {
  23160. err = errors.New("querying old values post mutation is not allowed")
  23161. } else {
  23162. value, err = m.Client().WxCard.Get(ctx, id)
  23163. }
  23164. })
  23165. return value, err
  23166. }
  23167. m.id = &id
  23168. }
  23169. }
  23170. // withWxCard sets the old WxCard of the mutation.
  23171. func withWxCard(node *WxCard) wxcardOption {
  23172. return func(m *WxCardMutation) {
  23173. m.oldValue = func(context.Context) (*WxCard, error) {
  23174. return node, nil
  23175. }
  23176. m.id = &node.ID
  23177. }
  23178. }
  23179. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23180. // executed in a transaction (ent.Tx), a transactional client is returned.
  23181. func (m WxCardMutation) Client() *Client {
  23182. client := &Client{config: m.config}
  23183. client.init()
  23184. return client
  23185. }
  23186. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23187. // it returns an error otherwise.
  23188. func (m WxCardMutation) Tx() (*Tx, error) {
  23189. if _, ok := m.driver.(*txDriver); !ok {
  23190. return nil, errors.New("ent: mutation is not running in a transaction")
  23191. }
  23192. tx := &Tx{config: m.config}
  23193. tx.init()
  23194. return tx, nil
  23195. }
  23196. // SetID sets the value of the id field. Note that this
  23197. // operation is only accepted on creation of WxCard entities.
  23198. func (m *WxCardMutation) SetID(id uint64) {
  23199. m.id = &id
  23200. }
  23201. // ID returns the ID value in the mutation. Note that the ID is only available
  23202. // if it was provided to the builder or after it was returned from the database.
  23203. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  23204. if m.id == nil {
  23205. return
  23206. }
  23207. return *m.id, true
  23208. }
  23209. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23210. // That means, if the mutation is applied within a transaction with an isolation level such
  23211. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23212. // or updated by the mutation.
  23213. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  23214. switch {
  23215. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23216. id, exists := m.ID()
  23217. if exists {
  23218. return []uint64{id}, nil
  23219. }
  23220. fallthrough
  23221. case m.op.Is(OpUpdate | OpDelete):
  23222. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  23223. default:
  23224. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23225. }
  23226. }
  23227. // SetCreatedAt sets the "created_at" field.
  23228. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  23229. m.created_at = &t
  23230. }
  23231. // CreatedAt returns the value of the "created_at" field in the mutation.
  23232. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  23233. v := m.created_at
  23234. if v == nil {
  23235. return
  23236. }
  23237. return *v, true
  23238. }
  23239. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  23240. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23242. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23243. if !m.op.Is(OpUpdateOne) {
  23244. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23245. }
  23246. if m.id == nil || m.oldValue == nil {
  23247. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23248. }
  23249. oldValue, err := m.oldValue(ctx)
  23250. if err != nil {
  23251. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23252. }
  23253. return oldValue.CreatedAt, nil
  23254. }
  23255. // ResetCreatedAt resets all changes to the "created_at" field.
  23256. func (m *WxCardMutation) ResetCreatedAt() {
  23257. m.created_at = nil
  23258. }
  23259. // SetUpdatedAt sets the "updated_at" field.
  23260. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  23261. m.updated_at = &t
  23262. }
  23263. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23264. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  23265. v := m.updated_at
  23266. if v == nil {
  23267. return
  23268. }
  23269. return *v, true
  23270. }
  23271. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  23272. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23274. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23275. if !m.op.Is(OpUpdateOne) {
  23276. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23277. }
  23278. if m.id == nil || m.oldValue == nil {
  23279. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23280. }
  23281. oldValue, err := m.oldValue(ctx)
  23282. if err != nil {
  23283. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23284. }
  23285. return oldValue.UpdatedAt, nil
  23286. }
  23287. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23288. func (m *WxCardMutation) ResetUpdatedAt() {
  23289. m.updated_at = nil
  23290. }
  23291. // SetDeletedAt sets the "deleted_at" field.
  23292. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  23293. m.deleted_at = &t
  23294. }
  23295. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23296. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  23297. v := m.deleted_at
  23298. if v == nil {
  23299. return
  23300. }
  23301. return *v, true
  23302. }
  23303. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  23304. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23306. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23307. if !m.op.Is(OpUpdateOne) {
  23308. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23309. }
  23310. if m.id == nil || m.oldValue == nil {
  23311. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23312. }
  23313. oldValue, err := m.oldValue(ctx)
  23314. if err != nil {
  23315. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23316. }
  23317. return oldValue.DeletedAt, nil
  23318. }
  23319. // ClearDeletedAt clears the value of the "deleted_at" field.
  23320. func (m *WxCardMutation) ClearDeletedAt() {
  23321. m.deleted_at = nil
  23322. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  23323. }
  23324. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23325. func (m *WxCardMutation) DeletedAtCleared() bool {
  23326. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  23327. return ok
  23328. }
  23329. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23330. func (m *WxCardMutation) ResetDeletedAt() {
  23331. m.deleted_at = nil
  23332. delete(m.clearedFields, wxcard.FieldDeletedAt)
  23333. }
  23334. // SetUserID sets the "user_id" field.
  23335. func (m *WxCardMutation) SetUserID(u uint64) {
  23336. m.user_id = &u
  23337. m.adduser_id = nil
  23338. }
  23339. // UserID returns the value of the "user_id" field in the mutation.
  23340. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  23341. v := m.user_id
  23342. if v == nil {
  23343. return
  23344. }
  23345. return *v, true
  23346. }
  23347. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  23348. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23350. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  23351. if !m.op.Is(OpUpdateOne) {
  23352. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  23353. }
  23354. if m.id == nil || m.oldValue == nil {
  23355. return v, errors.New("OldUserID requires an ID field in the mutation")
  23356. }
  23357. oldValue, err := m.oldValue(ctx)
  23358. if err != nil {
  23359. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  23360. }
  23361. return oldValue.UserID, nil
  23362. }
  23363. // AddUserID adds u to the "user_id" field.
  23364. func (m *WxCardMutation) AddUserID(u int64) {
  23365. if m.adduser_id != nil {
  23366. *m.adduser_id += u
  23367. } else {
  23368. m.adduser_id = &u
  23369. }
  23370. }
  23371. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  23372. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  23373. v := m.adduser_id
  23374. if v == nil {
  23375. return
  23376. }
  23377. return *v, true
  23378. }
  23379. // ClearUserID clears the value of the "user_id" field.
  23380. func (m *WxCardMutation) ClearUserID() {
  23381. m.user_id = nil
  23382. m.adduser_id = nil
  23383. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  23384. }
  23385. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  23386. func (m *WxCardMutation) UserIDCleared() bool {
  23387. _, ok := m.clearedFields[wxcard.FieldUserID]
  23388. return ok
  23389. }
  23390. // ResetUserID resets all changes to the "user_id" field.
  23391. func (m *WxCardMutation) ResetUserID() {
  23392. m.user_id = nil
  23393. m.adduser_id = nil
  23394. delete(m.clearedFields, wxcard.FieldUserID)
  23395. }
  23396. // SetWxUserID sets the "wx_user_id" field.
  23397. func (m *WxCardMutation) SetWxUserID(u uint64) {
  23398. m.wx_user_id = &u
  23399. m.addwx_user_id = nil
  23400. }
  23401. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  23402. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  23403. v := m.wx_user_id
  23404. if v == nil {
  23405. return
  23406. }
  23407. return *v, true
  23408. }
  23409. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  23410. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23412. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  23413. if !m.op.Is(OpUpdateOne) {
  23414. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  23415. }
  23416. if m.id == nil || m.oldValue == nil {
  23417. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  23418. }
  23419. oldValue, err := m.oldValue(ctx)
  23420. if err != nil {
  23421. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  23422. }
  23423. return oldValue.WxUserID, nil
  23424. }
  23425. // AddWxUserID adds u to the "wx_user_id" field.
  23426. func (m *WxCardMutation) AddWxUserID(u int64) {
  23427. if m.addwx_user_id != nil {
  23428. *m.addwx_user_id += u
  23429. } else {
  23430. m.addwx_user_id = &u
  23431. }
  23432. }
  23433. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  23434. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  23435. v := m.addwx_user_id
  23436. if v == nil {
  23437. return
  23438. }
  23439. return *v, true
  23440. }
  23441. // ClearWxUserID clears the value of the "wx_user_id" field.
  23442. func (m *WxCardMutation) ClearWxUserID() {
  23443. m.wx_user_id = nil
  23444. m.addwx_user_id = nil
  23445. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  23446. }
  23447. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  23448. func (m *WxCardMutation) WxUserIDCleared() bool {
  23449. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  23450. return ok
  23451. }
  23452. // ResetWxUserID resets all changes to the "wx_user_id" field.
  23453. func (m *WxCardMutation) ResetWxUserID() {
  23454. m.wx_user_id = nil
  23455. m.addwx_user_id = nil
  23456. delete(m.clearedFields, wxcard.FieldWxUserID)
  23457. }
  23458. // SetAvatar sets the "avatar" field.
  23459. func (m *WxCardMutation) SetAvatar(s string) {
  23460. m.avatar = &s
  23461. }
  23462. // Avatar returns the value of the "avatar" field in the mutation.
  23463. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  23464. v := m.avatar
  23465. if v == nil {
  23466. return
  23467. }
  23468. return *v, true
  23469. }
  23470. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  23471. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23473. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  23474. if !m.op.Is(OpUpdateOne) {
  23475. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  23476. }
  23477. if m.id == nil || m.oldValue == nil {
  23478. return v, errors.New("OldAvatar requires an ID field in the mutation")
  23479. }
  23480. oldValue, err := m.oldValue(ctx)
  23481. if err != nil {
  23482. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  23483. }
  23484. return oldValue.Avatar, nil
  23485. }
  23486. // ResetAvatar resets all changes to the "avatar" field.
  23487. func (m *WxCardMutation) ResetAvatar() {
  23488. m.avatar = nil
  23489. }
  23490. // SetLogo sets the "logo" field.
  23491. func (m *WxCardMutation) SetLogo(s string) {
  23492. m.logo = &s
  23493. }
  23494. // Logo returns the value of the "logo" field in the mutation.
  23495. func (m *WxCardMutation) Logo() (r string, exists bool) {
  23496. v := m.logo
  23497. if v == nil {
  23498. return
  23499. }
  23500. return *v, true
  23501. }
  23502. // OldLogo returns the old "logo" field's value of the WxCard entity.
  23503. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23505. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  23506. if !m.op.Is(OpUpdateOne) {
  23507. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  23508. }
  23509. if m.id == nil || m.oldValue == nil {
  23510. return v, errors.New("OldLogo requires an ID field in the mutation")
  23511. }
  23512. oldValue, err := m.oldValue(ctx)
  23513. if err != nil {
  23514. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  23515. }
  23516. return oldValue.Logo, nil
  23517. }
  23518. // ResetLogo resets all changes to the "logo" field.
  23519. func (m *WxCardMutation) ResetLogo() {
  23520. m.logo = nil
  23521. }
  23522. // SetName sets the "name" field.
  23523. func (m *WxCardMutation) SetName(s string) {
  23524. m.name = &s
  23525. }
  23526. // Name returns the value of the "name" field in the mutation.
  23527. func (m *WxCardMutation) Name() (r string, exists bool) {
  23528. v := m.name
  23529. if v == nil {
  23530. return
  23531. }
  23532. return *v, true
  23533. }
  23534. // OldName returns the old "name" field's value of the WxCard entity.
  23535. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23537. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  23538. if !m.op.Is(OpUpdateOne) {
  23539. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23540. }
  23541. if m.id == nil || m.oldValue == nil {
  23542. return v, errors.New("OldName requires an ID field in the mutation")
  23543. }
  23544. oldValue, err := m.oldValue(ctx)
  23545. if err != nil {
  23546. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23547. }
  23548. return oldValue.Name, nil
  23549. }
  23550. // ResetName resets all changes to the "name" field.
  23551. func (m *WxCardMutation) ResetName() {
  23552. m.name = nil
  23553. }
  23554. // SetCompany sets the "company" field.
  23555. func (m *WxCardMutation) SetCompany(s string) {
  23556. m.company = &s
  23557. }
  23558. // Company returns the value of the "company" field in the mutation.
  23559. func (m *WxCardMutation) Company() (r string, exists bool) {
  23560. v := m.company
  23561. if v == nil {
  23562. return
  23563. }
  23564. return *v, true
  23565. }
  23566. // OldCompany returns the old "company" field's value of the WxCard entity.
  23567. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23569. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  23570. if !m.op.Is(OpUpdateOne) {
  23571. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  23572. }
  23573. if m.id == nil || m.oldValue == nil {
  23574. return v, errors.New("OldCompany requires an ID field in the mutation")
  23575. }
  23576. oldValue, err := m.oldValue(ctx)
  23577. if err != nil {
  23578. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  23579. }
  23580. return oldValue.Company, nil
  23581. }
  23582. // ResetCompany resets all changes to the "company" field.
  23583. func (m *WxCardMutation) ResetCompany() {
  23584. m.company = nil
  23585. }
  23586. // SetAddress sets the "address" field.
  23587. func (m *WxCardMutation) SetAddress(s string) {
  23588. m.address = &s
  23589. }
  23590. // Address returns the value of the "address" field in the mutation.
  23591. func (m *WxCardMutation) Address() (r string, exists bool) {
  23592. v := m.address
  23593. if v == nil {
  23594. return
  23595. }
  23596. return *v, true
  23597. }
  23598. // OldAddress returns the old "address" field's value of the WxCard entity.
  23599. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23601. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  23602. if !m.op.Is(OpUpdateOne) {
  23603. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  23604. }
  23605. if m.id == nil || m.oldValue == nil {
  23606. return v, errors.New("OldAddress requires an ID field in the mutation")
  23607. }
  23608. oldValue, err := m.oldValue(ctx)
  23609. if err != nil {
  23610. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  23611. }
  23612. return oldValue.Address, nil
  23613. }
  23614. // ResetAddress resets all changes to the "address" field.
  23615. func (m *WxCardMutation) ResetAddress() {
  23616. m.address = nil
  23617. }
  23618. // SetPhone sets the "phone" field.
  23619. func (m *WxCardMutation) SetPhone(s string) {
  23620. m.phone = &s
  23621. }
  23622. // Phone returns the value of the "phone" field in the mutation.
  23623. func (m *WxCardMutation) Phone() (r string, exists bool) {
  23624. v := m.phone
  23625. if v == nil {
  23626. return
  23627. }
  23628. return *v, true
  23629. }
  23630. // OldPhone returns the old "phone" field's value of the WxCard entity.
  23631. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23633. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  23634. if !m.op.Is(OpUpdateOne) {
  23635. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  23636. }
  23637. if m.id == nil || m.oldValue == nil {
  23638. return v, errors.New("OldPhone requires an ID field in the mutation")
  23639. }
  23640. oldValue, err := m.oldValue(ctx)
  23641. if err != nil {
  23642. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  23643. }
  23644. return oldValue.Phone, nil
  23645. }
  23646. // ResetPhone resets all changes to the "phone" field.
  23647. func (m *WxCardMutation) ResetPhone() {
  23648. m.phone = nil
  23649. }
  23650. // SetOfficialAccount sets the "official_account" field.
  23651. func (m *WxCardMutation) SetOfficialAccount(s string) {
  23652. m.official_account = &s
  23653. }
  23654. // OfficialAccount returns the value of the "official_account" field in the mutation.
  23655. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  23656. v := m.official_account
  23657. if v == nil {
  23658. return
  23659. }
  23660. return *v, true
  23661. }
  23662. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  23663. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23665. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  23666. if !m.op.Is(OpUpdateOne) {
  23667. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  23668. }
  23669. if m.id == nil || m.oldValue == nil {
  23670. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  23671. }
  23672. oldValue, err := m.oldValue(ctx)
  23673. if err != nil {
  23674. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  23675. }
  23676. return oldValue.OfficialAccount, nil
  23677. }
  23678. // ResetOfficialAccount resets all changes to the "official_account" field.
  23679. func (m *WxCardMutation) ResetOfficialAccount() {
  23680. m.official_account = nil
  23681. }
  23682. // SetWechatAccount sets the "wechat_account" field.
  23683. func (m *WxCardMutation) SetWechatAccount(s string) {
  23684. m.wechat_account = &s
  23685. }
  23686. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  23687. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  23688. v := m.wechat_account
  23689. if v == nil {
  23690. return
  23691. }
  23692. return *v, true
  23693. }
  23694. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  23695. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23697. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  23698. if !m.op.Is(OpUpdateOne) {
  23699. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  23700. }
  23701. if m.id == nil || m.oldValue == nil {
  23702. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  23703. }
  23704. oldValue, err := m.oldValue(ctx)
  23705. if err != nil {
  23706. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  23707. }
  23708. return oldValue.WechatAccount, nil
  23709. }
  23710. // ResetWechatAccount resets all changes to the "wechat_account" field.
  23711. func (m *WxCardMutation) ResetWechatAccount() {
  23712. m.wechat_account = nil
  23713. }
  23714. // SetEmail sets the "email" field.
  23715. func (m *WxCardMutation) SetEmail(s string) {
  23716. m.email = &s
  23717. }
  23718. // Email returns the value of the "email" field in the mutation.
  23719. func (m *WxCardMutation) Email() (r string, exists bool) {
  23720. v := m.email
  23721. if v == nil {
  23722. return
  23723. }
  23724. return *v, true
  23725. }
  23726. // OldEmail returns the old "email" field's value of the WxCard entity.
  23727. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23729. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  23730. if !m.op.Is(OpUpdateOne) {
  23731. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  23732. }
  23733. if m.id == nil || m.oldValue == nil {
  23734. return v, errors.New("OldEmail requires an ID field in the mutation")
  23735. }
  23736. oldValue, err := m.oldValue(ctx)
  23737. if err != nil {
  23738. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  23739. }
  23740. return oldValue.Email, nil
  23741. }
  23742. // ClearEmail clears the value of the "email" field.
  23743. func (m *WxCardMutation) ClearEmail() {
  23744. m.email = nil
  23745. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  23746. }
  23747. // EmailCleared returns if the "email" field was cleared in this mutation.
  23748. func (m *WxCardMutation) EmailCleared() bool {
  23749. _, ok := m.clearedFields[wxcard.FieldEmail]
  23750. return ok
  23751. }
  23752. // ResetEmail resets all changes to the "email" field.
  23753. func (m *WxCardMutation) ResetEmail() {
  23754. m.email = nil
  23755. delete(m.clearedFields, wxcard.FieldEmail)
  23756. }
  23757. // SetAPIBase sets the "api_base" field.
  23758. func (m *WxCardMutation) SetAPIBase(s string) {
  23759. m.api_base = &s
  23760. }
  23761. // APIBase returns the value of the "api_base" field in the mutation.
  23762. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  23763. v := m.api_base
  23764. if v == nil {
  23765. return
  23766. }
  23767. return *v, true
  23768. }
  23769. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  23770. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23772. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  23773. if !m.op.Is(OpUpdateOne) {
  23774. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  23775. }
  23776. if m.id == nil || m.oldValue == nil {
  23777. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  23778. }
  23779. oldValue, err := m.oldValue(ctx)
  23780. if err != nil {
  23781. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  23782. }
  23783. return oldValue.APIBase, nil
  23784. }
  23785. // ClearAPIBase clears the value of the "api_base" field.
  23786. func (m *WxCardMutation) ClearAPIBase() {
  23787. m.api_base = nil
  23788. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  23789. }
  23790. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  23791. func (m *WxCardMutation) APIBaseCleared() bool {
  23792. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  23793. return ok
  23794. }
  23795. // ResetAPIBase resets all changes to the "api_base" field.
  23796. func (m *WxCardMutation) ResetAPIBase() {
  23797. m.api_base = nil
  23798. delete(m.clearedFields, wxcard.FieldAPIBase)
  23799. }
  23800. // SetAPIKey sets the "api_key" field.
  23801. func (m *WxCardMutation) SetAPIKey(s string) {
  23802. m.api_key = &s
  23803. }
  23804. // APIKey returns the value of the "api_key" field in the mutation.
  23805. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  23806. v := m.api_key
  23807. if v == nil {
  23808. return
  23809. }
  23810. return *v, true
  23811. }
  23812. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  23813. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23815. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  23816. if !m.op.Is(OpUpdateOne) {
  23817. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  23818. }
  23819. if m.id == nil || m.oldValue == nil {
  23820. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  23821. }
  23822. oldValue, err := m.oldValue(ctx)
  23823. if err != nil {
  23824. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  23825. }
  23826. return oldValue.APIKey, nil
  23827. }
  23828. // ClearAPIKey clears the value of the "api_key" field.
  23829. func (m *WxCardMutation) ClearAPIKey() {
  23830. m.api_key = nil
  23831. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  23832. }
  23833. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  23834. func (m *WxCardMutation) APIKeyCleared() bool {
  23835. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  23836. return ok
  23837. }
  23838. // ResetAPIKey resets all changes to the "api_key" field.
  23839. func (m *WxCardMutation) ResetAPIKey() {
  23840. m.api_key = nil
  23841. delete(m.clearedFields, wxcard.FieldAPIKey)
  23842. }
  23843. // SetAiInfo sets the "ai_info" field.
  23844. func (m *WxCardMutation) SetAiInfo(s string) {
  23845. m.ai_info = &s
  23846. }
  23847. // AiInfo returns the value of the "ai_info" field in the mutation.
  23848. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  23849. v := m.ai_info
  23850. if v == nil {
  23851. return
  23852. }
  23853. return *v, true
  23854. }
  23855. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  23856. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23858. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  23859. if !m.op.Is(OpUpdateOne) {
  23860. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  23861. }
  23862. if m.id == nil || m.oldValue == nil {
  23863. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  23864. }
  23865. oldValue, err := m.oldValue(ctx)
  23866. if err != nil {
  23867. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  23868. }
  23869. return oldValue.AiInfo, nil
  23870. }
  23871. // ClearAiInfo clears the value of the "ai_info" field.
  23872. func (m *WxCardMutation) ClearAiInfo() {
  23873. m.ai_info = nil
  23874. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  23875. }
  23876. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  23877. func (m *WxCardMutation) AiInfoCleared() bool {
  23878. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  23879. return ok
  23880. }
  23881. // ResetAiInfo resets all changes to the "ai_info" field.
  23882. func (m *WxCardMutation) ResetAiInfo() {
  23883. m.ai_info = nil
  23884. delete(m.clearedFields, wxcard.FieldAiInfo)
  23885. }
  23886. // SetIntro sets the "intro" field.
  23887. func (m *WxCardMutation) SetIntro(s string) {
  23888. m.intro = &s
  23889. }
  23890. // Intro returns the value of the "intro" field in the mutation.
  23891. func (m *WxCardMutation) Intro() (r string, exists bool) {
  23892. v := m.intro
  23893. if v == nil {
  23894. return
  23895. }
  23896. return *v, true
  23897. }
  23898. // OldIntro returns the old "intro" field's value of the WxCard entity.
  23899. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23901. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  23902. if !m.op.Is(OpUpdateOne) {
  23903. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  23904. }
  23905. if m.id == nil || m.oldValue == nil {
  23906. return v, errors.New("OldIntro requires an ID field in the mutation")
  23907. }
  23908. oldValue, err := m.oldValue(ctx)
  23909. if err != nil {
  23910. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  23911. }
  23912. return oldValue.Intro, nil
  23913. }
  23914. // ClearIntro clears the value of the "intro" field.
  23915. func (m *WxCardMutation) ClearIntro() {
  23916. m.intro = nil
  23917. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  23918. }
  23919. // IntroCleared returns if the "intro" field was cleared in this mutation.
  23920. func (m *WxCardMutation) IntroCleared() bool {
  23921. _, ok := m.clearedFields[wxcard.FieldIntro]
  23922. return ok
  23923. }
  23924. // ResetIntro resets all changes to the "intro" field.
  23925. func (m *WxCardMutation) ResetIntro() {
  23926. m.intro = nil
  23927. delete(m.clearedFields, wxcard.FieldIntro)
  23928. }
  23929. // Where appends a list predicates to the WxCardMutation builder.
  23930. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  23931. m.predicates = append(m.predicates, ps...)
  23932. }
  23933. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  23934. // users can use type-assertion to append predicates that do not depend on any generated package.
  23935. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  23936. p := make([]predicate.WxCard, len(ps))
  23937. for i := range ps {
  23938. p[i] = ps[i]
  23939. }
  23940. m.Where(p...)
  23941. }
  23942. // Op returns the operation name.
  23943. func (m *WxCardMutation) Op() Op {
  23944. return m.op
  23945. }
  23946. // SetOp allows setting the mutation operation.
  23947. func (m *WxCardMutation) SetOp(op Op) {
  23948. m.op = op
  23949. }
  23950. // Type returns the node type of this mutation (WxCard).
  23951. func (m *WxCardMutation) Type() string {
  23952. return m.typ
  23953. }
  23954. // Fields returns all fields that were changed during this mutation. Note that in
  23955. // order to get all numeric fields that were incremented/decremented, call
  23956. // AddedFields().
  23957. func (m *WxCardMutation) Fields() []string {
  23958. fields := make([]string, 0, 18)
  23959. if m.created_at != nil {
  23960. fields = append(fields, wxcard.FieldCreatedAt)
  23961. }
  23962. if m.updated_at != nil {
  23963. fields = append(fields, wxcard.FieldUpdatedAt)
  23964. }
  23965. if m.deleted_at != nil {
  23966. fields = append(fields, wxcard.FieldDeletedAt)
  23967. }
  23968. if m.user_id != nil {
  23969. fields = append(fields, wxcard.FieldUserID)
  23970. }
  23971. if m.wx_user_id != nil {
  23972. fields = append(fields, wxcard.FieldWxUserID)
  23973. }
  23974. if m.avatar != nil {
  23975. fields = append(fields, wxcard.FieldAvatar)
  23976. }
  23977. if m.logo != nil {
  23978. fields = append(fields, wxcard.FieldLogo)
  23979. }
  23980. if m.name != nil {
  23981. fields = append(fields, wxcard.FieldName)
  23982. }
  23983. if m.company != nil {
  23984. fields = append(fields, wxcard.FieldCompany)
  23985. }
  23986. if m.address != nil {
  23987. fields = append(fields, wxcard.FieldAddress)
  23988. }
  23989. if m.phone != nil {
  23990. fields = append(fields, wxcard.FieldPhone)
  23991. }
  23992. if m.official_account != nil {
  23993. fields = append(fields, wxcard.FieldOfficialAccount)
  23994. }
  23995. if m.wechat_account != nil {
  23996. fields = append(fields, wxcard.FieldWechatAccount)
  23997. }
  23998. if m.email != nil {
  23999. fields = append(fields, wxcard.FieldEmail)
  24000. }
  24001. if m.api_base != nil {
  24002. fields = append(fields, wxcard.FieldAPIBase)
  24003. }
  24004. if m.api_key != nil {
  24005. fields = append(fields, wxcard.FieldAPIKey)
  24006. }
  24007. if m.ai_info != nil {
  24008. fields = append(fields, wxcard.FieldAiInfo)
  24009. }
  24010. if m.intro != nil {
  24011. fields = append(fields, wxcard.FieldIntro)
  24012. }
  24013. return fields
  24014. }
  24015. // Field returns the value of a field with the given name. The second boolean
  24016. // return value indicates that this field was not set, or was not defined in the
  24017. // schema.
  24018. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  24019. switch name {
  24020. case wxcard.FieldCreatedAt:
  24021. return m.CreatedAt()
  24022. case wxcard.FieldUpdatedAt:
  24023. return m.UpdatedAt()
  24024. case wxcard.FieldDeletedAt:
  24025. return m.DeletedAt()
  24026. case wxcard.FieldUserID:
  24027. return m.UserID()
  24028. case wxcard.FieldWxUserID:
  24029. return m.WxUserID()
  24030. case wxcard.FieldAvatar:
  24031. return m.Avatar()
  24032. case wxcard.FieldLogo:
  24033. return m.Logo()
  24034. case wxcard.FieldName:
  24035. return m.Name()
  24036. case wxcard.FieldCompany:
  24037. return m.Company()
  24038. case wxcard.FieldAddress:
  24039. return m.Address()
  24040. case wxcard.FieldPhone:
  24041. return m.Phone()
  24042. case wxcard.FieldOfficialAccount:
  24043. return m.OfficialAccount()
  24044. case wxcard.FieldWechatAccount:
  24045. return m.WechatAccount()
  24046. case wxcard.FieldEmail:
  24047. return m.Email()
  24048. case wxcard.FieldAPIBase:
  24049. return m.APIBase()
  24050. case wxcard.FieldAPIKey:
  24051. return m.APIKey()
  24052. case wxcard.FieldAiInfo:
  24053. return m.AiInfo()
  24054. case wxcard.FieldIntro:
  24055. return m.Intro()
  24056. }
  24057. return nil, false
  24058. }
  24059. // OldField returns the old value of the field from the database. An error is
  24060. // returned if the mutation operation is not UpdateOne, or the query to the
  24061. // database failed.
  24062. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24063. switch name {
  24064. case wxcard.FieldCreatedAt:
  24065. return m.OldCreatedAt(ctx)
  24066. case wxcard.FieldUpdatedAt:
  24067. return m.OldUpdatedAt(ctx)
  24068. case wxcard.FieldDeletedAt:
  24069. return m.OldDeletedAt(ctx)
  24070. case wxcard.FieldUserID:
  24071. return m.OldUserID(ctx)
  24072. case wxcard.FieldWxUserID:
  24073. return m.OldWxUserID(ctx)
  24074. case wxcard.FieldAvatar:
  24075. return m.OldAvatar(ctx)
  24076. case wxcard.FieldLogo:
  24077. return m.OldLogo(ctx)
  24078. case wxcard.FieldName:
  24079. return m.OldName(ctx)
  24080. case wxcard.FieldCompany:
  24081. return m.OldCompany(ctx)
  24082. case wxcard.FieldAddress:
  24083. return m.OldAddress(ctx)
  24084. case wxcard.FieldPhone:
  24085. return m.OldPhone(ctx)
  24086. case wxcard.FieldOfficialAccount:
  24087. return m.OldOfficialAccount(ctx)
  24088. case wxcard.FieldWechatAccount:
  24089. return m.OldWechatAccount(ctx)
  24090. case wxcard.FieldEmail:
  24091. return m.OldEmail(ctx)
  24092. case wxcard.FieldAPIBase:
  24093. return m.OldAPIBase(ctx)
  24094. case wxcard.FieldAPIKey:
  24095. return m.OldAPIKey(ctx)
  24096. case wxcard.FieldAiInfo:
  24097. return m.OldAiInfo(ctx)
  24098. case wxcard.FieldIntro:
  24099. return m.OldIntro(ctx)
  24100. }
  24101. return nil, fmt.Errorf("unknown WxCard field %s", name)
  24102. }
  24103. // SetField sets the value of a field with the given name. It returns an error if
  24104. // the field is not defined in the schema, or if the type mismatched the field
  24105. // type.
  24106. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  24107. switch name {
  24108. case wxcard.FieldCreatedAt:
  24109. v, ok := value.(time.Time)
  24110. if !ok {
  24111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24112. }
  24113. m.SetCreatedAt(v)
  24114. return nil
  24115. case wxcard.FieldUpdatedAt:
  24116. v, ok := value.(time.Time)
  24117. if !ok {
  24118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24119. }
  24120. m.SetUpdatedAt(v)
  24121. return nil
  24122. case wxcard.FieldDeletedAt:
  24123. v, ok := value.(time.Time)
  24124. if !ok {
  24125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24126. }
  24127. m.SetDeletedAt(v)
  24128. return nil
  24129. case wxcard.FieldUserID:
  24130. v, ok := value.(uint64)
  24131. if !ok {
  24132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24133. }
  24134. m.SetUserID(v)
  24135. return nil
  24136. case wxcard.FieldWxUserID:
  24137. v, ok := value.(uint64)
  24138. if !ok {
  24139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24140. }
  24141. m.SetWxUserID(v)
  24142. return nil
  24143. case wxcard.FieldAvatar:
  24144. v, ok := value.(string)
  24145. if !ok {
  24146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24147. }
  24148. m.SetAvatar(v)
  24149. return nil
  24150. case wxcard.FieldLogo:
  24151. v, ok := value.(string)
  24152. if !ok {
  24153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24154. }
  24155. m.SetLogo(v)
  24156. return nil
  24157. case wxcard.FieldName:
  24158. v, ok := value.(string)
  24159. if !ok {
  24160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24161. }
  24162. m.SetName(v)
  24163. return nil
  24164. case wxcard.FieldCompany:
  24165. v, ok := value.(string)
  24166. if !ok {
  24167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24168. }
  24169. m.SetCompany(v)
  24170. return nil
  24171. case wxcard.FieldAddress:
  24172. v, ok := value.(string)
  24173. if !ok {
  24174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24175. }
  24176. m.SetAddress(v)
  24177. return nil
  24178. case wxcard.FieldPhone:
  24179. v, ok := value.(string)
  24180. if !ok {
  24181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24182. }
  24183. m.SetPhone(v)
  24184. return nil
  24185. case wxcard.FieldOfficialAccount:
  24186. v, ok := value.(string)
  24187. if !ok {
  24188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24189. }
  24190. m.SetOfficialAccount(v)
  24191. return nil
  24192. case wxcard.FieldWechatAccount:
  24193. v, ok := value.(string)
  24194. if !ok {
  24195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24196. }
  24197. m.SetWechatAccount(v)
  24198. return nil
  24199. case wxcard.FieldEmail:
  24200. v, ok := value.(string)
  24201. if !ok {
  24202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24203. }
  24204. m.SetEmail(v)
  24205. return nil
  24206. case wxcard.FieldAPIBase:
  24207. v, ok := value.(string)
  24208. if !ok {
  24209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24210. }
  24211. m.SetAPIBase(v)
  24212. return nil
  24213. case wxcard.FieldAPIKey:
  24214. v, ok := value.(string)
  24215. if !ok {
  24216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24217. }
  24218. m.SetAPIKey(v)
  24219. return nil
  24220. case wxcard.FieldAiInfo:
  24221. v, ok := value.(string)
  24222. if !ok {
  24223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24224. }
  24225. m.SetAiInfo(v)
  24226. return nil
  24227. case wxcard.FieldIntro:
  24228. v, ok := value.(string)
  24229. if !ok {
  24230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24231. }
  24232. m.SetIntro(v)
  24233. return nil
  24234. }
  24235. return fmt.Errorf("unknown WxCard field %s", name)
  24236. }
  24237. // AddedFields returns all numeric fields that were incremented/decremented during
  24238. // this mutation.
  24239. func (m *WxCardMutation) AddedFields() []string {
  24240. var fields []string
  24241. if m.adduser_id != nil {
  24242. fields = append(fields, wxcard.FieldUserID)
  24243. }
  24244. if m.addwx_user_id != nil {
  24245. fields = append(fields, wxcard.FieldWxUserID)
  24246. }
  24247. return fields
  24248. }
  24249. // AddedField returns the numeric value that was incremented/decremented on a field
  24250. // with the given name. The second boolean return value indicates that this field
  24251. // was not set, or was not defined in the schema.
  24252. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  24253. switch name {
  24254. case wxcard.FieldUserID:
  24255. return m.AddedUserID()
  24256. case wxcard.FieldWxUserID:
  24257. return m.AddedWxUserID()
  24258. }
  24259. return nil, false
  24260. }
  24261. // AddField adds the value to the field with the given name. It returns an error if
  24262. // the field is not defined in the schema, or if the type mismatched the field
  24263. // type.
  24264. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  24265. switch name {
  24266. case wxcard.FieldUserID:
  24267. v, ok := value.(int64)
  24268. if !ok {
  24269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24270. }
  24271. m.AddUserID(v)
  24272. return nil
  24273. case wxcard.FieldWxUserID:
  24274. v, ok := value.(int64)
  24275. if !ok {
  24276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24277. }
  24278. m.AddWxUserID(v)
  24279. return nil
  24280. }
  24281. return fmt.Errorf("unknown WxCard numeric field %s", name)
  24282. }
  24283. // ClearedFields returns all nullable fields that were cleared during this
  24284. // mutation.
  24285. func (m *WxCardMutation) ClearedFields() []string {
  24286. var fields []string
  24287. if m.FieldCleared(wxcard.FieldDeletedAt) {
  24288. fields = append(fields, wxcard.FieldDeletedAt)
  24289. }
  24290. if m.FieldCleared(wxcard.FieldUserID) {
  24291. fields = append(fields, wxcard.FieldUserID)
  24292. }
  24293. if m.FieldCleared(wxcard.FieldWxUserID) {
  24294. fields = append(fields, wxcard.FieldWxUserID)
  24295. }
  24296. if m.FieldCleared(wxcard.FieldEmail) {
  24297. fields = append(fields, wxcard.FieldEmail)
  24298. }
  24299. if m.FieldCleared(wxcard.FieldAPIBase) {
  24300. fields = append(fields, wxcard.FieldAPIBase)
  24301. }
  24302. if m.FieldCleared(wxcard.FieldAPIKey) {
  24303. fields = append(fields, wxcard.FieldAPIKey)
  24304. }
  24305. if m.FieldCleared(wxcard.FieldAiInfo) {
  24306. fields = append(fields, wxcard.FieldAiInfo)
  24307. }
  24308. if m.FieldCleared(wxcard.FieldIntro) {
  24309. fields = append(fields, wxcard.FieldIntro)
  24310. }
  24311. return fields
  24312. }
  24313. // FieldCleared returns a boolean indicating if a field with the given name was
  24314. // cleared in this mutation.
  24315. func (m *WxCardMutation) FieldCleared(name string) bool {
  24316. _, ok := m.clearedFields[name]
  24317. return ok
  24318. }
  24319. // ClearField clears the value of the field with the given name. It returns an
  24320. // error if the field is not defined in the schema.
  24321. func (m *WxCardMutation) ClearField(name string) error {
  24322. switch name {
  24323. case wxcard.FieldDeletedAt:
  24324. m.ClearDeletedAt()
  24325. return nil
  24326. case wxcard.FieldUserID:
  24327. m.ClearUserID()
  24328. return nil
  24329. case wxcard.FieldWxUserID:
  24330. m.ClearWxUserID()
  24331. return nil
  24332. case wxcard.FieldEmail:
  24333. m.ClearEmail()
  24334. return nil
  24335. case wxcard.FieldAPIBase:
  24336. m.ClearAPIBase()
  24337. return nil
  24338. case wxcard.FieldAPIKey:
  24339. m.ClearAPIKey()
  24340. return nil
  24341. case wxcard.FieldAiInfo:
  24342. m.ClearAiInfo()
  24343. return nil
  24344. case wxcard.FieldIntro:
  24345. m.ClearIntro()
  24346. return nil
  24347. }
  24348. return fmt.Errorf("unknown WxCard nullable field %s", name)
  24349. }
  24350. // ResetField resets all changes in the mutation for the field with the given name.
  24351. // It returns an error if the field is not defined in the schema.
  24352. func (m *WxCardMutation) ResetField(name string) error {
  24353. switch name {
  24354. case wxcard.FieldCreatedAt:
  24355. m.ResetCreatedAt()
  24356. return nil
  24357. case wxcard.FieldUpdatedAt:
  24358. m.ResetUpdatedAt()
  24359. return nil
  24360. case wxcard.FieldDeletedAt:
  24361. m.ResetDeletedAt()
  24362. return nil
  24363. case wxcard.FieldUserID:
  24364. m.ResetUserID()
  24365. return nil
  24366. case wxcard.FieldWxUserID:
  24367. m.ResetWxUserID()
  24368. return nil
  24369. case wxcard.FieldAvatar:
  24370. m.ResetAvatar()
  24371. return nil
  24372. case wxcard.FieldLogo:
  24373. m.ResetLogo()
  24374. return nil
  24375. case wxcard.FieldName:
  24376. m.ResetName()
  24377. return nil
  24378. case wxcard.FieldCompany:
  24379. m.ResetCompany()
  24380. return nil
  24381. case wxcard.FieldAddress:
  24382. m.ResetAddress()
  24383. return nil
  24384. case wxcard.FieldPhone:
  24385. m.ResetPhone()
  24386. return nil
  24387. case wxcard.FieldOfficialAccount:
  24388. m.ResetOfficialAccount()
  24389. return nil
  24390. case wxcard.FieldWechatAccount:
  24391. m.ResetWechatAccount()
  24392. return nil
  24393. case wxcard.FieldEmail:
  24394. m.ResetEmail()
  24395. return nil
  24396. case wxcard.FieldAPIBase:
  24397. m.ResetAPIBase()
  24398. return nil
  24399. case wxcard.FieldAPIKey:
  24400. m.ResetAPIKey()
  24401. return nil
  24402. case wxcard.FieldAiInfo:
  24403. m.ResetAiInfo()
  24404. return nil
  24405. case wxcard.FieldIntro:
  24406. m.ResetIntro()
  24407. return nil
  24408. }
  24409. return fmt.Errorf("unknown WxCard field %s", name)
  24410. }
  24411. // AddedEdges returns all edge names that were set/added in this mutation.
  24412. func (m *WxCardMutation) AddedEdges() []string {
  24413. edges := make([]string, 0, 0)
  24414. return edges
  24415. }
  24416. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24417. // name in this mutation.
  24418. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  24419. return nil
  24420. }
  24421. // RemovedEdges returns all edge names that were removed in this mutation.
  24422. func (m *WxCardMutation) RemovedEdges() []string {
  24423. edges := make([]string, 0, 0)
  24424. return edges
  24425. }
  24426. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24427. // the given name in this mutation.
  24428. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  24429. return nil
  24430. }
  24431. // ClearedEdges returns all edge names that were cleared in this mutation.
  24432. func (m *WxCardMutation) ClearedEdges() []string {
  24433. edges := make([]string, 0, 0)
  24434. return edges
  24435. }
  24436. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24437. // was cleared in this mutation.
  24438. func (m *WxCardMutation) EdgeCleared(name string) bool {
  24439. return false
  24440. }
  24441. // ClearEdge clears the value of the edge with the given name. It returns an error
  24442. // if that edge is not defined in the schema.
  24443. func (m *WxCardMutation) ClearEdge(name string) error {
  24444. return fmt.Errorf("unknown WxCard unique edge %s", name)
  24445. }
  24446. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24447. // It returns an error if the edge is not defined in the schema.
  24448. func (m *WxCardMutation) ResetEdge(name string) error {
  24449. return fmt.Errorf("unknown WxCard edge %s", name)
  24450. }
  24451. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  24452. type WxCardUserMutation struct {
  24453. config
  24454. op Op
  24455. typ string
  24456. id *uint64
  24457. created_at *time.Time
  24458. updated_at *time.Time
  24459. deleted_at *time.Time
  24460. wxid *string
  24461. account *string
  24462. avatar *string
  24463. nickname *string
  24464. remark *string
  24465. phone *string
  24466. open_id *string
  24467. union_id *string
  24468. session_key *string
  24469. is_vip *int
  24470. addis_vip *int
  24471. clearedFields map[string]struct{}
  24472. done bool
  24473. oldValue func(context.Context) (*WxCardUser, error)
  24474. predicates []predicate.WxCardUser
  24475. }
  24476. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  24477. // wxcarduserOption allows management of the mutation configuration using functional options.
  24478. type wxcarduserOption func(*WxCardUserMutation)
  24479. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  24480. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  24481. m := &WxCardUserMutation{
  24482. config: c,
  24483. op: op,
  24484. typ: TypeWxCardUser,
  24485. clearedFields: make(map[string]struct{}),
  24486. }
  24487. for _, opt := range opts {
  24488. opt(m)
  24489. }
  24490. return m
  24491. }
  24492. // withWxCardUserID sets the ID field of the mutation.
  24493. func withWxCardUserID(id uint64) wxcarduserOption {
  24494. return func(m *WxCardUserMutation) {
  24495. var (
  24496. err error
  24497. once sync.Once
  24498. value *WxCardUser
  24499. )
  24500. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  24501. once.Do(func() {
  24502. if m.done {
  24503. err = errors.New("querying old values post mutation is not allowed")
  24504. } else {
  24505. value, err = m.Client().WxCardUser.Get(ctx, id)
  24506. }
  24507. })
  24508. return value, err
  24509. }
  24510. m.id = &id
  24511. }
  24512. }
  24513. // withWxCardUser sets the old WxCardUser of the mutation.
  24514. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  24515. return func(m *WxCardUserMutation) {
  24516. m.oldValue = func(context.Context) (*WxCardUser, error) {
  24517. return node, nil
  24518. }
  24519. m.id = &node.ID
  24520. }
  24521. }
  24522. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24523. // executed in a transaction (ent.Tx), a transactional client is returned.
  24524. func (m WxCardUserMutation) Client() *Client {
  24525. client := &Client{config: m.config}
  24526. client.init()
  24527. return client
  24528. }
  24529. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24530. // it returns an error otherwise.
  24531. func (m WxCardUserMutation) Tx() (*Tx, error) {
  24532. if _, ok := m.driver.(*txDriver); !ok {
  24533. return nil, errors.New("ent: mutation is not running in a transaction")
  24534. }
  24535. tx := &Tx{config: m.config}
  24536. tx.init()
  24537. return tx, nil
  24538. }
  24539. // SetID sets the value of the id field. Note that this
  24540. // operation is only accepted on creation of WxCardUser entities.
  24541. func (m *WxCardUserMutation) SetID(id uint64) {
  24542. m.id = &id
  24543. }
  24544. // ID returns the ID value in the mutation. Note that the ID is only available
  24545. // if it was provided to the builder or after it was returned from the database.
  24546. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  24547. if m.id == nil {
  24548. return
  24549. }
  24550. return *m.id, true
  24551. }
  24552. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24553. // That means, if the mutation is applied within a transaction with an isolation level such
  24554. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24555. // or updated by the mutation.
  24556. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  24557. switch {
  24558. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24559. id, exists := m.ID()
  24560. if exists {
  24561. return []uint64{id}, nil
  24562. }
  24563. fallthrough
  24564. case m.op.Is(OpUpdate | OpDelete):
  24565. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  24566. default:
  24567. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24568. }
  24569. }
  24570. // SetCreatedAt sets the "created_at" field.
  24571. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  24572. m.created_at = &t
  24573. }
  24574. // CreatedAt returns the value of the "created_at" field in the mutation.
  24575. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  24576. v := m.created_at
  24577. if v == nil {
  24578. return
  24579. }
  24580. return *v, true
  24581. }
  24582. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  24583. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24585. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24586. if !m.op.Is(OpUpdateOne) {
  24587. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24588. }
  24589. if m.id == nil || m.oldValue == nil {
  24590. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24591. }
  24592. oldValue, err := m.oldValue(ctx)
  24593. if err != nil {
  24594. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24595. }
  24596. return oldValue.CreatedAt, nil
  24597. }
  24598. // ResetCreatedAt resets all changes to the "created_at" field.
  24599. func (m *WxCardUserMutation) ResetCreatedAt() {
  24600. m.created_at = nil
  24601. }
  24602. // SetUpdatedAt sets the "updated_at" field.
  24603. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  24604. m.updated_at = &t
  24605. }
  24606. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24607. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  24608. v := m.updated_at
  24609. if v == nil {
  24610. return
  24611. }
  24612. return *v, true
  24613. }
  24614. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  24615. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24617. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24618. if !m.op.Is(OpUpdateOne) {
  24619. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24620. }
  24621. if m.id == nil || m.oldValue == nil {
  24622. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24623. }
  24624. oldValue, err := m.oldValue(ctx)
  24625. if err != nil {
  24626. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24627. }
  24628. return oldValue.UpdatedAt, nil
  24629. }
  24630. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24631. func (m *WxCardUserMutation) ResetUpdatedAt() {
  24632. m.updated_at = nil
  24633. }
  24634. // SetDeletedAt sets the "deleted_at" field.
  24635. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  24636. m.deleted_at = &t
  24637. }
  24638. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24639. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  24640. v := m.deleted_at
  24641. if v == nil {
  24642. return
  24643. }
  24644. return *v, true
  24645. }
  24646. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  24647. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24649. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24650. if !m.op.Is(OpUpdateOne) {
  24651. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24652. }
  24653. if m.id == nil || m.oldValue == nil {
  24654. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24655. }
  24656. oldValue, err := m.oldValue(ctx)
  24657. if err != nil {
  24658. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24659. }
  24660. return oldValue.DeletedAt, nil
  24661. }
  24662. // ClearDeletedAt clears the value of the "deleted_at" field.
  24663. func (m *WxCardUserMutation) ClearDeletedAt() {
  24664. m.deleted_at = nil
  24665. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  24666. }
  24667. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24668. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  24669. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  24670. return ok
  24671. }
  24672. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24673. func (m *WxCardUserMutation) ResetDeletedAt() {
  24674. m.deleted_at = nil
  24675. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  24676. }
  24677. // SetWxid sets the "wxid" field.
  24678. func (m *WxCardUserMutation) SetWxid(s string) {
  24679. m.wxid = &s
  24680. }
  24681. // Wxid returns the value of the "wxid" field in the mutation.
  24682. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  24683. v := m.wxid
  24684. if v == nil {
  24685. return
  24686. }
  24687. return *v, true
  24688. }
  24689. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  24690. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24692. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  24693. if !m.op.Is(OpUpdateOne) {
  24694. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  24695. }
  24696. if m.id == nil || m.oldValue == nil {
  24697. return v, errors.New("OldWxid requires an ID field in the mutation")
  24698. }
  24699. oldValue, err := m.oldValue(ctx)
  24700. if err != nil {
  24701. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  24702. }
  24703. return oldValue.Wxid, nil
  24704. }
  24705. // ResetWxid resets all changes to the "wxid" field.
  24706. func (m *WxCardUserMutation) ResetWxid() {
  24707. m.wxid = nil
  24708. }
  24709. // SetAccount sets the "account" field.
  24710. func (m *WxCardUserMutation) SetAccount(s string) {
  24711. m.account = &s
  24712. }
  24713. // Account returns the value of the "account" field in the mutation.
  24714. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  24715. v := m.account
  24716. if v == nil {
  24717. return
  24718. }
  24719. return *v, true
  24720. }
  24721. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  24722. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24724. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  24725. if !m.op.Is(OpUpdateOne) {
  24726. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  24727. }
  24728. if m.id == nil || m.oldValue == nil {
  24729. return v, errors.New("OldAccount requires an ID field in the mutation")
  24730. }
  24731. oldValue, err := m.oldValue(ctx)
  24732. if err != nil {
  24733. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  24734. }
  24735. return oldValue.Account, nil
  24736. }
  24737. // ResetAccount resets all changes to the "account" field.
  24738. func (m *WxCardUserMutation) ResetAccount() {
  24739. m.account = nil
  24740. }
  24741. // SetAvatar sets the "avatar" field.
  24742. func (m *WxCardUserMutation) SetAvatar(s string) {
  24743. m.avatar = &s
  24744. }
  24745. // Avatar returns the value of the "avatar" field in the mutation.
  24746. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  24747. v := m.avatar
  24748. if v == nil {
  24749. return
  24750. }
  24751. return *v, true
  24752. }
  24753. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  24754. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24756. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  24757. if !m.op.Is(OpUpdateOne) {
  24758. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  24759. }
  24760. if m.id == nil || m.oldValue == nil {
  24761. return v, errors.New("OldAvatar requires an ID field in the mutation")
  24762. }
  24763. oldValue, err := m.oldValue(ctx)
  24764. if err != nil {
  24765. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  24766. }
  24767. return oldValue.Avatar, nil
  24768. }
  24769. // ResetAvatar resets all changes to the "avatar" field.
  24770. func (m *WxCardUserMutation) ResetAvatar() {
  24771. m.avatar = nil
  24772. }
  24773. // SetNickname sets the "nickname" field.
  24774. func (m *WxCardUserMutation) SetNickname(s string) {
  24775. m.nickname = &s
  24776. }
  24777. // Nickname returns the value of the "nickname" field in the mutation.
  24778. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  24779. v := m.nickname
  24780. if v == nil {
  24781. return
  24782. }
  24783. return *v, true
  24784. }
  24785. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  24786. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24788. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  24789. if !m.op.Is(OpUpdateOne) {
  24790. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  24791. }
  24792. if m.id == nil || m.oldValue == nil {
  24793. return v, errors.New("OldNickname requires an ID field in the mutation")
  24794. }
  24795. oldValue, err := m.oldValue(ctx)
  24796. if err != nil {
  24797. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  24798. }
  24799. return oldValue.Nickname, nil
  24800. }
  24801. // ResetNickname resets all changes to the "nickname" field.
  24802. func (m *WxCardUserMutation) ResetNickname() {
  24803. m.nickname = nil
  24804. }
  24805. // SetRemark sets the "remark" field.
  24806. func (m *WxCardUserMutation) SetRemark(s string) {
  24807. m.remark = &s
  24808. }
  24809. // Remark returns the value of the "remark" field in the mutation.
  24810. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  24811. v := m.remark
  24812. if v == nil {
  24813. return
  24814. }
  24815. return *v, true
  24816. }
  24817. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  24818. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24820. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  24821. if !m.op.Is(OpUpdateOne) {
  24822. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  24823. }
  24824. if m.id == nil || m.oldValue == nil {
  24825. return v, errors.New("OldRemark requires an ID field in the mutation")
  24826. }
  24827. oldValue, err := m.oldValue(ctx)
  24828. if err != nil {
  24829. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  24830. }
  24831. return oldValue.Remark, nil
  24832. }
  24833. // ResetRemark resets all changes to the "remark" field.
  24834. func (m *WxCardUserMutation) ResetRemark() {
  24835. m.remark = nil
  24836. }
  24837. // SetPhone sets the "phone" field.
  24838. func (m *WxCardUserMutation) SetPhone(s string) {
  24839. m.phone = &s
  24840. }
  24841. // Phone returns the value of the "phone" field in the mutation.
  24842. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  24843. v := m.phone
  24844. if v == nil {
  24845. return
  24846. }
  24847. return *v, true
  24848. }
  24849. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  24850. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24852. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  24853. if !m.op.Is(OpUpdateOne) {
  24854. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  24855. }
  24856. if m.id == nil || m.oldValue == nil {
  24857. return v, errors.New("OldPhone requires an ID field in the mutation")
  24858. }
  24859. oldValue, err := m.oldValue(ctx)
  24860. if err != nil {
  24861. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  24862. }
  24863. return oldValue.Phone, nil
  24864. }
  24865. // ResetPhone resets all changes to the "phone" field.
  24866. func (m *WxCardUserMutation) ResetPhone() {
  24867. m.phone = nil
  24868. }
  24869. // SetOpenID sets the "open_id" field.
  24870. func (m *WxCardUserMutation) SetOpenID(s string) {
  24871. m.open_id = &s
  24872. }
  24873. // OpenID returns the value of the "open_id" field in the mutation.
  24874. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  24875. v := m.open_id
  24876. if v == nil {
  24877. return
  24878. }
  24879. return *v, true
  24880. }
  24881. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  24882. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24884. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  24885. if !m.op.Is(OpUpdateOne) {
  24886. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  24887. }
  24888. if m.id == nil || m.oldValue == nil {
  24889. return v, errors.New("OldOpenID requires an ID field in the mutation")
  24890. }
  24891. oldValue, err := m.oldValue(ctx)
  24892. if err != nil {
  24893. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  24894. }
  24895. return oldValue.OpenID, nil
  24896. }
  24897. // ResetOpenID resets all changes to the "open_id" field.
  24898. func (m *WxCardUserMutation) ResetOpenID() {
  24899. m.open_id = nil
  24900. }
  24901. // SetUnionID sets the "union_id" field.
  24902. func (m *WxCardUserMutation) SetUnionID(s string) {
  24903. m.union_id = &s
  24904. }
  24905. // UnionID returns the value of the "union_id" field in the mutation.
  24906. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  24907. v := m.union_id
  24908. if v == nil {
  24909. return
  24910. }
  24911. return *v, true
  24912. }
  24913. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  24914. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24916. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  24917. if !m.op.Is(OpUpdateOne) {
  24918. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  24919. }
  24920. if m.id == nil || m.oldValue == nil {
  24921. return v, errors.New("OldUnionID requires an ID field in the mutation")
  24922. }
  24923. oldValue, err := m.oldValue(ctx)
  24924. if err != nil {
  24925. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  24926. }
  24927. return oldValue.UnionID, nil
  24928. }
  24929. // ResetUnionID resets all changes to the "union_id" field.
  24930. func (m *WxCardUserMutation) ResetUnionID() {
  24931. m.union_id = nil
  24932. }
  24933. // SetSessionKey sets the "session_key" field.
  24934. func (m *WxCardUserMutation) SetSessionKey(s string) {
  24935. m.session_key = &s
  24936. }
  24937. // SessionKey returns the value of the "session_key" field in the mutation.
  24938. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  24939. v := m.session_key
  24940. if v == nil {
  24941. return
  24942. }
  24943. return *v, true
  24944. }
  24945. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  24946. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24948. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  24949. if !m.op.Is(OpUpdateOne) {
  24950. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  24951. }
  24952. if m.id == nil || m.oldValue == nil {
  24953. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  24954. }
  24955. oldValue, err := m.oldValue(ctx)
  24956. if err != nil {
  24957. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  24958. }
  24959. return oldValue.SessionKey, nil
  24960. }
  24961. // ResetSessionKey resets all changes to the "session_key" field.
  24962. func (m *WxCardUserMutation) ResetSessionKey() {
  24963. m.session_key = nil
  24964. }
  24965. // SetIsVip sets the "is_vip" field.
  24966. func (m *WxCardUserMutation) SetIsVip(i int) {
  24967. m.is_vip = &i
  24968. m.addis_vip = nil
  24969. }
  24970. // IsVip returns the value of the "is_vip" field in the mutation.
  24971. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  24972. v := m.is_vip
  24973. if v == nil {
  24974. return
  24975. }
  24976. return *v, true
  24977. }
  24978. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  24979. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24981. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  24982. if !m.op.Is(OpUpdateOne) {
  24983. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  24984. }
  24985. if m.id == nil || m.oldValue == nil {
  24986. return v, errors.New("OldIsVip requires an ID field in the mutation")
  24987. }
  24988. oldValue, err := m.oldValue(ctx)
  24989. if err != nil {
  24990. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  24991. }
  24992. return oldValue.IsVip, nil
  24993. }
  24994. // AddIsVip adds i to the "is_vip" field.
  24995. func (m *WxCardUserMutation) AddIsVip(i int) {
  24996. if m.addis_vip != nil {
  24997. *m.addis_vip += i
  24998. } else {
  24999. m.addis_vip = &i
  25000. }
  25001. }
  25002. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  25003. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  25004. v := m.addis_vip
  25005. if v == nil {
  25006. return
  25007. }
  25008. return *v, true
  25009. }
  25010. // ResetIsVip resets all changes to the "is_vip" field.
  25011. func (m *WxCardUserMutation) ResetIsVip() {
  25012. m.is_vip = nil
  25013. m.addis_vip = nil
  25014. }
  25015. // Where appends a list predicates to the WxCardUserMutation builder.
  25016. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  25017. m.predicates = append(m.predicates, ps...)
  25018. }
  25019. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  25020. // users can use type-assertion to append predicates that do not depend on any generated package.
  25021. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  25022. p := make([]predicate.WxCardUser, len(ps))
  25023. for i := range ps {
  25024. p[i] = ps[i]
  25025. }
  25026. m.Where(p...)
  25027. }
  25028. // Op returns the operation name.
  25029. func (m *WxCardUserMutation) Op() Op {
  25030. return m.op
  25031. }
  25032. // SetOp allows setting the mutation operation.
  25033. func (m *WxCardUserMutation) SetOp(op Op) {
  25034. m.op = op
  25035. }
  25036. // Type returns the node type of this mutation (WxCardUser).
  25037. func (m *WxCardUserMutation) Type() string {
  25038. return m.typ
  25039. }
  25040. // Fields returns all fields that were changed during this mutation. Note that in
  25041. // order to get all numeric fields that were incremented/decremented, call
  25042. // AddedFields().
  25043. func (m *WxCardUserMutation) Fields() []string {
  25044. fields := make([]string, 0, 13)
  25045. if m.created_at != nil {
  25046. fields = append(fields, wxcarduser.FieldCreatedAt)
  25047. }
  25048. if m.updated_at != nil {
  25049. fields = append(fields, wxcarduser.FieldUpdatedAt)
  25050. }
  25051. if m.deleted_at != nil {
  25052. fields = append(fields, wxcarduser.FieldDeletedAt)
  25053. }
  25054. if m.wxid != nil {
  25055. fields = append(fields, wxcarduser.FieldWxid)
  25056. }
  25057. if m.account != nil {
  25058. fields = append(fields, wxcarduser.FieldAccount)
  25059. }
  25060. if m.avatar != nil {
  25061. fields = append(fields, wxcarduser.FieldAvatar)
  25062. }
  25063. if m.nickname != nil {
  25064. fields = append(fields, wxcarduser.FieldNickname)
  25065. }
  25066. if m.remark != nil {
  25067. fields = append(fields, wxcarduser.FieldRemark)
  25068. }
  25069. if m.phone != nil {
  25070. fields = append(fields, wxcarduser.FieldPhone)
  25071. }
  25072. if m.open_id != nil {
  25073. fields = append(fields, wxcarduser.FieldOpenID)
  25074. }
  25075. if m.union_id != nil {
  25076. fields = append(fields, wxcarduser.FieldUnionID)
  25077. }
  25078. if m.session_key != nil {
  25079. fields = append(fields, wxcarduser.FieldSessionKey)
  25080. }
  25081. if m.is_vip != nil {
  25082. fields = append(fields, wxcarduser.FieldIsVip)
  25083. }
  25084. return fields
  25085. }
  25086. // Field returns the value of a field with the given name. The second boolean
  25087. // return value indicates that this field was not set, or was not defined in the
  25088. // schema.
  25089. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  25090. switch name {
  25091. case wxcarduser.FieldCreatedAt:
  25092. return m.CreatedAt()
  25093. case wxcarduser.FieldUpdatedAt:
  25094. return m.UpdatedAt()
  25095. case wxcarduser.FieldDeletedAt:
  25096. return m.DeletedAt()
  25097. case wxcarduser.FieldWxid:
  25098. return m.Wxid()
  25099. case wxcarduser.FieldAccount:
  25100. return m.Account()
  25101. case wxcarduser.FieldAvatar:
  25102. return m.Avatar()
  25103. case wxcarduser.FieldNickname:
  25104. return m.Nickname()
  25105. case wxcarduser.FieldRemark:
  25106. return m.Remark()
  25107. case wxcarduser.FieldPhone:
  25108. return m.Phone()
  25109. case wxcarduser.FieldOpenID:
  25110. return m.OpenID()
  25111. case wxcarduser.FieldUnionID:
  25112. return m.UnionID()
  25113. case wxcarduser.FieldSessionKey:
  25114. return m.SessionKey()
  25115. case wxcarduser.FieldIsVip:
  25116. return m.IsVip()
  25117. }
  25118. return nil, false
  25119. }
  25120. // OldField returns the old value of the field from the database. An error is
  25121. // returned if the mutation operation is not UpdateOne, or the query to the
  25122. // database failed.
  25123. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25124. switch name {
  25125. case wxcarduser.FieldCreatedAt:
  25126. return m.OldCreatedAt(ctx)
  25127. case wxcarduser.FieldUpdatedAt:
  25128. return m.OldUpdatedAt(ctx)
  25129. case wxcarduser.FieldDeletedAt:
  25130. return m.OldDeletedAt(ctx)
  25131. case wxcarduser.FieldWxid:
  25132. return m.OldWxid(ctx)
  25133. case wxcarduser.FieldAccount:
  25134. return m.OldAccount(ctx)
  25135. case wxcarduser.FieldAvatar:
  25136. return m.OldAvatar(ctx)
  25137. case wxcarduser.FieldNickname:
  25138. return m.OldNickname(ctx)
  25139. case wxcarduser.FieldRemark:
  25140. return m.OldRemark(ctx)
  25141. case wxcarduser.FieldPhone:
  25142. return m.OldPhone(ctx)
  25143. case wxcarduser.FieldOpenID:
  25144. return m.OldOpenID(ctx)
  25145. case wxcarduser.FieldUnionID:
  25146. return m.OldUnionID(ctx)
  25147. case wxcarduser.FieldSessionKey:
  25148. return m.OldSessionKey(ctx)
  25149. case wxcarduser.FieldIsVip:
  25150. return m.OldIsVip(ctx)
  25151. }
  25152. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  25153. }
  25154. // SetField sets the value of a field with the given name. It returns an error if
  25155. // the field is not defined in the schema, or if the type mismatched the field
  25156. // type.
  25157. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  25158. switch name {
  25159. case wxcarduser.FieldCreatedAt:
  25160. v, ok := value.(time.Time)
  25161. if !ok {
  25162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25163. }
  25164. m.SetCreatedAt(v)
  25165. return nil
  25166. case wxcarduser.FieldUpdatedAt:
  25167. v, ok := value.(time.Time)
  25168. if !ok {
  25169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25170. }
  25171. m.SetUpdatedAt(v)
  25172. return nil
  25173. case wxcarduser.FieldDeletedAt:
  25174. v, ok := value.(time.Time)
  25175. if !ok {
  25176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25177. }
  25178. m.SetDeletedAt(v)
  25179. return nil
  25180. case wxcarduser.FieldWxid:
  25181. v, ok := value.(string)
  25182. if !ok {
  25183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25184. }
  25185. m.SetWxid(v)
  25186. return nil
  25187. case wxcarduser.FieldAccount:
  25188. v, ok := value.(string)
  25189. if !ok {
  25190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25191. }
  25192. m.SetAccount(v)
  25193. return nil
  25194. case wxcarduser.FieldAvatar:
  25195. v, ok := value.(string)
  25196. if !ok {
  25197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25198. }
  25199. m.SetAvatar(v)
  25200. return nil
  25201. case wxcarduser.FieldNickname:
  25202. v, ok := value.(string)
  25203. if !ok {
  25204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25205. }
  25206. m.SetNickname(v)
  25207. return nil
  25208. case wxcarduser.FieldRemark:
  25209. v, ok := value.(string)
  25210. if !ok {
  25211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25212. }
  25213. m.SetRemark(v)
  25214. return nil
  25215. case wxcarduser.FieldPhone:
  25216. v, ok := value.(string)
  25217. if !ok {
  25218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25219. }
  25220. m.SetPhone(v)
  25221. return nil
  25222. case wxcarduser.FieldOpenID:
  25223. v, ok := value.(string)
  25224. if !ok {
  25225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25226. }
  25227. m.SetOpenID(v)
  25228. return nil
  25229. case wxcarduser.FieldUnionID:
  25230. v, ok := value.(string)
  25231. if !ok {
  25232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25233. }
  25234. m.SetUnionID(v)
  25235. return nil
  25236. case wxcarduser.FieldSessionKey:
  25237. v, ok := value.(string)
  25238. if !ok {
  25239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25240. }
  25241. m.SetSessionKey(v)
  25242. return nil
  25243. case wxcarduser.FieldIsVip:
  25244. v, ok := value.(int)
  25245. if !ok {
  25246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25247. }
  25248. m.SetIsVip(v)
  25249. return nil
  25250. }
  25251. return fmt.Errorf("unknown WxCardUser field %s", name)
  25252. }
  25253. // AddedFields returns all numeric fields that were incremented/decremented during
  25254. // this mutation.
  25255. func (m *WxCardUserMutation) AddedFields() []string {
  25256. var fields []string
  25257. if m.addis_vip != nil {
  25258. fields = append(fields, wxcarduser.FieldIsVip)
  25259. }
  25260. return fields
  25261. }
  25262. // AddedField returns the numeric value that was incremented/decremented on a field
  25263. // with the given name. The second boolean return value indicates that this field
  25264. // was not set, or was not defined in the schema.
  25265. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  25266. switch name {
  25267. case wxcarduser.FieldIsVip:
  25268. return m.AddedIsVip()
  25269. }
  25270. return nil, false
  25271. }
  25272. // AddField adds the value to the field with the given name. It returns an error if
  25273. // the field is not defined in the schema, or if the type mismatched the field
  25274. // type.
  25275. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  25276. switch name {
  25277. case wxcarduser.FieldIsVip:
  25278. v, ok := value.(int)
  25279. if !ok {
  25280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25281. }
  25282. m.AddIsVip(v)
  25283. return nil
  25284. }
  25285. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  25286. }
  25287. // ClearedFields returns all nullable fields that were cleared during this
  25288. // mutation.
  25289. func (m *WxCardUserMutation) ClearedFields() []string {
  25290. var fields []string
  25291. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  25292. fields = append(fields, wxcarduser.FieldDeletedAt)
  25293. }
  25294. return fields
  25295. }
  25296. // FieldCleared returns a boolean indicating if a field with the given name was
  25297. // cleared in this mutation.
  25298. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  25299. _, ok := m.clearedFields[name]
  25300. return ok
  25301. }
  25302. // ClearField clears the value of the field with the given name. It returns an
  25303. // error if the field is not defined in the schema.
  25304. func (m *WxCardUserMutation) ClearField(name string) error {
  25305. switch name {
  25306. case wxcarduser.FieldDeletedAt:
  25307. m.ClearDeletedAt()
  25308. return nil
  25309. }
  25310. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  25311. }
  25312. // ResetField resets all changes in the mutation for the field with the given name.
  25313. // It returns an error if the field is not defined in the schema.
  25314. func (m *WxCardUserMutation) ResetField(name string) error {
  25315. switch name {
  25316. case wxcarduser.FieldCreatedAt:
  25317. m.ResetCreatedAt()
  25318. return nil
  25319. case wxcarduser.FieldUpdatedAt:
  25320. m.ResetUpdatedAt()
  25321. return nil
  25322. case wxcarduser.FieldDeletedAt:
  25323. m.ResetDeletedAt()
  25324. return nil
  25325. case wxcarduser.FieldWxid:
  25326. m.ResetWxid()
  25327. return nil
  25328. case wxcarduser.FieldAccount:
  25329. m.ResetAccount()
  25330. return nil
  25331. case wxcarduser.FieldAvatar:
  25332. m.ResetAvatar()
  25333. return nil
  25334. case wxcarduser.FieldNickname:
  25335. m.ResetNickname()
  25336. return nil
  25337. case wxcarduser.FieldRemark:
  25338. m.ResetRemark()
  25339. return nil
  25340. case wxcarduser.FieldPhone:
  25341. m.ResetPhone()
  25342. return nil
  25343. case wxcarduser.FieldOpenID:
  25344. m.ResetOpenID()
  25345. return nil
  25346. case wxcarduser.FieldUnionID:
  25347. m.ResetUnionID()
  25348. return nil
  25349. case wxcarduser.FieldSessionKey:
  25350. m.ResetSessionKey()
  25351. return nil
  25352. case wxcarduser.FieldIsVip:
  25353. m.ResetIsVip()
  25354. return nil
  25355. }
  25356. return fmt.Errorf("unknown WxCardUser field %s", name)
  25357. }
  25358. // AddedEdges returns all edge names that were set/added in this mutation.
  25359. func (m *WxCardUserMutation) AddedEdges() []string {
  25360. edges := make([]string, 0, 0)
  25361. return edges
  25362. }
  25363. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25364. // name in this mutation.
  25365. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  25366. return nil
  25367. }
  25368. // RemovedEdges returns all edge names that were removed in this mutation.
  25369. func (m *WxCardUserMutation) RemovedEdges() []string {
  25370. edges := make([]string, 0, 0)
  25371. return edges
  25372. }
  25373. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25374. // the given name in this mutation.
  25375. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  25376. return nil
  25377. }
  25378. // ClearedEdges returns all edge names that were cleared in this mutation.
  25379. func (m *WxCardUserMutation) ClearedEdges() []string {
  25380. edges := make([]string, 0, 0)
  25381. return edges
  25382. }
  25383. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25384. // was cleared in this mutation.
  25385. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  25386. return false
  25387. }
  25388. // ClearEdge clears the value of the edge with the given name. It returns an error
  25389. // if that edge is not defined in the schema.
  25390. func (m *WxCardUserMutation) ClearEdge(name string) error {
  25391. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  25392. }
  25393. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25394. // It returns an error if the edge is not defined in the schema.
  25395. func (m *WxCardUserMutation) ResetEdge(name string) error {
  25396. return fmt.Errorf("unknown WxCardUser edge %s", name)
  25397. }
  25398. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  25399. type WxCardVisitMutation struct {
  25400. config
  25401. op Op
  25402. typ string
  25403. id *uint64
  25404. created_at *time.Time
  25405. updated_at *time.Time
  25406. deleted_at *time.Time
  25407. user_id *uint64
  25408. adduser_id *int64
  25409. bot_id *uint64
  25410. addbot_id *int64
  25411. bot_type *uint8
  25412. addbot_type *int8
  25413. clearedFields map[string]struct{}
  25414. done bool
  25415. oldValue func(context.Context) (*WxCardVisit, error)
  25416. predicates []predicate.WxCardVisit
  25417. }
  25418. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  25419. // wxcardvisitOption allows management of the mutation configuration using functional options.
  25420. type wxcardvisitOption func(*WxCardVisitMutation)
  25421. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  25422. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  25423. m := &WxCardVisitMutation{
  25424. config: c,
  25425. op: op,
  25426. typ: TypeWxCardVisit,
  25427. clearedFields: make(map[string]struct{}),
  25428. }
  25429. for _, opt := range opts {
  25430. opt(m)
  25431. }
  25432. return m
  25433. }
  25434. // withWxCardVisitID sets the ID field of the mutation.
  25435. func withWxCardVisitID(id uint64) wxcardvisitOption {
  25436. return func(m *WxCardVisitMutation) {
  25437. var (
  25438. err error
  25439. once sync.Once
  25440. value *WxCardVisit
  25441. )
  25442. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  25443. once.Do(func() {
  25444. if m.done {
  25445. err = errors.New("querying old values post mutation is not allowed")
  25446. } else {
  25447. value, err = m.Client().WxCardVisit.Get(ctx, id)
  25448. }
  25449. })
  25450. return value, err
  25451. }
  25452. m.id = &id
  25453. }
  25454. }
  25455. // withWxCardVisit sets the old WxCardVisit of the mutation.
  25456. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  25457. return func(m *WxCardVisitMutation) {
  25458. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  25459. return node, nil
  25460. }
  25461. m.id = &node.ID
  25462. }
  25463. }
  25464. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25465. // executed in a transaction (ent.Tx), a transactional client is returned.
  25466. func (m WxCardVisitMutation) Client() *Client {
  25467. client := &Client{config: m.config}
  25468. client.init()
  25469. return client
  25470. }
  25471. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25472. // it returns an error otherwise.
  25473. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  25474. if _, ok := m.driver.(*txDriver); !ok {
  25475. return nil, errors.New("ent: mutation is not running in a transaction")
  25476. }
  25477. tx := &Tx{config: m.config}
  25478. tx.init()
  25479. return tx, nil
  25480. }
  25481. // SetID sets the value of the id field. Note that this
  25482. // operation is only accepted on creation of WxCardVisit entities.
  25483. func (m *WxCardVisitMutation) SetID(id uint64) {
  25484. m.id = &id
  25485. }
  25486. // ID returns the ID value in the mutation. Note that the ID is only available
  25487. // if it was provided to the builder or after it was returned from the database.
  25488. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  25489. if m.id == nil {
  25490. return
  25491. }
  25492. return *m.id, true
  25493. }
  25494. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25495. // That means, if the mutation is applied within a transaction with an isolation level such
  25496. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25497. // or updated by the mutation.
  25498. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  25499. switch {
  25500. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25501. id, exists := m.ID()
  25502. if exists {
  25503. return []uint64{id}, nil
  25504. }
  25505. fallthrough
  25506. case m.op.Is(OpUpdate | OpDelete):
  25507. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  25508. default:
  25509. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25510. }
  25511. }
  25512. // SetCreatedAt sets the "created_at" field.
  25513. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  25514. m.created_at = &t
  25515. }
  25516. // CreatedAt returns the value of the "created_at" field in the mutation.
  25517. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  25518. v := m.created_at
  25519. if v == nil {
  25520. return
  25521. }
  25522. return *v, true
  25523. }
  25524. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  25525. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25527. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25528. if !m.op.Is(OpUpdateOne) {
  25529. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25530. }
  25531. if m.id == nil || m.oldValue == nil {
  25532. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25533. }
  25534. oldValue, err := m.oldValue(ctx)
  25535. if err != nil {
  25536. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25537. }
  25538. return oldValue.CreatedAt, nil
  25539. }
  25540. // ResetCreatedAt resets all changes to the "created_at" field.
  25541. func (m *WxCardVisitMutation) ResetCreatedAt() {
  25542. m.created_at = nil
  25543. }
  25544. // SetUpdatedAt sets the "updated_at" field.
  25545. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  25546. m.updated_at = &t
  25547. }
  25548. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25549. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  25550. v := m.updated_at
  25551. if v == nil {
  25552. return
  25553. }
  25554. return *v, true
  25555. }
  25556. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  25557. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25559. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25560. if !m.op.Is(OpUpdateOne) {
  25561. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25562. }
  25563. if m.id == nil || m.oldValue == nil {
  25564. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25565. }
  25566. oldValue, err := m.oldValue(ctx)
  25567. if err != nil {
  25568. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25569. }
  25570. return oldValue.UpdatedAt, nil
  25571. }
  25572. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25573. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  25574. m.updated_at = nil
  25575. }
  25576. // SetDeletedAt sets the "deleted_at" field.
  25577. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  25578. m.deleted_at = &t
  25579. }
  25580. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25581. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  25582. v := m.deleted_at
  25583. if v == nil {
  25584. return
  25585. }
  25586. return *v, true
  25587. }
  25588. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  25589. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25591. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25592. if !m.op.Is(OpUpdateOne) {
  25593. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25594. }
  25595. if m.id == nil || m.oldValue == nil {
  25596. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25597. }
  25598. oldValue, err := m.oldValue(ctx)
  25599. if err != nil {
  25600. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25601. }
  25602. return oldValue.DeletedAt, nil
  25603. }
  25604. // ClearDeletedAt clears the value of the "deleted_at" field.
  25605. func (m *WxCardVisitMutation) ClearDeletedAt() {
  25606. m.deleted_at = nil
  25607. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  25608. }
  25609. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25610. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  25611. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  25612. return ok
  25613. }
  25614. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25615. func (m *WxCardVisitMutation) ResetDeletedAt() {
  25616. m.deleted_at = nil
  25617. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  25618. }
  25619. // SetUserID sets the "user_id" field.
  25620. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  25621. m.user_id = &u
  25622. m.adduser_id = nil
  25623. }
  25624. // UserID returns the value of the "user_id" field in the mutation.
  25625. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  25626. v := m.user_id
  25627. if v == nil {
  25628. return
  25629. }
  25630. return *v, true
  25631. }
  25632. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  25633. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25635. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  25636. if !m.op.Is(OpUpdateOne) {
  25637. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  25638. }
  25639. if m.id == nil || m.oldValue == nil {
  25640. return v, errors.New("OldUserID requires an ID field in the mutation")
  25641. }
  25642. oldValue, err := m.oldValue(ctx)
  25643. if err != nil {
  25644. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  25645. }
  25646. return oldValue.UserID, nil
  25647. }
  25648. // AddUserID adds u to the "user_id" field.
  25649. func (m *WxCardVisitMutation) AddUserID(u int64) {
  25650. if m.adduser_id != nil {
  25651. *m.adduser_id += u
  25652. } else {
  25653. m.adduser_id = &u
  25654. }
  25655. }
  25656. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  25657. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  25658. v := m.adduser_id
  25659. if v == nil {
  25660. return
  25661. }
  25662. return *v, true
  25663. }
  25664. // ClearUserID clears the value of the "user_id" field.
  25665. func (m *WxCardVisitMutation) ClearUserID() {
  25666. m.user_id = nil
  25667. m.adduser_id = nil
  25668. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  25669. }
  25670. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  25671. func (m *WxCardVisitMutation) UserIDCleared() bool {
  25672. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  25673. return ok
  25674. }
  25675. // ResetUserID resets all changes to the "user_id" field.
  25676. func (m *WxCardVisitMutation) ResetUserID() {
  25677. m.user_id = nil
  25678. m.adduser_id = nil
  25679. delete(m.clearedFields, wxcardvisit.FieldUserID)
  25680. }
  25681. // SetBotID sets the "bot_id" field.
  25682. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  25683. m.bot_id = &u
  25684. m.addbot_id = nil
  25685. }
  25686. // BotID returns the value of the "bot_id" field in the mutation.
  25687. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  25688. v := m.bot_id
  25689. if v == nil {
  25690. return
  25691. }
  25692. return *v, true
  25693. }
  25694. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  25695. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25697. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  25698. if !m.op.Is(OpUpdateOne) {
  25699. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  25700. }
  25701. if m.id == nil || m.oldValue == nil {
  25702. return v, errors.New("OldBotID requires an ID field in the mutation")
  25703. }
  25704. oldValue, err := m.oldValue(ctx)
  25705. if err != nil {
  25706. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  25707. }
  25708. return oldValue.BotID, nil
  25709. }
  25710. // AddBotID adds u to the "bot_id" field.
  25711. func (m *WxCardVisitMutation) AddBotID(u int64) {
  25712. if m.addbot_id != nil {
  25713. *m.addbot_id += u
  25714. } else {
  25715. m.addbot_id = &u
  25716. }
  25717. }
  25718. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  25719. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  25720. v := m.addbot_id
  25721. if v == nil {
  25722. return
  25723. }
  25724. return *v, true
  25725. }
  25726. // ResetBotID resets all changes to the "bot_id" field.
  25727. func (m *WxCardVisitMutation) ResetBotID() {
  25728. m.bot_id = nil
  25729. m.addbot_id = nil
  25730. }
  25731. // SetBotType sets the "bot_type" field.
  25732. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  25733. m.bot_type = &u
  25734. m.addbot_type = nil
  25735. }
  25736. // BotType returns the value of the "bot_type" field in the mutation.
  25737. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  25738. v := m.bot_type
  25739. if v == nil {
  25740. return
  25741. }
  25742. return *v, true
  25743. }
  25744. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  25745. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25747. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  25748. if !m.op.Is(OpUpdateOne) {
  25749. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  25750. }
  25751. if m.id == nil || m.oldValue == nil {
  25752. return v, errors.New("OldBotType requires an ID field in the mutation")
  25753. }
  25754. oldValue, err := m.oldValue(ctx)
  25755. if err != nil {
  25756. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  25757. }
  25758. return oldValue.BotType, nil
  25759. }
  25760. // AddBotType adds u to the "bot_type" field.
  25761. func (m *WxCardVisitMutation) AddBotType(u int8) {
  25762. if m.addbot_type != nil {
  25763. *m.addbot_type += u
  25764. } else {
  25765. m.addbot_type = &u
  25766. }
  25767. }
  25768. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  25769. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  25770. v := m.addbot_type
  25771. if v == nil {
  25772. return
  25773. }
  25774. return *v, true
  25775. }
  25776. // ResetBotType resets all changes to the "bot_type" field.
  25777. func (m *WxCardVisitMutation) ResetBotType() {
  25778. m.bot_type = nil
  25779. m.addbot_type = nil
  25780. }
  25781. // Where appends a list predicates to the WxCardVisitMutation builder.
  25782. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  25783. m.predicates = append(m.predicates, ps...)
  25784. }
  25785. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  25786. // users can use type-assertion to append predicates that do not depend on any generated package.
  25787. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  25788. p := make([]predicate.WxCardVisit, len(ps))
  25789. for i := range ps {
  25790. p[i] = ps[i]
  25791. }
  25792. m.Where(p...)
  25793. }
  25794. // Op returns the operation name.
  25795. func (m *WxCardVisitMutation) Op() Op {
  25796. return m.op
  25797. }
  25798. // SetOp allows setting the mutation operation.
  25799. func (m *WxCardVisitMutation) SetOp(op Op) {
  25800. m.op = op
  25801. }
  25802. // Type returns the node type of this mutation (WxCardVisit).
  25803. func (m *WxCardVisitMutation) Type() string {
  25804. return m.typ
  25805. }
  25806. // Fields returns all fields that were changed during this mutation. Note that in
  25807. // order to get all numeric fields that were incremented/decremented, call
  25808. // AddedFields().
  25809. func (m *WxCardVisitMutation) Fields() []string {
  25810. fields := make([]string, 0, 6)
  25811. if m.created_at != nil {
  25812. fields = append(fields, wxcardvisit.FieldCreatedAt)
  25813. }
  25814. if m.updated_at != nil {
  25815. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  25816. }
  25817. if m.deleted_at != nil {
  25818. fields = append(fields, wxcardvisit.FieldDeletedAt)
  25819. }
  25820. if m.user_id != nil {
  25821. fields = append(fields, wxcardvisit.FieldUserID)
  25822. }
  25823. if m.bot_id != nil {
  25824. fields = append(fields, wxcardvisit.FieldBotID)
  25825. }
  25826. if m.bot_type != nil {
  25827. fields = append(fields, wxcardvisit.FieldBotType)
  25828. }
  25829. return fields
  25830. }
  25831. // Field returns the value of a field with the given name. The second boolean
  25832. // return value indicates that this field was not set, or was not defined in the
  25833. // schema.
  25834. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  25835. switch name {
  25836. case wxcardvisit.FieldCreatedAt:
  25837. return m.CreatedAt()
  25838. case wxcardvisit.FieldUpdatedAt:
  25839. return m.UpdatedAt()
  25840. case wxcardvisit.FieldDeletedAt:
  25841. return m.DeletedAt()
  25842. case wxcardvisit.FieldUserID:
  25843. return m.UserID()
  25844. case wxcardvisit.FieldBotID:
  25845. return m.BotID()
  25846. case wxcardvisit.FieldBotType:
  25847. return m.BotType()
  25848. }
  25849. return nil, false
  25850. }
  25851. // OldField returns the old value of the field from the database. An error is
  25852. // returned if the mutation operation is not UpdateOne, or the query to the
  25853. // database failed.
  25854. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25855. switch name {
  25856. case wxcardvisit.FieldCreatedAt:
  25857. return m.OldCreatedAt(ctx)
  25858. case wxcardvisit.FieldUpdatedAt:
  25859. return m.OldUpdatedAt(ctx)
  25860. case wxcardvisit.FieldDeletedAt:
  25861. return m.OldDeletedAt(ctx)
  25862. case wxcardvisit.FieldUserID:
  25863. return m.OldUserID(ctx)
  25864. case wxcardvisit.FieldBotID:
  25865. return m.OldBotID(ctx)
  25866. case wxcardvisit.FieldBotType:
  25867. return m.OldBotType(ctx)
  25868. }
  25869. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  25870. }
  25871. // SetField sets the value of a field with the given name. It returns an error if
  25872. // the field is not defined in the schema, or if the type mismatched the field
  25873. // type.
  25874. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  25875. switch name {
  25876. case wxcardvisit.FieldCreatedAt:
  25877. v, ok := value.(time.Time)
  25878. if !ok {
  25879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25880. }
  25881. m.SetCreatedAt(v)
  25882. return nil
  25883. case wxcardvisit.FieldUpdatedAt:
  25884. v, ok := value.(time.Time)
  25885. if !ok {
  25886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25887. }
  25888. m.SetUpdatedAt(v)
  25889. return nil
  25890. case wxcardvisit.FieldDeletedAt:
  25891. v, ok := value.(time.Time)
  25892. if !ok {
  25893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25894. }
  25895. m.SetDeletedAt(v)
  25896. return nil
  25897. case wxcardvisit.FieldUserID:
  25898. v, ok := value.(uint64)
  25899. if !ok {
  25900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25901. }
  25902. m.SetUserID(v)
  25903. return nil
  25904. case wxcardvisit.FieldBotID:
  25905. v, ok := value.(uint64)
  25906. if !ok {
  25907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25908. }
  25909. m.SetBotID(v)
  25910. return nil
  25911. case wxcardvisit.FieldBotType:
  25912. v, ok := value.(uint8)
  25913. if !ok {
  25914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25915. }
  25916. m.SetBotType(v)
  25917. return nil
  25918. }
  25919. return fmt.Errorf("unknown WxCardVisit field %s", name)
  25920. }
  25921. // AddedFields returns all numeric fields that were incremented/decremented during
  25922. // this mutation.
  25923. func (m *WxCardVisitMutation) AddedFields() []string {
  25924. var fields []string
  25925. if m.adduser_id != nil {
  25926. fields = append(fields, wxcardvisit.FieldUserID)
  25927. }
  25928. if m.addbot_id != nil {
  25929. fields = append(fields, wxcardvisit.FieldBotID)
  25930. }
  25931. if m.addbot_type != nil {
  25932. fields = append(fields, wxcardvisit.FieldBotType)
  25933. }
  25934. return fields
  25935. }
  25936. // AddedField returns the numeric value that was incremented/decremented on a field
  25937. // with the given name. The second boolean return value indicates that this field
  25938. // was not set, or was not defined in the schema.
  25939. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  25940. switch name {
  25941. case wxcardvisit.FieldUserID:
  25942. return m.AddedUserID()
  25943. case wxcardvisit.FieldBotID:
  25944. return m.AddedBotID()
  25945. case wxcardvisit.FieldBotType:
  25946. return m.AddedBotType()
  25947. }
  25948. return nil, false
  25949. }
  25950. // AddField adds the value to the field with the given name. It returns an error if
  25951. // the field is not defined in the schema, or if the type mismatched the field
  25952. // type.
  25953. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  25954. switch name {
  25955. case wxcardvisit.FieldUserID:
  25956. v, ok := value.(int64)
  25957. if !ok {
  25958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25959. }
  25960. m.AddUserID(v)
  25961. return nil
  25962. case wxcardvisit.FieldBotID:
  25963. v, ok := value.(int64)
  25964. if !ok {
  25965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25966. }
  25967. m.AddBotID(v)
  25968. return nil
  25969. case wxcardvisit.FieldBotType:
  25970. v, ok := value.(int8)
  25971. if !ok {
  25972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25973. }
  25974. m.AddBotType(v)
  25975. return nil
  25976. }
  25977. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  25978. }
  25979. // ClearedFields returns all nullable fields that were cleared during this
  25980. // mutation.
  25981. func (m *WxCardVisitMutation) ClearedFields() []string {
  25982. var fields []string
  25983. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  25984. fields = append(fields, wxcardvisit.FieldDeletedAt)
  25985. }
  25986. if m.FieldCleared(wxcardvisit.FieldUserID) {
  25987. fields = append(fields, wxcardvisit.FieldUserID)
  25988. }
  25989. return fields
  25990. }
  25991. // FieldCleared returns a boolean indicating if a field with the given name was
  25992. // cleared in this mutation.
  25993. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  25994. _, ok := m.clearedFields[name]
  25995. return ok
  25996. }
  25997. // ClearField clears the value of the field with the given name. It returns an
  25998. // error if the field is not defined in the schema.
  25999. func (m *WxCardVisitMutation) ClearField(name string) error {
  26000. switch name {
  26001. case wxcardvisit.FieldDeletedAt:
  26002. m.ClearDeletedAt()
  26003. return nil
  26004. case wxcardvisit.FieldUserID:
  26005. m.ClearUserID()
  26006. return nil
  26007. }
  26008. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  26009. }
  26010. // ResetField resets all changes in the mutation for the field with the given name.
  26011. // It returns an error if the field is not defined in the schema.
  26012. func (m *WxCardVisitMutation) ResetField(name string) error {
  26013. switch name {
  26014. case wxcardvisit.FieldCreatedAt:
  26015. m.ResetCreatedAt()
  26016. return nil
  26017. case wxcardvisit.FieldUpdatedAt:
  26018. m.ResetUpdatedAt()
  26019. return nil
  26020. case wxcardvisit.FieldDeletedAt:
  26021. m.ResetDeletedAt()
  26022. return nil
  26023. case wxcardvisit.FieldUserID:
  26024. m.ResetUserID()
  26025. return nil
  26026. case wxcardvisit.FieldBotID:
  26027. m.ResetBotID()
  26028. return nil
  26029. case wxcardvisit.FieldBotType:
  26030. m.ResetBotType()
  26031. return nil
  26032. }
  26033. return fmt.Errorf("unknown WxCardVisit field %s", name)
  26034. }
  26035. // AddedEdges returns all edge names that were set/added in this mutation.
  26036. func (m *WxCardVisitMutation) AddedEdges() []string {
  26037. edges := make([]string, 0, 0)
  26038. return edges
  26039. }
  26040. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26041. // name in this mutation.
  26042. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  26043. return nil
  26044. }
  26045. // RemovedEdges returns all edge names that were removed in this mutation.
  26046. func (m *WxCardVisitMutation) RemovedEdges() []string {
  26047. edges := make([]string, 0, 0)
  26048. return edges
  26049. }
  26050. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26051. // the given name in this mutation.
  26052. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  26053. return nil
  26054. }
  26055. // ClearedEdges returns all edge names that were cleared in this mutation.
  26056. func (m *WxCardVisitMutation) ClearedEdges() []string {
  26057. edges := make([]string, 0, 0)
  26058. return edges
  26059. }
  26060. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26061. // was cleared in this mutation.
  26062. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  26063. return false
  26064. }
  26065. // ClearEdge clears the value of the edge with the given name. It returns an error
  26066. // if that edge is not defined in the schema.
  26067. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  26068. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  26069. }
  26070. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26071. // It returns an error if the edge is not defined in the schema.
  26072. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  26073. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  26074. }