Skip to content

Commit

Permalink
feat: reaction count만큼 올리는 로직 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
chansooo committed Oct 1, 2024
1 parent a932693 commit fea0d38
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions Projects/Core/PPACData/Sources/Endpoint/MemeEndpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public enum MemeEndpoint: Requestable {
case deleteBookmark(memeId: String)
case share(memeId: String)
case watch(memeId: String, type: String)
case reaction(memeId: String)
case reaction(memeId: String, count: Int)

public var httpMethod: PPACNetwork.HTTPMethod {
switch self {
Expand Down Expand Up @@ -61,8 +61,8 @@ public enum MemeEndpoint: Requestable {
return "/meme/\(memeId)/share"
case .watch(let memeId, let type):
return "/meme/\(memeId)/watch/\(type)"
case .reaction(let memeId):
return "/meme/\(memeId)/reaction"
case .reaction(let memeId, _):
return "meme/\(memeId)/reaction"
}
}

Expand All @@ -85,8 +85,8 @@ public enum MemeEndpoint: Requestable {
return nil
case .watch:
return nil
case .reaction:
return nil
case let .reaction(memeId, count):
return .body(MemeReactionRequestDTO(count: count))
case .meme(memeId: _):
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public class MemeRepositoryImpl: MemeRepository {
}
}

public func reactToMeme(memeId: String) async throws {
let endpoint = MemeEndpoint.reaction(memeId: memeId)
public func reactToMeme(memeId: String, count: Int) async throws {
let endpoint = MemeEndpoint.reaction(memeId: memeId, count: count)
let result = await networkservice.request(endpoint, dataType: BaseDTO<VoidResponse>.self)
switch result {
case .success:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public protocol MemeRepository {
func deleteBookmarkMeme(memeId: String) async throws
func shareMeme(memeId: String) async throws
func watchMeme(memeId: String, type: String) async throws
func reactToMeme(memeId: String) async throws
func reactToMeme(memeId: String, count: Int) async throws

func registerMeme(formData: FormData, title: String, source: String, keywordIds: [String]) async throws
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import PPACModels

public protocol ReactToMemeUseCase {
func execute(memeId: String) async throws
func execute(memeId: String, count: Int) async throws
}

public class ReactToMemeUseCaseImpl: ReactToMemeUseCase {
Expand All @@ -20,7 +20,7 @@ public class ReactToMemeUseCaseImpl: ReactToMemeUseCase {
self.repository = repository
}

public func execute(memeId: String) async throws {
try await repository.reactToMeme(memeId: memeId)
public func execute(memeId: String, count: Int) async throws {
try await repository.reactToMeme(memeId: memeId, count: count)
}
}

0 comments on commit fea0d38

Please sign in to comment.