Skip to content

Commit

Permalink
Merge branch 'develop' into feature/CategoryTab/#29
Browse files Browse the repository at this point in the history
  • Loading branch information
abi-hong authored Feb 8, 2022
2 parents b091662 + 68bd489 commit 7662583
Show file tree
Hide file tree
Showing 17 changed files with 334 additions and 40 deletions.
44 changes: 38 additions & 6 deletions Hyangyu/Hyangyu.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
836086F827A6A59B00E9B9F5 /* Search.swift in Sources */ = {isa = PBXBuildFile; fileRef = 836086F727A6A59B00E9B9F5 /* Search.swift */; };
8375EADB27B00D4E007D5EFA /* ServiceDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8375EADA27B00D4E007D5EFA /* ServiceDataModel.swift */; };
8375EADD27B00F04007D5EFA /* CategoryTab.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 00D0CCB5278BC3DC0087EF87 /* CategoryTab.storyboard */; };
8375EAE527B02D88007D5EFA /* MyPageAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8375EAE427B02D88007D5EFA /* MyPageAPI.swift */; };
8375EAE827B02D9B007D5EFA /* MyPageService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8375EAE727B02D9B007D5EFA /* MyPageService.swift */; };
837763BC27A067E600248B6F /* SignUpUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 837763BB27A067E600248B6F /* SignUpUser.swift */; };
837763C127A0892400248B6F /* MoyaLoggingPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 837763C027A0892400248B6F /* MoyaLoggingPlugin.swift */; };
837763C427A0894B00248B6F /* SignUpService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 837763C327A0894B00248B6F /* SignUpService.swift */; };
Expand Down Expand Up @@ -131,6 +133,8 @@
83C167CD279DF4DE00A4F289 /* SearchResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83C167CC279DF4DE00A4F289 /* SearchResult.swift */; };
83CA48CF27AF187E00F38EC6 /* SearchHeaderCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83CA48CE27AF187E00F38EC6 /* SearchHeaderCollectionReusableView.swift */; };
83CA48D227AF1DD500F38EC6 /* SearchResultView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83CA48D127AF1DD500F38EC6 /* SearchResultView.swift */; };
83DADD6027B12B51001DCE44 /* MyPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83DADD5F27B12B51001DCE44 /* MyPage.swift */; };
83DADD6327B13255001DCE44 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83DADD6227B13255001DCE44 /* User.swift */; };
83E2A0E927AC1E2900EB0A55 /* SearchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83E2A0E827AC1E2900EB0A55 /* SearchView.swift */; };
83E42363279ACB850094DC2E /* UIImage+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83E42362279ACB850094DC2E /* UIImage+Extensions.swift */; };
83E42366279ACD890094DC2E /* UITextField+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83E42365279ACD890094DC2E /* UITextField+Extensions.swift */; };
Expand Down Expand Up @@ -212,6 +216,8 @@
836086F427A6A58100E9B9F5 /* SearchTableViewHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchTableViewHeaderView.swift; sourceTree = "<group>"; };
836086F727A6A59B00E9B9F5 /* Search.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Search.swift; sourceTree = "<group>"; };
8375EADA27B00D4E007D5EFA /* ServiceDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceDataModel.swift; sourceTree = "<group>"; };
8375EAE427B02D88007D5EFA /* MyPageAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageAPI.swift; sourceTree = "<group>"; };
8375EAE727B02D9B007D5EFA /* MyPageService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageService.swift; sourceTree = "<group>"; };
837763BB27A067E600248B6F /* SignUpUser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignUpUser.swift; sourceTree = "<group>"; };
837763C027A0892400248B6F /* MoyaLoggingPlugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoyaLoggingPlugin.swift; sourceTree = "<group>"; };
837763C327A0894B00248B6F /* SignUpService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignUpService.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -263,6 +269,8 @@
83C167CC279DF4DE00A4F289 /* SearchResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResult.swift; sourceTree = "<group>"; };
83CA48CE27AF187E00F38EC6 /* SearchHeaderCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchHeaderCollectionReusableView.swift; sourceTree = "<group>"; };
83CA48D127AF1DD500F38EC6 /* SearchResultView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultView.swift; sourceTree = "<group>"; };
83DADD5F27B12B51001DCE44 /* MyPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPage.swift; sourceTree = "<group>"; };
83DADD6227B13255001DCE44 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
83E2A0E827AC1E2900EB0A55 /* SearchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchView.swift; sourceTree = "<group>"; };
83E42362279ACB850094DC2E /* UIImage+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Extensions.swift"; sourceTree = "<group>"; };
83E42365279ACD890094DC2E /* UITextField+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITextField+Extensions.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -435,6 +443,28 @@
path = Views;
sourceTree = "<group>";
};
8375EAE227B02CA9007D5EFA /* AuthAPI */ = {
isa = PBXGroup;
children = (
837763C327A0894B00248B6F /* SignUpService.swift */,
83B8A66227A1042B00C22495 /* SignUpAPI.swift */,
83B8A66F27A10ECC00C22495 /* LoginAPI.swift */,
83B8A67227A10EEA00C22495 /* LoginService.swift */,
8307901927AB184500E0F7D4 /* PasswordAPI.swift */,
8307901C27AB185F00E0F7D4 /* PasswordService.swift */,
);
path = AuthAPI;
sourceTree = "<group>";
};
8375EAE327B02D76007D5EFA /* MyPageAPI */ = {
isa = PBXGroup;
children = (
8375EAE427B02D88007D5EFA /* MyPageAPI.swift */,
8375EAE727B02D9B007D5EFA /* MyPageService.swift */,
);
path = MyPageAPI;
sourceTree = "<group>";
};
837763BA27A067D400248B6F /* AppModels */ = {
isa = PBXGroup;
children = (
Expand All @@ -443,22 +473,19 @@
836086F727A6A59B00E9B9F5 /* Search.swift */,
8375EADA27B00D4E007D5EFA /* ServiceDataModel.swift */,
0003779927B0F6E200724152 /* ReviewModel.swift */,
83DADD6227B13255001DCE44 /* User.swift */,
);
path = AppModels;
sourceTree = "<group>";
};
837763BF27A088A400248B6F /* APIServices */ = {
isa = PBXGroup;
children = (
8375EAE327B02D76007D5EFA /* MyPageAPI */,
8375EAE227B02CA9007D5EFA /* AuthAPI */,
837763C027A0892400248B6F /* MoyaLoggingPlugin.swift */,
837763C327A0894B00248B6F /* SignUpService.swift */,
83B8A66227A1042B00C22495 /* SignUpAPI.swift */,
83B8A66527A1048C00C22495 /* NetworkResult.swift */,
83B8A66827A104C800C22495 /* GenericResponse.swift */,
83B8A66F27A10ECC00C22495 /* LoginAPI.swift */,
83B8A67227A10EEA00C22495 /* LoginService.swift */,
8307901927AB184500E0F7D4 /* PasswordAPI.swift */,
8307901C27AB185F00E0F7D4 /* PasswordService.swift */,
);
path = APIServices;
sourceTree = "<group>";
Expand Down Expand Up @@ -613,6 +640,7 @@
isa = PBXGroup;
children = (
83B8A65F27A103C100C22495 /* Auth.swift */,
83DADD5F27B12B51001DCE44 /* MyPage.swift */,
);
path = APIModels;
sourceTree = "<group>";
Expand Down Expand Up @@ -840,6 +868,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
83DADD6027B12B51001DCE44 /* MyPage.swift in Sources */,
0093448627AFAEB000490D57 /* WriteReviewViewController.swift in Sources */,
0003779A27B0F6E200724152 /* ReviewModel.swift in Sources */,
0093448427AFAE7F00490D57 /* MoreReviewViewController.swift in Sources */,
Expand All @@ -851,6 +880,7 @@
0003779727B0F05800724152 /* ReviewCollectionViewCell.swift in Sources */,
23842AA4279EBCF800621427 /* HomeHashtagDataModel.swift in Sources */,
83B34E01278735FF009A8009 /* AppDelegate.swift in Sources */,
8375EAE527B02D88007D5EFA /* MyPageAPI.swift in Sources */,
23842A95279EBCD600621427 /* ReviewViewController.swift in Sources */,
23842AA6279EBCF800621427 /* HashtagDetailDataModel.swift in Sources */,
23842A94279EBCD600621427 /* ReviewEditViewController.swift in Sources */,
Expand Down Expand Up @@ -892,6 +922,7 @@
836086F227A6A55600E9B9F5 /* SearchResultCell.swift in Sources */,
837763C127A0892400248B6F /* MoyaLoggingPlugin.swift in Sources */,
8399CF8E27994DB9002E5287 /* UIFont.swift in Sources */,
8375EAE827B02D9B007D5EFA /* MyPageService.swift in Sources */,
83E42363279ACB850094DC2E /* UIImage+Extensions.swift in Sources */,
837763C427A0894B00248B6F /* SignUpService.swift in Sources */,
8399CF6F27994775002E5287 /* UIScrollView+Extensions.swift in Sources */,
Expand Down Expand Up @@ -936,6 +967,7 @@
8399CF8B27994DA0002E5287 /* UIColor+RGB.swift in Sources */,
83B8A66627A1048C00C22495 /* NetworkResult.swift in Sources */,
832DFDB32795744500CBFC13 /* MyPageViewController.swift in Sources */,
83DADD6327B13255001DCE44 /* User.swift in Sources */,
8349587527987AB60045B419 /* TabBarViewController.swift in Sources */,
83B8A67027A10ECC00C22495 /* LoginAPI.swift in Sources */,
8399CF7A27994B2C002E5287 /* CustomChildViewController.swift in Sources */,
Expand Down
13 changes: 11 additions & 2 deletions Hyangyu/Hyangyu/Resources/Constants/URL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ extension Const {
struct URL {

// base url
static let baseURL = "http://13.209.87.36:8080/api"
static let baseURL = "http://52.79.236.231:8080/api"

// MARK: - Auth - Auth Service

// 회원가입 (POST)
static let signUpURL = "/UserApi/signup"

// 로그인 (GET)
// 로그인 (POST)

static let signInURL = "/AuthController/authenticate"

Expand All @@ -28,6 +28,15 @@ extension Const {
// 회원 탈퇴 (DELETE)
static let deleteUser = "/UserApi/user/deleteMyUser"

// MARK: - My Page - User Service

// 닉네임 변경 (POST)
static let modifyUserName = "/UserApi/user/modifyUsername"

// 유저 조회 (GET)
static let userView = "/api/UserApi/user"


}
}

13 changes: 13 additions & 0 deletions Hyangyu/Hyangyu/Sources/APIModels/MyPage.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// MyPage.swift
// Hyangyu
//
// Created by 배소린 on 2022/02/07.
//

import Foundation

// MARK: - message
struct ModifyCheckData: Codable {
let message: String
}
67 changes: 67 additions & 0 deletions Hyangyu/Hyangyu/Sources/APIServices/MyPageAPI/MyPageAPI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// MyPageAPI.swift
// Hyangyu
//
// Created by 배소린 on 2022/02/07.
//

import Foundation
import Moya

public class MyPageAPI {

static let shared = MyPageAPI()
var myPageProvider = MoyaProvider<MyPageService>()

public init() { }

func modifyUserName(completion: @escaping (NetworkResult<Any>) -> Void, email: String, password: String, nickname: String) {
myPageProvider.request(.modifyUserName(email: email, password: password, nickname: nickname)) {
(result) in
switch result {
case .success(let response):
let statusCode = response.statusCode
let data = response.data
let networkResult = self.judgeStatus(by: statusCode, data)
completion(networkResult)

case .failure(let err):
print(err)
}
}
}

func getUserInfo(completion: @escaping (NetworkResult<Any>) -> Void) {
myPageProvider.request(.getUserInfo) { (result) in
print(result)
switch result {
case .success(let response):
let statusCode = response.statusCode
let data = response.data
let networkResult = self.judgeStatus(by: statusCode, data)
completion(networkResult)
case .failure(let err):
print(err)
}
}
}

private func judgeStatus(by statusCode: Int, _ data: Data) -> NetworkResult<Any> {
let decoder = JSONDecoder()
guard let decodedData = try? decoder.decode(GenericResponse<ModifyCheckData>.self, from: data as Data)
else {
return .pathErr
}

switch statusCode {
case 200:
return .success(decodedData.data)
case 400..<500:
return .requestErr(decodedData.message)
case 500:
return .serverErr
default:
return .networkFail
}
}
}
82 changes: 82 additions & 0 deletions Hyangyu/Hyangyu/Sources/APIServices/MyPageAPI/MyPageService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// MyPageService.swift
// Hyangyu
//
// Created by 배소린 on 2022/02/07.
//

import Foundation
import Moya

enum MyPageService {

case modifyUserName(email:String, password:String, nickname: String)

case getUserInfo

}

extension MyPageService: TargetType, AccessTokenAuthorizable {
var authorizationType: AuthorizationType? {
return .bearer
}

var baseURL: URL {
return URL(string: Const.URL.baseURL)!
}
var path: String {
switch self {
case .modifyUserName(_, _, _):
return Const.URL.modifyUserName
case .getUserInfo:
return Const.URL.userView


}
}

var method: Moya.Method {
switch self {
case .modifyUserName(_, _, _):
return .post
case .getUserInfo:
return .get

}
}

var sampleData: Data {
return Data()
}


var task: Task {
switch self {
case .modifyUserName(let email, let password, let nickname):
return .requestParameters(parameters: [
"email": nil,
"password": nil,
"username": nickname,
], encoding: JSONEncoding.default)
case .getUserInfo:
return .requestPlain

}
}

var headers: [String: String]? {

switch self {
case .modifyUserName(_, _, _):
return [
"Content-Type": "application/json",
"Authorization": "Bearer \(UserDefaults.standard.string(forKey: "jwtToken") ?? "")"
]
case .getUserInfo:
return [
"Authorization": "Bearer \(UserDefaults.standard.string(forKey: "jwtToken") ?? "")",
"Content-Type": "application/json",
]
}
}
}
16 changes: 16 additions & 0 deletions Hyangyu/Hyangyu/Sources/AppModels/User.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// User.swift
// Hyangyu
//
// Created by 배소린 on 2022/02/07.
//

import Foundation
import UIKit

class User {
static let shared = User()

var username: String?
var profileImage: UIImage?
}
12 changes: 6 additions & 6 deletions Hyangyu/Hyangyu/Sources/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).

// if !hasJwtToken() {
// setRootViewControllerToLogin()
// } else {
// print(UserDefaults.standard.string(forKey: "jwtToken"))
// setRootViewControllerToTabbar()
// }
if !hasJwtToken() {
setRootViewControllerToLogin()
} else {
print(UserDefaults.standard.string(forKey: "jwtToken"))
setRootViewControllerToTabbar()
}
self.window?.backgroundColor = .white

guard let _ = (scene as? UIWindowScene) else { return }
Expand Down
Loading

0 comments on commit 7662583

Please sign in to comment.