2026-05-31 15:42:52 +09:00
|
|
|
import http from './http'
|
|
|
|
|
|
|
|
|
|
// 백엔드 /api/board 엔드포인트와 매핑
|
|
|
|
|
export const boardApi = {
|
2026-06-04 05:01:33 +09:00
|
|
|
list({ category = '', page = 1, size = 10, tag = '', keyword = '', searchType = '' } = {}) {
|
2026-05-31 15:42:52 +09:00
|
|
|
return http.get('/board/posts', {
|
|
|
|
|
params: {
|
2026-06-04 05:01:33 +09:00
|
|
|
category: category || undefined,
|
2026-05-31 15:42:52 +09:00
|
|
|
page,
|
|
|
|
|
size,
|
|
|
|
|
tag: tag || undefined,
|
|
|
|
|
keyword: keyword || undefined,
|
|
|
|
|
searchType: keyword ? searchType || 'title' : undefined,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
get(id) {
|
|
|
|
|
return http.get(`/board/posts/${id}`)
|
|
|
|
|
},
|
|
|
|
|
create(payload) {
|
|
|
|
|
return http.post('/board/posts', payload)
|
|
|
|
|
},
|
|
|
|
|
update(id, payload) {
|
|
|
|
|
return http.put(`/board/posts/${id}`, payload)
|
|
|
|
|
},
|
|
|
|
|
remove(id) {
|
|
|
|
|
return http.delete(`/board/posts/${id}`)
|
|
|
|
|
},
|
2026-06-07 19:17:44 +09:00
|
|
|
// 본문 인라인 이미지 업로드(서버 DB 저장) → { url } (예: /api/images/123)
|
|
|
|
|
uploadImage(blob) {
|
|
|
|
|
const fd = new FormData()
|
|
|
|
|
fd.append('image', blob, 'image.jpg')
|
|
|
|
|
return http.post('/board/images', fd, {
|
|
|
|
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
|
|
|
timeout: 30000,
|
|
|
|
|
})
|
|
|
|
|
},
|
2026-06-28 15:44:40 +09:00
|
|
|
tags(category) {
|
|
|
|
|
return http.get('/board/tags', { params: { category: category || undefined } })
|
2026-05-31 15:42:52 +09:00
|
|
|
},
|
2026-06-28 13:34:40 +09:00
|
|
|
tagGroups(category) {
|
|
|
|
|
return http.get('/board/tag-groups', { params: { category: category || undefined } })
|
2026-05-31 15:42:52 +09:00
|
|
|
},
|
|
|
|
|
addComment(id, content) {
|
|
|
|
|
return http.post(`/board/posts/${id}/comments`, { content })
|
|
|
|
|
},
|
|
|
|
|
removeComment(commentId) {
|
|
|
|
|
return http.delete(`/board/comments/${commentId}`)
|
|
|
|
|
},
|
2026-06-28 12:28:20 +09:00
|
|
|
// 추천/비추천 (토글) — type: 'UP' | 'DOWN'
|
|
|
|
|
votePost(id, type) {
|
|
|
|
|
return http.post(`/board/posts/${id}/vote`, { type })
|
|
|
|
|
},
|
|
|
|
|
voteComment(commentId, type) {
|
|
|
|
|
return http.post(`/board/comments/${commentId}/vote`, { type })
|
|
|
|
|
},
|
|
|
|
|
// 추천(👍)한 사람 목록
|
|
|
|
|
recommenders(id) {
|
|
|
|
|
return http.get(`/board/posts/${id}/recommenders`)
|
|
|
|
|
},
|
2026-06-28 18:05:43 +09:00
|
|
|
// 신고 (누적 5건 시 블라인드)
|
|
|
|
|
reportPost(id) {
|
|
|
|
|
return http.post(`/board/posts/${id}/report`)
|
|
|
|
|
},
|
|
|
|
|
reportComment(commentId) {
|
|
|
|
|
return http.post(`/board/comments/${commentId}/report`)
|
|
|
|
|
},
|
2026-05-31 15:42:52 +09:00
|
|
|
block(id, reason) {
|
|
|
|
|
return http.post(`/board/posts/${id}/block`, { reason })
|
|
|
|
|
},
|
|
|
|
|
unblock(id) {
|
|
|
|
|
return http.post(`/board/posts/${id}/unblock`)
|
|
|
|
|
},
|
2026-06-27 22:07:03 +09:00
|
|
|
// 공지 설정/해제 (관리자) — 목록 최상단 고정
|
|
|
|
|
setNotice(id) {
|
|
|
|
|
return http.post(`/board/posts/${id}/notice`)
|
|
|
|
|
},
|
|
|
|
|
unsetNotice(id) {
|
|
|
|
|
return http.post(`/board/posts/${id}/unnotice`)
|
|
|
|
|
},
|
2026-05-31 15:42:52 +09:00
|
|
|
}
|