- 체인 nonce 경쟁 조건 수정 (operatorMu + per-user mutex) - 등록/SSAFY 원자적 트랜잭션 (wallet+profile 롤백 보장) - IdempotencyRequired 미들웨어 (SETNX 원자적 클레임) - 런치 티켓 API (JWT URL 노출 방지) - HttpOnly 쿠키 refresh token - SSAFY OAuth state 파라미터 (CSRF 방지) - Refresh 시 DB 조회로 최신 role 사용 - 공지사항/유저목록 페이지네이션 - BodyLimit 미들웨어 (1MB, upload 제외) - 입력 검증 강화 (닉네임, 게임데이터, 공지 길이) - 에러 메시지 내부 정보 노출 방지 - io.LimitReader (RPC 10MB, SSAFY 1MB) - RequestID 비출력 문자 제거 - 단위 테스트 (auth 11, announcement 9, bossraid 16) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
42 lines
921 B
Go
42 lines
921 B
Go
package announcement
|
|
|
|
import "fmt"
|
|
|
|
type Service struct {
|
|
repo *Repository
|
|
}
|
|
|
|
func NewService(repo *Repository) *Service {
|
|
return &Service{repo: repo}
|
|
}
|
|
|
|
func (s *Service) GetAll(offset, limit int) ([]Announcement, error) {
|
|
return s.repo.FindAll(offset, limit)
|
|
}
|
|
|
|
func (s *Service) Create(title, content string) (*Announcement, error) {
|
|
a := &Announcement{Title: title, Content: content}
|
|
return a, s.repo.Create(a)
|
|
}
|
|
|
|
func (s *Service) Update(id uint, title, content string) (*Announcement, error) {
|
|
a, err := s.repo.FindByID(id)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("공지사항을 찾을 수 없습니다")
|
|
}
|
|
if title != "" {
|
|
a.Title = title
|
|
}
|
|
if content != "" {
|
|
a.Content = content
|
|
}
|
|
return a, s.repo.Save(a)
|
|
}
|
|
|
|
func (s *Service) Delete(id uint) error {
|
|
if _, err := s.repo.FindByID(id); err != nil {
|
|
return fmt.Errorf("공지사항을 찾을 수 없습니다")
|
|
}
|
|
return s.repo.Delete(id)
|
|
}
|