feat: 게시판 공지 기능 (관리자) — 목록 최상단 고정

- post.notice 컬럼 추가(멱등 ALTER)
- 목록 정렬 ORDER BY notice DESC, id DESC (공지 최상단)
- 작성 시 공지 설정(관리자만 반영) + /posts/{id}/notice·unnotice 토글
- Post/PostSummary/PostDetail/PostRequest 에 notice 반영

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ByungCheol
2026-06-27 22:06:48 +09:00
co-authored by Claude Opus 4.8
parent b48d8c667c
commit 8d8d26ec3a
9 changed files with 50 additions and 5 deletions
@@ -91,6 +91,14 @@ public class BoardService {
postMapper.updateBlocked(id, blocked, blocked ? reason : null);
}
/** 게시글 공지 설정/해제 (관리자 전용) — 목록 최상단 고정 */
@Transactional
public void setNotice(Long id, boolean notice, SessionUser user) {
assertAdmin(user);
mustFindPost(id);
postMapper.updateNotice(id, notice);
}
/** Redis 로 (사용자, 게시글) 단위 첫 열람 여부 판단 → 중복 클릭 시 조회수 증가 방지 */
private boolean shouldCountView(Long postId, SessionUser viewer) {
if (viewer == null) {
@@ -108,6 +116,8 @@ public class BoardService {
.content(req.getContent())
.authorId(author.getId())
.authorName(author.getName())
// 공지는 관리자만 설정 가능
.notice(isAdmin(author) && Boolean.TRUE.equals(req.getNotice()))
.category(toCategory(req.getCategory()))
.build();
postMapper.insert(post);