From f09beb1a4ae597fce12cfbe5336d8061fec1637a Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sat, 9 Sep 2023 22:52:51 +0200 Subject: [PATCH] Implement POST /market/:id/order --- init.sql | 1 + pages/market.html | 6 +++--- public/400.html | 37 +++++++++++++++++++++++++++++++++++++ src/db.go | 9 +++++++++ src/market.go | 33 ++++++++++++++++++++++++++------- 5 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 public/400.html diff --git a/init.sql b/init.sql index 14c4e7f..abb228b 100644 --- a/init.sql +++ b/init.sql @@ -34,3 +34,4 @@ CREATE TABLE orders( price BIGINT NOT NULL, order_id UUID REFERENCES orders(id) ); +ALTER TABLE orders ADD CONSTRAINT order_price CHECK(price > 0 AND price < 100); diff --git a/pages/market.html b/pages/market.html index 927cbf8..d5333bc 100644 --- a/pages/market.html +++ b/pages/market.html @@ -80,10 +80,10 @@ {{ else }} {{ end }} - {{ if and (eq .ShareId $.YesShare.Id) (eq .Side "BUY") }} + {{ if and (eq .ShareId $.NoShare.Id) (eq .Side "BUY") }}
- YES + NO {{.Quantity}} @ {{.Price}}
@@ -97,7 +97,7 @@
Order Form -