Repository navigation
[Feat/#478] 알림함 화면과 학식 탭 알림 아이콘 추가 #481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c00f05d
[#478] 알림함 화면과 학식 탭 알림 아이콘을 추가하고, 알림·푸시를 누르면 읽음 처리 후 해당 학식 화면으로 이동
Hrepay a0786f5
[#478] 알림함 API 호출 모음을 Data/Notification 폴더로 이동
Hrepay 4ce7d93
[#478] 알림이 없으면 모두 읽음 버튼을 숨기고, 알림 아이콘에 접근성 라벨 추가
Hrepay a0bbdf2
[#478] 안 읽은 알림 조회는 마지막 요청만 반영하고, 모두 읽음 실패 시 서버 상태를 다시 받도록 수정
Hrepay f1197fa
Merge remote-tracking branch 'origin/develop' into feat/#478
Hrepay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
EATSSU/App/Sources/Data/Network/DTO/Notification/NotificationDTO.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // | ||
| // NotificationDTO.swift | ||
| // EATSSU | ||
| // | ||
| // Created by 황상환 on 11/7/26. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| /// 알림함 항목 (`GET /notifications`) | ||
| struct NotificationItemDTO: Codable, Equatable { | ||
| let notificationId: Int | ||
| /// 알림 종류. 현재는 `MENU_FAVORITE`만 온다 | ||
| let type: String | ||
| /// 제목·본문은 조회 시점의 사용자 언어로 만들어진다 | ||
| let title: String | ||
| let body: String | ||
| /// 알림을 누르면 이동할 식단 날짜 (yyyyMMdd) | ||
| let date: String | ||
| /// 이동할 시간대 (MORNING / LUNCH / DINNER) | ||
| let timePart: String? | ||
| let isRead: Bool | ||
| /// 알림 생성 시각. 서버(한국) 시간이며 타임존 표기가 없다 (예: `2026-11-02T11:00:00`) | ||
| let createdAt: String | ||
| } | ||
|
|
||
| /// `GET /notifications/unread` | ||
| struct UnreadNotificationDTO: Codable { | ||
| let hasUnread: Bool | ||
| } |
62 changes: 62 additions & 0 deletions
62
EATSSU/App/Sources/Data/Network/Router/NotificationRouter.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // | ||
| // NotificationRouter.swift | ||
| // EATSSU | ||
| // | ||
| // Created by 황상환 on 11/7/26. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| import Moya | ||
|
|
||
| /// 알림함 API (로그인 필요). 서버는 최근 7일(식단 날짜 기준) 찜 메뉴 알림만 보관한다 | ||
| enum NotificationRouter { | ||
| /// 알림 목록 (최신순). 제목·본문은 조회 시점의 사용자 언어로 내려온다 | ||
| case getNotifications | ||
| /// 안 읽은 알림이 있는지 (학식 탭 알림 아이콘의 점 표시) | ||
| case hasUnread | ||
| /// 알림 하나 읽음 처리. 이미 읽었어도 성공 | ||
| case read(notificationId: Int) | ||
| /// 내 알림 모두 읽음 처리 | ||
| case readAll | ||
| } | ||
|
|
||
| extension NotificationRouter: TargetType { | ||
| var baseURL: URL { | ||
| URL(string: Config.baseURL)! | ||
| } | ||
|
|
||
| var path: String { | ||
| switch self { | ||
| case .getNotifications: | ||
| "/notifications" | ||
| case .hasUnread: | ||
| "/notifications/unread" | ||
| case let .read(notificationId): | ||
| "/notifications/\(notificationId)/read" | ||
| case .readAll: | ||
| "/notifications/read-all" | ||
| } | ||
| } | ||
|
|
||
| var method: Moya.Method { | ||
| switch self { | ||
| case .getNotifications, .hasUnread: | ||
| .get | ||
| case .read, .readAll: | ||
| .patch | ||
| } | ||
| } | ||
|
|
||
| var task: Moya.Task { | ||
| .requestPlain | ||
| } | ||
|
|
||
| var headers: [String: String]? { | ||
| ["Content-Type": "application/json"] | ||
| } | ||
|
|
||
| var validationType: ValidationType { | ||
| .successCodes | ||
| } | ||
| } |
58 changes: 58 additions & 0 deletions
58
EATSSU/App/Sources/Data/Notification/NotificationInboxService.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // | ||
| // NotificationInboxService.swift | ||
| // EATSSU | ||
| // | ||
| // Created by 황상환 on 11/7/26. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| /// 알림함 API 호출 모음. 알림함 화면, 학식 탭 알림 아이콘, 푸시 탭 읽음 처리가 함께 쓴다 | ||
| enum NotificationInboxService { | ||
|
|
||
| static func fetchNotifications(completion: @escaping (Result<[NotificationItemDTO], Error>) -> Void) { | ||
| NetworkService.shared.request( | ||
| NotificationRouter.getNotifications, | ||
| responseType: [NotificationItemDTO].self, | ||
| useAuth: true, | ||
| completion: completion | ||
| ) | ||
| } | ||
|
|
||
| static func fetchHasUnread(completion: @escaping (Result<Bool, Error>) -> Void) { | ||
| NetworkService.shared.request( | ||
| NotificationRouter.hasUnread, | ||
| responseType: UnreadNotificationDTO.self, | ||
| useAuth: true | ||
| ) { result in | ||
| completion(result.map { $0.hasUnread }) | ||
| } | ||
| } | ||
|
|
||
| /// 읽음 처리 뒤 `.didUpdateNotificationReadState`를 보내 학식 탭 알림 아이콘이 점을 갱신하게 한다 | ||
| static func markRead(notificationId: Int, completion: ((Result<Bool, Error>) -> Void)? = nil) { | ||
| NetworkService.shared.request( | ||
| NotificationRouter.read(notificationId: notificationId), | ||
| responseType: Bool.self, | ||
| useAuth: true | ||
| ) { result in | ||
| if case .success = result { | ||
| NotificationCenter.default.post(name: .didUpdateNotificationReadState, object: nil) | ||
| } | ||
| completion?(result) | ||
| } | ||
| } | ||
|
|
||
| static func markAllRead(completion: @escaping (Result<Bool, Error>) -> Void) { | ||
| NetworkService.shared.request( | ||
| NotificationRouter.readAll, | ||
| responseType: Bool.self, | ||
| useAuth: true | ||
| ) { result in | ||
| if case .success = result { | ||
| NotificationCenter.default.post(name: .didUpdateNotificationReadState, object: nil) | ||
| } | ||
| completion(result) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.