From f50c10934974f0b2eef4a170b53cafb84e0abce8 Mon Sep 17 00:00:00 2001 From: Shiuan Date: Sun, 12 Dec 2021 21:19:52 -0600 Subject: [PATCH 1/3] change sql poo.execute in get all data request to pool.query --- backend/service/data.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/service/data.js b/backend/service/data.js index d056815..5fa8cde 100644 --- a/backend/service/data.js +++ b/backend/service/data.js @@ -54,7 +54,7 @@ const exportMetricCsv = async(data) => { const getAllCsvExport = async(data) => { let userId = data.userId; - results = await pool.execute(dataQuery.getAllDataRequest,[userId]); + results = await pool.query(dataQuery.getAllDataRequest,userId); for(i=0;i Date: Mon, 13 Dec 2021 23:25:54 -0600 Subject: [PATCH 2/3] modify how sql get all data request history, add api for getting access list of capture --- backend/controller/course.js | 10 +++++++++- backend/query/course.js | 10 ++++++++-- backend/service/course.js | 12 +++++++++++- backend/service/data.js | 17 ++++++++++++----- 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/backend/controller/course.js b/backend/controller/course.js index 066013b..d2de321 100644 --- a/backend/controller/course.js +++ b/backend/controller/course.js @@ -1,5 +1,5 @@ const express = require("express"); -const { getCourseList, getCourseListByInstructor, getCourseDetail, getAllCourses, createCourse, editCourse, editMultipleCourse, getAllSemesters, deleteCourse } = require("../service/course"); +const { getCourseList, getCourseListByInstructor, getCourseDetail, getAllCourses, createCourse, editCourse, editMultipleCourse, getAllSemesters, deleteCourse, getCourseAccess } = require("../service/course"); const courseController = express.Router(); // Query course list by user id @@ -78,4 +78,12 @@ courseController.delete("/delete", } ); +//get access list of courses by course id +courseController.get("/permissions/:courseId", + async (req, res) => { + const { courseId } = req.params; + const results = await getCourseAccess(courseId); + res.status(results.code || 200).json(results.data); + }); + module.exports = courseController; diff --git a/backend/query/course.js b/backend/query/course.js index 93c6173..8ae9514 100644 --- a/backend/query/course.js +++ b/backend/query/course.js @@ -92,7 +92,12 @@ FROM KP_Semester; const deleteCourseQuery = ` DELETE FROM KP_Course WHERE course_id = ?; -`; +` +const getCourseAccessByCouseId = ` +SELECT * FROM can_access_capture_files +WHERE couse_id = ? +` + module.exports = { getCourseList, getCourseListByInstructor, @@ -106,5 +111,6 @@ module.exports = { unregisterUser, editMultipleCourses, getSemestersQuery, - deleteCourseQuery + deleteCourseQuery, + getCourseAccessByCouseId }; diff --git a/backend/service/course.js b/backend/service/course.js index 0d07253..5fc1ec5 100644 --- a/backend/service/course.js +++ b/backend/service/course.js @@ -142,6 +142,15 @@ const deleteCourse = async({courseId}) => { } } +//get access list of courses by course id +const getCourseAccess = async courseId => { + const accessResults = await pool.execute(courseQuery.getCourseAccessByCouseId, [courseId]); + const accessList = accessResults[0]; + return { + data: {accessList} + }; +}; + module.exports = { getCourseList, getCourseListByInstructor, @@ -151,5 +160,6 @@ module.exports = { editCourse, editMultipleCourse, getAllSemesters, - deleteCourse + deleteCourse, + getCourseAccess }; diff --git a/backend/service/data.js b/backend/service/data.js index 5fa8cde..9b3950c 100644 --- a/backend/service/data.js +++ b/backend/service/data.js @@ -55,12 +55,19 @@ const exportMetricCsv = async(data) => { const getAllCsvExport = async(data) => { let userId = data.userId; results = await pool.query(dataQuery.getAllDataRequest,userId); - for(i=0;i 0){ + for(i=0;i { From eb3285ddd97f1e8ecb3744739f7fcb8f301a9122 Mon Sep 17 00:00:00 2001 From: Shiuan Date: Tue, 14 Dec 2021 14:04:15 -0600 Subject: [PATCH 3/3] modify api format for capture access --- backend/query/course.js | 2 +- backend/service/course.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/query/course.js b/backend/query/course.js index 8ae9514..6fa3e6c 100644 --- a/backend/query/course.js +++ b/backend/query/course.js @@ -94,7 +94,7 @@ DELETE FROM KP_Course WHERE course_id = ?; ` const getCourseAccessByCouseId = ` -SELECT * FROM can_access_capture_files +SELECT client_id FROM can_access_capture_files WHERE couse_id = ? ` diff --git a/backend/service/course.js b/backend/service/course.js index 5fc1ec5..0330e4c 100644 --- a/backend/service/course.js +++ b/backend/service/course.js @@ -147,7 +147,7 @@ const getCourseAccess = async courseId => { const accessResults = await pool.execute(courseQuery.getCourseAccessByCouseId, [courseId]); const accessList = accessResults[0]; return { - data: {accessList} + data: {courseId: courseId, accessList: accessList} }; };