-
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.
feat(#53): converted Utils classes java to kotlin
- Loading branch information
1 parent
dc4836b
commit c1dc055
Showing
17 changed files
with
98 additions
and
122 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
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
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
14 changes: 0 additions & 14 deletions
14
archive-common/src/main/java/site/archive/common/ArchiveStringUtils.java
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
archive-common/src/main/java/site/archive/common/ArchiveStringUtils.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,9 @@ | ||
@file:JvmName("ArchiveStringUtils") | ||
|
||
package site.archive.common | ||
|
||
private const val MAIL_AT = '@' | ||
|
||
fun extractIdFromMail(mailAddress: String): String { | ||
return mailAddress.substring(0, mailAddress.indexOf(MAIL_AT)) | ||
} |
40 changes: 0 additions & 40 deletions
40
archive-common/src/main/java/site/archive/common/DateTimeUtil.java
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
archive-common/src/main/java/site/archive/common/DateTimeUtils.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,34 @@ | ||
@file:JvmName("DateTimeUtils") | ||
package site.archive.common | ||
|
||
import java.time.Clock | ||
import java.time.Instant | ||
import java.time.LocalDate | ||
import java.time.LocalDateTime | ||
import java.time.YearMonth | ||
import java.time.ZoneId | ||
import java.time.ZonedDateTime | ||
import java.time.format.DateTimeFormatter | ||
|
||
const val ASIA_SEOUL_ZONE_ID = "Asia/Seoul" | ||
val yymmddFormatter: DateTimeFormatter = DateTimeFormatter.ofPattern("yy/MM/dd") | ||
val dateTimeFormatter: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") | ||
val asiaSeoulZone: ZoneId = ZoneId.of(ASIA_SEOUL_ZONE_ID) | ||
|
||
var clock: Clock = Clock.system(asiaSeoulZone) | ||
|
||
fun changeClock(date: LocalDate) { | ||
val dateTime = date.atStartOfDay() | ||
val zoneOffset = asiaSeoulZone.rules.getOffset(dateTime) | ||
clock = Clock.fixed(dateTime.atOffset(zoneOffset).toInstant(), zoneOffset) | ||
} | ||
|
||
fun fromMilli(milli: Long): ZonedDateTime { | ||
return Instant.ofEpochMilli(milli).atZone(asiaSeoulZone) | ||
} | ||
|
||
fun firstDateTimeOfMonth(): LocalDateTime { | ||
return YearMonth.now(clock) | ||
.atDay(1) | ||
.atTime(0, 0) | ||
} |
30 changes: 0 additions & 30 deletions
30
archive-common/src/main/java/site/archive/common/FileUtils.java
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
archive-common/src/main/java/site/archive/common/FileUtils.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,22 @@ | ||
@file:JvmName("FileUtils") | ||
|
||
package site.archive.common | ||
|
||
import org.springframework.http.MediaType.IMAGE_GIF_VALUE | ||
import org.springframework.http.MediaType.IMAGE_JPEG_VALUE | ||
import org.springframework.http.MediaType.IMAGE_PNG_VALUE | ||
import org.springframework.web.multipart.MultipartFile | ||
|
||
private const val HTTP = "http://" | ||
private const val HTTPS = "https://" | ||
|
||
fun verifyImageFile(imageFile: MultipartFile) { | ||
if (!listOf(IMAGE_PNG_VALUE, IMAGE_GIF_VALUE, IMAGE_JPEG_VALUE) | ||
.contains(imageFile.contentType)) { | ||
throw IllegalStateException("FIle uploaded is not an image") | ||
} | ||
} | ||
|
||
fun isFileUrl(file: String?) : Boolean{ | ||
return file != null && (file.startsWith(HTTP) || file.startsWith(HTTPS)) | ||
} |
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
Oops, something went wrong.