From 3d22cb7d1ee6bdf7b484bbf001c76e81ae351dea Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sat, 7 Feb 2015 23:57:36 +0100 Subject: Update accounts view to include usernames --- app/models/Views.scala | 9 ++++++--- res/sql/orcl_all.sql | 2 ++ res/sql/pg_all.sql | 2 ++ res/sql/views/orcl_accounts.sql | 1 + res/sql/views/pg_accounts.sql | 1 + 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/models/Views.scala b/app/models/Views.scala index a76b043..438c1d3 100644 --- a/app/models/Views.scala +++ b/app/models/Views.scala @@ -18,21 +18,24 @@ trait Views { /** Entity class storing rows of table Accounts * @param userUuid Database column user_uuid DBType(varchar), Length(36,true), Default(None) + * @param username Database column username DBType(varchar), Length(20,true), Default(None) * @param balance Database column balance DBType(numeric), Default(None) * @param openBids Database column open_bids DBType(numeric), Default(None) * @param equity Database column equity DBType(numeric), Default(None) */ - case class Account(userUuid: Option[String] = None, balance: Option[scala.math.BigDecimal] = None, openBids: Option[scala.math.BigDecimal] = None, equity: Option[scala.math.BigDecimal] = None) + case class Account(userUuid: Option[String] = None, username: Option[String] = None, balance: Option[scala.math.BigDecimal] = None, openBids: Option[scala.math.BigDecimal] = None, equity: Option[scala.math.BigDecimal] = None) /** GetResult implicit for fetching Account objects using plain SQL queries */ implicit def GetResultAccount(implicit e0: GR[Option[String]], e1: GR[Option[scala.math.BigDecimal]]): GR[Account] = GR{ prs => import prs._ - Account.tupled((< (Account.tupled, Account.unapply) + def * = (userUuid, username, balance, openBids, equity) <> (Account.tupled, Account.unapply) /** Database column user_uuid DBType(varchar), Length(36,true), Default(None) */ val userUuid: Column[Option[String]] = column[Option[String]]("user_uuid", O.Length(36,varying=true), O.Default(None)) + /** Database column username DBType(varchar), Length(20,true), Default(None) */ + val username: Column[Option[String]] = column[Option[String]]("username", O.Length(20,varying=true), O.Default(None)) /** Database column balance DBType(numeric), Default(None) */ val balance: Column[Option[scala.math.BigDecimal]] = column[Option[scala.math.BigDecimal]]("balance", O.Default(None)) /** Database column open_bids DBType(numeric), Default(None) */ diff --git a/res/sql/orcl_all.sql b/res/sql/orcl_all.sql index b0367de..08015f4 100644 --- a/res/sql/orcl_all.sql +++ b/res/sql/orcl_all.sql @@ -222,6 +222,7 @@ CREATE OR REPLACE VIEW accounts AS SELECT users.uuid AS user_uuid, + users.username AS username, COALESCE(transactions.balance, 0) AS balance, COALESCE(sales.open_bids, 0) AS open_bids, COALESCE(transactions.balance, 0) - COALESCE(sales.open_bids, 0) AS equity @@ -249,6 +250,7 @@ CREATE OR REPLACE VIEW accounts AS GROUP BY best_bidder_uuid ) sales ON sales.best_bidder_uuid = users.uuid; + INSERT INTO USERS (UUID, USERNAME, EMAIL, USER_PASSWORD, CREATION_DATE, FIRST_NAME, LAST_NAME, COUNTRY_CODE, POSTAL_CODE, ADDRESS, PHONE, BIRTHDATE) VALUES ('0C99BEF9-375F-3E4A-E050-D7936EBE2782', 'duf', 'duf@gmail.com', '123456', TO_TIMESTAMP_TZ('2000-01-01 00:00:00.000000', 'YYYY-MM-DD Hh24:MI:SS.FF'), 'Francis', 'Dumas', 'FR', '86544', diff --git a/res/sql/pg_all.sql b/res/sql/pg_all.sql index b76cb88..5d763e0 100644 --- a/res/sql/pg_all.sql +++ b/res/sql/pg_all.sql @@ -196,6 +196,7 @@ CREATE OR REPLACE VIEW accounts AS SELECT users.uuid AS user_uuid, + users.username AS username, COALESCE(transactions.balance, 0) AS balance, COALESCE(sales.open_bids, 0) AS open_bids, COALESCE(transactions.balance, 0) - COALESCE(sales.open_bids, 0) AS equity @@ -223,6 +224,7 @@ CREATE OR REPLACE VIEW accounts AS GROUP BY best_bidder_uuid ) sales ON sales.best_bidder_uuid = users.uuid; + INSERT INTO USERS (UUID, USERNAME, EMAIL, USER_PASSWORD, CREATION_DATE, FIRST_NAME, LAST_NAME, COUNTRY_CODE, POSTAL_CODE, ADDRESS, PHONE, BIRTHDATE) VALUES ('0C99BEF9-375F-3E4A-E050-D7936EBE2782', 'duf', 'duf@gmail.com', '123456', '2000-01-01 00:00:00.000000', 'Francis', diff --git a/res/sql/views/orcl_accounts.sql b/res/sql/views/orcl_accounts.sql index 400d38f..f3f5d6e 100644 --- a/res/sql/views/orcl_accounts.sql +++ b/res/sql/views/orcl_accounts.sql @@ -2,6 +2,7 @@ CREATE OR REPLACE VIEW accounts AS SELECT users.uuid AS user_uuid, + users.username AS username, COALESCE(transactions.balance, 0) AS balance, COALESCE(sales.open_bids, 0) AS open_bids, COALESCE(transactions.balance, 0) - COALESCE(sales.open_bids, 0) AS equity diff --git a/res/sql/views/pg_accounts.sql b/res/sql/views/pg_accounts.sql index 400d38f..f3f5d6e 100644 --- a/res/sql/views/pg_accounts.sql +++ b/res/sql/views/pg_accounts.sql @@ -2,6 +2,7 @@ CREATE OR REPLACE VIEW accounts AS SELECT users.uuid AS user_uuid, + users.username AS username, COALESCE(transactions.balance, 0) AS balance, COALESCE(sales.open_bids, 0) AS open_bids, COALESCE(transactions.balance, 0) - COALESCE(sales.open_bids, 0) AS equity -- cgit v1.2.3