Skip to content

Commit

Permalink
Merge pull request #154 from boostcampwm-2022/feature/diary-delete-logic
Browse files Browse the repository at this point in the history
Diary Delete Logic 추가
  • Loading branch information
radiantchoi authored Dec 6, 2022
2 parents 6a6653b + 151f3c4 commit 62bf578
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Segno/Segno.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
7940FB2F292E063100276EFC /* DiaryDetailDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7940FB2E292E063100276EFC /* DiaryDetailDTO.swift */; };
7940FB31292E065100276EFC /* DiaryDetailEndpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7940FB30292E065100276EFC /* DiaryDetailEndpoint.swift */; };
7940FB33292E065F00276EFC /* DiaryDetailUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7940FB32292E065F00276EFC /* DiaryDetailUseCase.swift */; };
79767E64293E2A1200E489DD /* DiaryDeleteEndpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79767E63293E2A1200E489DD /* DiaryDeleteEndpoint.swift */; };
9825F41B29377875005F2163 /* ChangeNicknameUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9825F41A29377875005F2163 /* ChangeNicknameUseCase.swift */; };
9825F41D29377ACF005F2163 /* SettingsRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9825F41C29377ACF005F2163 /* SettingsRepository.swift */; };
982A2A472924AE74006F6ACD /* UserDefaultsKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 982A2A462924AE74006F6ACD /* UserDefaultsKey.swift */; };
Expand Down Expand Up @@ -160,6 +161,7 @@
7940FB2E292E063100276EFC /* DiaryDetailDTO.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryDetailDTO.swift; sourceTree = "<group>"; };
7940FB30292E065100276EFC /* DiaryDetailEndpoint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryDetailEndpoint.swift; sourceTree = "<group>"; };
7940FB32292E065F00276EFC /* DiaryDetailUseCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryDetailUseCase.swift; sourceTree = "<group>"; };
79767E63293E2A1200E489DD /* DiaryDeleteEndpoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryDeleteEndpoint.swift; sourceTree = "<group>"; };
9825F41A29377875005F2163 /* ChangeNicknameUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangeNicknameUseCase.swift; sourceTree = "<group>"; };
9825F41C29377ACF005F2163 /* SettingsRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsRepository.swift; sourceTree = "<group>"; };
982A2A462924AE74006F6ACD /* UserDefaultsKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsKey.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -437,6 +439,7 @@
4FA3242A2923646F00DB04D5 /* DiaryListItemEndpoint.swift */,
7940FB30292E065100276EFC /* DiaryDetailEndpoint.swift */,
791529DF293344E8005A8DDB /* DiaryPostEndpoint.swift */,
79767E63293E2A1200E489DD /* DiaryDeleteEndpoint.swift */,
4F4E0D7529252236005ABA8F /* LoginEndpoint.swift */,
66A8CF6C29379A9900C17F84 /* UserDetailEndpoint.swift */,
791529DD29333D40005A8DDB /* ImageEndpoint.swift */,
Expand Down Expand Up @@ -578,6 +581,7 @@
983AE9D82935CEE2006547BD /* SettingsViewModel.swift in Sources */,
9825F41D29377ACF005F2163 /* SettingsRepository.swift in Sources */,
66F0D7EE2925FF8B0074872E /* DiaryCell.swift in Sources */,
79767E64293E2A1200E489DD /* DiaryDeleteEndpoint.swift in Sources */,
4F307A482938832900FA36A0 /* MusicSession.swift in Sources */,
4F9A00202922337F007D9057 /* LoginViewController.swift in Sources */,
982A2A472924AE74006F6ACD /* UserDefaultsKey.swift in Sources */,
Expand Down
31 changes: 31 additions & 0 deletions Segno/Segno/Data/Network/Endpoints/DiaryDeleteEndpoint.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// DiaryDeleteEndpoint.swift
// Segno
//
// Created by TaehoYoo on 2022/12/05.
//

import Foundation

enum DiaryDeleteEndpoint: Endpoint {
case item(token: String, diaryId: String)

var baseURL: URL? {
return URL(string: BaseURL.urlString)
}

var httpMethod: HTTPMethod {
return .DELETE
}

var path: String {
return "diary"
}

var parameters: HTTPRequestParameter? {
switch self {
case .item(let token, let diaryId):
return HTTPRequestParameter.body(["token": token, "diaryId": diaryId])
}
}
}
2 changes: 1 addition & 1 deletion Segno/Segno/Data/Network/Endpoints/DiaryPostEndpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ enum DiaryPostEndpoint: Endpoint {
}

var httpMethod: HTTPMethod {
return .GET
return .POST
}

var path: String {
Expand Down
15 changes: 15 additions & 0 deletions Segno/Segno/Data/Repository/DiaryRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ protocol DiaryRepository {
func getDiaryListItem() -> Single<DiaryListDTO>
func getDiary(id: String) -> Single<DiaryDetailDTO>
func postDiary(_ diary: DiaryDetail, image: Data) -> Single<DiaryDetailDTO>
func deleteDiary(id: String) -> Single<Bool>
}

final class DiaryRepositoryImpl: DiaryRepository {
Expand Down Expand Up @@ -79,4 +80,18 @@ final class DiaryRepositoryImpl: DiaryRepository {

return single
}

func deleteDiary(id: String) -> RxSwift.Single<Bool> {
//TODO: - Token 받아오기
let token = "0KjV78s0YPKbrlVP3QeAwUJcjohs2h2ysdWDLWg"

let diaryDeleteEndpoint = DiaryDeleteEndpoint.item(token: token, diaryId: id)

let single = NetworkManager.shared.call(diaryDeleteEndpoint)
.map { _ in
return true
}

return single
}
}

0 comments on commit 62bf578

Please sign in to comment.