aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/Sale.scala37
-rw-r--r--app/models/Views.scala12
-rw-r--r--conf/routes55
-rw-r--r--res/sql/orcl_all.sql4
-rw-r--r--res/sql/pg_all.sql4
-rw-r--r--res/sql/views/orcl_sales.sql2
-rw-r--r--res/sql/views/pg_sales.sql2
7 files changed, 86 insertions, 30 deletions
diff --git a/app/controllers/Sale.scala b/app/controllers/Sale.scala
new file mode 100644
index 0000000..b5e4622
--- /dev/null
+++ b/app/controllers/Sale.scala
@@ -0,0 +1,37 @@
1package controllers
2
3import play.api._
4import play.api.data._
5import play.api.data.Forms._
6import play.api.mvc._
7
8import play.api.db.slick._
9import play.api.db.slick.Config.driver.simple._
10import play.api.Play.current
11
12import scala.concurrent.Future
13
14import models._
15
16
17object Sale extends Controller {
18
19 def sales = Auth { implicit request =>
20 DB.withSession { implicit session =>
21 val currentDateTime = new java.sql.Timestamp((new java.util.Date).getTime)
22 val sales = Views.Sales.filter(_.endDate > currentDateTime).sortBy(_.endDate.asc).run
23
24 Ok(views.html.pages.sales.currentSales(sales))
25 }
26 }
27
28 def sell(itemUuid: String) = TODO
29
30
31 def item(itemUuid: String) = TODO
32
33 def bids(itemUuid: String) = TODO
34
35 def bidSubmit(itemUuid: String) = TODO
36
37}
diff --git a/app/models/Views.scala b/app/models/Views.scala
index 438c1d3..154ca86 100644
--- a/app/models/Views.scala
+++ b/app/models/Views.scala
@@ -48,25 +48,29 @@ trait Views {
48 48
49 /** Entity class storing rows of table Sales 49 /** Entity class storing rows of table Sales
50 * @param itemUuid Database column item_uuid DBType(varchar), Length(36,true), Default(None) 50 * @param itemUuid Database column item_uuid DBType(varchar), Length(36,true), Default(None)
51 * @param itemName Database column item_name DBType(varchar), Length(20,true), Default(None)
51 * @param sellerUuid Database column seller_uuid DBType(varchar), Length(36,true), Default(None) 52 * @param sellerUuid Database column seller_uuid DBType(varchar), Length(36,true), Default(None)
52 * @param startDate Database column start_date DBType(timestamptz), Default(None) 53 * @param startDate Database column start_date DBType(timestamptz), Default(None)
53 * @param endDate Database column end_date DBType(timestamptz), Default(None) 54 * @param endDate Database column end_date DBType(timestamptz), Default(None)
54 * @param bestBidUuid Database column best_bid_uuid DBType(varchar), Length(36,true), Default(None) 55 * @param bestBidUuid Database column best_bid_uuid DBType(varchar), Length(36,true), Default(None)
55 * @param bestBidderUuid Database column best_bidder_uuid DBType(varchar), Length(36,true), Default(None) 56 * @param bestBidderUuid Database column best_bidder_uuid DBType(varchar), Length(36,true), Default(None)
57 * @param initialPrice Database column initial_price DBType(numeric), Default(None)
56 * @param bestOffer Database column best_offer DBType(numeric), Default(None) 58 * @param bestOffer Database column best_offer DBType(numeric), Default(None)
57 * @param charges Database column charges DBType(numeric), Default(None) */ 59 * @param charges Database column charges DBType(numeric), Default(None) */
58 case class Sale(itemUuid: Option[String] = None, sellerUuid: Option[String] = None, startDate: Option[java.sql.Timestamp] = None, endDate: Option[java.sql.Timestamp] = None, bestBidUuid: Option[String] = None, bestBidderUuid: Option[String] = None, bestOffer: Option[scala.math.BigDecimal] = None, charges: Option[scala.math.BigDecimal] = None) 60 case class Sale(itemUuid: Option[String] = None, itemName: Option[String] = None, sellerUuid: Option[String] = None, startDate: Option[java.sql.Timestamp] = None, endDate: Option[java.sql.Timestamp] = None, bestBidUuid: Option[String] = None, bestBidderUuid: Option[String] = None, initialPrice: Option[scala.math.BigDecimal] = None, bestOffer: Option[scala.math.BigDecimal] = None, charges: Option[scala.math.BigDecimal] = None)
59 /** GetResult implicit for fetching Sale objects using plain SQL queries */ 61 /** GetResult implicit for fetching Sale objects using plain SQL queries */
60 implicit def GetResultSale(implicit e0: GR[Option[String]], e1: GR[Option[java.sql.Timestamp]], e2: GR[Option[scala.math.BigDecimal]]): GR[Sale] = GR{ 62 implicit def GetResultSale(implicit e0: GR[Option[String]], e1: GR[Option[java.sql.Timestamp]], e2: GR[Option[scala.math.BigDecimal]]): GR[Sale] = GR{
61 prs => import prs._ 63 prs => import prs._
62 Sale.tupled((<<?[String], <<?[String], <<?[java.sql.Timestamp], <<?[java.sql.Timestamp], <<?[String], <<?[String], <<?[scala.math.BigDecimal], <<?[scala.math.BigDecimal])) 64 Sale.tupled((<<?[String], <<?[String], <<?[String], <<?[java.sql.Timestamp], <<?[java.sql.Timestamp], <<?[String], <<?[String], <<?[scala.math.BigDecimal], <<?[scala.math.BigDecimal], <<?[scala.math.BigDecimal]))
63 } 65 }
64 /** Table description of table sales. Objects of this class serve as prototypes for rows in queries. */ 66 /** Table description of table sales. Objects of this class serve as prototypes for rows in queries. */
65 class Sales(_tableTag: Tag) extends Table[Sale](_tableTag, "sales") { 67 class Sales(_tableTag: Tag) extends Table[Sale](_tableTag, "sales") {
66 def * = (itemUuid, sellerUuid, startDate, endDate, bestBidUuid, bestBidderUuid, bestOffer, charges) <> (Sale.tupled, Sale.unapply) 68 def * = (itemUuid, itemName, sellerUuid, startDate, endDate, bestBidUuid, bestBidderUuid, initialPrice, bestOffer, charges) <> (Sale.tupled, Sale.unapply)
67 69
68 /** Database column item_uuid DBType(varchar), Length(36,true), Default(None) */ 70 /** Database column item_uuid DBType(varchar), Length(36,true), Default(None) */
69 val itemUuid: Column[Option[String]] = column[Option[String]]("item_uuid", O.Length(36,varying=true), O.Default(None)) 71 val itemUuid: Column[Option[String]] = column[Option[String]]("item_uuid", O.Length(36,varying=true), O.Default(None))
72 /** Database column item_name DBType(varchar), Length(20,true), Default(None) */
73 val itemName: Column[Option[String]] = column[Option[String]]("item_name", O.Length(20,varying=true), O.Default(None))
70 /** Database column seller_uuid DBType(varchar), Length(36,true), Default(None) */ 74 /** Database column seller_uuid DBType(varchar), Length(36,true), Default(None) */
71 val sellerUuid: Column[Option[String]] = column[Option[String]]("seller_uuid", O.Length(36,varying=true), O.Default(None)) 75 val sellerUuid: Column[Option[String]] = column[Option[String]]("seller_uuid", O.Length(36,varying=true), O.Default(None))
72 /** Database column start_date DBType(timestamptz), Default(None) */ 76 /** Database column start_date DBType(timestamptz), Default(None) */
@@ -77,6 +81,8 @@ trait Views {
77 val bestBidUuid: Column[Option[String]] = column[Option[String]]("best_bid_uuid", O.Length(36,varying=true), O.Default(None)) 81 val bestBidUuid: Column[Option[String]] = column[Option[String]]("best_bid_uuid", O.Length(36,varying=true), O.Default(None))
78 /** Database column best_bidder_uuid DBType(varchar), Length(36,true), Default(None) */ 82 /** Database column best_bidder_uuid DBType(varchar), Length(36,true), Default(None) */
79 val bestBidderUuid: Column[Option[String]] = column[Option[String]]("best_bidder_uuid", O.Length(36,varying=true), O.Default(None)) 83 val bestBidderUuid: Column[Option[String]] = column[Option[String]]("best_bidder_uuid", O.Length(36,varying=true), O.Default(None))
84 /** Database column initial_price DBType(numeric), Default(None) */
85 val initialPrice: Column[Option[scala.math.BigDecimal]] = column[Option[scala.math.BigDecimal]]("initial_price", O.Default(None))
80 /** Database column best_offer DBType(numeric), Default(None) */ 86 /** Database column best_offer DBType(numeric), Default(None) */
81 val bestOffer: Column[Option[scala.math.BigDecimal]] = column[Option[scala.math.BigDecimal]]("best_offer", O.Default(None)) 87 val bestOffer: Column[Option[scala.math.BigDecimal]] = column[Option[scala.math.BigDecimal]]("best_offer", O.Default(None))
82 /** Database column charges DBType(numeric), Default(None) */ 88 /** Database column charges DBType(numeric), Default(None) */
diff --git a/conf/routes b/conf/routes
index d9d1cb1..06081d1 100644
--- a/conf/routes
+++ b/conf/routes
@@ -4,45 +4,46 @@
4 4
5 5
6# Home page 6# Home page
7GET / controllers.Application.index 7GET / controllers.Application.index
8GET /terms controllers.Application.terms 8GET /terms controllers.Application.terms
9GET /privacy controllers.Application.privacy 9GET /privacy controllers.Application.privacy
10 10
11# User account 11# User account
12GET /login controllers.Authentication.login 12GET /login controllers.Authentication.login
13POST /login controllers.Authentication.loginSubmit 13POST /login controllers.Authentication.loginSubmit
14 14
15GET /logout controllers.Authentication.logout 15GET /logout controllers.Authentication.logout
16 16
17GET /signup controllers.Profile.signup 17GET /signup controllers.Profile.signup
18POST /signup controllers.Profile.signupSubmit 18POST /signup controllers.Profile.signupSubmit
19 19
20#GET /profile controllers.Application.index 20#GET /profile controllers.Application.index
21#POST /profile controllers.Application.index 21#POST /profile controllers.Application.index
22# 22
23## Internal wallet and transactions (Pépal) 23# Internal wallet and transactions (Pépal)
24GET /account controllers.Account.summary 24GET /account controllers.Account.summary
25# 25
26#GET /deposit controllers.Application.index 26#GET /deposit controllers.Application.index
27#POST /deposit controllers.Application.index 27#POST /deposit controllers.Application.index
28# 28
29#GET /withdraw controllers.Application.index 29#GET /withdraw controllers.Application.index
30#POST /withdraw controllers.Application.index 30#POST /withdraw controllers.Application.index
31# 31
32## Items and sales (eBé) 32# Items and sales (eBé)
33#GET /sales/:page controllers.Application.index 33GET /sales controllers.Sale.sales
34# 34
35#GET /item/:uuid controllers.Application.index 35GET /item/:uuid controllers.Sale.item(uuid)
36# 36
37#GET /item/:uuid/bids controllers.Application.index 37GET /item/:uuid/bids controllers.Sale.bids(uuid)
38#POST /item/:uuid/bids controllers.Application.index 38POST /item/:uuid/bids controllers.Sale.bids(uuid)
39# 39
40#GET /sell controllers.Application.index 40GET /sell controllers.Sale.sell(itemUuid = null)
41#GET /sell/:uuid controllers.Application.index 41GET /sell/:uuid controllers.Sale.sell(uuid)
42#POST /sell controllers.Application.index 42POST /sell controllers.Sale.sell(itemUuid = null)
43POST /sell/:uuid controllers.Sale.sell(uuid)
43 44
44# Cheat console 45# Cheat console
45POST /console controllers.Console.console 46POST /console controllers.Console.console
46 47
47# Map static resources from the /public folder to the /assets URL path 48# Map static resources from the /public folder to the /assets URL path
48GET /assets/*file controllers.Assets.at(path="/public", file) 49GET /assets/*file controllers.Assets.at(path="/public", file)
diff --git a/res/sql/orcl_all.sql b/res/sql/orcl_all.sql
index 08015f4..b3b4072 100644
--- a/res/sql/orcl_all.sql
+++ b/res/sql/orcl_all.sql
@@ -173,11 +173,13 @@ CREATE OR REPLACE VIEW sales AS
173 173
174 SELECT 174 SELECT
175 items.uuid AS item_uuid, 175 items.uuid AS item_uuid,
176 items.item_name AS item_name,
176 items.user_uuid AS seller_uuid, 177 items.user_uuid AS seller_uuid,
177 items.start_date AS start_date, 178 items.start_date AS start_date,
178 items.end_date AS end_date, 179 items.end_date AS end_date,
179 best_bids.uuid AS best_bid_uuid, 180 best_bids.uuid AS best_bid_uuid,
180 best_bids.user_uuid AS best_bidder_uuid, 181 best_bids.user_uuid AS best_bidder_uuid,
182 items.initial_price AS initial_price,
181 best_bids.offer AS best_offer, 183 best_bids.offer AS best_offer,
182 COALESCE(charges.fee, 0) + COALESCE(charges.rate, 0) * best_bids.offer AS charges 184 COALESCE(charges.fee, 0) + COALESCE(charges.rate, 0) * best_bids.offer AS charges
183 185
@@ -218,6 +220,8 @@ CREATE OR REPLACE VIEW sales AS
218 GROUP BY charges.start_date, charges.end_date 220 GROUP BY charges.start_date, charges.end_date
219 ) charges 221 ) charges
220 ON items.end_date BETWEEN charges.start_date AND charges.end_date; 222 ON items.end_date BETWEEN charges.start_date AND charges.end_date;
223
224
221CREATE OR REPLACE VIEW accounts AS 225CREATE OR REPLACE VIEW accounts AS
222 226
223 SELECT 227 SELECT
diff --git a/res/sql/pg_all.sql b/res/sql/pg_all.sql
index 5d763e0..cecb7ed 100644
--- a/res/sql/pg_all.sql
+++ b/res/sql/pg_all.sql
@@ -164,11 +164,13 @@ CREATE OR REPLACE VIEW sales AS
164 164
165 SELECT 165 SELECT
166 items.uuid AS item_uuid, 166 items.uuid AS item_uuid,
167 items.item_name AS item_name,
167 items.user_uuid AS seller_uuid, 168 items.user_uuid AS seller_uuid,
168 items.start_date AS start_date, 169 items.start_date AS start_date,
169 items.end_date AS end_date, 170 items.end_date AS end_date,
170 best_bids.uuid AS best_bid_uuid, 171 best_bids.uuid AS best_bid_uuid,
171 best_bids.user_uuid AS best_bidder_uuid, 172 best_bids.user_uuid AS best_bidder_uuid,
173 items.initial_price AS initial_price,
172