Auctions index and CORS filter
This commit is contained in:
@@ -2,7 +2,7 @@ package dao
|
||||
|
||||
import models.{Auction, AuctionStatus}
|
||||
import schemas.Auctions
|
||||
import schemas.auctionStatusColumnType
|
||||
import schemas.given
|
||||
import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfigProvider}
|
||||
import slick.jdbc.PostgresProfile
|
||||
import slick.jdbc.PostgresProfile.api.*
|
||||
@@ -15,6 +15,16 @@ import scala.util.Random
|
||||
class AuctionsDAO @Inject()(protected val dbConfigProvider: DatabaseConfigProvider)(implicit val ec: ExecutionContext)
|
||||
extends HasDatabaseConfigProvider[PostgresProfile] {
|
||||
|
||||
def list_available(user: models.User): Future[Seq[Auction]] = {
|
||||
db.run {
|
||||
Auctions.filter(row => (row.status === AuctionStatus.Ready) && (row.authorId =!= user.id.get)).result
|
||||
}
|
||||
}
|
||||
|
||||
def list_created_by(user: models.User): Future[Seq[Auction]] = {
|
||||
db.run(Auctions.filter(_.authorId === user.id).result)
|
||||
}
|
||||
|
||||
def create(name: String, startingPrice: BigDecimal, author: models.User): Future[Auction] = {
|
||||
val auction = Auction(
|
||||
id = None, name = name,
|
||||
|
||||
Reference in New Issue
Block a user