Skip to content
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

[Feat] 보관함 캘린더 구현 #212

Merged
merged 4 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public extension ModulePath {
case Onboarding
case Calendar
case PlaceSearch
case Archive

public static let name: String = "Feature"
}
Expand All @@ -49,6 +50,7 @@ public extension ModulePath {
case Moim
case Auth
case PlaceSearch
case Diary

public static let name: String = "Domain"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,78 +1,51 @@
//
// DiaryEndPoint.swift
// Namo_SwiftUI
// CoreNetwork
//
// Created by 서은수 on 3/16/24.
// Created by 정현우 on 11/1/24.
//

import Alamofire
import Foundation
import SwiftUICalendar

import SharedUtil

public enum DiaryEndPoint {
case createDiary(scheduleId: Int, content: String, images: [Data?])
case getMonthDiary(request: GetDiaryRequestDTO)
case getOneDiary(scheduleId: Int)
case changeDiary(scheduleId: Int, content: String, images: [Data?], deleteImageIds: [Int])
case deleteDiary(diaryId: Int)
case getCalendarByMonth(ym: YearMonth)
case getDiaryByDate(ymd: YearMonthDay)
}

extension DiaryEndPoint: EndPoint {
public var baseURL: String {
return "\(SecretConstants.baseURL)/diaries"
}

public var path: String {
switch self {
case .createDiary(_, _, _):
return ""
case .getMonthDiary(let req):
return "/month/\(req.year),\(req.month)"
case .getOneDiary(let scheduleId):
return "/\(scheduleId)"
case .changeDiary:
return ""
case .deleteDiary(let diaryId):
return "/\(diaryId)"
}
}

public var method: Alamofire.HTTPMethod {
switch self {
case .createDiary:
return .post
case .getMonthDiary, .getOneDiary:
return .get
case .changeDiary:
return .patch
case .deleteDiary:
return .delete
}
}

public var task: APITask {
switch self {
case .createDiary(let scheduleId, let content, let images):
let body = ["scheduleId": scheduleId, "content": content] as [String : Any]
return .uploadImagesWithBody(imageDatas: images, body: body)
case .changeDiary(let scheduleId, let content, let images, let deleteImageIds):
let params = ["scheduleId": scheduleId, "content": content, "deleteImageIds": deleteImageIds] as [String : Any]
return .uploadImagesWithParameter(imageDatas: images, parameters: params, imageKeyName: "createImages")
case .getMonthDiary(let req):
let params = ["page": req.page, "size": req.size]
return .requestParameters(parameters: params, encoding: URLEncoding.default)
case .deleteDiary, .getOneDiary:
return .requestPlain
}
}

public var headers: HTTPHeaders? {
switch self {
case .createDiary, .changeDiary:
return ["Content-Type": "multipart/form-data"]
default:
return ["Content-Type": "application/json"]
}
}
public var baseURL: String {
return "\(SecretConstants.baseURL)/diaries"
}

public var path: String {
switch self {
case .getCalendarByMonth(let ym):
return "/calendar/\(ym.year)-\(String(format: "%02d", ym.month))"
case .getDiaryByDate(let ymd):
return "/date/\(ymd.year)-\(String(format: "%02d", ymd.month))-\(String(format: "%02d", ymd.day))"
Comment on lines +26 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 포맷의 경우는 따로 유지보수하기 편하게 String Extension이나 ymd의 함수로 만들어 놓으면 좋을 것 같아보여요!

}
}

public var method: Alamofire.HTTPMethod {
switch self {
case .getCalendarByMonth:
return .get
case .getDiaryByDate:
return .get
}
}

public var task: APITask {
switch self {
case .getCalendarByMonth:
return .requestPlain
case .getDiaryByDate:
return .requestPlain
}
}


}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// DiaryCalendarDTO.swift
// CoreNetwork
//
// Created by 정현우 on 11/1/24.
//

public struct DiaryCalendarDTO: Decodable {
public let year: Int
public let month: Int
public let diaryDateForPersonal: [Int]
public let diaryDateForMeeting: [Int]
public let diaryDateForBirthday: [Int]

public init(year: Int, month: Int, diaryDateForPersonal: [Int], diaryDateForMeeting: [Int], diaryDateForBirthday: [Int]) {
self.year = year
self.month = month
self.diaryDateForPersonal = diaryDateForPersonal
self.diaryDateForMeeting = diaryDateForMeeting
self.diaryDateForBirthday = diaryDateForBirthday
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// DiaryScheduleDTO.swift
// CoreNetwork
//
// Created by 정현우 on 11/1/24.
//

public struct DiaryScheduleDTO: Decodable {
public let scheduleId: Int
public let scheduleType: Int
public let categoryInfo: DiaryScheduleCategoryDTO
public let scheduleStartDate: String
public let scheduleEndDate: String
public let scheduleTitle: String
public let diaryId: Int
public let participantInfo: DiaryScheduleParticipantDTO

public init(scheduleId: Int, scheduleType: Int, categoryInfo: DiaryScheduleCategoryDTO, scheduleStartDate: String, scheduleEndDate: String, scheduleTitle: String, diaryId: Int, participantInfo: DiaryScheduleParticipantDTO) {
self.scheduleId = scheduleId
self.scheduleType = scheduleType
self.categoryInfo = categoryInfo
self.scheduleStartDate = scheduleStartDate
self.scheduleEndDate = scheduleEndDate
self.scheduleTitle = scheduleTitle
self.diaryId = diaryId
self.participantInfo = participantInfo
}
}

public struct DiaryScheduleCategoryDTO: Decodable {
public let name: String
public let colorId: Int

public init(name: String, colorId: Int) {
self.name = name
self.colorId = colorId
}
}

public struct DiaryScheduleParticipantDTO: Decodable {
public let participantsCount: Int
public let participantsNames: String

public init(participantsCount: Int, participantsNames: String) {
self.participantsCount = participantsCount
self.participantsNames = participantsNames
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//
// emptyfile.swift
// Manifests
//
// Created by 정현우 on 10/1/24.
//

46 changes: 46 additions & 0 deletions Namo_SwiftUI/Projects/Domain/Diary/Project.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import ProjectDescription
import ProjectDescriptionHelpers
import DependencyPlugin

let targets: [Target] = [
.domain(
interface: .Diary,
factory: .init(
dependencies: [
.core
]
)
),
.domain(
implements: .Diary,
factory: .init(
dependencies: [
.domain(interface: .Diary)
]
)
),
.domain(
testing: .Diary,
factory: .init(
dependencies: [
.domain(interface: .Diary)
]
)
),
.domain(
tests: .Diary,
factory: .init(
dependencies: [
.domain(testing: .Diary)
]
)
)
]

let project: Project = .makeModule(
name: ModulePath.Domain.name+ModulePath.Domain.Diary.rawValue,
targets: targets
)



Loading