diff --git a/Readme.md b/Readme.md index 074b913..0bc78cc 100644 --- a/Readme.md +++ b/Readme.md @@ -32,4 +32,6 @@ This client did not ask for any renting. So everything will be sale only, the pr In reality, this specific backend is pretty much done (although there's more to come). The only thing left to do is add authentication to all the admin routes. For this, there's a couple of choices. -One is connect with user service (Our already created service for authentication). But this does not have email or sms access in case the client forgets his password. So I would instead connect this with a service like google authentication so that the client can connect his account with google. This means the database must have a new table named admins that contains everything regarding authentication. A part of the migration should be adding the client's user, as for now it shall only be him. \ No newline at end of file +One is connect with user service (Our already created service for authentication). But this does not have email or sms access in case the client forgets his password. So I would instead connect this with a service like google authentication so that the client can connect his account with google. This means the database must have a new table named admins that contains everything regarding authentication. A part of the migration should be adding the client's user, as for now it shall only be him. + +Filtering by rooms as well \ No newline at end of file diff --git a/migrations/2_agent.sql b/migrations/2_agent.sql index 6a86a5a..bba54ca 100644 --- a/migrations/2_agent.sql +++ b/migrations/2_agent.sql @@ -1,5 +1,6 @@ CREATE TABLE IF NOT EXISTS "agent" ( id UUID PRIMARY KEY, + shortcode VARCHAR UNIQUE NOT NULL, full_name VARCHAR NOT NULL, credential VARCHAR NOT NULL, credential_type VARCHAR NOT NULL, diff --git a/sql/agent/fetch_all.sql b/sql/agent/fetch_all.sql index 9a6666e..b61f06f 100644 --- a/sql/agent/fetch_all.sql +++ b/sql/agent/fetch_all.sql @@ -1,5 +1,6 @@ SELECT id, + shortcode, full_name, credential, credential_type as "credential_type: _", @@ -7,4 +8,4 @@ SELECT time_created, last_updated FROM agent -ORDER BY time_created DESC; \ No newline at end of file +ORDER BY full_name DESC; \ No newline at end of file diff --git a/sql/agent/fetch_with_ids.sql b/sql/agent/fetch_with_ids.sql index f35f65b..67f9d70 100644 --- a/sql/agent/fetch_with_ids.sql +++ b/sql/agent/fetch_with_ids.sql @@ -1,5 +1,6 @@ SELECT id, + shortcode, full_name, credential, credential_type as "credential_type: _", diff --git a/sql/agent/fetch_with_shortcode.sql b/sql/agent/fetch_with_shortcode.sql new file mode 100644 index 0000000..7a5e7fa --- /dev/null +++ b/sql/agent/fetch_with_shortcode.sql @@ -0,0 +1,11 @@ +SELECT + id, + shortcode, + full_name, + credential, + credential_type as "credential_type: _", + profile_picture_url, + time_created, + last_updated +FROM agent where shortcode = $1 +ORDER BY time_created DESC; \ No newline at end of file diff --git a/sql/agent/get_with_id.sql b/sql/agent/get_with_id.sql index 6e029be..8f9e53b 100644 --- a/sql/agent/get_with_id.sql +++ b/sql/agent/get_with_id.sql @@ -1,9 +1,10 @@ SELECT -id, -full_name, -credential, -credential_type as "credential_type: _", -profile_picture_url, -time_created, -last_updated + id, + shortcode, + full_name, + credential, + credential_type as "credential_type: _", + profile_picture_url, + time_created, + last_updated FROM agent WHERE id = $1 \ No newline at end of file diff --git a/sql/agent/insert.sql b/sql/agent/insert.sql index 9677d6e..d0543f5 100644 --- a/sql/agent/insert.sql +++ b/sql/agent/insert.sql @@ -1,9 +1,10 @@ INSERT INTO agent ( - id, full_name, credential, credential_type, profile_picture_url, time_created, last_updated + id, shortcode, full_name, credential, credential_type, profile_picture_url, time_created, last_updated ) VALUES ( - $1, $2, $3, $4, $5, $6, $6 + $1, $2, $3, $4, $5, $6, $7, $7 ) RETURNING id, +shortcode full_name, credential, credential_type as "credential_type: _", diff --git a/sql/agent/update.sql b/sql/agent/update.sql index b566b3b..97a0eba 100644 --- a/sql/agent/update.sql +++ b/sql/agent/update.sql @@ -1,12 +1,14 @@ UPDATE agent SET full_name = $1, - credential = $2, - credential_type = $3, - profile_picture_url = $4, - last_updated = $5 -WHERE id = $6 + shortcode = $2, + credential = $3, + credential_type = $4, + profile_picture_url = $5, + last_updated = $6 +WHERE id = $7 RETURNING id, + shortcode, full_name, credential, credential_type as "credential_type: _",