feat(channel-donation-calculate): 채널 후원 정산 조회 기능을 추가한다
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package kr.co.vividnext.sodalive.support
|
||||
|
||||
import org.hibernate.dialect.H2Dialect
|
||||
import org.hibernate.dialect.function.StandardSQLFunction
|
||||
import org.hibernate.type.StandardBasicTypes
|
||||
|
||||
class H2MySqlFunctionDialect : H2Dialect() {
|
||||
init {
|
||||
registerFunction("date_format", StandardSQLFunction("DATE_FORMAT", StandardBasicTypes.STRING))
|
||||
registerFunction("DATE_FORMAT", StandardSQLFunction("DATE_FORMAT", StandardBasicTypes.STRING))
|
||||
registerFunction("convert_tz", StandardSQLFunction("CONVERT_TZ", StandardBasicTypes.TIMESTAMP))
|
||||
registerFunction("CONVERT_TZ", StandardSQLFunction("CONVERT_TZ", StandardBasicTypes.TIMESTAMP))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package kr.co.vividnext.sodalive.support
|
||||
|
||||
import java.sql.Timestamp
|
||||
import java.time.ZoneId
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
class H2MysqlDateFunctions {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun convertTz(value: Timestamp?, fromTz: String?, toTz: String?): Timestamp? {
|
||||
if (value == null || fromTz == null || toTz == null) {
|
||||
return value
|
||||
}
|
||||
|
||||
val fromZoneId = ZoneId.of(fromTz)
|
||||
val toZoneId = ZoneId.of(toTz)
|
||||
val converted = value.toLocalDateTime().atZone(fromZoneId).withZoneSameInstant(toZoneId).toLocalDateTime()
|
||||
|
||||
return Timestamp.valueOf(converted)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun dateFormat(value: Timestamp?, pattern: String?): String? {
|
||||
if (value == null || pattern == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
val javaPattern = pattern
|
||||
.replace("%Y", "yyyy")
|
||||
.replace("%m", "MM")
|
||||
.replace("%d", "dd")
|
||||
|
||||
return value.toLocalDateTime().format(DateTimeFormatter.ofPattern(javaPattern))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user