페이지 섹션·공개 목록 설정 누적 변경 일괄 반영
페이지 섹션 관리와 홈 Pages 진열장 연동, 공개 목록 표시개수 설정 관련 누적 로컬 변경을 기능 단위로 정리해 반영한다. 문서 이력과 패키지 버전을 v1.9.23으로 맞춰 코드와 문서 상태를 동기화한다. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
38
server/routes/admin/api/page-sections.post.js
Normal file
38
server/routes/admin/api/page-sections.post.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import { createError, readBody } from 'h3'
|
||||
import { z } from 'zod'
|
||||
import { requireAdminSession } from '../../../utils/admin-auth'
|
||||
import { createAdminPageSection } 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 parsedBody = pageSectionInputSchema.safeParse(await readBody(event))
|
||||
|
||||
if (!parsedBody.success) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
message: '페이지 섹션 입력 형식이 올바르지 않습니다.'
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
return await createAdminPageSection(parsedBody.data.name)
|
||||
} catch (error) {
|
||||
if (error?.code === '23505') {
|
||||
throw createError({
|
||||
statusCode: 409,
|
||||
message: '이미 사용 중인 페이지 섹션입니다.'
|
||||
})
|
||||
}
|
||||
|
||||
throw error
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user