Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
merge :: (#185) Recruitment ResponseDTO and Entity 수정
Browse files Browse the repository at this point in the history
merge :: (#185) Recruitment ResponseDTO and Entity 수정
  • Loading branch information
HongSJae authored Nov 5, 2023
2 parents db8909a + ddc1072 commit 5423472
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@ public struct AreaResponseDTO: Decodable {
public let tech: [String]
public let hiring: Int
public let majorTask: String
public let preferentialTreatment: String?

public init(
id: Int,
job: [String],
tech: [String],
hiring: Int,
majorTask: String
majorTask: String,
preferentialTreatment: String?
) {
self.id = id
self.job = job
self.tech = tech
self.hiring = hiring
self.majorTask = majorTask
self.preferentialTreatment = preferentialTreatment
}

enum CodingKeys: String, CodingKey {
case id, job, tech, hiring
case majorTask = "major_task"
case preferentialTreatment = "preferential_treatment"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ public struct RecruitmentDetailResponseDTO: Decodable {
public let companyProfileUrl: String
public let companyName: String
public let areas: [AreaResponseDTO]
public let preferentialTreatment: String?
public let requiredGrade: Int?
public let workHours: Int
public let startTime, endTime: String
public let requiredLicenses: [String]?
public let hiringProgress: [InterviewType]
public let trainPay: Int
public let pay: Int?
public let pay: String?
public let benefits: String?
public let military: Bool
public let submitDocument: String
Expand All @@ -23,13 +22,13 @@ public struct RecruitmentDetailResponseDTO: Decodable {
companyProfileUrl: String,
companyName: String,
areas: [AreaResponseDTO],
preferentialTreatment: String?,
requiredGrade: Int?,
workHours: Int,
startTime: String,
endTime: String,
requiredLicenses: [String]?,
hiringProgress: [InterviewType],
trainPay: Int,
pay: Int?,
pay: String?,
benefits: String?,
military: Bool,
submitDocument: String,
Expand All @@ -41,9 +40,9 @@ public struct RecruitmentDetailResponseDTO: Decodable {
self.companyProfileUrl = companyProfileUrl
self.companyName = companyName
self.areas = areas
self.preferentialTreatment = preferentialTreatment
self.requiredGrade = requiredGrade
self.workHours = workHours
self.startTime = startTime
self.endTime = endTime
self.requiredLicenses = requiredLicenses
self.hiringProgress = hiringProgress
self.trainPay = trainPay
Expand All @@ -61,9 +60,9 @@ public struct RecruitmentDetailResponseDTO: Decodable {
case companyProfileUrl = "company_profile_url"
case companyName = "company_name"
case areas
case preferentialTreatment = "preferential_treatment"
case requiredGrade = "required_grade"
case workHours = "work_hours"
case startTime = "start_time"
case endTime = "end_time"
case requiredLicenses = "required_licenses"
case hiringProgress = "hiring_progress"
case trainPay = "train_pay"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,27 @@ import Foundation
public extension RecruitmentDetailResponseDTO {
func toDomain() -> RecruitmentDetailEntity {
var unwrappedRequiredGrade: String? {
if let requiredGrade {
return String(requiredGrade) + "% 이내"
} else {
return nil
}
guard let requiredGrade else { return nil }
return String(requiredGrade) + "% 이내"
}
var unwrappedPay: String? {
if let pay {
return String(pay) + " 만원/년"
} else {
return nil
}
var workTime: String {
startTime.toHoursMinutes() +
" ~ " +
endTime.toHoursMinutes()
}
return RecruitmentDetailEntity(
companyID: companyID,
companyProfileUrl: companyProfileUrl,
companyName: companyName,
areas: areas.map { $0.toDomain() },
preferentialTreatment: preferentialTreatment,
requiredGrade: unwrappedRequiredGrade,
workHours: String(workHours),
workTime: workTime,
requiredLicenses: requiredLicenses?.joined(separator: ", "),
hiringProgress: hiringProgress.enumerated().map { (index, value) in
"\(index + 1). \(value.localizedString())"
}.joined(separator: "\n"),
trainPay: String(trainPay),
pay: unwrappedPay,
pay: pay,
benefits: benefits,
military: military,
submitDocument: submitDocument,
Expand All @@ -47,7 +41,14 @@ public extension AreaResponseDTO {
job: job.joined(separator: ", "),
tech: tech,
hiring: hiring,
majorTask: majorTask
majorTask: majorTask,
preferentialTreatment: preferentialTreatment
)
}
}

extension String {
func toHoursMinutes() -> String {
self.components(separatedBy: ":")[0...1].joined(separator: ":")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ public struct AreaEntity: Equatable, Hashable {
public let tech: [String]
public let hiring: Int
public let majorTask: String
public let preferentialTreatment: String?

public init(
id: String,
job: String,
tech: [String],
hiring: Int,
majorTask: String
majorTask: String,
preferentialTreatment: String?
) {
self.id = id
self.job = job
self.tech = tech
self.hiring = hiring
self.majorTask = majorTask
self.preferentialTreatment = preferentialTreatment
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ public struct RecruitmentDetailEntity: Equatable {
public let companyProfileUrl: String
public let companyName: String
public let areas: [AreaEntity]
public let preferentialTreatment: String?
public let requiredGrade: String?
public let workHours: String
public let workTime: String
public let requiredLicenses: String?
public let hiringProgress: String
public let trainPay: String
Expand All @@ -23,9 +22,8 @@ public struct RecruitmentDetailEntity: Equatable {
companyProfileUrl: String,
companyName: String,
areas: [AreaEntity],
preferentialTreatment: String?,
requiredGrade: String?,
workHours: String,
workTime: String,
requiredLicenses: String?,
hiringProgress: String,
trainPay: String,
Expand All @@ -41,9 +39,8 @@ public struct RecruitmentDetailEntity: Equatable {
self.companyProfileUrl = companyProfileUrl
self.companyName = companyName
self.areas = areas
self.preferentialTreatment = preferentialTreatment
self.requiredGrade = requiredGrade
self.workHours = workHours
self.workTime = workTime
self.requiredLicenses = requiredLicenses
self.hiringProgress = hiringProgress
self.trainPay = trainPay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ struct AreaCell: View {

if isShowDetail {
areaInfo(title: "사용기술", content: area.tech.joined(separator: ", "))
if let preferentialTreatment = area.preferentialTreatment {
areaInfo(title: "우대사항", content: preferentialTreatment)
}
}

HStack {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ final class RecruitmentDetailViewModel: BaseViewModel {
) { [weak self] recruitmentDetail in
self?.recruitmentDetail = recruitmentDetail
let insertTitles = [
"우대사항",
"자격증",
"필수성적",
"근무시간",
Expand All @@ -103,10 +102,9 @@ final class RecruitmentDetailViewModel: BaseViewModel {
"기타사항"
]
let insertContents = [
recruitmentDetail.preferentialTreatment,
recruitmentDetail.requiredLicenses,
recruitmentDetail.requiredGrade,
recruitmentDetail.workHours + " 시간",
recruitmentDetail.workTime,
recruitmentDetail.trainPay + " 만원/월",
recruitmentDetail.pay,
recruitmentDetail.benefits,
Expand Down

0 comments on commit 5423472

Please sign in to comment.