ucap-doc/documents/업무/2월/3째주/file-viewer-prj/plan.event-json.ts

35 lines
880 B
TypeScript
Raw Normal View History

import { EventJsonDecoder } from './event-json';
import { JsonAnalization } from '@ucap-webmessenger/api';
export interface PlanEventJson {
planSeq?: number;
title?: string;
contents?: PlanContentType | string;
date?: string;
endDate?: string;
active?: boolean;
}
export enum PlanContentType {
New = 'PLAN_CONTENTS_NEW',
Update = 'PLAN_CONTENTS_UPDATE',
Delete = 'PLAN_CONTENTS_DELETE'
}
export const decodePlanEventJson: EventJsonDecoder<PlanEventJson> = (
message: string
) => {
try {
const json = JsonAnalization.receiveAnalization(message);
return {
planSeq: Number(json.planSeq),
title: json.title,
contents: json.contents,
date: json.date,
endDate: json.endDate,
active: !!json.activeYn && 'Y' === json.activeYn ? true : false
} as PlanEventJson;
} catch (e) {
return {} as PlanEventJson;
}
};