Skip to content

Commit

Permalink
[ADD] DO-NOTTO-DO#84 - merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongdung-eo committed Jan 13, 2023
2 parents 670c534 + 83e5c9f commit c43839d
Show file tree
Hide file tree
Showing 53 changed files with 142 additions and 74 deletions.
28 changes: 12 additions & 16 deletions NotToDo/NotToDo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
090FA2F52960B70400918AED /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 090FA2F42960B70400918AED /* SnapKit */; };
090FA2F82960B74000918AED /* Then in Frameworks */ = {isa = PBXBuildFile; productRef = 090FA2F72960B74000918AED /* Then */; };
090FA2FB2960B87500918AED /* Moya in Frameworks */ = {isa = PBXBuildFile; productRef = 090FA2FA2960B87500918AED /* Moya */; };
0951EE8D297130DF004A3B5B /* AchieveCalendarResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0951EE8C297130DF004A3B5B /* AchieveCalendarResponseDTO.swift */; };
09611EE7296FD52700561CAA /* RecommendService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09611EE6296FD52700561CAA /* RecommendService.swift */; };
09611EEA296FDC6300561CAA /* RecommendDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09611EE9296FDC6300561CAA /* RecommendDTO.swift */; };
09611EED296FDD4200561CAA /* RecommendAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09611EEC296FDD4200561CAA /* RecommendAPI.swift */; };
Expand All @@ -33,10 +34,10 @@
099F0728296B94790036CF55 /* StatisticsEmptyTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 099F0727296B94790036CF55 /* StatisticsEmptyTableViewCell.swift */; };
099F072A296B98B90036CF55 /* SituationTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 099F0729296B98B90036CF55 /* SituationTitleView.swift */; };
099F073D296C2F770036CF55 /* CustomSegmentedControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 099F073C296C2F770036CF55 /* CustomSegmentedControl.swift */; };
09D3C535296FFD3500F1488D /* SituationStasticsResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D3C534296FFD3500F1488D /* SituationStasticsResponse.swift */; };
09D3C535296FFD3500F1488D /* SituationStasticsResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D3C534296FFD3500F1488D /* SituationStasticsResponseDTO.swift */; };
09D3C538296FFD7C00F1488D /* AchieveAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D3C537296FFD7C00F1488D /* AchieveAPI.swift */; };
09D3C53D29700DC800F1488D /* AchieveService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D3C53C29700DC800F1488D /* AchieveService.swift */; };
09D3C5412970101400F1488D /* MissionStatisticsReponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D3C5402970101400F1488D /* MissionStatisticsReponse.swift */; };
09D3C5412970101400F1488D /* MissionStatisticsReponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D3C5402970101400F1488D /* MissionStatisticsReponseDTO.swift */; };
09F695D9296C332D00877EA7 /* CompositionalLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09F695D8296C332D00877EA7 /* CompositionalLayout.swift */; };
09F695DB296C52B600877EA7 /* MissionTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09F695DA296C52B600877EA7 /* MissionTableViewCell.swift */; };
09F695DD296C52F000877EA7 /* SituationTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09F695DC296C52F000877EA7 /* SituationTableViewCell.swift */; };
Expand Down Expand Up @@ -147,6 +148,7 @@

/* Begin PBXFileReference section */
090FA2E6295F51BB00918AED /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
0951EE8C297130DF004A3B5B /* AchieveCalendarResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AchieveCalendarResponseDTO.swift; sourceTree = "<group>"; };
09611EE6296FD52700561CAA /* RecommendService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendService.swift; sourceTree = "<group>"; };
09611EE9296FDC6300561CAA /* RecommendDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendDTO.swift; sourceTree = "<group>"; };
09611EEC296FDD4200561CAA /* RecommendAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendAPI.swift; sourceTree = "<group>"; };
Expand All @@ -168,10 +170,10 @@
099F0727296B94790036CF55 /* StatisticsEmptyTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatisticsEmptyTableViewCell.swift; sourceTree = "<group>"; };
099F0729296B98B90036CF55 /* SituationTitleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SituationTitleView.swift; sourceTree = "<group>"; };
099F073C296C2F770036CF55 /* CustomSegmentedControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSegmentedControl.swift; sourceTree = "<group>"; };
09D3C534296FFD3500F1488D /* SituationStasticsResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SituationStasticsResponse.swift; sourceTree = "<group>"; };
09D3C534296FFD3500F1488D /* SituationStasticsResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SituationStasticsResponseDTO.swift; sourceTree = "<group>"; };
09D3C537296FFD7C00F1488D /* AchieveAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AchieveAPI.swift; sourceTree = "<group>"; };
09D3C53C29700DC800F1488D /* AchieveService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AchieveService.swift; sourceTree = "<group>"; };
09D3C5402970101400F1488D /* MissionStatisticsReponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MissionStatisticsReponse.swift; sourceTree = "<group>"; };
09D3C5402970101400F1488D /* MissionStatisticsReponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MissionStatisticsReponseDTO.swift; sourceTree = "<group>"; };
09F695D8296C332D00877EA7 /* CompositionalLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CompositionalLayout.swift; path = ../ViewControllers/CompositionalLayout.swift; sourceTree = "<group>"; };
09F695DA296C52B600877EA7 /* MissionTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MissionTableViewCell.swift; sourceTree = "<group>"; };
09F695DC296C52F000877EA7 /* SituationTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SituationTableViewCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -324,8 +326,9 @@
09611EEE296FFC5D00561CAA /* Achieve */ = {
isa = PBXGroup;
children = (
09D3C534296FFD3500F1488D /* SituationStasticsResponse.swift */,
09D3C5402970101400F1488D /* MissionStatisticsReponse.swift */,
09D3C534296FFD3500F1488D /* SituationStasticsResponseDTO.swift */,
0951EE8C297130DF004A3B5B /* AchieveCalendarResponseDTO.swift */,
09D3C5402970101400F1488D /* MissionStatisticsReponseDTO.swift */,
);
path = Achieve;
sourceTree = "<group>";
Expand Down Expand Up @@ -377,13 +380,6 @@
path = Common;
sourceTree = "<group>";
};
099F07002969E0F30036CF55 /* Model */ = {
isa = PBXGroup;
children = (
);
path = Model;
sourceTree = "<group>";
};
09D3C536296FFD5500F1488D /* Achieve */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -556,7 +552,6 @@
3B16289A295AD9850077AE7B /* AchievementScene */ = {
isa = PBXGroup;
children = (
099F07002969E0F30036CF55 /* Model */,
096BDFF329652260009ED396 /* Cells */,
096BDFE1296508C3009ED396 /* Common */,
3B1628A1295AD9EC0077AE7B /* ViewControllers */,
Expand Down Expand Up @@ -1221,15 +1216,16 @@
3BE6CBC32969D700003A8A7B /* MissionModel.swift in Sources */,
096BE01F2966A1FA009ED396 /* NestedView.swift in Sources */,
09F695DB296C52B600877EA7 /* MissionTableViewCell.swift in Sources */,
09D3C5412970101400F1488D /* MissionStatisticsReponse.swift in Sources */,
09D3C5412970101400F1488D /* MissionStatisticsReponseDTO.swift in Sources */,
0951EE8D297130DF004A3B5B /* AchieveCalendarResponseDTO.swift in Sources */,
3BE0700C296F43A2002CC50A /* UIView+.swift in Sources */,
3BE07013296F4456002CC50A /* NetworkResult.swift in Sources */,
09F695DD296C52F000877EA7 /* SituationTableViewCell.swift in Sources */,
6C600BC029693B3100421D7A /* MissionHistoryModel.swift in Sources */,
6C8826122967D85F0005E222 /* AddSituationModel.swift in Sources */,
6C600BCC2969FCBC00421D7A /* EmptyRecentViewCell.swift in Sources */,
3BE07004296F43A2002CC50A /* UIDevice+.swift in Sources */,
09D3C535296FFD3500F1488D /* SituationStasticsResponse.swift in Sources */,
09D3C535296FFD3500F1488D /* SituationStasticsResponseDTO.swift in Sources */,
6CCBCF9729707A790093C0F3 /* AddMissionReqeustDTO.swift in Sources */,
6CA2EFBE296FD28400D3E66B /* AddMissionService.swift in Sources */,
3BBE56F5296C4ED100771DE4 /* ThirdOnboardingViewController.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion NotToDo/NotToDo/Global/Extensions/UI/UIImage+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ extension UIImage {
static let rank = UIImage(named: "IC/ic_rank")!.withRenderingMode(.alwaysOriginal)
static let recentSearch = UIImage(named: "IC/ic_recentsearch")!.withRenderingMode(.alwaysOriginal)
static let recentUse = UIImage(named: "IC/ic_recentuse")!.withRenderingMode(.alwaysOriginal)
static let icRecommend = UIImage(named: "IC/ic_recommand")!.withRenderingMode(.alwaysOriginal)
static let icRecommend = UIImage(named: "IC/ic_recommend")!.withRenderingMode(.alwaysOriginal)
static let trash = UIImage(named: "IC/ic_trash")!.withRenderingMode(.alwaysOriginal)
static let warning = UIImage(named: "IC/ic_warning")!.withRenderingMode(.alwaysOriginal)
static let star = UIImage(named: "IC/ic_star")!.withRenderingMode(.alwaysOriginal)
Expand Down
23 changes: 22 additions & 1 deletion NotToDo/NotToDo/Network/API/Achieve/AchieveAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ final class AchieveAPI {

public private(set) var situationStatisticsData: GeneralArrayResponse<SituationStatistcsResponse>?
public private(set) var missionStatisticsData: GeneralArrayResponse<MissionStatistcsResponse>?
public private(set) var achieveCalendarData: GeneralArrayResponse<AchieveCalendarResponse>?

// MARK: - GET

Expand All @@ -30,7 +31,7 @@ final class AchieveAPI {
self.situationStatisticsData = try response.map(GeneralArrayResponse<SituationStatistcsResponse>?.self)
guard let situationStatisticsData = self.situationStatisticsData else { return }
completion(situationStatisticsData)
} catch (let err) {
} catch let err {
print(err.localizedDescription, 500)
}
case .failure(let err):
Expand Down Expand Up @@ -59,4 +60,24 @@ final class AchieveAPI {
}
}
}

// MARK: - GET

func getAchieveCalendar(month: String, completion: @escaping (GeneralArrayResponse<AchieveCalendarResponse>?) -> Void) {
achieveProvider.request(.achieveCalendar(month: month)) { result in
switch result {
case .success(let response):
do {
self.achieveCalendarData = try response.map(GeneralArrayResponse<AchieveCalendarResponse>?.self)
guard let situationStatisticsData = self.achieveCalendarData else { return }
completion(self.achieveCalendarData)
} catch (let err) {
print(err.localizedDescription, 500)
}
case .failure(let err):
print(err.localizedDescription)
completion(nil)
}
}
}
}
41 changes: 41 additions & 0 deletions NotToDo/NotToDo/Network/API/Achieve/MissionStatisticsAPI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// MissionStatisticsAPI.swift
// NotToDo
//
// Created by JEONGEUN KIM on 2023/01/12.
//

import Foundation

import Moya

final class MissionStatisticsAPI {

static let shared: MissionStatisticsAPI = MissionStatisticsAPI()

private let missionStatisticsProvider = MoyaProvider<AchieveService>(plugins: [MoyaLoggingPlugin()])

private init() { }

public private(set) var missionStatisticsData: GeneralArrayResponse<MissionStatistcsResponse>?

// MARK: - GET

func getMissionStatistics(completion: @escaping (GeneralArrayResponse<MissionStatistcsResponse>?) -> Void) {
missionStatisticsProvider.request(.missionStatistics) { result in
switch result {
case .success(let response):
do {
self.missionStatisticsData = try response.map(GeneralArrayResponse<MissionStatistcsResponse>?.self)
guard self.missionStatisticsData != nil else { return }
completion(self.missionStatisticsData)
} catch let err {
print(err.localizedDescription, 500)
}
case .failure(let err):
print(err.localizedDescription)
completion(nil)
}
}
}
}
4 changes: 1 addition & 3 deletions NotToDo/NotToDo/Network/API/AddSituation/AddMissionAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ final class AddMissionAPI {

private init() { }

//public private(set) var addMissionData: GeneralResponse<AddMissionResponse>?

// MARK: - POST

func postAddMission(newMission: AddMissionRequest, completion: @escaping (GeneralResponse<AddMissionResponse>?) -> Void) {
Expand All @@ -28,7 +26,7 @@ final class AddMissionAPI {
do {
guard let addMissionData = try response.map(GeneralResponse<AddMissionResponse>?.self) else { return }
completion(addMissionData)
} catch (let err) {
} catch let err {
print(err.localizedDescription, 500)
}
case .failure(let err):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class AddSituationAPI {
self.addSituationData = try response.map(GeneralResponse<AddSituationResponse>?.self)
guard let addSituationData = self.addSituationData else { return }
completion(addSituationData)
} catch (let err) {
} catch let err {
print(err.localizedDescription, 500)
}
case .failure(let err):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class MissionHistoryAPI {

// MARK: - GET

func getMissionHistory(completion: @escaping (GeneralArrayResponse<MissionHistoryModel>?) -> ()) {
func getMissionHistory(completion: @escaping (GeneralArrayResponse<MissionHistoryModel>?) -> Void) {
missionHistoryProvider.request(.missionHistory) { result in
switch result {
case .success(let response):
Expand All @@ -30,7 +30,7 @@ final class MissionHistoryAPI {
response.map(GeneralArrayResponse<MissionHistoryModel>?.self)
guard let missionHistoryData = self.missionHistoryData else { return }
completion(missionHistoryData)
} catch (let err) {
} catch let err {
print(err.localizedDescription, 500)
}
case .failure(let err):
Expand Down
8 changes: 4 additions & 4 deletions NotToDo/NotToDo/Network/API/Home/HomeAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ final class HomeAPI {
case .success(let response):
do {
self.updateMissionStatus = try response.map(GeneralResponse<UpdateMissionResponseDTO>?.self)
guard let updateMissionStatus = self.updateMissionStatus else { return }
guard self.updateMissionStatus != nil else { return }
completion(self.updateMissionStatus)
} catch (let err) {
} catch let err {
print(err.localizedDescription, 500)
}
case .failure(let err):
Expand All @@ -95,7 +95,7 @@ final class HomeAPI {
do {
let data = try response.map(GeneralResponse<VoidType>.self)
completion(data)
} catch (let err) {
} catch let err {
print(err.localizedDescription, 500)
}
case .failure(let err):
Expand All @@ -115,7 +115,7 @@ final class HomeAPI {
self.addAnotherDay = try response.map(GeneralResponse<AddAnotherDayResponseDTO>?.self)
guard let addAnotherDay = self.addAnotherDay else { return }
completion(addAnotherDay)
} catch(let err) {
} catch let err {
print(err.localizedDescription, 500)
}
case .failure(let err):
Expand Down
2 changes: 1 addition & 1 deletion NotToDo/NotToDo/Network/API/Recommend/RecommendAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class RecommendAPI {
self.recommendData = try response.map(GeneralArrayResponse<RecommendElementResponse>?.self)
guard let recommendData = self.recommendData else { return }
completion(recommendData)
} catch (let err) {
} catch let err {
print(err.localizedDescription, 500)
}
case .failure(let err):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// AchieveCalendarResponse.swift
// NotToDo
//
// Created by JEONGEUN KIM on 2023/01/13.
//

import Foundation

// MARK: - AchieveCalendarResponse
struct AchieveCalendarResponse: Codable {
let actionDate: String
let count: Int
}
6 changes: 3 additions & 3 deletions NotToDo/NotToDo/Network/Service/Achieve/AchieveService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ extension AchieveService: TargetType {

var method: Moya.Method {
switch self {
case .achieveCalendar(month: _), .missionStatistics, .situationStatistics:
case .achieveCalendar, .missionStatistics, .situationStatistics:
return .get
}
}

var task: Moya.Task {
switch self {
case .achieveCalendar(month: _), .missionStatistics, .situationStatistics:
case .achieveCalendar, .missionStatistics, .situationStatistics:
return .requestPlain
}
}

var headers: [String: String]? {
switch self {
case .achieveCalendar(month: _), .missionStatistics, .situationStatistics:
case .achieveCalendar, .missionStatistics, .situationStatistics:
return NetworkConstant.hasTokenHeader
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ extension AddMissionService: TargetType {
}

extension Encodable {
var toDictionary : [String: Any] {
var toDictionary: [String: Any] {
guard let object = try? JSONEncoder().encode(self) else { fatalError() }
guard let dictionary = try? JSONSerialization.jsonObject(with: object, options: []) as? [String: Any] else { fatalError() }
return dictionary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ extension AchievementViewController {
}

func configSituationView() {
var isSelected: [Bool] = [Bool](repeating: false, count: situationList.count)
let isSelected: [Bool] = [Bool](repeating: false, count: situationList.count)
situationView.situationList = situationList
situationView.isSelected = isSelected
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@ extension AddMissionViewController {
// MARK: - @objc Methods

@objc private func requestAddMissionAPI() {
print(addMissionView.addMissionButton.titleLabel?.text)
AddMissionAPI.shared.postAddMission(newMission: AddMissionRequest(title: addMissionView.missionText.text!, situation: (addMissionView.situationView.AddMissionButton.titleLabel?.text)!, actions: behaviorList.map { $0.behavior }, goal: addMissionView.goalTextField.text!, actionDate: "2023.01.25")) { [weak self] request in
AddMissionAPI.shared.postAddMission(
newMission: AddMissionRequest(title: addMissionView.missionText.text!,
situation: (addMissionView.situationView.AddMissionButton.titleLabel?.text)!,
actions: behaviorList.map { $0.behavior },
goal: addMissionView.goalTextField.text!,
actionDate: "2023.01.25")) { [weak self] _ in
guard self != nil else { return }
// behaviorList.removeAll()
} // (addMissionView.dateButton.titleLabel?.text)!
}
}

@objc func checkEnable() {
Expand Down
Loading

0 comments on commit c43839d

Please sign in to comment.