This repository has been archived by the owner on Nov 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
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
149 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.kokasai.api.form | ||
|
||
import com.kokasai.api.util.serialize.DateSerializer | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import java.util.Date | ||
|
||
@Serializable | ||
data class FormDefineFile( | ||
val name: String, | ||
val description: String, | ||
@Serializable(with = DateSerializer::class) val receive: Date, | ||
@Serializable(with = DateSerializer::class) val limit: Date, | ||
val values: Map<Int, FormDefineValue>, | ||
val group: List<String> | ||
) | ||
|
||
@Serializable | ||
data class FormDefineValue( | ||
val name: String, | ||
val description: String, | ||
val type: FormDefineType | ||
) | ||
|
||
@Serializable | ||
sealed class FormDefineType { | ||
@Serializable | ||
@SerialName("string") | ||
object String : FormDefineType() { | ||
const val name = "string" | ||
} | ||
|
||
@Serializable | ||
@SerialName("check") | ||
data class Check( | ||
val element: Map<Int, kotlin.String>, | ||
val limit: Int | ||
) : FormDefineType() { | ||
companion object { | ||
const val name = "check" | ||
} | ||
} | ||
} |
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,25 @@ | ||
package com.kokasai.api.form | ||
|
||
import com.kokasai.api.util.serialize.DateSerializer | ||
import kotlinx.serialization.Serializable | ||
import java.util.Date | ||
|
||
@Serializable | ||
data class FormGetFile( | ||
val name: String, | ||
val description: String, | ||
@Serializable(with = DateSerializer::class) val receive: Date, | ||
@Serializable(with = DateSerializer::class) val limit: Date, | ||
val values: Map<Int, FormGetValue>, | ||
val comment: String, | ||
val status: Int | ||
) | ||
|
||
@Serializable | ||
data class FormGetValue( | ||
val name: String, | ||
val description: String, | ||
val type: FormDefineType, | ||
val value: FormSaveValue, | ||
val comment: String | ||
) |
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,10 @@ | ||
package com.kokasai.api.form | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class FormResponseFile( | ||
val values: Map<Int, FormSaveType>, | ||
val comment: String, | ||
val status: Int | ||
) |
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 @@ | ||
package com.kokasai.api.form | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class FormSaveFile( | ||
val values: Map<Int, FormSaveValue>, | ||
val comment: String, | ||
val status: Int | ||
) | ||
|
||
@Serializable | ||
data class FormSaveValue( | ||
val value: FormSaveType, | ||
val comment: String | ||
) | ||
|
||
@Serializable | ||
sealed class FormSaveType { | ||
@Serializable | ||
@SerialName("string") | ||
data class String(val content: kotlin.String) | ||
|
||
@Serializable | ||
@SerialName("check") | ||
data class Check(val select: List<Int>) | ||
} |
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,8 @@ | ||
package com.kokasai.api.form | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class FormSubmitFile( | ||
val values: Map<Int, FormSaveType> | ||
) |
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/com/kokasai/api/util/serialize/DateSerializer.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,29 @@ | ||
package com.kokasai.api.util.serialize | ||
|
||
import kotlinx.serialization.KSerializer | ||
import kotlinx.serialization.descriptors.PrimitiveKind | ||
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor | ||
import kotlinx.serialization.descriptors.SerialDescriptor | ||
import kotlinx.serialization.encoding.Decoder | ||
import kotlinx.serialization.encoding.Encoder | ||
import java.text.SimpleDateFormat | ||
import java.util.Date | ||
|
||
class DateSerializer : KSerializer<Date> { | ||
override val descriptor: SerialDescriptor by lazy { | ||
PrimitiveSerialDescriptor( | ||
DateSerializer::class.qualifiedName!!, | ||
PrimitiveKind.STRING | ||
) | ||
} | ||
|
||
private val formatter = SimpleDateFormat("yyyy/MM/dd HH:mm:ss") | ||
|
||
override fun serialize(encoder: Encoder, value: Date) { | ||
encoder.encodeString(formatter.format(value)) | ||
} | ||
|
||
override fun deserialize(decoder: Decoder): Date { | ||
return formatter.parse(decoder.decodeString()) | ||
} | ||
} |