From 2c64737d1d36265866f2a90486878909145dc207 Mon Sep 17 00:00:00 2001 From: ernestjx <73307945+ernestjx@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:42:51 +0800 Subject: [PATCH 1/5] added student/accept-invitation, tutor/profile apis --- .../V1.8__add_user_api_resources.sql | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/resources/db/migration/V1.8__add_user_api_resources.sql diff --git a/src/main/resources/db/migration/V1.8__add_user_api_resources.sql b/src/main/resources/db/migration/V1.8__add_user_api_resources.sql new file mode 100644 index 0000000..81db599 --- /dev/null +++ b/src/main/resources/db/migration/V1.8__add_user_api_resources.sql @@ -0,0 +1,39 @@ +do +$$ +DECLARE + get_tutor_profile integer; + post_tutor_profile integer; + accept_invite integer; + tutor integer; + student integer; +BEGIN + +-- Api Resource + +INSERT INTO qms_auth.api_resource(method, path) +VALUES( 'GET', '/users/tutor/profile'); + +INSERT INTO qms_auth.api_resource(method, path) +VALUES( 'POST', '/users/tutor/profile'); + +INSERT INTO qms_auth.api_resource(method, path) +VALUES( 'POST', '/student/accept-invitation'); + +-- Grants +SELECT id into get_tutor_profile FROM qms_auth.api_resource WHERE path = '/users/tutor/profile' and method = 'GET'; +SELECT id into post_tutor_profile FROM qms_auth.api_resource WHERE path = '/users/tutor/profile' and method = 'POST'; +SELECT id into accept_invite FROM qms_auth.api_resource WHERE path = '/student/accept-invitation' and method = 'POST'; + +select id into tutor FROM qms_auth.role where name = 'tutor'; +select id into student FROM qms_auth.role where name = 'student'; + +/*generate question from ai*/ +INSERT INTO qms_auth.role_api_resource(resource_id, role_id) +VALUES( get_tutor_profile, tutor); +INSERT INTO qms_auth.role_api_resource(resource_id, role_id) +VALUES(post_tutor_profile, tutor); +INSERT INTO qms_auth.role_api_resource(resource_id, role_id) +VALUES(accept_invite, student); + +END; +$$; \ No newline at end of file From 34ecb0c9f5b5918a3cdba6c92982ba7c2bd6a64a Mon Sep 17 00:00:00 2001 From: ernestjx <73307945+ernestjx@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:55:45 +0800 Subject: [PATCH 2/5] added student/accept-invitation, tutor/profile, student/profile apis --- .../resources/db/migration/V1.8__add_user_api_resources.sql | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/resources/db/migration/V1.8__add_user_api_resources.sql b/src/main/resources/db/migration/V1.8__add_user_api_resources.sql index 81db599..d7769c2 100644 --- a/src/main/resources/db/migration/V1.8__add_user_api_resources.sql +++ b/src/main/resources/db/migration/V1.8__add_user_api_resources.sql @@ -1,6 +1,7 @@ do $$ DECLARE + get_student_profile integer; get_tutor_profile integer; post_tutor_profile integer; accept_invite integer; @@ -9,6 +10,8 @@ DECLARE BEGIN -- Api Resource +INSERT INTO qms_auth.api_resource(method, path) +VALUES( 'GET', '/student/profile'); INSERT INTO qms_auth.api_resource(method, path) VALUES( 'GET', '/users/tutor/profile'); @@ -20,6 +23,7 @@ INSERT INTO qms_auth.api_resource(method, path) VALUES( 'POST', '/student/accept-invitation'); -- Grants +SELECT id into get_student_profile FROM qms_auth.api_resource WHERE path = '/student/profile' and method = 'GET'; SELECT id into get_tutor_profile FROM qms_auth.api_resource WHERE path = '/users/tutor/profile' and method = 'GET'; SELECT id into post_tutor_profile FROM qms_auth.api_resource WHERE path = '/users/tutor/profile' and method = 'POST'; SELECT id into accept_invite FROM qms_auth.api_resource WHERE path = '/student/accept-invitation' and method = 'POST'; @@ -29,6 +33,8 @@ select id into student FROM qms_auth.role where name = 'student'; /*generate question from ai*/ INSERT INTO qms_auth.role_api_resource(resource_id, role_id) +VALUES(get_student_profile, student); +INSERT INTO qms_auth.role_api_resource(resource_id, role_id) VALUES( get_tutor_profile, tutor); INSERT INTO qms_auth.role_api_resource(resource_id, role_id) VALUES(post_tutor_profile, tutor); From fb1bde7348952fcf42c8762815919d5eaf4b177c Mon Sep 17 00:00:00 2001 From: ernestjx <73307945+ernestjx@users.noreply.github.com> Date: Mon, 16 Sep 2024 01:29:03 +0800 Subject: [PATCH 3/5] added GET /class/* for tutors --- .../V1.9__add_class_api_resources.sql | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/resources/db/migration/V1.9__add_class_api_resources.sql diff --git a/src/main/resources/db/migration/V1.9__add_class_api_resources.sql b/src/main/resources/db/migration/V1.9__add_class_api_resources.sql new file mode 100644 index 0000000..4d11280 --- /dev/null +++ b/src/main/resources/db/migration/V1.9__add_class_api_resources.sql @@ -0,0 +1,22 @@ +do +$$ +DECLARE + get_class_details integer; + tutor integer; +BEGIN + +-- Api Resource +INSERT INTO qms_auth.api_resource(method, path) +VALUES( 'GET', '/class/(.*)'); + +-- Grants +SELECT id into get_class_details FROM qms_auth.api_resource WHERE path = '/class/(.*)' and method = 'GET'; + +select id into tutor FROM qms_auth.role where name = 'tutor'; + +/*generate question from ai*/ +INSERT INTO qms_auth.role_api_resource(resource_id, role_id) +VALUES(get_class_details, tutor); + +END; +$$; \ No newline at end of file From 2140e756c4db0bc667090b0051f93bf8b74fd277 Mon Sep 17 00:00:00 2001 From: ernestjx <73307945+ernestjx@users.noreply.github.com> Date: Thu, 19 Sep 2024 22:53:00 +0800 Subject: [PATCH 4/5] added /student/search api --- .../db/migration/V2.0__add_student_api.sql | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/resources/db/migration/V2.0__add_student_api.sql diff --git a/src/main/resources/db/migration/V2.0__add_student_api.sql b/src/main/resources/db/migration/V2.0__add_student_api.sql new file mode 100644 index 0000000..615550a --- /dev/null +++ b/src/main/resources/db/migration/V2.0__add_student_api.sql @@ -0,0 +1,22 @@ +do +$$ +DECLARE + search_student integer; + tutor integer; +BEGIN + +-- Api Resource +INSERT INTO qms_auth.api_resource(method, path) +VALUES( 'POST', '/student/search'); + +-- Grants +SELECT id into search_student FROM qms_auth.api_resource WHERE path = '/student/search' and method = 'POST'; + +select id into tutor FROM qms_auth.role where name = 'tutor'; + +/*generate question from ai*/ +INSERT INTO qms_auth.role_api_resource(resource_id, role_id) +VALUES(search_student, tutor); + +END; +$$; From 991677ab59ebe99cc573dbcd1895acae29338f8e Mon Sep 17 00:00:00 2001 From: ernestjx <73307945+ernestjx@users.noreply.github.com> Date: Thu, 26 Sep 2024 22:57:05 +0800 Subject: [PATCH 5/5] added remove student api --- .../V2.1__remove_student_from_class.sql | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/resources/db/migration/V2.1__remove_student_from_class.sql diff --git a/src/main/resources/db/migration/V2.1__remove_student_from_class.sql b/src/main/resources/db/migration/V2.1__remove_student_from_class.sql new file mode 100644 index 0000000..05bf74a --- /dev/null +++ b/src/main/resources/db/migration/V2.1__remove_student_from_class.sql @@ -0,0 +1,22 @@ +do +$$ +DECLARE +remove_student integer; + tutor integer; +BEGIN + +-- Api Resource +INSERT INTO qms_auth.api_resource(method, path) +VALUES( 'DELETE', '/class/(\d+)/student/(\d+)'); + +-- Grants +SELECT id into remove_student FROM qms_auth.api_resource WHERE path = '/class/(\d+)/student/(\d+)' and method = 'DELETE'; + +select id into tutor FROM qms_auth.role where name = 'tutor'; + +/*generate question from ai*/ +INSERT INTO qms_auth.role_api_resource(resource_id, role_id) +VALUES(remove_student, tutor); + +END; +$$;