sequenceDiagram
autonumber
participant Client as 클라이언트(브라우저)
participant API as 백엔드 API 서버
participant DB as 데이터베이스
rect rgba(255, 255, 150, 0.1)
Note over Client, DB: 콘텐츠 찜하기/취소 프로세스
Client->>Client: 찜하기 버튼 클릭
alt 비로그인 상태
Client->>Client: 로그인 페이지로 리다이렉트
else 로그인 상태
Client->>API: 찜하기 토글 요청<br>(content_id, JWT 토큰)
API->>API: JWT 토큰 검증
alt 토큰 유효
API->>DB: 현재 찜 상태 확인<br>(Wishlists 테이블)
DB-->>API: 찜 상태 결과
alt 이미 찜한 경우 (찜 취소)
API->>DB: Wishlists 테이블에서 삭제<br>(user_id, content_id)
DB-->>API: 삭제 결과
API-->>Client: 200 OK<br>(찜 취소 성공, 새로운 상태: false)
else 찜하지 않은 경우 (찜하기)
API->>DB: Wishlists 테이블에 추가<br>(user_id, content_id, created_at)
DB-->>API: 추가 결과
API-->>Client: 201 Created<br>(찜하기 성공, 새로운 상태: true)
end
Client->>Client: UI 업데이트<br>(찜하기 버튼 상태 변경)
else 토큰 무효
API-->>Client: 401 Unauthorized
Client->>Client: 로그인 페이지로 리다이렉트
end
end
end
Created
April 18, 2025 15:41
-
-
Save Mineru98/05765b370f9f601fa020f69b6074c565 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment