Skip to content

Commit

Permalink
[#73] 보고서작성 구현완료
Browse files Browse the repository at this point in the history
  • Loading branch information
00yhsp committed Feb 18, 2024
1 parent 2820b32 commit 74a0963
Show file tree
Hide file tree
Showing 5 changed files with 286 additions and 228 deletions.
6 changes: 6 additions & 0 deletions Spon-us.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@
DF498F2C2B7CDDB200ADE078 /* MyAnnouncementsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF498F2B2B7CDDB200ADE078 /* MyAnnouncementsViewModel.swift */; };
DF498F2E2B7DF4F600ADE078 /* LogoutModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF498F2D2B7DF4F500ADE078 /* LogoutModel.swift */; };
DF498F302B7DF50200ADE078 /* LogoutViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF498F2F2B7DF50200ADE078 /* LogoutViewModel.swift */; };
DF5AB1522B81ED890061F421 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = DF5AB1512B81ED880061F421 /* GoogleService-Info.plist */; };
DF5AB1542B8228CC0061F421 /* MakeReportViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF5AB1532B8228CC0061F421 /* MakeReportViewModel.swift */; };
DF5B7E922B7FA430001C009C /* PortfolioOfferViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF5B7E912B7FA430001C009C /* PortfolioOfferViewModel.swift */; };
DF5B7E942B808DF1001C009C /* EditAnnouncementViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF5B7E932B808DF0001C009C /* EditAnnouncementViewModel.swift */; };
DF5B7E962B809257001C009C /* EditAnnouncementModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF5B7E952B809257001C009C /* EditAnnouncementModel.swift */; };
Expand Down Expand Up @@ -230,6 +232,8 @@
DF498F2B2B7CDDB200ADE078 /* MyAnnouncementsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyAnnouncementsViewModel.swift; sourceTree = "<group>"; };
DF498F2D2B7DF4F500ADE078 /* LogoutModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogoutModel.swift; sourceTree = "<group>"; };
DF498F2F2B7DF50200ADE078 /* LogoutViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogoutViewModel.swift; sourceTree = "<group>"; };
DF5AB1512B81ED880061F421 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "../../../Downloads/GoogleService-Info.plist"; sourceTree = "<group>"; };
DF5AB1532B8228CC0061F421 /* MakeReportViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MakeReportViewModel.swift; sourceTree = "<group>"; };
DF5B7E912B7FA430001C009C /* PortfolioOfferViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PortfolioOfferViewModel.swift; sourceTree = "<group>"; };
DF5B7E932B808DF0001C009C /* EditAnnouncementViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditAnnouncementViewModel.swift; sourceTree = "<group>"; };
DF5B7E952B809257001C009C /* EditAnnouncementModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditAnnouncementModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -643,6 +647,7 @@
DF5B7E912B7FA430001C009C /* PortfolioOfferViewModel.swift */,
DF5B7E932B808DF0001C009C /* EditAnnouncementViewModel.swift */,
DF5B7E952B809257001C009C /* EditAnnouncementModel.swift */,
DF5AB1532B8228CC0061F421 /* MakeReportViewModel.swift */,
);
path = Portfolio;
sourceTree = "<group>";
Expand Down Expand Up @@ -811,6 +816,7 @@
DFB22ED92B767003007903DF /* JoinViewModel.swift in Sources */,
100A1E302B71637A00AAC1E8 /* MyProfileView.swift in Sources */,
3BFC8D1F2B5597C9000D6006 /* ProfileView.swift in Sources */,
DF5AB1542B8228CC0061F421 /* MakeReportViewModel.swift in Sources */,
10025B372B7B802F00DCCC5A /* ProposalModel.swift in Sources */,
3B36F09C2B6FEBA00000ACFB /* ChargerInfoViewTest.swift in Sources */,
DF90A5BE2B6E39A600BC54D0 /* RegisterPWView.swift in Sources */,
Expand Down
40 changes: 40 additions & 0 deletions Spon-us/Model/Portfolio/MakeReportViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// MakeReportViewModel.swift
// Spon-us
//
// Created by 박현수 on 2/18/24.
//

import Foundation
import Moya

struct PostReportResponse: Codable {
let statusCode: String
let message: String
let content: PostReportContent
}

// 'content' 필드 내용을 담을 구조체
struct PostReportContent: Codable {
let id: Int
let writerId: Int
let title: String
let content: String
}

struct RequestParams: Codable {
let title: String
let content: String
let proposeId: Int
}

struct PatchProposeReportBody: Codable {
let isReported: Bool
let reportId: Int?
}

class MakeReportViewModel: ObservableObject {
@Published var filename = ""


}
80 changes: 78 additions & 2 deletions Spon-us/Model/Portfolio/PortfolioOfferViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ class PortfolioOfferViewModel: ObservableObject {
myProposes.append(prop)
}
}
// myProposes = Array(Set(myProposes))
// myProposes.sort { $0.createdDate > $1.createdDate }

myProposes = Array(Set(myProposes))
myProposes.sort {$0.proposeId > $1.proposeId}
// for content in myProposes {
// if content.status == "SUSPENDED" || content.status == "COMPLETED" {
//
Expand All @@ -96,6 +97,7 @@ class PortfolioOfferViewModel: ObservableObject {
case let .success(response):
if response.statusCode == 200 {
do {
print("stopoffer")
let responseBody = try JSONDecoder().decode(ChangeAnnouncementStatusModel400.self, from: response.data)
print(responseBody)
completion(true)
Expand Down Expand Up @@ -162,4 +164,78 @@ class PortfolioOfferViewModel: ObservableObject {
}
}
}

func completeOffer(proposeId: Int, completion: @escaping (Bool) -> Void) {
provider.request(.patchChangeOfferStatus(proposeID: proposeId, status: "COMPLETED")) { result in
switch result {
case let .success(response):
if response.statusCode == 200 {
do {
print("여기")
let responseBody = try JSONDecoder().decode(ChangeAnnouncementStatusModel400.self, from: response.data)
print(responseBody)
completion(true)
}
catch {
print("200 successError")
completion(false)
}
}
else {
do {
print(response.statusCode)
let responseBody = try JSONDecoder().decode(ChangeAnnouncementStatusModel400.self, from: response.data)
print(responseBody)
completion(false)
}
catch {
print("40x successError")
completion(false)
}
}
case let .failure(response):
print(response.errorDescription)
if let moyaError = response as? MoyaError, let response = moyaError.response {
if let responseBody = String(data: response.data, encoding: .utf8) {
print("실패 응답 본문: \(responseBody)")
}
}
print("failureError")
completion(false)
}
}
}

func cancelCompleteOffer(proposeId: Int, status: String, completion: @escaping (Bool) -> Void) {
provider.request(.patchChangeOfferStatus(proposeID: proposeId, status: status)) { result in
switch result {
case let .success(response):
if response.statusCode == 200 {
do {
let responseBody = try JSONDecoder().decode(ChangeAnnouncementStatusModel400.self, from: response.data)
print(responseBody)
completion(true)
}
catch {
print("200 successError")
completion(false)
}
}
else {
do {
let responseBody = try JSONDecoder().decode(ChangeAnnouncementStatusModel400.self, from: response.data)
print(responseBody)
completion(false)
}
catch {
print("40x successError")
completion(false)
}
}
case .failure(_):
print("failureError")
completion(false)
}
}
}
}
Loading

0 comments on commit 74a0963

Please sign in to comment.