36 lines
1.2 KiB
Scala
36 lines
1.2 KiB
Scala
package models
|
|
|
|
import play.api.libs.json.{JsValue, Json, Writes}
|
|
|
|
import java.time.Instant
|
|
|
|
case class User(id: Option[Int], username: String, gid: String, passwordDigest: Option[String])
|
|
|
|
case class AuthToken(id: Option[Int], userId: Int, token: String, createdAt: Instant, expiresAt: Instant)
|
|
|
|
enum AuctionStatus(val value: Short) {
|
|
case Created extends AuctionStatus(0)
|
|
case Ready extends AuctionStatus(10)
|
|
case Finished extends AuctionStatus(10000)
|
|
}
|
|
|
|
object AuctionStatus {
|
|
lazy val byValue: Map[Short, AuctionStatus] = Map.from(AuctionStatus.values.map{it => (it.value, it)})
|
|
}
|
|
|
|
case class Auction(id: Option[Int], name: String, status: AuctionStatus, gid: String, authorId: Int,
|
|
startingPrice: BigDecimal, currentBid: Option[BigDecimal],
|
|
currentBidderId: Option[Int], currentBidAt: Option[Instant],
|
|
createdAt: Instant)
|
|
|
|
object Auction {
|
|
implicit val writes: Writes[Auction] = (a: Auction) => Json.obj(
|
|
"id" -> a.id,
|
|
"name" -> a.name,
|
|
"gid" -> a.gid,
|
|
"starting_price" -> a.startingPrice,
|
|
"current_bid" -> a.currentBid,
|
|
"current_bidder_id" -> a.currentBidderId,
|
|
"current_bid_at" -> a.currentBidAt
|
|
)
|
|
} |