Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
linxiaoxin committed Sep 30, 2024
2 parents 6ed6b4e + 991677a commit 6fd5d93
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/main/resources/db/migration/V1.8__add_user_api_resources.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
do
$$
DECLARE
get_student_profile integer;
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', '/student/profile');

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_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';

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_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);
INSERT INTO qms_auth.role_api_resource(resource_id, role_id)
VALUES(accept_invite, student);

END;
$$;
22 changes: 22 additions & 0 deletions src/main/resources/db/migration/V1.9__add_class_api_resources.sql
Original file line number Diff line number Diff line change
@@ -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;
$$;
22 changes: 22 additions & 0 deletions src/main/resources/db/migration/V2.0__add_student_api.sql
Original file line number Diff line number Diff line change
@@ -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;
$$;
Original file line number Diff line number Diff line change
@@ -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;
$$;

0 comments on commit 6fd5d93

Please sign in to comment.