mutation.go 842 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578
  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. // ResetWxWxid resets all changes to the "wx_wxid" field.
  6143. func (m *ContactMutation) ResetWxWxid() {
  6144. m.wx_wxid = nil
  6145. }
  6146. // SetType sets the "type" field.
  6147. func (m *ContactMutation) SetType(i int) {
  6148. m._type = &i
  6149. m.add_type = nil
  6150. }
  6151. // GetType returns the value of the "type" field in the mutation.
  6152. func (m *ContactMutation) GetType() (r int, exists bool) {
  6153. v := m._type
  6154. if v == nil {
  6155. return
  6156. }
  6157. return *v, true
  6158. }
  6159. // OldType returns the old "type" field's value of the Contact entity.
  6160. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6162. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  6163. if !m.op.Is(OpUpdateOne) {
  6164. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6165. }
  6166. if m.id == nil || m.oldValue == nil {
  6167. return v, errors.New("OldType requires an ID field in the mutation")
  6168. }
  6169. oldValue, err := m.oldValue(ctx)
  6170. if err != nil {
  6171. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6172. }
  6173. return oldValue.Type, nil
  6174. }
  6175. // AddType adds i to the "type" field.
  6176. func (m *ContactMutation) AddType(i int) {
  6177. if m.add_type != nil {
  6178. *m.add_type += i
  6179. } else {
  6180. m.add_type = &i
  6181. }
  6182. }
  6183. // AddedType returns the value that was added to the "type" field in this mutation.
  6184. func (m *ContactMutation) AddedType() (r int, exists bool) {
  6185. v := m.add_type
  6186. if v == nil {
  6187. return
  6188. }
  6189. return *v, true
  6190. }
  6191. // ClearType clears the value of the "type" field.
  6192. func (m *ContactMutation) ClearType() {
  6193. m._type = nil
  6194. m.add_type = nil
  6195. m.clearedFields[contact.FieldType] = struct{}{}
  6196. }
  6197. // TypeCleared returns if the "type" field was cleared in this mutation.
  6198. func (m *ContactMutation) TypeCleared() bool {
  6199. _, ok := m.clearedFields[contact.FieldType]
  6200. return ok
  6201. }
  6202. // ResetType resets all changes to the "type" field.
  6203. func (m *ContactMutation) ResetType() {
  6204. m._type = nil
  6205. m.add_type = nil
  6206. delete(m.clearedFields, contact.FieldType)
  6207. }
  6208. // SetWxid sets the "wxid" field.
  6209. func (m *ContactMutation) SetWxid(s string) {
  6210. m.wxid = &s
  6211. }
  6212. // Wxid returns the value of the "wxid" field in the mutation.
  6213. func (m *ContactMutation) Wxid() (r string, exists bool) {
  6214. v := m.wxid
  6215. if v == nil {
  6216. return
  6217. }
  6218. return *v, true
  6219. }
  6220. // OldWxid returns the old "wxid" field's value of the Contact entity.
  6221. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6223. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  6224. if !m.op.Is(OpUpdateOne) {
  6225. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  6226. }
  6227. if m.id == nil || m.oldValue == nil {
  6228. return v, errors.New("OldWxid requires an ID field in the mutation")
  6229. }
  6230. oldValue, err := m.oldValue(ctx)
  6231. if err != nil {
  6232. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  6233. }
  6234. return oldValue.Wxid, nil
  6235. }
  6236. // ResetWxid resets all changes to the "wxid" field.
  6237. func (m *ContactMutation) ResetWxid() {
  6238. m.wxid = nil
  6239. }
  6240. // SetAccount sets the "account" field.
  6241. func (m *ContactMutation) SetAccount(s string) {
  6242. m.account = &s
  6243. }
  6244. // Account returns the value of the "account" field in the mutation.
  6245. func (m *ContactMutation) Account() (r string, exists bool) {
  6246. v := m.account
  6247. if v == nil {
  6248. return
  6249. }
  6250. return *v, true
  6251. }
  6252. // OldAccount returns the old "account" field's value of the Contact entity.
  6253. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6255. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  6256. if !m.op.Is(OpUpdateOne) {
  6257. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  6258. }
  6259. if m.id == nil || m.oldValue == nil {
  6260. return v, errors.New("OldAccount requires an ID field in the mutation")
  6261. }
  6262. oldValue, err := m.oldValue(ctx)
  6263. if err != nil {
  6264. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  6265. }
  6266. return oldValue.Account, nil
  6267. }
  6268. // ResetAccount resets all changes to the "account" field.
  6269. func (m *ContactMutation) ResetAccount() {
  6270. m.account = nil
  6271. }
  6272. // SetNickname sets the "nickname" field.
  6273. func (m *ContactMutation) SetNickname(s string) {
  6274. m.nickname = &s
  6275. }
  6276. // Nickname returns the value of the "nickname" field in the mutation.
  6277. func (m *ContactMutation) Nickname() (r string, exists bool) {
  6278. v := m.nickname
  6279. if v == nil {
  6280. return
  6281. }
  6282. return *v, true
  6283. }
  6284. // OldNickname returns the old "nickname" field's value of the Contact entity.
  6285. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6287. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  6288. if !m.op.Is(OpUpdateOne) {
  6289. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  6290. }
  6291. if m.id == nil || m.oldValue == nil {
  6292. return v, errors.New("OldNickname requires an ID field in the mutation")
  6293. }
  6294. oldValue, err := m.oldValue(ctx)
  6295. if err != nil {
  6296. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  6297. }
  6298. return oldValue.Nickname, nil
  6299. }
  6300. // ResetNickname resets all changes to the "nickname" field.
  6301. func (m *ContactMutation) ResetNickname() {
  6302. m.nickname = nil
  6303. }
  6304. // SetMarkname sets the "markname" field.
  6305. func (m *ContactMutation) SetMarkname(s string) {
  6306. m.markname = &s
  6307. }
  6308. // Markname returns the value of the "markname" field in the mutation.
  6309. func (m *ContactMutation) Markname() (r string, exists bool) {
  6310. v := m.markname
  6311. if v == nil {
  6312. return
  6313. }
  6314. return *v, true
  6315. }
  6316. // OldMarkname returns the old "markname" field's value of the Contact entity.
  6317. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6319. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  6320. if !m.op.Is(OpUpdateOne) {
  6321. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  6322. }
  6323. if m.id == nil || m.oldValue == nil {
  6324. return v, errors.New("OldMarkname requires an ID field in the mutation")
  6325. }
  6326. oldValue, err := m.oldValue(ctx)
  6327. if err != nil {
  6328. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  6329. }
  6330. return oldValue.Markname, nil
  6331. }
  6332. // ResetMarkname resets all changes to the "markname" field.
  6333. func (m *ContactMutation) ResetMarkname() {
  6334. m.markname = nil
  6335. }
  6336. // SetHeadimg sets the "headimg" field.
  6337. func (m *ContactMutation) SetHeadimg(s string) {
  6338. m.headimg = &s
  6339. }
  6340. // Headimg returns the value of the "headimg" field in the mutation.
  6341. func (m *ContactMutation) Headimg() (r string, exists bool) {
  6342. v := m.headimg
  6343. if v == nil {
  6344. return
  6345. }
  6346. return *v, true
  6347. }
  6348. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  6349. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6351. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  6352. if !m.op.Is(OpUpdateOne) {
  6353. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  6354. }
  6355. if m.id == nil || m.oldValue == nil {
  6356. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  6357. }
  6358. oldValue, err := m.oldValue(ctx)
  6359. if err != nil {
  6360. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  6361. }
  6362. return oldValue.Headimg, nil
  6363. }
  6364. // ResetHeadimg resets all changes to the "headimg" field.
  6365. func (m *ContactMutation) ResetHeadimg() {
  6366. m.headimg = nil
  6367. }
  6368. // SetSex sets the "sex" field.
  6369. func (m *ContactMutation) SetSex(i int) {
  6370. m.sex = &i
  6371. m.addsex = nil
  6372. }
  6373. // Sex returns the value of the "sex" field in the mutation.
  6374. func (m *ContactMutation) Sex() (r int, exists bool) {
  6375. v := m.sex
  6376. if v == nil {
  6377. return
  6378. }
  6379. return *v, true
  6380. }
  6381. // OldSex returns the old "sex" field's value of the Contact entity.
  6382. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6384. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  6385. if !m.op.Is(OpUpdateOne) {
  6386. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  6387. }
  6388. if m.id == nil || m.oldValue == nil {
  6389. return v, errors.New("OldSex requires an ID field in the mutation")
  6390. }
  6391. oldValue, err := m.oldValue(ctx)
  6392. if err != nil {
  6393. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  6394. }
  6395. return oldValue.Sex, nil
  6396. }
  6397. // AddSex adds i to the "sex" field.
  6398. func (m *ContactMutation) AddSex(i int) {
  6399. if m.addsex != nil {
  6400. *m.addsex += i
  6401. } else {
  6402. m.addsex = &i
  6403. }
  6404. }
  6405. // AddedSex returns the value that was added to the "sex" field in this mutation.
  6406. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  6407. v := m.addsex
  6408. if v == nil {
  6409. return
  6410. }
  6411. return *v, true
  6412. }
  6413. // ResetSex resets all changes to the "sex" field.
  6414. func (m *ContactMutation) ResetSex() {
  6415. m.sex = nil
  6416. m.addsex = nil
  6417. }
  6418. // SetStarrole sets the "starrole" field.
  6419. func (m *ContactMutation) SetStarrole(s string) {
  6420. m.starrole = &s
  6421. }
  6422. // Starrole returns the value of the "starrole" field in the mutation.
  6423. func (m *ContactMutation) Starrole() (r string, exists bool) {
  6424. v := m.starrole
  6425. if v == nil {
  6426. return
  6427. }
  6428. return *v, true
  6429. }
  6430. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  6431. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6433. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  6434. if !m.op.Is(OpUpdateOne) {
  6435. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  6436. }
  6437. if m.id == nil || m.oldValue == nil {
  6438. return v, errors.New("OldStarrole requires an ID field in the mutation")
  6439. }
  6440. oldValue, err := m.oldValue(ctx)
  6441. if err != nil {
  6442. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  6443. }
  6444. return oldValue.Starrole, nil
  6445. }
  6446. // ResetStarrole resets all changes to the "starrole" field.
  6447. func (m *ContactMutation) ResetStarrole() {
  6448. m.starrole = nil
  6449. }
  6450. // SetDontseeit sets the "dontseeit" field.
  6451. func (m *ContactMutation) SetDontseeit(i int) {
  6452. m.dontseeit = &i
  6453. m.adddontseeit = nil
  6454. }
  6455. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  6456. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  6457. v := m.dontseeit
  6458. if v == nil {
  6459. return
  6460. }
  6461. return *v, true
  6462. }
  6463. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  6464. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6466. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  6467. if !m.op.Is(OpUpdateOne) {
  6468. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  6469. }
  6470. if m.id == nil || m.oldValue == nil {
  6471. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  6472. }
  6473. oldValue, err := m.oldValue(ctx)
  6474. if err != nil {
  6475. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  6476. }
  6477. return oldValue.Dontseeit, nil
  6478. }
  6479. // AddDontseeit adds i to the "dontseeit" field.
  6480. func (m *ContactMutation) AddDontseeit(i int) {
  6481. if m.adddontseeit != nil {
  6482. *m.adddontseeit += i
  6483. } else {
  6484. m.adddontseeit = &i
  6485. }
  6486. }
  6487. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  6488. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  6489. v := m.adddontseeit
  6490. if v == nil {
  6491. return
  6492. }
  6493. return *v, true
  6494. }
  6495. // ResetDontseeit resets all changes to the "dontseeit" field.
  6496. func (m *ContactMutation) ResetDontseeit() {
  6497. m.dontseeit = nil
  6498. m.adddontseeit = nil
  6499. }
  6500. // SetDontseeme sets the "dontseeme" field.
  6501. func (m *ContactMutation) SetDontseeme(i int) {
  6502. m.dontseeme = &i
  6503. m.adddontseeme = nil
  6504. }
  6505. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  6506. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  6507. v := m.dontseeme
  6508. if v == nil {
  6509. return
  6510. }
  6511. return *v, true
  6512. }
  6513. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  6514. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6516. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  6517. if !m.op.Is(OpUpdateOne) {
  6518. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  6519. }
  6520. if m.id == nil || m.oldValue == nil {
  6521. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  6522. }
  6523. oldValue, err := m.oldValue(ctx)
  6524. if err != nil {
  6525. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  6526. }
  6527. return oldValue.Dontseeme, nil
  6528. }
  6529. // AddDontseeme adds i to the "dontseeme" field.
  6530. func (m *ContactMutation) AddDontseeme(i int) {
  6531. if m.adddontseeme != nil {
  6532. *m.adddontseeme += i
  6533. } else {
  6534. m.adddontseeme = &i
  6535. }
  6536. }
  6537. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  6538. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  6539. v := m.adddontseeme
  6540. if v == nil {
  6541. return
  6542. }
  6543. return *v, true
  6544. }
  6545. // ResetDontseeme resets all changes to the "dontseeme" field.
  6546. func (m *ContactMutation) ResetDontseeme() {
  6547. m.dontseeme = nil
  6548. m.adddontseeme = nil
  6549. }
  6550. // SetLag sets the "lag" field.
  6551. func (m *ContactMutation) SetLag(s string) {
  6552. m.lag = &s
  6553. }
  6554. // Lag returns the value of the "lag" field in the mutation.
  6555. func (m *ContactMutation) Lag() (r string, exists bool) {
  6556. v := m.lag
  6557. if v == nil {
  6558. return
  6559. }
  6560. return *v, true
  6561. }
  6562. // OldLag returns the old "lag" field's value of the Contact entity.
  6563. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6565. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  6566. if !m.op.Is(OpUpdateOne) {
  6567. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  6568. }
  6569. if m.id == nil || m.oldValue == nil {
  6570. return v, errors.New("OldLag requires an ID field in the mutation")
  6571. }
  6572. oldValue, err := m.oldValue(ctx)
  6573. if err != nil {
  6574. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  6575. }
  6576. return oldValue.Lag, nil
  6577. }
  6578. // ResetLag resets all changes to the "lag" field.
  6579. func (m *ContactMutation) ResetLag() {
  6580. m.lag = nil
  6581. }
  6582. // SetGid sets the "gid" field.
  6583. func (m *ContactMutation) SetGid(s string) {
  6584. m.gid = &s
  6585. }
  6586. // Gid returns the value of the "gid" field in the mutation.
  6587. func (m *ContactMutation) Gid() (r string, exists bool) {
  6588. v := m.gid
  6589. if v == nil {
  6590. return
  6591. }
  6592. return *v, true
  6593. }
  6594. // OldGid returns the old "gid" field's value of the Contact entity.
  6595. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6597. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  6598. if !m.op.Is(OpUpdateOne) {
  6599. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  6600. }
  6601. if m.id == nil || m.oldValue == nil {
  6602. return v, errors.New("OldGid requires an ID field in the mutation")
  6603. }
  6604. oldValue, err := m.oldValue(ctx)
  6605. if err != nil {
  6606. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  6607. }
  6608. return oldValue.Gid, nil
  6609. }
  6610. // ResetGid resets all changes to the "gid" field.
  6611. func (m *ContactMutation) ResetGid() {
  6612. m.gid = nil
  6613. }
  6614. // SetGname sets the "gname" field.
  6615. func (m *ContactMutation) SetGname(s string) {
  6616. m.gname = &s
  6617. }
  6618. // Gname returns the value of the "gname" field in the mutation.
  6619. func (m *ContactMutation) Gname() (r string, exists bool) {
  6620. v := m.gname
  6621. if v == nil {
  6622. return
  6623. }
  6624. return *v, true
  6625. }
  6626. // OldGname returns the old "gname" field's value of the Contact entity.
  6627. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6629. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  6630. if !m.op.Is(OpUpdateOne) {
  6631. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  6632. }
  6633. if m.id == nil || m.oldValue == nil {
  6634. return v, errors.New("OldGname requires an ID field in the mutation")
  6635. }
  6636. oldValue, err := m.oldValue(ctx)
  6637. if err != nil {
  6638. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  6639. }
  6640. return oldValue.Gname, nil
  6641. }
  6642. // ResetGname resets all changes to the "gname" field.
  6643. func (m *ContactMutation) ResetGname() {
  6644. m.gname = nil
  6645. }
  6646. // SetV3 sets the "v3" field.
  6647. func (m *ContactMutation) SetV3(s string) {
  6648. m.v3 = &s
  6649. }
  6650. // V3 returns the value of the "v3" field in the mutation.
  6651. func (m *ContactMutation) V3() (r string, exists bool) {
  6652. v := m.v3
  6653. if v == nil {
  6654. return
  6655. }
  6656. return *v, true
  6657. }
  6658. // OldV3 returns the old "v3" field's value of the Contact entity.
  6659. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6661. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  6662. if !m.op.Is(OpUpdateOne) {
  6663. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  6664. }
  6665. if m.id == nil || m.oldValue == nil {
  6666. return v, errors.New("OldV3 requires an ID field in the mutation")
  6667. }
  6668. oldValue, err := m.oldValue(ctx)
  6669. if err != nil {
  6670. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  6671. }
  6672. return oldValue.V3, nil
  6673. }
  6674. // ResetV3 resets all changes to the "v3" field.
  6675. func (m *ContactMutation) ResetV3() {
  6676. m.v3 = nil
  6677. }
  6678. // SetOrganizationID sets the "organization_id" field.
  6679. func (m *ContactMutation) SetOrganizationID(u uint64) {
  6680. m.organization_id = &u
  6681. m.addorganization_id = nil
  6682. }
  6683. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6684. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  6685. v := m.organization_id
  6686. if v == nil {
  6687. return
  6688. }
  6689. return *v, true
  6690. }
  6691. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  6692. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6694. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6695. if !m.op.Is(OpUpdateOne) {
  6696. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6697. }
  6698. if m.id == nil || m.oldValue == nil {
  6699. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6700. }
  6701. oldValue, err := m.oldValue(ctx)
  6702. if err != nil {
  6703. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6704. }
  6705. return oldValue.OrganizationID, nil
  6706. }
  6707. // AddOrganizationID adds u to the "organization_id" field.
  6708. func (m *ContactMutation) AddOrganizationID(u int64) {
  6709. if m.addorganization_id != nil {
  6710. *m.addorganization_id += u
  6711. } else {
  6712. m.addorganization_id = &u
  6713. }
  6714. }
  6715. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6716. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  6717. v := m.addorganization_id
  6718. if v == nil {
  6719. return
  6720. }
  6721. return *v, true
  6722. }
  6723. // ClearOrganizationID clears the value of the "organization_id" field.
  6724. func (m *ContactMutation) ClearOrganizationID() {
  6725. m.organization_id = nil
  6726. m.addorganization_id = nil
  6727. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  6728. }
  6729. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6730. func (m *ContactMutation) OrganizationIDCleared() bool {
  6731. _, ok := m.clearedFields[contact.FieldOrganizationID]
  6732. return ok
  6733. }
  6734. // ResetOrganizationID resets all changes to the "organization_id" field.
  6735. func (m *ContactMutation) ResetOrganizationID() {
  6736. m.organization_id = nil
  6737. m.addorganization_id = nil
  6738. delete(m.clearedFields, contact.FieldOrganizationID)
  6739. }
  6740. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  6741. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  6742. if m.contact_relationships == nil {
  6743. m.contact_relationships = make(map[uint64]struct{})
  6744. }
  6745. for i := range ids {
  6746. m.contact_relationships[ids[i]] = struct{}{}
  6747. }
  6748. }
  6749. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  6750. func (m *ContactMutation) ClearContactRelationships() {
  6751. m.clearedcontact_relationships = true
  6752. }
  6753. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  6754. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  6755. return m.clearedcontact_relationships
  6756. }
  6757. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  6758. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  6759. if m.removedcontact_relationships == nil {
  6760. m.removedcontact_relationships = make(map[uint64]struct{})
  6761. }
  6762. for i := range ids {
  6763. delete(m.contact_relationships, ids[i])
  6764. m.removedcontact_relationships[ids[i]] = struct{}{}
  6765. }
  6766. }
  6767. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  6768. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  6769. for id := range m.removedcontact_relationships {
  6770. ids = append(ids, id)
  6771. }
  6772. return
  6773. }
  6774. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  6775. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  6776. for id := range m.contact_relationships {
  6777. ids = append(ids, id)
  6778. }
  6779. return
  6780. }
  6781. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  6782. func (m *ContactMutation) ResetContactRelationships() {
  6783. m.contact_relationships = nil
  6784. m.clearedcontact_relationships = false
  6785. m.removedcontact_relationships = nil
  6786. }
  6787. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  6788. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  6789. if m.contact_messages == nil {
  6790. m.contact_messages = make(map[uint64]struct{})
  6791. }
  6792. for i := range ids {
  6793. m.contact_messages[ids[i]] = struct{}{}
  6794. }
  6795. }
  6796. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  6797. func (m *ContactMutation) ClearContactMessages() {
  6798. m.clearedcontact_messages = true
  6799. }
  6800. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  6801. func (m *ContactMutation) ContactMessagesCleared() bool {
  6802. return m.clearedcontact_messages
  6803. }
  6804. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  6805. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  6806. if m.removedcontact_messages == nil {
  6807. m.removedcontact_messages = make(map[uint64]struct{})
  6808. }
  6809. for i := range ids {
  6810. delete(m.contact_messages, ids[i])
  6811. m.removedcontact_messages[ids[i]] = struct{}{}
  6812. }
  6813. }
  6814. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  6815. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  6816. for id := range m.removedcontact_messages {
  6817. ids = append(ids, id)
  6818. }
  6819. return
  6820. }
  6821. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  6822. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  6823. for id := range m.contact_messages {
  6824. ids = append(ids, id)
  6825. }
  6826. return
  6827. }
  6828. // ResetContactMessages resets all changes to the "contact_messages" edge.
  6829. func (m *ContactMutation) ResetContactMessages() {
  6830. m.contact_messages = nil
  6831. m.clearedcontact_messages = false
  6832. m.removedcontact_messages = nil
  6833. }
  6834. // Where appends a list predicates to the ContactMutation builder.
  6835. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  6836. m.predicates = append(m.predicates, ps...)
  6837. }
  6838. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  6839. // users can use type-assertion to append predicates that do not depend on any generated package.
  6840. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  6841. p := make([]predicate.Contact, len(ps))
  6842. for i := range ps {
  6843. p[i] = ps[i]
  6844. }
  6845. m.Where(p...)
  6846. }
  6847. // Op returns the operation name.
  6848. func (m *ContactMutation) Op() Op {
  6849. return m.op
  6850. }
  6851. // SetOp allows setting the mutation operation.
  6852. func (m *ContactMutation) SetOp(op Op) {
  6853. m.op = op
  6854. }
  6855. // Type returns the node type of this mutation (Contact).
  6856. func (m *ContactMutation) Type() string {
  6857. return m.typ
  6858. }
  6859. // Fields returns all fields that were changed during this mutation. Note that in
  6860. // order to get all numeric fields that were incremented/decremented, call
  6861. // AddedFields().
  6862. func (m *ContactMutation) Fields() []string {
  6863. fields := make([]string, 0, 20)
  6864. if m.created_at != nil {
  6865. fields = append(fields, contact.FieldCreatedAt)
  6866. }
  6867. if m.updated_at != nil {
  6868. fields = append(fields, contact.FieldUpdatedAt)
  6869. }
  6870. if m.status != nil {
  6871. fields = append(fields, contact.FieldStatus)
  6872. }
  6873. if m.deleted_at != nil {
  6874. fields = append(fields, contact.FieldDeletedAt)
  6875. }
  6876. if m.wx_wxid != nil {
  6877. fields = append(fields, contact.FieldWxWxid)
  6878. }
  6879. if m._type != nil {
  6880. fields = append(fields, contact.FieldType)
  6881. }
  6882. if m.wxid != nil {
  6883. fields = append(fields, contact.FieldWxid)
  6884. }
  6885. if m.account != nil {
  6886. fields = append(fields, contact.FieldAccount)
  6887. }
  6888. if m.nickname != nil {
  6889. fields = append(fields, contact.FieldNickname)
  6890. }
  6891. if m.markname != nil {
  6892. fields = append(fields, contact.FieldMarkname)
  6893. }
  6894. if m.headimg != nil {
  6895. fields = append(fields, contact.FieldHeadimg)
  6896. }
  6897. if m.sex != nil {
  6898. fields = append(fields, contact.FieldSex)
  6899. }
  6900. if m.starrole != nil {
  6901. fields = append(fields, contact.FieldStarrole)
  6902. }
  6903. if m.dontseeit != nil {
  6904. fields = append(fields, contact.FieldDontseeit)
  6905. }
  6906. if m.dontseeme != nil {
  6907. fields = append(fields, contact.FieldDontseeme)
  6908. }
  6909. if m.lag != nil {
  6910. fields = append(fields, contact.FieldLag)
  6911. }
  6912. if m.gid != nil {
  6913. fields = append(fields, contact.FieldGid)
  6914. }
  6915. if m.gname != nil {
  6916. fields = append(fields, contact.FieldGname)
  6917. }
  6918. if m.v3 != nil {
  6919. fields = append(fields, contact.FieldV3)
  6920. }
  6921. if m.organization_id != nil {
  6922. fields = append(fields, contact.FieldOrganizationID)
  6923. }
  6924. return fields
  6925. }
  6926. // Field returns the value of a field with the given name. The second boolean
  6927. // return value indicates that this field was not set, or was not defined in the
  6928. // schema.
  6929. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  6930. switch name {
  6931. case contact.FieldCreatedAt:
  6932. return m.CreatedAt()
  6933. case contact.FieldUpdatedAt:
  6934. return m.UpdatedAt()
  6935. case contact.FieldStatus:
  6936. return m.Status()
  6937. case contact.FieldDeletedAt:
  6938. return m.DeletedAt()
  6939. case contact.FieldWxWxid:
  6940. return m.WxWxid()
  6941. case contact.FieldType:
  6942. return m.GetType()
  6943. case contact.FieldWxid:
  6944. return m.Wxid()
  6945. case contact.FieldAccount:
  6946. return m.Account()
  6947. case contact.FieldNickname:
  6948. return m.Nickname()
  6949. case contact.FieldMarkname:
  6950. return m.Markname()
  6951. case contact.FieldHeadimg:
  6952. return m.Headimg()
  6953. case contact.FieldSex:
  6954. return m.Sex()
  6955. case contact.FieldStarrole:
  6956. return m.Starrole()
  6957. case contact.FieldDontseeit:
  6958. return m.Dontseeit()
  6959. case contact.FieldDontseeme:
  6960. return m.Dontseeme()
  6961. case contact.FieldLag:
  6962. return m.Lag()
  6963. case contact.FieldGid:
  6964. return m.Gid()
  6965. case contact.FieldGname:
  6966. return m.Gname()
  6967. case contact.FieldV3:
  6968. return m.V3()
  6969. case contact.FieldOrganizationID:
  6970. return m.OrganizationID()
  6971. }
  6972. return nil, false
  6973. }
  6974. // OldField returns the old value of the field from the database. An error is
  6975. // returned if the mutation operation is not UpdateOne, or the query to the
  6976. // database failed.
  6977. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6978. switch name {
  6979. case contact.FieldCreatedAt:
  6980. return m.OldCreatedAt(ctx)
  6981. case contact.FieldUpdatedAt:
  6982. return m.OldUpdatedAt(ctx)
  6983. case contact.FieldStatus:
  6984. return m.OldStatus(ctx)
  6985. case contact.FieldDeletedAt:
  6986. return m.OldDeletedAt(ctx)
  6987. case contact.FieldWxWxid:
  6988. return m.OldWxWxid(ctx)
  6989. case contact.FieldType:
  6990. return m.OldType(ctx)
  6991. case contact.FieldWxid:
  6992. return m.OldWxid(ctx)
  6993. case contact.FieldAccount:
  6994. return m.OldAccount(ctx)
  6995. case contact.FieldNickname:
  6996. return m.OldNickname(ctx)
  6997. case contact.FieldMarkname:
  6998. return m.OldMarkname(ctx)
  6999. case contact.FieldHeadimg:
  7000. return m.OldHeadimg(ctx)
  7001. case contact.FieldSex:
  7002. return m.OldSex(ctx)
  7003. case contact.FieldStarrole:
  7004. return m.OldStarrole(ctx)
  7005. case contact.FieldDontseeit:
  7006. return m.OldDontseeit(ctx)
  7007. case contact.FieldDontseeme:
  7008. return m.OldDontseeme(ctx)
  7009. case contact.FieldLag:
  7010. return m.OldLag(ctx)
  7011. case contact.FieldGid:
  7012. return m.OldGid(ctx)
  7013. case contact.FieldGname:
  7014. return m.OldGname(ctx)
  7015. case contact.FieldV3:
  7016. return m.OldV3(ctx)
  7017. case contact.FieldOrganizationID:
  7018. return m.OldOrganizationID(ctx)
  7019. }
  7020. return nil, fmt.Errorf("unknown Contact field %s", name)
  7021. }
  7022. // SetField sets the value of a field with the given name. It returns an error if
  7023. // the field is not defined in the schema, or if the type mismatched the field
  7024. // type.
  7025. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  7026. switch name {
  7027. case contact.FieldCreatedAt:
  7028. v, ok := value.(time.Time)
  7029. if !ok {
  7030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7031. }
  7032. m.SetCreatedAt(v)
  7033. return nil
  7034. case contact.FieldUpdatedAt:
  7035. v, ok := value.(time.Time)
  7036. if !ok {
  7037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7038. }
  7039. m.SetUpdatedAt(v)
  7040. return nil
  7041. case contact.FieldStatus:
  7042. v, ok := value.(uint8)
  7043. if !ok {
  7044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7045. }
  7046. m.SetStatus(v)
  7047. return nil
  7048. case contact.FieldDeletedAt:
  7049. v, ok := value.(time.Time)
  7050. if !ok {
  7051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7052. }
  7053. m.SetDeletedAt(v)
  7054. return nil
  7055. case contact.FieldWxWxid:
  7056. v, ok := value.(string)
  7057. if !ok {
  7058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7059. }
  7060. m.SetWxWxid(v)
  7061. return nil
  7062. case contact.FieldType:
  7063. v, ok := value.(int)
  7064. if !ok {
  7065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7066. }
  7067. m.SetType(v)
  7068. return nil
  7069. case contact.FieldWxid:
  7070. v, ok := value.(string)
  7071. if !ok {
  7072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7073. }
  7074. m.SetWxid(v)
  7075. return nil
  7076. case contact.FieldAccount:
  7077. v, ok := value.(string)
  7078. if !ok {
  7079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7080. }
  7081. m.SetAccount(v)
  7082. return nil
  7083. case contact.FieldNickname:
  7084. v, ok := value.(string)
  7085. if !ok {
  7086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7087. }
  7088. m.SetNickname(v)
  7089. return nil
  7090. case contact.FieldMarkname:
  7091. v, ok := value.(string)
  7092. if !ok {
  7093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7094. }
  7095. m.SetMarkname(v)
  7096. return nil
  7097. case contact.FieldHeadimg:
  7098. v, ok := value.(string)
  7099. if !ok {
  7100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7101. }
  7102. m.SetHeadimg(v)
  7103. return nil
  7104. case contact.FieldSex:
  7105. v, ok := value.(int)
  7106. if !ok {
  7107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7108. }
  7109. m.SetSex(v)
  7110. return nil
  7111. case contact.FieldStarrole:
  7112. v, ok := value.(string)
  7113. if !ok {
  7114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7115. }
  7116. m.SetStarrole(v)
  7117. return nil
  7118. case contact.FieldDontseeit:
  7119. v, ok := value.(int)
  7120. if !ok {
  7121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7122. }
  7123. m.SetDontseeit(v)
  7124. return nil
  7125. case contact.FieldDontseeme:
  7126. v, ok := value.(int)
  7127. if !ok {
  7128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7129. }
  7130. m.SetDontseeme(v)
  7131. return nil
  7132. case contact.FieldLag:
  7133. v, ok := value.(string)
  7134. if !ok {
  7135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7136. }
  7137. m.SetLag(v)
  7138. return nil
  7139. case contact.FieldGid:
  7140. v, ok := value.(string)
  7141. if !ok {
  7142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7143. }
  7144. m.SetGid(v)
  7145. return nil
  7146. case contact.FieldGname:
  7147. v, ok := value.(string)
  7148. if !ok {
  7149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7150. }
  7151. m.SetGname(v)
  7152. return nil
  7153. case contact.FieldV3:
  7154. v, ok := value.(string)
  7155. if !ok {
  7156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7157. }
  7158. m.SetV3(v)
  7159. return nil
  7160. case contact.FieldOrganizationID:
  7161. v, ok := value.(uint64)
  7162. if !ok {
  7163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7164. }
  7165. m.SetOrganizationID(v)
  7166. return nil
  7167. }
  7168. return fmt.Errorf("unknown Contact field %s", name)
  7169. }
  7170. // AddedFields returns all numeric fields that were incremented/decremented during
  7171. // this mutation.
  7172. func (m *ContactMutation) AddedFields() []string {
  7173. var fields []string
  7174. if m.addstatus != nil {
  7175. fields = append(fields, contact.FieldStatus)
  7176. }
  7177. if m.add_type != nil {
  7178. fields = append(fields, contact.FieldType)
  7179. }
  7180. if m.addsex != nil {
  7181. fields = append(fields, contact.FieldSex)
  7182. }
  7183. if m.adddontseeit != nil {
  7184. fields = append(fields, contact.FieldDontseeit)
  7185. }
  7186. if m.adddontseeme != nil {
  7187. fields = append(fields, contact.FieldDontseeme)
  7188. }
  7189. if m.addorganization_id != nil {
  7190. fields = append(fields, contact.FieldOrganizationID)
  7191. }
  7192. return fields
  7193. }
  7194. // AddedField returns the numeric value that was incremented/decremented on a field
  7195. // with the given name. The second boolean return value indicates that this field
  7196. // was not set, or was not defined in the schema.
  7197. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  7198. switch name {
  7199. case contact.FieldStatus:
  7200. return m.AddedStatus()
  7201. case contact.FieldType:
  7202. return m.AddedType()
  7203. case contact.FieldSex:
  7204. return m.AddedSex()
  7205. case contact.FieldDontseeit:
  7206. return m.AddedDontseeit()
  7207. case contact.FieldDontseeme:
  7208. return m.AddedDontseeme()
  7209. case contact.FieldOrganizationID:
  7210. return m.AddedOrganizationID()
  7211. }
  7212. return nil, false
  7213. }
  7214. // AddField adds the value to the field with the given name. It returns an error if
  7215. // the field is not defined in the schema, or if the type mismatched the field
  7216. // type.
  7217. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  7218. switch name {
  7219. case contact.FieldStatus:
  7220. v, ok := value.(int8)
  7221. if !ok {
  7222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7223. }
  7224. m.AddStatus(v)
  7225. return nil
  7226. case contact.FieldType:
  7227. v, ok := value.(int)
  7228. if !ok {
  7229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7230. }
  7231. m.AddType(v)
  7232. return nil
  7233. case contact.FieldSex:
  7234. v, ok := value.(int)
  7235. if !ok {
  7236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7237. }
  7238. m.AddSex(v)
  7239. return nil
  7240. case contact.FieldDontseeit:
  7241. v, ok := value.(int)
  7242. if !ok {
  7243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7244. }
  7245. m.AddDontseeit(v)
  7246. return nil
  7247. case contact.FieldDontseeme:
  7248. v, ok := value.(int)
  7249. if !ok {
  7250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7251. }
  7252. m.AddDontseeme(v)
  7253. return nil
  7254. case contact.FieldOrganizationID:
  7255. v, ok := value.(int64)
  7256. if !ok {
  7257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7258. }
  7259. m.AddOrganizationID(v)
  7260. return nil
  7261. }
  7262. return fmt.Errorf("unknown Contact numeric field %s", name)
  7263. }
  7264. // ClearedFields returns all nullable fields that were cleared during this
  7265. // mutation.
  7266. func (m *ContactMutation) ClearedFields() []string {
  7267. var fields []string
  7268. if m.FieldCleared(contact.FieldStatus) {
  7269. fields = append(fields, contact.FieldStatus)
  7270. }
  7271. if m.FieldCleared(contact.FieldDeletedAt) {
  7272. fields = append(fields, contact.FieldDeletedAt)
  7273. }
  7274. if m.FieldCleared(contact.FieldType) {
  7275. fields = append(fields, contact.FieldType)
  7276. }
  7277. if m.FieldCleared(contact.FieldOrganizationID) {
  7278. fields = append(fields, contact.FieldOrganizationID)
  7279. }
  7280. return fields
  7281. }
  7282. // FieldCleared returns a boolean indicating if a field with the given name was
  7283. // cleared in this mutation.
  7284. func (m *ContactMutation) FieldCleared(name string) bool {
  7285. _, ok := m.clearedFields[name]
  7286. return ok
  7287. }
  7288. // ClearField clears the value of the field with the given name. It returns an
  7289. // error if the field is not defined in the schema.
  7290. func (m *ContactMutation) ClearField(name string) error {
  7291. switch name {
  7292. case contact.FieldStatus:
  7293. m.ClearStatus()
  7294. return nil
  7295. case contact.FieldDeletedAt:
  7296. m.ClearDeletedAt()
  7297. return nil
  7298. case contact.FieldType:
  7299. m.ClearType()
  7300. return nil
  7301. case contact.FieldOrganizationID:
  7302. m.ClearOrganizationID()
  7303. return nil
  7304. }
  7305. return fmt.Errorf("unknown Contact nullable field %s", name)
  7306. }
  7307. // ResetField resets all changes in the mutation for the field with the given name.
  7308. // It returns an error if the field is not defined in the schema.
  7309. func (m *ContactMutation) ResetField(name string) error {
  7310. switch name {
  7311. case contact.FieldCreatedAt:
  7312. m.ResetCreatedAt()
  7313. return nil
  7314. case contact.FieldUpdatedAt:
  7315. m.ResetUpdatedAt()
  7316. return nil
  7317. case contact.FieldStatus:
  7318. m.ResetStatus()
  7319. return nil
  7320. case contact.FieldDeletedAt:
  7321. m.ResetDeletedAt()
  7322. return nil
  7323. case contact.FieldWxWxid:
  7324. m.ResetWxWxid()
  7325. return nil
  7326. case contact.FieldType:
  7327. m.ResetType()
  7328. return nil
  7329. case contact.FieldWxid:
  7330. m.ResetWxid()
  7331. return nil
  7332. case contact.FieldAccount:
  7333. m.ResetAccount()
  7334. return nil
  7335. case contact.FieldNickname:
  7336. m.ResetNickname()
  7337. return nil
  7338. case contact.FieldMarkname:
  7339. m.ResetMarkname()
  7340. return nil
  7341. case contact.FieldHeadimg:
  7342. m.ResetHeadimg()
  7343. return nil
  7344. case contact.FieldSex:
  7345. m.ResetSex()
  7346. return nil
  7347. case contact.FieldStarrole:
  7348. m.ResetStarrole()
  7349. return nil
  7350. case contact.FieldDontseeit:
  7351. m.ResetDontseeit()
  7352. return nil
  7353. case contact.FieldDontseeme:
  7354. m.ResetDontseeme()
  7355. return nil
  7356. case contact.FieldLag:
  7357. m.ResetLag()
  7358. return nil
  7359. case contact.FieldGid:
  7360. m.ResetGid()
  7361. return nil
  7362. case contact.FieldGname:
  7363. m.ResetGname()
  7364. return nil
  7365. case contact.FieldV3:
  7366. m.ResetV3()
  7367. return nil
  7368. case contact.FieldOrganizationID:
  7369. m.ResetOrganizationID()
  7370. return nil
  7371. }
  7372. return fmt.Errorf("unknown Contact field %s", name)
  7373. }
  7374. // AddedEdges returns all edge names that were set/added in this mutation.
  7375. func (m *ContactMutation) AddedEdges() []string {
  7376. edges := make([]string, 0, 2)
  7377. if m.contact_relationships != nil {
  7378. edges = append(edges, contact.EdgeContactRelationships)
  7379. }
  7380. if m.contact_messages != nil {
  7381. edges = append(edges, contact.EdgeContactMessages)
  7382. }
  7383. return edges
  7384. }
  7385. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7386. // name in this mutation.
  7387. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  7388. switch name {
  7389. case contact.EdgeContactRelationships:
  7390. ids := make([]ent.Value, 0, len(m.contact_relationships))
  7391. for id := range m.contact_relationships {
  7392. ids = append(ids, id)
  7393. }
  7394. return ids
  7395. case contact.EdgeContactMessages:
  7396. ids := make([]ent.Value, 0, len(m.contact_messages))
  7397. for id := range m.contact_messages {
  7398. ids = append(ids, id)
  7399. }
  7400. return ids
  7401. }
  7402. return nil
  7403. }
  7404. // RemovedEdges returns all edge names that were removed in this mutation.
  7405. func (m *ContactMutation) RemovedEdges() []string {
  7406. edges := make([]string, 0, 2)
  7407. if m.removedcontact_relationships != nil {
  7408. edges = append(edges, contact.EdgeContactRelationships)
  7409. }
  7410. if m.removedcontact_messages != nil {
  7411. edges = append(edges, contact.EdgeContactMessages)
  7412. }
  7413. return edges
  7414. }
  7415. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7416. // the given name in this mutation.
  7417. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  7418. switch name {
  7419. case contact.EdgeContactRelationships:
  7420. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  7421. for id := range m.removedcontact_relationships {
  7422. ids = append(ids, id)
  7423. }
  7424. return ids
  7425. case contact.EdgeContactMessages:
  7426. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  7427. for id := range m.removedcontact_messages {
  7428. ids = append(ids, id)
  7429. }
  7430. return ids
  7431. }
  7432. return nil
  7433. }
  7434. // ClearedEdges returns all edge names that were cleared in this mutation.
  7435. func (m *ContactMutation) ClearedEdges() []string {
  7436. edges := make([]string, 0, 2)
  7437. if m.clearedcontact_relationships {
  7438. edges = append(edges, contact.EdgeContactRelationships)
  7439. }
  7440. if m.clearedcontact_messages {
  7441. edges = append(edges, contact.EdgeContactMessages)
  7442. }
  7443. return edges
  7444. }
  7445. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7446. // was cleared in this mutation.
  7447. func (m *ContactMutation) EdgeCleared(name string) bool {
  7448. switch name {
  7449. case contact.EdgeContactRelationships:
  7450. return m.clearedcontact_relationships
  7451. case contact.EdgeContactMessages:
  7452. return m.clearedcontact_messages
  7453. }
  7454. return false
  7455. }
  7456. // ClearEdge clears the value of the edge with the given name. It returns an error
  7457. // if that edge is not defined in the schema.
  7458. func (m *ContactMutation) ClearEdge(name string) error {
  7459. switch name {
  7460. }
  7461. return fmt.Errorf("unknown Contact unique edge %s", name)
  7462. }
  7463. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7464. // It returns an error if the edge is not defined in the schema.
  7465. func (m *ContactMutation) ResetEdge(name string) error {
  7466. switch name {
  7467. case contact.EdgeContactRelationships:
  7468. m.ResetContactRelationships()
  7469. return nil
  7470. case contact.EdgeContactMessages:
  7471. m.ResetContactMessages()
  7472. return nil
  7473. }
  7474. return fmt.Errorf("unknown Contact edge %s", name)
  7475. }
  7476. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  7477. type EmployeeMutation struct {
  7478. config
  7479. op Op
  7480. typ string
  7481. id *uint64
  7482. created_at *time.Time
  7483. updated_at *time.Time
  7484. deleted_at *time.Time
  7485. title *string
  7486. avatar *string
  7487. tags *string
  7488. hire_count *int
  7489. addhire_count *int
  7490. service_count *int
  7491. addservice_count *int
  7492. achievement_count *int
  7493. addachievement_count *int
  7494. intro *string
  7495. estimate *string
  7496. skill *string
  7497. ability_type *string
  7498. scene *string
  7499. switch_in *string
  7500. video_url *string
  7501. organization_id *uint64
  7502. addorganization_id *int64
  7503. category_id *uint64
  7504. addcategory_id *int64
  7505. api_base *string
  7506. api_key *string
  7507. ai_info *string
  7508. is_vip *int
  7509. addis_vip *int
  7510. clearedFields map[string]struct{}
  7511. em_work_experiences map[uint64]struct{}
  7512. removedem_work_experiences map[uint64]struct{}
  7513. clearedem_work_experiences bool
  7514. em_tutorial map[uint64]struct{}
  7515. removedem_tutorial map[uint64]struct{}
  7516. clearedem_tutorial bool
  7517. done bool
  7518. oldValue func(context.Context) (*Employee, error)
  7519. predicates []predicate.Employee
  7520. }
  7521. var _ ent.Mutation = (*EmployeeMutation)(nil)
  7522. // employeeOption allows management of the mutation configuration using functional options.
  7523. type employeeOption func(*EmployeeMutation)
  7524. // newEmployeeMutation creates new mutation for the Employee entity.
  7525. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  7526. m := &EmployeeMutation{
  7527. config: c,
  7528. op: op,
  7529. typ: TypeEmployee,
  7530. clearedFields: make(map[string]struct{}),
  7531. }
  7532. for _, opt := range opts {
  7533. opt(m)
  7534. }
  7535. return m
  7536. }
  7537. // withEmployeeID sets the ID field of the mutation.
  7538. func withEmployeeID(id uint64) employeeOption {
  7539. return func(m *EmployeeMutation) {
  7540. var (
  7541. err error
  7542. once sync.Once
  7543. value *Employee
  7544. )
  7545. m.oldValue = func(ctx context.Context) (*Employee, error) {
  7546. once.Do(func() {
  7547. if m.done {
  7548. err = errors.New("querying old values post mutation is not allowed")
  7549. } else {
  7550. value, err = m.Client().Employee.Get(ctx, id)
  7551. }
  7552. })
  7553. return value, err
  7554. }
  7555. m.id = &id
  7556. }
  7557. }
  7558. // withEmployee sets the old Employee of the mutation.
  7559. func withEmployee(node *Employee) employeeOption {
  7560. return func(m *EmployeeMutation) {
  7561. m.oldValue = func(context.Context) (*Employee, error) {
  7562. return node, nil
  7563. }
  7564. m.id = &node.ID
  7565. }
  7566. }
  7567. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7568. // executed in a transaction (ent.Tx), a transactional client is returned.
  7569. func (m EmployeeMutation) Client() *Client {
  7570. client := &Client{config: m.config}
  7571. client.init()
  7572. return client
  7573. }
  7574. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7575. // it returns an error otherwise.
  7576. func (m EmployeeMutation) Tx() (*Tx, error) {
  7577. if _, ok := m.driver.(*txDriver); !ok {
  7578. return nil, errors.New("ent: mutation is not running in a transaction")
  7579. }
  7580. tx := &Tx{config: m.config}
  7581. tx.init()
  7582. return tx, nil
  7583. }
  7584. // SetID sets the value of the id field. Note that this
  7585. // operation is only accepted on creation of Employee entities.
  7586. func (m *EmployeeMutation) SetID(id uint64) {
  7587. m.id = &id
  7588. }
  7589. // ID returns the ID value in the mutation. Note that the ID is only available
  7590. // if it was provided to the builder or after it was returned from the database.
  7591. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  7592. if m.id == nil {
  7593. return
  7594. }
  7595. return *m.id, true
  7596. }
  7597. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7598. // That means, if the mutation is applied within a transaction with an isolation level such
  7599. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7600. // or updated by the mutation.
  7601. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  7602. switch {
  7603. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7604. id, exists := m.ID()
  7605. if exists {
  7606. return []uint64{id}, nil
  7607. }
  7608. fallthrough
  7609. case m.op.Is(OpUpdate | OpDelete):
  7610. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  7611. default:
  7612. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7613. }
  7614. }
  7615. // SetCreatedAt sets the "created_at" field.
  7616. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  7617. m.created_at = &t
  7618. }
  7619. // CreatedAt returns the value of the "created_at" field in the mutation.
  7620. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  7621. v := m.created_at
  7622. if v == nil {
  7623. return
  7624. }
  7625. return *v, true
  7626. }
  7627. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  7628. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7630. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7631. if !m.op.Is(OpUpdateOne) {
  7632. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7633. }
  7634. if m.id == nil || m.oldValue == nil {
  7635. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7636. }
  7637. oldValue, err := m.oldValue(ctx)
  7638. if err != nil {
  7639. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7640. }
  7641. return oldValue.CreatedAt, nil
  7642. }
  7643. // ResetCreatedAt resets all changes to the "created_at" field.
  7644. func (m *EmployeeMutation) ResetCreatedAt() {
  7645. m.created_at = nil
  7646. }
  7647. // SetUpdatedAt sets the "updated_at" field.
  7648. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  7649. m.updated_at = &t
  7650. }
  7651. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7652. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  7653. v := m.updated_at
  7654. if v == nil {
  7655. return
  7656. }
  7657. return *v, true
  7658. }
  7659. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  7660. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7662. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7663. if !m.op.Is(OpUpdateOne) {
  7664. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7665. }
  7666. if m.id == nil || m.oldValue == nil {
  7667. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7668. }
  7669. oldValue, err := m.oldValue(ctx)
  7670. if err != nil {
  7671. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7672. }
  7673. return oldValue.UpdatedAt, nil
  7674. }
  7675. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7676. func (m *EmployeeMutation) ResetUpdatedAt() {
  7677. m.updated_at = nil
  7678. }
  7679. // SetDeletedAt sets the "deleted_at" field.
  7680. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  7681. m.deleted_at = &t
  7682. }
  7683. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7684. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  7685. v := m.deleted_at
  7686. if v == nil {
  7687. return
  7688. }
  7689. return *v, true
  7690. }
  7691. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  7692. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7694. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7695. if !m.op.Is(OpUpdateOne) {
  7696. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7697. }
  7698. if m.id == nil || m.oldValue == nil {
  7699. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7700. }
  7701. oldValue, err := m.oldValue(ctx)
  7702. if err != nil {
  7703. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7704. }
  7705. return oldValue.DeletedAt, nil
  7706. }
  7707. // ClearDeletedAt clears the value of the "deleted_at" field.
  7708. func (m *EmployeeMutation) ClearDeletedAt() {
  7709. m.deleted_at = nil
  7710. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  7711. }
  7712. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7713. func (m *EmployeeMutation) DeletedAtCleared() bool {
  7714. _, ok := m.clearedFields[employee.FieldDeletedAt]
  7715. return ok
  7716. }
  7717. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7718. func (m *EmployeeMutation) ResetDeletedAt() {
  7719. m.deleted_at = nil
  7720. delete(m.clearedFields, employee.FieldDeletedAt)
  7721. }
  7722. // SetTitle sets the "title" field.
  7723. func (m *EmployeeMutation) SetTitle(s string) {
  7724. m.title = &s
  7725. }
  7726. // Title returns the value of the "title" field in the mutation.
  7727. func (m *EmployeeMutation) Title() (r string, exists bool) {
  7728. v := m.title
  7729. if v == nil {
  7730. return
  7731. }
  7732. return *v, true
  7733. }
  7734. // OldTitle returns the old "title" field's value of the Employee entity.
  7735. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7737. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  7738. if !m.op.Is(OpUpdateOne) {
  7739. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  7740. }
  7741. if m.id == nil || m.oldValue == nil {
  7742. return v, errors.New("OldTitle requires an ID field in the mutation")
  7743. }
  7744. oldValue, err := m.oldValue(ctx)
  7745. if err != nil {
  7746. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  7747. }
  7748. return oldValue.Title, nil
  7749. }
  7750. // ResetTitle resets all changes to the "title" field.
  7751. func (m *EmployeeMutation) ResetTitle() {
  7752. m.title = nil
  7753. }
  7754. // SetAvatar sets the "avatar" field.
  7755. func (m *EmployeeMutation) SetAvatar(s string) {
  7756. m.avatar = &s
  7757. }
  7758. // Avatar returns the value of the "avatar" field in the mutation.
  7759. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  7760. v := m.avatar
  7761. if v == nil {
  7762. return
  7763. }
  7764. return *v, true
  7765. }
  7766. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  7767. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7769. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  7770. if !m.op.Is(OpUpdateOne) {
  7771. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  7772. }
  7773. if m.id == nil || m.oldValue == nil {
  7774. return v, errors.New("OldAvatar requires an ID field in the mutation")
  7775. }
  7776. oldValue, err := m.oldValue(ctx)
  7777. if err != nil {
  7778. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  7779. }
  7780. return oldValue.Avatar, nil
  7781. }
  7782. // ResetAvatar resets all changes to the "avatar" field.
  7783. func (m *EmployeeMutation) ResetAvatar() {
  7784. m.avatar = nil
  7785. }
  7786. // SetTags sets the "tags" field.
  7787. func (m *EmployeeMutation) SetTags(s string) {
  7788. m.tags = &s
  7789. }
  7790. // Tags returns the value of the "tags" field in the mutation.
  7791. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  7792. v := m.tags
  7793. if v == nil {
  7794. return
  7795. }
  7796. return *v, true
  7797. }
  7798. // OldTags returns the old "tags" field's value of the Employee entity.
  7799. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7801. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  7802. if !m.op.Is(OpUpdateOne) {
  7803. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  7804. }
  7805. if m.id == nil || m.oldValue == nil {
  7806. return v, errors.New("OldTags requires an ID field in the mutation")
  7807. }
  7808. oldValue, err := m.oldValue(ctx)
  7809. if err != nil {
  7810. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  7811. }
  7812. return oldValue.Tags, nil
  7813. }
  7814. // ResetTags resets all changes to the "tags" field.
  7815. func (m *EmployeeMutation) ResetTags() {
  7816. m.tags = nil
  7817. }
  7818. // SetHireCount sets the "hire_count" field.
  7819. func (m *EmployeeMutation) SetHireCount(i int) {
  7820. m.hire_count = &i
  7821. m.addhire_count = nil
  7822. }
  7823. // HireCount returns the value of the "hire_count" field in the mutation.
  7824. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  7825. v := m.hire_count
  7826. if v == nil {
  7827. return
  7828. }
  7829. return *v, true
  7830. }
  7831. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  7832. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7834. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  7835. if !m.op.Is(OpUpdateOne) {
  7836. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  7837. }
  7838. if m.id == nil || m.oldValue == nil {
  7839. return v, errors.New("OldHireCount requires an ID field in the mutation")
  7840. }
  7841. oldValue, err := m.oldValue(ctx)
  7842. if err != nil {
  7843. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  7844. }
  7845. return oldValue.HireCount, nil
  7846. }
  7847. // AddHireCount adds i to the "hire_count" field.
  7848. func (m *EmployeeMutation) AddHireCount(i int) {
  7849. if m.addhire_count != nil {
  7850. *m.addhire_count += i
  7851. } else {
  7852. m.addhire_count = &i
  7853. }
  7854. }
  7855. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  7856. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  7857. v := m.addhire_count
  7858. if v == nil {
  7859. return
  7860. }
  7861. return *v, true
  7862. }
  7863. // ResetHireCount resets all changes to the "hire_count" field.
  7864. func (m *EmployeeMutation) ResetHireCount() {
  7865. m.hire_count = nil
  7866. m.addhire_count = nil
  7867. }
  7868. // SetServiceCount sets the "service_count" field.
  7869. func (m *EmployeeMutation) SetServiceCount(i int) {
  7870. m.service_count = &i
  7871. m.addservice_count = nil
  7872. }
  7873. // ServiceCount returns the value of the "service_count" field in the mutation.
  7874. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  7875. v := m.service_count
  7876. if v == nil {
  7877. return
  7878. }
  7879. return *v, true
  7880. }
  7881. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  7882. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7884. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  7885. if !m.op.Is(OpUpdateOne) {
  7886. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  7887. }
  7888. if m.id == nil || m.oldValue == nil {
  7889. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  7890. }
  7891. oldValue, err := m.oldValue(ctx)
  7892. if err != nil {
  7893. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  7894. }
  7895. return oldValue.ServiceCount, nil
  7896. }
  7897. // AddServiceCount adds i to the "service_count" field.
  7898. func (m *EmployeeMutation) AddServiceCount(i int) {
  7899. if m.addservice_count != nil {
  7900. *m.addservice_count += i
  7901. } else {
  7902. m.addservice_count = &i
  7903. }
  7904. }
  7905. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  7906. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  7907. v := m.addservice_count
  7908. if v == nil {
  7909. return
  7910. }
  7911. return *v, true
  7912. }
  7913. // ResetServiceCount resets all changes to the "service_count" field.
  7914. func (m *EmployeeMutation) ResetServiceCount() {
  7915. m.service_count = nil
  7916. m.addservice_count = nil
  7917. }
  7918. // SetAchievementCount sets the "achievement_count" field.
  7919. func (m *EmployeeMutation) SetAchievementCount(i int) {
  7920. m.achievement_count = &i
  7921. m.addachievement_count = nil
  7922. }
  7923. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  7924. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  7925. v := m.achievement_count
  7926. if v == nil {
  7927. return
  7928. }
  7929. return *v, true
  7930. }
  7931. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  7932. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7934. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  7935. if !m.op.Is(OpUpdateOne) {
  7936. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  7937. }
  7938. if m.id == nil || m.oldValue == nil {
  7939. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  7940. }
  7941. oldValue, err := m.oldValue(ctx)
  7942. if err != nil {
  7943. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  7944. }
  7945. return oldValue.AchievementCount, nil
  7946. }
  7947. // AddAchievementCount adds i to the "achievement_count" field.
  7948. func (m *EmployeeMutation) AddAchievementCount(i int) {
  7949. if m.addachievement_count != nil {
  7950. *m.addachievement_count += i
  7951. } else {
  7952. m.addachievement_count = &i
  7953. }
  7954. }
  7955. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  7956. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  7957. v := m.addachievement_count
  7958. if v == nil {
  7959. return
  7960. }
  7961. return *v, true
  7962. }
  7963. // ResetAchievementCount resets all changes to the "achievement_count" field.
  7964. func (m *EmployeeMutation) ResetAchievementCount() {
  7965. m.achievement_count = nil
  7966. m.addachievement_count = nil
  7967. }
  7968. // SetIntro sets the "intro" field.
  7969. func (m *EmployeeMutation) SetIntro(s string) {
  7970. m.intro = &s
  7971. }
  7972. // Intro returns the value of the "intro" field in the mutation.
  7973. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  7974. v := m.intro
  7975. if v == nil {
  7976. return
  7977. }
  7978. return *v, true
  7979. }
  7980. // OldIntro returns the old "intro" field's value of the Employee entity.
  7981. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7983. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  7984. if !m.op.Is(OpUpdateOne) {
  7985. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  7986. }
  7987. if m.id == nil || m.oldValue == nil {
  7988. return v, errors.New("OldIntro requires an ID field in the mutation")
  7989. }
  7990. oldValue, err := m.oldValue(ctx)
  7991. if err != nil {
  7992. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  7993. }
  7994. return oldValue.Intro, nil
  7995. }
  7996. // ResetIntro resets all changes to the "intro" field.
  7997. func (m *EmployeeMutation) ResetIntro() {
  7998. m.intro = nil
  7999. }
  8000. // SetEstimate sets the "estimate" field.
  8001. func (m *EmployeeMutation) SetEstimate(s string) {
  8002. m.estimate = &s
  8003. }
  8004. // Estimate returns the value of the "estimate" field in the mutation.
  8005. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  8006. v := m.estimate
  8007. if v == nil {
  8008. return
  8009. }
  8010. return *v, true
  8011. }
  8012. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  8013. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8015. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  8016. if !m.op.Is(OpUpdateOne) {
  8017. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  8018. }
  8019. if m.id == nil || m.oldValue == nil {
  8020. return v, errors.New("OldEstimate requires an ID field in the mutation")
  8021. }
  8022. oldValue, err := m.oldValue(ctx)
  8023. if err != nil {
  8024. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  8025. }
  8026. return oldValue.Estimate, nil
  8027. }
  8028. // ResetEstimate resets all changes to the "estimate" field.
  8029. func (m *EmployeeMutation) ResetEstimate() {
  8030. m.estimate = nil
  8031. }
  8032. // SetSkill sets the "skill" field.
  8033. func (m *EmployeeMutation) SetSkill(s string) {
  8034. m.skill = &s
  8035. }
  8036. // Skill returns the value of the "skill" field in the mutation.
  8037. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  8038. v := m.skill
  8039. if v == nil {
  8040. return
  8041. }
  8042. return *v, true
  8043. }
  8044. // OldSkill returns the old "skill" field's value of the Employee entity.
  8045. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8047. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  8048. if !m.op.Is(OpUpdateOne) {
  8049. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  8050. }
  8051. if m.id == nil || m.oldValue == nil {
  8052. return v, errors.New("OldSkill requires an ID field in the mutation")
  8053. }
  8054. oldValue, err := m.oldValue(ctx)
  8055. if err != nil {
  8056. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  8057. }
  8058. return oldValue.Skill, nil
  8059. }
  8060. // ResetSkill resets all changes to the "skill" field.
  8061. func (m *EmployeeMutation) ResetSkill() {
  8062. m.skill = nil
  8063. }
  8064. // SetAbilityType sets the "ability_type" field.
  8065. func (m *EmployeeMutation) SetAbilityType(s string) {
  8066. m.ability_type = &s
  8067. }
  8068. // AbilityType returns the value of the "ability_type" field in the mutation.
  8069. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  8070. v := m.ability_type
  8071. if v == nil {
  8072. return
  8073. }
  8074. return *v, true
  8075. }
  8076. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  8077. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8079. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  8080. if !m.op.Is(OpUpdateOne) {
  8081. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  8082. }
  8083. if m.id == nil || m.oldValue == nil {
  8084. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  8085. }
  8086. oldValue, err := m.oldValue(ctx)
  8087. if err != nil {
  8088. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  8089. }
  8090. return oldValue.AbilityType, nil
  8091. }
  8092. // ResetAbilityType resets all changes to the "ability_type" field.
  8093. func (m *EmployeeMutation) ResetAbilityType() {
  8094. m.ability_type = nil
  8095. }
  8096. // SetScene sets the "scene" field.
  8097. func (m *EmployeeMutation) SetScene(s string) {
  8098. m.scene = &s
  8099. }
  8100. // Scene returns the value of the "scene" field in the mutation.
  8101. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  8102. v := m.scene
  8103. if v == nil {
  8104. return
  8105. }
  8106. return *v, true
  8107. }
  8108. // OldScene returns the old "scene" field's value of the Employee entity.
  8109. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8111. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  8112. if !m.op.Is(OpUpdateOne) {
  8113. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  8114. }
  8115. if m.id == nil || m.oldValue == nil {
  8116. return v, errors.New("OldScene requires an ID field in the mutation")
  8117. }
  8118. oldValue, err := m.oldValue(ctx)
  8119. if err != nil {
  8120. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  8121. }
  8122. return oldValue.Scene, nil
  8123. }
  8124. // ResetScene resets all changes to the "scene" field.
  8125. func (m *EmployeeMutation) ResetScene() {
  8126. m.scene = nil
  8127. }
  8128. // SetSwitchIn sets the "switch_in" field.
  8129. func (m *EmployeeMutation) SetSwitchIn(s string) {
  8130. m.switch_in = &s
  8131. }
  8132. // SwitchIn returns the value of the "switch_in" field in the mutation.
  8133. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  8134. v := m.switch_in
  8135. if v == nil {
  8136. return
  8137. }
  8138. return *v, true
  8139. }
  8140. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  8141. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8143. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  8144. if !m.op.Is(OpUpdateOne) {
  8145. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  8146. }
  8147. if m.id == nil || m.oldValue == nil {
  8148. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  8149. }
  8150. oldValue, err := m.oldValue(ctx)
  8151. if err != nil {
  8152. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  8153. }
  8154. return oldValue.SwitchIn, nil
  8155. }
  8156. // ResetSwitchIn resets all changes to the "switch_in" field.
  8157. func (m *EmployeeMutation) ResetSwitchIn() {
  8158. m.switch_in = nil
  8159. }
  8160. // SetVideoURL sets the "video_url" field.
  8161. func (m *EmployeeMutation) SetVideoURL(s string) {
  8162. m.video_url = &s
  8163. }
  8164. // VideoURL returns the value of the "video_url" field in the mutation.
  8165. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  8166. v := m.video_url
  8167. if v == nil {
  8168. return
  8169. }
  8170. return *v, true
  8171. }
  8172. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  8173. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8175. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  8176. if !m.op.Is(OpUpdateOne) {
  8177. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  8178. }
  8179. if m.id == nil || m.oldValue == nil {
  8180. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  8181. }
  8182. oldValue, err := m.oldValue(ctx)
  8183. if err != nil {
  8184. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  8185. }
  8186. return oldValue.VideoURL, nil
  8187. }
  8188. // ResetVideoURL resets all changes to the "video_url" field.
  8189. func (m *EmployeeMutation) ResetVideoURL() {
  8190. m.video_url = nil
  8191. }
  8192. // SetOrganizationID sets the "organization_id" field.
  8193. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  8194. m.organization_id = &u
  8195. m.addorganization_id = nil
  8196. }
  8197. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8198. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  8199. v := m.organization_id
  8200. if v == nil {
  8201. return
  8202. }
  8203. return *v, true
  8204. }
  8205. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  8206. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8208. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8209. if !m.op.Is(OpUpdateOne) {
  8210. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8211. }
  8212. if m.id == nil || m.oldValue == nil {
  8213. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8214. }
  8215. oldValue, err := m.oldValue(ctx)
  8216. if err != nil {
  8217. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8218. }
  8219. return oldValue.OrganizationID, nil
  8220. }
  8221. // AddOrganizationID adds u to the "organization_id" field.
  8222. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  8223. if m.addorganization_id != nil {
  8224. *m.addorganization_id += u
  8225. } else {
  8226. m.addorganization_id = &u
  8227. }
  8228. }
  8229. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8230. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  8231. v := m.addorganization_id
  8232. if v == nil {
  8233. return
  8234. }
  8235. return *v, true
  8236. }
  8237. // ResetOrganizationID resets all changes to the "organization_id" field.
  8238. func (m *EmployeeMutation) ResetOrganizationID() {
  8239. m.organization_id = nil
  8240. m.addorganization_id = nil
  8241. }
  8242. // SetCategoryID sets the "category_id" field.
  8243. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  8244. m.category_id = &u
  8245. m.addcategory_id = nil
  8246. }
  8247. // CategoryID returns the value of the "category_id" field in the mutation.
  8248. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  8249. v := m.category_id
  8250. if v == nil {
  8251. return
  8252. }
  8253. return *v, true
  8254. }
  8255. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  8256. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8258. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  8259. if !m.op.Is(OpUpdateOne) {
  8260. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  8261. }
  8262. if m.id == nil || m.oldValue == nil {
  8263. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  8264. }
  8265. oldValue, err := m.oldValue(ctx)
  8266. if err != nil {
  8267. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  8268. }
  8269. return oldValue.CategoryID, nil
  8270. }
  8271. // AddCategoryID adds u to the "category_id" field.
  8272. func (m *EmployeeMutation) AddCategoryID(u int64) {
  8273. if m.addcategory_id != nil {
  8274. *m.addcategory_id += u
  8275. } else {
  8276. m.addcategory_id = &u
  8277. }
  8278. }
  8279. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  8280. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  8281. v := m.addcategory_id
  8282. if v == nil {
  8283. return
  8284. }
  8285. return *v, true
  8286. }
  8287. // ResetCategoryID resets all changes to the "category_id" field.
  8288. func (m *EmployeeMutation) ResetCategoryID() {
  8289. m.category_id = nil
  8290. m.addcategory_id = nil
  8291. }
  8292. // SetAPIBase sets the "api_base" field.
  8293. func (m *EmployeeMutation) SetAPIBase(s string) {
  8294. m.api_base = &s
  8295. }
  8296. // APIBase returns the value of the "api_base" field in the mutation.
  8297. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  8298. v := m.api_base
  8299. if v == nil {
  8300. return
  8301. }
  8302. return *v, true
  8303. }
  8304. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  8305. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8307. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  8308. if !m.op.Is(OpUpdateOne) {
  8309. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  8310. }
  8311. if m.id == nil || m.oldValue == nil {
  8312. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  8313. }
  8314. oldValue, err := m.oldValue(ctx)
  8315. if err != nil {
  8316. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  8317. }
  8318. return oldValue.APIBase, nil
  8319. }
  8320. // ResetAPIBase resets all changes to the "api_base" field.
  8321. func (m *EmployeeMutation) ResetAPIBase() {
  8322. m.api_base = nil
  8323. }
  8324. // SetAPIKey sets the "api_key" field.
  8325. func (m *EmployeeMutation) SetAPIKey(s string) {
  8326. m.api_key = &s
  8327. }
  8328. // APIKey returns the value of the "api_key" field in the mutation.
  8329. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  8330. v := m.api_key
  8331. if v == nil {
  8332. return
  8333. }
  8334. return *v, true
  8335. }
  8336. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  8337. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8339. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  8340. if !m.op.Is(OpUpdateOne) {
  8341. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  8342. }
  8343. if m.id == nil || m.oldValue == nil {
  8344. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  8345. }
  8346. oldValue, err := m.oldValue(ctx)
  8347. if err != nil {
  8348. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  8349. }
  8350. return oldValue.APIKey, nil
  8351. }
  8352. // ResetAPIKey resets all changes to the "api_key" field.
  8353. func (m *EmployeeMutation) ResetAPIKey() {
  8354. m.api_key = nil
  8355. }
  8356. // SetAiInfo sets the "ai_info" field.
  8357. func (m *EmployeeMutation) SetAiInfo(s string) {
  8358. m.ai_info = &s
  8359. }
  8360. // AiInfo returns the value of the "ai_info" field in the mutation.
  8361. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  8362. v := m.ai_info
  8363. if v == nil {
  8364. return
  8365. }
  8366. return *v, true
  8367. }
  8368. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  8369. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8371. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  8372. if !m.op.Is(OpUpdateOne) {
  8373. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  8374. }
  8375. if m.id == nil || m.oldValue == nil {
  8376. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  8377. }
  8378. oldValue, err := m.oldValue(ctx)
  8379. if err != nil {
  8380. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  8381. }
  8382. return oldValue.AiInfo, nil
  8383. }
  8384. // ClearAiInfo clears the value of the "ai_info" field.
  8385. func (m *EmployeeMutation) ClearAiInfo() {
  8386. m.ai_info = nil
  8387. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  8388. }
  8389. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  8390. func (m *EmployeeMutation) AiInfoCleared() bool {
  8391. _, ok := m.clearedFields[employee.FieldAiInfo]
  8392. return ok
  8393. }
  8394. // ResetAiInfo resets all changes to the "ai_info" field.
  8395. func (m *EmployeeMutation) ResetAiInfo() {
  8396. m.ai_info = nil
  8397. delete(m.clearedFields, employee.FieldAiInfo)
  8398. }
  8399. // SetIsVip sets the "is_vip" field.
  8400. func (m *EmployeeMutation) SetIsVip(i int) {
  8401. m.is_vip = &i
  8402. m.addis_vip = nil
  8403. }
  8404. // IsVip returns the value of the "is_vip" field in the mutation.
  8405. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  8406. v := m.is_vip
  8407. if v == nil {
  8408. return
  8409. }
  8410. return *v, true
  8411. }
  8412. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  8413. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8415. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  8416. if !m.op.Is(OpUpdateOne) {
  8417. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  8418. }
  8419. if m.id == nil || m.oldValue == nil {
  8420. return v, errors.New("OldIsVip requires an ID field in the mutation")
  8421. }
  8422. oldValue, err := m.oldValue(ctx)
  8423. if err != nil {
  8424. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  8425. }
  8426. return oldValue.IsVip, nil
  8427. }
  8428. // AddIsVip adds i to the "is_vip" field.
  8429. func (m *EmployeeMutation) AddIsVip(i int) {
  8430. if m.addis_vip != nil {
  8431. *m.addis_vip += i
  8432. } else {
  8433. m.addis_vip = &i
  8434. }
  8435. }
  8436. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  8437. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  8438. v := m.addis_vip
  8439. if v == nil {
  8440. return
  8441. }
  8442. return *v, true
  8443. }
  8444. // ResetIsVip resets all changes to the "is_vip" field.
  8445. func (m *EmployeeMutation) ResetIsVip() {
  8446. m.is_vip = nil
  8447. m.addis_vip = nil
  8448. }
  8449. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  8450. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  8451. if m.em_work_experiences == nil {
  8452. m.em_work_experiences = make(map[uint64]struct{})
  8453. }
  8454. for i := range ids {
  8455. m.em_work_experiences[ids[i]] = struct{}{}
  8456. }
  8457. }
  8458. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  8459. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  8460. m.clearedem_work_experiences = true
  8461. }
  8462. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  8463. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  8464. return m.clearedem_work_experiences
  8465. }
  8466. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  8467. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  8468. if m.removedem_work_experiences == nil {
  8469. m.removedem_work_experiences = make(map[uint64]struct{})
  8470. }
  8471. for i := range ids {
  8472. delete(m.em_work_experiences, ids[i])
  8473. m.removedem_work_experiences[ids[i]] = struct{}{}
  8474. }
  8475. }
  8476. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  8477. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  8478. for id := range m.removedem_work_experiences {
  8479. ids = append(ids, id)
  8480. }
  8481. return
  8482. }
  8483. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  8484. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  8485. for id := range m.em_work_experiences {
  8486. ids = append(ids, id)
  8487. }
  8488. return
  8489. }
  8490. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  8491. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  8492. m.em_work_experiences = nil
  8493. m.clearedem_work_experiences = false
  8494. m.removedem_work_experiences = nil
  8495. }
  8496. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  8497. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  8498. if m.em_tutorial == nil {
  8499. m.em_tutorial = make(map[uint64]struct{})
  8500. }
  8501. for i := range ids {
  8502. m.em_tutorial[ids[i]] = struct{}{}
  8503. }
  8504. }
  8505. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  8506. func (m *EmployeeMutation) ClearEmTutorial() {
  8507. m.clearedem_tutorial = true
  8508. }
  8509. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  8510. func (m *EmployeeMutation) EmTutorialCleared() bool {
  8511. return m.clearedem_tutorial
  8512. }
  8513. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  8514. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  8515. if m.removedem_tutorial == nil {
  8516. m.removedem_tutorial = make(map[uint64]struct{})
  8517. }
  8518. for i := range ids {
  8519. delete(m.em_tutorial, ids[i])
  8520. m.removedem_tutorial[ids[i]] = struct{}{}
  8521. }
  8522. }
  8523. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  8524. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  8525. for id := range m.removedem_tutorial {
  8526. ids = append(ids, id)
  8527. }
  8528. return
  8529. }
  8530. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  8531. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  8532. for id := range m.em_tutorial {
  8533. ids = append(ids, id)
  8534. }
  8535. return
  8536. }
  8537. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  8538. func (m *EmployeeMutation) ResetEmTutorial() {
  8539. m.em_tutorial = nil
  8540. m.clearedem_tutorial = false
  8541. m.removedem_tutorial = nil
  8542. }
  8543. // Where appends a list predicates to the EmployeeMutation builder.
  8544. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  8545. m.predicates = append(m.predicates, ps...)
  8546. }
  8547. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  8548. // users can use type-assertion to append predicates that do not depend on any generated package.
  8549. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  8550. p := make([]predicate.Employee, len(ps))
  8551. for i := range ps {
  8552. p[i] = ps[i]
  8553. }
  8554. m.Where(p...)
  8555. }
  8556. // Op returns the operation name.
  8557. func (m *EmployeeMutation) Op() Op {
  8558. return m.op
  8559. }
  8560. // SetOp allows setting the mutation operation.
  8561. func (m *EmployeeMutation) SetOp(op Op) {
  8562. m.op = op
  8563. }
  8564. // Type returns the node type of this mutation (Employee).
  8565. func (m *EmployeeMutation) Type() string {
  8566. return m.typ
  8567. }
  8568. // Fields returns all fields that were changed during this mutation. Note that in
  8569. // order to get all numeric fields that were incremented/decremented, call
  8570. // AddedFields().
  8571. func (m *EmployeeMutation) Fields() []string {
  8572. fields := make([]string, 0, 22)
  8573. if m.created_at != nil {
  8574. fields = append(fields, employee.FieldCreatedAt)
  8575. }
  8576. if m.updated_at != nil {
  8577. fields = append(fields, employee.FieldUpdatedAt)
  8578. }
  8579. if m.deleted_at != nil {
  8580. fields = append(fields, employee.FieldDeletedAt)
  8581. }
  8582. if m.title != nil {
  8583. fields = append(fields, employee.FieldTitle)
  8584. }
  8585. if m.avatar != nil {
  8586. fields = append(fields, employee.FieldAvatar)
  8587. }
  8588. if m.tags != nil {
  8589. fields = append(fields, employee.FieldTags)
  8590. }
  8591. if m.hire_count != nil {
  8592. fields = append(fields, employee.FieldHireCount)
  8593. }
  8594. if m.service_count != nil {
  8595. fields = append(fields, employee.FieldServiceCount)
  8596. }
  8597. if m.achievement_count != nil {
  8598. fields = append(fields, employee.FieldAchievementCount)
  8599. }
  8600. if m.intro != nil {
  8601. fields = append(fields, employee.FieldIntro)
  8602. }
  8603. if m.estimate != nil {
  8604. fields = append(fields, employee.FieldEstimate)
  8605. }
  8606. if m.skill != nil {
  8607. fields = append(fields, employee.FieldSkill)
  8608. }
  8609. if m.ability_type != nil {
  8610. fields = append(fields, employee.FieldAbilityType)
  8611. }
  8612. if m.scene != nil {
  8613. fields = append(fields, employee.FieldScene)
  8614. }
  8615. if m.switch_in != nil {
  8616. fields = append(fields, employee.FieldSwitchIn)
  8617. }
  8618. if m.video_url != nil {
  8619. fields = append(fields, employee.FieldVideoURL)
  8620. }
  8621. if m.organization_id != nil {
  8622. fields = append(fields, employee.FieldOrganizationID)
  8623. }
  8624. if m.category_id != nil {
  8625. fields = append(fields, employee.FieldCategoryID)
  8626. }
  8627. if m.api_base != nil {
  8628. fields = append(fields, employee.FieldAPIBase)
  8629. }
  8630. if m.api_key != nil {
  8631. fields = append(fields, employee.FieldAPIKey)
  8632. }
  8633. if m.ai_info != nil {
  8634. fields = append(fields, employee.FieldAiInfo)
  8635. }
  8636. if m.is_vip != nil {
  8637. fields = append(fields, employee.FieldIsVip)
  8638. }
  8639. return fields
  8640. }
  8641. // Field returns the value of a field with the given name. The second boolean
  8642. // return value indicates that this field was not set, or was not defined in the
  8643. // schema.
  8644. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  8645. switch name {
  8646. case employee.FieldCreatedAt:
  8647. return m.CreatedAt()
  8648. case employee.FieldUpdatedAt:
  8649. return m.UpdatedAt()
  8650. case employee.FieldDeletedAt:
  8651. return m.DeletedAt()
  8652. case employee.FieldTitle:
  8653. return m.Title()
  8654. case employee.FieldAvatar:
  8655. return m.Avatar()
  8656. case employee.FieldTags:
  8657. return m.Tags()
  8658. case employee.FieldHireCount:
  8659. return m.HireCount()
  8660. case employee.FieldServiceCount:
  8661. return m.ServiceCount()
  8662. case employee.FieldAchievementCount:
  8663. return m.AchievementCount()
  8664. case employee.FieldIntro:
  8665. return m.Intro()
  8666. case employee.FieldEstimate:
  8667. return m.Estimate()
  8668. case employee.FieldSkill:
  8669. return m.Skill()
  8670. case employee.FieldAbilityType:
  8671. return m.AbilityType()
  8672. case employee.FieldScene:
  8673. return m.Scene()
  8674. case employee.FieldSwitchIn:
  8675. return m.SwitchIn()
  8676. case employee.FieldVideoURL:
  8677. return m.VideoURL()
  8678. case employee.FieldOrganizationID:
  8679. return m.OrganizationID()
  8680. case employee.FieldCategoryID:
  8681. return m.CategoryID()
  8682. case employee.FieldAPIBase:
  8683. return m.APIBase()
  8684. case employee.FieldAPIKey:
  8685. return m.APIKey()
  8686. case employee.FieldAiInfo:
  8687. return m.AiInfo()
  8688. case employee.FieldIsVip:
  8689. return m.IsVip()
  8690. }
  8691. return nil, false
  8692. }
  8693. // OldField returns the old value of the field from the database. An error is
  8694. // returned if the mutation operation is not UpdateOne, or the query to the
  8695. // database failed.
  8696. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8697. switch name {
  8698. case employee.FieldCreatedAt:
  8699. return m.OldCreatedAt(ctx)
  8700. case employee.FieldUpdatedAt:
  8701. return m.OldUpdatedAt(ctx)
  8702. case employee.FieldDeletedAt:
  8703. return m.OldDeletedAt(ctx)
  8704. case employee.FieldTitle:
  8705. return m.OldTitle(ctx)
  8706. case employee.FieldAvatar:
  8707. return m.OldAvatar(ctx)
  8708. case employee.FieldTags:
  8709. return m.OldTags(ctx)
  8710. case employee.FieldHireCount:
  8711. return m.OldHireCount(ctx)
  8712. case employee.FieldServiceCount:
  8713. return m.OldServiceCount(ctx)
  8714. case employee.FieldAchievementCount:
  8715. return m.OldAchievementCount(ctx)
  8716. case employee.FieldIntro:
  8717. return m.OldIntro(ctx)
  8718. case employee.FieldEstimate:
  8719. return m.OldEstimate(ctx)
  8720. case employee.FieldSkill:
  8721. return m.OldSkill(ctx)
  8722. case employee.FieldAbilityType:
  8723. return m.OldAbilityType(ctx)
  8724. case employee.FieldScene:
  8725. return m.OldScene(ctx)
  8726. case employee.FieldSwitchIn:
  8727. return m.OldSwitchIn(ctx)
  8728. case employee.FieldVideoURL:
  8729. return m.OldVideoURL(ctx)
  8730. case employee.FieldOrganizationID:
  8731. return m.OldOrganizationID(ctx)
  8732. case employee.FieldCategoryID:
  8733. return m.OldCategoryID(ctx)
  8734. case employee.FieldAPIBase:
  8735. return m.OldAPIBase(ctx)
  8736. case employee.FieldAPIKey:
  8737. return m.OldAPIKey(ctx)
  8738. case employee.FieldAiInfo:
  8739. return m.OldAiInfo(ctx)
  8740. case employee.FieldIsVip:
  8741. return m.OldIsVip(ctx)
  8742. }
  8743. return nil, fmt.Errorf("unknown Employee field %s", name)
  8744. }
  8745. // SetField sets the value of a field with the given name. It returns an error if
  8746. // the field is not defined in the schema, or if the type mismatched the field
  8747. // type.
  8748. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  8749. switch name {
  8750. case employee.FieldCreatedAt:
  8751. v, ok := value.(time.Time)
  8752. if !ok {
  8753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8754. }
  8755. m.SetCreatedAt(v)
  8756. return nil
  8757. case employee.FieldUpdatedAt:
  8758. v, ok := value.(time.Time)
  8759. if !ok {
  8760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8761. }
  8762. m.SetUpdatedAt(v)
  8763. return nil
  8764. case employee.FieldDeletedAt:
  8765. v, ok := value.(time.Time)
  8766. if !ok {
  8767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8768. }
  8769. m.SetDeletedAt(v)
  8770. return nil
  8771. case employee.FieldTitle:
  8772. v, ok := value.(string)
  8773. if !ok {
  8774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8775. }
  8776. m.SetTitle(v)
  8777. return nil
  8778. case employee.FieldAvatar:
  8779. v, ok := value.(string)
  8780. if !ok {
  8781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8782. }
  8783. m.SetAvatar(v)
  8784. return nil
  8785. case employee.FieldTags:
  8786. v, ok := value.(string)
  8787. if !ok {
  8788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8789. }
  8790. m.SetTags(v)
  8791. return nil
  8792. case employee.FieldHireCount:
  8793. v, ok := value.(int)
  8794. if !ok {
  8795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8796. }
  8797. m.SetHireCount(v)
  8798. return nil
  8799. case employee.FieldServiceCount:
  8800. v, ok := value.(int)
  8801. if !ok {
  8802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8803. }
  8804. m.SetServiceCount(v)
  8805. return nil
  8806. case employee.FieldAchievementCount:
  8807. v, ok := value.(int)
  8808. if !ok {
  8809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8810. }
  8811. m.SetAchievementCount(v)
  8812. return nil
  8813. case employee.FieldIntro:
  8814. v, ok := value.(string)
  8815. if !ok {
  8816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8817. }
  8818. m.SetIntro(v)
  8819. return nil
  8820. case employee.FieldEstimate:
  8821. v, ok := value.(string)
  8822. if !ok {
  8823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8824. }
  8825. m.SetEstimate(v)
  8826. return nil
  8827. case employee.FieldSkill:
  8828. v, ok := value.(string)
  8829. if !ok {
  8830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8831. }
  8832. m.SetSkill(v)
  8833. return nil
  8834. case employee.FieldAbilityType:
  8835. v, ok := value.(string)
  8836. if !ok {
  8837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8838. }
  8839. m.SetAbilityType(v)
  8840. return nil
  8841. case employee.FieldScene:
  8842. v, ok := value.(string)
  8843. if !ok {
  8844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8845. }
  8846. m.SetScene(v)
  8847. return nil
  8848. case employee.FieldSwitchIn:
  8849. v, ok := value.(string)
  8850. if !ok {
  8851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8852. }
  8853. m.SetSwitchIn(v)
  8854. return nil
  8855. case employee.FieldVideoURL:
  8856. v, ok := value.(string)
  8857. if !ok {
  8858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8859. }
  8860. m.SetVideoURL(v)
  8861. return nil
  8862. case employee.FieldOrganizationID:
  8863. v, ok := value.(uint64)
  8864. if !ok {
  8865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8866. }
  8867. m.SetOrganizationID(v)
  8868. return nil
  8869. case employee.FieldCategoryID:
  8870. v, ok := value.(uint64)
  8871. if !ok {
  8872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8873. }
  8874. m.SetCategoryID(v)
  8875. return nil
  8876. case employee.FieldAPIBase:
  8877. v, ok := value.(string)
  8878. if !ok {
  8879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8880. }
  8881. m.SetAPIBase(v)
  8882. return nil
  8883. case employee.FieldAPIKey:
  8884. v, ok := value.(string)
  8885. if !ok {
  8886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8887. }
  8888. m.SetAPIKey(v)
  8889. return nil
  8890. case employee.FieldAiInfo:
  8891. v, ok := value.(string)
  8892. if !ok {
  8893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8894. }
  8895. m.SetAiInfo(v)
  8896. return nil
  8897. case employee.FieldIsVip:
  8898. v, ok := value.(int)
  8899. if !ok {
  8900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8901. }
  8902. m.SetIsVip(v)
  8903. return nil
  8904. }
  8905. return fmt.Errorf("unknown Employee field %s", name)
  8906. }
  8907. // AddedFields returns all numeric fields that were incremented/decremented during
  8908. // this mutation.
  8909. func (m *EmployeeMutation) AddedFields() []string {
  8910. var fields []string
  8911. if m.addhire_count != nil {
  8912. fields = append(fields, employee.FieldHireCount)
  8913. }
  8914. if m.addservice_count != nil {
  8915. fields = append(fields, employee.FieldServiceCount)
  8916. }
  8917. if m.addachievement_count != nil {
  8918. fields = append(fields, employee.FieldAchievementCount)
  8919. }
  8920. if m.addorganization_id != nil {
  8921. fields = append(fields, employee.FieldOrganizationID)
  8922. }
  8923. if m.addcategory_id != nil {
  8924. fields = append(fields, employee.FieldCategoryID)
  8925. }
  8926. if m.addis_vip != nil {
  8927. fields = append(fields, employee.FieldIsVip)
  8928. }
  8929. return fields
  8930. }
  8931. // AddedField returns the numeric value that was incremented/decremented on a field
  8932. // with the given name. The second boolean return value indicates that this field
  8933. // was not set, or was not defined in the schema.
  8934. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  8935. switch name {
  8936. case employee.FieldHireCount:
  8937. return m.AddedHireCount()
  8938. case employee.FieldServiceCount:
  8939. return m.AddedServiceCount()
  8940. case employee.FieldAchievementCount:
  8941. return m.AddedAchievementCount()
  8942. case employee.FieldOrganizationID:
  8943. return m.AddedOrganizationID()
  8944. case employee.FieldCategoryID:
  8945. return m.AddedCategoryID()
  8946. case employee.FieldIsVip:
  8947. return m.AddedIsVip()
  8948. }
  8949. return nil, false
  8950. }
  8951. // AddField adds the value to the field with the given name. It returns an error if
  8952. // the field is not defined in the schema, or if the type mismatched the field
  8953. // type.
  8954. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  8955. switch name {
  8956. case employee.FieldHireCount:
  8957. v, ok := value.(int)
  8958. if !ok {
  8959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8960. }
  8961. m.AddHireCount(v)
  8962. return nil
  8963. case employee.FieldServiceCount:
  8964. v, ok := value.(int)
  8965. if !ok {
  8966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8967. }
  8968. m.AddServiceCount(v)
  8969. return nil
  8970. case employee.FieldAchievementCount:
  8971. v, ok := value.(int)
  8972. if !ok {
  8973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8974. }
  8975. m.AddAchievementCount(v)
  8976. return nil
  8977. case employee.FieldOrganizationID:
  8978. v, ok := value.(int64)
  8979. if !ok {
  8980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8981. }
  8982. m.AddOrganizationID(v)
  8983. return nil
  8984. case employee.FieldCategoryID:
  8985. v, ok := value.(int64)
  8986. if !ok {
  8987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8988. }
  8989. m.AddCategoryID(v)
  8990. return nil
  8991. case employee.FieldIsVip:
  8992. v, ok := value.(int)
  8993. if !ok {
  8994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8995. }
  8996. m.AddIsVip(v)
  8997. return nil
  8998. }
  8999. return fmt.Errorf("unknown Employee numeric field %s", name)
  9000. }
  9001. // ClearedFields returns all nullable fields that were cleared during this
  9002. // mutation.
  9003. func (m *EmployeeMutation) ClearedFields() []string {
  9004. var fields []string
  9005. if m.FieldCleared(employee.FieldDeletedAt) {
  9006. fields = append(fields, employee.FieldDeletedAt)
  9007. }
  9008. if m.FieldCleared(employee.FieldAiInfo) {
  9009. fields = append(fields, employee.FieldAiInfo)
  9010. }
  9011. return fields
  9012. }
  9013. // FieldCleared returns a boolean indicating if a field with the given name was
  9014. // cleared in this mutation.
  9015. func (m *EmployeeMutation) FieldCleared(name string) bool {
  9016. _, ok := m.clearedFields[name]
  9017. return ok
  9018. }
  9019. // ClearField clears the value of the field with the given name. It returns an
  9020. // error if the field is not defined in the schema.
  9021. func (m *EmployeeMutation) ClearField(name string) error {
  9022. switch name {
  9023. case employee.FieldDeletedAt:
  9024. m.ClearDeletedAt()
  9025. return nil
  9026. case employee.FieldAiInfo:
  9027. m.ClearAiInfo()
  9028. return nil
  9029. }
  9030. return fmt.Errorf("unknown Employee nullable field %s", name)
  9031. }
  9032. // ResetField resets all changes in the mutation for the field with the given name.
  9033. // It returns an error if the field is not defined in the schema.
  9034. func (m *EmployeeMutation) ResetField(name string) error {
  9035. switch name {
  9036. case employee.FieldCreatedAt:
  9037. m.ResetCreatedAt()
  9038. return nil
  9039. case employee.FieldUpdatedAt:
  9040. m.ResetUpdatedAt()
  9041. return nil
  9042. case employee.FieldDeletedAt:
  9043. m.ResetDeletedAt()
  9044. return nil
  9045. case employee.FieldTitle:
  9046. m.ResetTitle()
  9047. return nil
  9048. case employee.FieldAvatar:
  9049. m.ResetAvatar()
  9050. return nil
  9051. case employee.FieldTags:
  9052. m.ResetTags()
  9053. return nil
  9054. case employee.FieldHireCount:
  9055. m.ResetHireCount()
  9056. return nil
  9057. case employee.FieldServiceCount:
  9058. m.ResetServiceCount()
  9059. return nil
  9060. case employee.FieldAchievementCount:
  9061. m.ResetAchievementCount()
  9062. return nil
  9063. case employee.FieldIntro:
  9064. m.ResetIntro()
  9065. return nil
  9066. case employee.FieldEstimate:
  9067. m.ResetEstimate()
  9068. return nil
  9069. case employee.FieldSkill:
  9070. m.ResetSkill()
  9071. return nil
  9072. case employee.FieldAbilityType:
  9073. m.ResetAbilityType()
  9074. return nil
  9075. case employee.FieldScene:
  9076. m.ResetScene()
  9077. return nil
  9078. case employee.FieldSwitchIn:
  9079. m.ResetSwitchIn()
  9080. return nil
  9081. case employee.FieldVideoURL:
  9082. m.ResetVideoURL()
  9083. return nil
  9084. case employee.FieldOrganizationID:
  9085. m.ResetOrganizationID()
  9086. return nil
  9087. case employee.FieldCategoryID:
  9088. m.ResetCategoryID()
  9089. return nil
  9090. case employee.FieldAPIBase:
  9091. m.ResetAPIBase()
  9092. return nil
  9093. case employee.FieldAPIKey:
  9094. m.ResetAPIKey()
  9095. return nil
  9096. case employee.FieldAiInfo:
  9097. m.ResetAiInfo()
  9098. return nil
  9099. case employee.FieldIsVip:
  9100. m.ResetIsVip()
  9101. return nil
  9102. }
  9103. return fmt.Errorf("unknown Employee field %s", name)
  9104. }
  9105. // AddedEdges returns all edge names that were set/added in this mutation.
  9106. func (m *EmployeeMutation) AddedEdges() []string {
  9107. edges := make([]string, 0, 2)
  9108. if m.em_work_experiences != nil {
  9109. edges = append(edges, employee.EdgeEmWorkExperiences)
  9110. }
  9111. if m.em_tutorial != nil {
  9112. edges = append(edges, employee.EdgeEmTutorial)
  9113. }
  9114. return edges
  9115. }
  9116. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9117. // name in this mutation.
  9118. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  9119. switch name {
  9120. case employee.EdgeEmWorkExperiences:
  9121. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  9122. for id := range m.em_work_experiences {
  9123. ids = append(ids, id)
  9124. }
  9125. return ids
  9126. case employee.EdgeEmTutorial:
  9127. ids := make([]ent.Value, 0, len(m.em_tutorial))
  9128. for id := range m.em_tutorial {
  9129. ids = append(ids, id)
  9130. }
  9131. return ids
  9132. }
  9133. return nil
  9134. }
  9135. // RemovedEdges returns all edge names that were removed in this mutation.
  9136. func (m *EmployeeMutation) RemovedEdges() []string {
  9137. edges := make([]string, 0, 2)
  9138. if m.removedem_work_experiences != nil {
  9139. edges = append(edges, employee.EdgeEmWorkExperiences)
  9140. }
  9141. if m.removedem_tutorial != nil {
  9142. edges = append(edges, employee.EdgeEmTutorial)
  9143. }
  9144. return edges
  9145. }
  9146. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9147. // the given name in this mutation.
  9148. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  9149. switch name {
  9150. case employee.EdgeEmWorkExperiences:
  9151. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  9152. for id := range m.removedem_work_experiences {
  9153. ids = append(ids, id)
  9154. }
  9155. return ids
  9156. case employee.EdgeEmTutorial:
  9157. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  9158. for id := range m.removedem_tutorial {
  9159. ids = append(ids, id)
  9160. }
  9161. return ids
  9162. }
  9163. return nil
  9164. }
  9165. // ClearedEdges returns all edge names that were cleared in this mutation.
  9166. func (m *EmployeeMutation) ClearedEdges() []string {
  9167. edges := make([]string, 0, 2)
  9168. if m.clearedem_work_experiences {
  9169. edges = append(edges, employee.EdgeEmWorkExperiences)
  9170. }
  9171. if m.clearedem_tutorial {
  9172. edges = append(edges, employee.EdgeEmTutorial)
  9173. }
  9174. return edges
  9175. }
  9176. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9177. // was cleared in this mutation.
  9178. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  9179. switch name {
  9180. case employee.EdgeEmWorkExperiences:
  9181. return m.clearedem_work_experiences
  9182. case employee.EdgeEmTutorial:
  9183. return m.clearedem_tutorial
  9184. }
  9185. return false
  9186. }
  9187. // ClearEdge clears the value of the edge with the given name. It returns an error
  9188. // if that edge is not defined in the schema.
  9189. func (m *EmployeeMutation) ClearEdge(name string) error {
  9190. switch name {
  9191. }
  9192. return fmt.Errorf("unknown Employee unique edge %s", name)
  9193. }
  9194. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9195. // It returns an error if the edge is not defined in the schema.
  9196. func (m *EmployeeMutation) ResetEdge(name string) error {
  9197. switch name {
  9198. case employee.EdgeEmWorkExperiences:
  9199. m.ResetEmWorkExperiences()
  9200. return nil
  9201. case employee.EdgeEmTutorial:
  9202. m.ResetEmTutorial()
  9203. return nil
  9204. }
  9205. return fmt.Errorf("unknown Employee edge %s", name)
  9206. }
  9207. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  9208. type EmployeeConfigMutation struct {
  9209. config
  9210. op Op
  9211. typ string
  9212. id *uint64
  9213. created_at *time.Time
  9214. updated_at *time.Time
  9215. deleted_at *time.Time
  9216. stype *string
  9217. title *string
  9218. photo *string
  9219. organization_id *uint64
  9220. addorganization_id *int64
  9221. clearedFields map[string]struct{}
  9222. done bool
  9223. oldValue func(context.Context) (*EmployeeConfig, error)
  9224. predicates []predicate.EmployeeConfig
  9225. }
  9226. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  9227. // employeeconfigOption allows management of the mutation configuration using functional options.
  9228. type employeeconfigOption func(*EmployeeConfigMutation)
  9229. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  9230. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  9231. m := &EmployeeConfigMutation{
  9232. config: c,
  9233. op: op,
  9234. typ: TypeEmployeeConfig,
  9235. clearedFields: make(map[string]struct{}),
  9236. }
  9237. for _, opt := range opts {
  9238. opt(m)
  9239. }
  9240. return m
  9241. }
  9242. // withEmployeeConfigID sets the ID field of the mutation.
  9243. func withEmployeeConfigID(id uint64) employeeconfigOption {
  9244. return func(m *EmployeeConfigMutation) {
  9245. var (
  9246. err error
  9247. once sync.Once
  9248. value *EmployeeConfig
  9249. )
  9250. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  9251. once.Do(func() {
  9252. if m.done {
  9253. err = errors.New("querying old values post mutation is not allowed")
  9254. } else {
  9255. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  9256. }
  9257. })
  9258. return value, err
  9259. }
  9260. m.id = &id
  9261. }
  9262. }
  9263. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  9264. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  9265. return func(m *EmployeeConfigMutation) {
  9266. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  9267. return node, nil
  9268. }
  9269. m.id = &node.ID
  9270. }
  9271. }
  9272. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9273. // executed in a transaction (ent.Tx), a transactional client is returned.
  9274. func (m EmployeeConfigMutation) Client() *Client {
  9275. client := &Client{config: m.config}
  9276. client.init()
  9277. return client
  9278. }
  9279. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9280. // it returns an error otherwise.
  9281. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  9282. if _, ok := m.driver.(*txDriver); !ok {
  9283. return nil, errors.New("ent: mutation is not running in a transaction")
  9284. }
  9285. tx := &Tx{config: m.config}
  9286. tx.init()
  9287. return tx, nil
  9288. }
  9289. // SetID sets the value of the id field. Note that this
  9290. // operation is only accepted on creation of EmployeeConfig entities.
  9291. func (m *EmployeeConfigMutation) SetID(id uint64) {
  9292. m.id = &id
  9293. }
  9294. // ID returns the ID value in the mutation. Note that the ID is only available
  9295. // if it was provided to the builder or after it was returned from the database.
  9296. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  9297. if m.id == nil {
  9298. return
  9299. }
  9300. return *m.id, true
  9301. }
  9302. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9303. // That means, if the mutation is applied within a transaction with an isolation level such
  9304. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9305. // or updated by the mutation.
  9306. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  9307. switch {
  9308. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9309. id, exists := m.ID()
  9310. if exists {
  9311. return []uint64{id}, nil
  9312. }
  9313. fallthrough
  9314. case m.op.Is(OpUpdate | OpDelete):
  9315. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  9316. default:
  9317. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9318. }
  9319. }
  9320. // SetCreatedAt sets the "created_at" field.
  9321. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  9322. m.created_at = &t
  9323. }
  9324. // CreatedAt returns the value of the "created_at" field in the mutation.
  9325. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  9326. v := m.created_at
  9327. if v == nil {
  9328. return
  9329. }
  9330. return *v, true
  9331. }
  9332. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  9333. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9335. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9336. if !m.op.Is(OpUpdateOne) {
  9337. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9338. }
  9339. if m.id == nil || m.oldValue == nil {
  9340. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9341. }
  9342. oldValue, err := m.oldValue(ctx)
  9343. if err != nil {
  9344. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9345. }
  9346. return oldValue.CreatedAt, nil
  9347. }
  9348. // ResetCreatedAt resets all changes to the "created_at" field.
  9349. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  9350. m.created_at = nil
  9351. }
  9352. // SetUpdatedAt sets the "updated_at" field.
  9353. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  9354. m.updated_at = &t
  9355. }
  9356. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9357. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  9358. v := m.updated_at
  9359. if v == nil {
  9360. return
  9361. }
  9362. return *v, true
  9363. }
  9364. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  9365. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9367. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9368. if !m.op.Is(OpUpdateOne) {
  9369. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9370. }
  9371. if m.id == nil || m.oldValue == nil {
  9372. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9373. }
  9374. oldValue, err := m.oldValue(ctx)
  9375. if err != nil {
  9376. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9377. }
  9378. return oldValue.UpdatedAt, nil
  9379. }
  9380. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9381. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  9382. m.updated_at = nil
  9383. }
  9384. // SetDeletedAt sets the "deleted_at" field.
  9385. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  9386. m.deleted_at = &t
  9387. }
  9388. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9389. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  9390. v := m.deleted_at
  9391. if v == nil {
  9392. return
  9393. }
  9394. return *v, true
  9395. }
  9396. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  9397. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9399. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9400. if !m.op.Is(OpUpdateOne) {
  9401. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9402. }
  9403. if m.id == nil || m.oldValue == nil {
  9404. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9405. }
  9406. oldValue, err := m.oldValue(ctx)
  9407. if err != nil {
  9408. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9409. }
  9410. return oldValue.DeletedAt, nil
  9411. }
  9412. // ClearDeletedAt clears the value of the "deleted_at" field.
  9413. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  9414. m.deleted_at = nil
  9415. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  9416. }
  9417. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9418. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  9419. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  9420. return ok
  9421. }
  9422. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9423. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  9424. m.deleted_at = nil
  9425. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  9426. }
  9427. // SetStype sets the "stype" field.
  9428. func (m *EmployeeConfigMutation) SetStype(s string) {
  9429. m.stype = &s
  9430. }
  9431. // Stype returns the value of the "stype" field in the mutation.
  9432. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  9433. v := m.stype
  9434. if v == nil {
  9435. return
  9436. }
  9437. return *v, true
  9438. }
  9439. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  9440. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9442. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  9443. if !m.op.Is(OpUpdateOne) {
  9444. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  9445. }
  9446. if m.id == nil || m.oldValue == nil {
  9447. return v, errors.New("OldStype requires an ID field in the mutation")
  9448. }
  9449. oldValue, err := m.oldValue(ctx)
  9450. if err != nil {
  9451. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  9452. }
  9453. return oldValue.Stype, nil
  9454. }
  9455. // ResetStype resets all changes to the "stype" field.
  9456. func (m *EmployeeConfigMutation) ResetStype() {
  9457. m.stype = nil
  9458. }
  9459. // SetTitle sets the "title" field.
  9460. func (m *EmployeeConfigMutation) SetTitle(s string) {
  9461. m.title = &s
  9462. }
  9463. // Title returns the value of the "title" field in the mutation.
  9464. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  9465. v := m.title
  9466. if v == nil {
  9467. return
  9468. }
  9469. return *v, true
  9470. }
  9471. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  9472. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9474. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  9475. if !m.op.Is(OpUpdateOne) {
  9476. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  9477. }
  9478. if m.id == nil || m.oldValue == nil {
  9479. return v, errors.New("OldTitle requires an ID field in the mutation")
  9480. }
  9481. oldValue, err := m.oldValue(ctx)
  9482. if err != nil {
  9483. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  9484. }
  9485. return oldValue.Title, nil
  9486. }
  9487. // ResetTitle resets all changes to the "title" field.
  9488. func (m *EmployeeConfigMutation) ResetTitle() {
  9489. m.title = nil
  9490. }
  9491. // SetPhoto sets the "photo" field.
  9492. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  9493. m.photo = &s
  9494. }
  9495. // Photo returns the value of the "photo" field in the mutation.
  9496. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  9497. v := m.photo
  9498. if v == nil {
  9499. return
  9500. }
  9501. return *v, true
  9502. }
  9503. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  9504. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9506. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  9507. if !m.op.Is(OpUpdateOne) {
  9508. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  9509. }
  9510. if m.id == nil || m.oldValue == nil {
  9511. return v, errors.New("OldPhoto requires an ID field in the mutation")
  9512. }
  9513. oldValue, err := m.oldValue(ctx)
  9514. if err != nil {
  9515. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  9516. }
  9517. return oldValue.Photo, nil
  9518. }
  9519. // ResetPhoto resets all changes to the "photo" field.
  9520. func (m *EmployeeConfigMutation) ResetPhoto() {
  9521. m.photo = nil
  9522. }
  9523. // SetOrganizationID sets the "organization_id" field.
  9524. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  9525. m.organization_id = &u
  9526. m.addorganization_id = nil
  9527. }
  9528. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9529. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  9530. v := m.organization_id
  9531. if v == nil {
  9532. return
  9533. }
  9534. return *v, true
  9535. }
  9536. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  9537. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9539. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9540. if !m.op.Is(OpUpdateOne) {
  9541. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9542. }
  9543. if m.id == nil || m.oldValue == nil {
  9544. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9545. }
  9546. oldValue, err := m.oldValue(ctx)
  9547. if err != nil {
  9548. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9549. }
  9550. return oldValue.OrganizationID, nil
  9551. }
  9552. // AddOrganizationID adds u to the "organization_id" field.
  9553. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  9554. if m.addorganization_id != nil {
  9555. *m.addorganization_id += u
  9556. } else {
  9557. m.addorganization_id = &u
  9558. }
  9559. }
  9560. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9561. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  9562. v := m.addorganization_id
  9563. if v == nil {
  9564. return
  9565. }
  9566. return *v, true
  9567. }
  9568. // ClearOrganizationID clears the value of the "organization_id" field.
  9569. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  9570. m.organization_id = nil
  9571. m.addorganization_id = nil
  9572. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  9573. }
  9574. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9575. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  9576. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  9577. return ok
  9578. }
  9579. // ResetOrganizationID resets all changes to the "organization_id" field.
  9580. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  9581. m.organization_id = nil
  9582. m.addorganization_id = nil
  9583. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  9584. }
  9585. // Where appends a list predicates to the EmployeeConfigMutation builder.
  9586. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  9587. m.predicates = append(m.predicates, ps...)
  9588. }
  9589. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  9590. // users can use type-assertion to append predicates that do not depend on any generated package.
  9591. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  9592. p := make([]predicate.EmployeeConfig, len(ps))
  9593. for i := range ps {
  9594. p[i] = ps[i]
  9595. }
  9596. m.Where(p...)
  9597. }
  9598. // Op returns the operation name.
  9599. func (m *EmployeeConfigMutation) Op() Op {
  9600. return m.op
  9601. }
  9602. // SetOp allows setting the mutation operation.
  9603. func (m *EmployeeConfigMutation) SetOp(op Op) {
  9604. m.op = op
  9605. }
  9606. // Type returns the node type of this mutation (EmployeeConfig).
  9607. func (m *EmployeeConfigMutation) Type() string {
  9608. return m.typ
  9609. }
  9610. // Fields returns all fields that were changed during this mutation. Note that in
  9611. // order to get all numeric fields that were incremented/decremented, call
  9612. // AddedFields().
  9613. func (m *EmployeeConfigMutation) Fields() []string {
  9614. fields := make([]string, 0, 7)
  9615. if m.created_at != nil {
  9616. fields = append(fields, employeeconfig.FieldCreatedAt)
  9617. }
  9618. if m.updated_at != nil {
  9619. fields = append(fields, employeeconfig.FieldUpdatedAt)
  9620. }
  9621. if m.deleted_at != nil {
  9622. fields = append(fields, employeeconfig.FieldDeletedAt)
  9623. }
  9624. if m.stype != nil {
  9625. fields = append(fields, employeeconfig.FieldStype)
  9626. }
  9627. if m.title != nil {
  9628. fields = append(fields, employeeconfig.FieldTitle)
  9629. }
  9630. if m.photo != nil {
  9631. fields = append(fields, employeeconfig.FieldPhoto)
  9632. }
  9633. if m.organization_id != nil {
  9634. fields = append(fields, employeeconfig.FieldOrganizationID)
  9635. }
  9636. return fields
  9637. }
  9638. // Field returns the value of a field with the given name. The second boolean
  9639. // return value indicates that this field was not set, or was not defined in the
  9640. // schema.
  9641. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  9642. switch name {
  9643. case employeeconfig.FieldCreatedAt:
  9644. return m.CreatedAt()
  9645. case employeeconfig.FieldUpdatedAt:
  9646. return m.UpdatedAt()
  9647. case employeeconfig.FieldDeletedAt:
  9648. return m.DeletedAt()
  9649. case employeeconfig.FieldStype:
  9650. return m.Stype()
  9651. case employeeconfig.FieldTitle:
  9652. return m.Title()
  9653. case employeeconfig.FieldPhoto:
  9654. return m.Photo()
  9655. case employeeconfig.FieldOrganizationID:
  9656. return m.OrganizationID()
  9657. }
  9658. return nil, false
  9659. }
  9660. // OldField returns the old value of the field from the database. An error is
  9661. // returned if the mutation operation is not UpdateOne, or the query to the
  9662. // database failed.
  9663. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9664. switch name {
  9665. case employeeconfig.FieldCreatedAt:
  9666. return m.OldCreatedAt(ctx)
  9667. case employeeconfig.FieldUpdatedAt:
  9668. return m.OldUpdatedAt(ctx)
  9669. case employeeconfig.FieldDeletedAt:
  9670. return m.OldDeletedAt(ctx)
  9671. case employeeconfig.FieldStype:
  9672. return m.OldStype(ctx)
  9673. case employeeconfig.FieldTitle:
  9674. return m.OldTitle(ctx)
  9675. case employeeconfig.FieldPhoto:
  9676. return m.OldPhoto(ctx)
  9677. case employeeconfig.FieldOrganizationID:
  9678. return m.OldOrganizationID(ctx)
  9679. }
  9680. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  9681. }
  9682. // SetField sets the value of a field with the given name. It returns an error if
  9683. // the field is not defined in the schema, or if the type mismatched the field
  9684. // type.
  9685. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  9686. switch name {
  9687. case employeeconfig.FieldCreatedAt:
  9688. v, ok := value.(time.Time)
  9689. if !ok {
  9690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9691. }
  9692. m.SetCreatedAt(v)
  9693. return nil
  9694. case employeeconfig.FieldUpdatedAt:
  9695. v, ok := value.(time.Time)
  9696. if !ok {
  9697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9698. }
  9699. m.SetUpdatedAt(v)
  9700. return nil
  9701. case employeeconfig.FieldDeletedAt:
  9702. v, ok := value.(time.Time)
  9703. if !ok {
  9704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9705. }
  9706. m.SetDeletedAt(v)
  9707. return nil
  9708. case employeeconfig.FieldStype:
  9709. v, ok := value.(string)
  9710. if !ok {
  9711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9712. }
  9713. m.SetStype(v)
  9714. return nil
  9715. case employeeconfig.FieldTitle:
  9716. v, ok := value.(string)
  9717. if !ok {
  9718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9719. }
  9720. m.SetTitle(v)
  9721. return nil
  9722. case employeeconfig.FieldPhoto:
  9723. v, ok := value.(string)
  9724. if !ok {
  9725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9726. }
  9727. m.SetPhoto(v)
  9728. return nil
  9729. case employeeconfig.FieldOrganizationID:
  9730. v, ok := value.(uint64)
  9731. if !ok {
  9732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9733. }
  9734. m.SetOrganizationID(v)
  9735. return nil
  9736. }
  9737. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  9738. }
  9739. // AddedFields returns all numeric fields that were incremented/decremented during
  9740. // this mutation.
  9741. func (m *EmployeeConfigMutation) AddedFields() []string {
  9742. var fields []string
  9743. if m.addorganization_id != nil {
  9744. fields = append(fields, employeeconfig.FieldOrganizationID)
  9745. }
  9746. return fields
  9747. }
  9748. // AddedField returns the numeric value that was incremented/decremented on a field
  9749. // with the given name. The second boolean return value indicates that this field
  9750. // was not set, or was not defined in the schema.
  9751. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  9752. switch name {
  9753. case employeeconfig.FieldOrganizationID:
  9754. return m.AddedOrganizationID()
  9755. }
  9756. return nil, false
  9757. }
  9758. // AddField adds the value to the field with the given name. It returns an error if
  9759. // the field is not defined in the schema, or if the type mismatched the field
  9760. // type.
  9761. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  9762. switch name {
  9763. case employeeconfig.FieldOrganizationID:
  9764. v, ok := value.(int64)
  9765. if !ok {
  9766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9767. }
  9768. m.AddOrganizationID(v)
  9769. return nil
  9770. }
  9771. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  9772. }
  9773. // ClearedFields returns all nullable fields that were cleared during this
  9774. // mutation.
  9775. func (m *EmployeeConfigMutation) ClearedFields() []string {
  9776. var fields []string
  9777. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  9778. fields = append(fields, employeeconfig.FieldDeletedAt)
  9779. }
  9780. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  9781. fields = append(fields, employeeconfig.FieldOrganizationID)
  9782. }
  9783. return fields
  9784. }
  9785. // FieldCleared returns a boolean indicating if a field with the given name was
  9786. // cleared in this mutation.
  9787. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  9788. _, ok := m.clearedFields[name]
  9789. return ok
  9790. }
  9791. // ClearField clears the value of the field with the given name. It returns an
  9792. // error if the field is not defined in the schema.
  9793. func (m *EmployeeConfigMutation) ClearField(name string) error {
  9794. switch name {
  9795. case employeeconfig.FieldDeletedAt:
  9796. m.ClearDeletedAt()
  9797. return nil
  9798. case employeeconfig.FieldOrganizationID:
  9799. m.ClearOrganizationID()
  9800. return nil
  9801. }
  9802. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  9803. }
  9804. // ResetField resets all changes in the mutation for the field with the given name.
  9805. // It returns an error if the field is not defined in the schema.
  9806. func (m *EmployeeConfigMutation) ResetField(name string) error {
  9807. switch name {
  9808. case employeeconfig.FieldCreatedAt:
  9809. m.ResetCreatedAt()
  9810. return nil
  9811. case employeeconfig.FieldUpdatedAt:
  9812. m.ResetUpdatedAt()
  9813. return nil
  9814. case employeeconfig.FieldDeletedAt:
  9815. m.ResetDeletedAt()
  9816. return nil
  9817. case employeeconfig.FieldStype:
  9818. m.ResetStype()
  9819. return nil
  9820. case employeeconfig.FieldTitle:
  9821. m.ResetTitle()
  9822. return nil
  9823. case employeeconfig.FieldPhoto:
  9824. m.ResetPhoto()
  9825. return nil
  9826. case employeeconfig.FieldOrganizationID:
  9827. m.ResetOrganizationID()
  9828. return nil
  9829. }
  9830. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  9831. }
  9832. // AddedEdges returns all edge names that were set/added in this mutation.
  9833. func (m *EmployeeConfigMutation) AddedEdges() []string {
  9834. edges := make([]string, 0, 0)
  9835. return edges
  9836. }
  9837. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9838. // name in this mutation.
  9839. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  9840. return nil
  9841. }
  9842. // RemovedEdges returns all edge names that were removed in this mutation.
  9843. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  9844. edges := make([]string, 0, 0)
  9845. return edges
  9846. }
  9847. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9848. // the given name in this mutation.
  9849. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  9850. return nil
  9851. }
  9852. // ClearedEdges returns all edge names that were cleared in this mutation.
  9853. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  9854. edges := make([]string, 0, 0)
  9855. return edges
  9856. }
  9857. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9858. // was cleared in this mutation.
  9859. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  9860. return false
  9861. }
  9862. // ClearEdge clears the value of the edge with the given name. It returns an error
  9863. // if that edge is not defined in the schema.
  9864. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  9865. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  9866. }
  9867. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9868. // It returns an error if the edge is not defined in the schema.
  9869. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  9870. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  9871. }
  9872. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  9873. type LabelMutation struct {
  9874. config
  9875. op Op
  9876. typ string
  9877. id *uint64
  9878. created_at *time.Time
  9879. updated_at *time.Time
  9880. status *uint8
  9881. addstatus *int8
  9882. _type *int
  9883. add_type *int
  9884. name *string
  9885. from *int
  9886. addfrom *int
  9887. mode *int
  9888. addmode *int
  9889. conditions *string
  9890. organization_id *uint64
  9891. addorganization_id *int64
  9892. clearedFields map[string]struct{}
  9893. label_relationships map[uint64]struct{}
  9894. removedlabel_relationships map[uint64]struct{}
  9895. clearedlabel_relationships bool
  9896. done bool
  9897. oldValue func(context.Context) (*Label, error)
  9898. predicates []predicate.Label
  9899. }
  9900. var _ ent.Mutation = (*LabelMutation)(nil)
  9901. // labelOption allows management of the mutation configuration using functional options.
  9902. type labelOption func(*LabelMutation)
  9903. // newLabelMutation creates new mutation for the Label entity.
  9904. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  9905. m := &LabelMutation{
  9906. config: c,
  9907. op: op,
  9908. typ: TypeLabel,
  9909. clearedFields: make(map[string]struct{}),
  9910. }
  9911. for _, opt := range opts {
  9912. opt(m)
  9913. }
  9914. return m
  9915. }
  9916. // withLabelID sets the ID field of the mutation.
  9917. func withLabelID(id uint64) labelOption {
  9918. return func(m *LabelMutation) {
  9919. var (
  9920. err error
  9921. once sync.Once
  9922. value *Label
  9923. )
  9924. m.oldValue = func(ctx context.Context) (*Label, error) {
  9925. once.Do(func() {
  9926. if m.done {
  9927. err = errors.New("querying old values post mutation is not allowed")
  9928. } else {
  9929. value, err = m.Client().Label.Get(ctx, id)
  9930. }
  9931. })
  9932. return value, err
  9933. }
  9934. m.id = &id
  9935. }
  9936. }
  9937. // withLabel sets the old Label of the mutation.
  9938. func withLabel(node *Label) labelOption {
  9939. return func(m *LabelMutation) {
  9940. m.oldValue = func(context.Context) (*Label, error) {
  9941. return node, nil
  9942. }
  9943. m.id = &node.ID
  9944. }
  9945. }
  9946. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9947. // executed in a transaction (ent.Tx), a transactional client is returned.
  9948. func (m LabelMutation) Client() *Client {
  9949. client := &Client{config: m.config}
  9950. client.init()
  9951. return client
  9952. }
  9953. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9954. // it returns an error otherwise.
  9955. func (m LabelMutation) Tx() (*Tx, error) {
  9956. if _, ok := m.driver.(*txDriver); !ok {
  9957. return nil, errors.New("ent: mutation is not running in a transaction")
  9958. }
  9959. tx := &Tx{config: m.config}
  9960. tx.init()
  9961. return tx, nil
  9962. }
  9963. // SetID sets the value of the id field. Note that this
  9964. // operation is only accepted on creation of Label entities.
  9965. func (m *LabelMutation) SetID(id uint64) {
  9966. m.id = &id
  9967. }
  9968. // ID returns the ID value in the mutation. Note that the ID is only available
  9969. // if it was provided to the builder or after it was returned from the database.
  9970. func (m *LabelMutation) ID() (id uint64, exists bool) {
  9971. if m.id == nil {
  9972. return
  9973. }
  9974. return *m.id, true
  9975. }
  9976. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9977. // That means, if the mutation is applied within a transaction with an isolation level such
  9978. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9979. // or updated by the mutation.
  9980. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  9981. switch {
  9982. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9983. id, exists := m.ID()
  9984. if exists {
  9985. return []uint64{id}, nil
  9986. }
  9987. fallthrough
  9988. case m.op.Is(OpUpdate | OpDelete):
  9989. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  9990. default:
  9991. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9992. }
  9993. }
  9994. // SetCreatedAt sets the "created_at" field.
  9995. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  9996. m.created_at = &t
  9997. }
  9998. // CreatedAt returns the value of the "created_at" field in the mutation.
  9999. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  10000. v := m.created_at
  10001. if v == nil {
  10002. return
  10003. }
  10004. return *v, true
  10005. }
  10006. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  10007. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10009. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10010. if !m.op.Is(OpUpdateOne) {
  10011. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10012. }
  10013. if m.id == nil || m.oldValue == nil {
  10014. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10015. }
  10016. oldValue, err := m.oldValue(ctx)
  10017. if err != nil {
  10018. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10019. }
  10020. return oldValue.CreatedAt, nil
  10021. }
  10022. // ResetCreatedAt resets all changes to the "created_at" field.
  10023. func (m *LabelMutation) ResetCreatedAt() {
  10024. m.created_at = nil
  10025. }
  10026. // SetUpdatedAt sets the "updated_at" field.
  10027. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  10028. m.updated_at = &t
  10029. }
  10030. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10031. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  10032. v := m.updated_at
  10033. if v == nil {
  10034. return
  10035. }
  10036. return *v, true
  10037. }
  10038. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  10039. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10041. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10042. if !m.op.Is(OpUpdateOne) {
  10043. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10044. }
  10045. if m.id == nil || m.oldValue == nil {
  10046. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10047. }
  10048. oldValue, err := m.oldValue(ctx)
  10049. if err != nil {
  10050. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10051. }
  10052. return oldValue.UpdatedAt, nil
  10053. }
  10054. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10055. func (m *LabelMutation) ResetUpdatedAt() {
  10056. m.updated_at = nil
  10057. }
  10058. // SetStatus sets the "status" field.
  10059. func (m *LabelMutation) SetStatus(u uint8) {
  10060. m.status = &u
  10061. m.addstatus = nil
  10062. }
  10063. // Status returns the value of the "status" field in the mutation.
  10064. func (m *LabelMutation) Status() (r uint8, exists bool) {
  10065. v := m.status
  10066. if v == nil {
  10067. return
  10068. }
  10069. return *v, true
  10070. }
  10071. // OldStatus returns the old "status" field's value of the Label entity.
  10072. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10074. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10075. if !m.op.Is(OpUpdateOne) {
  10076. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10077. }
  10078. if m.id == nil || m.oldValue == nil {
  10079. return v, errors.New("OldStatus requires an ID field in the mutation")
  10080. }
  10081. oldValue, err := m.oldValue(ctx)
  10082. if err != nil {
  10083. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10084. }
  10085. return oldValue.Status, nil
  10086. }
  10087. // AddStatus adds u to the "status" field.
  10088. func (m *LabelMutation) AddStatus(u int8) {
  10089. if m.addstatus != nil {
  10090. *m.addstatus += u
  10091. } else {
  10092. m.addstatus = &u
  10093. }
  10094. }
  10095. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10096. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  10097. v := m.addstatus
  10098. if v == nil {
  10099. return
  10100. }
  10101. return *v, true
  10102. }
  10103. // ClearStatus clears the value of the "status" field.
  10104. func (m *LabelMutation) ClearStatus() {
  10105. m.status = nil
  10106. m.addstatus = nil
  10107. m.clearedFields[label.FieldStatus] = struct{}{}
  10108. }
  10109. // StatusCleared returns if the "status" field was cleared in this mutation.
  10110. func (m *LabelMutation) StatusCleared() bool {
  10111. _, ok := m.clearedFields[label.FieldStatus]
  10112. return ok
  10113. }
  10114. // ResetStatus resets all changes to the "status" field.
  10115. func (m *LabelMutation) ResetStatus() {
  10116. m.status = nil
  10117. m.addstatus = nil
  10118. delete(m.clearedFields, label.FieldStatus)
  10119. }
  10120. // SetType sets the "type" field.
  10121. func (m *LabelMutation) SetType(i int) {
  10122. m._type = &i
  10123. m.add_type = nil
  10124. }
  10125. // GetType returns the value of the "type" field in the mutation.
  10126. func (m *LabelMutation) GetType() (r int, exists bool) {
  10127. v := m._type
  10128. if v == nil {
  10129. return
  10130. }
  10131. return *v, true
  10132. }
  10133. // OldType returns the old "type" field's value of the Label entity.
  10134. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10136. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  10137. if !m.op.Is(OpUpdateOne) {
  10138. return v, errors.New("OldType is only allowed on UpdateOne operations")
  10139. }
  10140. if m.id == nil || m.oldValue == nil {
  10141. return v, errors.New("OldType requires an ID field in the mutation")
  10142. }
  10143. oldValue, err := m.oldValue(ctx)
  10144. if err != nil {
  10145. return v, fmt.Errorf("querying old value for OldType: %w", err)
  10146. }
  10147. return oldValue.Type, nil
  10148. }
  10149. // AddType adds i to the "type" field.
  10150. func (m *LabelMutation) AddType(i int) {
  10151. if m.add_type != nil {
  10152. *m.add_type += i
  10153. } else {
  10154. m.add_type = &i
  10155. }
  10156. }
  10157. // AddedType returns the value that was added to the "type" field in this mutation.
  10158. func (m *LabelMutation) AddedType() (r int, exists bool) {
  10159. v := m.add_type
  10160. if v == nil {
  10161. return
  10162. }
  10163. return *v, true
  10164. }
  10165. // ResetType resets all changes to the "type" field.
  10166. func (m *LabelMutation) ResetType() {
  10167. m._type = nil
  10168. m.add_type = nil
  10169. }
  10170. // SetName sets the "name" field.
  10171. func (m *LabelMutation) SetName(s string) {
  10172. m.name = &s
  10173. }
  10174. // Name returns the value of the "name" field in the mutation.
  10175. func (m *LabelMutation) Name() (r string, exists bool) {
  10176. v := m.name
  10177. if v == nil {
  10178. return
  10179. }
  10180. return *v, true
  10181. }
  10182. // OldName returns the old "name" field's value of the Label entity.
  10183. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10185. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  10186. if !m.op.Is(OpUpdateOne) {
  10187. return v, errors.New("OldName is only allowed on UpdateOne operations")
  10188. }
  10189. if m.id == nil || m.oldValue == nil {
  10190. return v, errors.New("OldName requires an ID field in the mutation")
  10191. }
  10192. oldValue, err := m.oldValue(ctx)
  10193. if err != nil {
  10194. return v, fmt.Errorf("querying old value for OldName: %w", err)
  10195. }
  10196. return oldValue.Name, nil
  10197. }
  10198. // ResetName resets all changes to the "name" field.
  10199. func (m *LabelMutation) ResetName() {
  10200. m.name = nil
  10201. }
  10202. // SetFrom sets the "from" field.
  10203. func (m *LabelMutation) SetFrom(i int) {
  10204. m.from = &i
  10205. m.addfrom = nil
  10206. }
  10207. // From returns the value of the "from" field in the mutation.
  10208. func (m *LabelMutation) From() (r int, exists bool) {
  10209. v := m.from
  10210. if v == nil {
  10211. return
  10212. }
  10213. return *v, true
  10214. }
  10215. // OldFrom returns the old "from" field's value of the Label entity.
  10216. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10218. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  10219. if !m.op.Is(OpUpdateOne) {
  10220. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  10221. }
  10222. if m.id == nil || m.oldValue == nil {
  10223. return v, errors.New("OldFrom requires an ID field in the mutation")
  10224. }
  10225. oldValue, err := m.oldValue(ctx)
  10226. if err != nil {
  10227. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  10228. }
  10229. return oldValue.From, nil
  10230. }
  10231. // AddFrom adds i to the "from" field.
  10232. func (m *LabelMutation) AddFrom(i int) {
  10233. if m.addfrom != nil {
  10234. *m.addfrom += i
  10235. } else {
  10236. m.addfrom = &i
  10237. }
  10238. }
  10239. // AddedFrom returns the value that was added to the "from" field in this mutation.
  10240. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  10241. v := m.addfrom
  10242. if v == nil {
  10243. return
  10244. }
  10245. return *v, true
  10246. }
  10247. // ResetFrom resets all changes to the "from" field.
  10248. func (m *LabelMutation) ResetFrom() {
  10249. m.from = nil
  10250. m.addfrom = nil
  10251. }
  10252. // SetMode sets the "mode" field.
  10253. func (m *LabelMutation) SetMode(i int) {
  10254. m.mode = &i
  10255. m.addmode = nil
  10256. }
  10257. // Mode returns the value of the "mode" field in the mutation.
  10258. func (m *LabelMutation) Mode() (r int, exists bool) {
  10259. v := m.mode
  10260. if v == nil {
  10261. return
  10262. }
  10263. return *v, true
  10264. }
  10265. // OldMode returns the old "mode" field's value of the Label entity.
  10266. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10268. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  10269. if !m.op.Is(OpUpdateOne) {
  10270. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  10271. }
  10272. if m.id == nil || m.oldValue == nil {
  10273. return v, errors.New("OldMode requires an ID field in the mutation")
  10274. }
  10275. oldValue, err := m.oldValue(ctx)
  10276. if err != nil {
  10277. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  10278. }
  10279. return oldValue.Mode, nil
  10280. }
  10281. // AddMode adds i to the "mode" field.
  10282. func (m *LabelMutation) AddMode(i int) {
  10283. if m.addmode != nil {
  10284. *m.addmode += i
  10285. } else {
  10286. m.addmode = &i
  10287. }
  10288. }
  10289. // AddedMode returns the value that was added to the "mode" field in this mutation.
  10290. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  10291. v := m.addmode
  10292. if v == nil {
  10293. return
  10294. }
  10295. return *v, true
  10296. }
  10297. // ResetMode resets all changes to the "mode" field.
  10298. func (m *LabelMutation) ResetMode() {
  10299. m.mode = nil
  10300. m.addmode = nil
  10301. }
  10302. // SetConditions sets the "conditions" field.
  10303. func (m *LabelMutation) SetConditions(s string) {
  10304. m.conditions = &s
  10305. }
  10306. // Conditions returns the value of the "conditions" field in the mutation.
  10307. func (m *LabelMutation) Conditions() (r string, exists bool) {
  10308. v := m.conditions
  10309. if v == nil {
  10310. return
  10311. }
  10312. return *v, true
  10313. }
  10314. // OldConditions returns the old "conditions" field's value of the Label entity.
  10315. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10317. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  10318. if !m.op.Is(OpUpdateOne) {
  10319. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  10320. }
  10321. if m.id == nil || m.oldValue == nil {
  10322. return v, errors.New("OldConditions requires an ID field in the mutation")
  10323. }
  10324. oldValue, err := m.oldValue(ctx)
  10325. if err != nil {
  10326. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  10327. }
  10328. return oldValue.Conditions, nil
  10329. }
  10330. // ClearConditions clears the value of the "conditions" field.
  10331. func (m *LabelMutation) ClearConditions() {
  10332. m.conditions = nil
  10333. m.clearedFields[label.FieldConditions] = struct{}{}
  10334. }
  10335. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  10336. func (m *LabelMutation) ConditionsCleared() bool {
  10337. _, ok := m.clearedFields[label.FieldConditions]
  10338. return ok
  10339. }
  10340. // ResetConditions resets all changes to the "conditions" field.
  10341. func (m *LabelMutation) ResetConditions() {
  10342. m.conditions = nil
  10343. delete(m.clearedFields, label.FieldConditions)
  10344. }
  10345. // SetOrganizationID sets the "organization_id" field.
  10346. func (m *LabelMutation) SetOrganizationID(u uint64) {
  10347. m.organization_id = &u
  10348. m.addorganization_id = nil
  10349. }
  10350. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10351. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  10352. v := m.organization_id
  10353. if v == nil {
  10354. return
  10355. }
  10356. return *v, true
  10357. }
  10358. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  10359. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10361. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10362. if !m.op.Is(OpUpdateOne) {
  10363. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10364. }
  10365. if m.id == nil || m.oldValue == nil {
  10366. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10367. }
  10368. oldValue, err := m.oldValue(ctx)
  10369. if err != nil {
  10370. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10371. }
  10372. return oldValue.OrganizationID, nil
  10373. }
  10374. // AddOrganizationID adds u to the "organization_id" field.
  10375. func (m *LabelMutation) AddOrganizationID(u int64) {
  10376. if m.addorganization_id != nil {
  10377. *m.addorganization_id += u
  10378. } else {
  10379. m.addorganization_id = &u
  10380. }
  10381. }
  10382. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10383. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  10384. v := m.addorganization_id
  10385. if v == nil {
  10386. return
  10387. }
  10388. return *v, true
  10389. }
  10390. // ClearOrganizationID clears the value of the "organization_id" field.
  10391. func (m *LabelMutation) ClearOrganizationID() {
  10392. m.organization_id = nil
  10393. m.addorganization_id = nil
  10394. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  10395. }
  10396. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10397. func (m *LabelMutation) OrganizationIDCleared() bool {
  10398. _, ok := m.clearedFields[label.FieldOrganizationID]
  10399. return ok
  10400. }
  10401. // ResetOrganizationID resets all changes to the "organization_id" field.
  10402. func (m *LabelMutation) ResetOrganizationID() {
  10403. m.organization_id = nil
  10404. m.addorganization_id = nil
  10405. delete(m.clearedFields, label.FieldOrganizationID)
  10406. }
  10407. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  10408. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  10409. if m.label_relationships == nil {
  10410. m.label_relationships = make(map[uint64]struct{})
  10411. }
  10412. for i := range ids {
  10413. m.label_relationships[ids[i]] = struct{}{}
  10414. }
  10415. }
  10416. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  10417. func (m *LabelMutation) ClearLabelRelationships() {
  10418. m.clearedlabel_relationships = true
  10419. }
  10420. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  10421. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  10422. return m.clearedlabel_relationships
  10423. }
  10424. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  10425. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  10426. if m.removedlabel_relationships == nil {
  10427. m.removedlabel_relationships = make(map[uint64]struct{})
  10428. }
  10429. for i := range ids {
  10430. delete(m.label_relationships, ids[i])
  10431. m.removedlabel_relationships[ids[i]] = struct{}{}
  10432. }
  10433. }
  10434. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  10435. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  10436. for id := range m.removedlabel_relationships {
  10437. ids = append(ids, id)
  10438. }
  10439. return
  10440. }
  10441. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  10442. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  10443. for id := range m.label_relationships {
  10444. ids = append(ids, id)
  10445. }
  10446. return
  10447. }
  10448. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  10449. func (m *LabelMutation) ResetLabelRelationships() {
  10450. m.label_relationships = nil
  10451. m.clearedlabel_relationships = false
  10452. m.removedlabel_relationships = nil
  10453. }
  10454. // Where appends a list predicates to the LabelMutation builder.
  10455. func (m *LabelMutation) Where(ps ...predicate.Label) {
  10456. m.predicates = append(m.predicates, ps...)
  10457. }
  10458. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  10459. // users can use type-assertion to append predicates that do not depend on any generated package.
  10460. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  10461. p := make([]predicate.Label, len(ps))
  10462. for i := range ps {
  10463. p[i] = ps[i]
  10464. }
  10465. m.Where(p...)
  10466. }
  10467. // Op returns the operation name.
  10468. func (m *LabelMutation) Op() Op {
  10469. return m.op
  10470. }
  10471. // SetOp allows setting the mutation operation.
  10472. func (m *LabelMutation) SetOp(op Op) {
  10473. m.op = op
  10474. }
  10475. // Type returns the node type of this mutation (Label).
  10476. func (m *LabelMutation) Type() string {
  10477. return m.typ
  10478. }
  10479. // Fields returns all fields that were changed during this mutation. Note that in
  10480. // order to get all numeric fields that were incremented/decremented, call
  10481. // AddedFields().
  10482. func (m *LabelMutation) Fields() []string {
  10483. fields := make([]string, 0, 9)
  10484. if m.created_at != nil {
  10485. fields = append(fields, label.FieldCreatedAt)
  10486. }
  10487. if m.updated_at != nil {
  10488. fields = append(fields, label.FieldUpdatedAt)
  10489. }
  10490. if m.status != nil {
  10491. fields = append(fields, label.FieldStatus)
  10492. }
  10493. if m._type != nil {
  10494. fields = append(fields, label.FieldType)
  10495. }
  10496. if m.name != nil {
  10497. fields = append(fields, label.FieldName)
  10498. }
  10499. if m.from != nil {
  10500. fields = append(fields, label.FieldFrom)
  10501. }
  10502. if m.mode != nil {
  10503. fields = append(fields, label.FieldMode)
  10504. }
  10505. if m.conditions != nil {
  10506. fields = append(fields, label.FieldConditions)
  10507. }
  10508. if m.organization_id != nil {
  10509. fields = append(fields, label.FieldOrganizationID)
  10510. }
  10511. return fields
  10512. }
  10513. // Field returns the value of a field with the given name. The second boolean
  10514. // return value indicates that this field was not set, or was not defined in the
  10515. // schema.
  10516. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  10517. switch name {
  10518. case label.FieldCreatedAt:
  10519. return m.CreatedAt()
  10520. case label.FieldUpdatedAt:
  10521. return m.UpdatedAt()
  10522. case label.FieldStatus:
  10523. return m.Status()
  10524. case label.FieldType:
  10525. return m.GetType()
  10526. case label.FieldName:
  10527. return m.Name()
  10528. case label.FieldFrom:
  10529. return m.From()
  10530. case label.FieldMode:
  10531. return m.Mode()
  10532. case label.FieldConditions:
  10533. return m.Conditions()
  10534. case label.FieldOrganizationID:
  10535. return m.OrganizationID()
  10536. }
  10537. return nil, false
  10538. }
  10539. // OldField returns the old value of the field from the database. An error is
  10540. // returned if the mutation operation is not UpdateOne, or the query to the
  10541. // database failed.
  10542. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10543. switch name {
  10544. case label.FieldCreatedAt:
  10545. return m.OldCreatedAt(ctx)
  10546. case label.FieldUpdatedAt:
  10547. return m.OldUpdatedAt(ctx)
  10548. case label.FieldStatus:
  10549. return m.OldStatus(ctx)
  10550. case label.FieldType:
  10551. return m.OldType(ctx)
  10552. case label.FieldName:
  10553. return m.OldName(ctx)
  10554. case label.FieldFrom:
  10555. return m.OldFrom(ctx)
  10556. case label.FieldMode:
  10557. return m.OldMode(ctx)
  10558. case label.FieldConditions:
  10559. return m.OldConditions(ctx)
  10560. case label.FieldOrganizationID:
  10561. return m.OldOrganizationID(ctx)
  10562. }
  10563. return nil, fmt.Errorf("unknown Label field %s", name)
  10564. }
  10565. // SetField sets the value of a field with the given name. It returns an error if
  10566. // the field is not defined in the schema, or if the type mismatched the field
  10567. // type.
  10568. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  10569. switch name {
  10570. case label.FieldCreatedAt:
  10571. v, ok := value.(time.Time)
  10572. if !ok {
  10573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10574. }
  10575. m.SetCreatedAt(v)
  10576. return nil
  10577. case label.FieldUpdatedAt:
  10578. v, ok := value.(time.Time)
  10579. if !ok {
  10580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10581. }
  10582. m.SetUpdatedAt(v)
  10583. return nil
  10584. case label.FieldStatus:
  10585. v, ok := value.(uint8)
  10586. if !ok {
  10587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10588. }
  10589. m.SetStatus(v)
  10590. return nil
  10591. case label.FieldType:
  10592. v, ok := value.(int)
  10593. if !ok {
  10594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10595. }
  10596. m.SetType(v)
  10597. return nil
  10598. case label.FieldName:
  10599. v, ok := value.(string)
  10600. if !ok {
  10601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10602. }
  10603. m.SetName(v)
  10604. return nil
  10605. case label.FieldFrom:
  10606. v, ok := value.(int)
  10607. if !ok {
  10608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10609. }
  10610. m.SetFrom(v)
  10611. return nil
  10612. case label.FieldMode:
  10613. v, ok := value.(int)
  10614. if !ok {
  10615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10616. }
  10617. m.SetMode(v)
  10618. return nil
  10619. case label.FieldConditions:
  10620. v, ok := value.(string)
  10621. if !ok {
  10622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10623. }
  10624. m.SetConditions(v)
  10625. return nil
  10626. case label.FieldOrganizationID:
  10627. v, ok := value.(uint64)
  10628. if !ok {
  10629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10630. }
  10631. m.SetOrganizationID(v)
  10632. return nil
  10633. }
  10634. return fmt.Errorf("unknown Label field %s", name)
  10635. }
  10636. // AddedFields returns all numeric fields that were incremented/decremented during
  10637. // this mutation.
  10638. func (m *LabelMutation) AddedFields() []string {
  10639. var fields []string
  10640. if m.addstatus != nil {
  10641. fields = append(fields, label.FieldStatus)
  10642. }
  10643. if m.add_type != nil {
  10644. fields = append(fields, label.FieldType)
  10645. }
  10646. if m.addfrom != nil {
  10647. fields = append(fields, label.FieldFrom)
  10648. }
  10649. if m.addmode != nil {
  10650. fields = append(fields, label.FieldMode)
  10651. }
  10652. if m.addorganization_id != nil {
  10653. fields = append(fields, label.FieldOrganizationID)
  10654. }
  10655. return fields
  10656. }
  10657. // AddedField returns the numeric value that was incremented/decremented on a field
  10658. // with the given name. The second boolean return value indicates that this field
  10659. // was not set, or was not defined in the schema.
  10660. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  10661. switch name {
  10662. case label.FieldStatus:
  10663. return m.AddedStatus()
  10664. case label.FieldType:
  10665. return m.AddedType()
  10666. case label.FieldFrom:
  10667. return m.AddedFrom()
  10668. case label.FieldMode:
  10669. return m.AddedMode()
  10670. case label.FieldOrganizationID:
  10671. return m.AddedOrganizationID()
  10672. }
  10673. return nil, false
  10674. }
  10675. // AddField adds the value to the field with the given name. It returns an error if
  10676. // the field is not defined in the schema, or if the type mismatched the field
  10677. // type.
  10678. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  10679. switch name {
  10680. case label.FieldStatus:
  10681. v, ok := value.(int8)
  10682. if !ok {
  10683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10684. }
  10685. m.AddStatus(v)
  10686. return nil
  10687. case label.FieldType:
  10688. v, ok := value.(int)
  10689. if !ok {
  10690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10691. }
  10692. m.AddType(v)
  10693. return nil
  10694. case label.FieldFrom:
  10695. v, ok := value.(int)
  10696. if !ok {
  10697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10698. }
  10699. m.AddFrom(v)
  10700. return nil
  10701. case label.FieldMode:
  10702. v, ok := value.(int)
  10703. if !ok {
  10704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10705. }
  10706. m.AddMode(v)
  10707. return nil
  10708. case label.FieldOrganizationID:
  10709. v, ok := value.(int64)
  10710. if !ok {
  10711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10712. }
  10713. m.AddOrganizationID(v)
  10714. return nil
  10715. }
  10716. return fmt.Errorf("unknown Label numeric field %s", name)
  10717. }
  10718. // ClearedFields returns all nullable fields that were cleared during this
  10719. // mutation.
  10720. func (m *LabelMutation) ClearedFields() []string {
  10721. var fields []string
  10722. if m.FieldCleared(label.FieldStatus) {
  10723. fields = append(fields, label.FieldStatus)
  10724. }
  10725. if m.FieldCleared(label.FieldConditions) {
  10726. fields = append(fields, label.FieldConditions)
  10727. }
  10728. if m.FieldCleared(label.FieldOrganizationID) {
  10729. fields = append(fields, label.FieldOrganizationID)
  10730. }
  10731. return fields
  10732. }
  10733. // FieldCleared returns a boolean indicating if a field with the given name was
  10734. // cleared in this mutation.
  10735. func (m *LabelMutation) FieldCleared(name string) bool {
  10736. _, ok := m.clearedFields[name]
  10737. return ok
  10738. }
  10739. // ClearField clears the value of the field with the given name. It returns an
  10740. // error if the field is not defined in the schema.
  10741. func (m *LabelMutation) ClearField(name string) error {
  10742. switch name {
  10743. case label.FieldStatus:
  10744. m.ClearStatus()
  10745. return nil
  10746. case label.FieldConditions:
  10747. m.ClearConditions()
  10748. return nil
  10749. case label.FieldOrganizationID:
  10750. m.ClearOrganizationID()
  10751. return nil
  10752. }
  10753. return fmt.Errorf("unknown Label nullable field %s", name)
  10754. }
  10755. // ResetField resets all changes in the mutation for the field with the given name.
  10756. // It returns an error if the field is not defined in the schema.
  10757. func (m *LabelMutation) ResetField(name string) error {
  10758. switch name {
  10759. case label.FieldCreatedAt:
  10760. m.ResetCreatedAt()
  10761. return nil
  10762. case label.FieldUpdatedAt:
  10763. m.ResetUpdatedAt()
  10764. return nil
  10765. case label.FieldStatus:
  10766. m.ResetStatus()
  10767. return nil
  10768. case label.FieldType:
  10769. m.ResetType()
  10770. return nil
  10771. case label.FieldName:
  10772. m.ResetName()
  10773. return nil
  10774. case label.FieldFrom:
  10775. m.ResetFrom()
  10776. return nil
  10777. case label.FieldMode:
  10778. m.ResetMode()
  10779. return nil
  10780. case label.FieldConditions:
  10781. m.ResetConditions()
  10782. return nil
  10783. case label.FieldOrganizationID:
  10784. m.ResetOrganizationID()
  10785. return nil
  10786. }
  10787. return fmt.Errorf("unknown Label field %s", name)
  10788. }
  10789. // AddedEdges returns all edge names that were set/added in this mutation.
  10790. func (m *LabelMutation) AddedEdges() []string {
  10791. edges := make([]string, 0, 1)
  10792. if m.label_relationships != nil {
  10793. edges = append(edges, label.EdgeLabelRelationships)
  10794. }
  10795. return edges
  10796. }
  10797. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10798. // name in this mutation.
  10799. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  10800. switch name {
  10801. case label.EdgeLabelRelationships:
  10802. ids := make([]ent.Value, 0, len(m.label_relationships))
  10803. for id := range m.label_relationships {
  10804. ids = append(ids, id)
  10805. }
  10806. return ids
  10807. }
  10808. return nil
  10809. }
  10810. // RemovedEdges returns all edge names that were removed in this mutation.
  10811. func (m *LabelMutation) RemovedEdges() []string {
  10812. edges := make([]string, 0, 1)
  10813. if m.removedlabel_relationships != nil {
  10814. edges = append(edges, label.EdgeLabelRelationships)
  10815. }
  10816. return edges
  10817. }
  10818. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10819. // the given name in this mutation.
  10820. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  10821. switch name {
  10822. case label.EdgeLabelRelationships:
  10823. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  10824. for id := range m.removedlabel_relationships {
  10825. ids = append(ids, id)
  10826. }
  10827. return ids
  10828. }
  10829. return nil
  10830. }
  10831. // ClearedEdges returns all edge names that were cleared in this mutation.
  10832. func (m *LabelMutation) ClearedEdges() []string {
  10833. edges := make([]string, 0, 1)
  10834. if m.clearedlabel_relationships {
  10835. edges = append(edges, label.EdgeLabelRelationships)
  10836. }
  10837. return edges
  10838. }
  10839. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10840. // was cleared in this mutation.
  10841. func (m *LabelMutation) EdgeCleared(name string) bool {
  10842. switch name {
  10843. case label.EdgeLabelRelationships:
  10844. return m.clearedlabel_relationships
  10845. }
  10846. return false
  10847. }
  10848. // ClearEdge clears the value of the edge with the given name. It returns an error
  10849. // if that edge is not defined in the schema.
  10850. func (m *LabelMutation) ClearEdge(name string) error {
  10851. switch name {
  10852. }
  10853. return fmt.Errorf("unknown Label unique edge %s", name)
  10854. }
  10855. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10856. // It returns an error if the edge is not defined in the schema.
  10857. func (m *LabelMutation) ResetEdge(name string) error {
  10858. switch name {
  10859. case label.EdgeLabelRelationships:
  10860. m.ResetLabelRelationships()
  10861. return nil
  10862. }
  10863. return fmt.Errorf("unknown Label edge %s", name)
  10864. }
  10865. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  10866. type LabelRelationshipMutation struct {
  10867. config
  10868. op Op
  10869. typ string
  10870. id *uint64
  10871. created_at *time.Time
  10872. updated_at *time.Time
  10873. status *uint8
  10874. addstatus *int8
  10875. deleted_at *time.Time
  10876. organization_id *uint64
  10877. addorganization_id *int64
  10878. clearedFields map[string]struct{}
  10879. contacts *uint64
  10880. clearedcontacts bool
  10881. labels *uint64
  10882. clearedlabels bool
  10883. done bool
  10884. oldValue func(context.Context) (*LabelRelationship, error)
  10885. predicates []predicate.LabelRelationship
  10886. }
  10887. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  10888. // labelrelationshipOption allows management of the mutation configuration using functional options.
  10889. type labelrelationshipOption func(*LabelRelationshipMutation)
  10890. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  10891. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  10892. m := &LabelRelationshipMutation{
  10893. config: c,
  10894. op: op,
  10895. typ: TypeLabelRelationship,
  10896. clearedFields: make(map[string]struct{}),
  10897. }
  10898. for _, opt := range opts {
  10899. opt(m)
  10900. }
  10901. return m
  10902. }
  10903. // withLabelRelationshipID sets the ID field of the mutation.
  10904. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  10905. return func(m *LabelRelationshipMutation) {
  10906. var (
  10907. err error
  10908. once sync.Once
  10909. value *LabelRelationship
  10910. )
  10911. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  10912. once.Do(func() {
  10913. if m.done {
  10914. err = errors.New("querying old values post mutation is not allowed")
  10915. } else {
  10916. value, err = m.Client().LabelRelationship.Get(ctx, id)
  10917. }
  10918. })
  10919. return value, err
  10920. }
  10921. m.id = &id
  10922. }
  10923. }
  10924. // withLabelRelationship sets the old LabelRelationship of the mutation.
  10925. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  10926. return func(m *LabelRelationshipMutation) {
  10927. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  10928. return node, nil
  10929. }
  10930. m.id = &node.ID
  10931. }
  10932. }
  10933. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10934. // executed in a transaction (ent.Tx), a transactional client is returned.
  10935. func (m LabelRelationshipMutation) Client() *Client {
  10936. client := &Client{config: m.config}
  10937. client.init()
  10938. return client
  10939. }
  10940. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10941. // it returns an error otherwise.
  10942. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  10943. if _, ok := m.driver.(*txDriver); !ok {
  10944. return nil, errors.New("ent: mutation is not running in a transaction")
  10945. }
  10946. tx := &Tx{config: m.config}
  10947. tx.init()
  10948. return tx, nil
  10949. }
  10950. // SetID sets the value of the id field. Note that this
  10951. // operation is only accepted on creation of LabelRelationship entities.
  10952. func (m *LabelRelationshipMutation) SetID(id uint64) {
  10953. m.id = &id
  10954. }
  10955. // ID returns the ID value in the mutation. Note that the ID is only available
  10956. // if it was provided to the builder or after it was returned from the database.
  10957. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  10958. if m.id == nil {
  10959. return
  10960. }
  10961. return *m.id, true
  10962. }
  10963. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10964. // That means, if the mutation is applied within a transaction with an isolation level such
  10965. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10966. // or updated by the mutation.
  10967. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  10968. switch {
  10969. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10970. id, exists := m.ID()
  10971. if exists {
  10972. return []uint64{id}, nil
  10973. }
  10974. fallthrough
  10975. case m.op.Is(OpUpdate | OpDelete):
  10976. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  10977. default:
  10978. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10979. }
  10980. }
  10981. // SetCreatedAt sets the "created_at" field.
  10982. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  10983. m.created_at = &t
  10984. }
  10985. // CreatedAt returns the value of the "created_at" field in the mutation.
  10986. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  10987. v := m.created_at
  10988. if v == nil {
  10989. return
  10990. }
  10991. return *v, true
  10992. }
  10993. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  10994. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  10995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10996. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10997. if !m.op.Is(OpUpdateOne) {
  10998. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10999. }
  11000. if m.id == nil || m.oldValue == nil {
  11001. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11002. }
  11003. oldValue, err := m.oldValue(ctx)
  11004. if err != nil {
  11005. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11006. }
  11007. return oldValue.CreatedAt, nil
  11008. }
  11009. // ResetCreatedAt resets all changes to the "created_at" field.
  11010. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  11011. m.created_at = nil
  11012. }
  11013. // SetUpdatedAt sets the "updated_at" field.
  11014. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  11015. m.updated_at = &t
  11016. }
  11017. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11018. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  11019. v := m.updated_at
  11020. if v == nil {
  11021. return
  11022. }
  11023. return *v, true
  11024. }
  11025. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  11026. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11028. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11029. if !m.op.Is(OpUpdateOne) {
  11030. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11031. }
  11032. if m.id == nil || m.oldValue == nil {
  11033. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11034. }
  11035. oldValue, err := m.oldValue(ctx)
  11036. if err != nil {
  11037. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11038. }
  11039. return oldValue.UpdatedAt, nil
  11040. }
  11041. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11042. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  11043. m.updated_at = nil
  11044. }
  11045. // SetStatus sets the "status" field.
  11046. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  11047. m.status = &u
  11048. m.addstatus = nil
  11049. }
  11050. // Status returns the value of the "status" field in the mutation.
  11051. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  11052. v := m.status
  11053. if v == nil {
  11054. return
  11055. }
  11056. return *v, true
  11057. }
  11058. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  11059. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11061. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11062. if !m.op.Is(OpUpdateOne) {
  11063. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11064. }
  11065. if m.id == nil || m.oldValue == nil {
  11066. return v, errors.New("OldStatus requires an ID field in the mutation")
  11067. }
  11068. oldValue, err := m.oldValue(ctx)
  11069. if err != nil {
  11070. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11071. }
  11072. return oldValue.Status, nil
  11073. }
  11074. // AddStatus adds u to the "status" field.
  11075. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  11076. if m.addstatus != nil {
  11077. *m.addstatus += u
  11078. } else {
  11079. m.addstatus = &u
  11080. }
  11081. }
  11082. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11083. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  11084. v := m.addstatus
  11085. if v == nil {
  11086. return
  11087. }
  11088. return *v, true
  11089. }
  11090. // ClearStatus clears the value of the "status" field.
  11091. func (m *LabelRelationshipMutation) ClearStatus() {
  11092. m.status = nil
  11093. m.addstatus = nil
  11094. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  11095. }
  11096. // StatusCleared returns if the "status" field was cleared in this mutation.
  11097. func (m *LabelRelationshipMutation) StatusCleared() bool {
  11098. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  11099. return ok
  11100. }
  11101. // ResetStatus resets all changes to the "status" field.
  11102. func (m *LabelRelationshipMutation) ResetStatus() {
  11103. m.status = nil
  11104. m.addstatus = nil
  11105. delete(m.clearedFields, labelrelationship.FieldStatus)
  11106. }
  11107. // SetDeletedAt sets the "deleted_at" field.
  11108. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  11109. m.deleted_at = &t
  11110. }
  11111. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11112. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  11113. v := m.deleted_at
  11114. if v == nil {
  11115. return
  11116. }
  11117. return *v, true
  11118. }
  11119. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  11120. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11122. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11123. if !m.op.Is(OpUpdateOne) {
  11124. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11125. }
  11126. if m.id == nil || m.oldValue == nil {
  11127. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11128. }
  11129. oldValue, err := m.oldValue(ctx)
  11130. if err != nil {
  11131. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11132. }
  11133. return oldValue.DeletedAt, nil
  11134. }
  11135. // ClearDeletedAt clears the value of the "deleted_at" field.
  11136. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  11137. m.deleted_at = nil
  11138. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  11139. }
  11140. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11141. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  11142. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  11143. return ok
  11144. }
  11145. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11146. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  11147. m.deleted_at = nil
  11148. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  11149. }
  11150. // SetLabelID sets the "label_id" field.
  11151. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  11152. m.labels = &u
  11153. }
  11154. // LabelID returns the value of the "label_id" field in the mutation.
  11155. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  11156. v := m.labels
  11157. if v == nil {
  11158. return
  11159. }
  11160. return *v, true
  11161. }
  11162. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  11163. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11165. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  11166. if !m.op.Is(OpUpdateOne) {
  11167. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  11168. }
  11169. if m.id == nil || m.oldValue == nil {
  11170. return v, errors.New("OldLabelID requires an ID field in the mutation")
  11171. }
  11172. oldValue, err := m.oldValue(ctx)
  11173. if err != nil {
  11174. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  11175. }
  11176. return oldValue.LabelID, nil
  11177. }
  11178. // ResetLabelID resets all changes to the "label_id" field.
  11179. func (m *LabelRelationshipMutation) ResetLabelID() {
  11180. m.labels = nil
  11181. }
  11182. // SetContactID sets the "contact_id" field.
  11183. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  11184. m.contacts = &u
  11185. }
  11186. // ContactID returns the value of the "contact_id" field in the mutation.
  11187. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  11188. v := m.contacts
  11189. if v == nil {
  11190. return
  11191. }
  11192. return *v, true
  11193. }
  11194. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  11195. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11197. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  11198. if !m.op.Is(OpUpdateOne) {
  11199. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  11200. }
  11201. if m.id == nil || m.oldValue == nil {
  11202. return v, errors.New("OldContactID requires an ID field in the mutation")
  11203. }
  11204. oldValue, err := m.oldValue(ctx)
  11205. if err != nil {
  11206. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  11207. }
  11208. return oldValue.ContactID, nil
  11209. }
  11210. // ResetContactID resets all changes to the "contact_id" field.
  11211. func (m *LabelRelationshipMutation) ResetContactID() {
  11212. m.contacts = nil
  11213. }
  11214. // SetOrganizationID sets the "organization_id" field.
  11215. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  11216. m.organization_id = &u
  11217. m.addorganization_id = nil
  11218. }
  11219. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11220. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  11221. v := m.organization_id
  11222. if v == nil {
  11223. return
  11224. }
  11225. return *v, true
  11226. }
  11227. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  11228. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11230. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11231. if !m.op.Is(OpUpdateOne) {
  11232. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11233. }
  11234. if m.id == nil || m.oldValue == nil {
  11235. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11236. }
  11237. oldValue, err := m.oldValue(ctx)
  11238. if err != nil {
  11239. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11240. }
  11241. return oldValue.OrganizationID, nil
  11242. }
  11243. // AddOrganizationID adds u to the "organization_id" field.
  11244. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  11245. if m.addorganization_id != nil {
  11246. *m.addorganization_id += u
  11247. } else {
  11248. m.addorganization_id = &u
  11249. }
  11250. }
  11251. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11252. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  11253. v := m.addorganization_id
  11254. if v == nil {
  11255. return
  11256. }
  11257. return *v, true
  11258. }
  11259. // ClearOrganizationID clears the value of the "organization_id" field.
  11260. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  11261. m.organization_id = nil
  11262. m.addorganization_id = nil
  11263. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  11264. }
  11265. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11266. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  11267. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  11268. return ok
  11269. }
  11270. // ResetOrganizationID resets all changes to the "organization_id" field.
  11271. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  11272. m.organization_id = nil
  11273. m.addorganization_id = nil
  11274. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  11275. }
  11276. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  11277. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  11278. m.contacts = &id
  11279. }
  11280. // ClearContacts clears the "contacts" edge to the Contact entity.
  11281. func (m *LabelRelationshipMutation) ClearContacts() {
  11282. m.clearedcontacts = true
  11283. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  11284. }
  11285. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  11286. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  11287. return m.clearedcontacts
  11288. }
  11289. // ContactsID returns the "contacts" edge ID in the mutation.
  11290. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  11291. if m.contacts != nil {
  11292. return *m.contacts, true
  11293. }
  11294. return
  11295. }
  11296. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  11297. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11298. // ContactsID instead. It exists only for internal usage by the builders.
  11299. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  11300. if id := m.contacts; id != nil {
  11301. ids = append(ids, *id)
  11302. }
  11303. return
  11304. }
  11305. // ResetContacts resets all changes to the "contacts" edge.
  11306. func (m *LabelRelationshipMutation) ResetContacts() {
  11307. m.contacts = nil
  11308. m.clearedcontacts = false
  11309. }
  11310. // SetLabelsID sets the "labels" edge to the Label entity by id.
  11311. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  11312. m.labels = &id
  11313. }
  11314. // ClearLabels clears the "labels" edge to the Label entity.
  11315. func (m *LabelRelationshipMutation) ClearLabels() {
  11316. m.clearedlabels = true
  11317. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  11318. }
  11319. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  11320. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  11321. return m.clearedlabels
  11322. }
  11323. // LabelsID returns the "labels" edge ID in the mutation.
  11324. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  11325. if m.labels != nil {
  11326. return *m.labels, true
  11327. }
  11328. return
  11329. }
  11330. // LabelsIDs returns the "labels" edge IDs in the mutation.
  11331. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11332. // LabelsID instead. It exists only for internal usage by the builders.
  11333. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  11334. if id := m.labels; id != nil {
  11335. ids = append(ids, *id)
  11336. }
  11337. return
  11338. }
  11339. // ResetLabels resets all changes to the "labels" edge.
  11340. func (m *LabelRelationshipMutation) ResetLabels() {
  11341. m.labels = nil
  11342. m.clearedlabels = false
  11343. }
  11344. // Where appends a list predicates to the LabelRelationshipMutation builder.
  11345. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  11346. m.predicates = append(m.predicates, ps...)
  11347. }
  11348. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  11349. // users can use type-assertion to append predicates that do not depend on any generated package.
  11350. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  11351. p := make([]predicate.LabelRelationship, len(ps))
  11352. for i := range ps {
  11353. p[i] = ps[i]
  11354. }
  11355. m.Where(p...)
  11356. }
  11357. // Op returns the operation name.
  11358. func (m *LabelRelationshipMutation) Op() Op {
  11359. return m.op
  11360. }
  11361. // SetOp allows setting the mutation operation.
  11362. func (m *LabelRelationshipMutation) SetOp(op Op) {
  11363. m.op = op
  11364. }
  11365. // Type returns the node type of this mutation (LabelRelationship).
  11366. func (m *LabelRelationshipMutation) Type() string {
  11367. return m.typ
  11368. }
  11369. // Fields returns all fields that were changed during this mutation. Note that in
  11370. // order to get all numeric fields that were incremented/decremented, call
  11371. // AddedFields().
  11372. func (m *LabelRelationshipMutation) Fields() []string {
  11373. fields := make([]string, 0, 7)
  11374. if m.created_at != nil {
  11375. fields = append(fields, labelrelationship.FieldCreatedAt)
  11376. }
  11377. if m.updated_at != nil {
  11378. fields = append(fields, labelrelationship.FieldUpdatedAt)
  11379. }
  11380. if m.status != nil {
  11381. fields = append(fields, labelrelationship.FieldStatus)
  11382. }
  11383. if m.deleted_at != nil {
  11384. fields = append(fields, labelrelationship.FieldDeletedAt)
  11385. }
  11386. if m.labels != nil {
  11387. fields = append(fields, labelrelationship.FieldLabelID)
  11388. }
  11389. if m.contacts != nil {
  11390. fields = append(fields, labelrelationship.FieldContactID)
  11391. }
  11392. if m.organization_id != nil {
  11393. fields = append(fields, labelrelationship.FieldOrganizationID)
  11394. }
  11395. return fields
  11396. }
  11397. // Field returns the value of a field with the given name. The second boolean
  11398. // return value indicates that this field was not set, or was not defined in the
  11399. // schema.
  11400. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  11401. switch name {
  11402. case labelrelationship.FieldCreatedAt:
  11403. return m.CreatedAt()
  11404. case labelrelationship.FieldUpdatedAt:
  11405. return m.UpdatedAt()
  11406. case labelrelationship.FieldStatus:
  11407. return m.Status()
  11408. case labelrelationship.FieldDeletedAt:
  11409. return m.DeletedAt()
  11410. case labelrelationship.FieldLabelID:
  11411. return m.LabelID()
  11412. case labelrelationship.FieldContactID:
  11413. return m.ContactID()
  11414. case labelrelationship.FieldOrganizationID:
  11415. return m.OrganizationID()
  11416. }
  11417. return nil, false
  11418. }
  11419. // OldField returns the old value of the field from the database. An error is
  11420. // returned if the mutation operation is not UpdateOne, or the query to the
  11421. // database failed.
  11422. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11423. switch name {
  11424. case labelrelationship.FieldCreatedAt:
  11425. return m.OldCreatedAt(ctx)
  11426. case labelrelationship.FieldUpdatedAt:
  11427. return m.OldUpdatedAt(ctx)
  11428. case labelrelationship.FieldStatus:
  11429. return m.OldStatus(ctx)
  11430. case labelrelationship.FieldDeletedAt:
  11431. return m.OldDeletedAt(ctx)
  11432. case labelrelationship.FieldLabelID:
  11433. return m.OldLabelID(ctx)
  11434. case labelrelationship.FieldContactID:
  11435. return m.OldContactID(ctx)
  11436. case labelrelationship.FieldOrganizationID:
  11437. return m.OldOrganizationID(ctx)
  11438. }
  11439. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  11440. }
  11441. // SetField sets the value of a field with the given name. It returns an error if
  11442. // the field is not defined in the schema, or if the type mismatched the field
  11443. // type.
  11444. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  11445. switch name {
  11446. case labelrelationship.FieldCreatedAt:
  11447. v, ok := value.(time.Time)
  11448. if !ok {
  11449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11450. }
  11451. m.SetCreatedAt(v)
  11452. return nil
  11453. case labelrelationship.FieldUpdatedAt:
  11454. v, ok := value.(time.Time)
  11455. if !ok {
  11456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11457. }
  11458. m.SetUpdatedAt(v)
  11459. return nil
  11460. case labelrelationship.FieldStatus:
  11461. v, ok := value.(uint8)
  11462. if !ok {
  11463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11464. }
  11465. m.SetStatus(v)
  11466. return nil
  11467. case labelrelationship.FieldDeletedAt:
  11468. v, ok := value.(time.Time)
  11469. if !ok {
  11470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11471. }
  11472. m.SetDeletedAt(v)
  11473. return nil
  11474. case labelrelationship.FieldLabelID:
  11475. v, ok := value.(uint64)
  11476. if !ok {
  11477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11478. }
  11479. m.SetLabelID(v)
  11480. return nil
  11481. case labelrelationship.FieldContactID:
  11482. v, ok := value.(uint64)
  11483. if !ok {
  11484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11485. }
  11486. m.SetContactID(v)
  11487. return nil
  11488. case labelrelationship.FieldOrganizationID:
  11489. v, ok := value.(uint64)
  11490. if !ok {
  11491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11492. }
  11493. m.SetOrganizationID(v)
  11494. return nil
  11495. }
  11496. return fmt.Errorf("unknown LabelRelationship field %s", name)
  11497. }
  11498. // AddedFields returns all numeric fields that were incremented/decremented during
  11499. // this mutation.
  11500. func (m *LabelRelationshipMutation) AddedFields() []string {
  11501. var fields []string
  11502. if m.addstatus != nil {
  11503. fields = append(fields, labelrelationship.FieldStatus)
  11504. }
  11505. if m.addorganization_id != nil {
  11506. fields = append(fields, labelrelationship.FieldOrganizationID)
  11507. }
  11508. return fields
  11509. }
  11510. // AddedField returns the numeric value that was incremented/decremented on a field
  11511. // with the given name. The second boolean return value indicates that this field
  11512. // was not set, or was not defined in the schema.
  11513. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  11514. switch name {
  11515. case labelrelationship.FieldStatus:
  11516. return m.AddedStatus()
  11517. case labelrelationship.FieldOrganizationID:
  11518. return m.AddedOrganizationID()
  11519. }
  11520. return nil, false
  11521. }
  11522. // AddField adds the value to the field with the given name. It returns an error if
  11523. // the field is not defined in the schema, or if the type mismatched the field
  11524. // type.
  11525. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  11526. switch name {
  11527. case labelrelationship.FieldStatus:
  11528. v, ok := value.(int8)
  11529. if !ok {
  11530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11531. }
  11532. m.AddStatus(v)
  11533. return nil
  11534. case labelrelationship.FieldOrganizationID:
  11535. v, ok := value.(int64)
  11536. if !ok {
  11537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11538. }
  11539. m.AddOrganizationID(v)
  11540. return nil
  11541. }
  11542. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  11543. }
  11544. // ClearedFields returns all nullable fields that were cleared during this
  11545. // mutation.
  11546. func (m *LabelRelationshipMutation) ClearedFields() []string {
  11547. var fields []string
  11548. if m.FieldCleared(labelrelationship.FieldStatus) {
  11549. fields = append(fields, labelrelationship.FieldStatus)
  11550. }
  11551. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  11552. fields = append(fields, labelrelationship.FieldDeletedAt)
  11553. }
  11554. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  11555. fields = append(fields, labelrelationship.FieldOrganizationID)
  11556. }
  11557. return fields
  11558. }
  11559. // FieldCleared returns a boolean indicating if a field with the given name was
  11560. // cleared in this mutation.
  11561. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  11562. _, ok := m.clearedFields[name]
  11563. return ok
  11564. }
  11565. // ClearField clears the value of the field with the given name. It returns an
  11566. // error if the field is not defined in the schema.
  11567. func (m *LabelRelationshipMutation) ClearField(name string) error {
  11568. switch name {
  11569. case labelrelationship.FieldStatus:
  11570. m.ClearStatus()
  11571. return nil
  11572. case labelrelationship.FieldDeletedAt:
  11573. m.ClearDeletedAt()
  11574. return nil
  11575. case labelrelationship.FieldOrganizationID:
  11576. m.ClearOrganizationID()
  11577. return nil
  11578. }
  11579. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  11580. }
  11581. // ResetField resets all changes in the mutation for the field with the given name.
  11582. // It returns an error if the field is not defined in the schema.
  11583. func (m *LabelRelationshipMutation) ResetField(name string) error {
  11584. switch name {
  11585. case labelrelationship.FieldCreatedAt:
  11586. m.ResetCreatedAt()
  11587. return nil
  11588. case labelrelationship.FieldUpdatedAt:
  11589. m.ResetUpdatedAt()
  11590. return nil
  11591. case labelrelationship.FieldStatus:
  11592. m.ResetStatus()
  11593. return nil
  11594. case labelrelationship.FieldDeletedAt:
  11595. m.ResetDeletedAt()
  11596. return nil
  11597. case labelrelationship.FieldLabelID:
  11598. m.ResetLabelID()
  11599. return nil
  11600. case labelrelationship.FieldContactID:
  11601. m.ResetContactID()
  11602. return nil
  11603. case labelrelationship.FieldOrganizationID:
  11604. m.ResetOrganizationID()
  11605. return nil
  11606. }
  11607. return fmt.Errorf("unknown LabelRelationship field %s", name)
  11608. }
  11609. // AddedEdges returns all edge names that were set/added in this mutation.
  11610. func (m *LabelRelationshipMutation) AddedEdges() []string {
  11611. edges := make([]string, 0, 2)
  11612. if m.contacts != nil {
  11613. edges = append(edges, labelrelationship.EdgeContacts)
  11614. }
  11615. if m.labels != nil {
  11616. edges = append(edges, labelrelationship.EdgeLabels)
  11617. }
  11618. return edges
  11619. }
  11620. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11621. // name in this mutation.
  11622. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  11623. switch name {
  11624. case labelrelationship.EdgeContacts:
  11625. if id := m.contacts; id != nil {
  11626. return []ent.Value{*id}
  11627. }
  11628. case labelrelationship.EdgeLabels:
  11629. if id := m.labels; id != nil {
  11630. return []ent.Value{*id}
  11631. }
  11632. }
  11633. return nil
  11634. }
  11635. // RemovedEdges returns all edge names that were removed in this mutation.
  11636. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  11637. edges := make([]string, 0, 2)
  11638. return edges
  11639. }
  11640. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11641. // the given name in this mutation.
  11642. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  11643. return nil
  11644. }
  11645. // ClearedEdges returns all edge names that were cleared in this mutation.
  11646. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  11647. edges := make([]string, 0, 2)
  11648. if m.clearedcontacts {
  11649. edges = append(edges, labelrelationship.EdgeContacts)
  11650. }
  11651. if m.clearedlabels {
  11652. edges = append(edges, labelrelationship.EdgeLabels)
  11653. }
  11654. return edges
  11655. }
  11656. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11657. // was cleared in this mutation.
  11658. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  11659. switch name {
  11660. case labelrelationship.EdgeContacts:
  11661. return m.clearedcontacts
  11662. case labelrelationship.EdgeLabels:
  11663. return m.clearedlabels
  11664. }
  11665. return false
  11666. }
  11667. // ClearEdge clears the value of the edge with the given name. It returns an error
  11668. // if that edge is not defined in the schema.
  11669. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  11670. switch name {
  11671. case labelrelationship.EdgeContacts:
  11672. m.ClearContacts()
  11673. return nil
  11674. case labelrelationship.EdgeLabels:
  11675. m.ClearLabels()
  11676. return nil
  11677. }
  11678. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  11679. }
  11680. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11681. // It returns an error if the edge is not defined in the schema.
  11682. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  11683. switch name {
  11684. case labelrelationship.EdgeContacts:
  11685. m.ResetContacts()
  11686. return nil
  11687. case labelrelationship.EdgeLabels:
  11688. m.ResetLabels()
  11689. return nil
  11690. }
  11691. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  11692. }
  11693. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  11694. type MessageMutation struct {
  11695. config
  11696. op Op
  11697. typ string
  11698. id *int
  11699. wx_wxid *string
  11700. wxid *string
  11701. content *string
  11702. clearedFields map[string]struct{}
  11703. done bool
  11704. oldValue func(context.Context) (*Message, error)
  11705. predicates []predicate.Message
  11706. }
  11707. var _ ent.Mutation = (*MessageMutation)(nil)
  11708. // messageOption allows management of the mutation configuration using functional options.
  11709. type messageOption func(*MessageMutation)
  11710. // newMessageMutation creates new mutation for the Message entity.
  11711. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  11712. m := &MessageMutation{
  11713. config: c,
  11714. op: op,
  11715. typ: TypeMessage,
  11716. clearedFields: make(map[string]struct{}),
  11717. }
  11718. for _, opt := range opts {
  11719. opt(m)
  11720. }
  11721. return m
  11722. }
  11723. // withMessageID sets the ID field of the mutation.
  11724. func withMessageID(id int) messageOption {
  11725. return func(m *MessageMutation) {
  11726. var (
  11727. err error
  11728. once sync.Once
  11729. value *Message
  11730. )
  11731. m.oldValue = func(ctx context.Context) (*Message, error) {
  11732. once.Do(func() {
  11733. if m.done {
  11734. err = errors.New("querying old values post mutation is not allowed")
  11735. } else {
  11736. value, err = m.Client().Message.Get(ctx, id)
  11737. }
  11738. })
  11739. return value, err
  11740. }
  11741. m.id = &id
  11742. }
  11743. }
  11744. // withMessage sets the old Message of the mutation.
  11745. func withMessage(node *Message) messageOption {
  11746. return func(m *MessageMutation) {
  11747. m.oldValue = func(context.Context) (*Message, error) {
  11748. return node, nil
  11749. }
  11750. m.id = &node.ID
  11751. }
  11752. }
  11753. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11754. // executed in a transaction (ent.Tx), a transactional client is returned.
  11755. func (m MessageMutation) Client() *Client {
  11756. client := &Client{config: m.config}
  11757. client.init()
  11758. return client
  11759. }
  11760. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11761. // it returns an error otherwise.
  11762. func (m MessageMutation) Tx() (*Tx, error) {
  11763. if _, ok := m.driver.(*txDriver); !ok {
  11764. return nil, errors.New("ent: mutation is not running in a transaction")
  11765. }
  11766. tx := &Tx{config: m.config}
  11767. tx.init()
  11768. return tx, nil
  11769. }
  11770. // ID returns the ID value in the mutation. Note that the ID is only available
  11771. // if it was provided to the builder or after it was returned from the database.
  11772. func (m *MessageMutation) ID() (id int, exists bool) {
  11773. if m.id == nil {
  11774. return
  11775. }
  11776. return *m.id, true
  11777. }
  11778. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11779. // That means, if the mutation is applied within a transaction with an isolation level such
  11780. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11781. // or updated by the mutation.
  11782. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  11783. switch {
  11784. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11785. id, exists := m.ID()
  11786. if exists {
  11787. return []int{id}, nil
  11788. }
  11789. fallthrough
  11790. case m.op.Is(OpUpdate | OpDelete):
  11791. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  11792. default:
  11793. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11794. }
  11795. }
  11796. // SetWxWxid sets the "wx_wxid" field.
  11797. func (m *MessageMutation) SetWxWxid(s string) {
  11798. m.wx_wxid = &s
  11799. }
  11800. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  11801. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  11802. v := m.wx_wxid
  11803. if v == nil {
  11804. return
  11805. }
  11806. return *v, true
  11807. }
  11808. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  11809. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  11810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11811. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  11812. if !m.op.Is(OpUpdateOne) {
  11813. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  11814. }
  11815. if m.id == nil || m.oldValue == nil {
  11816. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  11817. }
  11818. oldValue, err := m.oldValue(ctx)
  11819. if err != nil {
  11820. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  11821. }
  11822. return oldValue.WxWxid, nil
  11823. }
  11824. // ClearWxWxid clears the value of the "wx_wxid" field.
  11825. func (m *MessageMutation) ClearWxWxid() {
  11826. m.wx_wxid = nil
  11827. m.clearedFields[message.FieldWxWxid] = struct{}{}
  11828. }
  11829. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  11830. func (m *MessageMutation) WxWxidCleared() bool {
  11831. _, ok := m.clearedFields[message.FieldWxWxid]
  11832. return ok
  11833. }
  11834. // ResetWxWxid resets all changes to the "wx_wxid" field.
  11835. func (m *MessageMutation) ResetWxWxid() {
  11836. m.wx_wxid = nil
  11837. delete(m.clearedFields, message.FieldWxWxid)
  11838. }
  11839. // SetWxid sets the "wxid" field.
  11840. func (m *MessageMutation) SetWxid(s string) {
  11841. m.wxid = &s
  11842. }
  11843. // Wxid returns the value of the "wxid" field in the mutation.
  11844. func (m *MessageMutation) Wxid() (r string, exists bool) {
  11845. v := m.wxid
  11846. if v == nil {
  11847. return
  11848. }
  11849. return *v, true
  11850. }
  11851. // OldWxid returns the old "wxid" field's value of the Message entity.
  11852. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  11853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11854. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  11855. if !m.op.Is(OpUpdateOne) {
  11856. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  11857. }
  11858. if m.id == nil || m.oldValue == nil {
  11859. return v, errors.New("OldWxid requires an ID field in the mutation")
  11860. }
  11861. oldValue, err := m.oldValue(ctx)
  11862. if err != nil {
  11863. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  11864. }
  11865. return oldValue.Wxid, nil
  11866. }
  11867. // ResetWxid resets all changes to the "wxid" field.
  11868. func (m *MessageMutation) ResetWxid() {
  11869. m.wxid = nil
  11870. }
  11871. // SetContent sets the "content" field.
  11872. func (m *MessageMutation) SetContent(s string) {
  11873. m.content = &s
  11874. }
  11875. // Content returns the value of the "content" field in the mutation.
  11876. func (m *MessageMutation) Content() (r string, exists bool) {
  11877. v := m.content
  11878. if v == nil {
  11879. return
  11880. }
  11881. return *v, true
  11882. }
  11883. // OldContent returns the old "content" field's value of the Message entity.
  11884. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  11885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11886. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  11887. if !m.op.Is(OpUpdateOne) {
  11888. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  11889. }
  11890. if m.id == nil || m.oldValue == nil {
  11891. return v, errors.New("OldContent requires an ID field in the mutation")
  11892. }
  11893. oldValue, err := m.oldValue(ctx)
  11894. if err != nil {
  11895. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  11896. }
  11897. return oldValue.Content, nil
  11898. }
  11899. // ResetContent resets all changes to the "content" field.
  11900. func (m *MessageMutation) ResetContent() {
  11901. m.content = nil
  11902. }
  11903. // Where appends a list predicates to the MessageMutation builder.
  11904. func (m *MessageMutation) Where(ps ...predicate.Message) {
  11905. m.predicates = append(m.predicates, ps...)
  11906. }
  11907. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  11908. // users can use type-assertion to append predicates that do not depend on any generated package.
  11909. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  11910. p := make([]predicate.Message, len(ps))
  11911. for i := range ps {
  11912. p[i] = ps[i]
  11913. }
  11914. m.Where(p...)
  11915. }
  11916. // Op returns the operation name.
  11917. func (m *MessageMutation) Op() Op {
  11918. return m.op
  11919. }
  11920. // SetOp allows setting the mutation operation.
  11921. func (m *MessageMutation) SetOp(op Op) {
  11922. m.op = op
  11923. }
  11924. // Type returns the node type of this mutation (Message).
  11925. func (m *MessageMutation) Type() string {
  11926. return m.typ
  11927. }
  11928. // Fields returns all fields that were changed during this mutation. Note that in
  11929. // order to get all numeric fields that were incremented/decremented, call
  11930. // AddedFields().
  11931. func (m *MessageMutation) Fields() []string {
  11932. fields := make([]string, 0, 3)
  11933. if m.wx_wxid != nil {
  11934. fields = append(fields, message.FieldWxWxid)
  11935. }
  11936. if m.wxid != nil {
  11937. fields = append(fields, message.FieldWxid)
  11938. }
  11939. if m.content != nil {
  11940. fields = append(fields, message.FieldContent)
  11941. }
  11942. return fields
  11943. }
  11944. // Field returns the value of a field with the given name. The second boolean
  11945. // return value indicates that this field was not set, or was not defined in the
  11946. // schema.
  11947. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  11948. switch name {
  11949. case message.FieldWxWxid:
  11950. return m.WxWxid()
  11951. case message.FieldWxid:
  11952. return m.Wxid()
  11953. case message.FieldContent:
  11954. return m.Content()
  11955. }
  11956. return nil, false
  11957. }
  11958. // OldField returns the old value of the field from the database. An error is
  11959. // returned if the mutation operation is not UpdateOne, or the query to the
  11960. // database failed.
  11961. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11962. switch name {
  11963. case message.FieldWxWxid:
  11964. return m.OldWxWxid(ctx)
  11965. case message.FieldWxid:
  11966. return m.OldWxid(ctx)
  11967. case message.FieldContent:
  11968. return m.OldContent(ctx)
  11969. }
  11970. return nil, fmt.Errorf("unknown Message field %s", name)
  11971. }
  11972. // SetField sets the value of a field with the given name. It returns an error if
  11973. // the field is not defined in the schema, or if the type mismatched the field
  11974. // type.
  11975. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  11976. switch name {
  11977. case message.FieldWxWxid:
  11978. v, ok := value.(string)
  11979. if !ok {
  11980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11981. }
  11982. m.SetWxWxid(v)
  11983. return nil
  11984. case message.FieldWxid:
  11985. v, ok := value.(string)
  11986. if !ok {
  11987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11988. }
  11989. m.SetWxid(v)
  11990. return nil
  11991. case message.FieldContent:
  11992. v, ok := value.(string)
  11993. if !ok {
  11994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11995. }
  11996. m.SetContent(v)
  11997. return nil
  11998. }
  11999. return fmt.Errorf("unknown Message field %s", name)
  12000. }
  12001. // AddedFields returns all numeric fields that were incremented/decremented during
  12002. // this mutation.
  12003. func (m *MessageMutation) AddedFields() []string {
  12004. return nil
  12005. }
  12006. // AddedField returns the numeric value that was incremented/decremented on a field
  12007. // with the given name. The second boolean return value indicates that this field
  12008. // was not set, or was not defined in the schema.
  12009. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  12010. return nil, false
  12011. }
  12012. // AddField adds the value to the field with the given name. It returns an error if
  12013. // the field is not defined in the schema, or if the type mismatched the field
  12014. // type.
  12015. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  12016. switch name {
  12017. }
  12018. return fmt.Errorf("unknown Message numeric field %s", name)
  12019. }
  12020. // ClearedFields returns all nullable fields that were cleared during this
  12021. // mutation.
  12022. func (m *MessageMutation) ClearedFields() []string {
  12023. var fields []string
  12024. if m.FieldCleared(message.FieldWxWxid) {
  12025. fields = append(fields, message.FieldWxWxid)
  12026. }
  12027. return fields
  12028. }
  12029. // FieldCleared returns a boolean indicating if a field with the given name was
  12030. // cleared in this mutation.
  12031. func (m *MessageMutation) FieldCleared(name string) bool {
  12032. _, ok := m.clearedFields[name]
  12033. return ok
  12034. }
  12035. // ClearField clears the value of the field with the given name. It returns an
  12036. // error if the field is not defined in the schema.
  12037. func (m *MessageMutation) ClearField(name string) error {
  12038. switch name {
  12039. case message.FieldWxWxid:
  12040. m.ClearWxWxid()
  12041. return nil
  12042. }
  12043. return fmt.Errorf("unknown Message nullable field %s", name)
  12044. }
  12045. // ResetField resets all changes in the mutation for the field with the given name.
  12046. // It returns an error if the field is not defined in the schema.
  12047. func (m *MessageMutation) ResetField(name string) error {
  12048. switch name {
  12049. case message.FieldWxWxid:
  12050. m.ResetWxWxid()
  12051. return nil
  12052. case message.FieldWxid:
  12053. m.ResetWxid()
  12054. return nil
  12055. case message.FieldContent:
  12056. m.ResetContent()
  12057. return nil
  12058. }
  12059. return fmt.Errorf("unknown Message field %s", name)
  12060. }
  12061. // AddedEdges returns all edge names that were set/added in this mutation.
  12062. func (m *MessageMutation) AddedEdges() []string {
  12063. edges := make([]string, 0, 0)
  12064. return edges
  12065. }
  12066. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12067. // name in this mutation.
  12068. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  12069. return nil
  12070. }
  12071. // RemovedEdges returns all edge names that were removed in this mutation.
  12072. func (m *MessageMutation) RemovedEdges() []string {
  12073. edges := make([]string, 0, 0)
  12074. return edges
  12075. }
  12076. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12077. // the given name in this mutation.
  12078. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  12079. return nil
  12080. }
  12081. // ClearedEdges returns all edge names that were cleared in this mutation.
  12082. func (m *MessageMutation) ClearedEdges() []string {
  12083. edges := make([]string, 0, 0)
  12084. return edges
  12085. }
  12086. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12087. // was cleared in this mutation.
  12088. func (m *MessageMutation) EdgeCleared(name string) bool {
  12089. return false
  12090. }
  12091. // ClearEdge clears the value of the edge with the given name. It returns an error
  12092. // if that edge is not defined in the schema.
  12093. func (m *MessageMutation) ClearEdge(name string) error {
  12094. return fmt.Errorf("unknown Message unique edge %s", name)
  12095. }
  12096. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12097. // It returns an error if the edge is not defined in the schema.
  12098. func (m *MessageMutation) ResetEdge(name string) error {
  12099. return fmt.Errorf("unknown Message edge %s", name)
  12100. }
  12101. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  12102. type MessageRecordsMutation struct {
  12103. config
  12104. op Op
  12105. typ string
  12106. id *uint64
  12107. created_at *time.Time
  12108. updated_at *time.Time
  12109. status *uint8
  12110. addstatus *int8
  12111. bot_wxid *string
  12112. contact_type *int
  12113. addcontact_type *int
  12114. contact_wxid *string
  12115. content_type *int
  12116. addcontent_type *int
  12117. content *string
  12118. meta *custom_types.Meta
  12119. error_detail *string
  12120. send_time *time.Time
  12121. source_type *int
  12122. addsource_type *int
  12123. organization_id *uint64
  12124. addorganization_id *int64
  12125. clearedFields map[string]struct{}
  12126. sop_stage *uint64
  12127. clearedsop_stage bool
  12128. sop_node *uint64
  12129. clearedsop_node bool
  12130. message_contact *uint64
  12131. clearedmessage_contact bool
  12132. done bool
  12133. oldValue func(context.Context) (*MessageRecords, error)
  12134. predicates []predicate.MessageRecords
  12135. }
  12136. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  12137. // messagerecordsOption allows management of the mutation configuration using functional options.
  12138. type messagerecordsOption func(*MessageRecordsMutation)
  12139. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  12140. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  12141. m := &MessageRecordsMutation{
  12142. config: c,
  12143. op: op,
  12144. typ: TypeMessageRecords,
  12145. clearedFields: make(map[string]struct{}),
  12146. }
  12147. for _, opt := range opts {
  12148. opt(m)
  12149. }
  12150. return m
  12151. }
  12152. // withMessageRecordsID sets the ID field of the mutation.
  12153. func withMessageRecordsID(id uint64) messagerecordsOption {
  12154. return func(m *MessageRecordsMutation) {
  12155. var (
  12156. err error
  12157. once sync.Once
  12158. value *MessageRecords
  12159. )
  12160. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  12161. once.Do(func() {
  12162. if m.done {
  12163. err = errors.New("querying old values post mutation is not allowed")
  12164. } else {
  12165. value, err = m.Client().MessageRecords.Get(ctx, id)
  12166. }
  12167. })
  12168. return value, err
  12169. }
  12170. m.id = &id
  12171. }
  12172. }
  12173. // withMessageRecords sets the old MessageRecords of the mutation.
  12174. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  12175. return func(m *MessageRecordsMutation) {
  12176. m.oldValue = func(context.Context) (*MessageRecords, error) {
  12177. return node, nil
  12178. }
  12179. m.id = &node.ID
  12180. }
  12181. }
  12182. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12183. // executed in a transaction (ent.Tx), a transactional client is returned.
  12184. func (m MessageRecordsMutation) Client() *Client {
  12185. client := &Client{config: m.config}
  12186. client.init()
  12187. return client
  12188. }
  12189. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12190. // it returns an error otherwise.
  12191. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  12192. if _, ok := m.driver.(*txDriver); !ok {
  12193. return nil, errors.New("ent: mutation is not running in a transaction")
  12194. }
  12195. tx := &Tx{config: m.config}
  12196. tx.init()
  12197. return tx, nil
  12198. }
  12199. // SetID sets the value of the id field. Note that this
  12200. // operation is only accepted on creation of MessageRecords entities.
  12201. func (m *MessageRecordsMutation) SetID(id uint64) {
  12202. m.id = &id
  12203. }
  12204. // ID returns the ID value in the mutation. Note that the ID is only available
  12205. // if it was provided to the builder or after it was returned from the database.
  12206. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  12207. if m.id == nil {
  12208. return
  12209. }
  12210. return *m.id, true
  12211. }
  12212. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12213. // That means, if the mutation is applied within a transaction with an isolation level such
  12214. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12215. // or updated by the mutation.
  12216. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  12217. switch {
  12218. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12219. id, exists := m.ID()
  12220. if exists {
  12221. return []uint64{id}, nil
  12222. }
  12223. fallthrough
  12224. case m.op.Is(OpUpdate | OpDelete):
  12225. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  12226. default:
  12227. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12228. }
  12229. }
  12230. // SetCreatedAt sets the "created_at" field.
  12231. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  12232. m.created_at = &t
  12233. }
  12234. // CreatedAt returns the value of the "created_at" field in the mutation.
  12235. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  12236. v := m.created_at
  12237. if v == nil {
  12238. return
  12239. }
  12240. return *v, true
  12241. }
  12242. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  12243. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12245. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12246. if !m.op.Is(OpUpdateOne) {
  12247. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12248. }
  12249. if m.id == nil || m.oldValue == nil {
  12250. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12251. }
  12252. oldValue, err := m.oldValue(ctx)
  12253. if err != nil {
  12254. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12255. }
  12256. return oldValue.CreatedAt, nil
  12257. }
  12258. // ResetCreatedAt resets all changes to the "created_at" field.
  12259. func (m *MessageRecordsMutation) ResetCreatedAt() {
  12260. m.created_at = nil
  12261. }
  12262. // SetUpdatedAt sets the "updated_at" field.
  12263. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  12264. m.updated_at = &t
  12265. }
  12266. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12267. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  12268. v := m.updated_at
  12269. if v == nil {
  12270. return
  12271. }
  12272. return *v, true
  12273. }
  12274. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  12275. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12277. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12278. if !m.op.Is(OpUpdateOne) {
  12279. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12280. }
  12281. if m.id == nil || m.oldValue == nil {
  12282. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12283. }
  12284. oldValue, err := m.oldValue(ctx)
  12285. if err != nil {
  12286. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12287. }
  12288. return oldValue.UpdatedAt, nil
  12289. }
  12290. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12291. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  12292. m.updated_at = nil
  12293. }
  12294. // SetStatus sets the "status" field.
  12295. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  12296. m.status = &u
  12297. m.addstatus = nil
  12298. }
  12299. // Status returns the value of the "status" field in the mutation.
  12300. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  12301. v := m.status
  12302. if v == nil {
  12303. return
  12304. }
  12305. return *v, true
  12306. }
  12307. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  12308. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12310. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12311. if !m.op.Is(OpUpdateOne) {
  12312. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12313. }
  12314. if m.id == nil || m.oldValue == nil {
  12315. return v, errors.New("OldStatus requires an ID field in the mutation")
  12316. }
  12317. oldValue, err := m.oldValue(ctx)
  12318. if err != nil {
  12319. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12320. }
  12321. return oldValue.Status, nil
  12322. }
  12323. // AddStatus adds u to the "status" field.
  12324. func (m *MessageRecordsMutation) AddStatus(u int8) {
  12325. if m.addstatus != nil {
  12326. *m.addstatus += u
  12327. } else {
  12328. m.addstatus = &u
  12329. }
  12330. }
  12331. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12332. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  12333. v := m.addstatus
  12334. if v == nil {
  12335. return
  12336. }
  12337. return *v, true
  12338. }
  12339. // ClearStatus clears the value of the "status" field.
  12340. func (m *MessageRecordsMutation) ClearStatus() {
  12341. m.status = nil
  12342. m.addstatus = nil
  12343. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  12344. }
  12345. // StatusCleared returns if the "status" field was cleared in this mutation.
  12346. func (m *MessageRecordsMutation) StatusCleared() bool {
  12347. _, ok := m.clearedFields[messagerecords.FieldStatus]
  12348. return ok
  12349. }
  12350. // ResetStatus resets all changes to the "status" field.
  12351. func (m *MessageRecordsMutation) ResetStatus() {
  12352. m.status = nil
  12353. m.addstatus = nil
  12354. delete(m.clearedFields, messagerecords.FieldStatus)
  12355. }
  12356. // SetBotWxid sets the "bot_wxid" field.
  12357. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  12358. m.bot_wxid = &s
  12359. }
  12360. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  12361. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  12362. v := m.bot_wxid
  12363. if v == nil {
  12364. return
  12365. }
  12366. return *v, true
  12367. }
  12368. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  12369. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12371. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  12372. if !m.op.Is(OpUpdateOne) {
  12373. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  12374. }
  12375. if m.id == nil || m.oldValue == nil {
  12376. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  12377. }
  12378. oldValue, err := m.oldValue(ctx)
  12379. if err != nil {
  12380. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  12381. }
  12382. return oldValue.BotWxid, nil
  12383. }
  12384. // ResetBotWxid resets all changes to the "bot_wxid" field.
  12385. func (m *MessageRecordsMutation) ResetBotWxid() {
  12386. m.bot_wxid = nil
  12387. }
  12388. // SetContactID sets the "contact_id" field.
  12389. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  12390. m.message_contact = &u
  12391. }
  12392. // ContactID returns the value of the "contact_id" field in the mutation.
  12393. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  12394. v := m.message_contact
  12395. if v == nil {
  12396. return
  12397. }
  12398. return *v, true
  12399. }
  12400. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  12401. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12403. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  12404. if !m.op.Is(OpUpdateOne) {
  12405. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  12406. }
  12407. if m.id == nil || m.oldValue == nil {
  12408. return v, errors.New("OldContactID requires an ID field in the mutation")
  12409. }
  12410. oldValue, err := m.oldValue(ctx)
  12411. if err != nil {
  12412. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  12413. }
  12414. return oldValue.ContactID, nil
  12415. }
  12416. // ClearContactID clears the value of the "contact_id" field.
  12417. func (m *MessageRecordsMutation) ClearContactID() {
  12418. m.message_contact = nil
  12419. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  12420. }
  12421. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  12422. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  12423. _, ok := m.clearedFields[messagerecords.FieldContactID]
  12424. return ok
  12425. }
  12426. // ResetContactID resets all changes to the "contact_id" field.
  12427. func (m *MessageRecordsMutation) ResetContactID() {
  12428. m.message_contact = nil
  12429. delete(m.clearedFields, messagerecords.FieldContactID)
  12430. }
  12431. // SetContactType sets the "contact_type" field.
  12432. func (m *MessageRecordsMutation) SetContactType(i int) {
  12433. m.contact_type = &i
  12434. m.addcontact_type = nil
  12435. }
  12436. // ContactType returns the value of the "contact_type" field in the mutation.
  12437. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  12438. v := m.contact_type
  12439. if v == nil {
  12440. return
  12441. }
  12442. return *v, true
  12443. }
  12444. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  12445. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12447. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  12448. if !m.op.Is(OpUpdateOne) {
  12449. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  12450. }
  12451. if m.id == nil || m.oldValue == nil {
  12452. return v, errors.New("OldContactType requires an ID field in the mutation")
  12453. }
  12454. oldValue, err := m.oldValue(ctx)
  12455. if err != nil {
  12456. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  12457. }
  12458. return oldValue.ContactType, nil
  12459. }
  12460. // AddContactType adds i to the "contact_type" field.
  12461. func (m *MessageRecordsMutation) AddContactType(i int) {
  12462. if m.addcontact_type != nil {
  12463. *m.addcontact_type += i
  12464. } else {
  12465. m.addcontact_type = &i
  12466. }
  12467. }
  12468. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  12469. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  12470. v := m.addcontact_type
  12471. if v == nil {
  12472. return
  12473. }
  12474. return *v, true
  12475. }
  12476. // ResetContactType resets all changes to the "contact_type" field.
  12477. func (m *MessageRecordsMutation) ResetContactType() {
  12478. m.contact_type = nil
  12479. m.addcontact_type = nil
  12480. }
  12481. // SetContactWxid sets the "contact_wxid" field.
  12482. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  12483. m.contact_wxid = &s
  12484. }
  12485. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  12486. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  12487. v := m.contact_wxid
  12488. if v == nil {
  12489. return
  12490. }
  12491. return *v, true
  12492. }
  12493. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  12494. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12496. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  12497. if !m.op.Is(OpUpdateOne) {
  12498. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  12499. }
  12500. if m.id == nil || m.oldValue == nil {
  12501. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  12502. }
  12503. oldValue, err := m.oldValue(ctx)
  12504. if err != nil {
  12505. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  12506. }
  12507. return oldValue.ContactWxid, nil
  12508. }
  12509. // ResetContactWxid resets all changes to the "contact_wxid" field.
  12510. func (m *MessageRecordsMutation) ResetContactWxid() {
  12511. m.contact_wxid = nil
  12512. }
  12513. // SetContentType sets the "content_type" field.
  12514. func (m *MessageRecordsMutation) SetContentType(i int) {
  12515. m.content_type = &i
  12516. m.addcontent_type = nil
  12517. }
  12518. // ContentType returns the value of the "content_type" field in the mutation.
  12519. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  12520. v := m.content_type
  12521. if v == nil {
  12522. return
  12523. }
  12524. return *v, true
  12525. }
  12526. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  12527. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12529. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  12530. if !m.op.Is(OpUpdateOne) {
  12531. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  12532. }
  12533. if m.id == nil || m.oldValue == nil {
  12534. return v, errors.New("OldContentType requires an ID field in the mutation")
  12535. }
  12536. oldValue, err := m.oldValue(ctx)
  12537. if err != nil {
  12538. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  12539. }
  12540. return oldValue.ContentType, nil
  12541. }
  12542. // AddContentType adds i to the "content_type" field.
  12543. func (m *MessageRecordsMutation) AddContentType(i int) {
  12544. if m.addcontent_type != nil {
  12545. *m.addcontent_type += i
  12546. } else {
  12547. m.addcontent_type = &i
  12548. }
  12549. }
  12550. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  12551. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  12552. v := m.addcontent_type
  12553. if v == nil {
  12554. return
  12555. }
  12556. return *v, true
  12557. }
  12558. // ResetContentType resets all changes to the "content_type" field.
  12559. func (m *MessageRecordsMutation) ResetContentType() {
  12560. m.content_type = nil
  12561. m.addcontent_type = nil
  12562. }
  12563. // SetContent sets the "content" field.
  12564. func (m *MessageRecordsMutation) SetContent(s string) {
  12565. m.content = &s
  12566. }
  12567. // Content returns the value of the "content" field in the mutation.
  12568. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  12569. v := m.content
  12570. if v == nil {
  12571. return
  12572. }
  12573. return *v, true
  12574. }
  12575. // OldContent returns the old "content" field's value of the MessageRecords entity.
  12576. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12578. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  12579. if !m.op.Is(OpUpdateOne) {
  12580. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  12581. }
  12582. if m.id == nil || m.oldValue == nil {
  12583. return v, errors.New("OldContent requires an ID field in the mutation")
  12584. }
  12585. oldValue, err := m.oldValue(ctx)
  12586. if err != nil {
  12587. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  12588. }
  12589. return oldValue.Content, nil
  12590. }
  12591. // ResetContent resets all changes to the "content" field.
  12592. func (m *MessageRecordsMutation) ResetContent() {
  12593. m.content = nil
  12594. }
  12595. // SetMeta sets the "meta" field.
  12596. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  12597. m.meta = &ct
  12598. }
  12599. // Meta returns the value of the "meta" field in the mutation.
  12600. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  12601. v := m.meta
  12602. if v == nil {
  12603. return
  12604. }
  12605. return *v, true
  12606. }
  12607. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  12608. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12610. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  12611. if !m.op.Is(OpUpdateOne) {
  12612. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  12613. }
  12614. if m.id == nil || m.oldValue == nil {
  12615. return v, errors.New("OldMeta requires an ID field in the mutation")
  12616. }
  12617. oldValue, err := m.oldValue(ctx)
  12618. if err != nil {
  12619. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  12620. }
  12621. return oldValue.Meta, nil
  12622. }
  12623. // ClearMeta clears the value of the "meta" field.
  12624. func (m *MessageRecordsMutation) ClearMeta() {
  12625. m.meta = nil
  12626. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  12627. }
  12628. // MetaCleared returns if the "meta" field was cleared in this mutation.
  12629. func (m *MessageRecordsMutation) MetaCleared() bool {
  12630. _, ok := m.clearedFields[messagerecords.FieldMeta]
  12631. return ok
  12632. }
  12633. // ResetMeta resets all changes to the "meta" field.
  12634. func (m *MessageRecordsMutation) ResetMeta() {
  12635. m.meta = nil
  12636. delete(m.clearedFields, messagerecords.FieldMeta)
  12637. }
  12638. // SetErrorDetail sets the "error_detail" field.
  12639. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  12640. m.error_detail = &s
  12641. }
  12642. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  12643. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  12644. v := m.error_detail
  12645. if v == nil {
  12646. return
  12647. }
  12648. return *v, true
  12649. }
  12650. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  12651. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12653. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  12654. if !m.op.Is(OpUpdateOne) {
  12655. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  12656. }
  12657. if m.id == nil || m.oldValue == nil {
  12658. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  12659. }
  12660. oldValue, err := m.oldValue(ctx)
  12661. if err != nil {
  12662. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  12663. }
  12664. return oldValue.ErrorDetail, nil
  12665. }
  12666. // ResetErrorDetail resets all changes to the "error_detail" field.
  12667. func (m *MessageRecordsMutation) ResetErrorDetail() {
  12668. m.error_detail = nil
  12669. }
  12670. // SetSendTime sets the "send_time" field.
  12671. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  12672. m.send_time = &t
  12673. }
  12674. // SendTime returns the value of the "send_time" field in the mutation.
  12675. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  12676. v := m.send_time
  12677. if v == nil {
  12678. return
  12679. }
  12680. return *v, true
  12681. }
  12682. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  12683. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12685. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  12686. if !m.op.Is(OpUpdateOne) {
  12687. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  12688. }
  12689. if m.id == nil || m.oldValue == nil {
  12690. return v, errors.New("OldSendTime requires an ID field in the mutation")
  12691. }
  12692. oldValue, err := m.oldValue(ctx)
  12693. if err != nil {
  12694. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  12695. }
  12696. return oldValue.SendTime, nil
  12697. }
  12698. // ClearSendTime clears the value of the "send_time" field.
  12699. func (m *MessageRecordsMutation) ClearSendTime() {
  12700. m.send_time = nil
  12701. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  12702. }
  12703. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  12704. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  12705. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  12706. return ok
  12707. }
  12708. // ResetSendTime resets all changes to the "send_time" field.
  12709. func (m *MessageRecordsMutation) ResetSendTime() {
  12710. m.send_time = nil
  12711. delete(m.clearedFields, messagerecords.FieldSendTime)
  12712. }
  12713. // SetSourceType sets the "source_type" field.
  12714. func (m *MessageRecordsMutation) SetSourceType(i int) {
  12715. m.source_type = &i
  12716. m.addsource_type = nil
  12717. }
  12718. // SourceType returns the value of the "source_type" field in the mutation.
  12719. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  12720. v := m.source_type
  12721. if v == nil {
  12722. return
  12723. }
  12724. return *v, true
  12725. }
  12726. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  12727. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12729. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  12730. if !m.op.Is(OpUpdateOne) {
  12731. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  12732. }
  12733. if m.id == nil || m.oldValue == nil {
  12734. return v, errors.New("OldSourceType requires an ID field in the mutation")
  12735. }
  12736. oldValue, err := m.oldValue(ctx)
  12737. if err != nil {
  12738. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  12739. }
  12740. return oldValue.SourceType, nil
  12741. }
  12742. // AddSourceType adds i to the "source_type" field.
  12743. func (m *MessageRecordsMutation) AddSourceType(i int) {
  12744. if m.addsource_type != nil {
  12745. *m.addsource_type += i
  12746. } else {
  12747. m.addsource_type = &i
  12748. }
  12749. }
  12750. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  12751. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  12752. v := m.addsource_type
  12753. if v == nil {
  12754. return
  12755. }
  12756. return *v, true
  12757. }
  12758. // ResetSourceType resets all changes to the "source_type" field.
  12759. func (m *MessageRecordsMutation) ResetSourceType() {
  12760. m.source_type = nil
  12761. m.addsource_type = nil
  12762. }
  12763. // SetSourceID sets the "source_id" field.
  12764. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  12765. m.sop_stage = &u
  12766. }
  12767. // SourceID returns the value of the "source_id" field in the mutation.
  12768. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  12769. v := m.sop_stage
  12770. if v == nil {
  12771. return
  12772. }
  12773. return *v, true
  12774. }
  12775. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  12776. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12778. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  12779. if !m.op.Is(OpUpdateOne) {
  12780. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  12781. }
  12782. if m.id == nil || m.oldValue == nil {
  12783. return v, errors.New("OldSourceID requires an ID field in the mutation")
  12784. }
  12785. oldValue, err := m.oldValue(ctx)
  12786. if err != nil {
  12787. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  12788. }
  12789. return oldValue.SourceID, nil
  12790. }
  12791. // ClearSourceID clears the value of the "source_id" field.
  12792. func (m *MessageRecordsMutation) ClearSourceID() {
  12793. m.sop_stage = nil
  12794. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  12795. }
  12796. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  12797. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  12798. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  12799. return ok
  12800. }
  12801. // ResetSourceID resets all changes to the "source_id" field.
  12802. func (m *MessageRecordsMutation) ResetSourceID() {
  12803. m.sop_stage = nil
  12804. delete(m.clearedFields, messagerecords.FieldSourceID)
  12805. }
  12806. // SetSubSourceID sets the "sub_source_id" field.
  12807. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  12808. m.sop_node = &u
  12809. }
  12810. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  12811. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  12812. v := m.sop_node
  12813. if v == nil {
  12814. return
  12815. }
  12816. return *v, true
  12817. }
  12818. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  12819. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12821. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  12822. if !m.op.Is(OpUpdateOne) {
  12823. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  12824. }
  12825. if m.id == nil || m.oldValue == nil {
  12826. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  12827. }
  12828. oldValue, err := m.oldValue(ctx)
  12829. if err != nil {
  12830. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  12831. }
  12832. return oldValue.SubSourceID, nil
  12833. }
  12834. // ClearSubSourceID clears the value of the "sub_source_id" field.
  12835. func (m *MessageRecordsMutation) ClearSubSourceID() {
  12836. m.sop_node = nil
  12837. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  12838. }
  12839. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  12840. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  12841. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  12842. return ok
  12843. }
  12844. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  12845. func (m *MessageRecordsMutation) ResetSubSourceID() {
  12846. m.sop_node = nil
  12847. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  12848. }
  12849. // SetOrganizationID sets the "organization_id" field.
  12850. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  12851. m.organization_id = &u
  12852. m.addorganization_id = nil
  12853. }
  12854. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12855. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  12856. v := m.organization_id
  12857. if v == nil {
  12858. return
  12859. }
  12860. return *v, true
  12861. }
  12862. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  12863. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12865. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12866. if !m.op.Is(OpUpdateOne) {
  12867. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12868. }
  12869. if m.id == nil || m.oldValue == nil {
  12870. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12871. }
  12872. oldValue, err := m.oldValue(ctx)
  12873. if err != nil {
  12874. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12875. }
  12876. return oldValue.OrganizationID, nil
  12877. }
  12878. // AddOrganizationID adds u to the "organization_id" field.
  12879. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  12880. if m.addorganization_id != nil {
  12881. *m.addorganization_id += u
  12882. } else {
  12883. m.addorganization_id = &u
  12884. }
  12885. }
  12886. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12887. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  12888. v := m.addorganization_id
  12889. if v == nil {
  12890. return
  12891. }
  12892. return *v, true
  12893. }
  12894. // ClearOrganizationID clears the value of the "organization_id" field.
  12895. func (m *MessageRecordsMutation) ClearOrganizationID() {
  12896. m.organization_id = nil
  12897. m.addorganization_id = nil
  12898. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  12899. }
  12900. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12901. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  12902. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  12903. return ok
  12904. }
  12905. // ResetOrganizationID resets all changes to the "organization_id" field.
  12906. func (m *MessageRecordsMutation) ResetOrganizationID() {
  12907. m.organization_id = nil
  12908. m.addorganization_id = nil
  12909. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  12910. }
  12911. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  12912. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  12913. m.sop_stage = &id
  12914. }
  12915. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  12916. func (m *MessageRecordsMutation) ClearSopStage() {
  12917. m.clearedsop_stage = true
  12918. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  12919. }
  12920. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  12921. func (m *MessageRecordsMutation) SopStageCleared() bool {
  12922. return m.SourceIDCleared() || m.clearedsop_stage
  12923. }
  12924. // SopStageID returns the "sop_stage" edge ID in the mutation.
  12925. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  12926. if m.sop_stage != nil {
  12927. return *m.sop_stage, true
  12928. }
  12929. return
  12930. }
  12931. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  12932. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12933. // SopStageID instead. It exists only for internal usage by the builders.
  12934. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  12935. if id := m.sop_stage; id != nil {
  12936. ids = append(ids, *id)
  12937. }
  12938. return
  12939. }
  12940. // ResetSopStage resets all changes to the "sop_stage" edge.
  12941. func (m *MessageRecordsMutation) ResetSopStage() {
  12942. m.sop_stage = nil
  12943. m.clearedsop_stage = false
  12944. }
  12945. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  12946. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  12947. m.sop_node = &id
  12948. }
  12949. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  12950. func (m *MessageRecordsMutation) ClearSopNode() {
  12951. m.clearedsop_node = true
  12952. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  12953. }
  12954. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  12955. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  12956. return m.SubSourceIDCleared() || m.clearedsop_node
  12957. }
  12958. // SopNodeID returns the "sop_node" edge ID in the mutation.
  12959. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  12960. if m.sop_node != nil {
  12961. return *m.sop_node, true
  12962. }
  12963. return
  12964. }
  12965. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  12966. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12967. // SopNodeID instead. It exists only for internal usage by the builders.
  12968. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  12969. if id := m.sop_node; id != nil {
  12970. ids = append(ids, *id)
  12971. }
  12972. return
  12973. }
  12974. // ResetSopNode resets all changes to the "sop_node" edge.
  12975. func (m *MessageRecordsMutation) ResetSopNode() {
  12976. m.sop_node = nil
  12977. m.clearedsop_node = false
  12978. }
  12979. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  12980. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  12981. m.message_contact = &id
  12982. }
  12983. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  12984. func (m *MessageRecordsMutation) ClearMessageContact() {
  12985. m.clearedmessage_contact = true
  12986. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  12987. }
  12988. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  12989. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  12990. return m.ContactIDCleared() || m.clearedmessage_contact
  12991. }
  12992. // MessageContactID returns the "message_contact" edge ID in the mutation.
  12993. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  12994. if m.message_contact != nil {
  12995. return *m.message_contact, true
  12996. }
  12997. return
  12998. }
  12999. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  13000. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13001. // MessageContactID instead. It exists only for internal usage by the builders.
  13002. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  13003. if id := m.message_contact; id != nil {
  13004. ids = append(ids, *id)
  13005. }
  13006. return
  13007. }
  13008. // ResetMessageContact resets all changes to the "message_contact" edge.
  13009. func (m *MessageRecordsMutation) ResetMessageContact() {
  13010. m.message_contact = nil
  13011. m.clearedmessage_contact = false
  13012. }
  13013. // Where appends a list predicates to the MessageRecordsMutation builder.
  13014. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  13015. m.predicates = append(m.predicates, ps...)
  13016. }
  13017. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  13018. // users can use type-assertion to append predicates that do not depend on any generated package.
  13019. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  13020. p := make([]predicate.MessageRecords, len(ps))
  13021. for i := range ps {
  13022. p[i] = ps[i]
  13023. }
  13024. m.Where(p...)
  13025. }
  13026. // Op returns the operation name.
  13027. func (m *MessageRecordsMutation) Op() Op {
  13028. return m.op
  13029. }
  13030. // SetOp allows setting the mutation operation.
  13031. func (m *MessageRecordsMutation) SetOp(op Op) {
  13032. m.op = op
  13033. }
  13034. // Type returns the node type of this mutation (MessageRecords).
  13035. func (m *MessageRecordsMutation) Type() string {
  13036. return m.typ
  13037. }
  13038. // Fields returns all fields that were changed during this mutation. Note that in
  13039. // order to get all numeric fields that were incremented/decremented, call
  13040. // AddedFields().
  13041. func (m *MessageRecordsMutation) Fields() []string {
  13042. fields := make([]string, 0, 16)
  13043. if m.created_at != nil {
  13044. fields = append(fields, messagerecords.FieldCreatedAt)
  13045. }
  13046. if m.updated_at != nil {
  13047. fields = append(fields, messagerecords.FieldUpdatedAt)
  13048. }
  13049. if m.status != nil {
  13050. fields = append(fields, messagerecords.FieldStatus)
  13051. }
  13052. if m.bot_wxid != nil {
  13053. fields = append(fields, messagerecords.FieldBotWxid)
  13054. }
  13055. if m.message_contact != nil {
  13056. fields = append(fields, messagerecords.FieldContactID)
  13057. }
  13058. if m.contact_type != nil {
  13059. fields = append(fields, messagerecords.FieldContactType)
  13060. }
  13061. if m.contact_wxid != nil {
  13062. fields = append(fields, messagerecords.FieldContactWxid)
  13063. }
  13064. if m.content_type != nil {
  13065. fields = append(fields, messagerecords.FieldContentType)
  13066. }
  13067. if m.content != nil {
  13068. fields = append(fields, messagerecords.FieldContent)
  13069. }
  13070. if m.meta != nil {
  13071. fields = append(fields, messagerecords.FieldMeta)
  13072. }
  13073. if m.error_detail != nil {
  13074. fields = append(fields, messagerecords.FieldErrorDetail)
  13075. }
  13076. if m.send_time != nil {
  13077. fields = append(fields, messagerecords.FieldSendTime)
  13078. }
  13079. if m.source_type != nil {
  13080. fields = append(fields, messagerecords.FieldSourceType)
  13081. }
  13082. if m.sop_stage != nil {
  13083. fields = append(fields, messagerecords.FieldSourceID)
  13084. }
  13085. if m.sop_node != nil {
  13086. fields = append(fields, messagerecords.FieldSubSourceID)
  13087. }
  13088. if m.organization_id != nil {
  13089. fields = append(fields, messagerecords.FieldOrganizationID)
  13090. }
  13091. return fields
  13092. }
  13093. // Field returns the value of a field with the given name. The second boolean
  13094. // return value indicates that this field was not set, or was not defined in the
  13095. // schema.
  13096. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  13097. switch name {
  13098. case messagerecords.FieldCreatedAt:
  13099. return m.CreatedAt()
  13100. case messagerecords.FieldUpdatedAt:
  13101. return m.UpdatedAt()
  13102. case messagerecords.FieldStatus:
  13103. return m.Status()
  13104. case messagerecords.FieldBotWxid:
  13105. return m.BotWxid()
  13106. case messagerecords.FieldContactID:
  13107. return m.ContactID()
  13108. case messagerecords.FieldContactType:
  13109. return m.ContactType()
  13110. case messagerecords.FieldContactWxid:
  13111. return m.ContactWxid()
  13112. case messagerecords.FieldContentType:
  13113. return m.ContentType()
  13114. case messagerecords.FieldContent:
  13115. return m.Content()
  13116. case messagerecords.FieldMeta:
  13117. return m.Meta()
  13118. case messagerecords.FieldErrorDetail:
  13119. return m.ErrorDetail()
  13120. case messagerecords.FieldSendTime:
  13121. return m.SendTime()
  13122. case messagerecords.FieldSourceType:
  13123. return m.SourceType()
  13124. case messagerecords.FieldSourceID:
  13125. return m.SourceID()
  13126. case messagerecords.FieldSubSourceID:
  13127. return m.SubSourceID()
  13128. case messagerecords.FieldOrganizationID:
  13129. return m.OrganizationID()
  13130. }
  13131. return nil, false
  13132. }
  13133. // OldField returns the old value of the field from the database. An error is
  13134. // returned if the mutation operation is not UpdateOne, or the query to the
  13135. // database failed.
  13136. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13137. switch name {
  13138. case messagerecords.FieldCreatedAt:
  13139. return m.OldCreatedAt(ctx)
  13140. case messagerecords.FieldUpdatedAt:
  13141. return m.OldUpdatedAt(ctx)
  13142. case messagerecords.FieldStatus:
  13143. return m.OldStatus(ctx)
  13144. case messagerecords.FieldBotWxid:
  13145. return m.OldBotWxid(ctx)
  13146. case messagerecords.FieldContactID:
  13147. return m.OldContactID(ctx)
  13148. case messagerecords.FieldContactType:
  13149. return m.OldContactType(ctx)
  13150. case messagerecords.FieldContactWxid:
  13151. return m.OldContactWxid(ctx)
  13152. case messagerecords.FieldContentType:
  13153. return m.OldContentType(ctx)
  13154. case messagerecords.FieldContent:
  13155. return m.OldContent(ctx)
  13156. case messagerecords.FieldMeta:
  13157. return m.OldMeta(ctx)
  13158. case messagerecords.FieldErrorDetail:
  13159. return m.OldErrorDetail(ctx)
  13160. case messagerecords.FieldSendTime:
  13161. return m.OldSendTime(ctx)
  13162. case messagerecords.FieldSourceType:
  13163. return m.OldSourceType(ctx)
  13164. case messagerecords.FieldSourceID:
  13165. return m.OldSourceID(ctx)
  13166. case messagerecords.FieldSubSourceID:
  13167. return m.OldSubSourceID(ctx)
  13168. case messagerecords.FieldOrganizationID:
  13169. return m.OldOrganizationID(ctx)
  13170. }
  13171. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  13172. }
  13173. // SetField sets the value of a field with the given name. It returns an error if
  13174. // the field is not defined in the schema, or if the type mismatched the field
  13175. // type.
  13176. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  13177. switch name {
  13178. case messagerecords.FieldCreatedAt:
  13179. v, ok := value.(time.Time)
  13180. if !ok {
  13181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13182. }
  13183. m.SetCreatedAt(v)
  13184. return nil
  13185. case messagerecords.FieldUpdatedAt:
  13186. v, ok := value.(time.Time)
  13187. if !ok {
  13188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13189. }
  13190. m.SetUpdatedAt(v)
  13191. return nil
  13192. case messagerecords.FieldStatus:
  13193. v, ok := value.(uint8)
  13194. if !ok {
  13195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13196. }
  13197. m.SetStatus(v)
  13198. return nil
  13199. case messagerecords.FieldBotWxid:
  13200. v, ok := value.(string)
  13201. if !ok {
  13202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13203. }
  13204. m.SetBotWxid(v)
  13205. return nil
  13206. case messagerecords.FieldContactID:
  13207. v, ok := value.(uint64)
  13208. if !ok {
  13209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13210. }
  13211. m.SetContactID(v)
  13212. return nil
  13213. case messagerecords.FieldContactType:
  13214. v, ok := value.(int)
  13215. if !ok {
  13216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13217. }
  13218. m.SetContactType(v)
  13219. return nil
  13220. case messagerecords.FieldContactWxid:
  13221. v, ok := value.(string)
  13222. if !ok {
  13223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13224. }
  13225. m.SetContactWxid(v)
  13226. return nil
  13227. case messagerecords.FieldContentType:
  13228. v, ok := value.(int)
  13229. if !ok {
  13230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13231. }
  13232. m.SetContentType(v)
  13233. return nil
  13234. case messagerecords.FieldContent:
  13235. v, ok := value.(string)
  13236. if !ok {
  13237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13238. }
  13239. m.SetContent(v)
  13240. return nil
  13241. case messagerecords.FieldMeta:
  13242. v, ok := value.(custom_types.Meta)
  13243. if !ok {
  13244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13245. }
  13246. m.SetMeta(v)
  13247. return nil
  13248. case messagerecords.FieldErrorDetail:
  13249. v, ok := value.(string)
  13250. if !ok {
  13251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13252. }
  13253. m.SetErrorDetail(v)
  13254. return nil
  13255. case messagerecords.FieldSendTime:
  13256. v, ok := value.(time.Time)
  13257. if !ok {
  13258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13259. }
  13260. m.SetSendTime(v)
  13261. return nil
  13262. case messagerecords.FieldSourceType:
  13263. v, ok := value.(int)
  13264. if !ok {
  13265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13266. }
  13267. m.SetSourceType(v)
  13268. return nil
  13269. case messagerecords.FieldSourceID:
  13270. v, ok := value.(uint64)
  13271. if !ok {
  13272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13273. }
  13274. m.SetSourceID(v)
  13275. return nil
  13276. case messagerecords.FieldSubSourceID:
  13277. v, ok := value.(uint64)
  13278. if !ok {
  13279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13280. }
  13281. m.SetSubSourceID(v)
  13282. return nil
  13283. case messagerecords.FieldOrganizationID:
  13284. v, ok := value.(uint64)
  13285. if !ok {
  13286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13287. }
  13288. m.SetOrganizationID(v)
  13289. return nil
  13290. }
  13291. return fmt.Errorf("unknown MessageRecords field %s", name)
  13292. }
  13293. // AddedFields returns all numeric fields that were incremented/decremented during
  13294. // this mutation.
  13295. func (m *MessageRecordsMutation) AddedFields() []string {
  13296. var fields []string
  13297. if m.addstatus != nil {
  13298. fields = append(fields, messagerecords.FieldStatus)
  13299. }
  13300. if m.addcontact_type != nil {
  13301. fields = append(fields, messagerecords.FieldContactType)
  13302. }
  13303. if m.addcontent_type != nil {
  13304. fields = append(fields, messagerecords.FieldContentType)
  13305. }
  13306. if m.addsource_type != nil {
  13307. fields = append(fields, messagerecords.FieldSourceType)
  13308. }
  13309. if m.addorganization_id != nil {
  13310. fields = append(fields, messagerecords.FieldOrganizationID)
  13311. }
  13312. return fields
  13313. }
  13314. // AddedField returns the numeric value that was incremented/decremented on a field
  13315. // with the given name. The second boolean return value indicates that this field
  13316. // was not set, or was not defined in the schema.
  13317. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  13318. switch name {
  13319. case messagerecords.FieldStatus:
  13320. return m.AddedStatus()
  13321. case messagerecords.FieldContactType:
  13322. return m.AddedContactType()
  13323. case messagerecords.FieldContentType:
  13324. return m.AddedContentType()
  13325. case messagerecords.FieldSourceType:
  13326. return m.AddedSourceType()
  13327. case messagerecords.FieldOrganizationID:
  13328. return m.AddedOrganizationID()
  13329. }
  13330. return nil, false
  13331. }
  13332. // AddField adds the value to the field with the given name. It returns an error if
  13333. // the field is not defined in the schema, or if the type mismatched the field
  13334. // type.
  13335. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  13336. switch name {
  13337. case messagerecords.FieldStatus:
  13338. v, ok := value.(int8)
  13339. if !ok {
  13340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13341. }
  13342. m.AddStatus(v)
  13343. return nil
  13344. case messagerecords.FieldContactType:
  13345. v, ok := value.(int)
  13346. if !ok {
  13347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13348. }
  13349. m.AddContactType(v)
  13350. return nil
  13351. case messagerecords.FieldContentType:
  13352. v, ok := value.(int)
  13353. if !ok {
  13354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13355. }
  13356. m.AddContentType(v)
  13357. return nil
  13358. case messagerecords.FieldSourceType:
  13359. v, ok := value.(int)
  13360. if !ok {
  13361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13362. }
  13363. m.AddSourceType(v)
  13364. return nil
  13365. case messagerecords.FieldOrganizationID:
  13366. v, ok := value.(int64)
  13367. if !ok {
  13368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13369. }
  13370. m.AddOrganizationID(v)
  13371. return nil
  13372. }
  13373. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  13374. }
  13375. // ClearedFields returns all nullable fields that were cleared during this
  13376. // mutation.
  13377. func (m *MessageRecordsMutation) ClearedFields() []string {
  13378. var fields []string
  13379. if m.FieldCleared(messagerecords.FieldStatus) {
  13380. fields = append(fields, messagerecords.FieldStatus)
  13381. }
  13382. if m.FieldCleared(messagerecords.FieldContactID) {
  13383. fields = append(fields, messagerecords.FieldContactID)
  13384. }
  13385. if m.FieldCleared(messagerecords.FieldMeta) {
  13386. fields = append(fields, messagerecords.FieldMeta)
  13387. }
  13388. if m.FieldCleared(messagerecords.FieldSendTime) {
  13389. fields = append(fields, messagerecords.FieldSendTime)
  13390. }
  13391. if m.FieldCleared(messagerecords.FieldSourceID) {
  13392. fields = append(fields, messagerecords.FieldSourceID)
  13393. }
  13394. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  13395. fields = append(fields, messagerecords.FieldSubSourceID)
  13396. }
  13397. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  13398. fields = append(fields, messagerecords.FieldOrganizationID)
  13399. }
  13400. return fields
  13401. }
  13402. // FieldCleared returns a boolean indicating if a field with the given name was
  13403. // cleared in this mutation.
  13404. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  13405. _, ok := m.clearedFields[name]
  13406. return ok
  13407. }
  13408. // ClearField clears the value of the field with the given name. It returns an
  13409. // error if the field is not defined in the schema.
  13410. func (m *MessageRecordsMutation) ClearField(name string) error {
  13411. switch name {
  13412. case messagerecords.FieldStatus:
  13413. m.ClearStatus()
  13414. return nil
  13415. case messagerecords.FieldContactID:
  13416. m.ClearContactID()
  13417. return nil
  13418. case messagerecords.FieldMeta:
  13419. m.ClearMeta()
  13420. return nil
  13421. case messagerecords.FieldSendTime:
  13422. m.ClearSendTime()
  13423. return nil
  13424. case messagerecords.FieldSourceID:
  13425. m.ClearSourceID()
  13426. return nil
  13427. case messagerecords.FieldSubSourceID:
  13428. m.ClearSubSourceID()
  13429. return nil
  13430. case messagerecords.FieldOrganizationID:
  13431. m.ClearOrganizationID()
  13432. return nil
  13433. }
  13434. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  13435. }
  13436. // ResetField resets all changes in the mutation for the field with the given name.
  13437. // It returns an error if the field is not defined in the schema.
  13438. func (m *MessageRecordsMutation) ResetField(name string) error {
  13439. switch name {
  13440. case messagerecords.FieldCreatedAt:
  13441. m.ResetCreatedAt()
  13442. return nil
  13443. case messagerecords.FieldUpdatedAt:
  13444. m.ResetUpdatedAt()
  13445. return nil
  13446. case messagerecords.FieldStatus:
  13447. m.ResetStatus()
  13448. return nil
  13449. case messagerecords.FieldBotWxid:
  13450. m.ResetBotWxid()
  13451. return nil
  13452. case messagerecords.FieldContactID:
  13453. m.ResetContactID()
  13454. return nil
  13455. case messagerecords.FieldContactType:
  13456. m.ResetContactType()
  13457. return nil
  13458. case messagerecords.FieldContactWxid:
  13459. m.ResetContactWxid()
  13460. return nil
  13461. case messagerecords.FieldContentType:
  13462. m.ResetContentType()
  13463. return nil
  13464. case messagerecords.FieldContent:
  13465. m.ResetContent()
  13466. return nil
  13467. case messagerecords.FieldMeta:
  13468. m.ResetMeta()
  13469. return nil
  13470. case messagerecords.FieldErrorDetail:
  13471. m.ResetErrorDetail()
  13472. return nil
  13473. case messagerecords.FieldSendTime:
  13474. m.ResetSendTime()
  13475. return nil
  13476. case messagerecords.FieldSourceType:
  13477. m.ResetSourceType()
  13478. return nil
  13479. case messagerecords.FieldSourceID:
  13480. m.ResetSourceID()
  13481. return nil
  13482. case messagerecords.FieldSubSourceID:
  13483. m.ResetSubSourceID()
  13484. return nil
  13485. case messagerecords.FieldOrganizationID:
  13486. m.ResetOrganizationID()
  13487. return nil
  13488. }
  13489. return fmt.Errorf("unknown MessageRecords field %s", name)
  13490. }
  13491. // AddedEdges returns all edge names that were set/added in this mutation.
  13492. func (m *MessageRecordsMutation) AddedEdges() []string {
  13493. edges := make([]string, 0, 3)
  13494. if m.sop_stage != nil {
  13495. edges = append(edges, messagerecords.EdgeSopStage)
  13496. }
  13497. if m.sop_node != nil {
  13498. edges = append(edges, messagerecords.EdgeSopNode)
  13499. }
  13500. if m.message_contact != nil {
  13501. edges = append(edges, messagerecords.EdgeMessageContact)
  13502. }
  13503. return edges
  13504. }
  13505. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13506. // name in this mutation.
  13507. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  13508. switch name {
  13509. case messagerecords.EdgeSopStage:
  13510. if id := m.sop_stage; id != nil {
  13511. return []ent.Value{*id}
  13512. }
  13513. case messagerecords.EdgeSopNode:
  13514. if id := m.sop_node; id != nil {
  13515. return []ent.Value{*id}
  13516. }
  13517. case messagerecords.EdgeMessageContact:
  13518. if id := m.message_contact; id != nil {
  13519. return []ent.Value{*id}
  13520. }
  13521. }
  13522. return nil
  13523. }
  13524. // RemovedEdges returns all edge names that were removed in this mutation.
  13525. func (m *MessageRecordsMutation) RemovedEdges() []string {
  13526. edges := make([]string, 0, 3)
  13527. return edges
  13528. }
  13529. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13530. // the given name in this mutation.
  13531. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  13532. return nil
  13533. }
  13534. // ClearedEdges returns all edge names that were cleared in this mutation.
  13535. func (m *MessageRecordsMutation) ClearedEdges() []string {
  13536. edges := make([]string, 0, 3)
  13537. if m.clearedsop_stage {
  13538. edges = append(edges, messagerecords.EdgeSopStage)
  13539. }
  13540. if m.clearedsop_node {
  13541. edges = append(edges, messagerecords.EdgeSopNode)
  13542. }
  13543. if m.clearedmessage_contact {
  13544. edges = append(edges, messagerecords.EdgeMessageContact)
  13545. }
  13546. return edges
  13547. }
  13548. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13549. // was cleared in this mutation.
  13550. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  13551. switch name {
  13552. case messagerecords.EdgeSopStage:
  13553. return m.clearedsop_stage
  13554. case messagerecords.EdgeSopNode:
  13555. return m.clearedsop_node
  13556. case messagerecords.EdgeMessageContact:
  13557. return m.clearedmessage_contact
  13558. }
  13559. return false
  13560. }
  13561. // ClearEdge clears the value of the edge with the given name. It returns an error
  13562. // if that edge is not defined in the schema.
  13563. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  13564. switch name {
  13565. case messagerecords.EdgeSopStage:
  13566. m.ClearSopStage()
  13567. return nil
  13568. case messagerecords.EdgeSopNode:
  13569. m.ClearSopNode()
  13570. return nil
  13571. case messagerecords.EdgeMessageContact:
  13572. m.ClearMessageContact()
  13573. return nil
  13574. }
  13575. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  13576. }
  13577. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13578. // It returns an error if the edge is not defined in the schema.
  13579. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  13580. switch name {
  13581. case messagerecords.EdgeSopStage:
  13582. m.ResetSopStage()
  13583. return nil
  13584. case messagerecords.EdgeSopNode:
  13585. m.ResetSopNode()
  13586. return nil
  13587. case messagerecords.EdgeMessageContact:
  13588. m.ResetMessageContact()
  13589. return nil
  13590. }
  13591. return fmt.Errorf("unknown MessageRecords edge %s", name)
  13592. }
  13593. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  13594. type MsgMutation struct {
  13595. config
  13596. op Op
  13597. typ string
  13598. id *uint64
  13599. created_at *time.Time
  13600. updated_at *time.Time
  13601. deleted_at *time.Time
  13602. status *uint8
  13603. addstatus *int8
  13604. fromwxid *string
  13605. toid *string
  13606. msgtype *int32
  13607. addmsgtype *int32
  13608. msg *string
  13609. batch_no *string
  13610. clearedFields map[string]struct{}
  13611. done bool
  13612. oldValue func(context.Context) (*Msg, error)
  13613. predicates []predicate.Msg
  13614. }
  13615. var _ ent.Mutation = (*MsgMutation)(nil)
  13616. // msgOption allows management of the mutation configuration using functional options.
  13617. type msgOption func(*MsgMutation)
  13618. // newMsgMutation creates new mutation for the Msg entity.
  13619. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  13620. m := &MsgMutation{
  13621. config: c,
  13622. op: op,
  13623. typ: TypeMsg,
  13624. clearedFields: make(map[string]struct{}),
  13625. }
  13626. for _, opt := range opts {
  13627. opt(m)
  13628. }
  13629. return m
  13630. }
  13631. // withMsgID sets the ID field of the mutation.
  13632. func withMsgID(id uint64) msgOption {
  13633. return func(m *MsgMutation) {
  13634. var (
  13635. err error
  13636. once sync.Once
  13637. value *Msg
  13638. )
  13639. m.oldValue = func(ctx context.Context) (*Msg, error) {
  13640. once.Do(func() {
  13641. if m.done {
  13642. err = errors.New("querying old values post mutation is not allowed")
  13643. } else {
  13644. value, err = m.Client().Msg.Get(ctx, id)
  13645. }
  13646. })
  13647. return value, err
  13648. }
  13649. m.id = &id
  13650. }
  13651. }
  13652. // withMsg sets the old Msg of the mutation.
  13653. func withMsg(node *Msg) msgOption {
  13654. return func(m *MsgMutation) {
  13655. m.oldValue = func(context.Context) (*Msg, error) {
  13656. return node, nil
  13657. }
  13658. m.id = &node.ID
  13659. }
  13660. }
  13661. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13662. // executed in a transaction (ent.Tx), a transactional client is returned.
  13663. func (m MsgMutation) Client() *Client {
  13664. client := &Client{config: m.config}
  13665. client.init()
  13666. return client
  13667. }
  13668. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13669. // it returns an error otherwise.
  13670. func (m MsgMutation) Tx() (*Tx, error) {
  13671. if _, ok := m.driver.(*txDriver); !ok {
  13672. return nil, errors.New("ent: mutation is not running in a transaction")
  13673. }
  13674. tx := &Tx{config: m.config}
  13675. tx.init()
  13676. return tx, nil
  13677. }
  13678. // SetID sets the value of the id field. Note that this
  13679. // operation is only accepted on creation of Msg entities.
  13680. func (m *MsgMutation) SetID(id uint64) {
  13681. m.id = &id
  13682. }
  13683. // ID returns the ID value in the mutation. Note that the ID is only available
  13684. // if it was provided to the builder or after it was returned from the database.
  13685. func (m *MsgMutation) ID() (id uint64, exists bool) {
  13686. if m.id == nil {
  13687. return
  13688. }
  13689. return *m.id, true
  13690. }
  13691. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13692. // That means, if the mutation is applied within a transaction with an isolation level such
  13693. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13694. // or updated by the mutation.
  13695. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  13696. switch {
  13697. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13698. id, exists := m.ID()
  13699. if exists {
  13700. return []uint64{id}, nil
  13701. }
  13702. fallthrough
  13703. case m.op.Is(OpUpdate | OpDelete):
  13704. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  13705. default:
  13706. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13707. }
  13708. }
  13709. // SetCreatedAt sets the "created_at" field.
  13710. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  13711. m.created_at = &t
  13712. }
  13713. // CreatedAt returns the value of the "created_at" field in the mutation.
  13714. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  13715. v := m.created_at
  13716. if v == nil {
  13717. return
  13718. }
  13719. return *v, true
  13720. }
  13721. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  13722. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13724. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13725. if !m.op.Is(OpUpdateOne) {
  13726. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13727. }
  13728. if m.id == nil || m.oldValue == nil {
  13729. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13730. }
  13731. oldValue, err := m.oldValue(ctx)
  13732. if err != nil {
  13733. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13734. }
  13735. return oldValue.CreatedAt, nil
  13736. }
  13737. // ResetCreatedAt resets all changes to the "created_at" field.
  13738. func (m *MsgMutation) ResetCreatedAt() {
  13739. m.created_at = nil
  13740. }
  13741. // SetUpdatedAt sets the "updated_at" field.
  13742. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  13743. m.updated_at = &t
  13744. }
  13745. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13746. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  13747. v := m.updated_at
  13748. if v == nil {
  13749. return
  13750. }
  13751. return *v, true
  13752. }
  13753. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  13754. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13756. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13757. if !m.op.Is(OpUpdateOne) {
  13758. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13759. }
  13760. if m.id == nil || m.oldValue == nil {
  13761. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13762. }
  13763. oldValue, err := m.oldValue(ctx)
  13764. if err != nil {
  13765. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13766. }
  13767. return oldValue.UpdatedAt, nil
  13768. }
  13769. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13770. func (m *MsgMutation) ResetUpdatedAt() {
  13771. m.updated_at = nil
  13772. }
  13773. // SetDeletedAt sets the "deleted_at" field.
  13774. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  13775. m.deleted_at = &t
  13776. }
  13777. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13778. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  13779. v := m.deleted_at
  13780. if v == nil {
  13781. return
  13782. }
  13783. return *v, true
  13784. }
  13785. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  13786. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13788. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13789. if !m.op.Is(OpUpdateOne) {
  13790. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13791. }
  13792. if m.id == nil || m.oldValue == nil {
  13793. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13794. }
  13795. oldValue, err := m.oldValue(ctx)
  13796. if err != nil {
  13797. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13798. }
  13799. return oldValue.DeletedAt, nil
  13800. }
  13801. // ClearDeletedAt clears the value of the "deleted_at" field.
  13802. func (m *MsgMutation) ClearDeletedAt() {
  13803. m.deleted_at = nil
  13804. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  13805. }
  13806. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13807. func (m *MsgMutation) DeletedAtCleared() bool {
  13808. _, ok := m.clearedFields[msg.FieldDeletedAt]
  13809. return ok
  13810. }
  13811. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13812. func (m *MsgMutation) ResetDeletedAt() {
  13813. m.deleted_at = nil
  13814. delete(m.clearedFields, msg.FieldDeletedAt)
  13815. }
  13816. // SetStatus sets the "status" field.
  13817. func (m *MsgMutation) SetStatus(u uint8) {
  13818. m.status = &u
  13819. m.addstatus = nil
  13820. }
  13821. // Status returns the value of the "status" field in the mutation.
  13822. func (m *MsgMutation) Status() (r uint8, exists bool) {
  13823. v := m.status
  13824. if v == nil {
  13825. return
  13826. }
  13827. return *v, true
  13828. }
  13829. // OldStatus returns the old "status" field's value of the Msg entity.
  13830. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13832. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13833. if !m.op.Is(OpUpdateOne) {
  13834. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13835. }
  13836. if m.id == nil || m.oldValue == nil {
  13837. return v, errors.New("OldStatus requires an ID field in the mutation")
  13838. }
  13839. oldValue, err := m.oldValue(ctx)
  13840. if err != nil {
  13841. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13842. }
  13843. return oldValue.Status, nil
  13844. }
  13845. // AddStatus adds u to the "status" field.
  13846. func (m *MsgMutation) AddStatus(u int8) {
  13847. if m.addstatus != nil {
  13848. *m.addstatus += u
  13849. } else {
  13850. m.addstatus = &u
  13851. }
  13852. }
  13853. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13854. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  13855. v := m.addstatus
  13856. if v == nil {
  13857. return
  13858. }
  13859. return *v, true
  13860. }
  13861. // ClearStatus clears the value of the "status" field.
  13862. func (m *MsgMutation) ClearStatus() {
  13863. m.status = nil
  13864. m.addstatus = nil
  13865. m.clearedFields[msg.FieldStatus] = struct{}{}
  13866. }
  13867. // StatusCleared returns if the "status" field was cleared in this mutation.
  13868. func (m *MsgMutation) StatusCleared() bool {
  13869. _, ok := m.clearedFields[msg.FieldStatus]
  13870. return ok
  13871. }
  13872. // ResetStatus resets all changes to the "status" field.
  13873. func (m *MsgMutation) ResetStatus() {
  13874. m.status = nil
  13875. m.addstatus = nil
  13876. delete(m.clearedFields, msg.FieldStatus)
  13877. }
  13878. // SetFromwxid sets the "fromwxid" field.
  13879. func (m *MsgMutation) SetFromwxid(s string) {
  13880. m.fromwxid = &s
  13881. }
  13882. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  13883. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  13884. v := m.fromwxid
  13885. if v == nil {
  13886. return
  13887. }
  13888. return *v, true
  13889. }
  13890. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  13891. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13893. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  13894. if !m.op.Is(OpUpdateOne) {
  13895. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  13896. }
  13897. if m.id == nil || m.oldValue == nil {
  13898. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  13899. }
  13900. oldValue, err := m.oldValue(ctx)
  13901. if err != nil {
  13902. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  13903. }
  13904. return oldValue.Fromwxid, nil
  13905. }
  13906. // ClearFromwxid clears the value of the "fromwxid" field.
  13907. func (m *MsgMutation) ClearFromwxid() {
  13908. m.fromwxid = nil
  13909. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  13910. }
  13911. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  13912. func (m *MsgMutation) FromwxidCleared() bool {
  13913. _, ok := m.clearedFields[msg.FieldFromwxid]
  13914. return ok
  13915. }
  13916. // ResetFromwxid resets all changes to the "fromwxid" field.
  13917. func (m *MsgMutation) ResetFromwxid() {
  13918. m.fromwxid = nil
  13919. delete(m.clearedFields, msg.FieldFromwxid)
  13920. }
  13921. // SetToid sets the "toid" field.
  13922. func (m *MsgMutation) SetToid(s string) {
  13923. m.toid = &s
  13924. }
  13925. // Toid returns the value of the "toid" field in the mutation.
  13926. func (m *MsgMutation) Toid() (r string, exists bool) {
  13927. v := m.toid
  13928. if v == nil {
  13929. return
  13930. }
  13931. return *v, true
  13932. }
  13933. // OldToid returns the old "toid" field's value of the Msg entity.
  13934. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13936. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  13937. if !m.op.Is(OpUpdateOne) {
  13938. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  13939. }
  13940. if m.id == nil || m.oldValue == nil {
  13941. return v, errors.New("OldToid requires an ID field in the mutation")
  13942. }
  13943. oldValue, err := m.oldValue(ctx)
  13944. if err != nil {
  13945. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  13946. }
  13947. return oldValue.Toid, nil
  13948. }
  13949. // ClearToid clears the value of the "toid" field.
  13950. func (m *MsgMutation) ClearToid() {
  13951. m.toid = nil
  13952. m.clearedFields[msg.FieldToid] = struct{}{}
  13953. }
  13954. // ToidCleared returns if the "toid" field was cleared in this mutation.
  13955. func (m *MsgMutation) ToidCleared() bool {
  13956. _, ok := m.clearedFields[msg.FieldToid]
  13957. return ok
  13958. }
  13959. // ResetToid resets all changes to the "toid" field.
  13960. func (m *MsgMutation) ResetToid() {
  13961. m.toid = nil
  13962. delete(m.clearedFields, msg.FieldToid)
  13963. }
  13964. // SetMsgtype sets the "msgtype" field.
  13965. func (m *MsgMutation) SetMsgtype(i int32) {
  13966. m.msgtype = &i
  13967. m.addmsgtype = nil
  13968. }
  13969. // Msgtype returns the value of the "msgtype" field in the mutation.
  13970. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  13971. v := m.msgtype
  13972. if v == nil {
  13973. return
  13974. }
  13975. return *v, true
  13976. }
  13977. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  13978. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13980. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  13981. if !m.op.Is(OpUpdateOne) {
  13982. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  13983. }
  13984. if m.id == nil || m.oldValue == nil {
  13985. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  13986. }
  13987. oldValue, err := m.oldValue(ctx)
  13988. if err != nil {
  13989. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  13990. }
  13991. return oldValue.Msgtype, nil
  13992. }
  13993. // AddMsgtype adds i to the "msgtype" field.
  13994. func (m *MsgMutation) AddMsgtype(i int32) {
  13995. if m.addmsgtype != nil {
  13996. *m.addmsgtype += i
  13997. } else {
  13998. m.addmsgtype = &i
  13999. }
  14000. }
  14001. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  14002. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  14003. v := m.addmsgtype
  14004. if v == nil {
  14005. return
  14006. }
  14007. return *v, true
  14008. }
  14009. // ClearMsgtype clears the value of the "msgtype" field.
  14010. func (m *MsgMutation) ClearMsgtype() {
  14011. m.msgtype = nil
  14012. m.addmsgtype = nil
  14013. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  14014. }
  14015. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  14016. func (m *MsgMutation) MsgtypeCleared() bool {
  14017. _, ok := m.clearedFields[msg.FieldMsgtype]
  14018. return ok
  14019. }
  14020. // ResetMsgtype resets all changes to the "msgtype" field.
  14021. func (m *MsgMutation) ResetMsgtype() {
  14022. m.msgtype = nil
  14023. m.addmsgtype = nil
  14024. delete(m.clearedFields, msg.FieldMsgtype)
  14025. }
  14026. // SetMsg sets the "msg" field.
  14027. func (m *MsgMutation) SetMsg(s string) {
  14028. m.msg = &s
  14029. }
  14030. // Msg returns the value of the "msg" field in the mutation.
  14031. func (m *MsgMutation) Msg() (r string, exists bool) {
  14032. v := m.msg
  14033. if v == nil {
  14034. return
  14035. }
  14036. return *v, true
  14037. }
  14038. // OldMsg returns the old "msg" field's value of the Msg entity.
  14039. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14041. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  14042. if !m.op.Is(OpUpdateOne) {
  14043. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  14044. }
  14045. if m.id == nil || m.oldValue == nil {
  14046. return v, errors.New("OldMsg requires an ID field in the mutation")
  14047. }
  14048. oldValue, err := m.oldValue(ctx)
  14049. if err != nil {
  14050. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  14051. }
  14052. return oldValue.Msg, nil
  14053. }
  14054. // ClearMsg clears the value of the "msg" field.
  14055. func (m *MsgMutation) ClearMsg() {
  14056. m.msg = nil
  14057. m.clearedFields[msg.FieldMsg] = struct{}{}
  14058. }
  14059. // MsgCleared returns if the "msg" field was cleared in this mutation.
  14060. func (m *MsgMutation) MsgCleared() bool {
  14061. _, ok := m.clearedFields[msg.FieldMsg]
  14062. return ok
  14063. }
  14064. // ResetMsg resets all changes to the "msg" field.
  14065. func (m *MsgMutation) ResetMsg() {
  14066. m.msg = nil
  14067. delete(m.clearedFields, msg.FieldMsg)
  14068. }
  14069. // SetBatchNo sets the "batch_no" field.
  14070. func (m *MsgMutation) SetBatchNo(s string) {
  14071. m.batch_no = &s
  14072. }
  14073. // BatchNo returns the value of the "batch_no" field in the mutation.
  14074. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  14075. v := m.batch_no
  14076. if v == nil {
  14077. return
  14078. }
  14079. return *v, true
  14080. }
  14081. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  14082. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14084. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  14085. if !m.op.Is(OpUpdateOne) {
  14086. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  14087. }
  14088. if m.id == nil || m.oldValue == nil {
  14089. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  14090. }
  14091. oldValue, err := m.oldValue(ctx)
  14092. if err != nil {
  14093. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  14094. }
  14095. return oldValue.BatchNo, nil
  14096. }
  14097. // ClearBatchNo clears the value of the "batch_no" field.
  14098. func (m *MsgMutation) ClearBatchNo() {
  14099. m.batch_no = nil
  14100. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  14101. }
  14102. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  14103. func (m *MsgMutation) BatchNoCleared() bool {
  14104. _, ok := m.clearedFields[msg.FieldBatchNo]
  14105. return ok
  14106. }
  14107. // ResetBatchNo resets all changes to the "batch_no" field.
  14108. func (m *MsgMutation) ResetBatchNo() {
  14109. m.batch_no = nil
  14110. delete(m.clearedFields, msg.FieldBatchNo)
  14111. }
  14112. // Where appends a list predicates to the MsgMutation builder.
  14113. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  14114. m.predicates = append(m.predicates, ps...)
  14115. }
  14116. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  14117. // users can use type-assertion to append predicates that do not depend on any generated package.
  14118. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  14119. p := make([]predicate.Msg, len(ps))
  14120. for i := range ps {
  14121. p[i] = ps[i]
  14122. }
  14123. m.Where(p...)
  14124. }
  14125. // Op returns the operation name.
  14126. func (m *MsgMutation) Op() Op {
  14127. return m.op
  14128. }
  14129. // SetOp allows setting the mutation operation.
  14130. func (m *MsgMutation) SetOp(op Op) {
  14131. m.op = op
  14132. }
  14133. // Type returns the node type of this mutation (Msg).
  14134. func (m *MsgMutation) Type() string {
  14135. return m.typ
  14136. }
  14137. // Fields returns all fields that were changed during this mutation. Note that in
  14138. // order to get all numeric fields that were incremented/decremented, call
  14139. // AddedFields().
  14140. func (m *MsgMutation) Fields() []string {
  14141. fields := make([]string, 0, 9)
  14142. if m.created_at != nil {
  14143. fields = append(fields, msg.FieldCreatedAt)
  14144. }
  14145. if m.updated_at != nil {
  14146. fields = append(fields, msg.FieldUpdatedAt)
  14147. }
  14148. if m.deleted_at != nil {
  14149. fields = append(fields, msg.FieldDeletedAt)
  14150. }
  14151. if m.status != nil {
  14152. fields = append(fields, msg.FieldStatus)
  14153. }
  14154. if m.fromwxid != nil {
  14155. fields = append(fields, msg.FieldFromwxid)
  14156. }
  14157. if m.toid != nil {
  14158. fields = append(fields, msg.FieldToid)
  14159. }
  14160. if m.msgtype != nil {
  14161. fields = append(fields, msg.FieldMsgtype)
  14162. }
  14163. if m.msg != nil {
  14164. fields = append(fields, msg.FieldMsg)
  14165. }
  14166. if m.batch_no != nil {
  14167. fields = append(fields, msg.FieldBatchNo)
  14168. }
  14169. return fields
  14170. }
  14171. // Field returns the value of a field with the given name. The second boolean
  14172. // return value indicates that this field was not set, or was not defined in the
  14173. // schema.
  14174. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  14175. switch name {
  14176. case msg.FieldCreatedAt:
  14177. return m.CreatedAt()
  14178. case msg.FieldUpdatedAt:
  14179. return m.UpdatedAt()
  14180. case msg.FieldDeletedAt:
  14181. return m.DeletedAt()
  14182. case msg.FieldStatus:
  14183. return m.Status()
  14184. case msg.FieldFromwxid:
  14185. return m.Fromwxid()
  14186. case msg.FieldToid:
  14187. return m.Toid()
  14188. case msg.FieldMsgtype:
  14189. return m.Msgtype()
  14190. case msg.FieldMsg:
  14191. return m.Msg()
  14192. case msg.FieldBatchNo:
  14193. return m.BatchNo()
  14194. }
  14195. return nil, false
  14196. }
  14197. // OldField returns the old value of the field from the database. An error is
  14198. // returned if the mutation operation is not UpdateOne, or the query to the
  14199. // database failed.
  14200. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14201. switch name {
  14202. case msg.FieldCreatedAt:
  14203. return m.OldCreatedAt(ctx)
  14204. case msg.FieldUpdatedAt:
  14205. return m.OldUpdatedAt(ctx)
  14206. case msg.FieldDeletedAt:
  14207. return m.OldDeletedAt(ctx)
  14208. case msg.FieldStatus:
  14209. return m.OldStatus(ctx)
  14210. case msg.FieldFromwxid:
  14211. return m.OldFromwxid(ctx)
  14212. case msg.FieldToid:
  14213. return m.OldToid(ctx)
  14214. case msg.FieldMsgtype:
  14215. return m.OldMsgtype(ctx)
  14216. case msg.FieldMsg:
  14217. return m.OldMsg(ctx)
  14218. case msg.FieldBatchNo:
  14219. return m.OldBatchNo(ctx)
  14220. }
  14221. return nil, fmt.Errorf("unknown Msg field %s", name)
  14222. }
  14223. // SetField sets the value of a field with the given name. It returns an error if
  14224. // the field is not defined in the schema, or if the type mismatched the field
  14225. // type.
  14226. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  14227. switch name {
  14228. case msg.FieldCreatedAt:
  14229. v, ok := value.(time.Time)
  14230. if !ok {
  14231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14232. }
  14233. m.SetCreatedAt(v)
  14234. return nil
  14235. case msg.FieldUpdatedAt:
  14236. v, ok := value.(time.Time)
  14237. if !ok {
  14238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14239. }
  14240. m.SetUpdatedAt(v)
  14241. return nil
  14242. case msg.FieldDeletedAt:
  14243. v, ok := value.(time.Time)
  14244. if !ok {
  14245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14246. }
  14247. m.SetDeletedAt(v)
  14248. return nil
  14249. case msg.FieldStatus:
  14250. v, ok := value.(uint8)
  14251. if !ok {
  14252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14253. }
  14254. m.SetStatus(v)
  14255. return nil
  14256. case msg.FieldFromwxid:
  14257. v, ok := value.(string)
  14258. if !ok {
  14259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14260. }
  14261. m.SetFromwxid(v)
  14262. return nil
  14263. case msg.FieldToid:
  14264. v, ok := value.(string)
  14265. if !ok {
  14266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14267. }
  14268. m.SetToid(v)
  14269. return nil
  14270. case msg.FieldMsgtype:
  14271. v, ok := value.(int32)
  14272. if !ok {
  14273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14274. }
  14275. m.SetMsgtype(v)
  14276. return nil
  14277. case msg.FieldMsg:
  14278. v, ok := value.(string)
  14279. if !ok {
  14280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14281. }
  14282. m.SetMsg(v)
  14283. return nil
  14284. case msg.FieldBatchNo:
  14285. v, ok := value.(string)
  14286. if !ok {
  14287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14288. }
  14289. m.SetBatchNo(v)
  14290. return nil
  14291. }
  14292. return fmt.Errorf("unknown Msg field %s", name)
  14293. }
  14294. // AddedFields returns all numeric fields that were incremented/decremented during
  14295. // this mutation.
  14296. func (m *MsgMutation) AddedFields() []string {
  14297. var fields []string
  14298. if m.addstatus != nil {
  14299. fields = append(fields, msg.FieldStatus)
  14300. }
  14301. if m.addmsgtype != nil {
  14302. fields = append(fields, msg.FieldMsgtype)
  14303. }
  14304. return fields
  14305. }
  14306. // AddedField returns the numeric value that was incremented/decremented on a field
  14307. // with the given name. The second boolean return value indicates that this field
  14308. // was not set, or was not defined in the schema.
  14309. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  14310. switch name {
  14311. case msg.FieldStatus:
  14312. return m.AddedStatus()
  14313. case msg.FieldMsgtype:
  14314. return m.AddedMsgtype()
  14315. }
  14316. return nil, false
  14317. }
  14318. // AddField adds the value to the field with the given name. It returns an error if
  14319. // the field is not defined in the schema, or if the type mismatched the field
  14320. // type.
  14321. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  14322. switch name {
  14323. case msg.FieldStatus:
  14324. v, ok := value.(int8)
  14325. if !ok {
  14326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14327. }
  14328. m.AddStatus(v)
  14329. return nil
  14330. case msg.FieldMsgtype:
  14331. v, ok := value.(int32)
  14332. if !ok {
  14333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14334. }
  14335. m.AddMsgtype(v)
  14336. return nil
  14337. }
  14338. return fmt.Errorf("unknown Msg numeric field %s", name)
  14339. }
  14340. // ClearedFields returns all nullable fields that were cleared during this
  14341. // mutation.
  14342. func (m *MsgMutation) ClearedFields() []string {
  14343. var fields []string
  14344. if m.FieldCleared(msg.FieldDeletedAt) {
  14345. fields = append(fields, msg.FieldDeletedAt)
  14346. }
  14347. if m.FieldCleared(msg.FieldStatus) {
  14348. fields = append(fields, msg.FieldStatus)
  14349. }
  14350. if m.FieldCleared(msg.FieldFromwxid) {
  14351. fields = append(fields, msg.FieldFromwxid)
  14352. }
  14353. if m.FieldCleared(msg.FieldToid) {
  14354. fields = append(fields, msg.FieldToid)
  14355. }
  14356. if m.FieldCleared(msg.FieldMsgtype) {
  14357. fields = append(fields, msg.FieldMsgtype)
  14358. }
  14359. if m.FieldCleared(msg.FieldMsg) {
  14360. fields = append(fields, msg.FieldMsg)
  14361. }
  14362. if m.FieldCleared(msg.FieldBatchNo) {
  14363. fields = append(fields, msg.FieldBatchNo)
  14364. }
  14365. return fields
  14366. }
  14367. // FieldCleared returns a boolean indicating if a field with the given name was
  14368. // cleared in this mutation.
  14369. func (m *MsgMutation) FieldCleared(name string) bool {
  14370. _, ok := m.clearedFields[name]
  14371. return ok
  14372. }
  14373. // ClearField clears the value of the field with the given name. It returns an
  14374. // error if the field is not defined in the schema.
  14375. func (m *MsgMutation) ClearField(name string) error {
  14376. switch name {
  14377. case msg.FieldDeletedAt:
  14378. m.ClearDeletedAt()
  14379. return nil
  14380. case msg.FieldStatus:
  14381. m.ClearStatus()
  14382. return nil
  14383. case msg.FieldFromwxid:
  14384. m.ClearFromwxid()
  14385. return nil
  14386. case msg.FieldToid:
  14387. m.ClearToid()
  14388. return nil
  14389. case msg.FieldMsgtype:
  14390. m.ClearMsgtype()
  14391. return nil
  14392. case msg.FieldMsg:
  14393. m.ClearMsg()
  14394. return nil
  14395. case msg.FieldBatchNo:
  14396. m.ClearBatchNo()
  14397. return nil
  14398. }
  14399. return fmt.Errorf("unknown Msg nullable field %s", name)
  14400. }
  14401. // ResetField resets all changes in the mutation for the field with the given name.
  14402. // It returns an error if the field is not defined in the schema.
  14403. func (m *MsgMutation) ResetField(name string) error {
  14404. switch name {
  14405. case msg.FieldCreatedAt:
  14406. m.ResetCreatedAt()
  14407. return nil
  14408. case msg.FieldUpdatedAt:
  14409. m.ResetUpdatedAt()
  14410. return nil
  14411. case msg.FieldDeletedAt:
  14412. m.ResetDeletedAt()
  14413. return nil
  14414. case msg.FieldStatus:
  14415. m.ResetStatus()
  14416. return nil
  14417. case msg.FieldFromwxid:
  14418. m.ResetFromwxid()
  14419. return nil
  14420. case msg.FieldToid:
  14421. m.ResetToid()
  14422. return nil
  14423. case msg.FieldMsgtype:
  14424. m.ResetMsgtype()
  14425. return nil
  14426. case msg.FieldMsg:
  14427. m.ResetMsg()
  14428. return nil
  14429. case msg.FieldBatchNo:
  14430. m.ResetBatchNo()
  14431. return nil
  14432. }
  14433. return fmt.Errorf("unknown Msg field %s", name)
  14434. }
  14435. // AddedEdges returns all edge names that were set/added in this mutation.
  14436. func (m *MsgMutation) AddedEdges() []string {
  14437. edges := make([]string, 0, 0)
  14438. return edges
  14439. }
  14440. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14441. // name in this mutation.
  14442. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  14443. return nil
  14444. }
  14445. // RemovedEdges returns all edge names that were removed in this mutation.
  14446. func (m *MsgMutation) RemovedEdges() []string {
  14447. edges := make([]string, 0, 0)
  14448. return edges
  14449. }
  14450. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14451. // the given name in this mutation.
  14452. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  14453. return nil
  14454. }
  14455. // ClearedEdges returns all edge names that were cleared in this mutation.
  14456. func (m *MsgMutation) ClearedEdges() []string {
  14457. edges := make([]string, 0, 0)
  14458. return edges
  14459. }
  14460. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14461. // was cleared in this mutation.
  14462. func (m *MsgMutation) EdgeCleared(name string) bool {
  14463. return false
  14464. }
  14465. // ClearEdge clears the value of the edge with the given name. It returns an error
  14466. // if that edge is not defined in the schema.
  14467. func (m *MsgMutation) ClearEdge(name string) error {
  14468. return fmt.Errorf("unknown Msg unique edge %s", name)
  14469. }
  14470. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14471. // It returns an error if the edge is not defined in the schema.
  14472. func (m *MsgMutation) ResetEdge(name string) error {
  14473. return fmt.Errorf("unknown Msg edge %s", name)
  14474. }
  14475. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  14476. type ServerMutation struct {
  14477. config
  14478. op Op
  14479. typ string
  14480. id *uint64
  14481. created_at *time.Time
  14482. updated_at *time.Time
  14483. status *uint8
  14484. addstatus *int8
  14485. deleted_at *time.Time
  14486. name *string
  14487. public_ip *string
  14488. private_ip *string
  14489. admin_port *string
  14490. clearedFields map[string]struct{}
  14491. wxs map[uint64]struct{}
  14492. removedwxs map[uint64]struct{}
  14493. clearedwxs bool
  14494. done bool
  14495. oldValue func(context.Context) (*Server, error)
  14496. predicates []predicate.Server
  14497. }
  14498. var _ ent.Mutation = (*ServerMutation)(nil)
  14499. // serverOption allows management of the mutation configuration using functional options.
  14500. type serverOption func(*ServerMutation)
  14501. // newServerMutation creates new mutation for the Server entity.
  14502. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  14503. m := &ServerMutation{
  14504. config: c,
  14505. op: op,
  14506. typ: TypeServer,
  14507. clearedFields: make(map[string]struct{}),
  14508. }
  14509. for _, opt := range opts {
  14510. opt(m)
  14511. }
  14512. return m
  14513. }
  14514. // withServerID sets the ID field of the mutation.
  14515. func withServerID(id uint64) serverOption {
  14516. return func(m *ServerMutation) {
  14517. var (
  14518. err error
  14519. once sync.Once
  14520. value *Server
  14521. )
  14522. m.oldValue = func(ctx context.Context) (*Server, error) {
  14523. once.Do(func() {
  14524. if m.done {
  14525. err = errors.New("querying old values post mutation is not allowed")
  14526. } else {
  14527. value, err = m.Client().Server.Get(ctx, id)
  14528. }
  14529. })
  14530. return value, err
  14531. }
  14532. m.id = &id
  14533. }
  14534. }
  14535. // withServer sets the old Server of the mutation.
  14536. func withServer(node *Server) serverOption {
  14537. return func(m *ServerMutation) {
  14538. m.oldValue = func(context.Context) (*Server, error) {
  14539. return node, nil
  14540. }
  14541. m.id = &node.ID
  14542. }
  14543. }
  14544. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14545. // executed in a transaction (ent.Tx), a transactional client is returned.
  14546. func (m ServerMutation) Client() *Client {
  14547. client := &Client{config: m.config}
  14548. client.init()
  14549. return client
  14550. }
  14551. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14552. // it returns an error otherwise.
  14553. func (m ServerMutation) Tx() (*Tx, error) {
  14554. if _, ok := m.driver.(*txDriver); !ok {
  14555. return nil, errors.New("ent: mutation is not running in a transaction")
  14556. }
  14557. tx := &Tx{config: m.config}
  14558. tx.init()
  14559. return tx, nil
  14560. }
  14561. // SetID sets the value of the id field. Note that this
  14562. // operation is only accepted on creation of Server entities.
  14563. func (m *ServerMutation) SetID(id uint64) {
  14564. m.id = &id
  14565. }
  14566. // ID returns the ID value in the mutation. Note that the ID is only available
  14567. // if it was provided to the builder or after it was returned from the database.
  14568. func (m *ServerMutation) ID() (id uint64, exists bool) {
  14569. if m.id == nil {
  14570. return
  14571. }
  14572. return *m.id, true
  14573. }
  14574. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14575. // That means, if the mutation is applied within a transaction with an isolation level such
  14576. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14577. // or updated by the mutation.
  14578. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  14579. switch {
  14580. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14581. id, exists := m.ID()
  14582. if exists {
  14583. return []uint64{id}, nil
  14584. }
  14585. fallthrough
  14586. case m.op.Is(OpUpdate | OpDelete):
  14587. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  14588. default:
  14589. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14590. }
  14591. }
  14592. // SetCreatedAt sets the "created_at" field.
  14593. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  14594. m.created_at = &t
  14595. }
  14596. // CreatedAt returns the value of the "created_at" field in the mutation.
  14597. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  14598. v := m.created_at
  14599. if v == nil {
  14600. return
  14601. }
  14602. return *v, true
  14603. }
  14604. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  14605. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14607. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14608. if !m.op.Is(OpUpdateOne) {
  14609. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14610. }
  14611. if m.id == nil || m.oldValue == nil {
  14612. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14613. }
  14614. oldValue, err := m.oldValue(ctx)
  14615. if err != nil {
  14616. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14617. }
  14618. return oldValue.CreatedAt, nil
  14619. }
  14620. // ResetCreatedAt resets all changes to the "created_at" field.
  14621. func (m *ServerMutation) ResetCreatedAt() {
  14622. m.created_at = nil
  14623. }
  14624. // SetUpdatedAt sets the "updated_at" field.
  14625. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  14626. m.updated_at = &t
  14627. }
  14628. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14629. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  14630. v := m.updated_at
  14631. if v == nil {
  14632. return
  14633. }
  14634. return *v, true
  14635. }
  14636. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  14637. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14639. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14640. if !m.op.Is(OpUpdateOne) {
  14641. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14642. }
  14643. if m.id == nil || m.oldValue == nil {
  14644. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14645. }
  14646. oldValue, err := m.oldValue(ctx)
  14647. if err != nil {
  14648. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14649. }
  14650. return oldValue.UpdatedAt, nil
  14651. }
  14652. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14653. func (m *ServerMutation) ResetUpdatedAt() {
  14654. m.updated_at = nil
  14655. }
  14656. // SetStatus sets the "status" field.
  14657. func (m *ServerMutation) SetStatus(u uint8) {
  14658. m.status = &u
  14659. m.addstatus = nil
  14660. }
  14661. // Status returns the value of the "status" field in the mutation.
  14662. func (m *ServerMutation) Status() (r uint8, exists bool) {
  14663. v := m.status
  14664. if v == nil {
  14665. return
  14666. }
  14667. return *v, true
  14668. }
  14669. // OldStatus returns the old "status" field's value of the Server entity.
  14670. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14672. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14673. if !m.op.Is(OpUpdateOne) {
  14674. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14675. }
  14676. if m.id == nil || m.oldValue == nil {
  14677. return v, errors.New("OldStatus requires an ID field in the mutation")
  14678. }
  14679. oldValue, err := m.oldValue(ctx)
  14680. if err != nil {
  14681. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14682. }
  14683. return oldValue.Status, nil
  14684. }
  14685. // AddStatus adds u to the "status" field.
  14686. func (m *ServerMutation) AddStatus(u int8) {
  14687. if m.addstatus != nil {
  14688. *m.addstatus += u
  14689. } else {
  14690. m.addstatus = &u
  14691. }
  14692. }
  14693. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14694. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  14695. v := m.addstatus
  14696. if v == nil {
  14697. return
  14698. }
  14699. return *v, true
  14700. }
  14701. // ClearStatus clears the value of the "status" field.
  14702. func (m *ServerMutation) ClearStatus() {
  14703. m.status = nil
  14704. m.addstatus = nil
  14705. m.clearedFields[server.FieldStatus] = struct{}{}
  14706. }
  14707. // StatusCleared returns if the "status" field was cleared in this mutation.
  14708. func (m *ServerMutation) StatusCleared() bool {
  14709. _, ok := m.clearedFields[server.FieldStatus]
  14710. return ok
  14711. }
  14712. // ResetStatus resets all changes to the "status" field.
  14713. func (m *ServerMutation) ResetStatus() {
  14714. m.status = nil
  14715. m.addstatus = nil
  14716. delete(m.clearedFields, server.FieldStatus)
  14717. }
  14718. // SetDeletedAt sets the "deleted_at" field.
  14719. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  14720. m.deleted_at = &t
  14721. }
  14722. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14723. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  14724. v := m.deleted_at
  14725. if v == nil {
  14726. return
  14727. }
  14728. return *v, true
  14729. }
  14730. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  14731. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14733. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14734. if !m.op.Is(OpUpdateOne) {
  14735. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14736. }
  14737. if m.id == nil || m.oldValue == nil {
  14738. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14739. }
  14740. oldValue, err := m.oldValue(ctx)
  14741. if err != nil {
  14742. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14743. }
  14744. return oldValue.DeletedAt, nil
  14745. }
  14746. // ClearDeletedAt clears the value of the "deleted_at" field.
  14747. func (m *ServerMutation) ClearDeletedAt() {
  14748. m.deleted_at = nil
  14749. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  14750. }
  14751. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14752. func (m *ServerMutation) DeletedAtCleared() bool {
  14753. _, ok := m.clearedFields[server.FieldDeletedAt]
  14754. return ok
  14755. }
  14756. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14757. func (m *ServerMutation) ResetDeletedAt() {
  14758. m.deleted_at = nil
  14759. delete(m.clearedFields, server.FieldDeletedAt)
  14760. }
  14761. // SetName sets the "name" field.
  14762. func (m *ServerMutation) SetName(s string) {
  14763. m.name = &s
  14764. }
  14765. // Name returns the value of the "name" field in the mutation.
  14766. func (m *ServerMutation) Name() (r string, exists bool) {
  14767. v := m.name
  14768. if v == nil {
  14769. return
  14770. }
  14771. return *v, true
  14772. }
  14773. // OldName returns the old "name" field's value of the Server entity.
  14774. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14776. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  14777. if !m.op.Is(OpUpdateOne) {
  14778. return v, errors.New("OldName is only allowed on UpdateOne operations")
  14779. }
  14780. if m.id == nil || m.oldValue == nil {
  14781. return v, errors.New("OldName requires an ID field in the mutation")
  14782. }
  14783. oldValue, err := m.oldValue(ctx)
  14784. if err != nil {
  14785. return v, fmt.Errorf("querying old value for OldName: %w", err)
  14786. }
  14787. return oldValue.Name, nil
  14788. }
  14789. // ResetName resets all changes to the "name" field.
  14790. func (m *ServerMutation) ResetName() {
  14791. m.name = nil
  14792. }
  14793. // SetPublicIP sets the "public_ip" field.
  14794. func (m *ServerMutation) SetPublicIP(s string) {
  14795. m.public_ip = &s
  14796. }
  14797. // PublicIP returns the value of the "public_ip" field in the mutation.
  14798. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  14799. v := m.public_ip
  14800. if v == nil {
  14801. return
  14802. }
  14803. return *v, true
  14804. }
  14805. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  14806. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14808. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  14809. if !m.op.Is(OpUpdateOne) {
  14810. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  14811. }
  14812. if m.id == nil || m.oldValue == nil {
  14813. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  14814. }
  14815. oldValue, err := m.oldValue(ctx)
  14816. if err != nil {
  14817. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  14818. }
  14819. return oldValue.PublicIP, nil
  14820. }
  14821. // ResetPublicIP resets all changes to the "public_ip" field.
  14822. func (m *ServerMutation) ResetPublicIP() {
  14823. m.public_ip = nil
  14824. }
  14825. // SetPrivateIP sets the "private_ip" field.
  14826. func (m *ServerMutation) SetPrivateIP(s string) {
  14827. m.private_ip = &s
  14828. }
  14829. // PrivateIP returns the value of the "private_ip" field in the mutation.
  14830. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  14831. v := m.private_ip
  14832. if v == nil {
  14833. return
  14834. }
  14835. return *v, true
  14836. }
  14837. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  14838. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14840. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  14841. if !m.op.Is(OpUpdateOne) {
  14842. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  14843. }
  14844. if m.id == nil || m.oldValue == nil {
  14845. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  14846. }
  14847. oldValue, err := m.oldValue(ctx)
  14848. if err != nil {
  14849. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  14850. }
  14851. return oldValue.PrivateIP, nil
  14852. }
  14853. // ResetPrivateIP resets all changes to the "private_ip" field.
  14854. func (m *ServerMutation) ResetPrivateIP() {
  14855. m.private_ip = nil
  14856. }
  14857. // SetAdminPort sets the "admin_port" field.
  14858. func (m *ServerMutation) SetAdminPort(s string) {
  14859. m.admin_port = &s
  14860. }
  14861. // AdminPort returns the value of the "admin_port" field in the mutation.
  14862. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  14863. v := m.admin_port
  14864. if v == nil {
  14865. return
  14866. }
  14867. return *v, true
  14868. }
  14869. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  14870. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14872. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  14873. if !m.op.Is(OpUpdateOne) {
  14874. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  14875. }
  14876. if m.id == nil || m.oldValue == nil {
  14877. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  14878. }
  14879. oldValue, err := m.oldValue(ctx)
  14880. if err != nil {
  14881. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  14882. }
  14883. return oldValue.AdminPort, nil
  14884. }
  14885. // ResetAdminPort resets all changes to the "admin_port" field.
  14886. func (m *ServerMutation) ResetAdminPort() {
  14887. m.admin_port = nil
  14888. }
  14889. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  14890. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  14891. if m.wxs == nil {
  14892. m.wxs = make(map[uint64]struct{})
  14893. }
  14894. for i := range ids {
  14895. m.wxs[ids[i]] = struct{}{}
  14896. }
  14897. }
  14898. // ClearWxs clears the "wxs" edge to the Wx entity.
  14899. func (m *ServerMutation) ClearWxs() {
  14900. m.clearedwxs = true
  14901. }
  14902. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  14903. func (m *ServerMutation) WxsCleared() bool {
  14904. return m.clearedwxs
  14905. }
  14906. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  14907. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  14908. if m.removedwxs == nil {
  14909. m.removedwxs = make(map[uint64]struct{})
  14910. }
  14911. for i := range ids {
  14912. delete(m.wxs, ids[i])
  14913. m.removedwxs[ids[i]] = struct{}{}
  14914. }
  14915. }
  14916. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  14917. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  14918. for id := range m.removedwxs {
  14919. ids = append(ids, id)
  14920. }
  14921. return
  14922. }
  14923. // WxsIDs returns the "wxs" edge IDs in the mutation.
  14924. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  14925. for id := range m.wxs {
  14926. ids = append(ids, id)
  14927. }
  14928. return
  14929. }
  14930. // ResetWxs resets all changes to the "wxs" edge.
  14931. func (m *ServerMutation) ResetWxs() {
  14932. m.wxs = nil
  14933. m.clearedwxs = false
  14934. m.removedwxs = nil
  14935. }
  14936. // Where appends a list predicates to the ServerMutation builder.
  14937. func (m *ServerMutation) Where(ps ...predicate.Server) {
  14938. m.predicates = append(m.predicates, ps...)
  14939. }
  14940. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  14941. // users can use type-assertion to append predicates that do not depend on any generated package.
  14942. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  14943. p := make([]predicate.Server, len(ps))
  14944. for i := range ps {
  14945. p[i] = ps[i]
  14946. }
  14947. m.Where(p...)
  14948. }
  14949. // Op returns the operation name.
  14950. func (m *ServerMutation) Op() Op {
  14951. return m.op
  14952. }
  14953. // SetOp allows setting the mutation operation.
  14954. func (m *ServerMutation) SetOp(op Op) {
  14955. m.op = op
  14956. }
  14957. // Type returns the node type of this mutation (Server).
  14958. func (m *ServerMutation) Type() string {
  14959. return m.typ
  14960. }
  14961. // Fields returns all fields that were changed during this mutation. Note that in
  14962. // order to get all numeric fields that were incremented/decremented, call
  14963. // AddedFields().
  14964. func (m *ServerMutation) Fields() []string {
  14965. fields := make([]string, 0, 8)
  14966. if m.created_at != nil {
  14967. fields = append(fields, server.FieldCreatedAt)
  14968. }
  14969. if m.updated_at != nil {
  14970. fields = append(fields, server.FieldUpdatedAt)
  14971. }
  14972. if m.status != nil {
  14973. fields = append(fields, server.FieldStatus)
  14974. }
  14975. if m.deleted_at != nil {
  14976. fields = append(fields, server.FieldDeletedAt)
  14977. }
  14978. if m.name != nil {
  14979. fields = append(fields, server.FieldName)
  14980. }
  14981. if m.public_ip != nil {
  14982. fields = append(fields, server.FieldPublicIP)
  14983. }
  14984. if m.private_ip != nil {
  14985. fields = append(fields, server.FieldPrivateIP)
  14986. }
  14987. if m.admin_port != nil {
  14988. fields = append(fields, server.FieldAdminPort)
  14989. }
  14990. return fields
  14991. }
  14992. // Field returns the value of a field with the given name. The second boolean
  14993. // return value indicates that this field was not set, or was not defined in the
  14994. // schema.
  14995. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  14996. switch name {
  14997. case server.FieldCreatedAt:
  14998. return m.CreatedAt()
  14999. case server.FieldUpdatedAt:
  15000. return m.UpdatedAt()
  15001. case server.FieldStatus:
  15002. return m.Status()
  15003. case server.FieldDeletedAt:
  15004. return m.DeletedAt()
  15005. case server.FieldName:
  15006. return m.Name()
  15007. case server.FieldPublicIP:
  15008. return m.PublicIP()
  15009. case server.FieldPrivateIP:
  15010. return m.PrivateIP()
  15011. case server.FieldAdminPort:
  15012. return m.AdminPort()
  15013. }
  15014. return nil, false
  15015. }
  15016. // OldField returns the old value of the field from the database. An error is
  15017. // returned if the mutation operation is not UpdateOne, or the query to the
  15018. // database failed.
  15019. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15020. switch name {
  15021. case server.FieldCreatedAt:
  15022. return m.OldCreatedAt(ctx)
  15023. case server.FieldUpdatedAt:
  15024. return m.OldUpdatedAt(ctx)
  15025. case server.FieldStatus:
  15026. return m.OldStatus(ctx)
  15027. case server.FieldDeletedAt:
  15028. return m.OldDeletedAt(ctx)
  15029. case server.FieldName:
  15030. return m.OldName(ctx)
  15031. case server.FieldPublicIP:
  15032. return m.OldPublicIP(ctx)
  15033. case server.FieldPrivateIP:
  15034. return m.OldPrivateIP(ctx)
  15035. case server.FieldAdminPort:
  15036. return m.OldAdminPort(ctx)
  15037. }
  15038. return nil, fmt.Errorf("unknown Server field %s", name)
  15039. }
  15040. // SetField sets the value of a field with the given name. It returns an error if
  15041. // the field is not defined in the schema, or if the type mismatched the field
  15042. // type.
  15043. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  15044. switch name {
  15045. case server.FieldCreatedAt:
  15046. v, ok := value.(time.Time)
  15047. if !ok {
  15048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15049. }
  15050. m.SetCreatedAt(v)
  15051. return nil
  15052. case server.FieldUpdatedAt:
  15053. v, ok := value.(time.Time)
  15054. if !ok {
  15055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15056. }
  15057. m.SetUpdatedAt(v)
  15058. return nil
  15059. case server.FieldStatus:
  15060. v, ok := value.(uint8)
  15061. if !ok {
  15062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15063. }
  15064. m.SetStatus(v)
  15065. return nil
  15066. case server.FieldDeletedAt:
  15067. v, ok := value.(time.Time)
  15068. if !ok {
  15069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15070. }
  15071. m.SetDeletedAt(v)
  15072. return nil
  15073. case server.FieldName:
  15074. v, ok := value.(string)
  15075. if !ok {
  15076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15077. }
  15078. m.SetName(v)
  15079. return nil
  15080. case server.FieldPublicIP:
  15081. v, ok := value.(string)
  15082. if !ok {
  15083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15084. }
  15085. m.SetPublicIP(v)
  15086. return nil
  15087. case server.FieldPrivateIP:
  15088. v, ok := value.(string)
  15089. if !ok {
  15090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15091. }
  15092. m.SetPrivateIP(v)
  15093. return nil
  15094. case server.FieldAdminPort:
  15095. v, ok := value.(string)
  15096. if !ok {
  15097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15098. }
  15099. m.SetAdminPort(v)
  15100. return nil
  15101. }
  15102. return fmt.Errorf("unknown Server field %s", name)
  15103. }
  15104. // AddedFields returns all numeric fields that were incremented/decremented during
  15105. // this mutation.
  15106. func (m *ServerMutation) AddedFields() []string {
  15107. var fields []string
  15108. if m.addstatus != nil {
  15109. fields = append(fields, server.FieldStatus)
  15110. }
  15111. return fields
  15112. }
  15113. // AddedField returns the numeric value that was incremented/decremented on a field
  15114. // with the given name. The second boolean return value indicates that this field
  15115. // was not set, or was not defined in the schema.
  15116. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  15117. switch name {
  15118. case server.FieldStatus:
  15119. return m.AddedStatus()
  15120. }
  15121. return nil, false
  15122. }
  15123. // AddField adds the value to the field with the given name. It returns an error if
  15124. // the field is not defined in the schema, or if the type mismatched the field
  15125. // type.
  15126. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  15127. switch name {
  15128. case server.FieldStatus:
  15129. v, ok := value.(int8)
  15130. if !ok {
  15131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15132. }
  15133. m.AddStatus(v)
  15134. return nil
  15135. }
  15136. return fmt.Errorf("unknown Server numeric field %s", name)
  15137. }
  15138. // ClearedFields returns all nullable fields that were cleared during this
  15139. // mutation.
  15140. func (m *ServerMutation) ClearedFields() []string {
  15141. var fields []string
  15142. if m.FieldCleared(server.FieldStatus) {
  15143. fields = append(fields, server.FieldStatus)
  15144. }
  15145. if m.FieldCleared(server.FieldDeletedAt) {
  15146. fields = append(fields, server.FieldDeletedAt)
  15147. }
  15148. return fields
  15149. }
  15150. // FieldCleared returns a boolean indicating if a field with the given name was
  15151. // cleared in this mutation.
  15152. func (m *ServerMutation) FieldCleared(name string) bool {
  15153. _, ok := m.clearedFields[name]
  15154. return ok
  15155. }
  15156. // ClearField clears the value of the field with the given name. It returns an
  15157. // error if the field is not defined in the schema.
  15158. func (m *ServerMutation) ClearField(name string) error {
  15159. switch name {
  15160. case server.FieldStatus:
  15161. m.ClearStatus()
  15162. return nil
  15163. case server.FieldDeletedAt:
  15164. m.ClearDeletedAt()
  15165. return nil
  15166. }
  15167. return fmt.Errorf("unknown Server nullable field %s", name)
  15168. }
  15169. // ResetField resets all changes in the mutation for the field with the given name.
  15170. // It returns an error if the field is not defined in the schema.
  15171. func (m *ServerMutation) ResetField(name string) error {
  15172. switch name {
  15173. case server.FieldCreatedAt:
  15174. m.ResetCreatedAt()
  15175. return nil
  15176. case server.FieldUpdatedAt:
  15177. m.ResetUpdatedAt()
  15178. return nil
  15179. case server.FieldStatus:
  15180. m.ResetStatus()
  15181. return nil
  15182. case server.FieldDeletedAt:
  15183. m.ResetDeletedAt()
  15184. return nil
  15185. case server.FieldName:
  15186. m.ResetName()
  15187. return nil
  15188. case server.FieldPublicIP:
  15189. m.ResetPublicIP()
  15190. return nil
  15191. case server.FieldPrivateIP:
  15192. m.ResetPrivateIP()
  15193. return nil
  15194. case server.FieldAdminPort:
  15195. m.ResetAdminPort()
  15196. return nil
  15197. }
  15198. return fmt.Errorf("unknown Server field %s", name)
  15199. }
  15200. // AddedEdges returns all edge names that were set/added in this mutation.
  15201. func (m *ServerMutation) AddedEdges() []string {
  15202. edges := make([]string, 0, 1)
  15203. if m.wxs != nil {
  15204. edges = append(edges, server.EdgeWxs)
  15205. }
  15206. return edges
  15207. }
  15208. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15209. // name in this mutation.
  15210. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  15211. switch name {
  15212. case server.EdgeWxs:
  15213. ids := make([]ent.Value, 0, len(m.wxs))
  15214. for id := range m.wxs {
  15215. ids = append(ids, id)
  15216. }
  15217. return ids
  15218. }
  15219. return nil
  15220. }
  15221. // RemovedEdges returns all edge names that were removed in this mutation.
  15222. func (m *ServerMutation) RemovedEdges() []string {
  15223. edges := make([]string, 0, 1)
  15224. if m.removedwxs != nil {
  15225. edges = append(edges, server.EdgeWxs)
  15226. }
  15227. return edges
  15228. }
  15229. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15230. // the given name in this mutation.
  15231. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  15232. switch name {
  15233. case server.EdgeWxs:
  15234. ids := make([]ent.Value, 0, len(m.removedwxs))
  15235. for id := range m.removedwxs {
  15236. ids = append(ids, id)
  15237. }
  15238. return ids
  15239. }
  15240. return nil
  15241. }
  15242. // ClearedEdges returns all edge names that were cleared in this mutation.
  15243. func (m *ServerMutation) ClearedEdges() []string {
  15244. edges := make([]string, 0, 1)
  15245. if m.clearedwxs {
  15246. edges = append(edges, server.EdgeWxs)
  15247. }
  15248. return edges
  15249. }
  15250. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15251. // was cleared in this mutation.
  15252. func (m *ServerMutation) EdgeCleared(name string) bool {
  15253. switch name {
  15254. case server.EdgeWxs:
  15255. return m.clearedwxs
  15256. }
  15257. return false
  15258. }
  15259. // ClearEdge clears the value of the edge with the given name. It returns an error
  15260. // if that edge is not defined in the schema.
  15261. func (m *ServerMutation) ClearEdge(name string) error {
  15262. switch name {
  15263. }
  15264. return fmt.Errorf("unknown Server unique edge %s", name)
  15265. }
  15266. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15267. // It returns an error if the edge is not defined in the schema.
  15268. func (m *ServerMutation) ResetEdge(name string) error {
  15269. switch name {
  15270. case server.EdgeWxs:
  15271. m.ResetWxs()
  15272. return nil
  15273. }
  15274. return fmt.Errorf("unknown Server edge %s", name)
  15275. }
  15276. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  15277. type SopNodeMutation struct {
  15278. config
  15279. op Op
  15280. typ string
  15281. id *uint64
  15282. created_at *time.Time
  15283. updated_at *time.Time
  15284. status *uint8
  15285. addstatus *int8
  15286. deleted_at *time.Time
  15287. parent_id *uint64
  15288. addparent_id *int64
  15289. name *string
  15290. condition_type *int
  15291. addcondition_type *int
  15292. condition_list *[]string
  15293. appendcondition_list []string
  15294. no_reply_condition *uint64
  15295. addno_reply_condition *int64
  15296. no_reply_unit *string
  15297. action_message *[]custom_types.Action
  15298. appendaction_message []custom_types.Action
  15299. action_label_add *[]uint64
  15300. appendaction_label_add []uint64
  15301. action_label_del *[]uint64
  15302. appendaction_label_del []uint64
  15303. action_forward **custom_types.ActionForward
  15304. clearedFields map[string]struct{}
  15305. sop_stage *uint64
  15306. clearedsop_stage bool
  15307. node_messages map[uint64]struct{}
  15308. removednode_messages map[uint64]struct{}
  15309. clearednode_messages bool
  15310. done bool
  15311. oldValue func(context.Context) (*SopNode, error)
  15312. predicates []predicate.SopNode
  15313. }
  15314. var _ ent.Mutation = (*SopNodeMutation)(nil)
  15315. // sopnodeOption allows management of the mutation configuration using functional options.
  15316. type sopnodeOption func(*SopNodeMutation)
  15317. // newSopNodeMutation creates new mutation for the SopNode entity.
  15318. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  15319. m := &SopNodeMutation{
  15320. config: c,
  15321. op: op,
  15322. typ: TypeSopNode,
  15323. clearedFields: make(map[string]struct{}),
  15324. }
  15325. for _, opt := range opts {
  15326. opt(m)
  15327. }
  15328. return m
  15329. }
  15330. // withSopNodeID sets the ID field of the mutation.
  15331. func withSopNodeID(id uint64) sopnodeOption {
  15332. return func(m *SopNodeMutation) {
  15333. var (
  15334. err error
  15335. once sync.Once
  15336. value *SopNode
  15337. )
  15338. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  15339. once.Do(func() {
  15340. if m.done {
  15341. err = errors.New("querying old values post mutation is not allowed")
  15342. } else {
  15343. value, err = m.Client().SopNode.Get(ctx, id)
  15344. }
  15345. })
  15346. return value, err
  15347. }
  15348. m.id = &id
  15349. }
  15350. }
  15351. // withSopNode sets the old SopNode of the mutation.
  15352. func withSopNode(node *SopNode) sopnodeOption {
  15353. return func(m *SopNodeMutation) {
  15354. m.oldValue = func(context.Context) (*SopNode, error) {
  15355. return node, nil
  15356. }
  15357. m.id = &node.ID
  15358. }
  15359. }
  15360. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15361. // executed in a transaction (ent.Tx), a transactional client is returned.
  15362. func (m SopNodeMutation) Client() *Client {
  15363. client := &Client{config: m.config}
  15364. client.init()
  15365. return client
  15366. }
  15367. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15368. // it returns an error otherwise.
  15369. func (m SopNodeMutation) Tx() (*Tx, error) {
  15370. if _, ok := m.driver.(*txDriver); !ok {
  15371. return nil, errors.New("ent: mutation is not running in a transaction")
  15372. }
  15373. tx := &Tx{config: m.config}
  15374. tx.init()
  15375. return tx, nil
  15376. }
  15377. // SetID sets the value of the id field. Note that this
  15378. // operation is only accepted on creation of SopNode entities.
  15379. func (m *SopNodeMutation) SetID(id uint64) {
  15380. m.id = &id
  15381. }
  15382. // ID returns the ID value in the mutation. Note that the ID is only available
  15383. // if it was provided to the builder or after it was returned from the database.
  15384. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  15385. if m.id == nil {
  15386. return
  15387. }
  15388. return *m.id, true
  15389. }
  15390. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15391. // That means, if the mutation is applied within a transaction with an isolation level such
  15392. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15393. // or updated by the mutation.
  15394. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  15395. switch {
  15396. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15397. id, exists := m.ID()
  15398. if exists {
  15399. return []uint64{id}, nil
  15400. }
  15401. fallthrough
  15402. case m.op.Is(OpUpdate | OpDelete):
  15403. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  15404. default:
  15405. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15406. }
  15407. }
  15408. // SetCreatedAt sets the "created_at" field.
  15409. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  15410. m.created_at = &t
  15411. }
  15412. // CreatedAt returns the value of the "created_at" field in the mutation.
  15413. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  15414. v := m.created_at
  15415. if v == nil {
  15416. return
  15417. }
  15418. return *v, true
  15419. }
  15420. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  15421. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15423. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15424. if !m.op.Is(OpUpdateOne) {
  15425. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15426. }
  15427. if m.id == nil || m.oldValue == nil {
  15428. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15429. }
  15430. oldValue, err := m.oldValue(ctx)
  15431. if err != nil {
  15432. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15433. }
  15434. return oldValue.CreatedAt, nil
  15435. }
  15436. // ResetCreatedAt resets all changes to the "created_at" field.
  15437. func (m *SopNodeMutation) ResetCreatedAt() {
  15438. m.created_at = nil
  15439. }
  15440. // SetUpdatedAt sets the "updated_at" field.
  15441. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  15442. m.updated_at = &t
  15443. }
  15444. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15445. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  15446. v := m.updated_at
  15447. if v == nil {
  15448. return
  15449. }
  15450. return *v, true
  15451. }
  15452. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  15453. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15455. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15456. if !m.op.Is(OpUpdateOne) {
  15457. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15458. }
  15459. if m.id == nil || m.oldValue == nil {
  15460. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15461. }
  15462. oldValue, err := m.oldValue(ctx)
  15463. if err != nil {
  15464. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15465. }
  15466. return oldValue.UpdatedAt, nil
  15467. }
  15468. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15469. func (m *SopNodeMutation) ResetUpdatedAt() {
  15470. m.updated_at = nil
  15471. }
  15472. // SetStatus sets the "status" field.
  15473. func (m *SopNodeMutation) SetStatus(u uint8) {
  15474. m.status = &u
  15475. m.addstatus = nil
  15476. }
  15477. // Status returns the value of the "status" field in the mutation.
  15478. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  15479. v := m.status
  15480. if v == nil {
  15481. return
  15482. }
  15483. return *v, true
  15484. }
  15485. // OldStatus returns the old "status" field's value of the SopNode entity.
  15486. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15488. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15489. if !m.op.Is(OpUpdateOne) {
  15490. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15491. }
  15492. if m.id == nil || m.oldValue == nil {
  15493. return v, errors.New("OldStatus requires an ID field in the mutation")
  15494. }
  15495. oldValue, err := m.oldValue(ctx)
  15496. if err != nil {
  15497. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15498. }
  15499. return oldValue.Status, nil
  15500. }
  15501. // AddStatus adds u to the "status" field.
  15502. func (m *SopNodeMutation) AddStatus(u int8) {
  15503. if m.addstatus != nil {
  15504. *m.addstatus += u
  15505. } else {
  15506. m.addstatus = &u
  15507. }
  15508. }
  15509. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15510. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  15511. v := m.addstatus
  15512. if v == nil {
  15513. return
  15514. }
  15515. return *v, true
  15516. }
  15517. // ClearStatus clears the value of the "status" field.
  15518. func (m *SopNodeMutation) ClearStatus() {
  15519. m.status = nil
  15520. m.addstatus = nil
  15521. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  15522. }
  15523. // StatusCleared returns if the "status" field was cleared in this mutation.
  15524. func (m *SopNodeMutation) StatusCleared() bool {
  15525. _, ok := m.clearedFields[sopnode.FieldStatus]
  15526. return ok
  15527. }
  15528. // ResetStatus resets all changes to the "status" field.
  15529. func (m *SopNodeMutation) ResetStatus() {
  15530. m.status = nil
  15531. m.addstatus = nil
  15532. delete(m.clearedFields, sopnode.FieldStatus)
  15533. }
  15534. // SetDeletedAt sets the "deleted_at" field.
  15535. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  15536. m.deleted_at = &t
  15537. }
  15538. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15539. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  15540. v := m.deleted_at
  15541. if v == nil {
  15542. return
  15543. }
  15544. return *v, true
  15545. }
  15546. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  15547. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15549. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15550. if !m.op.Is(OpUpdateOne) {
  15551. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15552. }
  15553. if m.id == nil || m.oldValue == nil {
  15554. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15555. }
  15556. oldValue, err := m.oldValue(ctx)
  15557. if err != nil {
  15558. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15559. }
  15560. return oldValue.DeletedAt, nil
  15561. }
  15562. // ClearDeletedAt clears the value of the "deleted_at" field.
  15563. func (m *SopNodeMutation) ClearDeletedAt() {
  15564. m.deleted_at = nil
  15565. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  15566. }
  15567. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15568. func (m *SopNodeMutation) DeletedAtCleared() bool {
  15569. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  15570. return ok
  15571. }
  15572. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15573. func (m *SopNodeMutation) ResetDeletedAt() {
  15574. m.deleted_at = nil
  15575. delete(m.clearedFields, sopnode.FieldDeletedAt)
  15576. }
  15577. // SetStageID sets the "stage_id" field.
  15578. func (m *SopNodeMutation) SetStageID(u uint64) {
  15579. m.sop_stage = &u
  15580. }
  15581. // StageID returns the value of the "stage_id" field in the mutation.
  15582. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  15583. v := m.sop_stage
  15584. if v == nil {
  15585. return
  15586. }
  15587. return *v, true
  15588. }
  15589. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  15590. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15592. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  15593. if !m.op.Is(OpUpdateOne) {
  15594. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  15595. }
  15596. if m.id == nil || m.oldValue == nil {
  15597. return v, errors.New("OldStageID requires an ID field in the mutation")
  15598. }
  15599. oldValue, err := m.oldValue(ctx)
  15600. if err != nil {
  15601. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  15602. }
  15603. return oldValue.StageID, nil
  15604. }
  15605. // ResetStageID resets all changes to the "stage_id" field.
  15606. func (m *SopNodeMutation) ResetStageID() {
  15607. m.sop_stage = nil
  15608. }
  15609. // SetParentID sets the "parent_id" field.
  15610. func (m *SopNodeMutation) SetParentID(u uint64) {
  15611. m.parent_id = &u
  15612. m.addparent_id = nil
  15613. }
  15614. // ParentID returns the value of the "parent_id" field in the mutation.
  15615. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  15616. v := m.parent_id
  15617. if v == nil {
  15618. return
  15619. }
  15620. return *v, true
  15621. }
  15622. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  15623. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15625. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  15626. if !m.op.Is(OpUpdateOne) {
  15627. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  15628. }
  15629. if m.id == nil || m.oldValue == nil {
  15630. return v, errors.New("OldParentID requires an ID field in the mutation")
  15631. }
  15632. oldValue, err := m.oldValue(ctx)
  15633. if err != nil {
  15634. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  15635. }
  15636. return oldValue.ParentID, nil
  15637. }
  15638. // AddParentID adds u to the "parent_id" field.
  15639. func (m *SopNodeMutation) AddParentID(u int64) {
  15640. if m.addparent_id != nil {
  15641. *m.addparent_id += u
  15642. } else {
  15643. m.addparent_id = &u
  15644. }
  15645. }
  15646. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  15647. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  15648. v := m.addparent_id
  15649. if v == nil {
  15650. return
  15651. }
  15652. return *v, true
  15653. }
  15654. // ResetParentID resets all changes to the "parent_id" field.
  15655. func (m *SopNodeMutation) ResetParentID() {
  15656. m.parent_id = nil
  15657. m.addparent_id = nil
  15658. }
  15659. // SetName sets the "name" field.
  15660. func (m *SopNodeMutation) SetName(s string) {
  15661. m.name = &s
  15662. }
  15663. // Name returns the value of the "name" field in the mutation.
  15664. func (m *SopNodeMutation) Name() (r string, exists bool) {
  15665. v := m.name
  15666. if v == nil {
  15667. return
  15668. }
  15669. return *v, true
  15670. }
  15671. // OldName returns the old "name" field's value of the SopNode entity.
  15672. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15674. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  15675. if !m.op.Is(OpUpdateOne) {
  15676. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15677. }
  15678. if m.id == nil || m.oldValue == nil {
  15679. return v, errors.New("OldName requires an ID field in the mutation")
  15680. }
  15681. oldValue, err := m.oldValue(ctx)
  15682. if err != nil {
  15683. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15684. }
  15685. return oldValue.Name, nil
  15686. }
  15687. // ResetName resets all changes to the "name" field.
  15688. func (m *SopNodeMutation) ResetName() {
  15689. m.name = nil
  15690. }
  15691. // SetConditionType sets the "condition_type" field.
  15692. func (m *SopNodeMutation) SetConditionType(i int) {
  15693. m.condition_type = &i
  15694. m.addcondition_type = nil
  15695. }
  15696. // ConditionType returns the value of the "condition_type" field in the mutation.
  15697. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  15698. v := m.condition_type
  15699. if v == nil {
  15700. return
  15701. }
  15702. return *v, true
  15703. }
  15704. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  15705. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15707. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  15708. if !m.op.Is(OpUpdateOne) {
  15709. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  15710. }
  15711. if m.id == nil || m.oldValue == nil {
  15712. return v, errors.New("OldConditionType requires an ID field in the mutation")
  15713. }
  15714. oldValue, err := m.oldValue(ctx)
  15715. if err != nil {
  15716. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  15717. }
  15718. return oldValue.ConditionType, nil
  15719. }
  15720. // AddConditionType adds i to the "condition_type" field.
  15721. func (m *SopNodeMutation) AddConditionType(i int) {
  15722. if m.addcondition_type != nil {
  15723. *m.addcondition_type += i
  15724. } else {
  15725. m.addcondition_type = &i
  15726. }
  15727. }
  15728. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  15729. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  15730. v := m.addcondition_type
  15731. if v == nil {
  15732. return
  15733. }
  15734. return *v, true
  15735. }
  15736. // ResetConditionType resets all changes to the "condition_type" field.
  15737. func (m *SopNodeMutation) ResetConditionType() {
  15738. m.condition_type = nil
  15739. m.addcondition_type = nil
  15740. }
  15741. // SetConditionList sets the "condition_list" field.
  15742. func (m *SopNodeMutation) SetConditionList(s []string) {
  15743. m.condition_list = &s
  15744. m.appendcondition_list = nil
  15745. }
  15746. // ConditionList returns the value of the "condition_list" field in the mutation.
  15747. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  15748. v := m.condition_list
  15749. if v == nil {
  15750. return
  15751. }
  15752. return *v, true
  15753. }
  15754. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  15755. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15757. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  15758. if !m.op.Is(OpUpdateOne) {
  15759. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  15760. }
  15761. if m.id == nil || m.oldValue == nil {
  15762. return v, errors.New("OldConditionList requires an ID field in the mutation")
  15763. }
  15764. oldValue, err := m.oldValue(ctx)
  15765. if err != nil {
  15766. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  15767. }
  15768. return oldValue.ConditionList, nil
  15769. }
  15770. // AppendConditionList adds s to the "condition_list" field.
  15771. func (m *SopNodeMutation) AppendConditionList(s []string) {
  15772. m.appendcondition_list = append(m.appendcondition_list, s...)
  15773. }
  15774. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  15775. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  15776. if len(m.appendcondition_list) == 0 {
  15777. return nil, false
  15778. }
  15779. return m.appendcondition_list, true
  15780. }
  15781. // ClearConditionList clears the value of the "condition_list" field.
  15782. func (m *SopNodeMutation) ClearConditionList() {
  15783. m.condition_list = nil
  15784. m.appendcondition_list = nil
  15785. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  15786. }
  15787. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  15788. func (m *SopNodeMutation) ConditionListCleared() bool {
  15789. _, ok := m.clearedFields[sopnode.FieldConditionList]
  15790. return ok
  15791. }
  15792. // ResetConditionList resets all changes to the "condition_list" field.
  15793. func (m *SopNodeMutation) ResetConditionList() {
  15794. m.condition_list = nil
  15795. m.appendcondition_list = nil
  15796. delete(m.clearedFields, sopnode.FieldConditionList)
  15797. }
  15798. // SetNoReplyCondition sets the "no_reply_condition" field.
  15799. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  15800. m.no_reply_condition = &u
  15801. m.addno_reply_condition = nil
  15802. }
  15803. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  15804. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  15805. v := m.no_reply_condition
  15806. if v == nil {
  15807. return
  15808. }
  15809. return *v, true
  15810. }
  15811. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  15812. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15814. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  15815. if !m.op.Is(OpUpdateOne) {
  15816. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  15817. }
  15818. if m.id == nil || m.oldValue == nil {
  15819. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  15820. }
  15821. oldValue, err := m.oldValue(ctx)
  15822. if err != nil {
  15823. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  15824. }
  15825. return oldValue.NoReplyCondition, nil
  15826. }
  15827. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  15828. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  15829. if m.addno_reply_condition != nil {
  15830. *m.addno_reply_condition += u
  15831. } else {
  15832. m.addno_reply_condition = &u
  15833. }
  15834. }
  15835. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  15836. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  15837. v := m.addno_reply_condition
  15838. if v == nil {
  15839. return
  15840. }
  15841. return *v, true
  15842. }
  15843. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  15844. func (m *SopNodeMutation) ResetNoReplyCondition() {
  15845. m.no_reply_condition = nil
  15846. m.addno_reply_condition = nil
  15847. }
  15848. // SetNoReplyUnit sets the "no_reply_unit" field.
  15849. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  15850. m.no_reply_unit = &s
  15851. }
  15852. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  15853. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  15854. v := m.no_reply_unit
  15855. if v == nil {
  15856. return
  15857. }
  15858. return *v, true
  15859. }
  15860. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  15861. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15863. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  15864. if !m.op.Is(OpUpdateOne) {
  15865. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  15866. }
  15867. if m.id == nil || m.oldValue == nil {
  15868. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  15869. }
  15870. oldValue, err := m.oldValue(ctx)
  15871. if err != nil {
  15872. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  15873. }
  15874. return oldValue.NoReplyUnit, nil
  15875. }
  15876. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  15877. func (m *SopNodeMutation) ResetNoReplyUnit() {
  15878. m.no_reply_unit = nil
  15879. }
  15880. // SetActionMessage sets the "action_message" field.
  15881. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  15882. m.action_message = &ct
  15883. m.appendaction_message = nil
  15884. }
  15885. // ActionMessage returns the value of the "action_message" field in the mutation.
  15886. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  15887. v := m.action_message
  15888. if v == nil {
  15889. return
  15890. }
  15891. return *v, true
  15892. }
  15893. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  15894. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15896. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  15897. if !m.op.Is(OpUpdateOne) {
  15898. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  15899. }
  15900. if m.id == nil || m.oldValue == nil {
  15901. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  15902. }
  15903. oldValue, err := m.oldValue(ctx)
  15904. if err != nil {
  15905. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  15906. }
  15907. return oldValue.ActionMessage, nil
  15908. }
  15909. // AppendActionMessage adds ct to the "action_message" field.
  15910. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  15911. m.appendaction_message = append(m.appendaction_message, ct...)
  15912. }
  15913. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  15914. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  15915. if len(m.appendaction_message) == 0 {
  15916. return nil, false
  15917. }
  15918. return m.appendaction_message, true
  15919. }
  15920. // ClearActionMessage clears the value of the "action_message" field.
  15921. func (m *SopNodeMutation) ClearActionMessage() {
  15922. m.action_message = nil
  15923. m.appendaction_message = nil
  15924. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  15925. }
  15926. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  15927. func (m *SopNodeMutation) ActionMessageCleared() bool {
  15928. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  15929. return ok
  15930. }
  15931. // ResetActionMessage resets all changes to the "action_message" field.
  15932. func (m *SopNodeMutation) ResetActionMessage() {
  15933. m.action_message = nil
  15934. m.appendaction_message = nil
  15935. delete(m.clearedFields, sopnode.FieldActionMessage)
  15936. }
  15937. // SetActionLabelAdd sets the "action_label_add" field.
  15938. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  15939. m.action_label_add = &u
  15940. m.appendaction_label_add = nil
  15941. }
  15942. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  15943. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  15944. v := m.action_label_add
  15945. if v == nil {
  15946. return
  15947. }
  15948. return *v, true
  15949. }
  15950. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  15951. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15953. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  15954. if !m.op.Is(OpUpdateOne) {
  15955. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  15956. }
  15957. if m.id == nil || m.oldValue == nil {
  15958. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  15959. }
  15960. oldValue, err := m.oldValue(ctx)
  15961. if err != nil {
  15962. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  15963. }
  15964. return oldValue.ActionLabelAdd, nil
  15965. }
  15966. // AppendActionLabelAdd adds u to the "action_label_add" field.
  15967. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  15968. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  15969. }
  15970. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  15971. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  15972. if len(m.appendaction_label_add) == 0 {
  15973. return nil, false
  15974. }
  15975. return m.appendaction_label_add, true
  15976. }
  15977. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  15978. func (m *SopNodeMutation) ClearActionLabelAdd() {
  15979. m.action_label_add = nil
  15980. m.appendaction_label_add = nil
  15981. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  15982. }
  15983. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  15984. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  15985. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  15986. return ok
  15987. }
  15988. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  15989. func (m *SopNodeMutation) ResetActionLabelAdd() {
  15990. m.action_label_add = nil
  15991. m.appendaction_label_add = nil
  15992. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  15993. }
  15994. // SetActionLabelDel sets the "action_label_del" field.
  15995. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  15996. m.action_label_del = &u
  15997. m.appendaction_label_del = nil
  15998. }
  15999. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  16000. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  16001. v := m.action_label_del
  16002. if v == nil {
  16003. return
  16004. }
  16005. return *v, true
  16006. }
  16007. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  16008. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16010. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  16011. if !m.op.Is(OpUpdateOne) {
  16012. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  16013. }
  16014. if m.id == nil || m.oldValue == nil {
  16015. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  16016. }
  16017. oldValue, err := m.oldValue(ctx)
  16018. if err != nil {
  16019. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  16020. }
  16021. return oldValue.ActionLabelDel, nil
  16022. }
  16023. // AppendActionLabelDel adds u to the "action_label_del" field.
  16024. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  16025. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  16026. }
  16027. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  16028. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  16029. if len(m.appendaction_label_del) == 0 {
  16030. return nil, false
  16031. }
  16032. return m.appendaction_label_del, true
  16033. }
  16034. // ClearActionLabelDel clears the value of the "action_label_del" field.
  16035. func (m *SopNodeMutation) ClearActionLabelDel() {
  16036. m.action_label_del = nil
  16037. m.appendaction_label_del = nil
  16038. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  16039. }
  16040. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  16041. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  16042. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  16043. return ok
  16044. }
  16045. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  16046. func (m *SopNodeMutation) ResetActionLabelDel() {
  16047. m.action_label_del = nil
  16048. m.appendaction_label_del = nil
  16049. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  16050. }
  16051. // SetActionForward sets the "action_forward" field.
  16052. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  16053. m.action_forward = &ctf
  16054. }
  16055. // ActionForward returns the value of the "action_forward" field in the mutation.
  16056. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  16057. v := m.action_forward
  16058. if v == nil {
  16059. return
  16060. }
  16061. return *v, true
  16062. }
  16063. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  16064. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16066. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  16067. if !m.op.Is(OpUpdateOne) {
  16068. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  16069. }
  16070. if m.id == nil || m.oldValue == nil {
  16071. return v, errors.New("OldActionForward requires an ID field in the mutation")
  16072. }
  16073. oldValue, err := m.oldValue(ctx)
  16074. if err != nil {
  16075. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  16076. }
  16077. return oldValue.ActionForward, nil
  16078. }
  16079. // ClearActionForward clears the value of the "action_forward" field.
  16080. func (m *SopNodeMutation) ClearActionForward() {
  16081. m.action_forward = nil
  16082. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  16083. }
  16084. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  16085. func (m *SopNodeMutation) ActionForwardCleared() bool {
  16086. _, ok := m.clearedFields[sopnode.FieldActionForward]
  16087. return ok
  16088. }
  16089. // ResetActionForward resets all changes to the "action_forward" field.
  16090. func (m *SopNodeMutation) ResetActionForward() {
  16091. m.action_forward = nil
  16092. delete(m.clearedFields, sopnode.FieldActionForward)
  16093. }
  16094. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  16095. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  16096. m.sop_stage = &id
  16097. }
  16098. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  16099. func (m *SopNodeMutation) ClearSopStage() {
  16100. m.clearedsop_stage = true
  16101. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  16102. }
  16103. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  16104. func (m *SopNodeMutation) SopStageCleared() bool {
  16105. return m.clearedsop_stage
  16106. }
  16107. // SopStageID returns the "sop_stage" edge ID in the mutation.
  16108. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  16109. if m.sop_stage != nil {
  16110. return *m.sop_stage, true
  16111. }
  16112. return
  16113. }
  16114. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  16115. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16116. // SopStageID instead. It exists only for internal usage by the builders.
  16117. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  16118. if id := m.sop_stage; id != nil {
  16119. ids = append(ids, *id)
  16120. }
  16121. return
  16122. }
  16123. // ResetSopStage resets all changes to the "sop_stage" edge.
  16124. func (m *SopNodeMutation) ResetSopStage() {
  16125. m.sop_stage = nil
  16126. m.clearedsop_stage = false
  16127. }
  16128. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  16129. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  16130. if m.node_messages == nil {
  16131. m.node_messages = make(map[uint64]struct{})
  16132. }
  16133. for i := range ids {
  16134. m.node_messages[ids[i]] = struct{}{}
  16135. }
  16136. }
  16137. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  16138. func (m *SopNodeMutation) ClearNodeMessages() {
  16139. m.clearednode_messages = true
  16140. }
  16141. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  16142. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  16143. return m.clearednode_messages
  16144. }
  16145. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  16146. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  16147. if m.removednode_messages == nil {
  16148. m.removednode_messages = make(map[uint64]struct{})
  16149. }
  16150. for i := range ids {
  16151. delete(m.node_messages, ids[i])
  16152. m.removednode_messages[ids[i]] = struct{}{}
  16153. }
  16154. }
  16155. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  16156. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  16157. for id := range m.removednode_messages {
  16158. ids = append(ids, id)
  16159. }
  16160. return
  16161. }
  16162. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  16163. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  16164. for id := range m.node_messages {
  16165. ids = append(ids, id)
  16166. }
  16167. return
  16168. }
  16169. // ResetNodeMessages resets all changes to the "node_messages" edge.
  16170. func (m *SopNodeMutation) ResetNodeMessages() {
  16171. m.node_messages = nil
  16172. m.clearednode_messages = false
  16173. m.removednode_messages = nil
  16174. }
  16175. // Where appends a list predicates to the SopNodeMutation builder.
  16176. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  16177. m.predicates = append(m.predicates, ps...)
  16178. }
  16179. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  16180. // users can use type-assertion to append predicates that do not depend on any generated package.
  16181. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  16182. p := make([]predicate.SopNode, len(ps))
  16183. for i := range ps {
  16184. p[i] = ps[i]
  16185. }
  16186. m.Where(p...)
  16187. }
  16188. // Op returns the operation name.
  16189. func (m *SopNodeMutation) Op() Op {
  16190. return m.op
  16191. }
  16192. // SetOp allows setting the mutation operation.
  16193. func (m *SopNodeMutation) SetOp(op Op) {
  16194. m.op = op
  16195. }
  16196. // Type returns the node type of this mutation (SopNode).
  16197. func (m *SopNodeMutation) Type() string {
  16198. return m.typ
  16199. }
  16200. // Fields returns all fields that were changed during this mutation. Note that in
  16201. // order to get all numeric fields that were incremented/decremented, call
  16202. // AddedFields().
  16203. func (m *SopNodeMutation) Fields() []string {
  16204. fields := make([]string, 0, 15)
  16205. if m.created_at != nil {
  16206. fields = append(fields, sopnode.FieldCreatedAt)
  16207. }
  16208. if m.updated_at != nil {
  16209. fields = append(fields, sopnode.FieldUpdatedAt)
  16210. }
  16211. if m.status != nil {
  16212. fields = append(fields, sopnode.FieldStatus)
  16213. }
  16214. if m.deleted_at != nil {
  16215. fields = append(fields, sopnode.FieldDeletedAt)
  16216. }
  16217. if m.sop_stage != nil {
  16218. fields = append(fields, sopnode.FieldStageID)
  16219. }
  16220. if m.parent_id != nil {
  16221. fields = append(fields, sopnode.FieldParentID)
  16222. }
  16223. if m.name != nil {
  16224. fields = append(fields, sopnode.FieldName)
  16225. }
  16226. if m.condition_type != nil {
  16227. fields = append(fields, sopnode.FieldConditionType)
  16228. }
  16229. if m.condition_list != nil {
  16230. fields = append(fields, sopnode.FieldConditionList)
  16231. }
  16232. if m.no_reply_condition != nil {
  16233. fields = append(fields, sopnode.FieldNoReplyCondition)
  16234. }
  16235. if m.no_reply_unit != nil {
  16236. fields = append(fields, sopnode.FieldNoReplyUnit)
  16237. }
  16238. if m.action_message != nil {
  16239. fields = append(fields, sopnode.FieldActionMessage)
  16240. }
  16241. if m.action_label_add != nil {
  16242. fields = append(fields, sopnode.FieldActionLabelAdd)
  16243. }
  16244. if m.action_label_del != nil {
  16245. fields = append(fields, sopnode.FieldActionLabelDel)
  16246. }
  16247. if m.action_forward != nil {
  16248. fields = append(fields, sopnode.FieldActionForward)
  16249. }
  16250. return fields
  16251. }
  16252. // Field returns the value of a field with the given name. The second boolean
  16253. // return value indicates that this field was not set, or was not defined in the
  16254. // schema.
  16255. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  16256. switch name {
  16257. case sopnode.FieldCreatedAt:
  16258. return m.CreatedAt()
  16259. case sopnode.FieldUpdatedAt:
  16260. return m.UpdatedAt()
  16261. case sopnode.FieldStatus:
  16262. return m.Status()
  16263. case sopnode.FieldDeletedAt:
  16264. return m.DeletedAt()
  16265. case sopnode.FieldStageID:
  16266. return m.StageID()
  16267. case sopnode.FieldParentID:
  16268. return m.ParentID()
  16269. case sopnode.FieldName:
  16270. return m.Name()
  16271. case sopnode.FieldConditionType:
  16272. return m.ConditionType()
  16273. case sopnode.FieldConditionList:
  16274. return m.ConditionList()
  16275. case sopnode.FieldNoReplyCondition:
  16276. return m.NoReplyCondition()
  16277. case sopnode.FieldNoReplyUnit:
  16278. return m.NoReplyUnit()
  16279. case sopnode.FieldActionMessage:
  16280. return m.ActionMessage()
  16281. case sopnode.FieldActionLabelAdd:
  16282. return m.ActionLabelAdd()
  16283. case sopnode.FieldActionLabelDel:
  16284. return m.ActionLabelDel()
  16285. case sopnode.FieldActionForward:
  16286. return m.ActionForward()
  16287. }
  16288. return nil, false
  16289. }
  16290. // OldField returns the old value of the field from the database. An error is
  16291. // returned if the mutation operation is not UpdateOne, or the query to the
  16292. // database failed.
  16293. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16294. switch name {
  16295. case sopnode.FieldCreatedAt:
  16296. return m.OldCreatedAt(ctx)
  16297. case sopnode.FieldUpdatedAt:
  16298. return m.OldUpdatedAt(ctx)
  16299. case sopnode.FieldStatus:
  16300. return m.OldStatus(ctx)
  16301. case sopnode.FieldDeletedAt:
  16302. return m.OldDeletedAt(ctx)
  16303. case sopnode.FieldStageID:
  16304. return m.OldStageID(ctx)
  16305. case sopnode.FieldParentID:
  16306. return m.OldParentID(ctx)
  16307. case sopnode.FieldName:
  16308. return m.OldName(ctx)
  16309. case sopnode.FieldConditionType:
  16310. return m.OldConditionType(ctx)
  16311. case sopnode.FieldConditionList:
  16312. return m.OldConditionList(ctx)
  16313. case sopnode.FieldNoReplyCondition:
  16314. return m.OldNoReplyCondition(ctx)
  16315. case sopnode.FieldNoReplyUnit:
  16316. return m.OldNoReplyUnit(ctx)
  16317. case sopnode.FieldActionMessage:
  16318. return m.OldActionMessage(ctx)
  16319. case sopnode.FieldActionLabelAdd:
  16320. return m.OldActionLabelAdd(ctx)
  16321. case sopnode.FieldActionLabelDel:
  16322. return m.OldActionLabelDel(ctx)
  16323. case sopnode.FieldActionForward:
  16324. return m.OldActionForward(ctx)
  16325. }
  16326. return nil, fmt.Errorf("unknown SopNode field %s", name)
  16327. }
  16328. // SetField sets the value of a field with the given name. It returns an error if
  16329. // the field is not defined in the schema, or if the type mismatched the field
  16330. // type.
  16331. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  16332. switch name {
  16333. case sopnode.FieldCreatedAt:
  16334. v, ok := value.(time.Time)
  16335. if !ok {
  16336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16337. }
  16338. m.SetCreatedAt(v)
  16339. return nil
  16340. case sopnode.FieldUpdatedAt:
  16341. v, ok := value.(time.Time)
  16342. if !ok {
  16343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16344. }
  16345. m.SetUpdatedAt(v)
  16346. return nil
  16347. case sopnode.FieldStatus:
  16348. v, ok := value.(uint8)
  16349. if !ok {
  16350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16351. }
  16352. m.SetStatus(v)
  16353. return nil
  16354. case sopnode.FieldDeletedAt:
  16355. v, ok := value.(time.Time)
  16356. if !ok {
  16357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16358. }
  16359. m.SetDeletedAt(v)
  16360. return nil
  16361. case sopnode.FieldStageID:
  16362. v, ok := value.(uint64)
  16363. if !ok {
  16364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16365. }
  16366. m.SetStageID(v)
  16367. return nil
  16368. case sopnode.FieldParentID:
  16369. v, ok := value.(uint64)
  16370. if !ok {
  16371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16372. }
  16373. m.SetParentID(v)
  16374. return nil
  16375. case sopnode.FieldName:
  16376. v, ok := value.(string)
  16377. if !ok {
  16378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16379. }
  16380. m.SetName(v)
  16381. return nil
  16382. case sopnode.FieldConditionType:
  16383. v, ok := value.(int)
  16384. if !ok {
  16385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16386. }
  16387. m.SetConditionType(v)
  16388. return nil
  16389. case sopnode.FieldConditionList:
  16390. v, ok := value.([]string)
  16391. if !ok {
  16392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16393. }
  16394. m.SetConditionList(v)
  16395. return nil
  16396. case sopnode.FieldNoReplyCondition:
  16397. v, ok := value.(uint64)
  16398. if !ok {
  16399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16400. }
  16401. m.SetNoReplyCondition(v)
  16402. return nil
  16403. case sopnode.FieldNoReplyUnit:
  16404. v, ok := value.(string)
  16405. if !ok {
  16406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16407. }
  16408. m.SetNoReplyUnit(v)
  16409. return nil
  16410. case sopnode.FieldActionMessage:
  16411. v, ok := value.([]custom_types.Action)
  16412. if !ok {
  16413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16414. }
  16415. m.SetActionMessage(v)
  16416. return nil
  16417. case sopnode.FieldActionLabelAdd:
  16418. v, ok := value.([]uint64)
  16419. if !ok {
  16420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16421. }
  16422. m.SetActionLabelAdd(v)
  16423. return nil
  16424. case sopnode.FieldActionLabelDel:
  16425. v, ok := value.([]uint64)
  16426. if !ok {
  16427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16428. }
  16429. m.SetActionLabelDel(v)
  16430. return nil
  16431. case sopnode.FieldActionForward:
  16432. v, ok := value.(*custom_types.ActionForward)
  16433. if !ok {
  16434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16435. }
  16436. m.SetActionForward(v)
  16437. return nil
  16438. }
  16439. return fmt.Errorf("unknown SopNode field %s", name)
  16440. }
  16441. // AddedFields returns all numeric fields that were incremented/decremented during
  16442. // this mutation.
  16443. func (m *SopNodeMutation) AddedFields() []string {
  16444. var fields []string
  16445. if m.addstatus != nil {
  16446. fields = append(fields, sopnode.FieldStatus)
  16447. }
  16448. if m.addparent_id != nil {
  16449. fields = append(fields, sopnode.FieldParentID)
  16450. }
  16451. if m.addcondition_type != nil {
  16452. fields = append(fields, sopnode.FieldConditionType)
  16453. }
  16454. if m.addno_reply_condition != nil {
  16455. fields = append(fields, sopnode.FieldNoReplyCondition)
  16456. }
  16457. return fields
  16458. }
  16459. // AddedField returns the numeric value that was incremented/decremented on a field
  16460. // with the given name. The second boolean return value indicates that this field
  16461. // was not set, or was not defined in the schema.
  16462. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  16463. switch name {
  16464. case sopnode.FieldStatus:
  16465. return m.AddedStatus()
  16466. case sopnode.FieldParentID:
  16467. return m.AddedParentID()
  16468. case sopnode.FieldConditionType:
  16469. return m.AddedConditionType()
  16470. case sopnode.FieldNoReplyCondition:
  16471. return m.AddedNoReplyCondition()
  16472. }
  16473. return nil, false
  16474. }
  16475. // AddField adds the value to the field with the given name. It returns an error if
  16476. // the field is not defined in the schema, or if the type mismatched the field
  16477. // type.
  16478. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  16479. switch name {
  16480. case sopnode.FieldStatus:
  16481. v, ok := value.(int8)
  16482. if !ok {
  16483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16484. }
  16485. m.AddStatus(v)
  16486. return nil
  16487. case sopnode.FieldParentID:
  16488. v, ok := value.(int64)
  16489. if !ok {
  16490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16491. }
  16492. m.AddParentID(v)
  16493. return nil
  16494. case sopnode.FieldConditionType:
  16495. v, ok := value.(int)
  16496. if !ok {
  16497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16498. }
  16499. m.AddConditionType(v)
  16500. return nil
  16501. case sopnode.FieldNoReplyCondition:
  16502. v, ok := value.(int64)
  16503. if !ok {
  16504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16505. }
  16506. m.AddNoReplyCondition(v)
  16507. return nil
  16508. }
  16509. return fmt.Errorf("unknown SopNode numeric field %s", name)
  16510. }
  16511. // ClearedFields returns all nullable fields that were cleared during this
  16512. // mutation.
  16513. func (m *SopNodeMutation) ClearedFields() []string {
  16514. var fields []string
  16515. if m.FieldCleared(sopnode.FieldStatus) {
  16516. fields = append(fields, sopnode.FieldStatus)
  16517. }
  16518. if m.FieldCleared(sopnode.FieldDeletedAt) {
  16519. fields = append(fields, sopnode.FieldDeletedAt)
  16520. }
  16521. if m.FieldCleared(sopnode.FieldConditionList) {
  16522. fields = append(fields, sopnode.FieldConditionList)
  16523. }
  16524. if m.FieldCleared(sopnode.FieldActionMessage) {
  16525. fields = append(fields, sopnode.FieldActionMessage)
  16526. }
  16527. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  16528. fields = append(fields, sopnode.FieldActionLabelAdd)
  16529. }
  16530. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  16531. fields = append(fields, sopnode.FieldActionLabelDel)
  16532. }
  16533. if m.FieldCleared(sopnode.FieldActionForward) {
  16534. fields = append(fields, sopnode.FieldActionForward)
  16535. }
  16536. return fields
  16537. }
  16538. // FieldCleared returns a boolean indicating if a field with the given name was
  16539. // cleared in this mutation.
  16540. func (m *SopNodeMutation) FieldCleared(name string) bool {
  16541. _, ok := m.clearedFields[name]
  16542. return ok
  16543. }
  16544. // ClearField clears the value of the field with the given name. It returns an
  16545. // error if the field is not defined in the schema.
  16546. func (m *SopNodeMutation) ClearField(name string) error {
  16547. switch name {
  16548. case sopnode.FieldStatus:
  16549. m.ClearStatus()
  16550. return nil
  16551. case sopnode.FieldDeletedAt:
  16552. m.ClearDeletedAt()
  16553. return nil
  16554. case sopnode.FieldConditionList:
  16555. m.ClearConditionList()
  16556. return nil
  16557. case sopnode.FieldActionMessage:
  16558. m.ClearActionMessage()
  16559. return nil
  16560. case sopnode.FieldActionLabelAdd:
  16561. m.ClearActionLabelAdd()
  16562. return nil
  16563. case sopnode.FieldActionLabelDel:
  16564. m.ClearActionLabelDel()
  16565. return nil
  16566. case sopnode.FieldActionForward:
  16567. m.ClearActionForward()
  16568. return nil
  16569. }
  16570. return fmt.Errorf("unknown SopNode nullable field %s", name)
  16571. }
  16572. // ResetField resets all changes in the mutation for the field with the given name.
  16573. // It returns an error if the field is not defined in the schema.
  16574. func (m *SopNodeMutation) ResetField(name string) error {
  16575. switch name {
  16576. case sopnode.FieldCreatedAt:
  16577. m.ResetCreatedAt()
  16578. return nil
  16579. case sopnode.FieldUpdatedAt:
  16580. m.ResetUpdatedAt()
  16581. return nil
  16582. case sopnode.FieldStatus:
  16583. m.ResetStatus()
  16584. return nil
  16585. case sopnode.FieldDeletedAt:
  16586. m.ResetDeletedAt()
  16587. return nil
  16588. case sopnode.FieldStageID:
  16589. m.ResetStageID()
  16590. return nil
  16591. case sopnode.FieldParentID:
  16592. m.ResetParentID()
  16593. return nil
  16594. case sopnode.FieldName:
  16595. m.ResetName()
  16596. return nil
  16597. case sopnode.FieldConditionType:
  16598. m.ResetConditionType()
  16599. return nil
  16600. case sopnode.FieldConditionList:
  16601. m.ResetConditionList()
  16602. return nil
  16603. case sopnode.FieldNoReplyCondition:
  16604. m.ResetNoReplyCondition()
  16605. return nil
  16606. case sopnode.FieldNoReplyUnit:
  16607. m.ResetNoReplyUnit()
  16608. return nil
  16609. case sopnode.FieldActionMessage:
  16610. m.ResetActionMessage()
  16611. return nil
  16612. case sopnode.FieldActionLabelAdd:
  16613. m.ResetActionLabelAdd()
  16614. return nil
  16615. case sopnode.FieldActionLabelDel:
  16616. m.ResetActionLabelDel()
  16617. return nil
  16618. case sopnode.FieldActionForward:
  16619. m.ResetActionForward()
  16620. return nil
  16621. }
  16622. return fmt.Errorf("unknown SopNode field %s", name)
  16623. }
  16624. // AddedEdges returns all edge names that were set/added in this mutation.
  16625. func (m *SopNodeMutation) AddedEdges() []string {
  16626. edges := make([]string, 0, 2)
  16627. if m.sop_stage != nil {
  16628. edges = append(edges, sopnode.EdgeSopStage)
  16629. }
  16630. if m.node_messages != nil {
  16631. edges = append(edges, sopnode.EdgeNodeMessages)
  16632. }
  16633. return edges
  16634. }
  16635. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16636. // name in this mutation.
  16637. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  16638. switch name {
  16639. case sopnode.EdgeSopStage:
  16640. if id := m.sop_stage; id != nil {
  16641. return []ent.Value{*id}
  16642. }
  16643. case sopnode.EdgeNodeMessages:
  16644. ids := make([]ent.Value, 0, len(m.node_messages))
  16645. for id := range m.node_messages {
  16646. ids = append(ids, id)
  16647. }
  16648. return ids
  16649. }
  16650. return nil
  16651. }
  16652. // RemovedEdges returns all edge names that were removed in this mutation.
  16653. func (m *SopNodeMutation) RemovedEdges() []string {
  16654. edges := make([]string, 0, 2)
  16655. if m.removednode_messages != nil {
  16656. edges = append(edges, sopnode.EdgeNodeMessages)
  16657. }
  16658. return edges
  16659. }
  16660. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16661. // the given name in this mutation.
  16662. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  16663. switch name {
  16664. case sopnode.EdgeNodeMessages:
  16665. ids := make([]ent.Value, 0, len(m.removednode_messages))
  16666. for id := range m.removednode_messages {
  16667. ids = append(ids, id)
  16668. }
  16669. return ids
  16670. }
  16671. return nil
  16672. }
  16673. // ClearedEdges returns all edge names that were cleared in this mutation.
  16674. func (m *SopNodeMutation) ClearedEdges() []string {
  16675. edges := make([]string, 0, 2)
  16676. if m.clearedsop_stage {
  16677. edges = append(edges, sopnode.EdgeSopStage)
  16678. }
  16679. if m.clearednode_messages {
  16680. edges = append(edges, sopnode.EdgeNodeMessages)
  16681. }
  16682. return edges
  16683. }
  16684. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16685. // was cleared in this mutation.
  16686. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  16687. switch name {
  16688. case sopnode.EdgeSopStage:
  16689. return m.clearedsop_stage
  16690. case sopnode.EdgeNodeMessages:
  16691. return m.clearednode_messages
  16692. }
  16693. return false
  16694. }
  16695. // ClearEdge clears the value of the edge with the given name. It returns an error
  16696. // if that edge is not defined in the schema.
  16697. func (m *SopNodeMutation) ClearEdge(name string) error {
  16698. switch name {
  16699. case sopnode.EdgeSopStage:
  16700. m.ClearSopStage()
  16701. return nil
  16702. }
  16703. return fmt.Errorf("unknown SopNode unique edge %s", name)
  16704. }
  16705. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16706. // It returns an error if the edge is not defined in the schema.
  16707. func (m *SopNodeMutation) ResetEdge(name string) error {
  16708. switch name {
  16709. case sopnode.EdgeSopStage:
  16710. m.ResetSopStage()
  16711. return nil
  16712. case sopnode.EdgeNodeMessages:
  16713. m.ResetNodeMessages()
  16714. return nil
  16715. }
  16716. return fmt.Errorf("unknown SopNode edge %s", name)
  16717. }
  16718. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  16719. type SopStageMutation struct {
  16720. config
  16721. op Op
  16722. typ string
  16723. id *uint64
  16724. created_at *time.Time
  16725. updated_at *time.Time
  16726. status *uint8
  16727. addstatus *int8
  16728. deleted_at *time.Time
  16729. name *string
  16730. condition_type *int
  16731. addcondition_type *int
  16732. condition_operator *int
  16733. addcondition_operator *int
  16734. condition_list *[]custom_types.Condition
  16735. appendcondition_list []custom_types.Condition
  16736. action_message *[]custom_types.Action
  16737. appendaction_message []custom_types.Action
  16738. action_label_add *[]uint64
  16739. appendaction_label_add []uint64
  16740. action_label_del *[]uint64
  16741. appendaction_label_del []uint64
  16742. action_forward **custom_types.ActionForward
  16743. index_sort *int
  16744. addindex_sort *int
  16745. clearedFields map[string]struct{}
  16746. sop_task *uint64
  16747. clearedsop_task bool
  16748. stage_nodes map[uint64]struct{}
  16749. removedstage_nodes map[uint64]struct{}
  16750. clearedstage_nodes bool
  16751. stage_messages map[uint64]struct{}
  16752. removedstage_messages map[uint64]struct{}
  16753. clearedstage_messages bool
  16754. done bool
  16755. oldValue func(context.Context) (*SopStage, error)
  16756. predicates []predicate.SopStage
  16757. }
  16758. var _ ent.Mutation = (*SopStageMutation)(nil)
  16759. // sopstageOption allows management of the mutation configuration using functional options.
  16760. type sopstageOption func(*SopStageMutation)
  16761. // newSopStageMutation creates new mutation for the SopStage entity.
  16762. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  16763. m := &SopStageMutation{
  16764. config: c,
  16765. op: op,
  16766. typ: TypeSopStage,
  16767. clearedFields: make(map[string]struct{}),
  16768. }
  16769. for _, opt := range opts {
  16770. opt(m)
  16771. }
  16772. return m
  16773. }
  16774. // withSopStageID sets the ID field of the mutation.
  16775. func withSopStageID(id uint64) sopstageOption {
  16776. return func(m *SopStageMutation) {
  16777. var (
  16778. err error
  16779. once sync.Once
  16780. value *SopStage
  16781. )
  16782. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  16783. once.Do(func() {
  16784. if m.done {
  16785. err = errors.New("querying old values post mutation is not allowed")
  16786. } else {
  16787. value, err = m.Client().SopStage.Get(ctx, id)
  16788. }
  16789. })
  16790. return value, err
  16791. }
  16792. m.id = &id
  16793. }
  16794. }
  16795. // withSopStage sets the old SopStage of the mutation.
  16796. func withSopStage(node *SopStage) sopstageOption {
  16797. return func(m *SopStageMutation) {
  16798. m.oldValue = func(context.Context) (*SopStage, error) {
  16799. return node, nil
  16800. }
  16801. m.id = &node.ID
  16802. }
  16803. }
  16804. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16805. // executed in a transaction (ent.Tx), a transactional client is returned.
  16806. func (m SopStageMutation) Client() *Client {
  16807. client := &Client{config: m.config}
  16808. client.init()
  16809. return client
  16810. }
  16811. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16812. // it returns an error otherwise.
  16813. func (m SopStageMutation) Tx() (*Tx, error) {
  16814. if _, ok := m.driver.(*txDriver); !ok {
  16815. return nil, errors.New("ent: mutation is not running in a transaction")
  16816. }
  16817. tx := &Tx{config: m.config}
  16818. tx.init()
  16819. return tx, nil
  16820. }
  16821. // SetID sets the value of the id field. Note that this
  16822. // operation is only accepted on creation of SopStage entities.
  16823. func (m *SopStageMutation) SetID(id uint64) {
  16824. m.id = &id
  16825. }
  16826. // ID returns the ID value in the mutation. Note that the ID is only available
  16827. // if it was provided to the builder or after it was returned from the database.
  16828. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  16829. if m.id == nil {
  16830. return
  16831. }
  16832. return *m.id, true
  16833. }
  16834. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16835. // That means, if the mutation is applied within a transaction with an isolation level such
  16836. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16837. // or updated by the mutation.
  16838. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  16839. switch {
  16840. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16841. id, exists := m.ID()
  16842. if exists {
  16843. return []uint64{id}, nil
  16844. }
  16845. fallthrough
  16846. case m.op.Is(OpUpdate | OpDelete):
  16847. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  16848. default:
  16849. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16850. }
  16851. }
  16852. // SetCreatedAt sets the "created_at" field.
  16853. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  16854. m.created_at = &t
  16855. }
  16856. // CreatedAt returns the value of the "created_at" field in the mutation.
  16857. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  16858. v := m.created_at
  16859. if v == nil {
  16860. return
  16861. }
  16862. return *v, true
  16863. }
  16864. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  16865. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  16866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16867. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16868. if !m.op.Is(OpUpdateOne) {
  16869. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16870. }
  16871. if m.id == nil || m.oldValue == nil {
  16872. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16873. }
  16874. oldValue, err := m.oldValue(ctx)
  16875. if err != nil {
  16876. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16877. }
  16878. return oldValue.CreatedAt, nil
  16879. }
  16880. // ResetCreatedAt resets all changes to the "created_at" field.
  16881. func (m *SopStageMutation) ResetCreatedAt() {
  16882. m.created_at = nil
  16883. }
  16884. // SetUpdatedAt sets the "updated_at" field.
  16885. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  16886. m.updated_at = &t
  16887. }
  16888. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16889. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  16890. v := m.updated_at
  16891. if v == nil {
  16892. return
  16893. }
  16894. return *v, true
  16895. }
  16896. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  16897. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  16898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16899. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16900. if !m.op.Is(OpUpdateOne) {
  16901. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16902. }
  16903. if m.id == nil || m.oldValue == nil {
  16904. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16905. }
  16906. oldValue, err := m.oldValue(ctx)
  16907. if err != nil {
  16908. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16909. }
  16910. return oldValue.UpdatedAt, nil
  16911. }
  16912. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16913. func (m *SopStageMutation) ResetUpdatedAt() {
  16914. m.updated_at = nil
  16915. }
  16916. // SetStatus sets the "status" field.
  16917. func (m *SopStageMutation) SetStatus(u uint8) {
  16918. m.status = &u
  16919. m.addstatus = nil
  16920. }
  16921. // Status returns the value of the "status" field in the mutation.
  16922. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  16923. v := m.status
  16924. if v == nil {
  16925. return
  16926. }
  16927. return *v, true
  16928. }
  16929. // OldStatus returns the old "status" field's value of the SopStage entity.
  16930. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  16931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16932. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16933. if !m.op.Is(OpUpdateOne) {
  16934. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16935. }
  16936. if m.id == nil || m.oldValue == nil {
  16937. return v, errors.New("OldStatus requires an ID field in the mutation")
  16938. }
  16939. oldValue, err := m.oldValue(ctx)
  16940. if err != nil {
  16941. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16942. }
  16943. return oldValue.Status, nil
  16944. }
  16945. // AddStatus adds u to the "status" field.
  16946. func (m *SopStageMutation) AddStatus(u int8) {
  16947. if m.addstatus != nil {
  16948. *m.addstatus += u
  16949. } else {
  16950. m.addstatus = &u
  16951. }
  16952. }
  16953. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16954. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  16955. v := m.addstatus
  16956. if v == nil {
  16957. return
  16958. }
  16959. return *v, true
  16960. }
  16961. // ClearStatus clears the value of the "status" field.
  16962. func (m *SopStageMutation) ClearStatus() {
  16963. m.status = nil
  16964. m.addstatus = nil
  16965. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  16966. }
  16967. // StatusCleared returns if the "status" field was cleared in this mutation.
  16968. func (m *SopStageMutation) StatusCleared() bool {
  16969. _, ok := m.clearedFields[sopstage.FieldStatus]
  16970. return ok
  16971. }
  16972. // ResetStatus resets all changes to the "status" field.
  16973. func (m *SopStageMutation) ResetStatus() {
  16974. m.status = nil
  16975. m.addstatus = nil
  16976. delete(m.clearedFields, sopstage.FieldStatus)
  16977. }
  16978. // SetDeletedAt sets the "deleted_at" field.
  16979. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  16980. m.deleted_at = &t
  16981. }
  16982. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16983. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  16984. v := m.deleted_at
  16985. if v == nil {
  16986. return
  16987. }
  16988. return *v, true
  16989. }
  16990. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  16991. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  16992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16993. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16994. if !m.op.Is(OpUpdateOne) {
  16995. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16996. }
  16997. if m.id == nil || m.oldValue == nil {
  16998. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16999. }
  17000. oldValue, err := m.oldValue(ctx)
  17001. if err != nil {
  17002. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17003. }
  17004. return oldValue.DeletedAt, nil
  17005. }
  17006. // ClearDeletedAt clears the value of the "deleted_at" field.
  17007. func (m *SopStageMutation) ClearDeletedAt() {
  17008. m.deleted_at = nil
  17009. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  17010. }
  17011. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17012. func (m *SopStageMutation) DeletedAtCleared() bool {
  17013. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  17014. return ok
  17015. }
  17016. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17017. func (m *SopStageMutation) ResetDeletedAt() {
  17018. m.deleted_at = nil
  17019. delete(m.clearedFields, sopstage.FieldDeletedAt)
  17020. }
  17021. // SetTaskID sets the "task_id" field.
  17022. func (m *SopStageMutation) SetTaskID(u uint64) {
  17023. m.sop_task = &u
  17024. }
  17025. // TaskID returns the value of the "task_id" field in the mutation.
  17026. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  17027. v := m.sop_task
  17028. if v == nil {
  17029. return
  17030. }
  17031. return *v, true
  17032. }
  17033. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  17034. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17036. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  17037. if !m.op.Is(OpUpdateOne) {
  17038. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  17039. }
  17040. if m.id == nil || m.oldValue == nil {
  17041. return v, errors.New("OldTaskID requires an ID field in the mutation")
  17042. }
  17043. oldValue, err := m.oldValue(ctx)
  17044. if err != nil {
  17045. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  17046. }
  17047. return oldValue.TaskID, nil
  17048. }
  17049. // ResetTaskID resets all changes to the "task_id" field.
  17050. func (m *SopStageMutation) ResetTaskID() {
  17051. m.sop_task = nil
  17052. }
  17053. // SetName sets the "name" field.
  17054. func (m *SopStageMutation) SetName(s string) {
  17055. m.name = &s
  17056. }
  17057. // Name returns the value of the "name" field in the mutation.
  17058. func (m *SopStageMutation) Name() (r string, exists bool) {
  17059. v := m.name
  17060. if v == nil {
  17061. return
  17062. }
  17063. return *v, true
  17064. }
  17065. // OldName returns the old "name" field's value of the SopStage entity.
  17066. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17068. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  17069. if !m.op.Is(OpUpdateOne) {
  17070. return v, errors.New("OldName is only allowed on UpdateOne operations")
  17071. }
  17072. if m.id == nil || m.oldValue == nil {
  17073. return v, errors.New("OldName requires an ID field in the mutation")
  17074. }
  17075. oldValue, err := m.oldValue(ctx)
  17076. if err != nil {
  17077. return v, fmt.Errorf("querying old value for OldName: %w", err)
  17078. }
  17079. return oldValue.Name, nil
  17080. }
  17081. // ResetName resets all changes to the "name" field.
  17082. func (m *SopStageMutation) ResetName() {
  17083. m.name = nil
  17084. }
  17085. // SetConditionType sets the "condition_type" field.
  17086. func (m *SopStageMutation) SetConditionType(i int) {
  17087. m.condition_type = &i
  17088. m.addcondition_type = nil
  17089. }
  17090. // ConditionType returns the value of the "condition_type" field in the mutation.
  17091. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  17092. v := m.condition_type
  17093. if v == nil {
  17094. return
  17095. }
  17096. return *v, true
  17097. }
  17098. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  17099. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17101. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  17102. if !m.op.Is(OpUpdateOne) {
  17103. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  17104. }
  17105. if m.id == nil || m.oldValue == nil {
  17106. return v, errors.New("OldConditionType requires an ID field in the mutation")
  17107. }
  17108. oldValue, err := m.oldValue(ctx)
  17109. if err != nil {
  17110. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  17111. }
  17112. return oldValue.ConditionType, nil
  17113. }
  17114. // AddConditionType adds i to the "condition_type" field.
  17115. func (m *SopStageMutation) AddConditionType(i int) {
  17116. if m.addcondition_type != nil {
  17117. *m.addcondition_type += i
  17118. } else {
  17119. m.addcondition_type = &i
  17120. }
  17121. }
  17122. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  17123. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  17124. v := m.addcondition_type
  17125. if v == nil {
  17126. return
  17127. }
  17128. return *v, true
  17129. }
  17130. // ResetConditionType resets all changes to the "condition_type" field.
  17131. func (m *SopStageMutation) ResetConditionType() {
  17132. m.condition_type = nil
  17133. m.addcondition_type = nil
  17134. }
  17135. // SetConditionOperator sets the "condition_operator" field.
  17136. func (m *SopStageMutation) SetConditionOperator(i int) {
  17137. m.condition_operator = &i
  17138. m.addcondition_operator = nil
  17139. }
  17140. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  17141. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  17142. v := m.condition_operator
  17143. if v == nil {
  17144. return
  17145. }
  17146. return *v, true
  17147. }
  17148. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  17149. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17151. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  17152. if !m.op.Is(OpUpdateOne) {
  17153. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  17154. }
  17155. if m.id == nil || m.oldValue == nil {
  17156. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  17157. }
  17158. oldValue, err := m.oldValue(ctx)
  17159. if err != nil {
  17160. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  17161. }
  17162. return oldValue.ConditionOperator, nil
  17163. }
  17164. // AddConditionOperator adds i to the "condition_operator" field.
  17165. func (m *SopStageMutation) AddConditionOperator(i int) {
  17166. if m.addcondition_operator != nil {
  17167. *m.addcondition_operator += i
  17168. } else {
  17169. m.addcondition_operator = &i
  17170. }
  17171. }
  17172. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  17173. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  17174. v := m.addcondition_operator
  17175. if v == nil {
  17176. return
  17177. }
  17178. return *v, true
  17179. }
  17180. // ResetConditionOperator resets all changes to the "condition_operator" field.
  17181. func (m *SopStageMutation) ResetConditionOperator() {
  17182. m.condition_operator = nil
  17183. m.addcondition_operator = nil
  17184. }
  17185. // SetConditionList sets the "condition_list" field.
  17186. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  17187. m.condition_list = &ct
  17188. m.appendcondition_list = nil
  17189. }
  17190. // ConditionList returns the value of the "condition_list" field in the mutation.
  17191. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  17192. v := m.condition_list
  17193. if v == nil {
  17194. return
  17195. }
  17196. return *v, true
  17197. }
  17198. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  17199. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17201. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  17202. if !m.op.Is(OpUpdateOne) {
  17203. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  17204. }
  17205. if m.id == nil || m.oldValue == nil {
  17206. return v, errors.New("OldConditionList requires an ID field in the mutation")
  17207. }
  17208. oldValue, err := m.oldValue(ctx)
  17209. if err != nil {
  17210. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  17211. }
  17212. return oldValue.ConditionList, nil
  17213. }
  17214. // AppendConditionList adds ct to the "condition_list" field.
  17215. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  17216. m.appendcondition_list = append(m.appendcondition_list, ct...)
  17217. }
  17218. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  17219. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  17220. if len(m.appendcondition_list) == 0 {
  17221. return nil, false
  17222. }
  17223. return m.appendcondition_list, true
  17224. }
  17225. // ResetConditionList resets all changes to the "condition_list" field.
  17226. func (m *SopStageMutation) ResetConditionList() {
  17227. m.condition_list = nil
  17228. m.appendcondition_list = nil
  17229. }
  17230. // SetActionMessage sets the "action_message" field.
  17231. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  17232. m.action_message = &ct
  17233. m.appendaction_message = nil
  17234. }
  17235. // ActionMessage returns the value of the "action_message" field in the mutation.
  17236. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  17237. v := m.action_message
  17238. if v == nil {
  17239. return
  17240. }
  17241. return *v, true
  17242. }
  17243. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  17244. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17246. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  17247. if !m.op.Is(OpUpdateOne) {
  17248. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  17249. }
  17250. if m.id == nil || m.oldValue == nil {
  17251. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  17252. }
  17253. oldValue, err := m.oldValue(ctx)
  17254. if err != nil {
  17255. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  17256. }
  17257. return oldValue.ActionMessage, nil
  17258. }
  17259. // AppendActionMessage adds ct to the "action_message" field.
  17260. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  17261. m.appendaction_message = append(m.appendaction_message, ct...)
  17262. }
  17263. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  17264. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  17265. if len(m.appendaction_message) == 0 {
  17266. return nil, false
  17267. }
  17268. return m.appendaction_message, true
  17269. }
  17270. // ClearActionMessage clears the value of the "action_message" field.
  17271. func (m *SopStageMutation) ClearActionMessage() {
  17272. m.action_message = nil
  17273. m.appendaction_message = nil
  17274. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  17275. }
  17276. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  17277. func (m *SopStageMutation) ActionMessageCleared() bool {
  17278. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  17279. return ok
  17280. }
  17281. // ResetActionMessage resets all changes to the "action_message" field.
  17282. func (m *SopStageMutation) ResetActionMessage() {
  17283. m.action_message = nil
  17284. m.appendaction_message = nil
  17285. delete(m.clearedFields, sopstage.FieldActionMessage)
  17286. }
  17287. // SetActionLabelAdd sets the "action_label_add" field.
  17288. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  17289. m.action_label_add = &u
  17290. m.appendaction_label_add = nil
  17291. }
  17292. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17293. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17294. v := m.action_label_add
  17295. if v == nil {
  17296. return
  17297. }
  17298. return *v, true
  17299. }
  17300. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  17301. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17303. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17304. if !m.op.Is(OpUpdateOne) {
  17305. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17306. }
  17307. if m.id == nil || m.oldValue == nil {
  17308. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17309. }
  17310. oldValue, err := m.oldValue(ctx)
  17311. if err != nil {
  17312. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17313. }
  17314. return oldValue.ActionLabelAdd, nil
  17315. }
  17316. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17317. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  17318. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17319. }
  17320. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17321. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17322. if len(m.appendaction_label_add) == 0 {
  17323. return nil, false
  17324. }
  17325. return m.appendaction_label_add, true
  17326. }
  17327. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17328. func (m *SopStageMutation) ClearActionLabelAdd() {
  17329. m.action_label_add = nil
  17330. m.appendaction_label_add = nil
  17331. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  17332. }
  17333. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17334. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  17335. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  17336. return ok
  17337. }
  17338. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17339. func (m *SopStageMutation) ResetActionLabelAdd() {
  17340. m.action_label_add = nil
  17341. m.appendaction_label_add = nil
  17342. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  17343. }
  17344. // SetActionLabelDel sets the "action_label_del" field.
  17345. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  17346. m.action_label_del = &u
  17347. m.appendaction_label_del = nil
  17348. }
  17349. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  17350. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  17351. v := m.action_label_del
  17352. if v == nil {
  17353. return
  17354. }
  17355. return *v, true
  17356. }
  17357. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  17358. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17360. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  17361. if !m.op.Is(OpUpdateOne) {
  17362. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  17363. }
  17364. if m.id == nil || m.oldValue == nil {
  17365. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  17366. }
  17367. oldValue, err := m.oldValue(ctx)
  17368. if err != nil {
  17369. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  17370. }
  17371. return oldValue.ActionLabelDel, nil
  17372. }
  17373. // AppendActionLabelDel adds u to the "action_label_del" field.
  17374. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  17375. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  17376. }
  17377. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  17378. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  17379. if len(m.appendaction_label_del) == 0 {
  17380. return nil, false
  17381. }
  17382. return m.appendaction_label_del, true
  17383. }
  17384. // ClearActionLabelDel clears the value of the "action_label_del" field.
  17385. func (m *SopStageMutation) ClearActionLabelDel() {
  17386. m.action_label_del = nil
  17387. m.appendaction_label_del = nil
  17388. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  17389. }
  17390. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  17391. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  17392. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  17393. return ok
  17394. }
  17395. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  17396. func (m *SopStageMutation) ResetActionLabelDel() {
  17397. m.action_label_del = nil
  17398. m.appendaction_label_del = nil
  17399. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  17400. }
  17401. // SetActionForward sets the "action_forward" field.
  17402. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  17403. m.action_forward = &ctf
  17404. }
  17405. // ActionForward returns the value of the "action_forward" field in the mutation.
  17406. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  17407. v := m.action_forward
  17408. if v == nil {
  17409. return
  17410. }
  17411. return *v, true
  17412. }
  17413. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  17414. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17416. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  17417. if !m.op.Is(OpUpdateOne) {
  17418. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  17419. }
  17420. if m.id == nil || m.oldValue == nil {
  17421. return v, errors.New("OldActionForward requires an ID field in the mutation")
  17422. }
  17423. oldValue, err := m.oldValue(ctx)
  17424. if err != nil {
  17425. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  17426. }
  17427. return oldValue.ActionForward, nil
  17428. }
  17429. // ClearActionForward clears the value of the "action_forward" field.
  17430. func (m *SopStageMutation) ClearActionForward() {
  17431. m.action_forward = nil
  17432. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  17433. }
  17434. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  17435. func (m *SopStageMutation) ActionForwardCleared() bool {
  17436. _, ok := m.clearedFields[sopstage.FieldActionForward]
  17437. return ok
  17438. }
  17439. // ResetActionForward resets all changes to the "action_forward" field.
  17440. func (m *SopStageMutation) ResetActionForward() {
  17441. m.action_forward = nil
  17442. delete(m.clearedFields, sopstage.FieldActionForward)
  17443. }
  17444. // SetIndexSort sets the "index_sort" field.
  17445. func (m *SopStageMutation) SetIndexSort(i int) {
  17446. m.index_sort = &i
  17447. m.addindex_sort = nil
  17448. }
  17449. // IndexSort returns the value of the "index_sort" field in the mutation.
  17450. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  17451. v := m.index_sort
  17452. if v == nil {
  17453. return
  17454. }
  17455. return *v, true
  17456. }
  17457. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  17458. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17460. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  17461. if !m.op.Is(OpUpdateOne) {
  17462. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  17463. }
  17464. if m.id == nil || m.oldValue == nil {
  17465. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  17466. }
  17467. oldValue, err := m.oldValue(ctx)
  17468. if err != nil {
  17469. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  17470. }
  17471. return oldValue.IndexSort, nil
  17472. }
  17473. // AddIndexSort adds i to the "index_sort" field.
  17474. func (m *SopStageMutation) AddIndexSort(i int) {
  17475. if m.addindex_sort != nil {
  17476. *m.addindex_sort += i
  17477. } else {
  17478. m.addindex_sort = &i
  17479. }
  17480. }
  17481. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  17482. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  17483. v := m.addindex_sort
  17484. if v == nil {
  17485. return
  17486. }
  17487. return *v, true
  17488. }
  17489. // ClearIndexSort clears the value of the "index_sort" field.
  17490. func (m *SopStageMutation) ClearIndexSort() {
  17491. m.index_sort = nil
  17492. m.addindex_sort = nil
  17493. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  17494. }
  17495. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  17496. func (m *SopStageMutation) IndexSortCleared() bool {
  17497. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  17498. return ok
  17499. }
  17500. // ResetIndexSort resets all changes to the "index_sort" field.
  17501. func (m *SopStageMutation) ResetIndexSort() {
  17502. m.index_sort = nil
  17503. m.addindex_sort = nil
  17504. delete(m.clearedFields, sopstage.FieldIndexSort)
  17505. }
  17506. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  17507. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  17508. m.sop_task = &id
  17509. }
  17510. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  17511. func (m *SopStageMutation) ClearSopTask() {
  17512. m.clearedsop_task = true
  17513. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  17514. }
  17515. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  17516. func (m *SopStageMutation) SopTaskCleared() bool {
  17517. return m.clearedsop_task
  17518. }
  17519. // SopTaskID returns the "sop_task" edge ID in the mutation.
  17520. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  17521. if m.sop_task != nil {
  17522. return *m.sop_task, true
  17523. }
  17524. return
  17525. }
  17526. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  17527. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17528. // SopTaskID instead. It exists only for internal usage by the builders.
  17529. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  17530. if id := m.sop_task; id != nil {
  17531. ids = append(ids, *id)
  17532. }
  17533. return
  17534. }
  17535. // ResetSopTask resets all changes to the "sop_task" edge.
  17536. func (m *SopStageMutation) ResetSopTask() {
  17537. m.sop_task = nil
  17538. m.clearedsop_task = false
  17539. }
  17540. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  17541. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  17542. if m.stage_nodes == nil {
  17543. m.stage_nodes = make(map[uint64]struct{})
  17544. }
  17545. for i := range ids {
  17546. m.stage_nodes[ids[i]] = struct{}{}
  17547. }
  17548. }
  17549. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  17550. func (m *SopStageMutation) ClearStageNodes() {
  17551. m.clearedstage_nodes = true
  17552. }
  17553. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  17554. func (m *SopStageMutation) StageNodesCleared() bool {
  17555. return m.clearedstage_nodes
  17556. }
  17557. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  17558. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  17559. if m.removedstage_nodes == nil {
  17560. m.removedstage_nodes = make(map[uint64]struct{})
  17561. }
  17562. for i := range ids {
  17563. delete(m.stage_nodes, ids[i])
  17564. m.removedstage_nodes[ids[i]] = struct{}{}
  17565. }
  17566. }
  17567. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  17568. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  17569. for id := range m.removedstage_nodes {
  17570. ids = append(ids, id)
  17571. }
  17572. return
  17573. }
  17574. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  17575. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  17576. for id := range m.stage_nodes {
  17577. ids = append(ids, id)
  17578. }
  17579. return
  17580. }
  17581. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  17582. func (m *SopStageMutation) ResetStageNodes() {
  17583. m.stage_nodes = nil
  17584. m.clearedstage_nodes = false
  17585. m.removedstage_nodes = nil
  17586. }
  17587. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  17588. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  17589. if m.stage_messages == nil {
  17590. m.stage_messages = make(map[uint64]struct{})
  17591. }
  17592. for i := range ids {
  17593. m.stage_messages[ids[i]] = struct{}{}
  17594. }
  17595. }
  17596. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  17597. func (m *SopStageMutation) ClearStageMessages() {
  17598. m.clearedstage_messages = true
  17599. }
  17600. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  17601. func (m *SopStageMutation) StageMessagesCleared() bool {
  17602. return m.clearedstage_messages
  17603. }
  17604. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  17605. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  17606. if m.removedstage_messages == nil {
  17607. m.removedstage_messages = make(map[uint64]struct{})
  17608. }
  17609. for i := range ids {
  17610. delete(m.stage_messages, ids[i])
  17611. m.removedstage_messages[ids[i]] = struct{}{}
  17612. }
  17613. }
  17614. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  17615. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  17616. for id := range m.removedstage_messages {
  17617. ids = append(ids, id)
  17618. }
  17619. return
  17620. }
  17621. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  17622. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  17623. for id := range m.stage_messages {
  17624. ids = append(ids, id)
  17625. }
  17626. return
  17627. }
  17628. // ResetStageMessages resets all changes to the "stage_messages" edge.
  17629. func (m *SopStageMutation) ResetStageMessages() {
  17630. m.stage_messages = nil
  17631. m.clearedstage_messages = false
  17632. m.removedstage_messages = nil
  17633. }
  17634. // Where appends a list predicates to the SopStageMutation builder.
  17635. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  17636. m.predicates = append(m.predicates, ps...)
  17637. }
  17638. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  17639. // users can use type-assertion to append predicates that do not depend on any generated package.
  17640. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  17641. p := make([]predicate.SopStage, len(ps))
  17642. for i := range ps {
  17643. p[i] = ps[i]
  17644. }
  17645. m.Where(p...)
  17646. }
  17647. // Op returns the operation name.
  17648. func (m *SopStageMutation) Op() Op {
  17649. return m.op
  17650. }
  17651. // SetOp allows setting the mutation operation.
  17652. func (m *SopStageMutation) SetOp(op Op) {
  17653. m.op = op
  17654. }
  17655. // Type returns the node type of this mutation (SopStage).
  17656. func (m *SopStageMutation) Type() string {
  17657. return m.typ
  17658. }
  17659. // Fields returns all fields that were changed during this mutation. Note that in
  17660. // order to get all numeric fields that were incremented/decremented, call
  17661. // AddedFields().
  17662. func (m *SopStageMutation) Fields() []string {
  17663. fields := make([]string, 0, 14)
  17664. if m.created_at != nil {
  17665. fields = append(fields, sopstage.FieldCreatedAt)
  17666. }
  17667. if m.updated_at != nil {
  17668. fields = append(fields, sopstage.FieldUpdatedAt)
  17669. }
  17670. if m.status != nil {
  17671. fields = append(fields, sopstage.FieldStatus)
  17672. }
  17673. if m.deleted_at != nil {
  17674. fields = append(fields, sopstage.FieldDeletedAt)
  17675. }
  17676. if m.sop_task != nil {
  17677. fields = append(fields, sopstage.FieldTaskID)
  17678. }
  17679. if m.name != nil {
  17680. fields = append(fields, sopstage.FieldName)
  17681. }
  17682. if m.condition_type != nil {
  17683. fields = append(fields, sopstage.FieldConditionType)
  17684. }
  17685. if m.condition_operator != nil {
  17686. fields = append(fields, sopstage.FieldConditionOperator)
  17687. }
  17688. if m.condition_list != nil {
  17689. fields = append(fields, sopstage.FieldConditionList)
  17690. }
  17691. if m.action_message != nil {
  17692. fields = append(fields, sopstage.FieldActionMessage)
  17693. }
  17694. if m.action_label_add != nil {
  17695. fields = append(fields, sopstage.FieldActionLabelAdd)
  17696. }
  17697. if m.action_label_del != nil {
  17698. fields = append(fields, sopstage.FieldActionLabelDel)
  17699. }
  17700. if m.action_forward != nil {
  17701. fields = append(fields, sopstage.FieldActionForward)
  17702. }
  17703. if m.index_sort != nil {
  17704. fields = append(fields, sopstage.FieldIndexSort)
  17705. }
  17706. return fields
  17707. }
  17708. // Field returns the value of a field with the given name. The second boolean
  17709. // return value indicates that this field was not set, or was not defined in the
  17710. // schema.
  17711. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  17712. switch name {
  17713. case sopstage.FieldCreatedAt:
  17714. return m.CreatedAt()
  17715. case sopstage.FieldUpdatedAt:
  17716. return m.UpdatedAt()
  17717. case sopstage.FieldStatus:
  17718. return m.Status()
  17719. case sopstage.FieldDeletedAt:
  17720. return m.DeletedAt()
  17721. case sopstage.FieldTaskID:
  17722. return m.TaskID()
  17723. case sopstage.FieldName:
  17724. return m.Name()
  17725. case sopstage.FieldConditionType:
  17726. return m.ConditionType()
  17727. case sopstage.FieldConditionOperator:
  17728. return m.ConditionOperator()
  17729. case sopstage.FieldConditionList:
  17730. return m.ConditionList()
  17731. case sopstage.FieldActionMessage:
  17732. return m.ActionMessage()
  17733. case sopstage.FieldActionLabelAdd:
  17734. return m.ActionLabelAdd()
  17735. case sopstage.FieldActionLabelDel:
  17736. return m.ActionLabelDel()
  17737. case sopstage.FieldActionForward:
  17738. return m.ActionForward()
  17739. case sopstage.FieldIndexSort:
  17740. return m.IndexSort()
  17741. }
  17742. return nil, false
  17743. }
  17744. // OldField returns the old value of the field from the database. An error is
  17745. // returned if the mutation operation is not UpdateOne, or the query to the
  17746. // database failed.
  17747. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17748. switch name {
  17749. case sopstage.FieldCreatedAt:
  17750. return m.OldCreatedAt(ctx)
  17751. case sopstage.FieldUpdatedAt:
  17752. return m.OldUpdatedAt(ctx)
  17753. case sopstage.FieldStatus:
  17754. return m.OldStatus(ctx)
  17755. case sopstage.FieldDeletedAt:
  17756. return m.OldDeletedAt(ctx)
  17757. case sopstage.FieldTaskID:
  17758. return m.OldTaskID(ctx)
  17759. case sopstage.FieldName:
  17760. return m.OldName(ctx)
  17761. case sopstage.FieldConditionType:
  17762. return m.OldConditionType(ctx)
  17763. case sopstage.FieldConditionOperator:
  17764. return m.OldConditionOperator(ctx)
  17765. case sopstage.FieldConditionList:
  17766. return m.OldConditionList(ctx)
  17767. case sopstage.FieldActionMessage:
  17768. return m.OldActionMessage(ctx)
  17769. case sopstage.FieldActionLabelAdd:
  17770. return m.OldActionLabelAdd(ctx)
  17771. case sopstage.FieldActionLabelDel:
  17772. return m.OldActionLabelDel(ctx)
  17773. case sopstage.FieldActionForward:
  17774. return m.OldActionForward(ctx)
  17775. case sopstage.FieldIndexSort:
  17776. return m.OldIndexSort(ctx)
  17777. }
  17778. return nil, fmt.Errorf("unknown SopStage field %s", name)
  17779. }
  17780. // SetField sets the value of a field with the given name. It returns an error if
  17781. // the field is not defined in the schema, or if the type mismatched the field
  17782. // type.
  17783. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  17784. switch name {
  17785. case sopstage.FieldCreatedAt:
  17786. v, ok := value.(time.Time)
  17787. if !ok {
  17788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17789. }
  17790. m.SetCreatedAt(v)
  17791. return nil
  17792. case sopstage.FieldUpdatedAt:
  17793. v, ok := value.(time.Time)
  17794. if !ok {
  17795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17796. }
  17797. m.SetUpdatedAt(v)
  17798. return nil
  17799. case sopstage.FieldStatus:
  17800. v, ok := value.(uint8)
  17801. if !ok {
  17802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17803. }
  17804. m.SetStatus(v)
  17805. return nil
  17806. case sopstage.FieldDeletedAt:
  17807. v, ok := value.(time.Time)
  17808. if !ok {
  17809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17810. }
  17811. m.SetDeletedAt(v)
  17812. return nil
  17813. case sopstage.FieldTaskID:
  17814. v, ok := value.(uint64)
  17815. if !ok {
  17816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17817. }
  17818. m.SetTaskID(v)
  17819. return nil
  17820. case sopstage.FieldName:
  17821. v, ok := value.(string)
  17822. if !ok {
  17823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17824. }
  17825. m.SetName(v)
  17826. return nil
  17827. case sopstage.FieldConditionType:
  17828. v, ok := value.(int)
  17829. if !ok {
  17830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17831. }
  17832. m.SetConditionType(v)
  17833. return nil
  17834. case sopstage.FieldConditionOperator:
  17835. v, ok := value.(int)
  17836. if !ok {
  17837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17838. }
  17839. m.SetConditionOperator(v)
  17840. return nil
  17841. case sopstage.FieldConditionList:
  17842. v, ok := value.([]custom_types.Condition)
  17843. if !ok {
  17844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17845. }
  17846. m.SetConditionList(v)
  17847. return nil
  17848. case sopstage.FieldActionMessage:
  17849. v, ok := value.([]custom_types.Action)
  17850. if !ok {
  17851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17852. }
  17853. m.SetActionMessage(v)
  17854. return nil
  17855. case sopstage.FieldActionLabelAdd:
  17856. v, ok := value.([]uint64)
  17857. if !ok {
  17858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17859. }
  17860. m.SetActionLabelAdd(v)
  17861. return nil
  17862. case sopstage.FieldActionLabelDel:
  17863. v, ok := value.([]uint64)
  17864. if !ok {
  17865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17866. }
  17867. m.SetActionLabelDel(v)
  17868. return nil
  17869. case sopstage.FieldActionForward:
  17870. v, ok := value.(*custom_types.ActionForward)
  17871. if !ok {
  17872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17873. }
  17874. m.SetActionForward(v)
  17875. return nil
  17876. case sopstage.FieldIndexSort:
  17877. v, ok := value.(int)
  17878. if !ok {
  17879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17880. }
  17881. m.SetIndexSort(v)
  17882. return nil
  17883. }
  17884. return fmt.Errorf("unknown SopStage field %s", name)
  17885. }
  17886. // AddedFields returns all numeric fields that were incremented/decremented during
  17887. // this mutation.
  17888. func (m *SopStageMutation) AddedFields() []string {
  17889. var fields []string
  17890. if m.addstatus != nil {
  17891. fields = append(fields, sopstage.FieldStatus)
  17892. }
  17893. if m.addcondition_type != nil {
  17894. fields = append(fields, sopstage.FieldConditionType)
  17895. }
  17896. if m.addcondition_operator != nil {
  17897. fields = append(fields, sopstage.FieldConditionOperator)
  17898. }
  17899. if m.addindex_sort != nil {
  17900. fields = append(fields, sopstage.FieldIndexSort)
  17901. }
  17902. return fields
  17903. }
  17904. // AddedField returns the numeric value that was incremented/decremented on a field
  17905. // with the given name. The second boolean return value indicates that this field
  17906. // was not set, or was not defined in the schema.
  17907. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  17908. switch name {
  17909. case sopstage.FieldStatus:
  17910. return m.AddedStatus()
  17911. case sopstage.FieldConditionType:
  17912. return m.AddedConditionType()
  17913. case sopstage.FieldConditionOperator:
  17914. return m.AddedConditionOperator()
  17915. case sopstage.FieldIndexSort:
  17916. return m.AddedIndexSort()
  17917. }
  17918. return nil, false
  17919. }
  17920. // AddField adds the value to the field with the given name. It returns an error if
  17921. // the field is not defined in the schema, or if the type mismatched the field
  17922. // type.
  17923. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  17924. switch name {
  17925. case sopstage.FieldStatus:
  17926. v, ok := value.(int8)
  17927. if !ok {
  17928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17929. }
  17930. m.AddStatus(v)
  17931. return nil
  17932. case sopstage.FieldConditionType:
  17933. v, ok := value.(int)
  17934. if !ok {
  17935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17936. }
  17937. m.AddConditionType(v)
  17938. return nil
  17939. case sopstage.FieldConditionOperator:
  17940. v, ok := value.(int)
  17941. if !ok {
  17942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17943. }
  17944. m.AddConditionOperator(v)
  17945. return nil
  17946. case sopstage.FieldIndexSort:
  17947. v, ok := value.(int)
  17948. if !ok {
  17949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17950. }
  17951. m.AddIndexSort(v)
  17952. return nil
  17953. }
  17954. return fmt.Errorf("unknown SopStage numeric field %s", name)
  17955. }
  17956. // ClearedFields returns all nullable fields that were cleared during this
  17957. // mutation.
  17958. func (m *SopStageMutation) ClearedFields() []string {
  17959. var fields []string
  17960. if m.FieldCleared(sopstage.FieldStatus) {
  17961. fields = append(fields, sopstage.FieldStatus)
  17962. }
  17963. if m.FieldCleared(sopstage.FieldDeletedAt) {
  17964. fields = append(fields, sopstage.FieldDeletedAt)
  17965. }
  17966. if m.FieldCleared(sopstage.FieldActionMessage) {
  17967. fields = append(fields, sopstage.FieldActionMessage)
  17968. }
  17969. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  17970. fields = append(fields, sopstage.FieldActionLabelAdd)
  17971. }
  17972. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  17973. fields = append(fields, sopstage.FieldActionLabelDel)
  17974. }
  17975. if m.FieldCleared(sopstage.FieldActionForward) {
  17976. fields = append(fields, sopstage.FieldActionForward)
  17977. }
  17978. if m.FieldCleared(sopstage.FieldIndexSort) {
  17979. fields = append(fields, sopstage.FieldIndexSort)
  17980. }
  17981. return fields
  17982. }
  17983. // FieldCleared returns a boolean indicating if a field with the given name was
  17984. // cleared in this mutation.
  17985. func (m *SopStageMutation) FieldCleared(name string) bool {
  17986. _, ok := m.clearedFields[name]
  17987. return ok
  17988. }
  17989. // ClearField clears the value of the field with the given name. It returns an
  17990. // error if the field is not defined in the schema.
  17991. func (m *SopStageMutation) ClearField(name string) error {
  17992. switch name {
  17993. case sopstage.FieldStatus:
  17994. m.ClearStatus()
  17995. return nil
  17996. case sopstage.FieldDeletedAt:
  17997. m.ClearDeletedAt()
  17998. return nil
  17999. case sopstage.FieldActionMessage:
  18000. m.ClearActionMessage()
  18001. return nil
  18002. case sopstage.FieldActionLabelAdd:
  18003. m.ClearActionLabelAdd()
  18004. return nil
  18005. case sopstage.FieldActionLabelDel:
  18006. m.ClearActionLabelDel()
  18007. return nil
  18008. case sopstage.FieldActionForward:
  18009. m.ClearActionForward()
  18010. return nil
  18011. case sopstage.FieldIndexSort:
  18012. m.ClearIndexSort()
  18013. return nil
  18014. }
  18015. return fmt.Errorf("unknown SopStage nullable field %s", name)
  18016. }
  18017. // ResetField resets all changes in the mutation for the field with the given name.
  18018. // It returns an error if the field is not defined in the schema.
  18019. func (m *SopStageMutation) ResetField(name string) error {
  18020. switch name {
  18021. case sopstage.FieldCreatedAt:
  18022. m.ResetCreatedAt()
  18023. return nil
  18024. case sopstage.FieldUpdatedAt:
  18025. m.ResetUpdatedAt()
  18026. return nil
  18027. case sopstage.FieldStatus:
  18028. m.ResetStatus()
  18029. return nil
  18030. case sopstage.FieldDeletedAt:
  18031. m.ResetDeletedAt()
  18032. return nil
  18033. case sopstage.FieldTaskID:
  18034. m.ResetTaskID()
  18035. return nil
  18036. case sopstage.FieldName:
  18037. m.ResetName()
  18038. return nil
  18039. case sopstage.FieldConditionType:
  18040. m.ResetConditionType()
  18041. return nil
  18042. case sopstage.FieldConditionOperator:
  18043. m.ResetConditionOperator()
  18044. return nil
  18045. case sopstage.FieldConditionList:
  18046. m.ResetConditionList()
  18047. return nil
  18048. case sopstage.FieldActionMessage:
  18049. m.ResetActionMessage()
  18050. return nil
  18051. case sopstage.FieldActionLabelAdd:
  18052. m.ResetActionLabelAdd()
  18053. return nil
  18054. case sopstage.FieldActionLabelDel:
  18055. m.ResetActionLabelDel()
  18056. return nil
  18057. case sopstage.FieldActionForward:
  18058. m.ResetActionForward()
  18059. return nil
  18060. case sopstage.FieldIndexSort:
  18061. m.ResetIndexSort()
  18062. return nil
  18063. }
  18064. return fmt.Errorf("unknown SopStage field %s", name)
  18065. }
  18066. // AddedEdges returns all edge names that were set/added in this mutation.
  18067. func (m *SopStageMutation) AddedEdges() []string {
  18068. edges := make([]string, 0, 3)
  18069. if m.sop_task != nil {
  18070. edges = append(edges, sopstage.EdgeSopTask)
  18071. }
  18072. if m.stage_nodes != nil {
  18073. edges = append(edges, sopstage.EdgeStageNodes)
  18074. }
  18075. if m.stage_messages != nil {
  18076. edges = append(edges, sopstage.EdgeStageMessages)
  18077. }
  18078. return edges
  18079. }
  18080. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18081. // name in this mutation.
  18082. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  18083. switch name {
  18084. case sopstage.EdgeSopTask:
  18085. if id := m.sop_task; id != nil {
  18086. return []ent.Value{*id}
  18087. }
  18088. case sopstage.EdgeStageNodes:
  18089. ids := make([]ent.Value, 0, len(m.stage_nodes))
  18090. for id := range m.stage_nodes {
  18091. ids = append(ids, id)
  18092. }
  18093. return ids
  18094. case sopstage.EdgeStageMessages:
  18095. ids := make([]ent.Value, 0, len(m.stage_messages))
  18096. for id := range m.stage_messages {
  18097. ids = append(ids, id)
  18098. }
  18099. return ids
  18100. }
  18101. return nil
  18102. }
  18103. // RemovedEdges returns all edge names that were removed in this mutation.
  18104. func (m *SopStageMutation) RemovedEdges() []string {
  18105. edges := make([]string, 0, 3)
  18106. if m.removedstage_nodes != nil {
  18107. edges = append(edges, sopstage.EdgeStageNodes)
  18108. }
  18109. if m.removedstage_messages != nil {
  18110. edges = append(edges, sopstage.EdgeStageMessages)
  18111. }
  18112. return edges
  18113. }
  18114. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18115. // the given name in this mutation.
  18116. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  18117. switch name {
  18118. case sopstage.EdgeStageNodes:
  18119. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  18120. for id := range m.removedstage_nodes {
  18121. ids = append(ids, id)
  18122. }
  18123. return ids
  18124. case sopstage.EdgeStageMessages:
  18125. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  18126. for id := range m.removedstage_messages {
  18127. ids = append(ids, id)
  18128. }
  18129. return ids
  18130. }
  18131. return nil
  18132. }
  18133. // ClearedEdges returns all edge names that were cleared in this mutation.
  18134. func (m *SopStageMutation) ClearedEdges() []string {
  18135. edges := make([]string, 0, 3)
  18136. if m.clearedsop_task {
  18137. edges = append(edges, sopstage.EdgeSopTask)
  18138. }
  18139. if m.clearedstage_nodes {
  18140. edges = append(edges, sopstage.EdgeStageNodes)
  18141. }
  18142. if m.clearedstage_messages {
  18143. edges = append(edges, sopstage.EdgeStageMessages)
  18144. }
  18145. return edges
  18146. }
  18147. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18148. // was cleared in this mutation.
  18149. func (m *SopStageMutation) EdgeCleared(name string) bool {
  18150. switch name {
  18151. case sopstage.EdgeSopTask:
  18152. return m.clearedsop_task
  18153. case sopstage.EdgeStageNodes:
  18154. return m.clearedstage_nodes
  18155. case sopstage.EdgeStageMessages:
  18156. return m.clearedstage_messages
  18157. }
  18158. return false
  18159. }
  18160. // ClearEdge clears the value of the edge with the given name. It returns an error
  18161. // if that edge is not defined in the schema.
  18162. func (m *SopStageMutation) ClearEdge(name string) error {
  18163. switch name {
  18164. case sopstage.EdgeSopTask:
  18165. m.ClearSopTask()
  18166. return nil
  18167. }
  18168. return fmt.Errorf("unknown SopStage unique edge %s", name)
  18169. }
  18170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18171. // It returns an error if the edge is not defined in the schema.
  18172. func (m *SopStageMutation) ResetEdge(name string) error {
  18173. switch name {
  18174. case sopstage.EdgeSopTask:
  18175. m.ResetSopTask()
  18176. return nil
  18177. case sopstage.EdgeStageNodes:
  18178. m.ResetStageNodes()
  18179. return nil
  18180. case sopstage.EdgeStageMessages:
  18181. m.ResetStageMessages()
  18182. return nil
  18183. }
  18184. return fmt.Errorf("unknown SopStage edge %s", name)
  18185. }
  18186. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  18187. type SopTaskMutation struct {
  18188. config
  18189. op Op
  18190. typ string
  18191. id *uint64
  18192. created_at *time.Time
  18193. updated_at *time.Time
  18194. status *uint8
  18195. addstatus *int8
  18196. deleted_at *time.Time
  18197. name *string
  18198. bot_wxid_list *[]string
  18199. appendbot_wxid_list []string
  18200. _type *int
  18201. add_type *int
  18202. plan_start_time *time.Time
  18203. plan_end_time *time.Time
  18204. creator_id *string
  18205. organization_id *uint64
  18206. addorganization_id *int64
  18207. clearedFields map[string]struct{}
  18208. task_stages map[uint64]struct{}
  18209. removedtask_stages map[uint64]struct{}
  18210. clearedtask_stages bool
  18211. done bool
  18212. oldValue func(context.Context) (*SopTask, error)
  18213. predicates []predicate.SopTask
  18214. }
  18215. var _ ent.Mutation = (*SopTaskMutation)(nil)
  18216. // soptaskOption allows management of the mutation configuration using functional options.
  18217. type soptaskOption func(*SopTaskMutation)
  18218. // newSopTaskMutation creates new mutation for the SopTask entity.
  18219. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  18220. m := &SopTaskMutation{
  18221. config: c,
  18222. op: op,
  18223. typ: TypeSopTask,
  18224. clearedFields: make(map[string]struct{}),
  18225. }
  18226. for _, opt := range opts {
  18227. opt(m)
  18228. }
  18229. return m
  18230. }
  18231. // withSopTaskID sets the ID field of the mutation.
  18232. func withSopTaskID(id uint64) soptaskOption {
  18233. return func(m *SopTaskMutation) {
  18234. var (
  18235. err error
  18236. once sync.Once
  18237. value *SopTask
  18238. )
  18239. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  18240. once.Do(func() {
  18241. if m.done {
  18242. err = errors.New("querying old values post mutation is not allowed")
  18243. } else {
  18244. value, err = m.Client().SopTask.Get(ctx, id)
  18245. }
  18246. })
  18247. return value, err
  18248. }
  18249. m.id = &id
  18250. }
  18251. }
  18252. // withSopTask sets the old SopTask of the mutation.
  18253. func withSopTask(node *SopTask) soptaskOption {
  18254. return func(m *SopTaskMutation) {
  18255. m.oldValue = func(context.Context) (*SopTask, error) {
  18256. return node, nil
  18257. }
  18258. m.id = &node.ID
  18259. }
  18260. }
  18261. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18262. // executed in a transaction (ent.Tx), a transactional client is returned.
  18263. func (m SopTaskMutation) Client() *Client {
  18264. client := &Client{config: m.config}
  18265. client.init()
  18266. return client
  18267. }
  18268. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18269. // it returns an error otherwise.
  18270. func (m SopTaskMutation) Tx() (*Tx, error) {
  18271. if _, ok := m.driver.(*txDriver); !ok {
  18272. return nil, errors.New("ent: mutation is not running in a transaction")
  18273. }
  18274. tx := &Tx{config: m.config}
  18275. tx.init()
  18276. return tx, nil
  18277. }
  18278. // SetID sets the value of the id field. Note that this
  18279. // operation is only accepted on creation of SopTask entities.
  18280. func (m *SopTaskMutation) SetID(id uint64) {
  18281. m.id = &id
  18282. }
  18283. // ID returns the ID value in the mutation. Note that the ID is only available
  18284. // if it was provided to the builder or after it was returned from the database.
  18285. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  18286. if m.id == nil {
  18287. return
  18288. }
  18289. return *m.id, true
  18290. }
  18291. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18292. // That means, if the mutation is applied within a transaction with an isolation level such
  18293. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18294. // or updated by the mutation.
  18295. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  18296. switch {
  18297. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18298. id, exists := m.ID()
  18299. if exists {
  18300. return []uint64{id}, nil
  18301. }
  18302. fallthrough
  18303. case m.op.Is(OpUpdate | OpDelete):
  18304. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  18305. default:
  18306. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18307. }
  18308. }
  18309. // SetCreatedAt sets the "created_at" field.
  18310. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  18311. m.created_at = &t
  18312. }
  18313. // CreatedAt returns the value of the "created_at" field in the mutation.
  18314. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  18315. v := m.created_at
  18316. if v == nil {
  18317. return
  18318. }
  18319. return *v, true
  18320. }
  18321. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  18322. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18324. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18325. if !m.op.Is(OpUpdateOne) {
  18326. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18327. }
  18328. if m.id == nil || m.oldValue == nil {
  18329. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18330. }
  18331. oldValue, err := m.oldValue(ctx)
  18332. if err != nil {
  18333. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18334. }
  18335. return oldValue.CreatedAt, nil
  18336. }
  18337. // ResetCreatedAt resets all changes to the "created_at" field.
  18338. func (m *SopTaskMutation) ResetCreatedAt() {
  18339. m.created_at = nil
  18340. }
  18341. // SetUpdatedAt sets the "updated_at" field.
  18342. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  18343. m.updated_at = &t
  18344. }
  18345. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18346. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  18347. v := m.updated_at
  18348. if v == nil {
  18349. return
  18350. }
  18351. return *v, true
  18352. }
  18353. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  18354. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18356. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18357. if !m.op.Is(OpUpdateOne) {
  18358. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18359. }
  18360. if m.id == nil || m.oldValue == nil {
  18361. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18362. }
  18363. oldValue, err := m.oldValue(ctx)
  18364. if err != nil {
  18365. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18366. }
  18367. return oldValue.UpdatedAt, nil
  18368. }
  18369. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18370. func (m *SopTaskMutation) ResetUpdatedAt() {
  18371. m.updated_at = nil
  18372. }
  18373. // SetStatus sets the "status" field.
  18374. func (m *SopTaskMutation) SetStatus(u uint8) {
  18375. m.status = &u
  18376. m.addstatus = nil
  18377. }
  18378. // Status returns the value of the "status" field in the mutation.
  18379. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  18380. v := m.status
  18381. if v == nil {
  18382. return
  18383. }
  18384. return *v, true
  18385. }
  18386. // OldStatus returns the old "status" field's value of the SopTask entity.
  18387. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18389. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18390. if !m.op.Is(OpUpdateOne) {
  18391. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18392. }
  18393. if m.id == nil || m.oldValue == nil {
  18394. return v, errors.New("OldStatus requires an ID field in the mutation")
  18395. }
  18396. oldValue, err := m.oldValue(ctx)
  18397. if err != nil {
  18398. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18399. }
  18400. return oldValue.Status, nil
  18401. }
  18402. // AddStatus adds u to the "status" field.
  18403. func (m *SopTaskMutation) AddStatus(u int8) {
  18404. if m.addstatus != nil {
  18405. *m.addstatus += u
  18406. } else {
  18407. m.addstatus = &u
  18408. }
  18409. }
  18410. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18411. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  18412. v := m.addstatus
  18413. if v == nil {
  18414. return
  18415. }
  18416. return *v, true
  18417. }
  18418. // ClearStatus clears the value of the "status" field.
  18419. func (m *SopTaskMutation) ClearStatus() {
  18420. m.status = nil
  18421. m.addstatus = nil
  18422. m.clearedFields[soptask.FieldStatus] = struct{}{}
  18423. }
  18424. // StatusCleared returns if the "status" field was cleared in this mutation.
  18425. func (m *SopTaskMutation) StatusCleared() bool {
  18426. _, ok := m.clearedFields[soptask.FieldStatus]
  18427. return ok
  18428. }
  18429. // ResetStatus resets all changes to the "status" field.
  18430. func (m *SopTaskMutation) ResetStatus() {
  18431. m.status = nil
  18432. m.addstatus = nil
  18433. delete(m.clearedFields, soptask.FieldStatus)
  18434. }
  18435. // SetDeletedAt sets the "deleted_at" field.
  18436. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  18437. m.deleted_at = &t
  18438. }
  18439. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18440. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  18441. v := m.deleted_at
  18442. if v == nil {
  18443. return
  18444. }
  18445. return *v, true
  18446. }
  18447. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  18448. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18450. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18451. if !m.op.Is(OpUpdateOne) {
  18452. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18453. }
  18454. if m.id == nil || m.oldValue == nil {
  18455. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18456. }
  18457. oldValue, err := m.oldValue(ctx)
  18458. if err != nil {
  18459. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18460. }
  18461. return oldValue.DeletedAt, nil
  18462. }
  18463. // ClearDeletedAt clears the value of the "deleted_at" field.
  18464. func (m *SopTaskMutation) ClearDeletedAt() {
  18465. m.deleted_at = nil
  18466. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  18467. }
  18468. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18469. func (m *SopTaskMutation) DeletedAtCleared() bool {
  18470. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  18471. return ok
  18472. }
  18473. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18474. func (m *SopTaskMutation) ResetDeletedAt() {
  18475. m.deleted_at = nil
  18476. delete(m.clearedFields, soptask.FieldDeletedAt)
  18477. }
  18478. // SetName sets the "name" field.
  18479. func (m *SopTaskMutation) SetName(s string) {
  18480. m.name = &s
  18481. }
  18482. // Name returns the value of the "name" field in the mutation.
  18483. func (m *SopTaskMutation) Name() (r string, exists bool) {
  18484. v := m.name
  18485. if v == nil {
  18486. return
  18487. }
  18488. return *v, true
  18489. }
  18490. // OldName returns the old "name" field's value of the SopTask entity.
  18491. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18493. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  18494. if !m.op.Is(OpUpdateOne) {
  18495. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18496. }
  18497. if m.id == nil || m.oldValue == nil {
  18498. return v, errors.New("OldName requires an ID field in the mutation")
  18499. }
  18500. oldValue, err := m.oldValue(ctx)
  18501. if err != nil {
  18502. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18503. }
  18504. return oldValue.Name, nil
  18505. }
  18506. // ResetName resets all changes to the "name" field.
  18507. func (m *SopTaskMutation) ResetName() {
  18508. m.name = nil
  18509. }
  18510. // SetBotWxidList sets the "bot_wxid_list" field.
  18511. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  18512. m.bot_wxid_list = &s
  18513. m.appendbot_wxid_list = nil
  18514. }
  18515. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  18516. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  18517. v := m.bot_wxid_list
  18518. if v == nil {
  18519. return
  18520. }
  18521. return *v, true
  18522. }
  18523. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  18524. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18526. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  18527. if !m.op.Is(OpUpdateOne) {
  18528. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  18529. }
  18530. if m.id == nil || m.oldValue == nil {
  18531. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  18532. }
  18533. oldValue, err := m.oldValue(ctx)
  18534. if err != nil {
  18535. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  18536. }
  18537. return oldValue.BotWxidList, nil
  18538. }
  18539. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  18540. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  18541. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  18542. }
  18543. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  18544. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  18545. if len(m.appendbot_wxid_list) == 0 {
  18546. return nil, false
  18547. }
  18548. return m.appendbot_wxid_list, true
  18549. }
  18550. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  18551. func (m *SopTaskMutation) ClearBotWxidList() {
  18552. m.bot_wxid_list = nil
  18553. m.appendbot_wxid_list = nil
  18554. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  18555. }
  18556. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  18557. func (m *SopTaskMutation) BotWxidListCleared() bool {
  18558. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  18559. return ok
  18560. }
  18561. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  18562. func (m *SopTaskMutation) ResetBotWxidList() {
  18563. m.bot_wxid_list = nil
  18564. m.appendbot_wxid_list = nil
  18565. delete(m.clearedFields, soptask.FieldBotWxidList)
  18566. }
  18567. // SetType sets the "type" field.
  18568. func (m *SopTaskMutation) SetType(i int) {
  18569. m._type = &i
  18570. m.add_type = nil
  18571. }
  18572. // GetType returns the value of the "type" field in the mutation.
  18573. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  18574. v := m._type
  18575. if v == nil {
  18576. return
  18577. }
  18578. return *v, true
  18579. }
  18580. // OldType returns the old "type" field's value of the SopTask entity.
  18581. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18583. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  18584. if !m.op.Is(OpUpdateOne) {
  18585. return v, errors.New("OldType is only allowed on UpdateOne operations")
  18586. }
  18587. if m.id == nil || m.oldValue == nil {
  18588. return v, errors.New("OldType requires an ID field in the mutation")
  18589. }
  18590. oldValue, err := m.oldValue(ctx)
  18591. if err != nil {
  18592. return v, fmt.Errorf("querying old value for OldType: %w", err)
  18593. }
  18594. return oldValue.Type, nil
  18595. }
  18596. // AddType adds i to the "type" field.
  18597. func (m *SopTaskMutation) AddType(i int) {
  18598. if m.add_type != nil {
  18599. *m.add_type += i
  18600. } else {
  18601. m.add_type = &i
  18602. }
  18603. }
  18604. // AddedType returns the value that was added to the "type" field in this mutation.
  18605. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  18606. v := m.add_type
  18607. if v == nil {
  18608. return
  18609. }
  18610. return *v, true
  18611. }
  18612. // ResetType resets all changes to the "type" field.
  18613. func (m *SopTaskMutation) ResetType() {
  18614. m._type = nil
  18615. m.add_type = nil
  18616. }
  18617. // SetPlanStartTime sets the "plan_start_time" field.
  18618. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  18619. m.plan_start_time = &t
  18620. }
  18621. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  18622. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  18623. v := m.plan_start_time
  18624. if v == nil {
  18625. return
  18626. }
  18627. return *v, true
  18628. }
  18629. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  18630. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18632. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  18633. if !m.op.Is(OpUpdateOne) {
  18634. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  18635. }
  18636. if m.id == nil || m.oldValue == nil {
  18637. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  18638. }
  18639. oldValue, err := m.oldValue(ctx)
  18640. if err != nil {
  18641. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  18642. }
  18643. return oldValue.PlanStartTime, nil
  18644. }
  18645. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  18646. func (m *SopTaskMutation) ClearPlanStartTime() {
  18647. m.plan_start_time = nil
  18648. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  18649. }
  18650. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  18651. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  18652. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  18653. return ok
  18654. }
  18655. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  18656. func (m *SopTaskMutation) ResetPlanStartTime() {
  18657. m.plan_start_time = nil
  18658. delete(m.clearedFields, soptask.FieldPlanStartTime)
  18659. }
  18660. // SetPlanEndTime sets the "plan_end_time" field.
  18661. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  18662. m.plan_end_time = &t
  18663. }
  18664. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  18665. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  18666. v := m.plan_end_time
  18667. if v == nil {
  18668. return
  18669. }
  18670. return *v, true
  18671. }
  18672. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  18673. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18675. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  18676. if !m.op.Is(OpUpdateOne) {
  18677. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  18678. }
  18679. if m.id == nil || m.oldValue == nil {
  18680. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  18681. }
  18682. oldValue, err := m.oldValue(ctx)
  18683. if err != nil {
  18684. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  18685. }
  18686. return oldValue.PlanEndTime, nil
  18687. }
  18688. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  18689. func (m *SopTaskMutation) ClearPlanEndTime() {
  18690. m.plan_end_time = nil
  18691. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  18692. }
  18693. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  18694. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  18695. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  18696. return ok
  18697. }
  18698. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  18699. func (m *SopTaskMutation) ResetPlanEndTime() {
  18700. m.plan_end_time = nil
  18701. delete(m.clearedFields, soptask.FieldPlanEndTime)
  18702. }
  18703. // SetCreatorID sets the "creator_id" field.
  18704. func (m *SopTaskMutation) SetCreatorID(s string) {
  18705. m.creator_id = &s
  18706. }
  18707. // CreatorID returns the value of the "creator_id" field in the mutation.
  18708. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  18709. v := m.creator_id
  18710. if v == nil {
  18711. return
  18712. }
  18713. return *v, true
  18714. }
  18715. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  18716. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18718. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  18719. if !m.op.Is(OpUpdateOne) {
  18720. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  18721. }
  18722. if m.id == nil || m.oldValue == nil {
  18723. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  18724. }
  18725. oldValue, err := m.oldValue(ctx)
  18726. if err != nil {
  18727. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  18728. }
  18729. return oldValue.CreatorID, nil
  18730. }
  18731. // ClearCreatorID clears the value of the "creator_id" field.
  18732. func (m *SopTaskMutation) ClearCreatorID() {
  18733. m.creator_id = nil
  18734. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  18735. }
  18736. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  18737. func (m *SopTaskMutation) CreatorIDCleared() bool {
  18738. _, ok := m.clearedFields[soptask.FieldCreatorID]
  18739. return ok
  18740. }
  18741. // ResetCreatorID resets all changes to the "creator_id" field.
  18742. func (m *SopTaskMutation) ResetCreatorID() {
  18743. m.creator_id = nil
  18744. delete(m.clearedFields, soptask.FieldCreatorID)
  18745. }
  18746. // SetOrganizationID sets the "organization_id" field.
  18747. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  18748. m.organization_id = &u
  18749. m.addorganization_id = nil
  18750. }
  18751. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18752. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  18753. v := m.organization_id
  18754. if v == nil {
  18755. return
  18756. }
  18757. return *v, true
  18758. }
  18759. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  18760. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18762. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18763. if !m.op.Is(OpUpdateOne) {
  18764. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18765. }
  18766. if m.id == nil || m.oldValue == nil {
  18767. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18768. }
  18769. oldValue, err := m.oldValue(ctx)
  18770. if err != nil {
  18771. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18772. }
  18773. return oldValue.OrganizationID, nil
  18774. }
  18775. // AddOrganizationID adds u to the "organization_id" field.
  18776. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  18777. if m.addorganization_id != nil {
  18778. *m.addorganization_id += u
  18779. } else {
  18780. m.addorganization_id = &u
  18781. }
  18782. }
  18783. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18784. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  18785. v := m.addorganization_id
  18786. if v == nil {
  18787. return
  18788. }
  18789. return *v, true
  18790. }
  18791. // ClearOrganizationID clears the value of the "organization_id" field.
  18792. func (m *SopTaskMutation) ClearOrganizationID() {
  18793. m.organization_id = nil
  18794. m.addorganization_id = nil
  18795. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  18796. }
  18797. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18798. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  18799. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  18800. return ok
  18801. }
  18802. // ResetOrganizationID resets all changes to the "organization_id" field.
  18803. func (m *SopTaskMutation) ResetOrganizationID() {
  18804. m.organization_id = nil
  18805. m.addorganization_id = nil
  18806. delete(m.clearedFields, soptask.FieldOrganizationID)
  18807. }
  18808. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  18809. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  18810. if m.task_stages == nil {
  18811. m.task_stages = make(map[uint64]struct{})
  18812. }
  18813. for i := range ids {
  18814. m.task_stages[ids[i]] = struct{}{}
  18815. }
  18816. }
  18817. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  18818. func (m *SopTaskMutation) ClearTaskStages() {
  18819. m.clearedtask_stages = true
  18820. }
  18821. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  18822. func (m *SopTaskMutation) TaskStagesCleared() bool {
  18823. return m.clearedtask_stages
  18824. }
  18825. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  18826. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  18827. if m.removedtask_stages == nil {
  18828. m.removedtask_stages = make(map[uint64]struct{})
  18829. }
  18830. for i := range ids {
  18831. delete(m.task_stages, ids[i])
  18832. m.removedtask_stages[ids[i]] = struct{}{}
  18833. }
  18834. }
  18835. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  18836. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  18837. for id := range m.removedtask_stages {
  18838. ids = append(ids, id)
  18839. }
  18840. return
  18841. }
  18842. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  18843. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  18844. for id := range m.task_stages {
  18845. ids = append(ids, id)
  18846. }
  18847. return
  18848. }
  18849. // ResetTaskStages resets all changes to the "task_stages" edge.
  18850. func (m *SopTaskMutation) ResetTaskStages() {
  18851. m.task_stages = nil
  18852. m.clearedtask_stages = false
  18853. m.removedtask_stages = nil
  18854. }
  18855. // Where appends a list predicates to the SopTaskMutation builder.
  18856. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  18857. m.predicates = append(m.predicates, ps...)
  18858. }
  18859. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  18860. // users can use type-assertion to append predicates that do not depend on any generated package.
  18861. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  18862. p := make([]predicate.SopTask, len(ps))
  18863. for i := range ps {
  18864. p[i] = ps[i]
  18865. }
  18866. m.Where(p...)
  18867. }
  18868. // Op returns the operation name.
  18869. func (m *SopTaskMutation) Op() Op {
  18870. return m.op
  18871. }
  18872. // SetOp allows setting the mutation operation.
  18873. func (m *SopTaskMutation) SetOp(op Op) {
  18874. m.op = op
  18875. }
  18876. // Type returns the node type of this mutation (SopTask).
  18877. func (m *SopTaskMutation) Type() string {
  18878. return m.typ
  18879. }
  18880. // Fields returns all fields that were changed during this mutation. Note that in
  18881. // order to get all numeric fields that were incremented/decremented, call
  18882. // AddedFields().
  18883. func (m *SopTaskMutation) Fields() []string {
  18884. fields := make([]string, 0, 11)
  18885. if m.created_at != nil {
  18886. fields = append(fields, soptask.FieldCreatedAt)
  18887. }
  18888. if m.updated_at != nil {
  18889. fields = append(fields, soptask.FieldUpdatedAt)
  18890. }
  18891. if m.status != nil {
  18892. fields = append(fields, soptask.FieldStatus)
  18893. }
  18894. if m.deleted_at != nil {
  18895. fields = append(fields, soptask.FieldDeletedAt)
  18896. }
  18897. if m.name != nil {
  18898. fields = append(fields, soptask.FieldName)
  18899. }
  18900. if m.bot_wxid_list != nil {
  18901. fields = append(fields, soptask.FieldBotWxidList)
  18902. }
  18903. if m._type != nil {
  18904. fields = append(fields, soptask.FieldType)
  18905. }
  18906. if m.plan_start_time != nil {
  18907. fields = append(fields, soptask.FieldPlanStartTime)
  18908. }
  18909. if m.plan_end_time != nil {
  18910. fields = append(fields, soptask.FieldPlanEndTime)
  18911. }
  18912. if m.creator_id != nil {
  18913. fields = append(fields, soptask.FieldCreatorID)
  18914. }
  18915. if m.organization_id != nil {
  18916. fields = append(fields, soptask.FieldOrganizationID)
  18917. }
  18918. return fields
  18919. }
  18920. // Field returns the value of a field with the given name. The second boolean
  18921. // return value indicates that this field was not set, or was not defined in the
  18922. // schema.
  18923. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  18924. switch name {
  18925. case soptask.FieldCreatedAt:
  18926. return m.CreatedAt()
  18927. case soptask.FieldUpdatedAt:
  18928. return m.UpdatedAt()
  18929. case soptask.FieldStatus:
  18930. return m.Status()
  18931. case soptask.FieldDeletedAt:
  18932. return m.DeletedAt()
  18933. case soptask.FieldName:
  18934. return m.Name()
  18935. case soptask.FieldBotWxidList:
  18936. return m.BotWxidList()
  18937. case soptask.FieldType:
  18938. return m.GetType()
  18939. case soptask.FieldPlanStartTime:
  18940. return m.PlanStartTime()
  18941. case soptask.FieldPlanEndTime:
  18942. return m.PlanEndTime()
  18943. case soptask.FieldCreatorID:
  18944. return m.CreatorID()
  18945. case soptask.FieldOrganizationID:
  18946. return m.OrganizationID()
  18947. }
  18948. return nil, false
  18949. }
  18950. // OldField returns the old value of the field from the database. An error is
  18951. // returned if the mutation operation is not UpdateOne, or the query to the
  18952. // database failed.
  18953. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18954. switch name {
  18955. case soptask.FieldCreatedAt:
  18956. return m.OldCreatedAt(ctx)
  18957. case soptask.FieldUpdatedAt:
  18958. return m.OldUpdatedAt(ctx)
  18959. case soptask.FieldStatus:
  18960. return m.OldStatus(ctx)
  18961. case soptask.FieldDeletedAt:
  18962. return m.OldDeletedAt(ctx)
  18963. case soptask.FieldName:
  18964. return m.OldName(ctx)
  18965. case soptask.FieldBotWxidList:
  18966. return m.OldBotWxidList(ctx)
  18967. case soptask.FieldType:
  18968. return m.OldType(ctx)
  18969. case soptask.FieldPlanStartTime:
  18970. return m.OldPlanStartTime(ctx)
  18971. case soptask.FieldPlanEndTime:
  18972. return m.OldPlanEndTime(ctx)
  18973. case soptask.FieldCreatorID:
  18974. return m.OldCreatorID(ctx)
  18975. case soptask.FieldOrganizationID:
  18976. return m.OldOrganizationID(ctx)
  18977. }
  18978. return nil, fmt.Errorf("unknown SopTask field %s", name)
  18979. }
  18980. // SetField sets the value of a field with the given name. It returns an error if
  18981. // the field is not defined in the schema, or if the type mismatched the field
  18982. // type.
  18983. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  18984. switch name {
  18985. case soptask.FieldCreatedAt:
  18986. v, ok := value.(time.Time)
  18987. if !ok {
  18988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18989. }
  18990. m.SetCreatedAt(v)
  18991. return nil
  18992. case soptask.FieldUpdatedAt:
  18993. v, ok := value.(time.Time)
  18994. if !ok {
  18995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18996. }
  18997. m.SetUpdatedAt(v)
  18998. return nil
  18999. case soptask.FieldStatus:
  19000. v, ok := value.(uint8)
  19001. if !ok {
  19002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19003. }
  19004. m.SetStatus(v)
  19005. return nil
  19006. case soptask.FieldDeletedAt:
  19007. v, ok := value.(time.Time)
  19008. if !ok {
  19009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19010. }
  19011. m.SetDeletedAt(v)
  19012. return nil
  19013. case soptask.FieldName:
  19014. v, ok := value.(string)
  19015. if !ok {
  19016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19017. }
  19018. m.SetName(v)
  19019. return nil
  19020. case soptask.FieldBotWxidList:
  19021. v, ok := value.([]string)
  19022. if !ok {
  19023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19024. }
  19025. m.SetBotWxidList(v)
  19026. return nil
  19027. case soptask.FieldType:
  19028. v, ok := value.(int)
  19029. if !ok {
  19030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19031. }
  19032. m.SetType(v)
  19033. return nil
  19034. case soptask.FieldPlanStartTime:
  19035. v, ok := value.(time.Time)
  19036. if !ok {
  19037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19038. }
  19039. m.SetPlanStartTime(v)
  19040. return nil
  19041. case soptask.FieldPlanEndTime:
  19042. v, ok := value.(time.Time)
  19043. if !ok {
  19044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19045. }
  19046. m.SetPlanEndTime(v)
  19047. return nil
  19048. case soptask.FieldCreatorID:
  19049. v, ok := value.(string)
  19050. if !ok {
  19051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19052. }
  19053. m.SetCreatorID(v)
  19054. return nil
  19055. case soptask.FieldOrganizationID:
  19056. v, ok := value.(uint64)
  19057. if !ok {
  19058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19059. }
  19060. m.SetOrganizationID(v)
  19061. return nil
  19062. }
  19063. return fmt.Errorf("unknown SopTask field %s", name)
  19064. }
  19065. // AddedFields returns all numeric fields that were incremented/decremented during
  19066. // this mutation.
  19067. func (m *SopTaskMutation) AddedFields() []string {
  19068. var fields []string
  19069. if m.addstatus != nil {
  19070. fields = append(fields, soptask.FieldStatus)
  19071. }
  19072. if m.add_type != nil {
  19073. fields = append(fields, soptask.FieldType)
  19074. }
  19075. if m.addorganization_id != nil {
  19076. fields = append(fields, soptask.FieldOrganizationID)
  19077. }
  19078. return fields
  19079. }
  19080. // AddedField returns the numeric value that was incremented/decremented on a field
  19081. // with the given name. The second boolean return value indicates that this field
  19082. // was not set, or was not defined in the schema.
  19083. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  19084. switch name {
  19085. case soptask.FieldStatus:
  19086. return m.AddedStatus()
  19087. case soptask.FieldType:
  19088. return m.AddedType()
  19089. case soptask.FieldOrganizationID:
  19090. return m.AddedOrganizationID()
  19091. }
  19092. return nil, false
  19093. }
  19094. // AddField adds the value to the field with the given name. It returns an error if
  19095. // the field is not defined in the schema, or if the type mismatched the field
  19096. // type.
  19097. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  19098. switch name {
  19099. case soptask.FieldStatus:
  19100. v, ok := value.(int8)
  19101. if !ok {
  19102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19103. }
  19104. m.AddStatus(v)
  19105. return nil
  19106. case soptask.FieldType:
  19107. v, ok := value.(int)
  19108. if !ok {
  19109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19110. }
  19111. m.AddType(v)
  19112. return nil
  19113. case soptask.FieldOrganizationID:
  19114. v, ok := value.(int64)
  19115. if !ok {
  19116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19117. }
  19118. m.AddOrganizationID(v)
  19119. return nil
  19120. }
  19121. return fmt.Errorf("unknown SopTask numeric field %s", name)
  19122. }
  19123. // ClearedFields returns all nullable fields that were cleared during this
  19124. // mutation.
  19125. func (m *SopTaskMutation) ClearedFields() []string {
  19126. var fields []string
  19127. if m.FieldCleared(soptask.FieldStatus) {
  19128. fields = append(fields, soptask.FieldStatus)
  19129. }
  19130. if m.FieldCleared(soptask.FieldDeletedAt) {
  19131. fields = append(fields, soptask.FieldDeletedAt)
  19132. }
  19133. if m.FieldCleared(soptask.FieldBotWxidList) {
  19134. fields = append(fields, soptask.FieldBotWxidList)
  19135. }
  19136. if m.FieldCleared(soptask.FieldPlanStartTime) {
  19137. fields = append(fields, soptask.FieldPlanStartTime)
  19138. }
  19139. if m.FieldCleared(soptask.FieldPlanEndTime) {
  19140. fields = append(fields, soptask.FieldPlanEndTime)
  19141. }
  19142. if m.FieldCleared(soptask.FieldCreatorID) {
  19143. fields = append(fields, soptask.FieldCreatorID)
  19144. }
  19145. if m.FieldCleared(soptask.FieldOrganizationID) {
  19146. fields = append(fields, soptask.FieldOrganizationID)
  19147. }
  19148. return fields
  19149. }
  19150. // FieldCleared returns a boolean indicating if a field with the given name was
  19151. // cleared in this mutation.
  19152. func (m *SopTaskMutation) FieldCleared(name string) bool {
  19153. _, ok := m.clearedFields[name]
  19154. return ok
  19155. }
  19156. // ClearField clears the value of the field with the given name. It returns an
  19157. // error if the field is not defined in the schema.
  19158. func (m *SopTaskMutation) ClearField(name string) error {
  19159. switch name {
  19160. case soptask.FieldStatus:
  19161. m.ClearStatus()
  19162. return nil
  19163. case soptask.FieldDeletedAt:
  19164. m.ClearDeletedAt()
  19165. return nil
  19166. case soptask.FieldBotWxidList:
  19167. m.ClearBotWxidList()
  19168. return nil
  19169. case soptask.FieldPlanStartTime:
  19170. m.ClearPlanStartTime()
  19171. return nil
  19172. case soptask.FieldPlanEndTime:
  19173. m.ClearPlanEndTime()
  19174. return nil
  19175. case soptask.FieldCreatorID:
  19176. m.ClearCreatorID()
  19177. return nil
  19178. case soptask.FieldOrganizationID:
  19179. m.ClearOrganizationID()
  19180. return nil
  19181. }
  19182. return fmt.Errorf("unknown SopTask nullable field %s", name)
  19183. }
  19184. // ResetField resets all changes in the mutation for the field with the given name.
  19185. // It returns an error if the field is not defined in the schema.
  19186. func (m *SopTaskMutation) ResetField(name string) error {
  19187. switch name {
  19188. case soptask.FieldCreatedAt:
  19189. m.ResetCreatedAt()
  19190. return nil
  19191. case soptask.FieldUpdatedAt:
  19192. m.ResetUpdatedAt()
  19193. return nil
  19194. case soptask.FieldStatus:
  19195. m.ResetStatus()
  19196. return nil
  19197. case soptask.FieldDeletedAt:
  19198. m.ResetDeletedAt()
  19199. return nil
  19200. case soptask.FieldName:
  19201. m.ResetName()
  19202. return nil
  19203. case soptask.FieldBotWxidList:
  19204. m.ResetBotWxidList()
  19205. return nil
  19206. case soptask.FieldType:
  19207. m.ResetType()
  19208. return nil
  19209. case soptask.FieldPlanStartTime:
  19210. m.ResetPlanStartTime()
  19211. return nil
  19212. case soptask.FieldPlanEndTime:
  19213. m.ResetPlanEndTime()
  19214. return nil
  19215. case soptask.FieldCreatorID:
  19216. m.ResetCreatorID()
  19217. return nil
  19218. case soptask.FieldOrganizationID:
  19219. m.ResetOrganizationID()
  19220. return nil
  19221. }
  19222. return fmt.Errorf("unknown SopTask field %s", name)
  19223. }
  19224. // AddedEdges returns all edge names that were set/added in this mutation.
  19225. func (m *SopTaskMutation) AddedEdges() []string {
  19226. edges := make([]string, 0, 1)
  19227. if m.task_stages != nil {
  19228. edges = append(edges, soptask.EdgeTaskStages)
  19229. }
  19230. return edges
  19231. }
  19232. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19233. // name in this mutation.
  19234. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  19235. switch name {
  19236. case soptask.EdgeTaskStages:
  19237. ids := make([]ent.Value, 0, len(m.task_stages))
  19238. for id := range m.task_stages {
  19239. ids = append(ids, id)
  19240. }
  19241. return ids
  19242. }
  19243. return nil
  19244. }
  19245. // RemovedEdges returns all edge names that were removed in this mutation.
  19246. func (m *SopTaskMutation) RemovedEdges() []string {
  19247. edges := make([]string, 0, 1)
  19248. if m.removedtask_stages != nil {
  19249. edges = append(edges, soptask.EdgeTaskStages)
  19250. }
  19251. return edges
  19252. }
  19253. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19254. // the given name in this mutation.
  19255. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  19256. switch name {
  19257. case soptask.EdgeTaskStages:
  19258. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  19259. for id := range m.removedtask_stages {
  19260. ids = append(ids, id)
  19261. }
  19262. return ids
  19263. }
  19264. return nil
  19265. }
  19266. // ClearedEdges returns all edge names that were cleared in this mutation.
  19267. func (m *SopTaskMutation) ClearedEdges() []string {
  19268. edges := make([]string, 0, 1)
  19269. if m.clearedtask_stages {
  19270. edges = append(edges, soptask.EdgeTaskStages)
  19271. }
  19272. return edges
  19273. }
  19274. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19275. // was cleared in this mutation.
  19276. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  19277. switch name {
  19278. case soptask.EdgeTaskStages:
  19279. return m.clearedtask_stages
  19280. }
  19281. return false
  19282. }
  19283. // ClearEdge clears the value of the edge with the given name. It returns an error
  19284. // if that edge is not defined in the schema.
  19285. func (m *SopTaskMutation) ClearEdge(name string) error {
  19286. switch name {
  19287. }
  19288. return fmt.Errorf("unknown SopTask unique edge %s", name)
  19289. }
  19290. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19291. // It returns an error if the edge is not defined in the schema.
  19292. func (m *SopTaskMutation) ResetEdge(name string) error {
  19293. switch name {
  19294. case soptask.EdgeTaskStages:
  19295. m.ResetTaskStages()
  19296. return nil
  19297. }
  19298. return fmt.Errorf("unknown SopTask edge %s", name)
  19299. }
  19300. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  19301. type TokenMutation struct {
  19302. config
  19303. op Op
  19304. typ string
  19305. id *uint64
  19306. created_at *time.Time
  19307. updated_at *time.Time
  19308. deleted_at *time.Time
  19309. expire_at *time.Time
  19310. token *string
  19311. mac *string
  19312. clearedFields map[string]struct{}
  19313. done bool
  19314. oldValue func(context.Context) (*Token, error)
  19315. predicates []predicate.Token
  19316. }
  19317. var _ ent.Mutation = (*TokenMutation)(nil)
  19318. // tokenOption allows management of the mutation configuration using functional options.
  19319. type tokenOption func(*TokenMutation)
  19320. // newTokenMutation creates new mutation for the Token entity.
  19321. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  19322. m := &TokenMutation{
  19323. config: c,
  19324. op: op,
  19325. typ: TypeToken,
  19326. clearedFields: make(map[string]struct{}),
  19327. }
  19328. for _, opt := range opts {
  19329. opt(m)
  19330. }
  19331. return m
  19332. }
  19333. // withTokenID sets the ID field of the mutation.
  19334. func withTokenID(id uint64) tokenOption {
  19335. return func(m *TokenMutation) {
  19336. var (
  19337. err error
  19338. once sync.Once
  19339. value *Token
  19340. )
  19341. m.oldValue = func(ctx context.Context) (*Token, error) {
  19342. once.Do(func() {
  19343. if m.done {
  19344. err = errors.New("querying old values post mutation is not allowed")
  19345. } else {
  19346. value, err = m.Client().Token.Get(ctx, id)
  19347. }
  19348. })
  19349. return value, err
  19350. }
  19351. m.id = &id
  19352. }
  19353. }
  19354. // withToken sets the old Token of the mutation.
  19355. func withToken(node *Token) tokenOption {
  19356. return func(m *TokenMutation) {
  19357. m.oldValue = func(context.Context) (*Token, error) {
  19358. return node, nil
  19359. }
  19360. m.id = &node.ID
  19361. }
  19362. }
  19363. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19364. // executed in a transaction (ent.Tx), a transactional client is returned.
  19365. func (m TokenMutation) Client() *Client {
  19366. client := &Client{config: m.config}
  19367. client.init()
  19368. return client
  19369. }
  19370. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19371. // it returns an error otherwise.
  19372. func (m TokenMutation) Tx() (*Tx, error) {
  19373. if _, ok := m.driver.(*txDriver); !ok {
  19374. return nil, errors.New("ent: mutation is not running in a transaction")
  19375. }
  19376. tx := &Tx{config: m.config}
  19377. tx.init()
  19378. return tx, nil
  19379. }
  19380. // SetID sets the value of the id field. Note that this
  19381. // operation is only accepted on creation of Token entities.
  19382. func (m *TokenMutation) SetID(id uint64) {
  19383. m.id = &id
  19384. }
  19385. // ID returns the ID value in the mutation. Note that the ID is only available
  19386. // if it was provided to the builder or after it was returned from the database.
  19387. func (m *TokenMutation) ID() (id uint64, exists bool) {
  19388. if m.id == nil {
  19389. return
  19390. }
  19391. return *m.id, true
  19392. }
  19393. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19394. // That means, if the mutation is applied within a transaction with an isolation level such
  19395. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19396. // or updated by the mutation.
  19397. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  19398. switch {
  19399. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19400. id, exists := m.ID()
  19401. if exists {
  19402. return []uint64{id}, nil
  19403. }
  19404. fallthrough
  19405. case m.op.Is(OpUpdate | OpDelete):
  19406. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  19407. default:
  19408. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19409. }
  19410. }
  19411. // SetCreatedAt sets the "created_at" field.
  19412. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  19413. m.created_at = &t
  19414. }
  19415. // CreatedAt returns the value of the "created_at" field in the mutation.
  19416. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  19417. v := m.created_at
  19418. if v == nil {
  19419. return
  19420. }
  19421. return *v, true
  19422. }
  19423. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  19424. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19426. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19427. if !m.op.Is(OpUpdateOne) {
  19428. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19429. }
  19430. if m.id == nil || m.oldValue == nil {
  19431. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19432. }
  19433. oldValue, err := m.oldValue(ctx)
  19434. if err != nil {
  19435. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19436. }
  19437. return oldValue.CreatedAt, nil
  19438. }
  19439. // ResetCreatedAt resets all changes to the "created_at" field.
  19440. func (m *TokenMutation) ResetCreatedAt() {
  19441. m.created_at = nil
  19442. }
  19443. // SetUpdatedAt sets the "updated_at" field.
  19444. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  19445. m.updated_at = &t
  19446. }
  19447. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19448. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  19449. v := m.updated_at
  19450. if v == nil {
  19451. return
  19452. }
  19453. return *v, true
  19454. }
  19455. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  19456. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19458. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19459. if !m.op.Is(OpUpdateOne) {
  19460. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19461. }
  19462. if m.id == nil || m.oldValue == nil {
  19463. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19464. }
  19465. oldValue, err := m.oldValue(ctx)
  19466. if err != nil {
  19467. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19468. }
  19469. return oldValue.UpdatedAt, nil
  19470. }
  19471. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19472. func (m *TokenMutation) ResetUpdatedAt() {
  19473. m.updated_at = nil
  19474. }
  19475. // SetDeletedAt sets the "deleted_at" field.
  19476. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  19477. m.deleted_at = &t
  19478. }
  19479. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19480. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  19481. v := m.deleted_at
  19482. if v == nil {
  19483. return
  19484. }
  19485. return *v, true
  19486. }
  19487. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  19488. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19490. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19491. if !m.op.Is(OpUpdateOne) {
  19492. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19493. }
  19494. if m.id == nil || m.oldValue == nil {
  19495. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19496. }
  19497. oldValue, err := m.oldValue(ctx)
  19498. if err != nil {
  19499. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19500. }
  19501. return oldValue.DeletedAt, nil
  19502. }
  19503. // ClearDeletedAt clears the value of the "deleted_at" field.
  19504. func (m *TokenMutation) ClearDeletedAt() {
  19505. m.deleted_at = nil
  19506. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  19507. }
  19508. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19509. func (m *TokenMutation) DeletedAtCleared() bool {
  19510. _, ok := m.clearedFields[token.FieldDeletedAt]
  19511. return ok
  19512. }
  19513. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19514. func (m *TokenMutation) ResetDeletedAt() {
  19515. m.deleted_at = nil
  19516. delete(m.clearedFields, token.FieldDeletedAt)
  19517. }
  19518. // SetExpireAt sets the "expire_at" field.
  19519. func (m *TokenMutation) SetExpireAt(t time.Time) {
  19520. m.expire_at = &t
  19521. }
  19522. // ExpireAt returns the value of the "expire_at" field in the mutation.
  19523. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  19524. v := m.expire_at
  19525. if v == nil {
  19526. return
  19527. }
  19528. return *v, true
  19529. }
  19530. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  19531. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19533. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  19534. if !m.op.Is(OpUpdateOne) {
  19535. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  19536. }
  19537. if m.id == nil || m.oldValue == nil {
  19538. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  19539. }
  19540. oldValue, err := m.oldValue(ctx)
  19541. if err != nil {
  19542. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  19543. }
  19544. return oldValue.ExpireAt, nil
  19545. }
  19546. // ClearExpireAt clears the value of the "expire_at" field.
  19547. func (m *TokenMutation) ClearExpireAt() {
  19548. m.expire_at = nil
  19549. m.clearedFields[token.FieldExpireAt] = struct{}{}
  19550. }
  19551. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  19552. func (m *TokenMutation) ExpireAtCleared() bool {
  19553. _, ok := m.clearedFields[token.FieldExpireAt]
  19554. return ok
  19555. }
  19556. // ResetExpireAt resets all changes to the "expire_at" field.
  19557. func (m *TokenMutation) ResetExpireAt() {
  19558. m.expire_at = nil
  19559. delete(m.clearedFields, token.FieldExpireAt)
  19560. }
  19561. // SetToken sets the "token" field.
  19562. func (m *TokenMutation) SetToken(s string) {
  19563. m.token = &s
  19564. }
  19565. // Token returns the value of the "token" field in the mutation.
  19566. func (m *TokenMutation) Token() (r string, exists bool) {
  19567. v := m.token
  19568. if v == nil {
  19569. return
  19570. }
  19571. return *v, true
  19572. }
  19573. // OldToken returns the old "token" field's value of the Token entity.
  19574. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19576. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  19577. if !m.op.Is(OpUpdateOne) {
  19578. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  19579. }
  19580. if m.id == nil || m.oldValue == nil {
  19581. return v, errors.New("OldToken requires an ID field in the mutation")
  19582. }
  19583. oldValue, err := m.oldValue(ctx)
  19584. if err != nil {
  19585. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  19586. }
  19587. return oldValue.Token, nil
  19588. }
  19589. // ClearToken clears the value of the "token" field.
  19590. func (m *TokenMutation) ClearToken() {
  19591. m.token = nil
  19592. m.clearedFields[token.FieldToken] = struct{}{}
  19593. }
  19594. // TokenCleared returns if the "token" field was cleared in this mutation.
  19595. func (m *TokenMutation) TokenCleared() bool {
  19596. _, ok := m.clearedFields[token.FieldToken]
  19597. return ok
  19598. }
  19599. // ResetToken resets all changes to the "token" field.
  19600. func (m *TokenMutation) ResetToken() {
  19601. m.token = nil
  19602. delete(m.clearedFields, token.FieldToken)
  19603. }
  19604. // SetMAC sets the "mac" field.
  19605. func (m *TokenMutation) SetMAC(s string) {
  19606. m.mac = &s
  19607. }
  19608. // MAC returns the value of the "mac" field in the mutation.
  19609. func (m *TokenMutation) MAC() (r string, exists bool) {
  19610. v := m.mac
  19611. if v == nil {
  19612. return
  19613. }
  19614. return *v, true
  19615. }
  19616. // OldMAC returns the old "mac" field's value of the Token entity.
  19617. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19619. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  19620. if !m.op.Is(OpUpdateOne) {
  19621. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  19622. }
  19623. if m.id == nil || m.oldValue == nil {
  19624. return v, errors.New("OldMAC requires an ID field in the mutation")
  19625. }
  19626. oldValue, err := m.oldValue(ctx)
  19627. if err != nil {
  19628. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  19629. }
  19630. return oldValue.MAC, nil
  19631. }
  19632. // ResetMAC resets all changes to the "mac" field.
  19633. func (m *TokenMutation) ResetMAC() {
  19634. m.mac = nil
  19635. }
  19636. // Where appends a list predicates to the TokenMutation builder.
  19637. func (m *TokenMutation) Where(ps ...predicate.Token) {
  19638. m.predicates = append(m.predicates, ps...)
  19639. }
  19640. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  19641. // users can use type-assertion to append predicates that do not depend on any generated package.
  19642. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  19643. p := make([]predicate.Token, len(ps))
  19644. for i := range ps {
  19645. p[i] = ps[i]
  19646. }
  19647. m.Where(p...)
  19648. }
  19649. // Op returns the operation name.
  19650. func (m *TokenMutation) Op() Op {
  19651. return m.op
  19652. }
  19653. // SetOp allows setting the mutation operation.
  19654. func (m *TokenMutation) SetOp(op Op) {
  19655. m.op = op
  19656. }
  19657. // Type returns the node type of this mutation (Token).
  19658. func (m *TokenMutation) Type() string {
  19659. return m.typ
  19660. }
  19661. // Fields returns all fields that were changed during this mutation. Note that in
  19662. // order to get all numeric fields that were incremented/decremented, call
  19663. // AddedFields().
  19664. func (m *TokenMutation) Fields() []string {
  19665. fields := make([]string, 0, 6)
  19666. if m.created_at != nil {
  19667. fields = append(fields, token.FieldCreatedAt)
  19668. }
  19669. if m.updated_at != nil {
  19670. fields = append(fields, token.FieldUpdatedAt)
  19671. }
  19672. if m.deleted_at != nil {
  19673. fields = append(fields, token.FieldDeletedAt)
  19674. }
  19675. if m.expire_at != nil {
  19676. fields = append(fields, token.FieldExpireAt)
  19677. }
  19678. if m.token != nil {
  19679. fields = append(fields, token.FieldToken)
  19680. }
  19681. if m.mac != nil {
  19682. fields = append(fields, token.FieldMAC)
  19683. }
  19684. return fields
  19685. }
  19686. // Field returns the value of a field with the given name. The second boolean
  19687. // return value indicates that this field was not set, or was not defined in the
  19688. // schema.
  19689. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  19690. switch name {
  19691. case token.FieldCreatedAt:
  19692. return m.CreatedAt()
  19693. case token.FieldUpdatedAt:
  19694. return m.UpdatedAt()
  19695. case token.FieldDeletedAt:
  19696. return m.DeletedAt()
  19697. case token.FieldExpireAt:
  19698. return m.ExpireAt()
  19699. case token.FieldToken:
  19700. return m.Token()
  19701. case token.FieldMAC:
  19702. return m.MAC()
  19703. }
  19704. return nil, false
  19705. }
  19706. // OldField returns the old value of the field from the database. An error is
  19707. // returned if the mutation operation is not UpdateOne, or the query to the
  19708. // database failed.
  19709. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19710. switch name {
  19711. case token.FieldCreatedAt:
  19712. return m.OldCreatedAt(ctx)
  19713. case token.FieldUpdatedAt:
  19714. return m.OldUpdatedAt(ctx)
  19715. case token.FieldDeletedAt:
  19716. return m.OldDeletedAt(ctx)
  19717. case token.FieldExpireAt:
  19718. return m.OldExpireAt(ctx)
  19719. case token.FieldToken:
  19720. return m.OldToken(ctx)
  19721. case token.FieldMAC:
  19722. return m.OldMAC(ctx)
  19723. }
  19724. return nil, fmt.Errorf("unknown Token field %s", name)
  19725. }
  19726. // SetField sets the value of a field with the given name. It returns an error if
  19727. // the field is not defined in the schema, or if the type mismatched the field
  19728. // type.
  19729. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  19730. switch name {
  19731. case token.FieldCreatedAt:
  19732. v, ok := value.(time.Time)
  19733. if !ok {
  19734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19735. }
  19736. m.SetCreatedAt(v)
  19737. return nil
  19738. case token.FieldUpdatedAt:
  19739. v, ok := value.(time.Time)
  19740. if !ok {
  19741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19742. }
  19743. m.SetUpdatedAt(v)
  19744. return nil
  19745. case token.FieldDeletedAt:
  19746. v, ok := value.(time.Time)
  19747. if !ok {
  19748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19749. }
  19750. m.SetDeletedAt(v)
  19751. return nil
  19752. case token.FieldExpireAt:
  19753. v, ok := value.(time.Time)
  19754. if !ok {
  19755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19756. }
  19757. m.SetExpireAt(v)
  19758. return nil
  19759. case token.FieldToken:
  19760. v, ok := value.(string)
  19761. if !ok {
  19762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19763. }
  19764. m.SetToken(v)
  19765. return nil
  19766. case token.FieldMAC:
  19767. v, ok := value.(string)
  19768. if !ok {
  19769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19770. }
  19771. m.SetMAC(v)
  19772. return nil
  19773. }
  19774. return fmt.Errorf("unknown Token field %s", name)
  19775. }
  19776. // AddedFields returns all numeric fields that were incremented/decremented during
  19777. // this mutation.
  19778. func (m *TokenMutation) AddedFields() []string {
  19779. return nil
  19780. }
  19781. // AddedField returns the numeric value that was incremented/decremented on a field
  19782. // with the given name. The second boolean return value indicates that this field
  19783. // was not set, or was not defined in the schema.
  19784. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  19785. return nil, false
  19786. }
  19787. // AddField adds the value to the field with the given name. It returns an error if
  19788. // the field is not defined in the schema, or if the type mismatched the field
  19789. // type.
  19790. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  19791. switch name {
  19792. }
  19793. return fmt.Errorf("unknown Token numeric field %s", name)
  19794. }
  19795. // ClearedFields returns all nullable fields that were cleared during this
  19796. // mutation.
  19797. func (m *TokenMutation) ClearedFields() []string {
  19798. var fields []string
  19799. if m.FieldCleared(token.FieldDeletedAt) {
  19800. fields = append(fields, token.FieldDeletedAt)
  19801. }
  19802. if m.FieldCleared(token.FieldExpireAt) {
  19803. fields = append(fields, token.FieldExpireAt)
  19804. }
  19805. if m.FieldCleared(token.FieldToken) {
  19806. fields = append(fields, token.FieldToken)
  19807. }
  19808. return fields
  19809. }
  19810. // FieldCleared returns a boolean indicating if a field with the given name was
  19811. // cleared in this mutation.
  19812. func (m *TokenMutation) FieldCleared(name string) bool {
  19813. _, ok := m.clearedFields[name]
  19814. return ok
  19815. }
  19816. // ClearField clears the value of the field with the given name. It returns an
  19817. // error if the field is not defined in the schema.
  19818. func (m *TokenMutation) ClearField(name string) error {
  19819. switch name {
  19820. case token.FieldDeletedAt:
  19821. m.ClearDeletedAt()
  19822. return nil
  19823. case token.FieldExpireAt:
  19824. m.ClearExpireAt()
  19825. return nil
  19826. case token.FieldToken:
  19827. m.ClearToken()
  19828. return nil
  19829. }
  19830. return fmt.Errorf("unknown Token nullable field %s", name)
  19831. }
  19832. // ResetField resets all changes in the mutation for the field with the given name.
  19833. // It returns an error if the field is not defined in the schema.
  19834. func (m *TokenMutation) ResetField(name string) error {
  19835. switch name {
  19836. case token.FieldCreatedAt:
  19837. m.ResetCreatedAt()
  19838. return nil
  19839. case token.FieldUpdatedAt:
  19840. m.ResetUpdatedAt()
  19841. return nil
  19842. case token.FieldDeletedAt:
  19843. m.ResetDeletedAt()
  19844. return nil
  19845. case token.FieldExpireAt:
  19846. m.ResetExpireAt()
  19847. return nil
  19848. case token.FieldToken:
  19849. m.ResetToken()
  19850. return nil
  19851. case token.FieldMAC:
  19852. m.ResetMAC()
  19853. return nil
  19854. }
  19855. return fmt.Errorf("unknown Token field %s", name)
  19856. }
  19857. // AddedEdges returns all edge names that were set/added in this mutation.
  19858. func (m *TokenMutation) AddedEdges() []string {
  19859. edges := make([]string, 0, 0)
  19860. return edges
  19861. }
  19862. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19863. // name in this mutation.
  19864. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  19865. return nil
  19866. }
  19867. // RemovedEdges returns all edge names that were removed in this mutation.
  19868. func (m *TokenMutation) RemovedEdges() []string {
  19869. edges := make([]string, 0, 0)
  19870. return edges
  19871. }
  19872. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19873. // the given name in this mutation.
  19874. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  19875. return nil
  19876. }
  19877. // ClearedEdges returns all edge names that were cleared in this mutation.
  19878. func (m *TokenMutation) ClearedEdges() []string {
  19879. edges := make([]string, 0, 0)
  19880. return edges
  19881. }
  19882. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19883. // was cleared in this mutation.
  19884. func (m *TokenMutation) EdgeCleared(name string) bool {
  19885. return false
  19886. }
  19887. // ClearEdge clears the value of the edge with the given name. It returns an error
  19888. // if that edge is not defined in the schema.
  19889. func (m *TokenMutation) ClearEdge(name string) error {
  19890. return fmt.Errorf("unknown Token unique edge %s", name)
  19891. }
  19892. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19893. // It returns an error if the edge is not defined in the schema.
  19894. func (m *TokenMutation) ResetEdge(name string) error {
  19895. return fmt.Errorf("unknown Token edge %s", name)
  19896. }
  19897. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  19898. type TutorialMutation struct {
  19899. config
  19900. op Op
  19901. typ string
  19902. id *uint64
  19903. created_at *time.Time
  19904. updated_at *time.Time
  19905. deleted_at *time.Time
  19906. index *int
  19907. addindex *int
  19908. title *string
  19909. content *string
  19910. organization_id *uint64
  19911. addorganization_id *int64
  19912. clearedFields map[string]struct{}
  19913. employee *uint64
  19914. clearedemployee bool
  19915. done bool
  19916. oldValue func(context.Context) (*Tutorial, error)
  19917. predicates []predicate.Tutorial
  19918. }
  19919. var _ ent.Mutation = (*TutorialMutation)(nil)
  19920. // tutorialOption allows management of the mutation configuration using functional options.
  19921. type tutorialOption func(*TutorialMutation)
  19922. // newTutorialMutation creates new mutation for the Tutorial entity.
  19923. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  19924. m := &TutorialMutation{
  19925. config: c,
  19926. op: op,
  19927. typ: TypeTutorial,
  19928. clearedFields: make(map[string]struct{}),
  19929. }
  19930. for _, opt := range opts {
  19931. opt(m)
  19932. }
  19933. return m
  19934. }
  19935. // withTutorialID sets the ID field of the mutation.
  19936. func withTutorialID(id uint64) tutorialOption {
  19937. return func(m *TutorialMutation) {
  19938. var (
  19939. err error
  19940. once sync.Once
  19941. value *Tutorial
  19942. )
  19943. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  19944. once.Do(func() {
  19945. if m.done {
  19946. err = errors.New("querying old values post mutation is not allowed")
  19947. } else {
  19948. value, err = m.Client().Tutorial.Get(ctx, id)
  19949. }
  19950. })
  19951. return value, err
  19952. }
  19953. m.id = &id
  19954. }
  19955. }
  19956. // withTutorial sets the old Tutorial of the mutation.
  19957. func withTutorial(node *Tutorial) tutorialOption {
  19958. return func(m *TutorialMutation) {
  19959. m.oldValue = func(context.Context) (*Tutorial, error) {
  19960. return node, nil
  19961. }
  19962. m.id = &node.ID
  19963. }
  19964. }
  19965. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19966. // executed in a transaction (ent.Tx), a transactional client is returned.
  19967. func (m TutorialMutation) Client() *Client {
  19968. client := &Client{config: m.config}
  19969. client.init()
  19970. return client
  19971. }
  19972. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19973. // it returns an error otherwise.
  19974. func (m TutorialMutation) Tx() (*Tx, error) {
  19975. if _, ok := m.driver.(*txDriver); !ok {
  19976. return nil, errors.New("ent: mutation is not running in a transaction")
  19977. }
  19978. tx := &Tx{config: m.config}
  19979. tx.init()
  19980. return tx, nil
  19981. }
  19982. // SetID sets the value of the id field. Note that this
  19983. // operation is only accepted on creation of Tutorial entities.
  19984. func (m *TutorialMutation) SetID(id uint64) {
  19985. m.id = &id
  19986. }
  19987. // ID returns the ID value in the mutation. Note that the ID is only available
  19988. // if it was provided to the builder or after it was returned from the database.
  19989. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  19990. if m.id == nil {
  19991. return
  19992. }
  19993. return *m.id, true
  19994. }
  19995. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19996. // That means, if the mutation is applied within a transaction with an isolation level such
  19997. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19998. // or updated by the mutation.
  19999. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  20000. switch {
  20001. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20002. id, exists := m.ID()
  20003. if exists {
  20004. return []uint64{id}, nil
  20005. }
  20006. fallthrough
  20007. case m.op.Is(OpUpdate | OpDelete):
  20008. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  20009. default:
  20010. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20011. }
  20012. }
  20013. // SetCreatedAt sets the "created_at" field.
  20014. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  20015. m.created_at = &t
  20016. }
  20017. // CreatedAt returns the value of the "created_at" field in the mutation.
  20018. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  20019. v := m.created_at
  20020. if v == nil {
  20021. return
  20022. }
  20023. return *v, true
  20024. }
  20025. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  20026. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20028. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20029. if !m.op.Is(OpUpdateOne) {
  20030. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20031. }
  20032. if m.id == nil || m.oldValue == nil {
  20033. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20034. }
  20035. oldValue, err := m.oldValue(ctx)
  20036. if err != nil {
  20037. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20038. }
  20039. return oldValue.CreatedAt, nil
  20040. }
  20041. // ResetCreatedAt resets all changes to the "created_at" field.
  20042. func (m *TutorialMutation) ResetCreatedAt() {
  20043. m.created_at = nil
  20044. }
  20045. // SetUpdatedAt sets the "updated_at" field.
  20046. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  20047. m.updated_at = &t
  20048. }
  20049. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20050. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  20051. v := m.updated_at
  20052. if v == nil {
  20053. return
  20054. }
  20055. return *v, true
  20056. }
  20057. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  20058. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20060. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20061. if !m.op.Is(OpUpdateOne) {
  20062. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20063. }
  20064. if m.id == nil || m.oldValue == nil {
  20065. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20066. }
  20067. oldValue, err := m.oldValue(ctx)
  20068. if err != nil {
  20069. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20070. }
  20071. return oldValue.UpdatedAt, nil
  20072. }
  20073. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20074. func (m *TutorialMutation) ResetUpdatedAt() {
  20075. m.updated_at = nil
  20076. }
  20077. // SetDeletedAt sets the "deleted_at" field.
  20078. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  20079. m.deleted_at = &t
  20080. }
  20081. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20082. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  20083. v := m.deleted_at
  20084. if v == nil {
  20085. return
  20086. }
  20087. return *v, true
  20088. }
  20089. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  20090. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20092. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20093. if !m.op.Is(OpUpdateOne) {
  20094. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20095. }
  20096. if m.id == nil || m.oldValue == nil {
  20097. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20098. }
  20099. oldValue, err := m.oldValue(ctx)
  20100. if err != nil {
  20101. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20102. }
  20103. return oldValue.DeletedAt, nil
  20104. }
  20105. // ClearDeletedAt clears the value of the "deleted_at" field.
  20106. func (m *TutorialMutation) ClearDeletedAt() {
  20107. m.deleted_at = nil
  20108. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  20109. }
  20110. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20111. func (m *TutorialMutation) DeletedAtCleared() bool {
  20112. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  20113. return ok
  20114. }
  20115. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20116. func (m *TutorialMutation) ResetDeletedAt() {
  20117. m.deleted_at = nil
  20118. delete(m.clearedFields, tutorial.FieldDeletedAt)
  20119. }
  20120. // SetEmployeeID sets the "employee_id" field.
  20121. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  20122. m.employee = &u
  20123. }
  20124. // EmployeeID returns the value of the "employee_id" field in the mutation.
  20125. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  20126. v := m.employee
  20127. if v == nil {
  20128. return
  20129. }
  20130. return *v, true
  20131. }
  20132. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  20133. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20135. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  20136. if !m.op.Is(OpUpdateOne) {
  20137. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  20138. }
  20139. if m.id == nil || m.oldValue == nil {
  20140. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  20141. }
  20142. oldValue, err := m.oldValue(ctx)
  20143. if err != nil {
  20144. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  20145. }
  20146. return oldValue.EmployeeID, nil
  20147. }
  20148. // ResetEmployeeID resets all changes to the "employee_id" field.
  20149. func (m *TutorialMutation) ResetEmployeeID() {
  20150. m.employee = nil
  20151. }
  20152. // SetIndex sets the "index" field.
  20153. func (m *TutorialMutation) SetIndex(i int) {
  20154. m.index = &i
  20155. m.addindex = nil
  20156. }
  20157. // Index returns the value of the "index" field in the mutation.
  20158. func (m *TutorialMutation) Index() (r int, exists bool) {
  20159. v := m.index
  20160. if v == nil {
  20161. return
  20162. }
  20163. return *v, true
  20164. }
  20165. // OldIndex returns the old "index" field's value of the Tutorial entity.
  20166. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20168. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  20169. if !m.op.Is(OpUpdateOne) {
  20170. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  20171. }
  20172. if m.id == nil || m.oldValue == nil {
  20173. return v, errors.New("OldIndex requires an ID field in the mutation")
  20174. }
  20175. oldValue, err := m.oldValue(ctx)
  20176. if err != nil {
  20177. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  20178. }
  20179. return oldValue.Index, nil
  20180. }
  20181. // AddIndex adds i to the "index" field.
  20182. func (m *TutorialMutation) AddIndex(i int) {
  20183. if m.addindex != nil {
  20184. *m.addindex += i
  20185. } else {
  20186. m.addindex = &i
  20187. }
  20188. }
  20189. // AddedIndex returns the value that was added to the "index" field in this mutation.
  20190. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  20191. v := m.addindex
  20192. if v == nil {
  20193. return
  20194. }
  20195. return *v, true
  20196. }
  20197. // ResetIndex resets all changes to the "index" field.
  20198. func (m *TutorialMutation) ResetIndex() {
  20199. m.index = nil
  20200. m.addindex = nil
  20201. }
  20202. // SetTitle sets the "title" field.
  20203. func (m *TutorialMutation) SetTitle(s string) {
  20204. m.title = &s
  20205. }
  20206. // Title returns the value of the "title" field in the mutation.
  20207. func (m *TutorialMutation) Title() (r string, exists bool) {
  20208. v := m.title
  20209. if v == nil {
  20210. return
  20211. }
  20212. return *v, true
  20213. }
  20214. // OldTitle returns the old "title" field's value of the Tutorial entity.
  20215. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20217. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  20218. if !m.op.Is(OpUpdateOne) {
  20219. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  20220. }
  20221. if m.id == nil || m.oldValue == nil {
  20222. return v, errors.New("OldTitle requires an ID field in the mutation")
  20223. }
  20224. oldValue, err := m.oldValue(ctx)
  20225. if err != nil {
  20226. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  20227. }
  20228. return oldValue.Title, nil
  20229. }
  20230. // ResetTitle resets all changes to the "title" field.
  20231. func (m *TutorialMutation) ResetTitle() {
  20232. m.title = nil
  20233. }
  20234. // SetContent sets the "content" field.
  20235. func (m *TutorialMutation) SetContent(s string) {
  20236. m.content = &s
  20237. }
  20238. // Content returns the value of the "content" field in the mutation.
  20239. func (m *TutorialMutation) Content() (r string, exists bool) {
  20240. v := m.content
  20241. if v == nil {
  20242. return
  20243. }
  20244. return *v, true
  20245. }
  20246. // OldContent returns the old "content" field's value of the Tutorial entity.
  20247. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20249. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  20250. if !m.op.Is(OpUpdateOne) {
  20251. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  20252. }
  20253. if m.id == nil || m.oldValue == nil {
  20254. return v, errors.New("OldContent requires an ID field in the mutation")
  20255. }
  20256. oldValue, err := m.oldValue(ctx)
  20257. if err != nil {
  20258. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  20259. }
  20260. return oldValue.Content, nil
  20261. }
  20262. // ResetContent resets all changes to the "content" field.
  20263. func (m *TutorialMutation) ResetContent() {
  20264. m.content = nil
  20265. }
  20266. // SetOrganizationID sets the "organization_id" field.
  20267. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  20268. m.organization_id = &u
  20269. m.addorganization_id = nil
  20270. }
  20271. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20272. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  20273. v := m.organization_id
  20274. if v == nil {
  20275. return
  20276. }
  20277. return *v, true
  20278. }
  20279. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  20280. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20282. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20283. if !m.op.Is(OpUpdateOne) {
  20284. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20285. }
  20286. if m.id == nil || m.oldValue == nil {
  20287. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20288. }
  20289. oldValue, err := m.oldValue(ctx)
  20290. if err != nil {
  20291. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20292. }
  20293. return oldValue.OrganizationID, nil
  20294. }
  20295. // AddOrganizationID adds u to the "organization_id" field.
  20296. func (m *TutorialMutation) AddOrganizationID(u int64) {
  20297. if m.addorganization_id != nil {
  20298. *m.addorganization_id += u
  20299. } else {
  20300. m.addorganization_id = &u
  20301. }
  20302. }
  20303. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20304. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  20305. v := m.addorganization_id
  20306. if v == nil {
  20307. return
  20308. }
  20309. return *v, true
  20310. }
  20311. // ResetOrganizationID resets all changes to the "organization_id" field.
  20312. func (m *TutorialMutation) ResetOrganizationID() {
  20313. m.organization_id = nil
  20314. m.addorganization_id = nil
  20315. }
  20316. // ClearEmployee clears the "employee" edge to the Employee entity.
  20317. func (m *TutorialMutation) ClearEmployee() {
  20318. m.clearedemployee = true
  20319. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  20320. }
  20321. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  20322. func (m *TutorialMutation) EmployeeCleared() bool {
  20323. return m.clearedemployee
  20324. }
  20325. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  20326. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20327. // EmployeeID instead. It exists only for internal usage by the builders.
  20328. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  20329. if id := m.employee; id != nil {
  20330. ids = append(ids, *id)
  20331. }
  20332. return
  20333. }
  20334. // ResetEmployee resets all changes to the "employee" edge.
  20335. func (m *TutorialMutation) ResetEmployee() {
  20336. m.employee = nil
  20337. m.clearedemployee = false
  20338. }
  20339. // Where appends a list predicates to the TutorialMutation builder.
  20340. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  20341. m.predicates = append(m.predicates, ps...)
  20342. }
  20343. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  20344. // users can use type-assertion to append predicates that do not depend on any generated package.
  20345. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  20346. p := make([]predicate.Tutorial, len(ps))
  20347. for i := range ps {
  20348. p[i] = ps[i]
  20349. }
  20350. m.Where(p...)
  20351. }
  20352. // Op returns the operation name.
  20353. func (m *TutorialMutation) Op() Op {
  20354. return m.op
  20355. }
  20356. // SetOp allows setting the mutation operation.
  20357. func (m *TutorialMutation) SetOp(op Op) {
  20358. m.op = op
  20359. }
  20360. // Type returns the node type of this mutation (Tutorial).
  20361. func (m *TutorialMutation) Type() string {
  20362. return m.typ
  20363. }
  20364. // Fields returns all fields that were changed during this mutation. Note that in
  20365. // order to get all numeric fields that were incremented/decremented, call
  20366. // AddedFields().
  20367. func (m *TutorialMutation) Fields() []string {
  20368. fields := make([]string, 0, 8)
  20369. if m.created_at != nil {
  20370. fields = append(fields, tutorial.FieldCreatedAt)
  20371. }
  20372. if m.updated_at != nil {
  20373. fields = append(fields, tutorial.FieldUpdatedAt)
  20374. }
  20375. if m.deleted_at != nil {
  20376. fields = append(fields, tutorial.FieldDeletedAt)
  20377. }
  20378. if m.employee != nil {
  20379. fields = append(fields, tutorial.FieldEmployeeID)
  20380. }
  20381. if m.index != nil {
  20382. fields = append(fields, tutorial.FieldIndex)
  20383. }
  20384. if m.title != nil {
  20385. fields = append(fields, tutorial.FieldTitle)
  20386. }
  20387. if m.content != nil {
  20388. fields = append(fields, tutorial.FieldContent)
  20389. }
  20390. if m.organization_id != nil {
  20391. fields = append(fields, tutorial.FieldOrganizationID)
  20392. }
  20393. return fields
  20394. }
  20395. // Field returns the value of a field with the given name. The second boolean
  20396. // return value indicates that this field was not set, or was not defined in the
  20397. // schema.
  20398. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  20399. switch name {
  20400. case tutorial.FieldCreatedAt:
  20401. return m.CreatedAt()
  20402. case tutorial.FieldUpdatedAt:
  20403. return m.UpdatedAt()
  20404. case tutorial.FieldDeletedAt:
  20405. return m.DeletedAt()
  20406. case tutorial.FieldEmployeeID:
  20407. return m.EmployeeID()
  20408. case tutorial.FieldIndex:
  20409. return m.Index()
  20410. case tutorial.FieldTitle:
  20411. return m.Title()
  20412. case tutorial.FieldContent:
  20413. return m.Content()
  20414. case tutorial.FieldOrganizationID:
  20415. return m.OrganizationID()
  20416. }
  20417. return nil, false
  20418. }
  20419. // OldField returns the old value of the field from the database. An error is
  20420. // returned if the mutation operation is not UpdateOne, or the query to the
  20421. // database failed.
  20422. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20423. switch name {
  20424. case tutorial.FieldCreatedAt:
  20425. return m.OldCreatedAt(ctx)
  20426. case tutorial.FieldUpdatedAt:
  20427. return m.OldUpdatedAt(ctx)
  20428. case tutorial.FieldDeletedAt:
  20429. return m.OldDeletedAt(ctx)
  20430. case tutorial.FieldEmployeeID:
  20431. return m.OldEmployeeID(ctx)
  20432. case tutorial.FieldIndex:
  20433. return m.OldIndex(ctx)
  20434. case tutorial.FieldTitle:
  20435. return m.OldTitle(ctx)
  20436. case tutorial.FieldContent:
  20437. return m.OldContent(ctx)
  20438. case tutorial.FieldOrganizationID:
  20439. return m.OldOrganizationID(ctx)
  20440. }
  20441. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  20442. }
  20443. // SetField sets the value of a field with the given name. It returns an error if
  20444. // the field is not defined in the schema, or if the type mismatched the field
  20445. // type.
  20446. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  20447. switch name {
  20448. case tutorial.FieldCreatedAt:
  20449. v, ok := value.(time.Time)
  20450. if !ok {
  20451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20452. }
  20453. m.SetCreatedAt(v)
  20454. return nil
  20455. case tutorial.FieldUpdatedAt:
  20456. v, ok := value.(time.Time)
  20457. if !ok {
  20458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20459. }
  20460. m.SetUpdatedAt(v)
  20461. return nil
  20462. case tutorial.FieldDeletedAt:
  20463. v, ok := value.(time.Time)
  20464. if !ok {
  20465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20466. }
  20467. m.SetDeletedAt(v)
  20468. return nil
  20469. case tutorial.FieldEmployeeID:
  20470. v, ok := value.(uint64)
  20471. if !ok {
  20472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20473. }
  20474. m.SetEmployeeID(v)
  20475. return nil
  20476. case tutorial.FieldIndex:
  20477. v, ok := value.(int)
  20478. if !ok {
  20479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20480. }
  20481. m.SetIndex(v)
  20482. return nil
  20483. case tutorial.FieldTitle:
  20484. v, ok := value.(string)
  20485. if !ok {
  20486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20487. }
  20488. m.SetTitle(v)
  20489. return nil
  20490. case tutorial.FieldContent:
  20491. v, ok := value.(string)
  20492. if !ok {
  20493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20494. }
  20495. m.SetContent(v)
  20496. return nil
  20497. case tutorial.FieldOrganizationID:
  20498. v, ok := value.(uint64)
  20499. if !ok {
  20500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20501. }
  20502. m.SetOrganizationID(v)
  20503. return nil
  20504. }
  20505. return fmt.Errorf("unknown Tutorial field %s", name)
  20506. }
  20507. // AddedFields returns all numeric fields that were incremented/decremented during
  20508. // this mutation.
  20509. func (m *TutorialMutation) AddedFields() []string {
  20510. var fields []string
  20511. if m.addindex != nil {
  20512. fields = append(fields, tutorial.FieldIndex)
  20513. }
  20514. if m.addorganization_id != nil {
  20515. fields = append(fields, tutorial.FieldOrganizationID)
  20516. }
  20517. return fields
  20518. }
  20519. // AddedField returns the numeric value that was incremented/decremented on a field
  20520. // with the given name. The second boolean return value indicates that this field
  20521. // was not set, or was not defined in the schema.
  20522. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  20523. switch name {
  20524. case tutorial.FieldIndex:
  20525. return m.AddedIndex()
  20526. case tutorial.FieldOrganizationID:
  20527. return m.AddedOrganizationID()
  20528. }
  20529. return nil, false
  20530. }
  20531. // AddField adds the value to the field with the given name. It returns an error if
  20532. // the field is not defined in the schema, or if the type mismatched the field
  20533. // type.
  20534. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  20535. switch name {
  20536. case tutorial.FieldIndex:
  20537. v, ok := value.(int)
  20538. if !ok {
  20539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20540. }
  20541. m.AddIndex(v)
  20542. return nil
  20543. case tutorial.FieldOrganizationID:
  20544. v, ok := value.(int64)
  20545. if !ok {
  20546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20547. }
  20548. m.AddOrganizationID(v)
  20549. return nil
  20550. }
  20551. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  20552. }
  20553. // ClearedFields returns all nullable fields that were cleared during this
  20554. // mutation.
  20555. func (m *TutorialMutation) ClearedFields() []string {
  20556. var fields []string
  20557. if m.FieldCleared(tutorial.FieldDeletedAt) {
  20558. fields = append(fields, tutorial.FieldDeletedAt)
  20559. }
  20560. return fields
  20561. }
  20562. // FieldCleared returns a boolean indicating if a field with the given name was
  20563. // cleared in this mutation.
  20564. func (m *TutorialMutation) FieldCleared(name string) bool {
  20565. _, ok := m.clearedFields[name]
  20566. return ok
  20567. }
  20568. // ClearField clears the value of the field with the given name. It returns an
  20569. // error if the field is not defined in the schema.
  20570. func (m *TutorialMutation) ClearField(name string) error {
  20571. switch name {
  20572. case tutorial.FieldDeletedAt:
  20573. m.ClearDeletedAt()
  20574. return nil
  20575. }
  20576. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  20577. }
  20578. // ResetField resets all changes in the mutation for the field with the given name.
  20579. // It returns an error if the field is not defined in the schema.
  20580. func (m *TutorialMutation) ResetField(name string) error {
  20581. switch name {
  20582. case tutorial.FieldCreatedAt:
  20583. m.ResetCreatedAt()
  20584. return nil
  20585. case tutorial.FieldUpdatedAt:
  20586. m.ResetUpdatedAt()
  20587. return nil
  20588. case tutorial.FieldDeletedAt:
  20589. m.ResetDeletedAt()
  20590. return nil
  20591. case tutorial.FieldEmployeeID:
  20592. m.ResetEmployeeID()
  20593. return nil
  20594. case tutorial.FieldIndex:
  20595. m.ResetIndex()
  20596. return nil
  20597. case tutorial.FieldTitle:
  20598. m.ResetTitle()
  20599. return nil
  20600. case tutorial.FieldContent:
  20601. m.ResetContent()
  20602. return nil
  20603. case tutorial.FieldOrganizationID:
  20604. m.ResetOrganizationID()
  20605. return nil
  20606. }
  20607. return fmt.Errorf("unknown Tutorial field %s", name)
  20608. }
  20609. // AddedEdges returns all edge names that were set/added in this mutation.
  20610. func (m *TutorialMutation) AddedEdges() []string {
  20611. edges := make([]string, 0, 1)
  20612. if m.employee != nil {
  20613. edges = append(edges, tutorial.EdgeEmployee)
  20614. }
  20615. return edges
  20616. }
  20617. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20618. // name in this mutation.
  20619. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  20620. switch name {
  20621. case tutorial.EdgeEmployee:
  20622. if id := m.employee; id != nil {
  20623. return []ent.Value{*id}
  20624. }
  20625. }
  20626. return nil
  20627. }
  20628. // RemovedEdges returns all edge names that were removed in this mutation.
  20629. func (m *TutorialMutation) RemovedEdges() []string {
  20630. edges := make([]string, 0, 1)
  20631. return edges
  20632. }
  20633. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20634. // the given name in this mutation.
  20635. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  20636. return nil
  20637. }
  20638. // ClearedEdges returns all edge names that were cleared in this mutation.
  20639. func (m *TutorialMutation) ClearedEdges() []string {
  20640. edges := make([]string, 0, 1)
  20641. if m.clearedemployee {
  20642. edges = append(edges, tutorial.EdgeEmployee)
  20643. }
  20644. return edges
  20645. }
  20646. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20647. // was cleared in this mutation.
  20648. func (m *TutorialMutation) EdgeCleared(name string) bool {
  20649. switch name {
  20650. case tutorial.EdgeEmployee:
  20651. return m.clearedemployee
  20652. }
  20653. return false
  20654. }
  20655. // ClearEdge clears the value of the edge with the given name. It returns an error
  20656. // if that edge is not defined in the schema.
  20657. func (m *TutorialMutation) ClearEdge(name string) error {
  20658. switch name {
  20659. case tutorial.EdgeEmployee:
  20660. m.ClearEmployee()
  20661. return nil
  20662. }
  20663. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  20664. }
  20665. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20666. // It returns an error if the edge is not defined in the schema.
  20667. func (m *TutorialMutation) ResetEdge(name string) error {
  20668. switch name {
  20669. case tutorial.EdgeEmployee:
  20670. m.ResetEmployee()
  20671. return nil
  20672. }
  20673. return fmt.Errorf("unknown Tutorial edge %s", name)
  20674. }
  20675. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  20676. type WorkExperienceMutation struct {
  20677. config
  20678. op Op
  20679. typ string
  20680. id *uint64
  20681. created_at *time.Time
  20682. updated_at *time.Time
  20683. deleted_at *time.Time
  20684. start_date *time.Time
  20685. end_date *time.Time
  20686. company *string
  20687. experience *string
  20688. organization_id *uint64
  20689. addorganization_id *int64
  20690. clearedFields map[string]struct{}
  20691. employee *uint64
  20692. clearedemployee bool
  20693. done bool
  20694. oldValue func(context.Context) (*WorkExperience, error)
  20695. predicates []predicate.WorkExperience
  20696. }
  20697. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  20698. // workexperienceOption allows management of the mutation configuration using functional options.
  20699. type workexperienceOption func(*WorkExperienceMutation)
  20700. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  20701. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  20702. m := &WorkExperienceMutation{
  20703. config: c,
  20704. op: op,
  20705. typ: TypeWorkExperience,
  20706. clearedFields: make(map[string]struct{}),
  20707. }
  20708. for _, opt := range opts {
  20709. opt(m)
  20710. }
  20711. return m
  20712. }
  20713. // withWorkExperienceID sets the ID field of the mutation.
  20714. func withWorkExperienceID(id uint64) workexperienceOption {
  20715. return func(m *WorkExperienceMutation) {
  20716. var (
  20717. err error
  20718. once sync.Once
  20719. value *WorkExperience
  20720. )
  20721. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  20722. once.Do(func() {
  20723. if m.done {
  20724. err = errors.New("querying old values post mutation is not allowed")
  20725. } else {
  20726. value, err = m.Client().WorkExperience.Get(ctx, id)
  20727. }
  20728. })
  20729. return value, err
  20730. }
  20731. m.id = &id
  20732. }
  20733. }
  20734. // withWorkExperience sets the old WorkExperience of the mutation.
  20735. func withWorkExperience(node *WorkExperience) workexperienceOption {
  20736. return func(m *WorkExperienceMutation) {
  20737. m.oldValue = func(context.Context) (*WorkExperience, error) {
  20738. return node, nil
  20739. }
  20740. m.id = &node.ID
  20741. }
  20742. }
  20743. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20744. // executed in a transaction (ent.Tx), a transactional client is returned.
  20745. func (m WorkExperienceMutation) Client() *Client {
  20746. client := &Client{config: m.config}
  20747. client.init()
  20748. return client
  20749. }
  20750. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20751. // it returns an error otherwise.
  20752. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  20753. if _, ok := m.driver.(*txDriver); !ok {
  20754. return nil, errors.New("ent: mutation is not running in a transaction")
  20755. }
  20756. tx := &Tx{config: m.config}
  20757. tx.init()
  20758. return tx, nil
  20759. }
  20760. // SetID sets the value of the id field. Note that this
  20761. // operation is only accepted on creation of WorkExperience entities.
  20762. func (m *WorkExperienceMutation) SetID(id uint64) {
  20763. m.id = &id
  20764. }
  20765. // ID returns the ID value in the mutation. Note that the ID is only available
  20766. // if it was provided to the builder or after it was returned from the database.
  20767. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  20768. if m.id == nil {
  20769. return
  20770. }
  20771. return *m.id, true
  20772. }
  20773. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20774. // That means, if the mutation is applied within a transaction with an isolation level such
  20775. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20776. // or updated by the mutation.
  20777. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  20778. switch {
  20779. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20780. id, exists := m.ID()
  20781. if exists {
  20782. return []uint64{id}, nil
  20783. }
  20784. fallthrough
  20785. case m.op.Is(OpUpdate | OpDelete):
  20786. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  20787. default:
  20788. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20789. }
  20790. }
  20791. // SetCreatedAt sets the "created_at" field.
  20792. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  20793. m.created_at = &t
  20794. }
  20795. // CreatedAt returns the value of the "created_at" field in the mutation.
  20796. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  20797. v := m.created_at
  20798. if v == nil {
  20799. return
  20800. }
  20801. return *v, true
  20802. }
  20803. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  20804. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20806. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20807. if !m.op.Is(OpUpdateOne) {
  20808. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20809. }
  20810. if m.id == nil || m.oldValue == nil {
  20811. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20812. }
  20813. oldValue, err := m.oldValue(ctx)
  20814. if err != nil {
  20815. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20816. }
  20817. return oldValue.CreatedAt, nil
  20818. }
  20819. // ResetCreatedAt resets all changes to the "created_at" field.
  20820. func (m *WorkExperienceMutation) ResetCreatedAt() {
  20821. m.created_at = nil
  20822. }
  20823. // SetUpdatedAt sets the "updated_at" field.
  20824. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  20825. m.updated_at = &t
  20826. }
  20827. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20828. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  20829. v := m.updated_at
  20830. if v == nil {
  20831. return
  20832. }
  20833. return *v, true
  20834. }
  20835. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  20836. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20838. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20839. if !m.op.Is(OpUpdateOne) {
  20840. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20841. }
  20842. if m.id == nil || m.oldValue == nil {
  20843. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20844. }
  20845. oldValue, err := m.oldValue(ctx)
  20846. if err != nil {
  20847. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20848. }
  20849. return oldValue.UpdatedAt, nil
  20850. }
  20851. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20852. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  20853. m.updated_at = nil
  20854. }
  20855. // SetDeletedAt sets the "deleted_at" field.
  20856. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  20857. m.deleted_at = &t
  20858. }
  20859. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20860. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  20861. v := m.deleted_at
  20862. if v == nil {
  20863. return
  20864. }
  20865. return *v, true
  20866. }
  20867. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  20868. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20870. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20871. if !m.op.Is(OpUpdateOne) {
  20872. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20873. }
  20874. if m.id == nil || m.oldValue == nil {
  20875. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20876. }
  20877. oldValue, err := m.oldValue(ctx)
  20878. if err != nil {
  20879. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20880. }
  20881. return oldValue.DeletedAt, nil
  20882. }
  20883. // ClearDeletedAt clears the value of the "deleted_at" field.
  20884. func (m *WorkExperienceMutation) ClearDeletedAt() {
  20885. m.deleted_at = nil
  20886. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  20887. }
  20888. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20889. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  20890. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  20891. return ok
  20892. }
  20893. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20894. func (m *WorkExperienceMutation) ResetDeletedAt() {
  20895. m.deleted_at = nil
  20896. delete(m.clearedFields, workexperience.FieldDeletedAt)
  20897. }
  20898. // SetEmployeeID sets the "employee_id" field.
  20899. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  20900. m.employee = &u
  20901. }
  20902. // EmployeeID returns the value of the "employee_id" field in the mutation.
  20903. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  20904. v := m.employee
  20905. if v == nil {
  20906. return
  20907. }
  20908. return *v, true
  20909. }
  20910. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  20911. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20913. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  20914. if !m.op.Is(OpUpdateOne) {
  20915. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  20916. }
  20917. if m.id == nil || m.oldValue == nil {
  20918. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  20919. }
  20920. oldValue, err := m.oldValue(ctx)
  20921. if err != nil {
  20922. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  20923. }
  20924. return oldValue.EmployeeID, nil
  20925. }
  20926. // ResetEmployeeID resets all changes to the "employee_id" field.
  20927. func (m *WorkExperienceMutation) ResetEmployeeID() {
  20928. m.employee = nil
  20929. }
  20930. // SetStartDate sets the "start_date" field.
  20931. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  20932. m.start_date = &t
  20933. }
  20934. // StartDate returns the value of the "start_date" field in the mutation.
  20935. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  20936. v := m.start_date
  20937. if v == nil {
  20938. return
  20939. }
  20940. return *v, true
  20941. }
  20942. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  20943. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20945. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  20946. if !m.op.Is(OpUpdateOne) {
  20947. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  20948. }
  20949. if m.id == nil || m.oldValue == nil {
  20950. return v, errors.New("OldStartDate requires an ID field in the mutation")
  20951. }
  20952. oldValue, err := m.oldValue(ctx)
  20953. if err != nil {
  20954. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  20955. }
  20956. return oldValue.StartDate, nil
  20957. }
  20958. // ResetStartDate resets all changes to the "start_date" field.
  20959. func (m *WorkExperienceMutation) ResetStartDate() {
  20960. m.start_date = nil
  20961. }
  20962. // SetEndDate sets the "end_date" field.
  20963. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  20964. m.end_date = &t
  20965. }
  20966. // EndDate returns the value of the "end_date" field in the mutation.
  20967. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  20968. v := m.end_date
  20969. if v == nil {
  20970. return
  20971. }
  20972. return *v, true
  20973. }
  20974. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  20975. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20977. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  20978. if !m.op.Is(OpUpdateOne) {
  20979. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  20980. }
  20981. if m.id == nil || m.oldValue == nil {
  20982. return v, errors.New("OldEndDate requires an ID field in the mutation")
  20983. }
  20984. oldValue, err := m.oldValue(ctx)
  20985. if err != nil {
  20986. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  20987. }
  20988. return oldValue.EndDate, nil
  20989. }
  20990. // ResetEndDate resets all changes to the "end_date" field.
  20991. func (m *WorkExperienceMutation) ResetEndDate() {
  20992. m.end_date = nil
  20993. }
  20994. // SetCompany sets the "company" field.
  20995. func (m *WorkExperienceMutation) SetCompany(s string) {
  20996. m.company = &s
  20997. }
  20998. // Company returns the value of the "company" field in the mutation.
  20999. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  21000. v := m.company
  21001. if v == nil {
  21002. return
  21003. }
  21004. return *v, true
  21005. }
  21006. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  21007. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  21008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21009. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  21010. if !m.op.Is(OpUpdateOne) {
  21011. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  21012. }
  21013. if m.id == nil || m.oldValue == nil {
  21014. return v, errors.New("OldCompany requires an ID field in the mutation")
  21015. }
  21016. oldValue, err := m.oldValue(ctx)
  21017. if err != nil {
  21018. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  21019. }
  21020. return oldValue.Company, nil
  21021. }
  21022. // ResetCompany resets all changes to the "company" field.
  21023. func (m *WorkExperienceMutation) ResetCompany() {
  21024. m.company = nil
  21025. }
  21026. // SetExperience sets the "experience" field.
  21027. func (m *WorkExperienceMutation) SetExperience(s string) {
  21028. m.experience = &s
  21029. }
  21030. // Experience returns the value of the "experience" field in the mutation.
  21031. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  21032. v := m.experience
  21033. if v == nil {
  21034. return
  21035. }
  21036. return *v, true
  21037. }
  21038. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  21039. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  21040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21041. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  21042. if !m.op.Is(OpUpdateOne) {
  21043. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  21044. }
  21045. if m.id == nil || m.oldValue == nil {
  21046. return v, errors.New("OldExperience requires an ID field in the mutation")
  21047. }
  21048. oldValue, err := m.oldValue(ctx)
  21049. if err != nil {
  21050. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  21051. }
  21052. return oldValue.Experience, nil
  21053. }
  21054. // ResetExperience resets all changes to the "experience" field.
  21055. func (m *WorkExperienceMutation) ResetExperience() {
  21056. m.experience = nil
  21057. }
  21058. // SetOrganizationID sets the "organization_id" field.
  21059. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  21060. m.organization_id = &u
  21061. m.addorganization_id = nil
  21062. }
  21063. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21064. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  21065. v := m.organization_id
  21066. if v == nil {
  21067. return
  21068. }
  21069. return *v, true
  21070. }
  21071. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  21072. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  21073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21074. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21075. if !m.op.Is(OpUpdateOne) {
  21076. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21077. }
  21078. if m.id == nil || m.oldValue == nil {
  21079. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21080. }
  21081. oldValue, err := m.oldValue(ctx)
  21082. if err != nil {
  21083. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21084. }
  21085. return oldValue.OrganizationID, nil
  21086. }
  21087. // AddOrganizationID adds u to the "organization_id" field.
  21088. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  21089. if m.addorganization_id != nil {
  21090. *m.addorganization_id += u
  21091. } else {
  21092. m.addorganization_id = &u
  21093. }
  21094. }
  21095. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21096. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  21097. v := m.addorganization_id
  21098. if v == nil {
  21099. return
  21100. }
  21101. return *v, true
  21102. }
  21103. // ResetOrganizationID resets all changes to the "organization_id" field.
  21104. func (m *WorkExperienceMutation) ResetOrganizationID() {
  21105. m.organization_id = nil
  21106. m.addorganization_id = nil
  21107. }
  21108. // ClearEmployee clears the "employee" edge to the Employee entity.
  21109. func (m *WorkExperienceMutation) ClearEmployee() {
  21110. m.clearedemployee = true
  21111. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  21112. }
  21113. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  21114. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  21115. return m.clearedemployee
  21116. }
  21117. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  21118. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21119. // EmployeeID instead. It exists only for internal usage by the builders.
  21120. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  21121. if id := m.employee; id != nil {
  21122. ids = append(ids, *id)
  21123. }
  21124. return
  21125. }
  21126. // ResetEmployee resets all changes to the "employee" edge.
  21127. func (m *WorkExperienceMutation) ResetEmployee() {
  21128. m.employee = nil
  21129. m.clearedemployee = false
  21130. }
  21131. // Where appends a list predicates to the WorkExperienceMutation builder.
  21132. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  21133. m.predicates = append(m.predicates, ps...)
  21134. }
  21135. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  21136. // users can use type-assertion to append predicates that do not depend on any generated package.
  21137. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  21138. p := make([]predicate.WorkExperience, len(ps))
  21139. for i := range ps {
  21140. p[i] = ps[i]
  21141. }
  21142. m.Where(p...)
  21143. }
  21144. // Op returns the operation name.
  21145. func (m *WorkExperienceMutation) Op() Op {
  21146. return m.op
  21147. }
  21148. // SetOp allows setting the mutation operation.
  21149. func (m *WorkExperienceMutation) SetOp(op Op) {
  21150. m.op = op
  21151. }
  21152. // Type returns the node type of this mutation (WorkExperience).
  21153. func (m *WorkExperienceMutation) Type() string {
  21154. return m.typ
  21155. }
  21156. // Fields returns all fields that were changed during this mutation. Note that in
  21157. // order to get all numeric fields that were incremented/decremented, call
  21158. // AddedFields().
  21159. func (m *WorkExperienceMutation) Fields() []string {
  21160. fields := make([]string, 0, 9)
  21161. if m.created_at != nil {
  21162. fields = append(fields, workexperience.FieldCreatedAt)
  21163. }
  21164. if m.updated_at != nil {
  21165. fields = append(fields, workexperience.FieldUpdatedAt)
  21166. }
  21167. if m.deleted_at != nil {
  21168. fields = append(fields, workexperience.FieldDeletedAt)
  21169. }
  21170. if m.employee != nil {
  21171. fields = append(fields, workexperience.FieldEmployeeID)
  21172. }
  21173. if m.start_date != nil {
  21174. fields = append(fields, workexperience.FieldStartDate)
  21175. }
  21176. if m.end_date != nil {
  21177. fields = append(fields, workexperience.FieldEndDate)
  21178. }
  21179. if m.company != nil {
  21180. fields = append(fields, workexperience.FieldCompany)
  21181. }
  21182. if m.experience != nil {
  21183. fields = append(fields, workexperience.FieldExperience)
  21184. }
  21185. if m.organization_id != nil {
  21186. fields = append(fields, workexperience.FieldOrganizationID)
  21187. }
  21188. return fields
  21189. }
  21190. // Field returns the value of a field with the given name. The second boolean
  21191. // return value indicates that this field was not set, or was not defined in the
  21192. // schema.
  21193. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  21194. switch name {
  21195. case workexperience.FieldCreatedAt:
  21196. return m.CreatedAt()
  21197. case workexperience.FieldUpdatedAt:
  21198. return m.UpdatedAt()
  21199. case workexperience.FieldDeletedAt:
  21200. return m.DeletedAt()
  21201. case workexperience.FieldEmployeeID:
  21202. return m.EmployeeID()
  21203. case workexperience.FieldStartDate:
  21204. return m.StartDate()
  21205. case workexperience.FieldEndDate:
  21206. return m.EndDate()
  21207. case workexperience.FieldCompany:
  21208. return m.Company()
  21209. case workexperience.FieldExperience:
  21210. return m.Experience()
  21211. case workexperience.FieldOrganizationID:
  21212. return m.OrganizationID()
  21213. }
  21214. return nil, false
  21215. }
  21216. // OldField returns the old value of the field from the database. An error is
  21217. // returned if the mutation operation is not UpdateOne, or the query to the
  21218. // database failed.
  21219. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21220. switch name {
  21221. case workexperience.FieldCreatedAt:
  21222. return m.OldCreatedAt(ctx)
  21223. case workexperience.FieldUpdatedAt:
  21224. return m.OldUpdatedAt(ctx)
  21225. case workexperience.FieldDeletedAt:
  21226. return m.OldDeletedAt(ctx)
  21227. case workexperience.FieldEmployeeID:
  21228. return m.OldEmployeeID(ctx)
  21229. case workexperience.FieldStartDate:
  21230. return m.OldStartDate(ctx)
  21231. case workexperience.FieldEndDate:
  21232. return m.OldEndDate(ctx)
  21233. case workexperience.FieldCompany:
  21234. return m.OldCompany(ctx)
  21235. case workexperience.FieldExperience:
  21236. return m.OldExperience(ctx)
  21237. case workexperience.FieldOrganizationID:
  21238. return m.OldOrganizationID(ctx)
  21239. }
  21240. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  21241. }
  21242. // SetField sets the value of a field with the given name. It returns an error if
  21243. // the field is not defined in the schema, or if the type mismatched the field
  21244. // type.
  21245. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  21246. switch name {
  21247. case workexperience.FieldCreatedAt:
  21248. v, ok := value.(time.Time)
  21249. if !ok {
  21250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21251. }
  21252. m.SetCreatedAt(v)
  21253. return nil
  21254. case workexperience.FieldUpdatedAt:
  21255. v, ok := value.(time.Time)
  21256. if !ok {
  21257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21258. }
  21259. m.SetUpdatedAt(v)
  21260. return nil
  21261. case workexperience.FieldDeletedAt:
  21262. v, ok := value.(time.Time)
  21263. if !ok {
  21264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21265. }
  21266. m.SetDeletedAt(v)
  21267. return nil
  21268. case workexperience.FieldEmployeeID:
  21269. v, ok := value.(uint64)
  21270. if !ok {
  21271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21272. }
  21273. m.SetEmployeeID(v)
  21274. return nil
  21275. case workexperience.FieldStartDate:
  21276. v, ok := value.(time.Time)
  21277. if !ok {
  21278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21279. }
  21280. m.SetStartDate(v)
  21281. return nil
  21282. case workexperience.FieldEndDate:
  21283. v, ok := value.(time.Time)
  21284. if !ok {
  21285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21286. }
  21287. m.SetEndDate(v)
  21288. return nil
  21289. case workexperience.FieldCompany:
  21290. v, ok := value.(string)
  21291. if !ok {
  21292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21293. }
  21294. m.SetCompany(v)
  21295. return nil
  21296. case workexperience.FieldExperience:
  21297. v, ok := value.(string)
  21298. if !ok {
  21299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21300. }
  21301. m.SetExperience(v)
  21302. return nil
  21303. case workexperience.FieldOrganizationID:
  21304. v, ok := value.(uint64)
  21305. if !ok {
  21306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21307. }
  21308. m.SetOrganizationID(v)
  21309. return nil
  21310. }
  21311. return fmt.Errorf("unknown WorkExperience field %s", name)
  21312. }
  21313. // AddedFields returns all numeric fields that were incremented/decremented during
  21314. // this mutation.
  21315. func (m *WorkExperienceMutation) AddedFields() []string {
  21316. var fields []string
  21317. if m.addorganization_id != nil {
  21318. fields = append(fields, workexperience.FieldOrganizationID)
  21319. }
  21320. return fields
  21321. }
  21322. // AddedField returns the numeric value that was incremented/decremented on a field
  21323. // with the given name. The second boolean return value indicates that this field
  21324. // was not set, or was not defined in the schema.
  21325. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  21326. switch name {
  21327. case workexperience.FieldOrganizationID:
  21328. return m.AddedOrganizationID()
  21329. }
  21330. return nil, false
  21331. }
  21332. // AddField adds the value to the field with the given name. It returns an error if
  21333. // the field is not defined in the schema, or if the type mismatched the field
  21334. // type.
  21335. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  21336. switch name {
  21337. case workexperience.FieldOrganizationID:
  21338. v, ok := value.(int64)
  21339. if !ok {
  21340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21341. }
  21342. m.AddOrganizationID(v)
  21343. return nil
  21344. }
  21345. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  21346. }
  21347. // ClearedFields returns all nullable fields that were cleared during this
  21348. // mutation.
  21349. func (m *WorkExperienceMutation) ClearedFields() []string {
  21350. var fields []string
  21351. if m.FieldCleared(workexperience.FieldDeletedAt) {
  21352. fields = append(fields, workexperience.FieldDeletedAt)
  21353. }
  21354. return fields
  21355. }
  21356. // FieldCleared returns a boolean indicating if a field with the given name was
  21357. // cleared in this mutation.
  21358. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  21359. _, ok := m.clearedFields[name]
  21360. return ok
  21361. }
  21362. // ClearField clears the value of the field with the given name. It returns an
  21363. // error if the field is not defined in the schema.
  21364. func (m *WorkExperienceMutation) ClearField(name string) error {
  21365. switch name {
  21366. case workexperience.FieldDeletedAt:
  21367. m.ClearDeletedAt()
  21368. return nil
  21369. }
  21370. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  21371. }
  21372. // ResetField resets all changes in the mutation for the field with the given name.
  21373. // It returns an error if the field is not defined in the schema.
  21374. func (m *WorkExperienceMutation) ResetField(name string) error {
  21375. switch name {
  21376. case workexperience.FieldCreatedAt:
  21377. m.ResetCreatedAt()
  21378. return nil
  21379. case workexperience.FieldUpdatedAt:
  21380. m.ResetUpdatedAt()
  21381. return nil
  21382. case workexperience.FieldDeletedAt:
  21383. m.ResetDeletedAt()
  21384. return nil
  21385. case workexperience.FieldEmployeeID:
  21386. m.ResetEmployeeID()
  21387. return nil
  21388. case workexperience.FieldStartDate:
  21389. m.ResetStartDate()
  21390. return nil
  21391. case workexperience.FieldEndDate:
  21392. m.ResetEndDate()
  21393. return nil
  21394. case workexperience.FieldCompany:
  21395. m.ResetCompany()
  21396. return nil
  21397. case workexperience.FieldExperience:
  21398. m.ResetExperience()
  21399. return nil
  21400. case workexperience.FieldOrganizationID:
  21401. m.ResetOrganizationID()
  21402. return nil
  21403. }
  21404. return fmt.Errorf("unknown WorkExperience field %s", name)
  21405. }
  21406. // AddedEdges returns all edge names that were set/added in this mutation.
  21407. func (m *WorkExperienceMutation) AddedEdges() []string {
  21408. edges := make([]string, 0, 1)
  21409. if m.employee != nil {
  21410. edges = append(edges, workexperience.EdgeEmployee)
  21411. }
  21412. return edges
  21413. }
  21414. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21415. // name in this mutation.
  21416. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  21417. switch name {
  21418. case workexperience.EdgeEmployee:
  21419. if id := m.employee; id != nil {
  21420. return []ent.Value{*id}
  21421. }
  21422. }
  21423. return nil
  21424. }
  21425. // RemovedEdges returns all edge names that were removed in this mutation.
  21426. func (m *WorkExperienceMutation) RemovedEdges() []string {
  21427. edges := make([]string, 0, 1)
  21428. return edges
  21429. }
  21430. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21431. // the given name in this mutation.
  21432. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  21433. return nil
  21434. }
  21435. // ClearedEdges returns all edge names that were cleared in this mutation.
  21436. func (m *WorkExperienceMutation) ClearedEdges() []string {
  21437. edges := make([]string, 0, 1)
  21438. if m.clearedemployee {
  21439. edges = append(edges, workexperience.EdgeEmployee)
  21440. }
  21441. return edges
  21442. }
  21443. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21444. // was cleared in this mutation.
  21445. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  21446. switch name {
  21447. case workexperience.EdgeEmployee:
  21448. return m.clearedemployee
  21449. }
  21450. return false
  21451. }
  21452. // ClearEdge clears the value of the edge with the given name. It returns an error
  21453. // if that edge is not defined in the schema.
  21454. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  21455. switch name {
  21456. case workexperience.EdgeEmployee:
  21457. m.ClearEmployee()
  21458. return nil
  21459. }
  21460. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  21461. }
  21462. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21463. // It returns an error if the edge is not defined in the schema.
  21464. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  21465. switch name {
  21466. case workexperience.EdgeEmployee:
  21467. m.ResetEmployee()
  21468. return nil
  21469. }
  21470. return fmt.Errorf("unknown WorkExperience edge %s", name)
  21471. }
  21472. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  21473. type WxMutation struct {
  21474. config
  21475. op Op
  21476. typ string
  21477. id *uint64
  21478. created_at *time.Time
  21479. updated_at *time.Time
  21480. status *uint8
  21481. addstatus *int8
  21482. deleted_at *time.Time
  21483. port *string
  21484. process_id *string
  21485. callback *string
  21486. wxid *string
  21487. account *string
  21488. nickname *string
  21489. tel *string
  21490. head_big *string
  21491. organization_id *uint64
  21492. addorganization_id *int64
  21493. api_base *string
  21494. api_key *string
  21495. allow_list *[]string
  21496. appendallow_list []string
  21497. group_allow_list *[]string
  21498. appendgroup_allow_list []string
  21499. block_list *[]string
  21500. appendblock_list []string
  21501. group_block_list *[]string
  21502. appendgroup_block_list []string
  21503. clearedFields map[string]struct{}
  21504. server *uint64
  21505. clearedserver bool
  21506. agent *uint64
  21507. clearedagent bool
  21508. done bool
  21509. oldValue func(context.Context) (*Wx, error)
  21510. predicates []predicate.Wx
  21511. }
  21512. var _ ent.Mutation = (*WxMutation)(nil)
  21513. // wxOption allows management of the mutation configuration using functional options.
  21514. type wxOption func(*WxMutation)
  21515. // newWxMutation creates new mutation for the Wx entity.
  21516. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  21517. m := &WxMutation{
  21518. config: c,
  21519. op: op,
  21520. typ: TypeWx,
  21521. clearedFields: make(map[string]struct{}),
  21522. }
  21523. for _, opt := range opts {
  21524. opt(m)
  21525. }
  21526. return m
  21527. }
  21528. // withWxID sets the ID field of the mutation.
  21529. func withWxID(id uint64) wxOption {
  21530. return func(m *WxMutation) {
  21531. var (
  21532. err error
  21533. once sync.Once
  21534. value *Wx
  21535. )
  21536. m.oldValue = func(ctx context.Context) (*Wx, error) {
  21537. once.Do(func() {
  21538. if m.done {
  21539. err = errors.New("querying old values post mutation is not allowed")
  21540. } else {
  21541. value, err = m.Client().Wx.Get(ctx, id)
  21542. }
  21543. })
  21544. return value, err
  21545. }
  21546. m.id = &id
  21547. }
  21548. }
  21549. // withWx sets the old Wx of the mutation.
  21550. func withWx(node *Wx) wxOption {
  21551. return func(m *WxMutation) {
  21552. m.oldValue = func(context.Context) (*Wx, error) {
  21553. return node, nil
  21554. }
  21555. m.id = &node.ID
  21556. }
  21557. }
  21558. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21559. // executed in a transaction (ent.Tx), a transactional client is returned.
  21560. func (m WxMutation) Client() *Client {
  21561. client := &Client{config: m.config}
  21562. client.init()
  21563. return client
  21564. }
  21565. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21566. // it returns an error otherwise.
  21567. func (m WxMutation) Tx() (*Tx, error) {
  21568. if _, ok := m.driver.(*txDriver); !ok {
  21569. return nil, errors.New("ent: mutation is not running in a transaction")
  21570. }
  21571. tx := &Tx{config: m.config}
  21572. tx.init()
  21573. return tx, nil
  21574. }
  21575. // SetID sets the value of the id field. Note that this
  21576. // operation is only accepted on creation of Wx entities.
  21577. func (m *WxMutation) SetID(id uint64) {
  21578. m.id = &id
  21579. }
  21580. // ID returns the ID value in the mutation. Note that the ID is only available
  21581. // if it was provided to the builder or after it was returned from the database.
  21582. func (m *WxMutation) ID() (id uint64, exists bool) {
  21583. if m.id == nil {
  21584. return
  21585. }
  21586. return *m.id, true
  21587. }
  21588. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21589. // That means, if the mutation is applied within a transaction with an isolation level such
  21590. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21591. // or updated by the mutation.
  21592. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  21593. switch {
  21594. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21595. id, exists := m.ID()
  21596. if exists {
  21597. return []uint64{id}, nil
  21598. }
  21599. fallthrough
  21600. case m.op.Is(OpUpdate | OpDelete):
  21601. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  21602. default:
  21603. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21604. }
  21605. }
  21606. // SetCreatedAt sets the "created_at" field.
  21607. func (m *WxMutation) SetCreatedAt(t time.Time) {
  21608. m.created_at = &t
  21609. }
  21610. // CreatedAt returns the value of the "created_at" field in the mutation.
  21611. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  21612. v := m.created_at
  21613. if v == nil {
  21614. return
  21615. }
  21616. return *v, true
  21617. }
  21618. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  21619. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21621. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21622. if !m.op.Is(OpUpdateOne) {
  21623. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21624. }
  21625. if m.id == nil || m.oldValue == nil {
  21626. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21627. }
  21628. oldValue, err := m.oldValue(ctx)
  21629. if err != nil {
  21630. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21631. }
  21632. return oldValue.CreatedAt, nil
  21633. }
  21634. // ResetCreatedAt resets all changes to the "created_at" field.
  21635. func (m *WxMutation) ResetCreatedAt() {
  21636. m.created_at = nil
  21637. }
  21638. // SetUpdatedAt sets the "updated_at" field.
  21639. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  21640. m.updated_at = &t
  21641. }
  21642. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21643. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  21644. v := m.updated_at
  21645. if v == nil {
  21646. return
  21647. }
  21648. return *v, true
  21649. }
  21650. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  21651. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21653. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21654. if !m.op.Is(OpUpdateOne) {
  21655. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21656. }
  21657. if m.id == nil || m.oldValue == nil {
  21658. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21659. }
  21660. oldValue, err := m.oldValue(ctx)
  21661. if err != nil {
  21662. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21663. }
  21664. return oldValue.UpdatedAt, nil
  21665. }
  21666. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21667. func (m *WxMutation) ResetUpdatedAt() {
  21668. m.updated_at = nil
  21669. }
  21670. // SetStatus sets the "status" field.
  21671. func (m *WxMutation) SetStatus(u uint8) {
  21672. m.status = &u
  21673. m.addstatus = nil
  21674. }
  21675. // Status returns the value of the "status" field in the mutation.
  21676. func (m *WxMutation) Status() (r uint8, exists bool) {
  21677. v := m.status
  21678. if v == nil {
  21679. return
  21680. }
  21681. return *v, true
  21682. }
  21683. // OldStatus returns the old "status" field's value of the Wx entity.
  21684. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21686. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21687. if !m.op.Is(OpUpdateOne) {
  21688. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21689. }
  21690. if m.id == nil || m.oldValue == nil {
  21691. return v, errors.New("OldStatus requires an ID field in the mutation")
  21692. }
  21693. oldValue, err := m.oldValue(ctx)
  21694. if err != nil {
  21695. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21696. }
  21697. return oldValue.Status, nil
  21698. }
  21699. // AddStatus adds u to the "status" field.
  21700. func (m *WxMutation) AddStatus(u int8) {
  21701. if m.addstatus != nil {
  21702. *m.addstatus += u
  21703. } else {
  21704. m.addstatus = &u
  21705. }
  21706. }
  21707. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21708. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  21709. v := m.addstatus
  21710. if v == nil {
  21711. return
  21712. }
  21713. return *v, true
  21714. }
  21715. // ClearStatus clears the value of the "status" field.
  21716. func (m *WxMutation) ClearStatus() {
  21717. m.status = nil
  21718. m.addstatus = nil
  21719. m.clearedFields[wx.FieldStatus] = struct{}{}
  21720. }
  21721. // StatusCleared returns if the "status" field was cleared in this mutation.
  21722. func (m *WxMutation) StatusCleared() bool {
  21723. _, ok := m.clearedFields[wx.FieldStatus]
  21724. return ok
  21725. }
  21726. // ResetStatus resets all changes to the "status" field.
  21727. func (m *WxMutation) ResetStatus() {
  21728. m.status = nil
  21729. m.addstatus = nil
  21730. delete(m.clearedFields, wx.FieldStatus)
  21731. }
  21732. // SetDeletedAt sets the "deleted_at" field.
  21733. func (m *WxMutation) SetDeletedAt(t time.Time) {
  21734. m.deleted_at = &t
  21735. }
  21736. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21737. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  21738. v := m.deleted_at
  21739. if v == nil {
  21740. return
  21741. }
  21742. return *v, true
  21743. }
  21744. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  21745. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21747. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21748. if !m.op.Is(OpUpdateOne) {
  21749. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21750. }
  21751. if m.id == nil || m.oldValue == nil {
  21752. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21753. }
  21754. oldValue, err := m.oldValue(ctx)
  21755. if err != nil {
  21756. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21757. }
  21758. return oldValue.DeletedAt, nil
  21759. }
  21760. // ClearDeletedAt clears the value of the "deleted_at" field.
  21761. func (m *WxMutation) ClearDeletedAt() {
  21762. m.deleted_at = nil
  21763. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  21764. }
  21765. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21766. func (m *WxMutation) DeletedAtCleared() bool {
  21767. _, ok := m.clearedFields[wx.FieldDeletedAt]
  21768. return ok
  21769. }
  21770. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21771. func (m *WxMutation) ResetDeletedAt() {
  21772. m.deleted_at = nil
  21773. delete(m.clearedFields, wx.FieldDeletedAt)
  21774. }
  21775. // SetServerID sets the "server_id" field.
  21776. func (m *WxMutation) SetServerID(u uint64) {
  21777. m.server = &u
  21778. }
  21779. // ServerID returns the value of the "server_id" field in the mutation.
  21780. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  21781. v := m.server
  21782. if v == nil {
  21783. return
  21784. }
  21785. return *v, true
  21786. }
  21787. // OldServerID returns the old "server_id" field's value of the Wx entity.
  21788. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21790. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  21791. if !m.op.Is(OpUpdateOne) {
  21792. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  21793. }
  21794. if m.id == nil || m.oldValue == nil {
  21795. return v, errors.New("OldServerID requires an ID field in the mutation")
  21796. }
  21797. oldValue, err := m.oldValue(ctx)
  21798. if err != nil {
  21799. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  21800. }
  21801. return oldValue.ServerID, nil
  21802. }
  21803. // ClearServerID clears the value of the "server_id" field.
  21804. func (m *WxMutation) ClearServerID() {
  21805. m.server = nil
  21806. m.clearedFields[wx.FieldServerID] = struct{}{}
  21807. }
  21808. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  21809. func (m *WxMutation) ServerIDCleared() bool {
  21810. _, ok := m.clearedFields[wx.FieldServerID]
  21811. return ok
  21812. }
  21813. // ResetServerID resets all changes to the "server_id" field.
  21814. func (m *WxMutation) ResetServerID() {
  21815. m.server = nil
  21816. delete(m.clearedFields, wx.FieldServerID)
  21817. }
  21818. // SetPort sets the "port" field.
  21819. func (m *WxMutation) SetPort(s string) {
  21820. m.port = &s
  21821. }
  21822. // Port returns the value of the "port" field in the mutation.
  21823. func (m *WxMutation) Port() (r string, exists bool) {
  21824. v := m.port
  21825. if v == nil {
  21826. return
  21827. }
  21828. return *v, true
  21829. }
  21830. // OldPort returns the old "port" field's value of the Wx entity.
  21831. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21833. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  21834. if !m.op.Is(OpUpdateOne) {
  21835. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  21836. }
  21837. if m.id == nil || m.oldValue == nil {
  21838. return v, errors.New("OldPort requires an ID field in the mutation")
  21839. }
  21840. oldValue, err := m.oldValue(ctx)
  21841. if err != nil {
  21842. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  21843. }
  21844. return oldValue.Port, nil
  21845. }
  21846. // ResetPort resets all changes to the "port" field.
  21847. func (m *WxMutation) ResetPort() {
  21848. m.port = nil
  21849. }
  21850. // SetProcessID sets the "process_id" field.
  21851. func (m *WxMutation) SetProcessID(s string) {
  21852. m.process_id = &s
  21853. }
  21854. // ProcessID returns the value of the "process_id" field in the mutation.
  21855. func (m *WxMutation) ProcessID() (r string, exists bool) {
  21856. v := m.process_id
  21857. if v == nil {
  21858. return
  21859. }
  21860. return *v, true
  21861. }
  21862. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  21863. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21865. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  21866. if !m.op.Is(OpUpdateOne) {
  21867. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  21868. }
  21869. if m.id == nil || m.oldValue == nil {
  21870. return v, errors.New("OldProcessID requires an ID field in the mutation")
  21871. }
  21872. oldValue, err := m.oldValue(ctx)
  21873. if err != nil {
  21874. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  21875. }
  21876. return oldValue.ProcessID, nil
  21877. }
  21878. // ResetProcessID resets all changes to the "process_id" field.
  21879. func (m *WxMutation) ResetProcessID() {
  21880. m.process_id = nil
  21881. }
  21882. // SetCallback sets the "callback" field.
  21883. func (m *WxMutation) SetCallback(s string) {
  21884. m.callback = &s
  21885. }
  21886. // Callback returns the value of the "callback" field in the mutation.
  21887. func (m *WxMutation) Callback() (r string, exists bool) {
  21888. v := m.callback
  21889. if v == nil {
  21890. return
  21891. }
  21892. return *v, true
  21893. }
  21894. // OldCallback returns the old "callback" field's value of the Wx entity.
  21895. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21897. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  21898. if !m.op.Is(OpUpdateOne) {
  21899. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  21900. }
  21901. if m.id == nil || m.oldValue == nil {
  21902. return v, errors.New("OldCallback requires an ID field in the mutation")
  21903. }
  21904. oldValue, err := m.oldValue(ctx)
  21905. if err != nil {
  21906. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  21907. }
  21908. return oldValue.Callback, nil
  21909. }
  21910. // ResetCallback resets all changes to the "callback" field.
  21911. func (m *WxMutation) ResetCallback() {
  21912. m.callback = nil
  21913. }
  21914. // SetWxid sets the "wxid" field.
  21915. func (m *WxMutation) SetWxid(s string) {
  21916. m.wxid = &s
  21917. }
  21918. // Wxid returns the value of the "wxid" field in the mutation.
  21919. func (m *WxMutation) Wxid() (r string, exists bool) {
  21920. v := m.wxid
  21921. if v == nil {
  21922. return
  21923. }
  21924. return *v, true
  21925. }
  21926. // OldWxid returns the old "wxid" field's value of the Wx entity.
  21927. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21929. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  21930. if !m.op.Is(OpUpdateOne) {
  21931. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  21932. }
  21933. if m.id == nil || m.oldValue == nil {
  21934. return v, errors.New("OldWxid requires an ID field in the mutation")
  21935. }
  21936. oldValue, err := m.oldValue(ctx)
  21937. if err != nil {
  21938. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  21939. }
  21940. return oldValue.Wxid, nil
  21941. }
  21942. // ResetWxid resets all changes to the "wxid" field.
  21943. func (m *WxMutation) ResetWxid() {
  21944. m.wxid = nil
  21945. }
  21946. // SetAccount sets the "account" field.
  21947. func (m *WxMutation) SetAccount(s string) {
  21948. m.account = &s
  21949. }
  21950. // Account returns the value of the "account" field in the mutation.
  21951. func (m *WxMutation) Account() (r string, exists bool) {
  21952. v := m.account
  21953. if v == nil {
  21954. return
  21955. }
  21956. return *v, true
  21957. }
  21958. // OldAccount returns the old "account" field's value of the Wx entity.
  21959. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21960. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21961. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  21962. if !m.op.Is(OpUpdateOne) {
  21963. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  21964. }
  21965. if m.id == nil || m.oldValue == nil {
  21966. return v, errors.New("OldAccount requires an ID field in the mutation")
  21967. }
  21968. oldValue, err := m.oldValue(ctx)
  21969. if err != nil {
  21970. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  21971. }
  21972. return oldValue.Account, nil
  21973. }
  21974. // ResetAccount resets all changes to the "account" field.
  21975. func (m *WxMutation) ResetAccount() {
  21976. m.account = nil
  21977. }
  21978. // SetNickname sets the "nickname" field.
  21979. func (m *WxMutation) SetNickname(s string) {
  21980. m.nickname = &s
  21981. }
  21982. // Nickname returns the value of the "nickname" field in the mutation.
  21983. func (m *WxMutation) Nickname() (r string, exists bool) {
  21984. v := m.nickname
  21985. if v == nil {
  21986. return
  21987. }
  21988. return *v, true
  21989. }
  21990. // OldNickname returns the old "nickname" field's value of the Wx entity.
  21991. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21993. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  21994. if !m.op.Is(OpUpdateOne) {
  21995. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  21996. }
  21997. if m.id == nil || m.oldValue == nil {
  21998. return v, errors.New("OldNickname requires an ID field in the mutation")
  21999. }
  22000. oldValue, err := m.oldValue(ctx)
  22001. if err != nil {
  22002. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  22003. }
  22004. return oldValue.Nickname, nil
  22005. }
  22006. // ResetNickname resets all changes to the "nickname" field.
  22007. func (m *WxMutation) ResetNickname() {
  22008. m.nickname = nil
  22009. }
  22010. // SetTel sets the "tel" field.
  22011. func (m *WxMutation) SetTel(s string) {
  22012. m.tel = &s
  22013. }
  22014. // Tel returns the value of the "tel" field in the mutation.
  22015. func (m *WxMutation) Tel() (r string, exists bool) {
  22016. v := m.tel
  22017. if v == nil {
  22018. return
  22019. }
  22020. return *v, true
  22021. }
  22022. // OldTel returns the old "tel" field's value of the Wx entity.
  22023. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22025. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  22026. if !m.op.Is(OpUpdateOne) {
  22027. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  22028. }
  22029. if m.id == nil || m.oldValue == nil {
  22030. return v, errors.New("OldTel requires an ID field in the mutation")
  22031. }
  22032. oldValue, err := m.oldValue(ctx)
  22033. if err != nil {
  22034. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  22035. }
  22036. return oldValue.Tel, nil
  22037. }
  22038. // ResetTel resets all changes to the "tel" field.
  22039. func (m *WxMutation) ResetTel() {
  22040. m.tel = nil
  22041. }
  22042. // SetHeadBig sets the "head_big" field.
  22043. func (m *WxMutation) SetHeadBig(s string) {
  22044. m.head_big = &s
  22045. }
  22046. // HeadBig returns the value of the "head_big" field in the mutation.
  22047. func (m *WxMutation) HeadBig() (r string, exists bool) {
  22048. v := m.head_big
  22049. if v == nil {
  22050. return
  22051. }
  22052. return *v, true
  22053. }
  22054. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  22055. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22057. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  22058. if !m.op.Is(OpUpdateOne) {
  22059. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  22060. }
  22061. if m.id == nil || m.oldValue == nil {
  22062. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  22063. }
  22064. oldValue, err := m.oldValue(ctx)
  22065. if err != nil {
  22066. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  22067. }
  22068. return oldValue.HeadBig, nil
  22069. }
  22070. // ResetHeadBig resets all changes to the "head_big" field.
  22071. func (m *WxMutation) ResetHeadBig() {
  22072. m.head_big = nil
  22073. }
  22074. // SetOrganizationID sets the "organization_id" field.
  22075. func (m *WxMutation) SetOrganizationID(u uint64) {
  22076. m.organization_id = &u
  22077. m.addorganization_id = nil
  22078. }
  22079. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22080. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  22081. v := m.organization_id
  22082. if v == nil {
  22083. return
  22084. }
  22085. return *v, true
  22086. }
  22087. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  22088. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22090. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22091. if !m.op.Is(OpUpdateOne) {
  22092. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22093. }
  22094. if m.id == nil || m.oldValue == nil {
  22095. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22096. }
  22097. oldValue, err := m.oldValue(ctx)
  22098. if err != nil {
  22099. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22100. }
  22101. return oldValue.OrganizationID, nil
  22102. }
  22103. // AddOrganizationID adds u to the "organization_id" field.
  22104. func (m *WxMutation) AddOrganizationID(u int64) {
  22105. if m.addorganization_id != nil {
  22106. *m.addorganization_id += u
  22107. } else {
  22108. m.addorganization_id = &u
  22109. }
  22110. }
  22111. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22112. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  22113. v := m.addorganization_id
  22114. if v == nil {
  22115. return
  22116. }
  22117. return *v, true
  22118. }
  22119. // ClearOrganizationID clears the value of the "organization_id" field.
  22120. func (m *WxMutation) ClearOrganizationID() {
  22121. m.organization_id = nil
  22122. m.addorganization_id = nil
  22123. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  22124. }
  22125. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  22126. func (m *WxMutation) OrganizationIDCleared() bool {
  22127. _, ok := m.clearedFields[wx.FieldOrganizationID]
  22128. return ok
  22129. }
  22130. // ResetOrganizationID resets all changes to the "organization_id" field.
  22131. func (m *WxMutation) ResetOrganizationID() {
  22132. m.organization_id = nil
  22133. m.addorganization_id = nil
  22134. delete(m.clearedFields, wx.FieldOrganizationID)
  22135. }
  22136. // SetAgentID sets the "agent_id" field.
  22137. func (m *WxMutation) SetAgentID(u uint64) {
  22138. m.agent = &u
  22139. }
  22140. // AgentID returns the value of the "agent_id" field in the mutation.
  22141. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  22142. v := m.agent
  22143. if v == nil {
  22144. return
  22145. }
  22146. return *v, true
  22147. }
  22148. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  22149. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22151. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  22152. if !m.op.Is(OpUpdateOne) {
  22153. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  22154. }
  22155. if m.id == nil || m.oldValue == nil {
  22156. return v, errors.New("OldAgentID requires an ID field in the mutation")
  22157. }
  22158. oldValue, err := m.oldValue(ctx)
  22159. if err != nil {
  22160. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  22161. }
  22162. return oldValue.AgentID, nil
  22163. }
  22164. // ResetAgentID resets all changes to the "agent_id" field.
  22165. func (m *WxMutation) ResetAgentID() {
  22166. m.agent = nil
  22167. }
  22168. // SetAPIBase sets the "api_base" field.
  22169. func (m *WxMutation) SetAPIBase(s string) {
  22170. m.api_base = &s
  22171. }
  22172. // APIBase returns the value of the "api_base" field in the mutation.
  22173. func (m *WxMutation) APIBase() (r string, exists bool) {
  22174. v := m.api_base
  22175. if v == nil {
  22176. return
  22177. }
  22178. return *v, true
  22179. }
  22180. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  22181. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22183. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  22184. if !m.op.Is(OpUpdateOne) {
  22185. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  22186. }
  22187. if m.id == nil || m.oldValue == nil {
  22188. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  22189. }
  22190. oldValue, err := m.oldValue(ctx)
  22191. if err != nil {
  22192. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  22193. }
  22194. return oldValue.APIBase, nil
  22195. }
  22196. // ClearAPIBase clears the value of the "api_base" field.
  22197. func (m *WxMutation) ClearAPIBase() {
  22198. m.api_base = nil
  22199. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  22200. }
  22201. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  22202. func (m *WxMutation) APIBaseCleared() bool {
  22203. _, ok := m.clearedFields[wx.FieldAPIBase]
  22204. return ok
  22205. }
  22206. // ResetAPIBase resets all changes to the "api_base" field.
  22207. func (m *WxMutation) ResetAPIBase() {
  22208. m.api_base = nil
  22209. delete(m.clearedFields, wx.FieldAPIBase)
  22210. }
  22211. // SetAPIKey sets the "api_key" field.
  22212. func (m *WxMutation) SetAPIKey(s string) {
  22213. m.api_key = &s
  22214. }
  22215. // APIKey returns the value of the "api_key" field in the mutation.
  22216. func (m *WxMutation) APIKey() (r string, exists bool) {
  22217. v := m.api_key
  22218. if v == nil {
  22219. return
  22220. }
  22221. return *v, true
  22222. }
  22223. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  22224. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22226. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  22227. if !m.op.Is(OpUpdateOne) {
  22228. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  22229. }
  22230. if m.id == nil || m.oldValue == nil {
  22231. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  22232. }
  22233. oldValue, err := m.oldValue(ctx)
  22234. if err != nil {
  22235. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  22236. }
  22237. return oldValue.APIKey, nil
  22238. }
  22239. // ClearAPIKey clears the value of the "api_key" field.
  22240. func (m *WxMutation) ClearAPIKey() {
  22241. m.api_key = nil
  22242. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  22243. }
  22244. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  22245. func (m *WxMutation) APIKeyCleared() bool {
  22246. _, ok := m.clearedFields[wx.FieldAPIKey]
  22247. return ok
  22248. }
  22249. // ResetAPIKey resets all changes to the "api_key" field.
  22250. func (m *WxMutation) ResetAPIKey() {
  22251. m.api_key = nil
  22252. delete(m.clearedFields, wx.FieldAPIKey)
  22253. }
  22254. // SetAllowList sets the "allow_list" field.
  22255. func (m *WxMutation) SetAllowList(s []string) {
  22256. m.allow_list = &s
  22257. m.appendallow_list = nil
  22258. }
  22259. // AllowList returns the value of the "allow_list" field in the mutation.
  22260. func (m *WxMutation) AllowList() (r []string, exists bool) {
  22261. v := m.allow_list
  22262. if v == nil {
  22263. return
  22264. }
  22265. return *v, true
  22266. }
  22267. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  22268. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22270. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  22271. if !m.op.Is(OpUpdateOne) {
  22272. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  22273. }
  22274. if m.id == nil || m.oldValue == nil {
  22275. return v, errors.New("OldAllowList requires an ID field in the mutation")
  22276. }
  22277. oldValue, err := m.oldValue(ctx)
  22278. if err != nil {
  22279. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  22280. }
  22281. return oldValue.AllowList, nil
  22282. }
  22283. // AppendAllowList adds s to the "allow_list" field.
  22284. func (m *WxMutation) AppendAllowList(s []string) {
  22285. m.appendallow_list = append(m.appendallow_list, s...)
  22286. }
  22287. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  22288. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  22289. if len(m.appendallow_list) == 0 {
  22290. return nil, false
  22291. }
  22292. return m.appendallow_list, true
  22293. }
  22294. // ResetAllowList resets all changes to the "allow_list" field.
  22295. func (m *WxMutation) ResetAllowList() {
  22296. m.allow_list = nil
  22297. m.appendallow_list = nil
  22298. }
  22299. // SetGroupAllowList sets the "group_allow_list" field.
  22300. func (m *WxMutation) SetGroupAllowList(s []string) {
  22301. m.group_allow_list = &s
  22302. m.appendgroup_allow_list = nil
  22303. }
  22304. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  22305. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  22306. v := m.group_allow_list
  22307. if v == nil {
  22308. return
  22309. }
  22310. return *v, true
  22311. }
  22312. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  22313. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22315. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  22316. if !m.op.Is(OpUpdateOne) {
  22317. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  22318. }
  22319. if m.id == nil || m.oldValue == nil {
  22320. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  22321. }
  22322. oldValue, err := m.oldValue(ctx)
  22323. if err != nil {
  22324. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  22325. }
  22326. return oldValue.GroupAllowList, nil
  22327. }
  22328. // AppendGroupAllowList adds s to the "group_allow_list" field.
  22329. func (m *WxMutation) AppendGroupAllowList(s []string) {
  22330. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  22331. }
  22332. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  22333. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  22334. if len(m.appendgroup_allow_list) == 0 {
  22335. return nil, false
  22336. }
  22337. return m.appendgroup_allow_list, true
  22338. }
  22339. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  22340. func (m *WxMutation) ResetGroupAllowList() {
  22341. m.group_allow_list = nil
  22342. m.appendgroup_allow_list = nil
  22343. }
  22344. // SetBlockList sets the "block_list" field.
  22345. func (m *WxMutation) SetBlockList(s []string) {
  22346. m.block_list = &s
  22347. m.appendblock_list = nil
  22348. }
  22349. // BlockList returns the value of the "block_list" field in the mutation.
  22350. func (m *WxMutation) BlockList() (r []string, exists bool) {
  22351. v := m.block_list
  22352. if v == nil {
  22353. return
  22354. }
  22355. return *v, true
  22356. }
  22357. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  22358. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22360. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  22361. if !m.op.Is(OpUpdateOne) {
  22362. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  22363. }
  22364. if m.id == nil || m.oldValue == nil {
  22365. return v, errors.New("OldBlockList requires an ID field in the mutation")
  22366. }
  22367. oldValue, err := m.oldValue(ctx)
  22368. if err != nil {
  22369. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  22370. }
  22371. return oldValue.BlockList, nil
  22372. }
  22373. // AppendBlockList adds s to the "block_list" field.
  22374. func (m *WxMutation) AppendBlockList(s []string) {
  22375. m.appendblock_list = append(m.appendblock_list, s...)
  22376. }
  22377. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  22378. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  22379. if len(m.appendblock_list) == 0 {
  22380. return nil, false
  22381. }
  22382. return m.appendblock_list, true
  22383. }
  22384. // ResetBlockList resets all changes to the "block_list" field.
  22385. func (m *WxMutation) ResetBlockList() {
  22386. m.block_list = nil
  22387. m.appendblock_list = nil
  22388. }
  22389. // SetGroupBlockList sets the "group_block_list" field.
  22390. func (m *WxMutation) SetGroupBlockList(s []string) {
  22391. m.group_block_list = &s
  22392. m.appendgroup_block_list = nil
  22393. }
  22394. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  22395. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  22396. v := m.group_block_list
  22397. if v == nil {
  22398. return
  22399. }
  22400. return *v, true
  22401. }
  22402. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  22403. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22405. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  22406. if !m.op.Is(OpUpdateOne) {
  22407. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  22408. }
  22409. if m.id == nil || m.oldValue == nil {
  22410. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  22411. }
  22412. oldValue, err := m.oldValue(ctx)
  22413. if err != nil {
  22414. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  22415. }
  22416. return oldValue.GroupBlockList, nil
  22417. }
  22418. // AppendGroupBlockList adds s to the "group_block_list" field.
  22419. func (m *WxMutation) AppendGroupBlockList(s []string) {
  22420. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  22421. }
  22422. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  22423. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  22424. if len(m.appendgroup_block_list) == 0 {
  22425. return nil, false
  22426. }
  22427. return m.appendgroup_block_list, true
  22428. }
  22429. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  22430. func (m *WxMutation) ResetGroupBlockList() {
  22431. m.group_block_list = nil
  22432. m.appendgroup_block_list = nil
  22433. }
  22434. // ClearServer clears the "server" edge to the Server entity.
  22435. func (m *WxMutation) ClearServer() {
  22436. m.clearedserver = true
  22437. m.clearedFields[wx.FieldServerID] = struct{}{}
  22438. }
  22439. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  22440. func (m *WxMutation) ServerCleared() bool {
  22441. return m.ServerIDCleared() || m.clearedserver
  22442. }
  22443. // ServerIDs returns the "server" edge IDs in the mutation.
  22444. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22445. // ServerID instead. It exists only for internal usage by the builders.
  22446. func (m *WxMutation) ServerIDs() (ids []uint64) {
  22447. if id := m.server; id != nil {
  22448. ids = append(ids, *id)
  22449. }
  22450. return
  22451. }
  22452. // ResetServer resets all changes to the "server" edge.
  22453. func (m *WxMutation) ResetServer() {
  22454. m.server = nil
  22455. m.clearedserver = false
  22456. }
  22457. // ClearAgent clears the "agent" edge to the Agent entity.
  22458. func (m *WxMutation) ClearAgent() {
  22459. m.clearedagent = true
  22460. m.clearedFields[wx.FieldAgentID] = struct{}{}
  22461. }
  22462. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  22463. func (m *WxMutation) AgentCleared() bool {
  22464. return m.clearedagent
  22465. }
  22466. // AgentIDs returns the "agent" edge IDs in the mutation.
  22467. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22468. // AgentID instead. It exists only for internal usage by the builders.
  22469. func (m *WxMutation) AgentIDs() (ids []uint64) {
  22470. if id := m.agent; id != nil {
  22471. ids = append(ids, *id)
  22472. }
  22473. return
  22474. }
  22475. // ResetAgent resets all changes to the "agent" edge.
  22476. func (m *WxMutation) ResetAgent() {
  22477. m.agent = nil
  22478. m.clearedagent = false
  22479. }
  22480. // Where appends a list predicates to the WxMutation builder.
  22481. func (m *WxMutation) Where(ps ...predicate.Wx) {
  22482. m.predicates = append(m.predicates, ps...)
  22483. }
  22484. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  22485. // users can use type-assertion to append predicates that do not depend on any generated package.
  22486. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  22487. p := make([]predicate.Wx, len(ps))
  22488. for i := range ps {
  22489. p[i] = ps[i]
  22490. }
  22491. m.Where(p...)
  22492. }
  22493. // Op returns the operation name.
  22494. func (m *WxMutation) Op() Op {
  22495. return m.op
  22496. }
  22497. // SetOp allows setting the mutation operation.
  22498. func (m *WxMutation) SetOp(op Op) {
  22499. m.op = op
  22500. }
  22501. // Type returns the node type of this mutation (Wx).
  22502. func (m *WxMutation) Type() string {
  22503. return m.typ
  22504. }
  22505. // Fields returns all fields that were changed during this mutation. Note that in
  22506. // order to get all numeric fields that were incremented/decremented, call
  22507. // AddedFields().
  22508. func (m *WxMutation) Fields() []string {
  22509. fields := make([]string, 0, 21)
  22510. if m.created_at != nil {
  22511. fields = append(fields, wx.FieldCreatedAt)
  22512. }
  22513. if m.updated_at != nil {
  22514. fields = append(fields, wx.FieldUpdatedAt)
  22515. }
  22516. if m.status != nil {
  22517. fields = append(fields, wx.FieldStatus)
  22518. }
  22519. if m.deleted_at != nil {
  22520. fields = append(fields, wx.FieldDeletedAt)
  22521. }
  22522. if m.server != nil {
  22523. fields = append(fields, wx.FieldServerID)
  22524. }
  22525. if m.port != nil {
  22526. fields = append(fields, wx.FieldPort)
  22527. }
  22528. if m.process_id != nil {
  22529. fields = append(fields, wx.FieldProcessID)
  22530. }
  22531. if m.callback != nil {
  22532. fields = append(fields, wx.FieldCallback)
  22533. }
  22534. if m.wxid != nil {
  22535. fields = append(fields, wx.FieldWxid)
  22536. }
  22537. if m.account != nil {
  22538. fields = append(fields, wx.FieldAccount)
  22539. }
  22540. if m.nickname != nil {
  22541. fields = append(fields, wx.FieldNickname)
  22542. }
  22543. if m.tel != nil {
  22544. fields = append(fields, wx.FieldTel)
  22545. }
  22546. if m.head_big != nil {
  22547. fields = append(fields, wx.FieldHeadBig)
  22548. }
  22549. if m.organization_id != nil {
  22550. fields = append(fields, wx.FieldOrganizationID)
  22551. }
  22552. if m.agent != nil {
  22553. fields = append(fields, wx.FieldAgentID)
  22554. }
  22555. if m.api_base != nil {
  22556. fields = append(fields, wx.FieldAPIBase)
  22557. }
  22558. if m.api_key != nil {
  22559. fields = append(fields, wx.FieldAPIKey)
  22560. }
  22561. if m.allow_list != nil {
  22562. fields = append(fields, wx.FieldAllowList)
  22563. }
  22564. if m.group_allow_list != nil {
  22565. fields = append(fields, wx.FieldGroupAllowList)
  22566. }
  22567. if m.block_list != nil {
  22568. fields = append(fields, wx.FieldBlockList)
  22569. }
  22570. if m.group_block_list != nil {
  22571. fields = append(fields, wx.FieldGroupBlockList)
  22572. }
  22573. return fields
  22574. }
  22575. // Field returns the value of a field with the given name. The second boolean
  22576. // return value indicates that this field was not set, or was not defined in the
  22577. // schema.
  22578. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  22579. switch name {
  22580. case wx.FieldCreatedAt:
  22581. return m.CreatedAt()
  22582. case wx.FieldUpdatedAt:
  22583. return m.UpdatedAt()
  22584. case wx.FieldStatus:
  22585. return m.Status()
  22586. case wx.FieldDeletedAt:
  22587. return m.DeletedAt()
  22588. case wx.FieldServerID:
  22589. return m.ServerID()
  22590. case wx.FieldPort:
  22591. return m.Port()
  22592. case wx.FieldProcessID:
  22593. return m.ProcessID()
  22594. case wx.FieldCallback:
  22595. return m.Callback()
  22596. case wx.FieldWxid:
  22597. return m.Wxid()
  22598. case wx.FieldAccount:
  22599. return m.Account()
  22600. case wx.FieldNickname:
  22601. return m.Nickname()
  22602. case wx.FieldTel:
  22603. return m.Tel()
  22604. case wx.FieldHeadBig:
  22605. return m.HeadBig()
  22606. case wx.FieldOrganizationID:
  22607. return m.OrganizationID()
  22608. case wx.FieldAgentID:
  22609. return m.AgentID()
  22610. case wx.FieldAPIBase:
  22611. return m.APIBase()
  22612. case wx.FieldAPIKey:
  22613. return m.APIKey()
  22614. case wx.FieldAllowList:
  22615. return m.AllowList()
  22616. case wx.FieldGroupAllowList:
  22617. return m.GroupAllowList()
  22618. case wx.FieldBlockList:
  22619. return m.BlockList()
  22620. case wx.FieldGroupBlockList:
  22621. return m.GroupBlockList()
  22622. }
  22623. return nil, false
  22624. }
  22625. // OldField returns the old value of the field from the database. An error is
  22626. // returned if the mutation operation is not UpdateOne, or the query to the
  22627. // database failed.
  22628. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22629. switch name {
  22630. case wx.FieldCreatedAt:
  22631. return m.OldCreatedAt(ctx)
  22632. case wx.FieldUpdatedAt:
  22633. return m.OldUpdatedAt(ctx)
  22634. case wx.FieldStatus:
  22635. return m.OldStatus(ctx)
  22636. case wx.FieldDeletedAt:
  22637. return m.OldDeletedAt(ctx)
  22638. case wx.FieldServerID:
  22639. return m.OldServerID(ctx)
  22640. case wx.FieldPort:
  22641. return m.OldPort(ctx)
  22642. case wx.FieldProcessID:
  22643. return m.OldProcessID(ctx)
  22644. case wx.FieldCallback:
  22645. return m.OldCallback(ctx)
  22646. case wx.FieldWxid:
  22647. return m.OldWxid(ctx)
  22648. case wx.FieldAccount:
  22649. return m.OldAccount(ctx)
  22650. case wx.FieldNickname:
  22651. return m.OldNickname(ctx)
  22652. case wx.FieldTel:
  22653. return m.OldTel(ctx)
  22654. case wx.FieldHeadBig:
  22655. return m.OldHeadBig(ctx)
  22656. case wx.FieldOrganizationID:
  22657. return m.OldOrganizationID(ctx)
  22658. case wx.FieldAgentID:
  22659. return m.OldAgentID(ctx)
  22660. case wx.FieldAPIBase:
  22661. return m.OldAPIBase(ctx)
  22662. case wx.FieldAPIKey:
  22663. return m.OldAPIKey(ctx)
  22664. case wx.FieldAllowList:
  22665. return m.OldAllowList(ctx)
  22666. case wx.FieldGroupAllowList:
  22667. return m.OldGroupAllowList(ctx)
  22668. case wx.FieldBlockList:
  22669. return m.OldBlockList(ctx)
  22670. case wx.FieldGroupBlockList:
  22671. return m.OldGroupBlockList(ctx)
  22672. }
  22673. return nil, fmt.Errorf("unknown Wx field %s", name)
  22674. }
  22675. // SetField sets the value of a field with the given name. It returns an error if
  22676. // the field is not defined in the schema, or if the type mismatched the field
  22677. // type.
  22678. func (m *WxMutation) SetField(name string, value ent.Value) error {
  22679. switch name {
  22680. case wx.FieldCreatedAt:
  22681. v, ok := value.(time.Time)
  22682. if !ok {
  22683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22684. }
  22685. m.SetCreatedAt(v)
  22686. return nil
  22687. case wx.FieldUpdatedAt:
  22688. v, ok := value.(time.Time)
  22689. if !ok {
  22690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22691. }
  22692. m.SetUpdatedAt(v)
  22693. return nil
  22694. case wx.FieldStatus:
  22695. v, ok := value.(uint8)
  22696. if !ok {
  22697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22698. }
  22699. m.SetStatus(v)
  22700. return nil
  22701. case wx.FieldDeletedAt:
  22702. v, ok := value.(time.Time)
  22703. if !ok {
  22704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22705. }
  22706. m.SetDeletedAt(v)
  22707. return nil
  22708. case wx.FieldServerID:
  22709. v, ok := value.(uint64)
  22710. if !ok {
  22711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22712. }
  22713. m.SetServerID(v)
  22714. return nil
  22715. case wx.FieldPort:
  22716. v, ok := value.(string)
  22717. if !ok {
  22718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22719. }
  22720. m.SetPort(v)
  22721. return nil
  22722. case wx.FieldProcessID:
  22723. v, ok := value.(string)
  22724. if !ok {
  22725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22726. }
  22727. m.SetProcessID(v)
  22728. return nil
  22729. case wx.FieldCallback:
  22730. v, ok := value.(string)
  22731. if !ok {
  22732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22733. }
  22734. m.SetCallback(v)
  22735. return nil
  22736. case wx.FieldWxid:
  22737. v, ok := value.(string)
  22738. if !ok {
  22739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22740. }
  22741. m.SetWxid(v)
  22742. return nil
  22743. case wx.FieldAccount:
  22744. v, ok := value.(string)
  22745. if !ok {
  22746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22747. }
  22748. m.SetAccount(v)
  22749. return nil
  22750. case wx.FieldNickname:
  22751. v, ok := value.(string)
  22752. if !ok {
  22753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22754. }
  22755. m.SetNickname(v)
  22756. return nil
  22757. case wx.FieldTel:
  22758. v, ok := value.(string)
  22759. if !ok {
  22760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22761. }
  22762. m.SetTel(v)
  22763. return nil
  22764. case wx.FieldHeadBig:
  22765. v, ok := value.(string)
  22766. if !ok {
  22767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22768. }
  22769. m.SetHeadBig(v)
  22770. return nil
  22771. case wx.FieldOrganizationID:
  22772. v, ok := value.(uint64)
  22773. if !ok {
  22774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22775. }
  22776. m.SetOrganizationID(v)
  22777. return nil
  22778. case wx.FieldAgentID:
  22779. v, ok := value.(uint64)
  22780. if !ok {
  22781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22782. }
  22783. m.SetAgentID(v)
  22784. return nil
  22785. case wx.FieldAPIBase:
  22786. v, ok := value.(string)
  22787. if !ok {
  22788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22789. }
  22790. m.SetAPIBase(v)
  22791. return nil
  22792. case wx.FieldAPIKey:
  22793. v, ok := value.(string)
  22794. if !ok {
  22795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22796. }
  22797. m.SetAPIKey(v)
  22798. return nil
  22799. case wx.FieldAllowList:
  22800. v, ok := value.([]string)
  22801. if !ok {
  22802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22803. }
  22804. m.SetAllowList(v)
  22805. return nil
  22806. case wx.FieldGroupAllowList:
  22807. v, ok := value.([]string)
  22808. if !ok {
  22809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22810. }
  22811. m.SetGroupAllowList(v)
  22812. return nil
  22813. case wx.FieldBlockList:
  22814. v, ok := value.([]string)
  22815. if !ok {
  22816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22817. }
  22818. m.SetBlockList(v)
  22819. return nil
  22820. case wx.FieldGroupBlockList:
  22821. v, ok := value.([]string)
  22822. if !ok {
  22823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22824. }
  22825. m.SetGroupBlockList(v)
  22826. return nil
  22827. }
  22828. return fmt.Errorf("unknown Wx field %s", name)
  22829. }
  22830. // AddedFields returns all numeric fields that were incremented/decremented during
  22831. // this mutation.
  22832. func (m *WxMutation) AddedFields() []string {
  22833. var fields []string
  22834. if m.addstatus != nil {
  22835. fields = append(fields, wx.FieldStatus)
  22836. }
  22837. if m.addorganization_id != nil {
  22838. fields = append(fields, wx.FieldOrganizationID)
  22839. }
  22840. return fields
  22841. }
  22842. // AddedField returns the numeric value that was incremented/decremented on a field
  22843. // with the given name. The second boolean return value indicates that this field
  22844. // was not set, or was not defined in the schema.
  22845. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  22846. switch name {
  22847. case wx.FieldStatus:
  22848. return m.AddedStatus()
  22849. case wx.FieldOrganizationID:
  22850. return m.AddedOrganizationID()
  22851. }
  22852. return nil, false
  22853. }
  22854. // AddField adds the value to the field with the given name. It returns an error if
  22855. // the field is not defined in the schema, or if the type mismatched the field
  22856. // type.
  22857. func (m *WxMutation) AddField(name string, value ent.Value) error {
  22858. switch name {
  22859. case wx.FieldStatus:
  22860. v, ok := value.(int8)
  22861. if !ok {
  22862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22863. }
  22864. m.AddStatus(v)
  22865. return nil
  22866. case wx.FieldOrganizationID:
  22867. v, ok := value.(int64)
  22868. if !ok {
  22869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22870. }
  22871. m.AddOrganizationID(v)
  22872. return nil
  22873. }
  22874. return fmt.Errorf("unknown Wx numeric field %s", name)
  22875. }
  22876. // ClearedFields returns all nullable fields that were cleared during this
  22877. // mutation.
  22878. func (m *WxMutation) ClearedFields() []string {
  22879. var fields []string
  22880. if m.FieldCleared(wx.FieldStatus) {
  22881. fields = append(fields, wx.FieldStatus)
  22882. }
  22883. if m.FieldCleared(wx.FieldDeletedAt) {
  22884. fields = append(fields, wx.FieldDeletedAt)
  22885. }
  22886. if m.FieldCleared(wx.FieldServerID) {
  22887. fields = append(fields, wx.FieldServerID)
  22888. }
  22889. if m.FieldCleared(wx.FieldOrganizationID) {
  22890. fields = append(fields, wx.FieldOrganizationID)
  22891. }
  22892. if m.FieldCleared(wx.FieldAPIBase) {
  22893. fields = append(fields, wx.FieldAPIBase)
  22894. }
  22895. if m.FieldCleared(wx.FieldAPIKey) {
  22896. fields = append(fields, wx.FieldAPIKey)
  22897. }
  22898. return fields
  22899. }
  22900. // FieldCleared returns a boolean indicating if a field with the given name was
  22901. // cleared in this mutation.
  22902. func (m *WxMutation) FieldCleared(name string) bool {
  22903. _, ok := m.clearedFields[name]
  22904. return ok
  22905. }
  22906. // ClearField clears the value of the field with the given name. It returns an
  22907. // error if the field is not defined in the schema.
  22908. func (m *WxMutation) ClearField(name string) error {
  22909. switch name {
  22910. case wx.FieldStatus:
  22911. m.ClearStatus()
  22912. return nil
  22913. case wx.FieldDeletedAt:
  22914. m.ClearDeletedAt()
  22915. return nil
  22916. case wx.FieldServerID:
  22917. m.ClearServerID()
  22918. return nil
  22919. case wx.FieldOrganizationID:
  22920. m.ClearOrganizationID()
  22921. return nil
  22922. case wx.FieldAPIBase:
  22923. m.ClearAPIBase()
  22924. return nil
  22925. case wx.FieldAPIKey:
  22926. m.ClearAPIKey()
  22927. return nil
  22928. }
  22929. return fmt.Errorf("unknown Wx nullable field %s", name)
  22930. }
  22931. // ResetField resets all changes in the mutation for the field with the given name.
  22932. // It returns an error if the field is not defined in the schema.
  22933. func (m *WxMutation) ResetField(name string) error {
  22934. switch name {
  22935. case wx.FieldCreatedAt:
  22936. m.ResetCreatedAt()
  22937. return nil
  22938. case wx.FieldUpdatedAt:
  22939. m.ResetUpdatedAt()
  22940. return nil
  22941. case wx.FieldStatus:
  22942. m.ResetStatus()
  22943. return nil
  22944. case wx.FieldDeletedAt:
  22945. m.ResetDeletedAt()
  22946. return nil
  22947. case wx.FieldServerID:
  22948. m.ResetServerID()
  22949. return nil
  22950. case wx.FieldPort:
  22951. m.ResetPort()
  22952. return nil
  22953. case wx.FieldProcessID:
  22954. m.ResetProcessID()
  22955. return nil
  22956. case wx.FieldCallback:
  22957. m.ResetCallback()
  22958. return nil
  22959. case wx.FieldWxid:
  22960. m.ResetWxid()
  22961. return nil
  22962. case wx.FieldAccount:
  22963. m.ResetAccount()
  22964. return nil
  22965. case wx.FieldNickname:
  22966. m.ResetNickname()
  22967. return nil
  22968. case wx.FieldTel:
  22969. m.ResetTel()
  22970. return nil
  22971. case wx.FieldHeadBig:
  22972. m.ResetHeadBig()
  22973. return nil
  22974. case wx.FieldOrganizationID:
  22975. m.ResetOrganizationID()
  22976. return nil
  22977. case wx.FieldAgentID:
  22978. m.ResetAgentID()
  22979. return nil
  22980. case wx.FieldAPIBase:
  22981. m.ResetAPIBase()
  22982. return nil
  22983. case wx.FieldAPIKey:
  22984. m.ResetAPIKey()
  22985. return nil
  22986. case wx.FieldAllowList:
  22987. m.ResetAllowList()
  22988. return nil
  22989. case wx.FieldGroupAllowList:
  22990. m.ResetGroupAllowList()
  22991. return nil
  22992. case wx.FieldBlockList:
  22993. m.ResetBlockList()
  22994. return nil
  22995. case wx.FieldGroupBlockList:
  22996. m.ResetGroupBlockList()
  22997. return nil
  22998. }
  22999. return fmt.Errorf("unknown Wx field %s", name)
  23000. }
  23001. // AddedEdges returns all edge names that were set/added in this mutation.
  23002. func (m *WxMutation) AddedEdges() []string {
  23003. edges := make([]string, 0, 2)
  23004. if m.server != nil {
  23005. edges = append(edges, wx.EdgeServer)
  23006. }
  23007. if m.agent != nil {
  23008. edges = append(edges, wx.EdgeAgent)
  23009. }
  23010. return edges
  23011. }
  23012. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23013. // name in this mutation.
  23014. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  23015. switch name {
  23016. case wx.EdgeServer:
  23017. if id := m.server; id != nil {
  23018. return []ent.Value{*id}
  23019. }
  23020. case wx.EdgeAgent:
  23021. if id := m.agent; id != nil {
  23022. return []ent.Value{*id}
  23023. }
  23024. }
  23025. return nil
  23026. }
  23027. // RemovedEdges returns all edge names that were removed in this mutation.
  23028. func (m *WxMutation) RemovedEdges() []string {
  23029. edges := make([]string, 0, 2)
  23030. return edges
  23031. }
  23032. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23033. // the given name in this mutation.
  23034. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  23035. return nil
  23036. }
  23037. // ClearedEdges returns all edge names that were cleared in this mutation.
  23038. func (m *WxMutation) ClearedEdges() []string {
  23039. edges := make([]string, 0, 2)
  23040. if m.clearedserver {
  23041. edges = append(edges, wx.EdgeServer)
  23042. }
  23043. if m.clearedagent {
  23044. edges = append(edges, wx.EdgeAgent)
  23045. }
  23046. return edges
  23047. }
  23048. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23049. // was cleared in this mutation.
  23050. func (m *WxMutation) EdgeCleared(name string) bool {
  23051. switch name {
  23052. case wx.EdgeServer:
  23053. return m.clearedserver
  23054. case wx.EdgeAgent:
  23055. return m.clearedagent
  23056. }
  23057. return false
  23058. }
  23059. // ClearEdge clears the value of the edge with the given name. It returns an error
  23060. // if that edge is not defined in the schema.
  23061. func (m *WxMutation) ClearEdge(name string) error {
  23062. switch name {
  23063. case wx.EdgeServer:
  23064. m.ClearServer()
  23065. return nil
  23066. case wx.EdgeAgent:
  23067. m.ClearAgent()
  23068. return nil
  23069. }
  23070. return fmt.Errorf("unknown Wx unique edge %s", name)
  23071. }
  23072. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23073. // It returns an error if the edge is not defined in the schema.
  23074. func (m *WxMutation) ResetEdge(name string) error {
  23075. switch name {
  23076. case wx.EdgeServer:
  23077. m.ResetServer()
  23078. return nil
  23079. case wx.EdgeAgent:
  23080. m.ResetAgent()
  23081. return nil
  23082. }
  23083. return fmt.Errorf("unknown Wx edge %s", name)
  23084. }
  23085. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  23086. type WxCardMutation struct {
  23087. config
  23088. op Op
  23089. typ string
  23090. id *uint64
  23091. created_at *time.Time
  23092. updated_at *time.Time
  23093. deleted_at *time.Time
  23094. user_id *uint64
  23095. adduser_id *int64
  23096. wx_user_id *uint64
  23097. addwx_user_id *int64
  23098. avatar *string
  23099. logo *string
  23100. name *string
  23101. company *string
  23102. address *string
  23103. phone *string
  23104. official_account *string
  23105. wechat_account *string
  23106. email *string
  23107. api_base *string
  23108. api_key *string
  23109. ai_info *string
  23110. intro *string
  23111. clearedFields map[string]struct{}
  23112. done bool
  23113. oldValue func(context.Context) (*WxCard, error)
  23114. predicates []predicate.WxCard
  23115. }
  23116. var _ ent.Mutation = (*WxCardMutation)(nil)
  23117. // wxcardOption allows management of the mutation configuration using functional options.
  23118. type wxcardOption func(*WxCardMutation)
  23119. // newWxCardMutation creates new mutation for the WxCard entity.
  23120. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  23121. m := &WxCardMutation{
  23122. config: c,
  23123. op: op,
  23124. typ: TypeWxCard,
  23125. clearedFields: make(map[string]struct{}),
  23126. }
  23127. for _, opt := range opts {
  23128. opt(m)
  23129. }
  23130. return m
  23131. }
  23132. // withWxCardID sets the ID field of the mutation.
  23133. func withWxCardID(id uint64) wxcardOption {
  23134. return func(m *WxCardMutation) {
  23135. var (
  23136. err error
  23137. once sync.Once
  23138. value *WxCard
  23139. )
  23140. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  23141. once.Do(func() {
  23142. if m.done {
  23143. err = errors.New("querying old values post mutation is not allowed")
  23144. } else {
  23145. value, err = m.Client().WxCard.Get(ctx, id)
  23146. }
  23147. })
  23148. return value, err
  23149. }
  23150. m.id = &id
  23151. }
  23152. }
  23153. // withWxCard sets the old WxCard of the mutation.
  23154. func withWxCard(node *WxCard) wxcardOption {
  23155. return func(m *WxCardMutation) {
  23156. m.oldValue = func(context.Context) (*WxCard, error) {
  23157. return node, nil
  23158. }
  23159. m.id = &node.ID
  23160. }
  23161. }
  23162. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23163. // executed in a transaction (ent.Tx), a transactional client is returned.
  23164. func (m WxCardMutation) Client() *Client {
  23165. client := &Client{config: m.config}
  23166. client.init()
  23167. return client
  23168. }
  23169. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23170. // it returns an error otherwise.
  23171. func (m WxCardMutation) Tx() (*Tx, error) {
  23172. if _, ok := m.driver.(*txDriver); !ok {
  23173. return nil, errors.New("ent: mutation is not running in a transaction")
  23174. }
  23175. tx := &Tx{config: m.config}
  23176. tx.init()
  23177. return tx, nil
  23178. }
  23179. // SetID sets the value of the id field. Note that this
  23180. // operation is only accepted on creation of WxCard entities.
  23181. func (m *WxCardMutation) SetID(id uint64) {
  23182. m.id = &id
  23183. }
  23184. // ID returns the ID value in the mutation. Note that the ID is only available
  23185. // if it was provided to the builder or after it was returned from the database.
  23186. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  23187. if m.id == nil {
  23188. return
  23189. }
  23190. return *m.id, true
  23191. }
  23192. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23193. // That means, if the mutation is applied within a transaction with an isolation level such
  23194. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23195. // or updated by the mutation.
  23196. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  23197. switch {
  23198. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23199. id, exists := m.ID()
  23200. if exists {
  23201. return []uint64{id}, nil
  23202. }
  23203. fallthrough
  23204. case m.op.Is(OpUpdate | OpDelete):
  23205. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  23206. default:
  23207. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23208. }
  23209. }
  23210. // SetCreatedAt sets the "created_at" field.
  23211. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  23212. m.created_at = &t
  23213. }
  23214. // CreatedAt returns the value of the "created_at" field in the mutation.
  23215. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  23216. v := m.created_at
  23217. if v == nil {
  23218. return
  23219. }
  23220. return *v, true
  23221. }
  23222. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  23223. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23225. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23226. if !m.op.Is(OpUpdateOne) {
  23227. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23228. }
  23229. if m.id == nil || m.oldValue == nil {
  23230. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23231. }
  23232. oldValue, err := m.oldValue(ctx)
  23233. if err != nil {
  23234. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23235. }
  23236. return oldValue.CreatedAt, nil
  23237. }
  23238. // ResetCreatedAt resets all changes to the "created_at" field.
  23239. func (m *WxCardMutation) ResetCreatedAt() {
  23240. m.created_at = nil
  23241. }
  23242. // SetUpdatedAt sets the "updated_at" field.
  23243. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  23244. m.updated_at = &t
  23245. }
  23246. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23247. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  23248. v := m.updated_at
  23249. if v == nil {
  23250. return
  23251. }
  23252. return *v, true
  23253. }
  23254. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  23255. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23257. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23258. if !m.op.Is(OpUpdateOne) {
  23259. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23260. }
  23261. if m.id == nil || m.oldValue == nil {
  23262. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23263. }
  23264. oldValue, err := m.oldValue(ctx)
  23265. if err != nil {
  23266. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23267. }
  23268. return oldValue.UpdatedAt, nil
  23269. }
  23270. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23271. func (m *WxCardMutation) ResetUpdatedAt() {
  23272. m.updated_at = nil
  23273. }
  23274. // SetDeletedAt sets the "deleted_at" field.
  23275. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  23276. m.deleted_at = &t
  23277. }
  23278. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23279. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  23280. v := m.deleted_at
  23281. if v == nil {
  23282. return
  23283. }
  23284. return *v, true
  23285. }
  23286. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  23287. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23289. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23290. if !m.op.Is(OpUpdateOne) {
  23291. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23292. }
  23293. if m.id == nil || m.oldValue == nil {
  23294. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23295. }
  23296. oldValue, err := m.oldValue(ctx)
  23297. if err != nil {
  23298. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23299. }
  23300. return oldValue.DeletedAt, nil
  23301. }
  23302. // ClearDeletedAt clears the value of the "deleted_at" field.
  23303. func (m *WxCardMutation) ClearDeletedAt() {
  23304. m.deleted_at = nil
  23305. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  23306. }
  23307. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23308. func (m *WxCardMutation) DeletedAtCleared() bool {
  23309. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  23310. return ok
  23311. }
  23312. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23313. func (m *WxCardMutation) ResetDeletedAt() {
  23314. m.deleted_at = nil
  23315. delete(m.clearedFields, wxcard.FieldDeletedAt)
  23316. }
  23317. // SetUserID sets the "user_id" field.
  23318. func (m *WxCardMutation) SetUserID(u uint64) {
  23319. m.user_id = &u
  23320. m.adduser_id = nil
  23321. }
  23322. // UserID returns the value of the "user_id" field in the mutation.
  23323. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  23324. v := m.user_id
  23325. if v == nil {
  23326. return
  23327. }
  23328. return *v, true
  23329. }
  23330. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  23331. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23333. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  23334. if !m.op.Is(OpUpdateOne) {
  23335. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  23336. }
  23337. if m.id == nil || m.oldValue == nil {
  23338. return v, errors.New("OldUserID requires an ID field in the mutation")
  23339. }
  23340. oldValue, err := m.oldValue(ctx)
  23341. if err != nil {
  23342. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  23343. }
  23344. return oldValue.UserID, nil
  23345. }
  23346. // AddUserID adds u to the "user_id" field.
  23347. func (m *WxCardMutation) AddUserID(u int64) {
  23348. if m.adduser_id != nil {
  23349. *m.adduser_id += u
  23350. } else {
  23351. m.adduser_id = &u
  23352. }
  23353. }
  23354. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  23355. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  23356. v := m.adduser_id
  23357. if v == nil {
  23358. return
  23359. }
  23360. return *v, true
  23361. }
  23362. // ClearUserID clears the value of the "user_id" field.
  23363. func (m *WxCardMutation) ClearUserID() {
  23364. m.user_id = nil
  23365. m.adduser_id = nil
  23366. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  23367. }
  23368. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  23369. func (m *WxCardMutation) UserIDCleared() bool {
  23370. _, ok := m.clearedFields[wxcard.FieldUserID]
  23371. return ok
  23372. }
  23373. // ResetUserID resets all changes to the "user_id" field.
  23374. func (m *WxCardMutation) ResetUserID() {
  23375. m.user_id = nil
  23376. m.adduser_id = nil
  23377. delete(m.clearedFields, wxcard.FieldUserID)
  23378. }
  23379. // SetWxUserID sets the "wx_user_id" field.
  23380. func (m *WxCardMutation) SetWxUserID(u uint64) {
  23381. m.wx_user_id = &u
  23382. m.addwx_user_id = nil
  23383. }
  23384. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  23385. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  23386. v := m.wx_user_id
  23387. if v == nil {
  23388. return
  23389. }
  23390. return *v, true
  23391. }
  23392. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  23393. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23395. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  23396. if !m.op.Is(OpUpdateOne) {
  23397. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  23398. }
  23399. if m.id == nil || m.oldValue == nil {
  23400. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  23401. }
  23402. oldValue, err := m.oldValue(ctx)
  23403. if err != nil {
  23404. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  23405. }
  23406. return oldValue.WxUserID, nil
  23407. }
  23408. // AddWxUserID adds u to the "wx_user_id" field.
  23409. func (m *WxCardMutation) AddWxUserID(u int64) {
  23410. if m.addwx_user_id != nil {
  23411. *m.addwx_user_id += u
  23412. } else {
  23413. m.addwx_user_id = &u
  23414. }
  23415. }
  23416. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  23417. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  23418. v := m.addwx_user_id
  23419. if v == nil {
  23420. return
  23421. }
  23422. return *v, true
  23423. }
  23424. // ClearWxUserID clears the value of the "wx_user_id" field.
  23425. func (m *WxCardMutation) ClearWxUserID() {
  23426. m.wx_user_id = nil
  23427. m.addwx_user_id = nil
  23428. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  23429. }
  23430. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  23431. func (m *WxCardMutation) WxUserIDCleared() bool {
  23432. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  23433. return ok
  23434. }
  23435. // ResetWxUserID resets all changes to the "wx_user_id" field.
  23436. func (m *WxCardMutation) ResetWxUserID() {
  23437. m.wx_user_id = nil
  23438. m.addwx_user_id = nil
  23439. delete(m.clearedFields, wxcard.FieldWxUserID)
  23440. }
  23441. // SetAvatar sets the "avatar" field.
  23442. func (m *WxCardMutation) SetAvatar(s string) {
  23443. m.avatar = &s
  23444. }
  23445. // Avatar returns the value of the "avatar" field in the mutation.
  23446. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  23447. v := m.avatar
  23448. if v == nil {
  23449. return
  23450. }
  23451. return *v, true
  23452. }
  23453. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  23454. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23456. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  23457. if !m.op.Is(OpUpdateOne) {
  23458. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  23459. }
  23460. if m.id == nil || m.oldValue == nil {
  23461. return v, errors.New("OldAvatar requires an ID field in the mutation")
  23462. }
  23463. oldValue, err := m.oldValue(ctx)
  23464. if err != nil {
  23465. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  23466. }
  23467. return oldValue.Avatar, nil
  23468. }
  23469. // ResetAvatar resets all changes to the "avatar" field.
  23470. func (m *WxCardMutation) ResetAvatar() {
  23471. m.avatar = nil
  23472. }
  23473. // SetLogo sets the "logo" field.
  23474. func (m *WxCardMutation) SetLogo(s string) {
  23475. m.logo = &s
  23476. }
  23477. // Logo returns the value of the "logo" field in the mutation.
  23478. func (m *WxCardMutation) Logo() (r string, exists bool) {
  23479. v := m.logo
  23480. if v == nil {
  23481. return
  23482. }
  23483. return *v, true
  23484. }
  23485. // OldLogo returns the old "logo" field's value of the WxCard entity.
  23486. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23488. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  23489. if !m.op.Is(OpUpdateOne) {
  23490. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  23491. }
  23492. if m.id == nil || m.oldValue == nil {
  23493. return v, errors.New("OldLogo requires an ID field in the mutation")
  23494. }
  23495. oldValue, err := m.oldValue(ctx)
  23496. if err != nil {
  23497. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  23498. }
  23499. return oldValue.Logo, nil
  23500. }
  23501. // ResetLogo resets all changes to the "logo" field.
  23502. func (m *WxCardMutation) ResetLogo() {
  23503. m.logo = nil
  23504. }
  23505. // SetName sets the "name" field.
  23506. func (m *WxCardMutation) SetName(s string) {
  23507. m.name = &s
  23508. }
  23509. // Name returns the value of the "name" field in the mutation.
  23510. func (m *WxCardMutation) Name() (r string, exists bool) {
  23511. v := m.name
  23512. if v == nil {
  23513. return
  23514. }
  23515. return *v, true
  23516. }
  23517. // OldName returns the old "name" field's value of the WxCard entity.
  23518. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23520. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  23521. if !m.op.Is(OpUpdateOne) {
  23522. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23523. }
  23524. if m.id == nil || m.oldValue == nil {
  23525. return v, errors.New("OldName requires an ID field in the mutation")
  23526. }
  23527. oldValue, err := m.oldValue(ctx)
  23528. if err != nil {
  23529. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23530. }
  23531. return oldValue.Name, nil
  23532. }
  23533. // ResetName resets all changes to the "name" field.
  23534. func (m *WxCardMutation) ResetName() {
  23535. m.name = nil
  23536. }
  23537. // SetCompany sets the "company" field.
  23538. func (m *WxCardMutation) SetCompany(s string) {
  23539. m.company = &s
  23540. }
  23541. // Company returns the value of the "company" field in the mutation.
  23542. func (m *WxCardMutation) Company() (r string, exists bool) {
  23543. v := m.company
  23544. if v == nil {
  23545. return
  23546. }
  23547. return *v, true
  23548. }
  23549. // OldCompany returns the old "company" field's value of the WxCard entity.
  23550. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23552. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  23553. if !m.op.Is(OpUpdateOne) {
  23554. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  23555. }
  23556. if m.id == nil || m.oldValue == nil {
  23557. return v, errors.New("OldCompany requires an ID field in the mutation")
  23558. }
  23559. oldValue, err := m.oldValue(ctx)
  23560. if err != nil {
  23561. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  23562. }
  23563. return oldValue.Company, nil
  23564. }
  23565. // ResetCompany resets all changes to the "company" field.
  23566. func (m *WxCardMutation) ResetCompany() {
  23567. m.company = nil
  23568. }
  23569. // SetAddress sets the "address" field.
  23570. func (m *WxCardMutation) SetAddress(s string) {
  23571. m.address = &s
  23572. }
  23573. // Address returns the value of the "address" field in the mutation.
  23574. func (m *WxCardMutation) Address() (r string, exists bool) {
  23575. v := m.address
  23576. if v == nil {
  23577. return
  23578. }
  23579. return *v, true
  23580. }
  23581. // OldAddress returns the old "address" field's value of the WxCard entity.
  23582. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23584. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  23585. if !m.op.Is(OpUpdateOne) {
  23586. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  23587. }
  23588. if m.id == nil || m.oldValue == nil {
  23589. return v, errors.New("OldAddress requires an ID field in the mutation")
  23590. }
  23591. oldValue, err := m.oldValue(ctx)
  23592. if err != nil {
  23593. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  23594. }
  23595. return oldValue.Address, nil
  23596. }
  23597. // ResetAddress resets all changes to the "address" field.
  23598. func (m *WxCardMutation) ResetAddress() {
  23599. m.address = nil
  23600. }
  23601. // SetPhone sets the "phone" field.
  23602. func (m *WxCardMutation) SetPhone(s string) {
  23603. m.phone = &s
  23604. }
  23605. // Phone returns the value of the "phone" field in the mutation.
  23606. func (m *WxCardMutation) Phone() (r string, exists bool) {
  23607. v := m.phone
  23608. if v == nil {
  23609. return
  23610. }
  23611. return *v, true
  23612. }
  23613. // OldPhone returns the old "phone" field's value of the WxCard entity.
  23614. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23616. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  23617. if !m.op.Is(OpUpdateOne) {
  23618. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  23619. }
  23620. if m.id == nil || m.oldValue == nil {
  23621. return v, errors.New("OldPhone requires an ID field in the mutation")
  23622. }
  23623. oldValue, err := m.oldValue(ctx)
  23624. if err != nil {
  23625. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  23626. }
  23627. return oldValue.Phone, nil
  23628. }
  23629. // ResetPhone resets all changes to the "phone" field.
  23630. func (m *WxCardMutation) ResetPhone() {
  23631. m.phone = nil
  23632. }
  23633. // SetOfficialAccount sets the "official_account" field.
  23634. func (m *WxCardMutation) SetOfficialAccount(s string) {
  23635. m.official_account = &s
  23636. }
  23637. // OfficialAccount returns the value of the "official_account" field in the mutation.
  23638. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  23639. v := m.official_account
  23640. if v == nil {
  23641. return
  23642. }
  23643. return *v, true
  23644. }
  23645. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  23646. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23648. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  23649. if !m.op.Is(OpUpdateOne) {
  23650. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  23651. }
  23652. if m.id == nil || m.oldValue == nil {
  23653. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  23654. }
  23655. oldValue, err := m.oldValue(ctx)
  23656. if err != nil {
  23657. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  23658. }
  23659. return oldValue.OfficialAccount, nil
  23660. }
  23661. // ResetOfficialAccount resets all changes to the "official_account" field.
  23662. func (m *WxCardMutation) ResetOfficialAccount() {
  23663. m.official_account = nil
  23664. }
  23665. // SetWechatAccount sets the "wechat_account" field.
  23666. func (m *WxCardMutation) SetWechatAccount(s string) {
  23667. m.wechat_account = &s
  23668. }
  23669. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  23670. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  23671. v := m.wechat_account
  23672. if v == nil {
  23673. return
  23674. }
  23675. return *v, true
  23676. }
  23677. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  23678. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23680. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  23681. if !m.op.Is(OpUpdateOne) {
  23682. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  23683. }
  23684. if m.id == nil || m.oldValue == nil {
  23685. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  23686. }
  23687. oldValue, err := m.oldValue(ctx)
  23688. if err != nil {
  23689. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  23690. }
  23691. return oldValue.WechatAccount, nil
  23692. }
  23693. // ResetWechatAccount resets all changes to the "wechat_account" field.
  23694. func (m *WxCardMutation) ResetWechatAccount() {
  23695. m.wechat_account = nil
  23696. }
  23697. // SetEmail sets the "email" field.
  23698. func (m *WxCardMutation) SetEmail(s string) {
  23699. m.email = &s
  23700. }
  23701. // Email returns the value of the "email" field in the mutation.
  23702. func (m *WxCardMutation) Email() (r string, exists bool) {
  23703. v := m.email
  23704. if v == nil {
  23705. return
  23706. }
  23707. return *v, true
  23708. }
  23709. // OldEmail returns the old "email" field's value of the WxCard entity.
  23710. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23712. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  23713. if !m.op.Is(OpUpdateOne) {
  23714. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  23715. }
  23716. if m.id == nil || m.oldValue == nil {
  23717. return v, errors.New("OldEmail requires an ID field in the mutation")
  23718. }
  23719. oldValue, err := m.oldValue(ctx)
  23720. if err != nil {
  23721. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  23722. }
  23723. return oldValue.Email, nil
  23724. }
  23725. // ClearEmail clears the value of the "email" field.
  23726. func (m *WxCardMutation) ClearEmail() {
  23727. m.email = nil
  23728. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  23729. }
  23730. // EmailCleared returns if the "email" field was cleared in this mutation.
  23731. func (m *WxCardMutation) EmailCleared() bool {
  23732. _, ok := m.clearedFields[wxcard.FieldEmail]
  23733. return ok
  23734. }
  23735. // ResetEmail resets all changes to the "email" field.
  23736. func (m *WxCardMutation) ResetEmail() {
  23737. m.email = nil
  23738. delete(m.clearedFields, wxcard.FieldEmail)
  23739. }
  23740. // SetAPIBase sets the "api_base" field.
  23741. func (m *WxCardMutation) SetAPIBase(s string) {
  23742. m.api_base = &s
  23743. }
  23744. // APIBase returns the value of the "api_base" field in the mutation.
  23745. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  23746. v := m.api_base
  23747. if v == nil {
  23748. return
  23749. }
  23750. return *v, true
  23751. }
  23752. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  23753. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23755. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  23756. if !m.op.Is(OpUpdateOne) {
  23757. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  23758. }
  23759. if m.id == nil || m.oldValue == nil {
  23760. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  23761. }
  23762. oldValue, err := m.oldValue(ctx)
  23763. if err != nil {
  23764. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  23765. }
  23766. return oldValue.APIBase, nil
  23767. }
  23768. // ClearAPIBase clears the value of the "api_base" field.
  23769. func (m *WxCardMutation) ClearAPIBase() {
  23770. m.api_base = nil
  23771. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  23772. }
  23773. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  23774. func (m *WxCardMutation) APIBaseCleared() bool {
  23775. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  23776. return ok
  23777. }
  23778. // ResetAPIBase resets all changes to the "api_base" field.
  23779. func (m *WxCardMutation) ResetAPIBase() {
  23780. m.api_base = nil
  23781. delete(m.clearedFields, wxcard.FieldAPIBase)
  23782. }
  23783. // SetAPIKey sets the "api_key" field.
  23784. func (m *WxCardMutation) SetAPIKey(s string) {
  23785. m.api_key = &s
  23786. }
  23787. // APIKey returns the value of the "api_key" field in the mutation.
  23788. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  23789. v := m.api_key
  23790. if v == nil {
  23791. return
  23792. }
  23793. return *v, true
  23794. }
  23795. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  23796. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23798. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  23799. if !m.op.Is(OpUpdateOne) {
  23800. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  23801. }
  23802. if m.id == nil || m.oldValue == nil {
  23803. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  23804. }
  23805. oldValue, err := m.oldValue(ctx)
  23806. if err != nil {
  23807. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  23808. }
  23809. return oldValue.APIKey, nil
  23810. }
  23811. // ClearAPIKey clears the value of the "api_key" field.
  23812. func (m *WxCardMutation) ClearAPIKey() {
  23813. m.api_key = nil
  23814. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  23815. }
  23816. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  23817. func (m *WxCardMutation) APIKeyCleared() bool {
  23818. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  23819. return ok
  23820. }
  23821. // ResetAPIKey resets all changes to the "api_key" field.
  23822. func (m *WxCardMutation) ResetAPIKey() {
  23823. m.api_key = nil
  23824. delete(m.clearedFields, wxcard.FieldAPIKey)
  23825. }
  23826. // SetAiInfo sets the "ai_info" field.
  23827. func (m *WxCardMutation) SetAiInfo(s string) {
  23828. m.ai_info = &s
  23829. }
  23830. // AiInfo returns the value of the "ai_info" field in the mutation.
  23831. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  23832. v := m.ai_info
  23833. if v == nil {
  23834. return
  23835. }
  23836. return *v, true
  23837. }
  23838. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  23839. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23841. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  23842. if !m.op.Is(OpUpdateOne) {
  23843. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  23844. }
  23845. if m.id == nil || m.oldValue == nil {
  23846. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  23847. }
  23848. oldValue, err := m.oldValue(ctx)
  23849. if err != nil {
  23850. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  23851. }
  23852. return oldValue.AiInfo, nil
  23853. }
  23854. // ClearAiInfo clears the value of the "ai_info" field.
  23855. func (m *WxCardMutation) ClearAiInfo() {
  23856. m.ai_info = nil
  23857. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  23858. }
  23859. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  23860. func (m *WxCardMutation) AiInfoCleared() bool {
  23861. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  23862. return ok
  23863. }
  23864. // ResetAiInfo resets all changes to the "ai_info" field.
  23865. func (m *WxCardMutation) ResetAiInfo() {
  23866. m.ai_info = nil
  23867. delete(m.clearedFields, wxcard.FieldAiInfo)
  23868. }
  23869. // SetIntro sets the "intro" field.
  23870. func (m *WxCardMutation) SetIntro(s string) {
  23871. m.intro = &s
  23872. }
  23873. // Intro returns the value of the "intro" field in the mutation.
  23874. func (m *WxCardMutation) Intro() (r string, exists bool) {
  23875. v := m.intro
  23876. if v == nil {
  23877. return
  23878. }
  23879. return *v, true
  23880. }
  23881. // OldIntro returns the old "intro" field's value of the WxCard entity.
  23882. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23884. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  23885. if !m.op.Is(OpUpdateOne) {
  23886. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  23887. }
  23888. if m.id == nil || m.oldValue == nil {
  23889. return v, errors.New("OldIntro requires an ID field in the mutation")
  23890. }
  23891. oldValue, err := m.oldValue(ctx)
  23892. if err != nil {
  23893. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  23894. }
  23895. return oldValue.Intro, nil
  23896. }
  23897. // ClearIntro clears the value of the "intro" field.
  23898. func (m *WxCardMutation) ClearIntro() {
  23899. m.intro = nil
  23900. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  23901. }
  23902. // IntroCleared returns if the "intro" field was cleared in this mutation.
  23903. func (m *WxCardMutation) IntroCleared() bool {
  23904. _, ok := m.clearedFields[wxcard.FieldIntro]
  23905. return ok
  23906. }
  23907. // ResetIntro resets all changes to the "intro" field.
  23908. func (m *WxCardMutation) ResetIntro() {
  23909. m.intro = nil
  23910. delete(m.clearedFields, wxcard.FieldIntro)
  23911. }
  23912. // Where appends a list predicates to the WxCardMutation builder.
  23913. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  23914. m.predicates = append(m.predicates, ps...)
  23915. }
  23916. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  23917. // users can use type-assertion to append predicates that do not depend on any generated package.
  23918. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  23919. p := make([]predicate.WxCard, len(ps))
  23920. for i := range ps {
  23921. p[i] = ps[i]
  23922. }
  23923. m.Where(p...)
  23924. }
  23925. // Op returns the operation name.
  23926. func (m *WxCardMutation) Op() Op {
  23927. return m.op
  23928. }
  23929. // SetOp allows setting the mutation operation.
  23930. func (m *WxCardMutation) SetOp(op Op) {
  23931. m.op = op
  23932. }
  23933. // Type returns the node type of this mutation (WxCard).
  23934. func (m *WxCardMutation) Type() string {
  23935. return m.typ
  23936. }
  23937. // Fields returns all fields that were changed during this mutation. Note that in
  23938. // order to get all numeric fields that were incremented/decremented, call
  23939. // AddedFields().
  23940. func (m *WxCardMutation) Fields() []string {
  23941. fields := make([]string, 0, 18)
  23942. if m.created_at != nil {
  23943. fields = append(fields, wxcard.FieldCreatedAt)
  23944. }
  23945. if m.updated_at != nil {
  23946. fields = append(fields, wxcard.FieldUpdatedAt)
  23947. }
  23948. if m.deleted_at != nil {
  23949. fields = append(fields, wxcard.FieldDeletedAt)
  23950. }
  23951. if m.user_id != nil {
  23952. fields = append(fields, wxcard.FieldUserID)
  23953. }
  23954. if m.wx_user_id != nil {
  23955. fields = append(fields, wxcard.FieldWxUserID)
  23956. }
  23957. if m.avatar != nil {
  23958. fields = append(fields, wxcard.FieldAvatar)
  23959. }
  23960. if m.logo != nil {
  23961. fields = append(fields, wxcard.FieldLogo)
  23962. }
  23963. if m.name != nil {
  23964. fields = append(fields, wxcard.FieldName)
  23965. }
  23966. if m.company != nil {
  23967. fields = append(fields, wxcard.FieldCompany)
  23968. }
  23969. if m.address != nil {
  23970. fields = append(fields, wxcard.FieldAddress)
  23971. }
  23972. if m.phone != nil {
  23973. fields = append(fields, wxcard.FieldPhone)
  23974. }
  23975. if m.official_account != nil {
  23976. fields = append(fields, wxcard.FieldOfficialAccount)
  23977. }
  23978. if m.wechat_account != nil {
  23979. fields = append(fields, wxcard.FieldWechatAccount)
  23980. }
  23981. if m.email != nil {
  23982. fields = append(fields, wxcard.FieldEmail)
  23983. }
  23984. if m.api_base != nil {
  23985. fields = append(fields, wxcard.FieldAPIBase)
  23986. }
  23987. if m.api_key != nil {
  23988. fields = append(fields, wxcard.FieldAPIKey)
  23989. }
  23990. if m.ai_info != nil {
  23991. fields = append(fields, wxcard.FieldAiInfo)
  23992. }
  23993. if m.intro != nil {
  23994. fields = append(fields, wxcard.FieldIntro)
  23995. }
  23996. return fields
  23997. }
  23998. // Field returns the value of a field with the given name. The second boolean
  23999. // return value indicates that this field was not set, or was not defined in the
  24000. // schema.
  24001. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  24002. switch name {
  24003. case wxcard.FieldCreatedAt:
  24004. return m.CreatedAt()
  24005. case wxcard.FieldUpdatedAt:
  24006. return m.UpdatedAt()
  24007. case wxcard.FieldDeletedAt:
  24008. return m.DeletedAt()
  24009. case wxcard.FieldUserID:
  24010. return m.UserID()
  24011. case wxcard.FieldWxUserID:
  24012. return m.WxUserID()
  24013. case wxcard.FieldAvatar:
  24014. return m.Avatar()
  24015. case wxcard.FieldLogo:
  24016. return m.Logo()
  24017. case wxcard.FieldName:
  24018. return m.Name()
  24019. case wxcard.FieldCompany:
  24020. return m.Company()
  24021. case wxcard.FieldAddress:
  24022. return m.Address()
  24023. case wxcard.FieldPhone:
  24024. return m.Phone()
  24025. case wxcard.FieldOfficialAccount:
  24026. return m.OfficialAccount()
  24027. case wxcard.FieldWechatAccount:
  24028. return m.WechatAccount()
  24029. case wxcard.FieldEmail:
  24030. return m.Email()
  24031. case wxcard.FieldAPIBase:
  24032. return m.APIBase()
  24033. case wxcard.FieldAPIKey:
  24034. return m.APIKey()
  24035. case wxcard.FieldAiInfo:
  24036. return m.AiInfo()
  24037. case wxcard.FieldIntro:
  24038. return m.Intro()
  24039. }
  24040. return nil, false
  24041. }
  24042. // OldField returns the old value of the field from the database. An error is
  24043. // returned if the mutation operation is not UpdateOne, or the query to the
  24044. // database failed.
  24045. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24046. switch name {
  24047. case wxcard.FieldCreatedAt:
  24048. return m.OldCreatedAt(ctx)
  24049. case wxcard.FieldUpdatedAt:
  24050. return m.OldUpdatedAt(ctx)
  24051. case wxcard.FieldDeletedAt:
  24052. return m.OldDeletedAt(ctx)
  24053. case wxcard.FieldUserID:
  24054. return m.OldUserID(ctx)
  24055. case wxcard.FieldWxUserID:
  24056. return m.OldWxUserID(ctx)
  24057. case wxcard.FieldAvatar:
  24058. return m.OldAvatar(ctx)
  24059. case wxcard.FieldLogo:
  24060. return m.OldLogo(ctx)
  24061. case wxcard.FieldName:
  24062. return m.OldName(ctx)
  24063. case wxcard.FieldCompany:
  24064. return m.OldCompany(ctx)
  24065. case wxcard.FieldAddress:
  24066. return m.OldAddress(ctx)
  24067. case wxcard.FieldPhone:
  24068. return m.OldPhone(ctx)
  24069. case wxcard.FieldOfficialAccount:
  24070. return m.OldOfficialAccount(ctx)
  24071. case wxcard.FieldWechatAccount:
  24072. return m.OldWechatAccount(ctx)
  24073. case wxcard.FieldEmail:
  24074. return m.OldEmail(ctx)
  24075. case wxcard.FieldAPIBase:
  24076. return m.OldAPIBase(ctx)
  24077. case wxcard.FieldAPIKey:
  24078. return m.OldAPIKey(ctx)
  24079. case wxcard.FieldAiInfo:
  24080. return m.OldAiInfo(ctx)
  24081. case wxcard.FieldIntro:
  24082. return m.OldIntro(ctx)
  24083. }
  24084. return nil, fmt.Errorf("unknown WxCard field %s", name)
  24085. }
  24086. // SetField sets the value of a field with the given name. It returns an error if
  24087. // the field is not defined in the schema, or if the type mismatched the field
  24088. // type.
  24089. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  24090. switch name {
  24091. case wxcard.FieldCreatedAt:
  24092. v, ok := value.(time.Time)
  24093. if !ok {
  24094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24095. }
  24096. m.SetCreatedAt(v)
  24097. return nil
  24098. case wxcard.FieldUpdatedAt:
  24099. v, ok := value.(time.Time)
  24100. if !ok {
  24101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24102. }
  24103. m.SetUpdatedAt(v)
  24104. return nil
  24105. case wxcard.FieldDeletedAt:
  24106. v, ok := value.(time.Time)
  24107. if !ok {
  24108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24109. }
  24110. m.SetDeletedAt(v)
  24111. return nil
  24112. case wxcard.FieldUserID:
  24113. v, ok := value.(uint64)
  24114. if !ok {
  24115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24116. }
  24117. m.SetUserID(v)
  24118. return nil
  24119. case wxcard.FieldWxUserID:
  24120. v, ok := value.(uint64)
  24121. if !ok {
  24122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24123. }
  24124. m.SetWxUserID(v)
  24125. return nil
  24126. case wxcard.FieldAvatar:
  24127. v, ok := value.(string)
  24128. if !ok {
  24129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24130. }
  24131. m.SetAvatar(v)
  24132. return nil
  24133. case wxcard.FieldLogo:
  24134. v, ok := value.(string)
  24135. if !ok {
  24136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24137. }
  24138. m.SetLogo(v)
  24139. return nil
  24140. case wxcard.FieldName:
  24141. v, ok := value.(string)
  24142. if !ok {
  24143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24144. }
  24145. m.SetName(v)
  24146. return nil
  24147. case wxcard.FieldCompany:
  24148. v, ok := value.(string)
  24149. if !ok {
  24150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24151. }
  24152. m.SetCompany(v)
  24153. return nil
  24154. case wxcard.FieldAddress:
  24155. v, ok := value.(string)
  24156. if !ok {
  24157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24158. }
  24159. m.SetAddress(v)
  24160. return nil
  24161. case wxcard.FieldPhone:
  24162. v, ok := value.(string)
  24163. if !ok {
  24164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24165. }
  24166. m.SetPhone(v)
  24167. return nil
  24168. case wxcard.FieldOfficialAccount:
  24169. v, ok := value.(string)
  24170. if !ok {
  24171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24172. }
  24173. m.SetOfficialAccount(v)
  24174. return nil
  24175. case wxcard.FieldWechatAccount:
  24176. v, ok := value.(string)
  24177. if !ok {
  24178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24179. }
  24180. m.SetWechatAccount(v)
  24181. return nil
  24182. case wxcard.FieldEmail:
  24183. v, ok := value.(string)
  24184. if !ok {
  24185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24186. }
  24187. m.SetEmail(v)
  24188. return nil
  24189. case wxcard.FieldAPIBase:
  24190. v, ok := value.(string)
  24191. if !ok {
  24192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24193. }
  24194. m.SetAPIBase(v)
  24195. return nil
  24196. case wxcard.FieldAPIKey:
  24197. v, ok := value.(string)
  24198. if !ok {
  24199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24200. }
  24201. m.SetAPIKey(v)
  24202. return nil
  24203. case wxcard.FieldAiInfo:
  24204. v, ok := value.(string)
  24205. if !ok {
  24206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24207. }
  24208. m.SetAiInfo(v)
  24209. return nil
  24210. case wxcard.FieldIntro:
  24211. v, ok := value.(string)
  24212. if !ok {
  24213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24214. }
  24215. m.SetIntro(v)
  24216. return nil
  24217. }
  24218. return fmt.Errorf("unknown WxCard field %s", name)
  24219. }
  24220. // AddedFields returns all numeric fields that were incremented/decremented during
  24221. // this mutation.
  24222. func (m *WxCardMutation) AddedFields() []string {
  24223. var fields []string
  24224. if m.adduser_id != nil {
  24225. fields = append(fields, wxcard.FieldUserID)
  24226. }
  24227. if m.addwx_user_id != nil {
  24228. fields = append(fields, wxcard.FieldWxUserID)
  24229. }
  24230. return fields
  24231. }
  24232. // AddedField returns the numeric value that was incremented/decremented on a field
  24233. // with the given name. The second boolean return value indicates that this field
  24234. // was not set, or was not defined in the schema.
  24235. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  24236. switch name {
  24237. case wxcard.FieldUserID:
  24238. return m.AddedUserID()
  24239. case wxcard.FieldWxUserID:
  24240. return m.AddedWxUserID()
  24241. }
  24242. return nil, false
  24243. }
  24244. // AddField adds the value to the field with the given name. It returns an error if
  24245. // the field is not defined in the schema, or if the type mismatched the field
  24246. // type.
  24247. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  24248. switch name {
  24249. case wxcard.FieldUserID:
  24250. v, ok := value.(int64)
  24251. if !ok {
  24252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24253. }
  24254. m.AddUserID(v)
  24255. return nil
  24256. case wxcard.FieldWxUserID:
  24257. v, ok := value.(int64)
  24258. if !ok {
  24259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24260. }
  24261. m.AddWxUserID(v)
  24262. return nil
  24263. }
  24264. return fmt.Errorf("unknown WxCard numeric field %s", name)
  24265. }
  24266. // ClearedFields returns all nullable fields that were cleared during this
  24267. // mutation.
  24268. func (m *WxCardMutation) ClearedFields() []string {
  24269. var fields []string
  24270. if m.FieldCleared(wxcard.FieldDeletedAt) {
  24271. fields = append(fields, wxcard.FieldDeletedAt)
  24272. }
  24273. if m.FieldCleared(wxcard.FieldUserID) {
  24274. fields = append(fields, wxcard.FieldUserID)
  24275. }
  24276. if m.FieldCleared(wxcard.FieldWxUserID) {
  24277. fields = append(fields, wxcard.FieldWxUserID)
  24278. }
  24279. if m.FieldCleared(wxcard.FieldEmail) {
  24280. fields = append(fields, wxcard.FieldEmail)
  24281. }
  24282. if m.FieldCleared(wxcard.FieldAPIBase) {
  24283. fields = append(fields, wxcard.FieldAPIBase)
  24284. }
  24285. if m.FieldCleared(wxcard.FieldAPIKey) {
  24286. fields = append(fields, wxcard.FieldAPIKey)
  24287. }
  24288. if m.FieldCleared(wxcard.FieldAiInfo) {
  24289. fields = append(fields, wxcard.FieldAiInfo)
  24290. }
  24291. if m.FieldCleared(wxcard.FieldIntro) {
  24292. fields = append(fields, wxcard.FieldIntro)
  24293. }
  24294. return fields
  24295. }
  24296. // FieldCleared returns a boolean indicating if a field with the given name was
  24297. // cleared in this mutation.
  24298. func (m *WxCardMutation) FieldCleared(name string) bool {
  24299. _, ok := m.clearedFields[name]
  24300. return ok
  24301. }
  24302. // ClearField clears the value of the field with the given name. It returns an
  24303. // error if the field is not defined in the schema.
  24304. func (m *WxCardMutation) ClearField(name string) error {
  24305. switch name {
  24306. case wxcard.FieldDeletedAt:
  24307. m.ClearDeletedAt()
  24308. return nil
  24309. case wxcard.FieldUserID:
  24310. m.ClearUserID()
  24311. return nil
  24312. case wxcard.FieldWxUserID:
  24313. m.ClearWxUserID()
  24314. return nil
  24315. case wxcard.FieldEmail:
  24316. m.ClearEmail()
  24317. return nil
  24318. case wxcard.FieldAPIBase:
  24319. m.ClearAPIBase()
  24320. return nil
  24321. case wxcard.FieldAPIKey:
  24322. m.ClearAPIKey()
  24323. return nil
  24324. case wxcard.FieldAiInfo:
  24325. m.ClearAiInfo()
  24326. return nil
  24327. case wxcard.FieldIntro:
  24328. m.ClearIntro()
  24329. return nil
  24330. }
  24331. return fmt.Errorf("unknown WxCard nullable field %s", name)
  24332. }
  24333. // ResetField resets all changes in the mutation for the field with the given name.
  24334. // It returns an error if the field is not defined in the schema.
  24335. func (m *WxCardMutation) ResetField(name string) error {
  24336. switch name {
  24337. case wxcard.FieldCreatedAt:
  24338. m.ResetCreatedAt()
  24339. return nil
  24340. case wxcard.FieldUpdatedAt:
  24341. m.ResetUpdatedAt()
  24342. return nil
  24343. case wxcard.FieldDeletedAt:
  24344. m.ResetDeletedAt()
  24345. return nil
  24346. case wxcard.FieldUserID:
  24347. m.ResetUserID()
  24348. return nil
  24349. case wxcard.FieldWxUserID:
  24350. m.ResetWxUserID()
  24351. return nil
  24352. case wxcard.FieldAvatar:
  24353. m.ResetAvatar()
  24354. return nil
  24355. case wxcard.FieldLogo:
  24356. m.ResetLogo()
  24357. return nil
  24358. case wxcard.FieldName:
  24359. m.ResetName()
  24360. return nil
  24361. case wxcard.FieldCompany:
  24362. m.ResetCompany()
  24363. return nil
  24364. case wxcard.FieldAddress:
  24365. m.ResetAddress()
  24366. return nil
  24367. case wxcard.FieldPhone:
  24368. m.ResetPhone()
  24369. return nil
  24370. case wxcard.FieldOfficialAccount:
  24371. m.ResetOfficialAccount()
  24372. return nil
  24373. case wxcard.FieldWechatAccount:
  24374. m.ResetWechatAccount()
  24375. return nil
  24376. case wxcard.FieldEmail:
  24377. m.ResetEmail()
  24378. return nil
  24379. case wxcard.FieldAPIBase:
  24380. m.ResetAPIBase()
  24381. return nil
  24382. case wxcard.FieldAPIKey:
  24383. m.ResetAPIKey()
  24384. return nil
  24385. case wxcard.FieldAiInfo:
  24386. m.ResetAiInfo()
  24387. return nil
  24388. case wxcard.FieldIntro:
  24389. m.ResetIntro()
  24390. return nil
  24391. }
  24392. return fmt.Errorf("unknown WxCard field %s", name)
  24393. }
  24394. // AddedEdges returns all edge names that were set/added in this mutation.
  24395. func (m *WxCardMutation) AddedEdges() []string {
  24396. edges := make([]string, 0, 0)
  24397. return edges
  24398. }
  24399. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24400. // name in this mutation.
  24401. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  24402. return nil
  24403. }
  24404. // RemovedEdges returns all edge names that were removed in this mutation.
  24405. func (m *WxCardMutation) RemovedEdges() []string {
  24406. edges := make([]string, 0, 0)
  24407. return edges
  24408. }
  24409. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24410. // the given name in this mutation.
  24411. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  24412. return nil
  24413. }
  24414. // ClearedEdges returns all edge names that were cleared in this mutation.
  24415. func (m *WxCardMutation) ClearedEdges() []string {
  24416. edges := make([]string, 0, 0)
  24417. return edges
  24418. }
  24419. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24420. // was cleared in this mutation.
  24421. func (m *WxCardMutation) EdgeCleared(name string) bool {
  24422. return false
  24423. }
  24424. // ClearEdge clears the value of the edge with the given name. It returns an error
  24425. // if that edge is not defined in the schema.
  24426. func (m *WxCardMutation) ClearEdge(name string) error {
  24427. return fmt.Errorf("unknown WxCard unique edge %s", name)
  24428. }
  24429. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24430. // It returns an error if the edge is not defined in the schema.
  24431. func (m *WxCardMutation) ResetEdge(name string) error {
  24432. return fmt.Errorf("unknown WxCard edge %s", name)
  24433. }
  24434. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  24435. type WxCardUserMutation struct {
  24436. config
  24437. op Op
  24438. typ string
  24439. id *uint64
  24440. created_at *time.Time
  24441. updated_at *time.Time
  24442. deleted_at *time.Time
  24443. wxid *string
  24444. account *string
  24445. avatar *string
  24446. nickname *string
  24447. remark *string
  24448. phone *string
  24449. open_id *string
  24450. union_id *string
  24451. session_key *string
  24452. is_vip *int
  24453. addis_vip *int
  24454. clearedFields map[string]struct{}
  24455. done bool
  24456. oldValue func(context.Context) (*WxCardUser, error)
  24457. predicates []predicate.WxCardUser
  24458. }
  24459. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  24460. // wxcarduserOption allows management of the mutation configuration using functional options.
  24461. type wxcarduserOption func(*WxCardUserMutation)
  24462. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  24463. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  24464. m := &WxCardUserMutation{
  24465. config: c,
  24466. op: op,
  24467. typ: TypeWxCardUser,
  24468. clearedFields: make(map[string]struct{}),
  24469. }
  24470. for _, opt := range opts {
  24471. opt(m)
  24472. }
  24473. return m
  24474. }
  24475. // withWxCardUserID sets the ID field of the mutation.
  24476. func withWxCardUserID(id uint64) wxcarduserOption {
  24477. return func(m *WxCardUserMutation) {
  24478. var (
  24479. err error
  24480. once sync.Once
  24481. value *WxCardUser
  24482. )
  24483. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  24484. once.Do(func() {
  24485. if m.done {
  24486. err = errors.New("querying old values post mutation is not allowed")
  24487. } else {
  24488. value, err = m.Client().WxCardUser.Get(ctx, id)
  24489. }
  24490. })
  24491. return value, err
  24492. }
  24493. m.id = &id
  24494. }
  24495. }
  24496. // withWxCardUser sets the old WxCardUser of the mutation.
  24497. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  24498. return func(m *WxCardUserMutation) {
  24499. m.oldValue = func(context.Context) (*WxCardUser, error) {
  24500. return node, nil
  24501. }
  24502. m.id = &node.ID
  24503. }
  24504. }
  24505. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24506. // executed in a transaction (ent.Tx), a transactional client is returned.
  24507. func (m WxCardUserMutation) Client() *Client {
  24508. client := &Client{config: m.config}
  24509. client.init()
  24510. return client
  24511. }
  24512. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24513. // it returns an error otherwise.
  24514. func (m WxCardUserMutation) Tx() (*Tx, error) {
  24515. if _, ok := m.driver.(*txDriver); !ok {
  24516. return nil, errors.New("ent: mutation is not running in a transaction")
  24517. }
  24518. tx := &Tx{config: m.config}
  24519. tx.init()
  24520. return tx, nil
  24521. }
  24522. // SetID sets the value of the id field. Note that this
  24523. // operation is only accepted on creation of WxCardUser entities.
  24524. func (m *WxCardUserMutation) SetID(id uint64) {
  24525. m.id = &id
  24526. }
  24527. // ID returns the ID value in the mutation. Note that the ID is only available
  24528. // if it was provided to the builder or after it was returned from the database.
  24529. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  24530. if m.id == nil {
  24531. return
  24532. }
  24533. return *m.id, true
  24534. }
  24535. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24536. // That means, if the mutation is applied within a transaction with an isolation level such
  24537. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24538. // or updated by the mutation.
  24539. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  24540. switch {
  24541. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24542. id, exists := m.ID()
  24543. if exists {
  24544. return []uint64{id}, nil
  24545. }
  24546. fallthrough
  24547. case m.op.Is(OpUpdate | OpDelete):
  24548. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  24549. default:
  24550. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24551. }
  24552. }
  24553. // SetCreatedAt sets the "created_at" field.
  24554. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  24555. m.created_at = &t
  24556. }
  24557. // CreatedAt returns the value of the "created_at" field in the mutation.
  24558. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  24559. v := m.created_at
  24560. if v == nil {
  24561. return
  24562. }
  24563. return *v, true
  24564. }
  24565. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  24566. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24568. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24569. if !m.op.Is(OpUpdateOne) {
  24570. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24571. }
  24572. if m.id == nil || m.oldValue == nil {
  24573. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24574. }
  24575. oldValue, err := m.oldValue(ctx)
  24576. if err != nil {
  24577. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24578. }
  24579. return oldValue.CreatedAt, nil
  24580. }
  24581. // ResetCreatedAt resets all changes to the "created_at" field.
  24582. func (m *WxCardUserMutation) ResetCreatedAt() {
  24583. m.created_at = nil
  24584. }
  24585. // SetUpdatedAt sets the "updated_at" field.
  24586. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  24587. m.updated_at = &t
  24588. }
  24589. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24590. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  24591. v := m.updated_at
  24592. if v == nil {
  24593. return
  24594. }
  24595. return *v, true
  24596. }
  24597. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  24598. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24600. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24601. if !m.op.Is(OpUpdateOne) {
  24602. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24603. }
  24604. if m.id == nil || m.oldValue == nil {
  24605. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24606. }
  24607. oldValue, err := m.oldValue(ctx)
  24608. if err != nil {
  24609. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24610. }
  24611. return oldValue.UpdatedAt, nil
  24612. }
  24613. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24614. func (m *WxCardUserMutation) ResetUpdatedAt() {
  24615. m.updated_at = nil
  24616. }
  24617. // SetDeletedAt sets the "deleted_at" field.
  24618. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  24619. m.deleted_at = &t
  24620. }
  24621. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24622. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  24623. v := m.deleted_at
  24624. if v == nil {
  24625. return
  24626. }
  24627. return *v, true
  24628. }
  24629. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  24630. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24632. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24633. if !m.op.Is(OpUpdateOne) {
  24634. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24635. }
  24636. if m.id == nil || m.oldValue == nil {
  24637. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24638. }
  24639. oldValue, err := m.oldValue(ctx)
  24640. if err != nil {
  24641. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24642. }
  24643. return oldValue.DeletedAt, nil
  24644. }
  24645. // ClearDeletedAt clears the value of the "deleted_at" field.
  24646. func (m *WxCardUserMutation) ClearDeletedAt() {
  24647. m.deleted_at = nil
  24648. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  24649. }
  24650. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24651. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  24652. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  24653. return ok
  24654. }
  24655. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24656. func (m *WxCardUserMutation) ResetDeletedAt() {
  24657. m.deleted_at = nil
  24658. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  24659. }
  24660. // SetWxid sets the "wxid" field.
  24661. func (m *WxCardUserMutation) SetWxid(s string) {
  24662. m.wxid = &s
  24663. }
  24664. // Wxid returns the value of the "wxid" field in the mutation.
  24665. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  24666. v := m.wxid
  24667. if v == nil {
  24668. return
  24669. }
  24670. return *v, true
  24671. }
  24672. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  24673. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24675. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  24676. if !m.op.Is(OpUpdateOne) {
  24677. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  24678. }
  24679. if m.id == nil || m.oldValue == nil {
  24680. return v, errors.New("OldWxid requires an ID field in the mutation")
  24681. }
  24682. oldValue, err := m.oldValue(ctx)
  24683. if err != nil {
  24684. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  24685. }
  24686. return oldValue.Wxid, nil
  24687. }
  24688. // ResetWxid resets all changes to the "wxid" field.
  24689. func (m *WxCardUserMutation) ResetWxid() {
  24690. m.wxid = nil
  24691. }
  24692. // SetAccount sets the "account" field.
  24693. func (m *WxCardUserMutation) SetAccount(s string) {
  24694. m.account = &s
  24695. }
  24696. // Account returns the value of the "account" field in the mutation.
  24697. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  24698. v := m.account
  24699. if v == nil {
  24700. return
  24701. }
  24702. return *v, true
  24703. }
  24704. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  24705. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24707. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  24708. if !m.op.Is(OpUpdateOne) {
  24709. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  24710. }
  24711. if m.id == nil || m.oldValue == nil {
  24712. return v, errors.New("OldAccount requires an ID field in the mutation")
  24713. }
  24714. oldValue, err := m.oldValue(ctx)
  24715. if err != nil {
  24716. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  24717. }
  24718. return oldValue.Account, nil
  24719. }
  24720. // ResetAccount resets all changes to the "account" field.
  24721. func (m *WxCardUserMutation) ResetAccount() {
  24722. m.account = nil
  24723. }
  24724. // SetAvatar sets the "avatar" field.
  24725. func (m *WxCardUserMutation) SetAvatar(s string) {
  24726. m.avatar = &s
  24727. }
  24728. // Avatar returns the value of the "avatar" field in the mutation.
  24729. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  24730. v := m.avatar
  24731. if v == nil {
  24732. return
  24733. }
  24734. return *v, true
  24735. }
  24736. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  24737. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24739. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  24740. if !m.op.Is(OpUpdateOne) {
  24741. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  24742. }
  24743. if m.id == nil || m.oldValue == nil {
  24744. return v, errors.New("OldAvatar requires an ID field in the mutation")
  24745. }
  24746. oldValue, err := m.oldValue(ctx)
  24747. if err != nil {
  24748. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  24749. }
  24750. return oldValue.Avatar, nil
  24751. }
  24752. // ResetAvatar resets all changes to the "avatar" field.
  24753. func (m *WxCardUserMutation) ResetAvatar() {
  24754. m.avatar = nil
  24755. }
  24756. // SetNickname sets the "nickname" field.
  24757. func (m *WxCardUserMutation) SetNickname(s string) {
  24758. m.nickname = &s
  24759. }
  24760. // Nickname returns the value of the "nickname" field in the mutation.
  24761. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  24762. v := m.nickname
  24763. if v == nil {
  24764. return
  24765. }
  24766. return *v, true
  24767. }
  24768. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  24769. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24771. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  24772. if !m.op.Is(OpUpdateOne) {
  24773. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  24774. }
  24775. if m.id == nil || m.oldValue == nil {
  24776. return v, errors.New("OldNickname requires an ID field in the mutation")
  24777. }
  24778. oldValue, err := m.oldValue(ctx)
  24779. if err != nil {
  24780. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  24781. }
  24782. return oldValue.Nickname, nil
  24783. }
  24784. // ResetNickname resets all changes to the "nickname" field.
  24785. func (m *WxCardUserMutation) ResetNickname() {
  24786. m.nickname = nil
  24787. }
  24788. // SetRemark sets the "remark" field.
  24789. func (m *WxCardUserMutation) SetRemark(s string) {
  24790. m.remark = &s
  24791. }
  24792. // Remark returns the value of the "remark" field in the mutation.
  24793. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  24794. v := m.remark
  24795. if v == nil {
  24796. return
  24797. }
  24798. return *v, true
  24799. }
  24800. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  24801. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24803. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  24804. if !m.op.Is(OpUpdateOne) {
  24805. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  24806. }
  24807. if m.id == nil || m.oldValue == nil {
  24808. return v, errors.New("OldRemark requires an ID field in the mutation")
  24809. }
  24810. oldValue, err := m.oldValue(ctx)
  24811. if err != nil {
  24812. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  24813. }
  24814. return oldValue.Remark, nil
  24815. }
  24816. // ResetRemark resets all changes to the "remark" field.
  24817. func (m *WxCardUserMutation) ResetRemark() {
  24818. m.remark = nil
  24819. }
  24820. // SetPhone sets the "phone" field.
  24821. func (m *WxCardUserMutation) SetPhone(s string) {
  24822. m.phone = &s
  24823. }
  24824. // Phone returns the value of the "phone" field in the mutation.
  24825. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  24826. v := m.phone
  24827. if v == nil {
  24828. return
  24829. }
  24830. return *v, true
  24831. }
  24832. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  24833. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24835. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  24836. if !m.op.Is(OpUpdateOne) {
  24837. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  24838. }
  24839. if m.id == nil || m.oldValue == nil {
  24840. return v, errors.New("OldPhone requires an ID field in the mutation")
  24841. }
  24842. oldValue, err := m.oldValue(ctx)
  24843. if err != nil {
  24844. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  24845. }
  24846. return oldValue.Phone, nil
  24847. }
  24848. // ResetPhone resets all changes to the "phone" field.
  24849. func (m *WxCardUserMutation) ResetPhone() {
  24850. m.phone = nil
  24851. }
  24852. // SetOpenID sets the "open_id" field.
  24853. func (m *WxCardUserMutation) SetOpenID(s string) {
  24854. m.open_id = &s
  24855. }
  24856. // OpenID returns the value of the "open_id" field in the mutation.
  24857. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  24858. v := m.open_id
  24859. if v == nil {
  24860. return
  24861. }
  24862. return *v, true
  24863. }
  24864. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  24865. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24867. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  24868. if !m.op.Is(OpUpdateOne) {
  24869. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  24870. }
  24871. if m.id == nil || m.oldValue == nil {
  24872. return v, errors.New("OldOpenID requires an ID field in the mutation")
  24873. }
  24874. oldValue, err := m.oldValue(ctx)
  24875. if err != nil {
  24876. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  24877. }
  24878. return oldValue.OpenID, nil
  24879. }
  24880. // ResetOpenID resets all changes to the "open_id" field.
  24881. func (m *WxCardUserMutation) ResetOpenID() {
  24882. m.open_id = nil
  24883. }
  24884. // SetUnionID sets the "union_id" field.
  24885. func (m *WxCardUserMutation) SetUnionID(s string) {
  24886. m.union_id = &s
  24887. }
  24888. // UnionID returns the value of the "union_id" field in the mutation.
  24889. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  24890. v := m.union_id
  24891. if v == nil {
  24892. return
  24893. }
  24894. return *v, true
  24895. }
  24896. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  24897. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24899. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  24900. if !m.op.Is(OpUpdateOne) {
  24901. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  24902. }
  24903. if m.id == nil || m.oldValue == nil {
  24904. return v, errors.New("OldUnionID requires an ID field in the mutation")
  24905. }
  24906. oldValue, err := m.oldValue(ctx)
  24907. if err != nil {
  24908. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  24909. }
  24910. return oldValue.UnionID, nil
  24911. }
  24912. // ResetUnionID resets all changes to the "union_id" field.
  24913. func (m *WxCardUserMutation) ResetUnionID() {
  24914. m.union_id = nil
  24915. }
  24916. // SetSessionKey sets the "session_key" field.
  24917. func (m *WxCardUserMutation) SetSessionKey(s string) {
  24918. m.session_key = &s
  24919. }
  24920. // SessionKey returns the value of the "session_key" field in the mutation.
  24921. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  24922. v := m.session_key
  24923. if v == nil {
  24924. return
  24925. }
  24926. return *v, true
  24927. }
  24928. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  24929. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24931. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  24932. if !m.op.Is(OpUpdateOne) {
  24933. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  24934. }
  24935. if m.id == nil || m.oldValue == nil {
  24936. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  24937. }
  24938. oldValue, err := m.oldValue(ctx)
  24939. if err != nil {
  24940. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  24941. }
  24942. return oldValue.SessionKey, nil
  24943. }
  24944. // ResetSessionKey resets all changes to the "session_key" field.
  24945. func (m *WxCardUserMutation) ResetSessionKey() {
  24946. m.session_key = nil
  24947. }
  24948. // SetIsVip sets the "is_vip" field.
  24949. func (m *WxCardUserMutation) SetIsVip(i int) {
  24950. m.is_vip = &i
  24951. m.addis_vip = nil
  24952. }
  24953. // IsVip returns the value of the "is_vip" field in the mutation.
  24954. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  24955. v := m.is_vip
  24956. if v == nil {
  24957. return
  24958. }
  24959. return *v, true
  24960. }
  24961. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  24962. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24964. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  24965. if !m.op.Is(OpUpdateOne) {
  24966. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  24967. }
  24968. if m.id == nil || m.oldValue == nil {
  24969. return v, errors.New("OldIsVip requires an ID field in the mutation")
  24970. }
  24971. oldValue, err := m.oldValue(ctx)
  24972. if err != nil {
  24973. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  24974. }
  24975. return oldValue.IsVip, nil
  24976. }
  24977. // AddIsVip adds i to the "is_vip" field.
  24978. func (m *WxCardUserMutation) AddIsVip(i int) {
  24979. if m.addis_vip != nil {
  24980. *m.addis_vip += i
  24981. } else {
  24982. m.addis_vip = &i
  24983. }
  24984. }
  24985. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  24986. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  24987. v := m.addis_vip
  24988. if v == nil {
  24989. return
  24990. }
  24991. return *v, true
  24992. }
  24993. // ResetIsVip resets all changes to the "is_vip" field.
  24994. func (m *WxCardUserMutation) ResetIsVip() {
  24995. m.is_vip = nil
  24996. m.addis_vip = nil
  24997. }
  24998. // Where appends a list predicates to the WxCardUserMutation builder.
  24999. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  25000. m.predicates = append(m.predicates, ps...)
  25001. }
  25002. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  25003. // users can use type-assertion to append predicates that do not depend on any generated package.
  25004. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  25005. p := make([]predicate.WxCardUser, len(ps))
  25006. for i := range ps {
  25007. p[i] = ps[i]
  25008. }
  25009. m.Where(p...)
  25010. }
  25011. // Op returns the operation name.
  25012. func (m *WxCardUserMutation) Op() Op {
  25013. return m.op
  25014. }
  25015. // SetOp allows setting the mutation operation.
  25016. func (m *WxCardUserMutation) SetOp(op Op) {
  25017. m.op = op
  25018. }
  25019. // Type returns the node type of this mutation (WxCardUser).
  25020. func (m *WxCardUserMutation) Type() string {
  25021. return m.typ
  25022. }
  25023. // Fields returns all fields that were changed during this mutation. Note that in
  25024. // order to get all numeric fields that were incremented/decremented, call
  25025. // AddedFields().
  25026. func (m *WxCardUserMutation) Fields() []string {
  25027. fields := make([]string, 0, 13)
  25028. if m.created_at != nil {
  25029. fields = append(fields, wxcarduser.FieldCreatedAt)
  25030. }
  25031. if m.updated_at != nil {
  25032. fields = append(fields, wxcarduser.FieldUpdatedAt)
  25033. }
  25034. if m.deleted_at != nil {
  25035. fields = append(fields, wxcarduser.FieldDeletedAt)
  25036. }
  25037. if m.wxid != nil {
  25038. fields = append(fields, wxcarduser.FieldWxid)
  25039. }
  25040. if m.account != nil {
  25041. fields = append(fields, wxcarduser.FieldAccount)
  25042. }
  25043. if m.avatar != nil {
  25044. fields = append(fields, wxcarduser.FieldAvatar)
  25045. }
  25046. if m.nickname != nil {
  25047. fields = append(fields, wxcarduser.FieldNickname)
  25048. }
  25049. if m.remark != nil {
  25050. fields = append(fields, wxcarduser.FieldRemark)
  25051. }
  25052. if m.phone != nil {
  25053. fields = append(fields, wxcarduser.FieldPhone)
  25054. }
  25055. if m.open_id != nil {
  25056. fields = append(fields, wxcarduser.FieldOpenID)
  25057. }
  25058. if m.union_id != nil {
  25059. fields = append(fields, wxcarduser.FieldUnionID)
  25060. }
  25061. if m.session_key != nil {
  25062. fields = append(fields, wxcarduser.FieldSessionKey)
  25063. }
  25064. if m.is_vip != nil {
  25065. fields = append(fields, wxcarduser.FieldIsVip)
  25066. }
  25067. return fields
  25068. }
  25069. // Field returns the value of a field with the given name. The second boolean
  25070. // return value indicates that this field was not set, or was not defined in the
  25071. // schema.
  25072. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  25073. switch name {
  25074. case wxcarduser.FieldCreatedAt:
  25075. return m.CreatedAt()
  25076. case wxcarduser.FieldUpdatedAt:
  25077. return m.UpdatedAt()
  25078. case wxcarduser.FieldDeletedAt:
  25079. return m.DeletedAt()
  25080. case wxcarduser.FieldWxid:
  25081. return m.Wxid()
  25082. case wxcarduser.FieldAccount:
  25083. return m.Account()
  25084. case wxcarduser.FieldAvatar:
  25085. return m.Avatar()
  25086. case wxcarduser.FieldNickname:
  25087. return m.Nickname()
  25088. case wxcarduser.FieldRemark:
  25089. return m.Remark()
  25090. case wxcarduser.FieldPhone:
  25091. return m.Phone()
  25092. case wxcarduser.FieldOpenID:
  25093. return m.OpenID()
  25094. case wxcarduser.FieldUnionID:
  25095. return m.UnionID()
  25096. case wxcarduser.FieldSessionKey:
  25097. return m.SessionKey()
  25098. case wxcarduser.FieldIsVip:
  25099. return m.IsVip()
  25100. }
  25101. return nil, false
  25102. }
  25103. // OldField returns the old value of the field from the database. An error is
  25104. // returned if the mutation operation is not UpdateOne, or the query to the
  25105. // database failed.
  25106. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25107. switch name {
  25108. case wxcarduser.FieldCreatedAt:
  25109. return m.OldCreatedAt(ctx)
  25110. case wxcarduser.FieldUpdatedAt:
  25111. return m.OldUpdatedAt(ctx)
  25112. case wxcarduser.FieldDeletedAt:
  25113. return m.OldDeletedAt(ctx)
  25114. case wxcarduser.FieldWxid:
  25115. return m.OldWxid(ctx)
  25116. case wxcarduser.FieldAccount:
  25117. return m.OldAccount(ctx)
  25118. case wxcarduser.FieldAvatar:
  25119. return m.OldAvatar(ctx)
  25120. case wxcarduser.FieldNickname:
  25121. return m.OldNickname(ctx)
  25122. case wxcarduser.FieldRemark:
  25123. return m.OldRemark(ctx)
  25124. case wxcarduser.FieldPhone:
  25125. return m.OldPhone(ctx)
  25126. case wxcarduser.FieldOpenID:
  25127. return m.OldOpenID(ctx)
  25128. case wxcarduser.FieldUnionID:
  25129. return m.OldUnionID(ctx)
  25130. case wxcarduser.FieldSessionKey:
  25131. return m.OldSessionKey(ctx)
  25132. case wxcarduser.FieldIsVip:
  25133. return m.OldIsVip(ctx)
  25134. }
  25135. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  25136. }
  25137. // SetField sets the value of a field with the given name. It returns an error if
  25138. // the field is not defined in the schema, or if the type mismatched the field
  25139. // type.
  25140. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  25141. switch name {
  25142. case wxcarduser.FieldCreatedAt:
  25143. v, ok := value.(time.Time)
  25144. if !ok {
  25145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25146. }
  25147. m.SetCreatedAt(v)
  25148. return nil
  25149. case wxcarduser.FieldUpdatedAt:
  25150. v, ok := value.(time.Time)
  25151. if !ok {
  25152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25153. }
  25154. m.SetUpdatedAt(v)
  25155. return nil
  25156. case wxcarduser.FieldDeletedAt:
  25157. v, ok := value.(time.Time)
  25158. if !ok {
  25159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25160. }
  25161. m.SetDeletedAt(v)
  25162. return nil
  25163. case wxcarduser.FieldWxid:
  25164. v, ok := value.(string)
  25165. if !ok {
  25166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25167. }
  25168. m.SetWxid(v)
  25169. return nil
  25170. case wxcarduser.FieldAccount:
  25171. v, ok := value.(string)
  25172. if !ok {
  25173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25174. }
  25175. m.SetAccount(v)
  25176. return nil
  25177. case wxcarduser.FieldAvatar:
  25178. v, ok := value.(string)
  25179. if !ok {
  25180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25181. }
  25182. m.SetAvatar(v)
  25183. return nil
  25184. case wxcarduser.FieldNickname:
  25185. v, ok := value.(string)
  25186. if !ok {
  25187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25188. }
  25189. m.SetNickname(v)
  25190. return nil
  25191. case wxcarduser.FieldRemark:
  25192. v, ok := value.(string)
  25193. if !ok {
  25194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25195. }
  25196. m.SetRemark(v)
  25197. return nil
  25198. case wxcarduser.FieldPhone:
  25199. v, ok := value.(string)
  25200. if !ok {
  25201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25202. }
  25203. m.SetPhone(v)
  25204. return nil
  25205. case wxcarduser.FieldOpenID:
  25206. v, ok := value.(string)
  25207. if !ok {
  25208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25209. }
  25210. m.SetOpenID(v)
  25211. return nil
  25212. case wxcarduser.FieldUnionID:
  25213. v, ok := value.(string)
  25214. if !ok {
  25215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25216. }
  25217. m.SetUnionID(v)
  25218. return nil
  25219. case wxcarduser.FieldSessionKey:
  25220. v, ok := value.(string)
  25221. if !ok {
  25222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25223. }
  25224. m.SetSessionKey(v)
  25225. return nil
  25226. case wxcarduser.FieldIsVip:
  25227. v, ok := value.(int)
  25228. if !ok {
  25229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25230. }
  25231. m.SetIsVip(v)
  25232. return nil
  25233. }
  25234. return fmt.Errorf("unknown WxCardUser field %s", name)
  25235. }
  25236. // AddedFields returns all numeric fields that were incremented/decremented during
  25237. // this mutation.
  25238. func (m *WxCardUserMutation) AddedFields() []string {
  25239. var fields []string
  25240. if m.addis_vip != nil {
  25241. fields = append(fields, wxcarduser.FieldIsVip)
  25242. }
  25243. return fields
  25244. }
  25245. // AddedField returns the numeric value that was incremented/decremented on a field
  25246. // with the given name. The second boolean return value indicates that this field
  25247. // was not set, or was not defined in the schema.
  25248. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  25249. switch name {
  25250. case wxcarduser.FieldIsVip:
  25251. return m.AddedIsVip()
  25252. }
  25253. return nil, false
  25254. }
  25255. // AddField adds the value to the field with the given name. It returns an error if
  25256. // the field is not defined in the schema, or if the type mismatched the field
  25257. // type.
  25258. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  25259. switch name {
  25260. case wxcarduser.FieldIsVip:
  25261. v, ok := value.(int)
  25262. if !ok {
  25263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25264. }
  25265. m.AddIsVip(v)
  25266. return nil
  25267. }
  25268. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  25269. }
  25270. // ClearedFields returns all nullable fields that were cleared during this
  25271. // mutation.
  25272. func (m *WxCardUserMutation) ClearedFields() []string {
  25273. var fields []string
  25274. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  25275. fields = append(fields, wxcarduser.FieldDeletedAt)
  25276. }
  25277. return fields
  25278. }
  25279. // FieldCleared returns a boolean indicating if a field with the given name was
  25280. // cleared in this mutation.
  25281. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  25282. _, ok := m.clearedFields[name]
  25283. return ok
  25284. }
  25285. // ClearField clears the value of the field with the given name. It returns an
  25286. // error if the field is not defined in the schema.
  25287. func (m *WxCardUserMutation) ClearField(name string) error {
  25288. switch name {
  25289. case wxcarduser.FieldDeletedAt:
  25290. m.ClearDeletedAt()
  25291. return nil
  25292. }
  25293. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  25294. }
  25295. // ResetField resets all changes in the mutation for the field with the given name.
  25296. // It returns an error if the field is not defined in the schema.
  25297. func (m *WxCardUserMutation) ResetField(name string) error {
  25298. switch name {
  25299. case wxcarduser.FieldCreatedAt:
  25300. m.ResetCreatedAt()
  25301. return nil
  25302. case wxcarduser.FieldUpdatedAt:
  25303. m.ResetUpdatedAt()
  25304. return nil
  25305. case wxcarduser.FieldDeletedAt:
  25306. m.ResetDeletedAt()
  25307. return nil
  25308. case wxcarduser.FieldWxid:
  25309. m.ResetWxid()
  25310. return nil
  25311. case wxcarduser.FieldAccount:
  25312. m.ResetAccount()
  25313. return nil
  25314. case wxcarduser.FieldAvatar:
  25315. m.ResetAvatar()
  25316. return nil
  25317. case wxcarduser.FieldNickname:
  25318. m.ResetNickname()
  25319. return nil
  25320. case wxcarduser.FieldRemark:
  25321. m.ResetRemark()
  25322. return nil
  25323. case wxcarduser.FieldPhone:
  25324. m.ResetPhone()
  25325. return nil
  25326. case wxcarduser.FieldOpenID:
  25327. m.ResetOpenID()
  25328. return nil
  25329. case wxcarduser.FieldUnionID:
  25330. m.ResetUnionID()
  25331. return nil
  25332. case wxcarduser.FieldSessionKey:
  25333. m.ResetSessionKey()
  25334. return nil
  25335. case wxcarduser.FieldIsVip:
  25336. m.ResetIsVip()
  25337. return nil
  25338. }
  25339. return fmt.Errorf("unknown WxCardUser field %s", name)
  25340. }
  25341. // AddedEdges returns all edge names that were set/added in this mutation.
  25342. func (m *WxCardUserMutation) AddedEdges() []string {
  25343. edges := make([]string, 0, 0)
  25344. return edges
  25345. }
  25346. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25347. // name in this mutation.
  25348. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  25349. return nil
  25350. }
  25351. // RemovedEdges returns all edge names that were removed in this mutation.
  25352. func (m *WxCardUserMutation) RemovedEdges() []string {
  25353. edges := make([]string, 0, 0)
  25354. return edges
  25355. }
  25356. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25357. // the given name in this mutation.
  25358. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  25359. return nil
  25360. }
  25361. // ClearedEdges returns all edge names that were cleared in this mutation.
  25362. func (m *WxCardUserMutation) ClearedEdges() []string {
  25363. edges := make([]string, 0, 0)
  25364. return edges
  25365. }
  25366. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25367. // was cleared in this mutation.
  25368. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  25369. return false
  25370. }
  25371. // ClearEdge clears the value of the edge with the given name. It returns an error
  25372. // if that edge is not defined in the schema.
  25373. func (m *WxCardUserMutation) ClearEdge(name string) error {
  25374. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  25375. }
  25376. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25377. // It returns an error if the edge is not defined in the schema.
  25378. func (m *WxCardUserMutation) ResetEdge(name string) error {
  25379. return fmt.Errorf("unknown WxCardUser edge %s", name)
  25380. }
  25381. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  25382. type WxCardVisitMutation struct {
  25383. config
  25384. op Op
  25385. typ string
  25386. id *uint64
  25387. created_at *time.Time
  25388. updated_at *time.Time
  25389. deleted_at *time.Time
  25390. user_id *uint64
  25391. adduser_id *int64
  25392. bot_id *uint64
  25393. addbot_id *int64
  25394. bot_type *uint8
  25395. addbot_type *int8
  25396. clearedFields map[string]struct{}
  25397. done bool
  25398. oldValue func(context.Context) (*WxCardVisit, error)
  25399. predicates []predicate.WxCardVisit
  25400. }
  25401. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  25402. // wxcardvisitOption allows management of the mutation configuration using functional options.
  25403. type wxcardvisitOption func(*WxCardVisitMutation)
  25404. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  25405. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  25406. m := &WxCardVisitMutation{
  25407. config: c,
  25408. op: op,
  25409. typ: TypeWxCardVisit,
  25410. clearedFields: make(map[string]struct{}),
  25411. }
  25412. for _, opt := range opts {
  25413. opt(m)
  25414. }
  25415. return m
  25416. }
  25417. // withWxCardVisitID sets the ID field of the mutation.
  25418. func withWxCardVisitID(id uint64) wxcardvisitOption {
  25419. return func(m *WxCardVisitMutation) {
  25420. var (
  25421. err error
  25422. once sync.Once
  25423. value *WxCardVisit
  25424. )
  25425. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  25426. once.Do(func() {
  25427. if m.done {
  25428. err = errors.New("querying old values post mutation is not allowed")
  25429. } else {
  25430. value, err = m.Client().WxCardVisit.Get(ctx, id)
  25431. }
  25432. })
  25433. return value, err
  25434. }
  25435. m.id = &id
  25436. }
  25437. }
  25438. // withWxCardVisit sets the old WxCardVisit of the mutation.
  25439. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  25440. return func(m *WxCardVisitMutation) {
  25441. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  25442. return node, nil
  25443. }
  25444. m.id = &node.ID
  25445. }
  25446. }
  25447. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25448. // executed in a transaction (ent.Tx), a transactional client is returned.
  25449. func (m WxCardVisitMutation) Client() *Client {
  25450. client := &Client{config: m.config}
  25451. client.init()
  25452. return client
  25453. }
  25454. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25455. // it returns an error otherwise.
  25456. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  25457. if _, ok := m.driver.(*txDriver); !ok {
  25458. return nil, errors.New("ent: mutation is not running in a transaction")
  25459. }
  25460. tx := &Tx{config: m.config}
  25461. tx.init()
  25462. return tx, nil
  25463. }
  25464. // SetID sets the value of the id field. Note that this
  25465. // operation is only accepted on creation of WxCardVisit entities.
  25466. func (m *WxCardVisitMutation) SetID(id uint64) {
  25467. m.id = &id
  25468. }
  25469. // ID returns the ID value in the mutation. Note that the ID is only available
  25470. // if it was provided to the builder or after it was returned from the database.
  25471. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  25472. if m.id == nil {
  25473. return
  25474. }
  25475. return *m.id, true
  25476. }
  25477. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25478. // That means, if the mutation is applied within a transaction with an isolation level such
  25479. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25480. // or updated by the mutation.
  25481. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  25482. switch {
  25483. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25484. id, exists := m.ID()
  25485. if exists {
  25486. return []uint64{id}, nil
  25487. }
  25488. fallthrough
  25489. case m.op.Is(OpUpdate | OpDelete):
  25490. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  25491. default:
  25492. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25493. }
  25494. }
  25495. // SetCreatedAt sets the "created_at" field.
  25496. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  25497. m.created_at = &t
  25498. }
  25499. // CreatedAt returns the value of the "created_at" field in the mutation.
  25500. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  25501. v := m.created_at
  25502. if v == nil {
  25503. return
  25504. }
  25505. return *v, true
  25506. }
  25507. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  25508. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25510. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25511. if !m.op.Is(OpUpdateOne) {
  25512. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25513. }
  25514. if m.id == nil || m.oldValue == nil {
  25515. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25516. }
  25517. oldValue, err := m.oldValue(ctx)
  25518. if err != nil {
  25519. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25520. }
  25521. return oldValue.CreatedAt, nil
  25522. }
  25523. // ResetCreatedAt resets all changes to the "created_at" field.
  25524. func (m *WxCardVisitMutation) ResetCreatedAt() {
  25525. m.created_at = nil
  25526. }
  25527. // SetUpdatedAt sets the "updated_at" field.
  25528. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  25529. m.updated_at = &t
  25530. }
  25531. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25532. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  25533. v := m.updated_at
  25534. if v == nil {
  25535. return
  25536. }
  25537. return *v, true
  25538. }
  25539. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  25540. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25542. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25543. if !m.op.Is(OpUpdateOne) {
  25544. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25545. }
  25546. if m.id == nil || m.oldValue == nil {
  25547. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25548. }
  25549. oldValue, err := m.oldValue(ctx)
  25550. if err != nil {
  25551. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25552. }
  25553. return oldValue.UpdatedAt, nil
  25554. }
  25555. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25556. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  25557. m.updated_at = nil
  25558. }
  25559. // SetDeletedAt sets the "deleted_at" field.
  25560. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  25561. m.deleted_at = &t
  25562. }
  25563. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25564. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  25565. v := m.deleted_at
  25566. if v == nil {
  25567. return
  25568. }
  25569. return *v, true
  25570. }
  25571. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  25572. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25574. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25575. if !m.op.Is(OpUpdateOne) {
  25576. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25577. }
  25578. if m.id == nil || m.oldValue == nil {
  25579. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25580. }
  25581. oldValue, err := m.oldValue(ctx)
  25582. if err != nil {
  25583. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25584. }
  25585. return oldValue.DeletedAt, nil
  25586. }
  25587. // ClearDeletedAt clears the value of the "deleted_at" field.
  25588. func (m *WxCardVisitMutation) ClearDeletedAt() {
  25589. m.deleted_at = nil
  25590. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  25591. }
  25592. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25593. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  25594. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  25595. return ok
  25596. }
  25597. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25598. func (m *WxCardVisitMutation) ResetDeletedAt() {
  25599. m.deleted_at = nil
  25600. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  25601. }
  25602. // SetUserID sets the "user_id" field.
  25603. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  25604. m.user_id = &u
  25605. m.adduser_id = nil
  25606. }
  25607. // UserID returns the value of the "user_id" field in the mutation.
  25608. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  25609. v := m.user_id
  25610. if v == nil {
  25611. return
  25612. }
  25613. return *v, true
  25614. }
  25615. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  25616. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25618. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  25619. if !m.op.Is(OpUpdateOne) {
  25620. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  25621. }
  25622. if m.id == nil || m.oldValue == nil {
  25623. return v, errors.New("OldUserID requires an ID field in the mutation")
  25624. }
  25625. oldValue, err := m.oldValue(ctx)
  25626. if err != nil {
  25627. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  25628. }
  25629. return oldValue.UserID, nil
  25630. }
  25631. // AddUserID adds u to the "user_id" field.
  25632. func (m *WxCardVisitMutation) AddUserID(u int64) {
  25633. if m.adduser_id != nil {
  25634. *m.adduser_id += u
  25635. } else {
  25636. m.adduser_id = &u
  25637. }
  25638. }
  25639. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  25640. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  25641. v := m.adduser_id
  25642. if v == nil {
  25643. return
  25644. }
  25645. return *v, true
  25646. }
  25647. // ClearUserID clears the value of the "user_id" field.
  25648. func (m *WxCardVisitMutation) ClearUserID() {
  25649. m.user_id = nil
  25650. m.adduser_id = nil
  25651. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  25652. }
  25653. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  25654. func (m *WxCardVisitMutation) UserIDCleared() bool {
  25655. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  25656. return ok
  25657. }
  25658. // ResetUserID resets all changes to the "user_id" field.
  25659. func (m *WxCardVisitMutation) ResetUserID() {
  25660. m.user_id = nil
  25661. m.adduser_id = nil
  25662. delete(m.clearedFields, wxcardvisit.FieldUserID)
  25663. }
  25664. // SetBotID sets the "bot_id" field.
  25665. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  25666. m.bot_id = &u
  25667. m.addbot_id = nil
  25668. }
  25669. // BotID returns the value of the "bot_id" field in the mutation.
  25670. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  25671. v := m.bot_id
  25672. if v == nil {
  25673. return
  25674. }
  25675. return *v, true
  25676. }
  25677. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  25678. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25680. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  25681. if !m.op.Is(OpUpdateOne) {
  25682. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  25683. }
  25684. if m.id == nil || m.oldValue == nil {
  25685. return v, errors.New("OldBotID requires an ID field in the mutation")
  25686. }
  25687. oldValue, err := m.oldValue(ctx)
  25688. if err != nil {
  25689. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  25690. }
  25691. return oldValue.BotID, nil
  25692. }
  25693. // AddBotID adds u to the "bot_id" field.
  25694. func (m *WxCardVisitMutation) AddBotID(u int64) {
  25695. if m.addbot_id != nil {
  25696. *m.addbot_id += u
  25697. } else {
  25698. m.addbot_id = &u
  25699. }
  25700. }
  25701. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  25702. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  25703. v := m.addbot_id
  25704. if v == nil {
  25705. return
  25706. }
  25707. return *v, true
  25708. }
  25709. // ResetBotID resets all changes to the "bot_id" field.
  25710. func (m *WxCardVisitMutation) ResetBotID() {
  25711. m.bot_id = nil
  25712. m.addbot_id = nil
  25713. }
  25714. // SetBotType sets the "bot_type" field.
  25715. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  25716. m.bot_type = &u
  25717. m.addbot_type = nil
  25718. }
  25719. // BotType returns the value of the "bot_type" field in the mutation.
  25720. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  25721. v := m.bot_type
  25722. if v == nil {
  25723. return
  25724. }
  25725. return *v, true
  25726. }
  25727. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  25728. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25730. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  25731. if !m.op.Is(OpUpdateOne) {
  25732. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  25733. }
  25734. if m.id == nil || m.oldValue == nil {
  25735. return v, errors.New("OldBotType requires an ID field in the mutation")
  25736. }
  25737. oldValue, err := m.oldValue(ctx)
  25738. if err != nil {
  25739. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  25740. }
  25741. return oldValue.BotType, nil
  25742. }
  25743. // AddBotType adds u to the "bot_type" field.
  25744. func (m *WxCardVisitMutation) AddBotType(u int8) {
  25745. if m.addbot_type != nil {
  25746. *m.addbot_type += u
  25747. } else {
  25748. m.addbot_type = &u
  25749. }
  25750. }
  25751. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  25752. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  25753. v := m.addbot_type
  25754. if v == nil {
  25755. return
  25756. }
  25757. return *v, true
  25758. }
  25759. // ResetBotType resets all changes to the "bot_type" field.
  25760. func (m *WxCardVisitMutation) ResetBotType() {
  25761. m.bot_type = nil
  25762. m.addbot_type = nil
  25763. }
  25764. // Where appends a list predicates to the WxCardVisitMutation builder.
  25765. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  25766. m.predicates = append(m.predicates, ps...)
  25767. }
  25768. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  25769. // users can use type-assertion to append predicates that do not depend on any generated package.
  25770. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  25771. p := make([]predicate.WxCardVisit, len(ps))
  25772. for i := range ps {
  25773. p[i] = ps[i]
  25774. }
  25775. m.Where(p...)
  25776. }
  25777. // Op returns the operation name.
  25778. func (m *WxCardVisitMutation) Op() Op {
  25779. return m.op
  25780. }
  25781. // SetOp allows setting the mutation operation.
  25782. func (m *WxCardVisitMutation) SetOp(op Op) {
  25783. m.op = op
  25784. }
  25785. // Type returns the node type of this mutation (WxCardVisit).
  25786. func (m *WxCardVisitMutation) Type() string {
  25787. return m.typ
  25788. }
  25789. // Fields returns all fields that were changed during this mutation. Note that in
  25790. // order to get all numeric fields that were incremented/decremented, call
  25791. // AddedFields().
  25792. func (m *WxCardVisitMutation) Fields() []string {
  25793. fields := make([]string, 0, 6)
  25794. if m.created_at != nil {
  25795. fields = append(fields, wxcardvisit.FieldCreatedAt)
  25796. }
  25797. if m.updated_at != nil {
  25798. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  25799. }
  25800. if m.deleted_at != nil {
  25801. fields = append(fields, wxcardvisit.FieldDeletedAt)
  25802. }
  25803. if m.user_id != nil {
  25804. fields = append(fields, wxcardvisit.FieldUserID)
  25805. }
  25806. if m.bot_id != nil {
  25807. fields = append(fields, wxcardvisit.FieldBotID)
  25808. }
  25809. if m.bot_type != nil {
  25810. fields = append(fields, wxcardvisit.FieldBotType)
  25811. }
  25812. return fields
  25813. }
  25814. // Field returns the value of a field with the given name. The second boolean
  25815. // return value indicates that this field was not set, or was not defined in the
  25816. // schema.
  25817. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  25818. switch name {
  25819. case wxcardvisit.FieldCreatedAt:
  25820. return m.CreatedAt()
  25821. case wxcardvisit.FieldUpdatedAt:
  25822. return m.UpdatedAt()
  25823. case wxcardvisit.FieldDeletedAt:
  25824. return m.DeletedAt()
  25825. case wxcardvisit.FieldUserID:
  25826. return m.UserID()
  25827. case wxcardvisit.FieldBotID:
  25828. return m.BotID()
  25829. case wxcardvisit.FieldBotType:
  25830. return m.BotType()
  25831. }
  25832. return nil, false
  25833. }
  25834. // OldField returns the old value of the field from the database. An error is
  25835. // returned if the mutation operation is not UpdateOne, or the query to the
  25836. // database failed.
  25837. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25838. switch name {
  25839. case wxcardvisit.FieldCreatedAt:
  25840. return m.OldCreatedAt(ctx)
  25841. case wxcardvisit.FieldUpdatedAt:
  25842. return m.OldUpdatedAt(ctx)
  25843. case wxcardvisit.FieldDeletedAt:
  25844. return m.OldDeletedAt(ctx)
  25845. case wxcardvisit.FieldUserID:
  25846. return m.OldUserID(ctx)
  25847. case wxcardvisit.FieldBotID:
  25848. return m.OldBotID(ctx)
  25849. case wxcardvisit.FieldBotType:
  25850. return m.OldBotType(ctx)
  25851. }
  25852. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  25853. }
  25854. // SetField sets the value of a field with the given name. It returns an error if
  25855. // the field is not defined in the schema, or if the type mismatched the field
  25856. // type.
  25857. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  25858. switch name {
  25859. case wxcardvisit.FieldCreatedAt:
  25860. v, ok := value.(time.Time)
  25861. if !ok {
  25862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25863. }
  25864. m.SetCreatedAt(v)
  25865. return nil
  25866. case wxcardvisit.FieldUpdatedAt:
  25867. v, ok := value.(time.Time)
  25868. if !ok {
  25869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25870. }
  25871. m.SetUpdatedAt(v)
  25872. return nil
  25873. case wxcardvisit.FieldDeletedAt:
  25874. v, ok := value.(time.Time)
  25875. if !ok {
  25876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25877. }
  25878. m.SetDeletedAt(v)
  25879. return nil
  25880. case wxcardvisit.FieldUserID:
  25881. v, ok := value.(uint64)
  25882. if !ok {
  25883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25884. }
  25885. m.SetUserID(v)
  25886. return nil
  25887. case wxcardvisit.FieldBotID:
  25888. v, ok := value.(uint64)
  25889. if !ok {
  25890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25891. }
  25892. m.SetBotID(v)
  25893. return nil
  25894. case wxcardvisit.FieldBotType:
  25895. v, ok := value.(uint8)
  25896. if !ok {
  25897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25898. }
  25899. m.SetBotType(v)
  25900. return nil
  25901. }
  25902. return fmt.Errorf("unknown WxCardVisit field %s", name)
  25903. }
  25904. // AddedFields returns all numeric fields that were incremented/decremented during
  25905. // this mutation.
  25906. func (m *WxCardVisitMutation) AddedFields() []string {
  25907. var fields []string
  25908. if m.adduser_id != nil {
  25909. fields = append(fields, wxcardvisit.FieldUserID)
  25910. }
  25911. if m.addbot_id != nil {
  25912. fields = append(fields, wxcardvisit.FieldBotID)
  25913. }
  25914. if m.addbot_type != nil {
  25915. fields = append(fields, wxcardvisit.FieldBotType)
  25916. }
  25917. return fields
  25918. }
  25919. // AddedField returns the numeric value that was incremented/decremented on a field
  25920. // with the given name. The second boolean return value indicates that this field
  25921. // was not set, or was not defined in the schema.
  25922. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  25923. switch name {
  25924. case wxcardvisit.FieldUserID:
  25925. return m.AddedUserID()
  25926. case wxcardvisit.FieldBotID:
  25927. return m.AddedBotID()
  25928. case wxcardvisit.FieldBotType:
  25929. return m.AddedBotType()
  25930. }
  25931. return nil, false
  25932. }
  25933. // AddField adds the value to the field with the given name. It returns an error if
  25934. // the field is not defined in the schema, or if the type mismatched the field
  25935. // type.
  25936. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  25937. switch name {
  25938. case wxcardvisit.FieldUserID:
  25939. v, ok := value.(int64)
  25940. if !ok {
  25941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25942. }
  25943. m.AddUserID(v)
  25944. return nil
  25945. case wxcardvisit.FieldBotID:
  25946. v, ok := value.(int64)
  25947. if !ok {
  25948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25949. }
  25950. m.AddBotID(v)
  25951. return nil
  25952. case wxcardvisit.FieldBotType:
  25953. v, ok := value.(int8)
  25954. if !ok {
  25955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25956. }
  25957. m.AddBotType(v)
  25958. return nil
  25959. }
  25960. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  25961. }
  25962. // ClearedFields returns all nullable fields that were cleared during this
  25963. // mutation.
  25964. func (m *WxCardVisitMutation) ClearedFields() []string {
  25965. var fields []string
  25966. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  25967. fields = append(fields, wxcardvisit.FieldDeletedAt)
  25968. }
  25969. if m.FieldCleared(wxcardvisit.FieldUserID) {
  25970. fields = append(fields, wxcardvisit.FieldUserID)
  25971. }
  25972. return fields
  25973. }
  25974. // FieldCleared returns a boolean indicating if a field with the given name was
  25975. // cleared in this mutation.
  25976. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  25977. _, ok := m.clearedFields[name]
  25978. return ok
  25979. }
  25980. // ClearField clears the value of the field with the given name. It returns an
  25981. // error if the field is not defined in the schema.
  25982. func (m *WxCardVisitMutation) ClearField(name string) error {
  25983. switch name {
  25984. case wxcardvisit.FieldDeletedAt:
  25985. m.ClearDeletedAt()
  25986. return nil
  25987. case wxcardvisit.FieldUserID:
  25988. m.ClearUserID()
  25989. return nil
  25990. }
  25991. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  25992. }
  25993. // ResetField resets all changes in the mutation for the field with the given name.
  25994. // It returns an error if the field is not defined in the schema.
  25995. func (m *WxCardVisitMutation) ResetField(name string) error {
  25996. switch name {
  25997. case wxcardvisit.FieldCreatedAt:
  25998. m.ResetCreatedAt()
  25999. return nil
  26000. case wxcardvisit.FieldUpdatedAt:
  26001. m.ResetUpdatedAt()
  26002. return nil
  26003. case wxcardvisit.FieldDeletedAt:
  26004. m.ResetDeletedAt()
  26005. return nil
  26006. case wxcardvisit.FieldUserID:
  26007. m.ResetUserID()
  26008. return nil
  26009. case wxcardvisit.FieldBotID:
  26010. m.ResetBotID()
  26011. return nil
  26012. case wxcardvisit.FieldBotType:
  26013. m.ResetBotType()
  26014. return nil
  26015. }
  26016. return fmt.Errorf("unknown WxCardVisit field %s", name)
  26017. }
  26018. // AddedEdges returns all edge names that were set/added in this mutation.
  26019. func (m *WxCardVisitMutation) AddedEdges() []string {
  26020. edges := make([]string, 0, 0)
  26021. return edges
  26022. }
  26023. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26024. // name in this mutation.
  26025. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  26026. return nil
  26027. }
  26028. // RemovedEdges returns all edge names that were removed in this mutation.
  26029. func (m *WxCardVisitMutation) RemovedEdges() []string {
  26030. edges := make([]string, 0, 0)
  26031. return edges
  26032. }
  26033. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26034. // the given name in this mutation.
  26035. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  26036. return nil
  26037. }
  26038. // ClearedEdges returns all edge names that were cleared in this mutation.
  26039. func (m *WxCardVisitMutation) ClearedEdges() []string {
  26040. edges := make([]string, 0, 0)
  26041. return edges
  26042. }
  26043. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26044. // was cleared in this mutation.
  26045. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  26046. return false
  26047. }
  26048. // ClearEdge clears the value of the edge with the given name. It returns an error
  26049. // if that edge is not defined in the schema.
  26050. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  26051. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  26052. }
  26053. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26054. // It returns an error if the edge is not defined in the schema.
  26055. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  26056. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  26057. }