-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feture/#13/snmnetwork
- Loading branch information
Showing
15 changed files
with
411 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
SniffMeet/SniffMeet/Source/Auth/CreateProfile/Entity/Dog.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// DogDTO.swift | ||
// SniffMeet | ||
// | ||
// Created by 윤지성 on 11/14/24. | ||
// | ||
import Foundation | ||
|
||
struct DogDetailInfo { | ||
let name: String | ||
let age: UInt8 | ||
let size: Size | ||
let keywords: [Keyword] | ||
} | ||
|
||
enum Size: Codable { | ||
case small | ||
case medium | ||
case big | ||
} | ||
|
||
enum Keyword: String, Codable { | ||
case energetic = "활발한" | ||
case smart = "똑똑한" | ||
case friendly = "친화력 좋은" | ||
case shy = "소심한" | ||
case independent = "독립적인" | ||
} | ||
|
||
|
||
struct Dog: Codable { | ||
let name: String | ||
let age: UInt8 | ||
let size: Size | ||
let keywords: [Keyword] | ||
let nickname: String | ||
let profileImage: Data? | ||
} |
28 changes: 28 additions & 0 deletions
28
SniffMeet/SniffMeet/Source/Auth/CreateProfile/Interactor/DataManager.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// DataManager.swift | ||
// SniffMeet | ||
// | ||
// Created by 윤지성 on 11/14/24. | ||
// | ||
|
||
import Foundation | ||
|
||
protocol DataStorable { | ||
func storeData(data: Encodable) throws | ||
} | ||
|
||
// TODO: - dataManager를 주입받을 수 있도록 수정 예정 | ||
final class LocalDataManager: DataStorable { | ||
private let dataManager = UserDefaultsManager(userDefaults: UserDefaults(suiteName: "demo")!, | ||
jsonEncoder: JSONEncoder(), | ||
jsonDecoder: JSONDecoder()) | ||
func storeData(data: any Encodable) throws { | ||
try dataManager.set(value: data, forKey: UserDefaultKey.dogInfo) | ||
} | ||
} | ||
|
||
extension LocalDataManager { | ||
private enum UserDefaultKey { | ||
static let dogInfo: String = "dogInfo" | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
SniffMeet/SniffMeet/Source/Auth/CreateProfile/Interactor/ProfileCreateInteractor.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// ProfileCreateInteractable.swift | ||
// SniffMeet | ||
// | ||
// Created by 윤지성 on 11/14/24. | ||
// | ||
|
||
protocol ProfileCreateInteractable: AnyObject { | ||
var presenter: DogInfoInteractorOutput? { get set } | ||
var storeDogInfoUsecase: StoreDogInfoUseCase { get set } | ||
|
||
func saveDogInfo(dogInfo: Dog) | ||
} | ||
|
||
final class ProfileCreateInteractor: ProfileCreateInteractable { | ||
weak var presenter: DogInfoInteractorOutput? | ||
var storeDogInfoUsecase: StoreDogInfoUseCase | ||
|
||
init(presenter: DogInfoInteractorOutput? = nil, usecase: StoreDogInfoUseCase) { | ||
self.presenter = presenter | ||
storeDogInfoUsecase = usecase | ||
} | ||
|
||
func saveDogInfo(dogInfo: Dog) { | ||
do { | ||
try storeDogInfoUsecase.execute(dog: dogInfo) | ||
presenter?.didSaveDogInfo() | ||
} catch (let error){ | ||
presenter?.didFailToSaveDogInfo(error: error) | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
SniffMeet/SniffMeet/Source/Auth/CreateProfile/Interactor/SaveInfoUseCase.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// SaveInfoUseCase.swift | ||
// SniffMeet | ||
// | ||
// Created by 윤지성 on 11/14/24. | ||
// | ||
import Foundation | ||
|
||
protocol StoreDogInfoUseCase { | ||
func execute(dog: Dog) throws | ||
} | ||
|
||
|
||
final class StoreDogInfoUserCaseImpl: StoreDogInfoUseCase { | ||
let localDataManager: DataStorable | ||
|
||
init(localDataManager: DataStorable) { | ||
self.localDataManager = localDataManager | ||
} | ||
|
||
func execute(dog: Dog) throws { | ||
try localDataManager.storeData(data: dog) | ||
} | ||
} |
Oops, something went wrong.