-
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.
- Loading branch information
Showing
7 changed files
with
113 additions
and
4 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
52 changes: 52 additions & 0 deletions
52
src/main/kotlin/backend/itracker/crawl/service/mapper/ipad/IpadAirM2Mapper.kt
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,52 @@ | ||
package backend.itracker.crawl.service.mapper.ipad | ||
|
||
import backend.itracker.crawl.ipad.domain.Ipad | ||
import backend.itracker.crawl.ipad.domain.IpadCategory | ||
import backend.itracker.crawl.service.response.IpadCrawlResponse | ||
import backend.itracker.crawl.service.vo.DefaultProduct | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class IpadAirM2Mapper : IpadMappingComponent { | ||
|
||
override fun supports(subCategory: String): Boolean { | ||
return subCategory.contains("iPad Air M2") | ||
} | ||
|
||
override fun toDomain(product: DefaultProduct): Ipad { | ||
val names = product.name.split(",") | ||
.map { it.trim() } | ||
.toList() | ||
|
||
val title = names[0].split(" ") | ||
val company = title[0] | ||
val releaseYear = title[2] | ||
val category = IpadCategory.I_PAD_AIR | ||
val chip = "M2" | ||
val size = title[5] | ||
val generation = "6" | ||
val color = names[1] | ||
val storage = names[2] | ||
val isCellular = names[3].contains("Cellular") | ||
|
||
return IpadCrawlResponse( | ||
coupangId = product.productId, | ||
company = company, | ||
name = product.name, | ||
category = category, | ||
chip = chip, | ||
storage = storage, | ||
color = color, | ||
size = size, | ||
releaseYear = releaseYear.toInt(), | ||
isCellular = isCellular, | ||
generation = generation, | ||
productLink = product.productLink, | ||
thumbnail = product.thumbnailLink, | ||
basePrice = product.price.basePrice, | ||
discountPercentage = product.price.discountPercentage, | ||
currentPrice = product.price.discountPrice, | ||
isOutOfStock = product.price.isOutOfStock | ||
).toDomain() | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/main/kotlin/backend/itracker/crawl/service/mapper/ipad/IpadProM4Mapper.kt
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,54 @@ | ||
package backend.itracker.crawl.service.mapper.ipad | ||
|
||
import backend.itracker.crawl.ipad.domain.Ipad | ||
import backend.itracker.crawl.ipad.domain.IpadCategory | ||
import backend.itracker.crawl.service.response.IpadCrawlResponse | ||
import backend.itracker.crawl.service.vo.DefaultProduct | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class IpadProM4Mapper : IpadMappingComponent { | ||
|
||
override fun supports(subCategory: String): Boolean { | ||
return subCategory.contains("iPad Pro M4") | ||
} | ||
|
||
override fun toDomain(product: DefaultProduct): Ipad { | ||
val names = product.name.split(",") | ||
.map { it.trim() } | ||
.toList() | ||
|
||
val title = names[0].split(" ") | ||
val company = title[0] | ||
val releaseYear = title[2] | ||
val category = IpadCategory.I_PAD_PRO | ||
val chip = "M4" | ||
val size = title[5] | ||
val generation = "5" | ||
val glass = title[7] | ||
val color = names[1] | ||
val storage = names[2] | ||
val isCellular = names[3].contains("Cellular") | ||
|
||
return IpadCrawlResponse( | ||
coupangId = product.productId, | ||
company = company, | ||
name = product.name, | ||
category = category, | ||
chip = chip, | ||
storage = storage, | ||
color = color, | ||
size = size, | ||
glass = glass, | ||
releaseYear = releaseYear.toInt(), | ||
isCellular = isCellular, | ||
generation = generation, | ||
productLink = product.productLink, | ||
thumbnail = product.thumbnailLink, | ||
basePrice = product.price.basePrice, | ||
discountPercentage = product.price.discountPercentage, | ||
currentPrice = product.price.discountPrice, | ||
isOutOfStock = product.price.isOutOfStock | ||
).toDomain() | ||
} | ||
} |
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