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] 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