페이지 섹션·공개 목록 설정 누적 변경 일괄 반영

페이지 섹션 관리와 홈 Pages 진열장 연동, 공개 목록 표시개수 설정 관련 누적 로컬 변경을 기능 단위로 정리해 반영한다.
문서 이력과 패키지 버전을 v1.9.23으로 맞춰 코드와 문서 상태를 동기화한다.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-30 18:48:42 +09:00
parent 6a3cc5d7ec
commit 00999404a4
37 changed files with 2681 additions and 123 deletions

View File

@@ -0,0 +1,23 @@
import { createError } from 'h3'
import { requireAdminSession } from '../../../../utils/admin-auth'
import { deleteAdminPageSection } from '../../../../repositories/content-repository'
/**
* 관리자 페이지 섹션 삭제 API
* @param {import('h3').H3Event} event - 요청 이벤트
* @returns {{ ok: true }} 삭제 결과
*/
export default defineEventHandler(async (event) => {
requireAdminSession(event)
const id = String(event.context.params?.id || '')
const deleted = await deleteAdminPageSection(id)
if (!deleted) {
throw createError({
statusCode: 409,
message: '사용 중인 페이지 섹션은 삭제할 수 없습니다.'
})
}
return { ok: true }
})

View File

@@ -0,0 +1,48 @@
import { createError, readBody } from 'h3'
import { z } from 'zod'
import { requireAdminSession } from '../../../../utils/admin-auth'
import { updateAdminPageSection } from '../../../../repositories/content-repository'
const pageSectionInputSchema = z.object({
name: z.string().trim().min(1).max(80)
})
/**
* 관리자 페이지 섹션 수정 API
* @param {import('h3').H3Event} event - 요청 이벤트
* @returns {Promise<Object>} 수정된 페이지 섹션
*/
export default defineEventHandler(async (event) => {
requireAdminSession(event)
const id = String(event.context.params?.id || '')
const parsedBody = pageSectionInputSchema.safeParse(await readBody(event))
if (!parsedBody.success) {
throw createError({
statusCode: 400,
message: '페이지 섹션 입력 형식이 올바르지 않습니다.'
})
}
try {
const section = await updateAdminPageSection(id, parsedBody.data)
if (!section) {
throw createError({
statusCode: 404,
message: '페이지 섹션을 찾을 수 없습니다.'
})
}
return section
} catch (error) {
if (error?.code === '23505') {
throw createError({
statusCode: 409,
message: '이미 사용 중인 페이지 섹션입니다.'
})
}
throw error
}
})

View File

@@ -0,0 +1,55 @@
import { createError, readBody } from 'h3'
import { z } from 'zod'
import { reorderAdminPageSectionPages } from '../../../../../../repositories/content-repository'
import { requireAdminSession } from '../../../../../../utils/admin-auth'
const reorderPageSectionPagesSchema = z.object({
pageIds: z.array(z.string().uuid()),
removedPageIds: z.array(z.string().uuid()).default([])
})
/**
* 관리자 페이지 섹션 내부 페이지 정렬 저장 API
* @param {import('h3').H3Event} event - 요청 이벤트
* @returns {Promise<Array>} 정렬 저장 후 페이지 목록
*/
export default defineEventHandler(async (event) => {
requireAdminSession(event)
const sectionId = String(event.context.params?.id || '').trim()
const body = await readBody(event)
const parsed = reorderPageSectionPagesSchema.safeParse(body)
if (!parsed.success) {
throw createError({
statusCode: 400,
message: '페이지 순서 요청 형식이 올바르지 않습니다.'
})
}
try {
const pages = await reorderAdminPageSectionPages(sectionId, parsed.data.pageIds, parsed.data.removedPageIds)
if (!pages) {
throw createError({
statusCode: 404,
message: '페이지 섹션을 찾을 수 없습니다.'
})
}
return pages
} catch (error) {
if (error?.statusCode) {
throw error
}
if (error?.message === 'PAGE_SECTION_PAGE_MISMATCH') {
throw createError({
statusCode: 400,
message: '해당 섹션에 속한 페이지 목록만 정렬할 수 있습니다.'
})
}
throw error
}
})

View File

@@ -0,0 +1,27 @@
import { createError, readBody } from 'h3'
import { z } from 'zod'
import { requireAdminSession } from '../../../../utils/admin-auth'
import { reorderAdminPageSections } from '../../../../repositories/content-repository'
const reorderPageSectionsSchema = z.object({
sectionIds: z.array(z.string().uuid()).min(1)
})
/**
* 관리자 페이지 섹션 정렬 저장 API
* @param {import('h3').H3Event} event - 요청 이벤트
* @returns {Promise<Array>} 정렬 저장 후 페이지 섹션 목록
*/
export default defineEventHandler(async (event) => {
requireAdminSession(event)
const parsedBody = reorderPageSectionsSchema.safeParse(await readBody(event))
if (!parsedBody.success) {
throw createError({
statusCode: 400,
message: '페이지 섹션 정렬 요청 형식이 올바르지 않습니다.'
})
}
return reorderAdminPageSections(parsedBody.data.sectionIds)
})