From 63f16091faa259da3f67c356620ee44af82610a9 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Tue, 27 Oct 2026 21:16:56 +0900 Subject: [PATCH] =?UTF-8?q?feat(content-banner):=20=EC=BD=98=ED=85=90?= =?UTF-8?q?=EC=B8=A0=20=EB=B0=B0=EB=84=88=20=EC=98=88=EC=95=BD=20=EA=B8=B0?= =?UTF-8?q?=EA=B0=84=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 등록/수정 폼에 선택적 시작·종료 일시(datetime-local, KST) 추가 - 관리자 목록 카드에 저장된 예약 기간 표기 - 수정 시 미변경 필드 생략, 값 삭제 시 명시적 null 전송 - 역전 범위 저장 차단(같은 분 허용) 및 검증 유틸·테스트 추가 --- package.json | 1 + src/utils/audio_content_banner.js | 71 ++++++ src/views/Content/ContentMainTopBanner.vue | 79 ++++++- tests/audio_content_banner.test.js | 251 +++++++++++++++++++++ 4 files changed, 400 insertions(+), 2 deletions(-) create mode 100644 src/utils/audio_content_banner.js create mode 100644 tests/audio_content_banner.test.js diff --git a/package.json b/package.json index ecfe8be..8c1e8fb 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "build": "vue-cli-service build", "build_development": "vue-cli-service build --mode development", "test:gift": "node tests/gift.test.js && node tests/gift_category.test.js && node tests/gift_size.test.js && node tests/gift_mailbox.test.js", + "test:banner": "node tests/audio_content_banner.test.js", "lint": "vue-cli-service lint" }, "dependencies": { diff --git a/src/utils/audio_content_banner.js b/src/utils/audio_content_banner.js new file mode 100644 index 0000000..5ec2487 --- /dev/null +++ b/src/utils/audio_content_banner.js @@ -0,0 +1,71 @@ +const DATE_TIME_PATTERN = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/ + +export function toDateTimeLocalInput(value) { + if (value === null || value === undefined) return '' + const text = String(value).trim() + if (!text || text === 'null') return '' + return text.replace(' ', 'T').slice(0, 16) +} + +export function toServerDateTime(value) { + if (value === null || value === undefined) return null + const text = String(value).trim() + if (!text || text === 'null') return null + return text.replace('T', ' ').slice(0, 16) +} + +export function formatScheduleRange(startDate, endDate) { + const start = toServerDateTime(startDate) + const end = toServerDateTime(endDate) + if (!start && !end) return '상시 노출' + if (start && !end) return `${start} ~` + if (!start && end) return `~ ${end}` + return `${start} ~ ${end}` +} + +export function createBannerScheduleForm(banner = {}) { + return { + start_date: toDateTimeLocalInput(banner.startDate), + end_date: toDateTimeLocalInput(banner.endDate) + } +} + +export function validateBannerSchedule(form = {}) { + const errors = {} + const start = toServerDateTime(form.start_date) + const end = toServerDateTime(form.end_date) + + if (start !== null && !DATE_TIME_PATTERN.test(start)) { + errors.start_date = '시작 일시 형식이 올바르지 않습니다. (yyyy-MM-dd HH:mm)' + } + if (end !== null && !DATE_TIME_PATTERN.test(end)) { + errors.end_date = '종료 일시 형식이 올바르지 않습니다. (yyyy-MM-dd HH:mm)' + } + if (!errors.start_date && !errors.end_date && start !== null && end !== null && start > end) { + errors.end_date = '종료 일시는 시작 일시보다 빠를 수 없습니다.' + } + + return errors +} + +export function applyScheduleToSaveRequest(request, form = {}) { + const start = toServerDateTime(form.start_date) + const end = toServerDateTime(form.end_date) + + if (start !== null) request.startDate = start + if (end !== null) request.endDate = end + + return request +} + +export function applyScheduleToModifyRequest(request, form = {}, banner = {}) { + const start = toServerDateTime(form.start_date) + const end = toServerDateTime(form.end_date) + const originalStart = toServerDateTime(banner.startDate) + const originalEnd = toServerDateTime(banner.endDate) + + if (start !== originalStart) request.startDate = start + if (end !== originalEnd) request.endDate = end + + return request +} diff --git a/src/views/Content/ContentMainTopBanner.vue b/src/views/Content/ContentMainTopBanner.vue index e4596fc..129ac77 100644 --- a/src/views/Content/ContentMainTopBanner.vue +++ b/src/views/Content/ContentMainTopBanner.vue @@ -60,6 +60,9 @@ + + {{ scheduleRangeText(item) }} + + + + + 노출 기간 (한국 시간 기준) + + + + + + + + + + + 비워두면 해당 경계의 예약 제한이 없습니다. 입력한 시간은 한국 시간(KST)으로 저장됩니다. + + +