Skip to content

Commit

Permalink
chore: Backend integration
Browse files Browse the repository at this point in the history
  • Loading branch information
dodo849 committed Aug 23, 2024
1 parent daf9b30 commit 0c771d7
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import AnnouncementDataInterface
import AnnouncementData
import OrganizationDataInterface
import OrganizationData
import TodoDataInterface
import TodoData

public extension Container {
static let shared: Container = {
Expand All @@ -30,6 +32,10 @@ public extension Container {
OrganizationRepository()
}

container.register(TodoRepositoryInterface.self) { _ in
TodoRepository()
}

return container
}()
}
2 changes: 2 additions & 0 deletions Projects/DI/ContainerDIModule/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ let project = Project.makeDIModule(
.dataInterface(.organization),
.dataInterface(.announcement),
.dataInterface(.member),
.dataInterface(.todo),
// data
.data(.organization),
.data(.announcement),
.data(.member),
.data(.todo),
// third party
.thirdParty(.swinject),
.thirdParty(.rxSwift)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@
// Created by DOYEON LEE on 7/22/24.
//

import Foundation

import OrganizationDataInterface
import AnnouncementEntity
import Container

import Swinject
import Foundation
import OrganizationDataInterface
import RxSwift
import Swinject

public final class GetAllAnnouncementUsecase {
// MARK: DTO
public struct Input {
public init() { }
public init() {

}
}

public struct Output {
public let announcements: [AnnouncementOrganizationEntity]
}

// MARK: Error
public enum Error: LocalizedError {
case organizationNotFound
Expand All @@ -34,7 +34,9 @@ public final class GetAllAnnouncementUsecase {

// MARK: Dependency
private let organizationRepository = Container.shared
.resolve(OrganizationRepositoryInterface.self)!
.resolve(
OrganizationRepositoryInterface.self
)!

// MARK: Internal Usecase
private var announcementUsecaseDict: [Int64: _GetAnnouncementsByOrganizationUsecase] = [:]
Expand All @@ -44,37 +46,47 @@ public final class GetAllAnnouncementUsecase {
page = Constant.StartPage
}

public func execute(_ input: Input) -> Observable<Output> {
public func execute(
_ input: Input
) -> Observable<Output> {
let param = GetJoinedOrganizationsParam(
pageable: .init(
page: Int32(page),
page: Int32(
page
),
size: Constant.PageSize
)
)

return organizationRepository
.getJoinedOrganizations(param)
.getJoinedOrganizations(
param
)
.flatMap { result -> Observable<Output> in
guard let content = result.content else {
throw Error.organizationNotFound
}

// 각 organization마다 공지사항을 가져오기 위한 Observable 생성
let announcementObservables = content.map { organization in
self.fetchAnnouncements(
organizationId: organization.organizationId,
organizationName: organization.organizationName
)
}

// 모든 Observable을 합쳐서 순차적으로 실행
return Observable.zip(announcementObservables)
.map { announcementEntities in
Output(announcements: announcementEntities)
}
return Observable.zip(
announcementObservables
)
.map { announcementEntities in
Output(
announcements: announcementEntities
)
}
}
}

private func fetchAnnouncements(
organizationId: Int64,
organizationName: String
Expand All @@ -84,12 +96,19 @@ public final class GetAllAnnouncementUsecase {
announcementUsecaseDict[organizationId] = announcementUsecase

return announcementUsecase
.execute(.init(organizationId: organizationId))
.execute(
.init(
organizationId: organizationId
)
)
.map { output in
return AnnouncementOrganizationEntity(
id: Int(organizationId),
id: Int(
organizationId
),
name: organizationName,
status: .join, // TODO: 실제 상태 판단 로직 필요
status: .join,
// TODO: 실제 상태 판단 로직 필요
announcements: output.announcements
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// GetTodosByOrganizationUsecase.swift
// TodoUsecase
//
// Created by DOYEON LEE on 8/23/24.
//

import RxSwift

public struct GetTodosByOrganizationUsecase {
// MARK: DTO
public struct Input {
public init() { }
}

public struct Output { }

// MARK: Dependency


// MARK: Initializer
public init() { }

// MARK: Execute method
public func execute(_ input: Input) -> Observable<Output> {
let outputObservable = Observable.just(Output())
return outputObservable
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ public class HomeTabView: BaseView {
public extension HomeTabView {
enum Page: CaseIterable, Identifiable, Paginable {
case announcement
// case todo
case todo

var krName: String {
switch self {
case .announcement: return "노티"
// case .todo: return "투두"
case .todo: return "투두"
}
}

Expand All @@ -117,8 +117,8 @@ public extension HomeTabView {
switch self {
case .announcement:
return AnnouncementPageViewController()
// case .todo:
// return TodoPageViewController()
case .todo:
return TodoPageViewController()
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions openapi-generator-cli/Sources/OpenapiGenerated/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@ public struct Client: APIProtocol {
}
)
}
/// [인증] 조직 가입
/// [인증] 조직 가입 신청
///
/// 조직에 가입합니다.
/// 조직에 가입을 신청합니다. 조직의 가입 대기자 목록에 추가됩니다.
///
/// - Remark: HTTP `POST /api/v1/organizations/{organizationId}/join`.
/// - Remark: Generated from `#/paths//api/v1/organizations/{organizationId}/join/post(join)`.
Expand Down Expand Up @@ -1963,7 +1963,7 @@ public struct Client: APIProtocol {
}
)
}
/// 사용자 할당 투두 목록 조회
/// [인증] 사용자 할당 투두 목록 조회
///
/// - Remark: HTTP `GET /api/v1/tasks/assigned`.
/// - Remark: Generated from `#/paths//api/v1/tasks/assigned/get(getAssigned)`.
Expand Down
19 changes: 9 additions & 10 deletions openapi-generator-cli/Sources/OpenapiGenerated/Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public protocol APIProtocol: Sendable {
/// - Remark: HTTP `POST /api/v1/organizations`.
/// - Remark: Generated from `#/paths//api/v1/organizations/post(create)`.
func create(_ input: Operations.create.Input) async throws -> Operations.create.Output
/// [인증] 조직 가입
/// [인증] 조직 가입 신청
///
/// 조직에 가입합니다.
/// 조직에 가입을 신청합니다. 조직의 가입 대기자 목록에 추가됩니다.
///
/// - Remark: HTTP `POST /api/v1/organizations/{organizationId}/join`.
/// - Remark: Generated from `#/paths//api/v1/organizations/{organizationId}/join/post(join)`.
Expand Down Expand Up @@ -163,7 +163,7 @@ public protocol APIProtocol: Sendable {
/// - Remark: HTTP `PATCH /api/v1/organizations/{organizationId}/register`.
/// - Remark: Generated from `#/paths//api/v1/organizations/{organizationId}/register/patch(registerMember)`.
func registerMember(_ input: Operations.registerMember.Input) async throws -> Operations.registerMember.Output
/// 사용자 할당 투두 목록 조회
/// [인증] 사용자 할당 투두 목록 조회
///
/// - Remark: HTTP `GET /api/v1/tasks/assigned`.
/// - Remark: Generated from `#/paths//api/v1/tasks/assigned/get(getAssigned)`.
Expand Down Expand Up @@ -332,9 +332,9 @@ extension APIProtocol {
body: body
))
}
/// [인증] 조직 가입
/// [인증] 조직 가입 신청
///
/// 조직에 가입합니다.
/// 조직에 가입을 신청합니다. 조직의 가입 대기자 목록에 추가됩니다.
///
/// - Remark: HTTP `POST /api/v1/organizations/{organizationId}/join`.
/// - Remark: Generated from `#/paths//api/v1/organizations/{organizationId}/join/post(join)`.
Expand Down Expand Up @@ -588,7 +588,7 @@ extension APIProtocol {
body: body
))
}
/// 사용자 할당 투두 목록 조회
/// [인증] 사용자 할당 투두 목록 조회
///
/// - Remark: HTTP `GET /api/v1/tasks/assigned`.
/// - Remark: Generated from `#/paths//api/v1/tasks/assigned/get(getAssigned)`.
Expand Down Expand Up @@ -1709,7 +1709,6 @@ public enum Components {
}
}
/// - Remark: Generated from `#/components/schemas/AnnouncementResponse`.
/// "announcementId": 10,
public struct AnnouncementResponse: Codable, Hashable, Sendable {
/// - Remark: Generated from `#/components/schemas/AnnouncementResponse/organizationId`.
public var organizationId: Swift.Int64?
Expand Down Expand Up @@ -4335,9 +4334,9 @@ public enum Operations {
}
}
}
/// [인증] 조직 가입
/// [인증] 조직 가입 신청
///
/// 조직에 가입합니다.
/// 조직에 가입을 신청합니다. 조직의 가입 대기자 목록에 추가됩니다.
///
/// - Remark: HTTP `POST /api/v1/organizations/{organizationId}/join`.
/// - Remark: Generated from `#/paths//api/v1/organizations/{organizationId}/join/post(join)`.
Expand Down Expand Up @@ -7487,7 +7486,7 @@ public enum Operations {
}
}
}
/// 사용자 할당 투두 목록 조회
/// [인증] 사용자 할당 투두 목록 조회
///
/// - Remark: HTTP `GET /api/v1/tasks/assigned`.
/// - Remark: Generated from `#/paths//api/v1/tasks/assigned/get(getAssigned)`.
Expand Down
Loading

0 comments on commit 0c771d7

Please sign in to comment.