From 56218f281aff2d4b753ee04ed27080db5492af54 Mon Sep 17 00:00:00 2001 From: nart4hire <nart4hire@gmail.com> Date: Fri, 31 Mar 2023 23:48:44 +0700 Subject: [PATCH] feat(course): added swag --- docs/docs.go | 1393 +++++++++++++++++--- docs/swagger.json | 1392 ++++++++++++++++--- docs/swagger.yaml | 838 ++++++++++-- handler/admin/addUser.go | 14 +- handler/admin/deleteUser.go | 12 +- handler/admin/getAllUser.go | 10 +- handler/admin/getUserByEmail.go | 10 +- handler/admin/updateUser.go | 14 +- handler/auth/login.go | 26 +- handler/auth/refresh.go | 22 +- handler/auth/register.go | 20 +- handler/auth/send_verify.go | 20 +- handler/auth/verify.go | 20 +- handler/common/home.go | 10 +- handler/course/addCourse.go | 25 +- handler/course/addFaculty.go | 20 +- handler/course/addMajor.go | 20 +- handler/course/deleteCourse.go | 21 +- handler/course/getCourse.go | 15 +- handler/course/getCourses.go | 10 + handler/course/getCoursesByFaculty.go | 16 +- handler/course/getCoursesByMajor.go | 16 +- handler/course/getFaculties.go | 11 +- handler/course/getFaculty.go | 16 +- handler/course/getMajor.go | 16 +- handler/course/getMajors.go | 10 + handler/course/getMajorsByFaculty.go | 17 +- handler/course/updateCourse.go | 21 +- handler/course/updateFaculty.go | 19 +- handler/course/updateMajor.go | 20 +- handler/material/add_content.go | 22 +- handler/material/create_material.go | 22 +- handler/material/delete_content.go | 18 +- handler/material/delete_material.go | 16 +- handler/material/get_material.go | 14 +- handler/reset/confirm.go | 14 +- handler/reset/request.go | 12 +- handler/reset/validate.go | 12 +- main.go | 6 +- model/web/admin/addUser/request.go | 2 +- model/web/admin/updateUser/request.go | 2 +- model/web/auth/login/request.go | 2 +- model/web/auth/login/response.go | 2 +- model/web/auth/refresh/response.go | 2 +- model/web/auth/register/request.go | 2 +- model/web/auth/verification/request.go | 2 +- model/web/course/add/request.go | 31 - model/web/course/delete/request.go | 11 - model/web/course/faculty/add/request.go | 14 - model/web/course/faculty/request.go | 32 + model/web/course/faculty/update/request.go | 19 - model/web/course/get/request.go | 17 - model/web/course/major/add/request.go | 22 - model/web/course/major/request.go | 45 + model/web/course/major/update/request.go | 25 - model/web/course/request.go | 89 ++ model/web/course/update/request.go | 34 - model/web/reset/confirm/request.go | 2 +- model/web/reset/request/request.go | 2 +- model/web/reset/validate/request.go | 2 +- routes/course/route.go | 7 - service/course/add.go | 20 +- service/course/delete.go | 6 +- service/course/get.go | 22 +- service/course/type.go | 45 +- service/course/update.go | 20 +- 66 files changed, 3774 insertions(+), 915 deletions(-) delete mode 100644 model/web/course/add/request.go delete mode 100644 model/web/course/delete/request.go delete mode 100644 model/web/course/faculty/add/request.go create mode 100644 model/web/course/faculty/request.go delete mode 100644 model/web/course/faculty/update/request.go delete mode 100644 model/web/course/get/request.go delete mode 100644 model/web/course/major/add/request.go create mode 100644 model/web/course/major/request.go delete mode 100644 model/web/course/major/update/request.go create mode 100644 model/web/course/request.go delete mode 100644 model/web/course/update/request.go diff --git a/docs/docs.go b/docs/docs.go index 2bbdaff..da6b6c7 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1,4 +1,5 @@ -// Code generated by swaggo/swag. DO NOT EDIT +// Code generated by swaggo/swag. DO NOT EDIT. + package docs import "github.com/swaggo/swag" @@ -33,35 +34,6 @@ const docTemplate = `{ } } } - }, - "put": { - "description": "Add new course", - "produces": [ - "application/json" - ], - "tags": [ - "course" - ], - "summary": "Add new course", - "parameters": [ - { - "description": "Payload", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/add.AddCourseRequestPayload" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.BaseResponse" - } - } - } } }, "/admin/user": { @@ -480,9 +452,39 @@ const docTemplate = `{ } } }, - "/course/{id}/material": { - "post": { - "description": "Add new material", + "/course": { + "get": { + "description": "Retrieve a list of all available courses.", + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Get all courses", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + }, + "put": { + "description": "Add a new course with the given details", "consumes": [ "application/json" ], @@ -490,52 +492,32 @@ const docTemplate = `{ "application/json" ], "tags": [ - "content" + "course" ], - "summary": "Add Material", + "summary": "Add a new course", "parameters": [ { "type": "string", - "description": "Access token", + "description": "AddCourseToken", "name": "Authorization", "in": "header", "required": true }, { - "description": "Material Request", + "description": "Add Course payload", "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/material.CreateMaterialRequest" + "$ref": "#/definitions/course.AddCourseRequestPayload" } - }, - { - "type": "string", - "example": "IF3230", - "description": "Course id", - "name": "id", - "in": "path", - "required": true } ], "responses": { "200": { - "description": "OK", + "description": "Success", "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.BaseResponse" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/material.CreateMaterialResponse" - } - } - } - ] + "$ref": "#/definitions/web.BaseResponse" } }, "400": { @@ -549,61 +531,61 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/web.BaseResponse" } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } } } } }, - "/course/{id}/materials": { + "/course/faculty": { "get": { - "description": "Get materials", - "consumes": [ - "application/json" - ], + "description": "Retrieves a list of all faculties", "produces": [ "application/json" ], "tags": [ - "content" - ], - "summary": "Get materials", - "parameters": [ - { - "type": "string", - "example": "IF3270", - "description": "Course id", - "name": "id", - "in": "path", - "required": true - } + "course" ], + "summary": "Get all faculties", "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.BaseResponse" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/material.Material" - } - } - } - } - ] + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" } } } - } - }, - "/material/{id}": { - "post": { - "description": "Add content of material", + }, + "put": { + "description": "Adds a new faculty with the given details", "consumes": [ "application/json" ], @@ -611,52 +593,32 @@ const docTemplate = `{ "application/json" ], "tags": [ - "content" + "course" ], - "summary": "Add Content", + "summary": "Add a new faculty", "parameters": [ { "type": "string", - "description": "Access token", + "description": "AddFacultyToken", "name": "Authorization", "in": "header", "required": true }, { - "description": "Add content request", + "description": "Add Faculty payload", "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/material.NewContentRequest" + "$ref": "#/definitions/faculty.AddFacultyRequestPayload" } - }, - { - "type": "string", - "format": "uuid", - "description": "Material id", - "name": "id", - "in": "path", - "required": true } ], "responses": { "200": { - "description": "OK", + "description": "Success", "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.BaseResponse" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/material.NewContentResponse" - } - } - } - ] + "$ref": "#/definitions/web.BaseResponse" } }, "400": { @@ -670,33 +632,42 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/web.BaseResponse" } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } } } - }, - "delete": { - "description": "Delete material", - "consumes": [ - "application/json" - ], + } + }, + "/course/faculty/courses/{id}": { + "get": { + "description": "Retrieve all courses that belong to the faculty with the given ID", "produces": [ "application/json" ], "tags": [ - "content" + "course" ], - "summary": "Delete material", + "summary": "Get all courses by faculty ID", "parameters": [ { "type": "string", - "description": "Access token", - "name": "Authorization", - "in": "header", - "required": true - }, - { - "type": "string", - "format": "uuid", - "description": "Material id", + "description": "Faculty ID (UUID)", "name": "id", "in": "path", "required": true @@ -704,7 +675,25 @@ const docTemplate = `{ ], "responses": { "200": { - "description": "OK", + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Invalid UUID provided in request path", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", "schema": { "$ref": "#/definitions/web.BaseResponse" } @@ -712,25 +701,876 @@ const docTemplate = `{ } } }, - "/material/{id}/content/{content-id}": { - "delete": { - "description": "Delete content of material", - "consumes": [ - "application/json" - ], + "/course/faculty/majors/{id}": { + "get": { + "description": "Returns a list of majors associated with the given faculty ID", "produces": [ "application/json" ], "tags": [ - "content" + "course" ], - "summary": "Delete Content", + "summary": "Get majors by faculty ID", "parameters": [ { "type": "string", - "description": "Access token", - "name": "Authorization", - "in": "header", + "description": "Faculty ID (UUID)", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Invalid UUID provided in request path", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + } + }, + "/course/faculty/{id}": { + "get": { + "description": "Retrieve faculty data by UUID", + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Get faculty by ID", + "parameters": [ + { + "type": "string", + "description": "Faculty ID (UUID)", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Invalid UUID provided in request path", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + }, + "patch": { + "description": "Update a faculty with the given ID", + "tags": [ + "course" + ], + "summary": "Update a faculty", + "parameters": [ + { + "type": "string", + "description": "Faculty ID (UUID)", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Update Faculty Payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/faculty.UpdateFacultyRequestPayload" + } + }, + { + "type": "string", + "description": "UpdateFacultyToken", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + } + }, + "/course/major": { + "get": { + "description": "Get a list of all majors", + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Get all majors", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + }, + "put": { + "description": "Add a new major to a faculty", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Add Major", + "parameters": [ + { + "type": "string", + "description": "AddMajorToken", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "Add Major payload", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/major.AddMajorRequestPayload" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + } + }, + "/course/major/courses/{id}": { + "get": { + "description": "Retrieve all courses related to a major", + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Get courses by major", + "parameters": [ + { + "type": "string", + "description": "Major ID (UUID)", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Invalid UUID provided in request path", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + } + }, + "/course/major/{id}": { + "get": { + "description": "Get a major by ID", + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Get a major by ID", + "parameters": [ + { + "type": "string", + "description": "Major ID (UUID)", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Invalid UUID provided in request path", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + }, + "put": { + "description": "Update a major with the given ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Update a major", + "parameters": [ + { + "type": "string", + "description": "Major ID (UUID)", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "UpdateMajorToken", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "Update Major payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/major.UpdateMajorRequestPayload" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + } + }, + "/course/{id}": { + "get": { + "description": "Retrieve a course by ID", + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Get a course by ID", + "parameters": [ + { + "type": "string", + "description": "ID of the course to retrieve", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + }, + "delete": { + "description": "Delete a course with the specified ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Delete course by ID", + "parameters": [ + { + "type": "string", + "description": "Course ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "DeleteCourseToken", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + }, + "patch": { + "description": "Update an existing course.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Update Course", + "parameters": [ + { + "type": "integer", + "description": "Course ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "UpdateCourseToken", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "Update Course Payload", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/course.UpdateCourseRequestPayload" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + } + }, + "/course/{id}/material": { + "post": { + "description": "Add new material", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "content" + ], + "summary": "Add Material", + "parameters": [ + { + "type": "string", + "description": "Access token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "Material Request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/material.CreateMaterialRequest" + } + }, + { + "type": "string", + "example": "IF3230", + "description": "Course id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/web.BaseResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/material.CreateMaterialResponse" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + } + }, + "/course/{id}/materials": { + "get": { + "description": "Get materials", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "content" + ], + "summary": "Get materials", + "parameters": [ + { + "type": "string", + "example": "IF3270", + "description": "Course id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/web.BaseResponse" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/material.Material" + } + } + } + } + ] + } + } + } + } + }, + "/material/{id}": { + "post": { + "description": "Add content of material", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "content" + ], + "summary": "Add Content", + "parameters": [ + { + "type": "string", + "description": "Access token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "Add content request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/material.NewContentRequest" + } + }, + { + "type": "string", + "format": "uuid", + "description": "Material id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/web.BaseResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/material.NewContentResponse" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + }, + "delete": { + "description": "Delete material", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "content" + ], + "summary": "Delete material", + "parameters": [ + { + "type": "string", + "description": "Access token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "format": "uuid", + "description": "Material id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + } + }, + "/material/{id}/content/{content-id}": { + "delete": { + "description": "Delete content of material", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "content" + ], + "summary": "Delete Content", + "parameters": [ + { + "type": "string", + "description": "Access token", + "name": "Authorization", + "in": "header", "required": true }, { @@ -860,7 +1700,81 @@ const docTemplate = `{ } }, "definitions": { - "add.AddCourseRequestPayload": { + "admin.AdminAddUserPayload": { + "type": "object", + "required": [ + "email", + "name", + "role" + ], + "properties": { + "email": { + "description": "User Email", + "type": "string", + "example": "someone@example.com" + }, + "name": { + "description": "User name", + "type": "string", + "example": "someone" + }, + "role": { + "description": "User Role", + "type": "string", + "example": "admin" + } + } + }, + "admin.AdminUpdateUserPayload": { + "type": "object", + "required": [ + "email", + "name", + "role" + ], + "properties": { + "email": { + "description": "User Email", + "type": "string", + "example": "someone@example.com" + }, + "name": { + "description": "User name", + "type": "string", + "example": "someone" + }, + "role": { + "description": "User Role", + "type": "string", + "example": "admin" + } + } + }, + "confirm.ConfirmRequestPayload": { + "description": "Information that should be available when you confirm a password reset", + "type": "object", + "required": [ + "password", + "password_validation" + ], + "properties": { + "confirmToken": { + "description": "Web Token that was appended to the link", + "type": "string" + }, + "password": { + "description": "User Password", + "type": "string", + "example": "secret" + }, + "password_validation": { + "description": "User Password Validation, must be same as user", + "type": "string", + "example": "secret" + } + } + }, + "course.AddCourseRequestPayload": { "description": "Information that should be available when you add a course", "type": "object", "required": [ @@ -905,77 +1819,100 @@ const docTemplate = `{ } } }, - "admin.AdminAddUserPayload": { + "course.UpdateCourseRequestPayload": { + "description": "Information that should be available when you add a course", "type": "object", "required": [ + "abbreviation", "email", - "name", - "role" + "lecturer", + "name" ], "properties": { + "abbreviation": { + "description": "Course Name Abbreviation", + "type": "string" + }, + "description": { + "description": "Course Description (Can be left empty)", + "type": "string" + }, "email": { - "description": "User Email", + "description": "Contributor Email", "type": "string", "example": "someone@example.com" }, + "id": { + "description": "Course ID, Provided by query", + "type": "string" + }, + "lecturer": { + "description": "Course Lecturer", + "type": "string" + }, + "majabbr": { + "description": "Course Major Abbreviation", + "type": "string" + }, + "major_id": { + "description": "Major Id, will be set by the server", + "type": "string" + }, "name": { - "description": "User name", - "type": "string", - "example": "someone" + "description": "Course Name", + "type": "string" }, - "role": { - "description": "User Role", - "type": "string", - "example": "admin" + "updateCourseToken": { + "description": "Web Token that was appended to the link", + "type": "string" } } }, - "admin.AdminUpdateUserPayload": { + "faculty.AddFacultyRequestPayload": { + "description": "Information that should be available when you add a faculty", "type": "object", "required": [ - "email", - "name", - "role" + "abbreviation", + "name" ], "properties": { - "email": { - "description": "User Email", - "type": "string", - "example": "someone@example.com" + "abbreviation": { + "description": "Faculty Name Abbreviation", + "type": "string" }, - "name": { - "description": "User name", - "type": "string", - "example": "someone" + "faculty_token": { + "description": "Web Token that was appended to the link", + "type": "string" }, - "role": { - "description": "User Role", - "type": "string", - "example": "admin" + "name": { + "description": "Faculty Name", + "type": "string" } } }, - "confirm.ConfirmRequestPayload": { - "description": "Information that should be available when you confirm a password reset", + "faculty.UpdateFacultyRequestPayload": { + "description": "Information that should be available when you update a faculty", "type": "object", "required": [ - "password", - "password_validation" + "abbreviation", + "name" ], "properties": { - "confirmToken": { - "description": "Web Token that was appended to the link", + "abbreviation": { + "description": "Faculty Name Abbreviation", "type": "string" }, - "password": { - "description": "User Password", - "type": "string", - "example": "secret" + "id": { + "description": "Faculty ID, Provided by Query", + "type": "string" }, - "password_validation": { - "description": "User Password Validation, must be same as user", - "type": "string", - "example": "secret" + "name": { + "description": "Faculty Name", + "type": "string" + }, + "updateFacultyToken": { + "description": "Web Token that was appended to the link", + "type": "string" } } }, @@ -1013,6 +1950,70 @@ const docTemplate = `{ } } }, + "major.AddMajorRequestPayload": { + "description": "Information that should be available when you add a major", + "type": "object", + "required": [ + "abbreviation", + "name" + ], + "properties": { + "abbreviation": { + "description": "Major Name Abbreviation", + "type": "string" + }, + "facabbr": { + "description": "Major Faculty Abbreviation", + "type": "string" + }, + "faculty_id": { + "description": "Faculty Id, will be set by the server", + "type": "string" + }, + "major_token": { + "description": "Web Token that was appended to the link", + "type": "string" + }, + "name": { + "description": "Major Name", + "type": "string" + } + } + }, + "major.UpdateMajorRequestPayload": { + "description": "Information that should be available when you update a major", + "type": "object", + "required": [ + "abbreviation", + "name" + ], + "properties": { + "abbreviation": { + "description": "Major Name Abbreviation", + "type": "string" + }, + "facabbr": { + "description": "Major Faculty Abbreviation", + "type": "string" + }, + "faculty_id": { + "description": "Faculty Id, will be set by the server", + "type": "string" + }, + "id": { + "description": "Major ID, provided by query", + "type": "string" + }, + "name": { + "description": "Major Name", + "type": "string" + }, + "updateMajorToken": { + "description": "Web Token that was appended to the link", + "type": "string" + } + } + }, "material.Content": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index 347524a..bd54fa7 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -25,35 +25,6 @@ } } } - }, - "put": { - "description": "Add new course", - "produces": [ - "application/json" - ], - "tags": [ - "course" - ], - "summary": "Add new course", - "parameters": [ - { - "description": "Payload", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/add.AddCourseRequestPayload" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.BaseResponse" - } - } - } } }, "/admin/user": { @@ -472,9 +443,39 @@ } } }, - "/course/{id}/material": { - "post": { - "description": "Add new material", + "/course": { + "get": { + "description": "Retrieve a list of all available courses.", + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Get all courses", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + }, + "put": { + "description": "Add a new course with the given details", "consumes": [ "application/json" ], @@ -482,52 +483,32 @@ "application/json" ], "tags": [ - "content" + "course" ], - "summary": "Add Material", + "summary": "Add a new course", "parameters": [ { "type": "string", - "description": "Access token", + "description": "AddCourseToken", "name": "Authorization", "in": "header", "required": true }, { - "description": "Material Request", + "description": "Add Course payload", "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/material.CreateMaterialRequest" + "$ref": "#/definitions/course.AddCourseRequestPayload" } - }, - { - "type": "string", - "example": "IF3230", - "description": "Course id", - "name": "id", - "in": "path", - "required": true } ], "responses": { "200": { - "description": "OK", + "description": "Success", "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.BaseResponse" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/material.CreateMaterialResponse" - } - } - } - ] + "$ref": "#/definitions/web.BaseResponse" } }, "400": { @@ -541,61 +522,61 @@ "schema": { "$ref": "#/definitions/web.BaseResponse" } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } } } } }, - "/course/{id}/materials": { + "/course/faculty": { "get": { - "description": "Get materials", - "consumes": [ - "application/json" - ], + "description": "Retrieves a list of all faculties", "produces": [ "application/json" ], "tags": [ - "content" - ], - "summary": "Get materials", - "parameters": [ - { - "type": "string", - "example": "IF3270", - "description": "Course id", - "name": "id", - "in": "path", - "required": true - } + "course" ], + "summary": "Get all faculties", "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.BaseResponse" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/material.Material" - } - } - } - } - ] + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" } } } - } - }, - "/material/{id}": { - "post": { - "description": "Add content of material", + }, + "put": { + "description": "Adds a new faculty with the given details", "consumes": [ "application/json" ], @@ -603,52 +584,32 @@ "application/json" ], "tags": [ - "content" + "course" ], - "summary": "Add Content", + "summary": "Add a new faculty", "parameters": [ { "type": "string", - "description": "Access token", + "description": "AddFacultyToken", "name": "Authorization", "in": "header", "required": true }, { - "description": "Add content request", + "description": "Add Faculty payload", "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/material.NewContentRequest" + "$ref": "#/definitions/faculty.AddFacultyRequestPayload" } - }, - { - "type": "string", - "format": "uuid", - "description": "Material id", - "name": "id", - "in": "path", - "required": true } ], "responses": { "200": { - "description": "OK", + "description": "Success", "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.BaseResponse" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/material.NewContentResponse" - } - } - } - ] + "$ref": "#/definitions/web.BaseResponse" } }, "400": { @@ -662,33 +623,42 @@ "schema": { "$ref": "#/definitions/web.BaseResponse" } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } } } - }, - "delete": { - "description": "Delete material", - "consumes": [ - "application/json" - ], + } + }, + "/course/faculty/courses/{id}": { + "get": { + "description": "Retrieve all courses that belong to the faculty with the given ID", "produces": [ "application/json" ], "tags": [ - "content" + "course" ], - "summary": "Delete material", + "summary": "Get all courses by faculty ID", "parameters": [ { "type": "string", - "description": "Access token", - "name": "Authorization", - "in": "header", - "required": true - }, - { - "type": "string", - "format": "uuid", - "description": "Material id", + "description": "Faculty ID (UUID)", "name": "id", "in": "path", "required": true @@ -696,7 +666,25 @@ ], "responses": { "200": { - "description": "OK", + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Invalid UUID provided in request path", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", "schema": { "$ref": "#/definitions/web.BaseResponse" } @@ -704,27 +692,878 @@ } } }, - "/material/{id}/content/{content-id}": { - "delete": { - "description": "Delete content of material", - "consumes": [ - "application/json" - ], + "/course/faculty/majors/{id}": { + "get": { + "description": "Returns a list of majors associated with the given faculty ID", "produces": [ "application/json" ], "tags": [ - "content" + "course" ], - "summary": "Delete Content", + "summary": "Get majors by faculty ID", "parameters": [ { "type": "string", - "description": "Access token", - "name": "Authorization", - "in": "header", + "description": "Faculty ID (UUID)", + "name": "id", + "in": "path", "required": true - }, + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Invalid UUID provided in request path", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + } + }, + "/course/faculty/{id}": { + "get": { + "description": "Retrieve faculty data by UUID", + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Get faculty by ID", + "parameters": [ + { + "type": "string", + "description": "Faculty ID (UUID)", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Invalid UUID provided in request path", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + }, + "patch": { + "description": "Update a faculty with the given ID", + "tags": [ + "course" + ], + "summary": "Update a faculty", + "parameters": [ + { + "type": "string", + "description": "Faculty ID (UUID)", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Update Faculty Payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/faculty.UpdateFacultyRequestPayload" + } + }, + { + "type": "string", + "description": "UpdateFacultyToken", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + } + }, + "/course/major": { + "get": { + "description": "Get a list of all majors", + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Get all majors", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + }, + "put": { + "description": "Add a new major to a faculty", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Add Major", + "parameters": [ + { + "type": "string", + "description": "AddMajorToken", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "Add Major payload", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/major.AddMajorRequestPayload" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + } + }, + "/course/major/courses/{id}": { + "get": { + "description": "Retrieve all courses related to a major", + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Get courses by major", + "parameters": [ + { + "type": "string", + "description": "Major ID (UUID)", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Invalid UUID provided in request path", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + } + }, + "/course/major/{id}": { + "get": { + "description": "Get a major by ID", + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Get a major by ID", + "parameters": [ + { + "type": "string", + "description": "Major ID (UUID)", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Invalid UUID provided in request path", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + }, + "put": { + "description": "Update a major with the given ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Update a major", + "parameters": [ + { + "type": "string", + "description": "Major ID (UUID)", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "UpdateMajorToken", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "Update Major payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/major.UpdateMajorRequestPayload" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + } + }, + "/course/{id}": { + "get": { + "description": "Retrieve a course by ID", + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Get a course by ID", + "parameters": [ + { + "type": "string", + "description": "ID of the course to retrieve", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + }, + "delete": { + "description": "Delete a course with the specified ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Delete course by ID", + "parameters": [ + { + "type": "string", + "description": "Course ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "DeleteCourseToken", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + }, + "patch": { + "description": "Update an existing course.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "course" + ], + "summary": "Update Course", + "parameters": [ + { + "type": "integer", + "description": "Course ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "UpdateCourseToken", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "Update Course Payload", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/course.UpdateCourseRequestPayload" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + } + }, + "/course/{id}/material": { + "post": { + "description": "Add new material", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "content" + ], + "summary": "Add Material", + "parameters": [ + { + "type": "string", + "description": "Access token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "Material Request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/material.CreateMaterialRequest" + } + }, + { + "type": "string", + "example": "IF3230", + "description": "Course id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/web.BaseResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/material.CreateMaterialResponse" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + } + }, + "/course/{id}/materials": { + "get": { + "description": "Get materials", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "content" + ], + "summary": "Get materials", + "parameters": [ + { + "type": "string", + "example": "IF3270", + "description": "Course id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/web.BaseResponse" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/material.Material" + } + } + } + } + ] + } + } + } + } + }, + "/material/{id}": { + "post": { + "description": "Add content of material", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "content" + ], + "summary": "Add Content", + "parameters": [ + { + "type": "string", + "description": "Access token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "Add content request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/material.NewContentRequest" + } + }, + { + "type": "string", + "format": "uuid", + "description": "Material id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/web.BaseResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/material.NewContentResponse" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + }, + "delete": { + "description": "Delete material", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "content" + ], + "summary": "Delete material", + "parameters": [ + { + "type": "string", + "description": "Access token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "format": "uuid", + "description": "Material id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/web.BaseResponse" + } + } + } + } + }, + "/material/{id}/content/{content-id}": { + "delete": { + "description": "Delete content of material", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "content" + ], + "summary": "Delete Content", + "parameters": [ + { + "type": "string", + "description": "Access token", + "name": "Authorization", + "in": "header", + "required": true + }, { "type": "string", "format": "uuid", @@ -852,7 +1691,81 @@ } }, "definitions": { - "add.AddCourseRequestPayload": { + "admin.AdminAddUserPayload": { + "type": "object", + "required": [ + "email", + "name", + "role" + ], + "properties": { + "email": { + "description": "User Email", + "type": "string", + "example": "someone@example.com" + }, + "name": { + "description": "User name", + "type": "string", + "example": "someone" + }, + "role": { + "description": "User Role", + "type": "string", + "example": "admin" + } + } + }, + "admin.AdminUpdateUserPayload": { + "type": "object", + "required": [ + "email", + "name", + "role" + ], + "properties": { + "email": { + "description": "User Email", + "type": "string", + "example": "someone@example.com" + }, + "name": { + "description": "User name", + "type": "string", + "example": "someone" + }, + "role": { + "description": "User Role", + "type": "string", + "example": "admin" + } + } + }, + "confirm.ConfirmRequestPayload": { + "description": "Information that should be available when you confirm a password reset", + "type": "object", + "required": [ + "password", + "password_validation" + ], + "properties": { + "confirmToken": { + "description": "Web Token that was appended to the link", + "type": "string" + }, + "password": { + "description": "User Password", + "type": "string", + "example": "secret" + }, + "password_validation": { + "description": "User Password Validation, must be same as user", + "type": "string", + "example": "secret" + } + } + }, + "course.AddCourseRequestPayload": { "description": "Information that should be available when you add a course", "type": "object", "required": [ @@ -897,77 +1810,100 @@ } } }, - "admin.AdminAddUserPayload": { + "course.UpdateCourseRequestPayload": { + "description": "Information that should be available when you add a course", "type": "object", "required": [ + "abbreviation", "email", - "name", - "role" + "lecturer", + "name" ], "properties": { + "abbreviation": { + "description": "Course Name Abbreviation", + "type": "string" + }, + "description": { + "description": "Course Description (Can be left empty)", + "type": "string" + }, "email": { - "description": "User Email", + "description": "Contributor Email", "type": "string", "example": "someone@example.com" }, + "id": { + "description": "Course ID, Provided by query", + "type": "string" + }, + "lecturer": { + "description": "Course Lecturer", + "type": "string" + }, + "majabbr": { + "description": "Course Major Abbreviation", + "type": "string" + }, + "major_id": { + "description": "Major Id, will be set by the server", + "type": "string" + }, "name": { - "description": "User name", - "type": "string", - "example": "someone" + "description": "Course Name", + "type": "string" }, - "role": { - "description": "User Role", - "type": "string", - "example": "admin" + "updateCourseToken": { + "description": "Web Token that was appended to the link", + "type": "string" } } }, - "admin.AdminUpdateUserPayload": { + "faculty.AddFacultyRequestPayload": { + "description": "Information that should be available when you add a faculty", "type": "object", "required": [ - "email", - "name", - "role" + "abbreviation", + "name" ], "properties": { - "email": { - "description": "User Email", - "type": "string", - "example": "someone@example.com" + "abbreviation": { + "description": "Faculty Name Abbreviation", + "type": "string" }, - "name": { - "description": "User name", - "type": "string", - "example": "someone" + "faculty_token": { + "description": "Web Token that was appended to the link", + "type": "string" }, - "role": { - "description": "User Role", - "type": "string", - "example": "admin" + "name": { + "description": "Faculty Name", + "type": "string" } } }, - "confirm.ConfirmRequestPayload": { - "description": "Information that should be available when you confirm a password reset", + "faculty.UpdateFacultyRequestPayload": { + "description": "Information that should be available when you update a faculty", "type": "object", "required": [ - "password", - "password_validation" + "abbreviation", + "name" ], "properties": { - "confirmToken": { - "description": "Web Token that was appended to the link", + "abbreviation": { + "description": "Faculty Name Abbreviation", "type": "string" }, - "password": { - "description": "User Password", - "type": "string", - "example": "secret" + "id": { + "description": "Faculty ID, Provided by Query", + "type": "string" }, - "password_validation": { - "description": "User Password Validation, must be same as user", - "type": "string", - "example": "secret" + "name": { + "description": "Faculty Name", + "type": "string" + }, + "updateFacultyToken": { + "description": "Web Token that was appended to the link", + "type": "string" } } }, @@ -1005,6 +1941,70 @@ } } }, + "major.AddMajorRequestPayload": { + "description": "Information that should be available when you add a major", + "type": "object", + "required": [ + "abbreviation", + "name" + ], + "properties": { + "abbreviation": { + "description": "Major Name Abbreviation", + "type": "string" + }, + "facabbr": { + "description": "Major Faculty Abbreviation", + "type": "string" + }, + "faculty_id": { + "description": "Faculty Id, will be set by the server", + "type": "string" + }, + "major_token": { + "description": "Web Token that was appended to the link", + "type": "string" + }, + "name": { + "description": "Major Name", + "type": "string" + } + } + }, + "major.UpdateMajorRequestPayload": { + "description": "Information that should be available when you update a major", + "type": "object", + "required": [ + "abbreviation", + "name" + ], + "properties": { + "abbreviation": { + "description": "Major Name Abbreviation", + "type": "string" + }, + "facabbr": { + "description": "Major Faculty Abbreviation", + "type": "string" + }, + "faculty_id": { + "description": "Faculty Id, will be set by the server", + "type": "string" + }, + "id": { + "description": "Major ID, provided by query", + "type": "string" + }, + "name": { + "description": "Major Name", + "type": "string" + }, + "updateMajorToken": { + "description": "Web Token that was appended to the link", + "type": "string" + } + } + }, "material.Content": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 54712e2..0e381a9 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1,38 +1,4 @@ definitions: - add.AddCourseRequestPayload: - description: Information that should be available when you add a course - properties: - abbreviation: - description: Course Name Abbreviation - type: string - addCourseToken: - description: Web Token that was appended to the link - type: string - description: - description: Course Description (Can be left empty) - type: string - email: - description: Contributor Email - example: someone@example.com - type: string - id: - description: Course ID - type: string - majabbr: - description: Course Major Abbreviation - type: string - major_id: - description: Major Id, will be set by the server - type: string - name: - description: Course Name - type: string - required: - - abbreviation - - email - - id - - name - type: object admin.AdminAddUserPayload: properties: email: @@ -90,6 +56,112 @@ definitions: - password - password_validation type: object + course.AddCourseRequestPayload: + description: Information that should be available when you add a course + properties: + abbreviation: + description: Course Name Abbreviation + type: string + addCourseToken: + description: Web Token that was appended to the link + type: string + description: + description: Course Description (Can be left empty) + type: string + email: + description: Contributor Email + example: someone@example.com + type: string + id: + description: Course ID + type: string + majabbr: + description: Course Major Abbreviation + type: string + major_id: + description: Major Id, will be set by the server + type: string + name: + description: Course Name + type: string + required: + - abbreviation + - email + - id + - name + type: object + course.UpdateCourseRequestPayload: + description: Information that should be available when you add a course + properties: + abbreviation: + description: Course Name Abbreviation + type: string + description: + description: Course Description (Can be left empty) + type: string + email: + description: Contributor Email + example: someone@example.com + type: string + id: + description: Course ID, Provided by query + type: string + lecturer: + description: Course Lecturer + type: string + majabbr: + description: Course Major Abbreviation + type: string + major_id: + description: Major Id, will be set by the server + type: string + name: + description: Course Name + type: string + updateCourseToken: + description: Web Token that was appended to the link + type: string + required: + - abbreviation + - email + - lecturer + - name + type: object + faculty.AddFacultyRequestPayload: + description: Information that should be available when you add a faculty + properties: + abbreviation: + description: Faculty Name Abbreviation + type: string + faculty_token: + description: Web Token that was appended to the link + type: string + name: + description: Faculty Name + type: string + required: + - abbreviation + - name + type: object + faculty.UpdateFacultyRequestPayload: + description: Information that should be available when you update a faculty + properties: + abbreviation: + description: Faculty Name Abbreviation + type: string + id: + description: Faculty ID, Provided by Query + type: string + name: + description: Faculty Name + type: string + updateFacultyToken: + description: Web Token that was appended to the link + type: string + required: + - abbreviation + - name + type: object login.LoginRequestPayload: description: Information that should be available when do a login process properties: @@ -115,6 +187,53 @@ definitions: description: Token that used to generate new access token type: string type: object + major.AddMajorRequestPayload: + description: Information that should be available when you add a major + properties: + abbreviation: + description: Major Name Abbreviation + type: string + facabbr: + description: Major Faculty Abbreviation + type: string + faculty_id: + description: Faculty Id, will be set by the server + type: string + major_token: + description: Web Token that was appended to the link + type: string + name: + description: Major Name + type: string + required: + - abbreviation + - name + type: object + major.UpdateMajorRequestPayload: + description: Information that should be available when you update a major + properties: + abbreviation: + description: Major Name Abbreviation + type: string + facabbr: + description: Major Faculty Abbreviation + type: string + faculty_id: + description: Faculty Id, will be set by the server + type: string + id: + description: Major ID, provided by query + type: string + name: + description: Major Name + type: string + updateMajorToken: + description: Web Token that was appended to the link + type: string + required: + - abbreviation + - name + type: object material.Content: properties: id: @@ -267,25 +386,6 @@ paths: summary: Index page tags: - common - put: - description: Add new course - parameters: - - description: Payload - in: body - name: data - required: true - schema: - $ref: '#/definitions/add.AddCourseRequestPayload' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/web.BaseResponse' - summary: Add new course - tags: - - course /admin/user: get: description: Get all users from database @@ -550,41 +650,96 @@ paths: summary: Send Email Verification tags: - auth - /course/{id}/material: - post: + /course: + get: + description: Retrieve a list of all available courses. + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/web.BaseResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/web.BaseResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/web.BaseResponse' + summary: Get all courses + tags: + - course + put: consumes: - application/json - description: Add new material + description: Add a new course with the given details parameters: - - description: Access token + - description: AddCourseToken in: header name: Authorization required: true type: string - - description: Material Request + - description: Add Course payload in: body name: data required: true schema: - $ref: '#/definitions/material.CreateMaterialRequest' - - description: Course id - example: IF3230 + $ref: '#/definitions/course.AddCourseRequestPayload' + produces: + - application/json + responses: + "200": + description: Success + schema: + $ref: '#/definitions/web.BaseResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/web.BaseResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/web.BaseResponse' + "403": + description: Forbidden + schema: + $ref: '#/definitions/web.BaseResponse' + "422": + description: Unprocessable Entity + schema: + $ref: '#/definitions/web.BaseResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/web.BaseResponse' + summary: Add a new course + tags: + - course + /course/{id}: + delete: + consumes: + - application/json + description: Delete a course with the specified ID + parameters: + - description: Course ID in: path name: id required: true type: string + - description: DeleteCourseToken + in: header + name: Authorization + required: true + type: string produces: - application/json responses: "200": - description: OK + description: Success schema: - allOf: - - $ref: '#/definitions/web.BaseResponse' - - properties: - data: - $ref: '#/definitions/material.CreateMaterialResponse' - type: object + $ref: '#/definitions/web.BaseResponse' "400": description: Bad Request schema: @@ -593,17 +748,25 @@ paths: description: Unauthorized schema: $ref: '#/definitions/web.BaseResponse' - summary: Add Material + "403": + description: Forbidden + schema: + $ref: '#/definitions/web.BaseResponse' + "422": + description: Unprocessable Entity + schema: + $ref: '#/definitions/web.BaseResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/web.BaseResponse' + summary: Delete course by ID tags: - - content - /course/{id}/materials: + - course get: - consumes: - - application/json - description: Get materials + description: Retrieve a course by ID parameters: - - description: Course id - example: IF3270 + - description: ID of the course to retrieve in: path name: id required: true @@ -614,10 +777,137 @@ paths: "200": description: OK schema: - allOf: - - $ref: '#/definitions/web.BaseResponse' - - properties: - data: + $ref: '#/definitions/web.BaseResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/web.BaseResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/web.BaseResponse' + summary: Get a course by ID + tags: + - course + patch: + consumes: + - application/json + description: Update an existing course. + parameters: + - description: Course ID + in: path + name: id + required: true + type: integer + - description: UpdateCourseToken + in: header + name: Authorization + required: true + type: string + - description: Update Course Payload + in: body + name: data + required: true + schema: + $ref: '#/definitions/course.UpdateCourseRequestPayload' + produces: + - application/json + responses: + "200": + description: Success + schema: + $ref: '#/definitions/web.BaseResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/web.BaseResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/web.BaseResponse' + "403": + description: Forbidden + schema: + $ref: '#/definitions/web.BaseResponse' + "422": + description: Unprocessable Entity + schema: + $ref: '#/definitions/web.BaseResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/web.BaseResponse' + summary: Update Course + tags: + - course + /course/{id}/material: + post: + consumes: + - application/json + description: Add new material + parameters: + - description: Access token + in: header + name: Authorization + required: true + type: string + - description: Material Request + in: body + name: data + required: true + schema: + $ref: '#/definitions/material.CreateMaterialRequest' + - description: Course id + example: IF3230 + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/web.BaseResponse' + - properties: + data: + $ref: '#/definitions/material.CreateMaterialResponse' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/web.BaseResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/web.BaseResponse' + summary: Add Material + tags: + - content + /course/{id}/materials: + get: + consumes: + - application/json + description: Get materials + parameters: + - description: Course id + example: IF3270 + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/web.BaseResponse' + - properties: + data: items: $ref: '#/definitions/material.Material' type: array @@ -625,6 +915,394 @@ paths: summary: Get materials tags: - content + /course/faculty: + get: + description: Retrieves a list of all faculties + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/web.BaseResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/web.BaseResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/web.BaseResponse' + summary: Get all faculties + tags: + - course + put: + consumes: + - application/json + description: Adds a new faculty with the given details + parameters: + - description: AddFacultyToken + in: header + name: Authorization + required: true + type: string + - description: Add Faculty payload + in: body + name: data + required: true + schema: + $ref: '#/definitions/faculty.AddFacultyRequestPayload' + produces: + - application/json + responses: + "200": + description: Success + schema: + $ref: '#/definitions/web.BaseResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/web.BaseResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/web.BaseResponse' + "403": + description: Forbidden + schema: + $ref: '#/definitions/web.BaseResponse' + "422": + description: Unprocessable Entity + schema: + $ref: '#/definitions/web.BaseResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/web.BaseResponse' + summary: Add a new faculty + tags: + - course + /course/faculty/{id}: + get: + description: Retrieve faculty data by UUID + parameters: + - description: Faculty ID (UUID) + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Success + schema: + $ref: '#/definitions/web.BaseResponse' + "400": + description: Invalid UUID provided in request path + schema: + $ref: '#/definitions/web.BaseResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/web.BaseResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/web.BaseResponse' + summary: Get faculty by ID + tags: + - course + patch: + description: Update a faculty with the given ID + parameters: + - description: Faculty ID (UUID) + in: path + name: id + required: true + type: string + - description: Update Faculty Payload + in: body + name: payload + required: true + schema: + $ref: '#/definitions/faculty.UpdateFacultyRequestPayload' + - description: UpdateFacultyToken + in: header + name: Authorization + required: true + type: string + responses: + "200": + description: Success + schema: + $ref: '#/definitions/web.BaseResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/web.BaseResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/web.BaseResponse' + "403": + description: Forbidden + schema: + $ref: '#/definitions/web.BaseResponse' + "422": + description: Unprocessable Entity + schema: + $ref: '#/definitions/web.BaseResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/web.BaseResponse' + summary: Update a faculty + tags: + - course + /course/faculty/courses/{id}: + get: + description: Retrieve all courses that belong to the faculty with the given + ID + parameters: + - description: Faculty ID (UUID) + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Success + schema: + $ref: '#/definitions/web.BaseResponse' + "400": + description: Invalid UUID provided in request path + schema: + $ref: '#/definitions/web.BaseResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/web.BaseResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/web.BaseResponse' + summary: Get all courses by faculty ID + tags: + - course + /course/faculty/majors/{id}: + get: + description: Returns a list of majors associated with the given faculty ID + parameters: + - description: Faculty ID (UUID) + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Success + schema: + $ref: '#/definitions/web.BaseResponse' + "400": + description: Invalid UUID provided in request path + schema: + $ref: '#/definitions/web.BaseResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/web.BaseResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/web.BaseResponse' + summary: Get majors by faculty ID + tags: + - course + /course/major: + get: + description: Get a list of all majors + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/web.BaseResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/web.BaseResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/web.BaseResponse' + summary: Get all majors + tags: + - course + put: + consumes: + - application/json + description: Add a new major to a faculty + parameters: + - description: AddMajorToken + in: header + name: Authorization + required: true + type: string + - description: Add Major payload + in: body + name: data + required: true + schema: + $ref: '#/definitions/major.AddMajorRequestPayload' + produces: + - application/json + responses: + "200": + description: Success + schema: + $ref: '#/definitions/web.BaseResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/web.BaseResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/web.BaseResponse' + "403": + description: Forbidden + schema: + $ref: '#/definitions/web.BaseResponse' + "422": + description: Unprocessable Entity + schema: + $ref: '#/definitions/web.BaseResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/web.BaseResponse' + summary: Add Major + tags: + - course + /course/major/{id}: + get: + description: Get a major by ID + parameters: + - description: Major ID (UUID) + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Success + schema: + $ref: '#/definitions/web.BaseResponse' + "400": + description: Invalid UUID provided in request path + schema: + $ref: '#/definitions/web.BaseResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/web.BaseResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/web.BaseResponse' + summary: Get a major by ID + tags: + - course + put: + consumes: + - application/json + description: Update a major with the given ID + parameters: + - description: Major ID (UUID) + in: path + name: id + required: true + type: string + - description: UpdateMajorToken + in: header + name: Authorization + required: true + type: string + - description: Update Major payload + in: body + name: payload + required: true + schema: + $ref: '#/definitions/major.UpdateMajorRequestPayload' + produces: + - application/json + responses: + "200": + description: Success + schema: + $ref: '#/definitions/web.BaseResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/web.BaseResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/web.BaseResponse' + "403": + description: Forbidden + schema: + $ref: '#/definitions/web.BaseResponse' + "422": + description: Unprocessable Entity + schema: + $ref: '#/definitions/web.BaseResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/web.BaseResponse' + summary: Update a major + tags: + - course + /course/major/courses/{id}: + get: + description: Retrieve all courses related to a major + parameters: + - description: Major ID (UUID) + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Success + schema: + $ref: '#/definitions/web.BaseResponse' + "400": + description: Invalid UUID provided in request path + schema: + $ref: '#/definitions/web.BaseResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/web.BaseResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/web.BaseResponse' + summary: Get courses by major + tags: + - course /material/{id}: delete: consumes: diff --git a/handler/admin/addUser.go b/handler/admin/addUser.go index 02c631b..71adae1 100644 --- a/handler/admin/addUser.go +++ b/handler/admin/addUser.go @@ -7,14 +7,14 @@ import ( // Index godoc // -// @Tags admin -// @Summary Add User +// @Tags admin +// @Summary Add User // @Description Add a user to database -// @Produce json -// @Accept json -// @Param data body req.AdminAddUserPayload true "Admin Add User Payload" -// @Success 200 {object} web.BaseResponse -// @Router /admin/user [post] +// @Produce json +// @Accept json +// @Param data body req.AdminAddUserPayload true "Admin Add User Payload" +// @Success 200 {object} web.BaseResponse +// @Router /admin/user [post] func (route AdminHandlerImpl) AddUser(w http.ResponseWriter, r *http.Request){ payload := req.AdminAddUserPayload{} diff --git a/handler/admin/deleteUser.go b/handler/admin/deleteUser.go index 9979a47..c9757d2 100644 --- a/handler/admin/deleteUser.go +++ b/handler/admin/deleteUser.go @@ -7,13 +7,13 @@ import ( // Index godoc // -// @Tags admin -// @Summary Delete User By Id +// @Tags admin +// @Summary Delete User By Id // @Description Delete a user from database -// @Produce json -// @Accept json -// @Success 200 {object} web.BaseResponse -// @Router /admin/user/{email} [delete] +// @Produce json +// @Accept json +// @Success 200 {object} web.BaseResponse +// @Router /admin/user/{email} [delete] func (route AdminHandlerImpl) DeleteUser(w http.ResponseWriter, r *http.Request){ email := path.Base(r.URL.Path) diff --git a/handler/admin/getAllUser.go b/handler/admin/getAllUser.go index 32771d8..3173207 100644 --- a/handler/admin/getAllUser.go +++ b/handler/admin/getAllUser.go @@ -6,12 +6,12 @@ import ( // Index godoc // -// @Tags admin -// @Summary Get All User +// @Tags admin +// @Summary Get All User // @Description Get all users from database -// @Produce json -// @Success 200 {object} web.BaseResponse -// @Router /admin/user [get] +// @Produce json +// @Success 200 {object} web.BaseResponse +// @Router /admin/user [get] func (route AdminHandlerImpl) GetAllUser(w http.ResponseWriter, r *http.Request){ // get all user from service users, err := route.AdminService.GetAllUser() diff --git a/handler/admin/getUserByEmail.go b/handler/admin/getUserByEmail.go index fd21301..7326be4 100644 --- a/handler/admin/getUserByEmail.go +++ b/handler/admin/getUserByEmail.go @@ -7,12 +7,12 @@ import ( // Index godoc // -// @Tags admin -// @Summary Get User By Email +// @Tags admin +// @Summary Get User By Email // @Description Get a user from database -// @Produce json -// @Success 200 {object} web.BaseResponse -// @Router /admin/user/{email} [get] +// @Produce json +// @Success 200 {object} web.BaseResponse +// @Router /admin/user/{email} [get] func (route AdminHandlerImpl) GetUserByEmail(w http.ResponseWriter, r *http.Request) { // email := r.URL.Query().Get("email") email := path.Base(r.URL.Path) diff --git a/handler/admin/updateUser.go b/handler/admin/updateUser.go index 877d5c8..a2f91cb 100644 --- a/handler/admin/updateUser.go +++ b/handler/admin/updateUser.go @@ -8,14 +8,14 @@ import ( // Index godoc // -// @Tags admin -// @Summary Update User By Id +// @Tags admin +// @Summary Update User By Id // @Description Update a user from database -// @Produce json -// @Accept json -// @Param data body req.AdminUpdateUserPayload true "Admin Update User Payload" -// @Success 200 {object} web.BaseResponse -// @Router /admin/user/{email} [patch] +// @Produce json +// @Accept json +// @Param data body req.AdminUpdateUserPayload true "Admin Update User Payload" +// @Success 200 {object} web.BaseResponse +// @Router /admin/user/{email} [patch] func (route AdminHandlerImpl) UpdateUser(w http.ResponseWriter, r *http.Request){ email := path.Base(r.URL.Path) // TODO: how to change email diff --git a/handler/auth/login.go b/handler/auth/login.go index 3ab6f07..309db78 100644 --- a/handler/auth/login.go +++ b/handler/auth/login.go @@ -11,19 +11,19 @@ import ( // Index godoc // -// @Tags auth -// @Summary Login -// @Description Login and generate new pair of token -// @Produce json -// @Accept json -// @Param data body login.LoginRequestPayload true "Login payload" -// @Success 200 {object} web.BaseResponse{data=login.LoginResponsePayload} "Login Success" -// @Failure 400 {object} web.BaseResponse{data=[]string} "Bad Input" -// @Failure 403 {object} web.BaseResponse "Login Credential Error" -// @Failure 415 {object} web.BaseResponse "Not a json request" -// @Failure 422 {object} web.BaseResponse "Invalid JSON input" -// @Failure 500 {object} web.BaseResponse "Unknown Internal Error" -// @Router /auth/login [post] +// @Tags auth +// @Summary Login +// @Description Login and generate new pair of token +// @Produce json +// @Accept json +// @Param data body login.LoginRequestPayload true "Login payload" +// @Success 200 {object} web.BaseResponse{data=login.LoginResponsePayload} "Login Success" +// @Failure 400 {object} web.BaseResponse{data=[]string} "Bad Input" +// @Failure 403 {object} web.BaseResponse "Login Credential Error" +// @Failure 415 {object} web.BaseResponse "Not a json request" +// @Failure 422 {object} web.BaseResponse "Invalid JSON input" +// @Failure 500 {object} web.BaseResponse "Unknown Internal Error" +// @Router /auth/login [post] func (a AuthHandlerImpl) Login(w http.ResponseWriter, r *http.Request) { payload := login.LoginRequestPayload{} validate := validator.New() diff --git a/handler/auth/refresh.go b/handler/auth/refresh.go index 20eaed5..78a8a9b 100644 --- a/handler/auth/refresh.go +++ b/handler/auth/refresh.go @@ -11,17 +11,17 @@ import ( // Index godoc // -// @Tags auth -// @Summary Refresh Token -// @Description Generate new access token -// @Produce json -// @Accept json -// @Param Authorization header string true "Refresh token" -// @Success 200 {object} web.BaseResponse{data=refresh.RefreshResponsePayload} -// @Failure 400 {object} web.BaseResponse -// @Failure 401 {object} web.BaseResponse -// @Failure 500 {object} web.BaseResponse -// @Router /auth/refresh [post] +// @Tags auth +// @Summary Refresh Token +// @Description Generate new access token +// @Produce json +// @Accept json +// @Param Authorization header string true "Refresh token" +// @Success 200 {object} web.BaseResponse{data=refresh.RefreshResponsePayload} +// @Failure 400 {object} web.BaseResponse +// @Failure 401 {object} web.BaseResponse +// @Failure 500 {object} web.BaseResponse +// @Router /auth/refresh [post] func (a AuthHandlerImpl) Refresh(w http.ResponseWriter, r *http.Request) { payload := refresh.RefreshRequestPayload{} diff --git a/handler/auth/register.go b/handler/auth/register.go index 8a24f5d..37a50b6 100644 --- a/handler/auth/register.go +++ b/handler/auth/register.go @@ -12,16 +12,16 @@ import ( // Index godoc // -// @Tags auth -// @Summary Register New Account -// @Description Generate New Account as Member -// @Produce json -// @Accept json -// @Param data body register.RegisterRequestPayload true "Register Payload" -// @Success 200 {object} web.BaseResponse -// @Failure 400 {object} web.BaseResponse -// @Failure 500 {object} web.BaseResponse -// @Router /auth/register [post] +// @Tags auth +// @Summary Register New Account +// @Description Generate New Account as Member +// @Produce json +// @Accept json +// @Param data body register.RegisterRequestPayload true "Register Payload" +// @Success 200 {object} web.BaseResponse +// @Failure 400 {object} web.BaseResponse +// @Failure 500 {object} web.BaseResponse +// @Router /auth/register [post] func (a AuthHandlerImpl) Register(w http.ResponseWriter, r *http.Request) { payload := register.RegisterRequestPayload{} validate := validator.New() diff --git a/handler/auth/send_verify.go b/handler/auth/send_verify.go index b2b4a2e..b2b41d0 100644 --- a/handler/auth/send_verify.go +++ b/handler/auth/send_verify.go @@ -11,16 +11,16 @@ import ( // Index godoc // -// @Tags auth -// @Summary Send Email Verification -// @Description Send Email Verification to user -// @Produce json -// @Accept json -// @Param data body verification.VerificationSendRequestPayload true "Register Payload" -// @Success 200 {object} web.BaseResponse -// @Failure 400 {object} web.BaseResponse -// @Failure 500 {object} web.BaseResponse -// @Router /auth/verify/resend [post] +// @Tags auth +// @Summary Send Email Verification +// @Description Send Email Verification to user +// @Produce json +// @Accept json +// @Param data body verification.VerificationSendRequestPayload true "Register Payload" +// @Success 200 {object} web.BaseResponse +// @Failure 400 {object} web.BaseResponse +// @Failure 500 {object} web.BaseResponse +// @Router /auth/verify/resend [post] func (a AuthHandlerImpl) SendEmailVerify(w http.ResponseWriter, r *http.Request) { payload := verification.VerificationSendRequestPayload{} validate := validator.New() diff --git a/handler/auth/verify.go b/handler/auth/verify.go index a118518..1e264a7 100644 --- a/handler/auth/verify.go +++ b/handler/auth/verify.go @@ -11,16 +11,16 @@ import ( // Index godoc // -// @Tags auth -// @Summary Do Email Verification -// @Description Do Email Verification to user -// @Produce json -// @Accept json -// @Param data body verification.VerificationRequestPayload true "Register Payload" -// @Success 200 {object} web.BaseResponse -// @Failure 400 {object} web.BaseResponse -// @Failure 500 {object} web.BaseResponse -// @Router /auth/verify [post] +// @Tags auth +// @Summary Do Email Verification +// @Description Do Email Verification to user +// @Produce json +// @Accept json +// @Param data body verification.VerificationRequestPayload true "Register Payload" +// @Success 200 {object} web.BaseResponse +// @Failure 400 {object} web.BaseResponse +// @Failure 500 {object} web.BaseResponse +// @Router /auth/verify [post] func (a AuthHandlerImpl) EmailVerify(w http.ResponseWriter, r *http.Request) { payload := verification.VerificationRequestPayload{} validate := validator.New() diff --git a/handler/common/home.go b/handler/common/home.go index 7266a95..272eda7 100644 --- a/handler/common/home.go +++ b/handler/common/home.go @@ -6,12 +6,12 @@ import ( // Index godoc // -// @Tags common -// @Summary Index page +// @Tags common +// @Summary Index page // @Description Give server index page response -// @Produce json -// @Success 200 {object} web.BaseResponse -// @Router / [get] +// @Produce json +// @Success 200 {object} web.BaseResponse +// @Router / [get] func (route CommonHandlerImpl) Home(w http.ResponseWriter, r *http.Request) { payload := route.WrapperUtil.SuccessResponseWrap(route.CommonService.Home()) route.HttpUtil.WriteSuccessJson(w, payload) diff --git a/handler/course/addCourse.go b/handler/course/addCourse.go index ebe3d70..4db1e67 100644 --- a/handler/course/addCourse.go +++ b/handler/course/addCourse.go @@ -7,20 +7,27 @@ import ( "github.com/go-playground/validator/v10" "gitlab.informatika.org/ocw/ocw-backend/model/web" - "gitlab.informatika.org/ocw/ocw-backend/model/web/course/add" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course" ) // Index godoc // -// @Tags course -// @Summary Add new course -// @Description Add new course -// @Produce json -// @Param data body add.AddCourseRequestPayload true "Payload" -// @Success 200 {object} web.BaseResponse -// @Router / [put] +// @Summary Add a new course +// @Description Add a new course with the given details +// @Tags course +// @Accept json +// @Produce json +// @Param Authorization header string true "AddCourseToken" +// @Param data body course.AddCourseRequestPayload true "Add Course payload" +// @Success 200 {object} web.BaseResponse "Success" +// @Failure 400 {object} web.BaseResponse "Bad Request" +// @Failure 401 {object} web.BaseResponse "Unauthorized" +// @Failure 403 {object} web.BaseResponse "Forbidden" +// @Failure 422 {object} web.BaseResponse "Unprocessable Entity" +// @Failure 500 {object} web.BaseResponse "Internal Server Error" +// @Router /course [put] func (c CourseHandlerImpl) AddCourse(w http.ResponseWriter, r *http.Request) { - payload := add.AddCourseRequestPayload{} + payload := course.AddCourseRequestPayload{} // Validate payload if r.Header.Get("Content-Type") != "application/json" { diff --git a/handler/course/addFaculty.go b/handler/course/addFaculty.go index a0430da..0226901 100644 --- a/handler/course/addFaculty.go +++ b/handler/course/addFaculty.go @@ -7,11 +7,27 @@ import ( "github.com/go-playground/validator/v10" "gitlab.informatika.org/ocw/ocw-backend/model/web" - "gitlab.informatika.org/ocw/ocw-backend/model/web/course/faculty/add" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course/faculty" ) +// Index godoc +// +// @Summary Add a new faculty +// @Description Adds a new faculty with the given details +// @Tags course +// @Accept json +// @Produce json +// @Param Authorization header string true "AddFacultyToken" +// @Param data body faculty.AddFacultyRequestPayload true "Add Faculty payload" +// @Success 200 {object} web.BaseResponse "Success" +// @Failure 400 {object} web.BaseResponse "Bad Request" +// @Failure 401 {object} web.BaseResponse "Unauthorized" +// @Failure 403 {object} web.BaseResponse "Forbidden" +// @Failure 422 {object} web.BaseResponse "Unprocessable Entity" +// @Failure 500 {object} web.BaseResponse "Internal Server Error" +// @Router /course/faculty [put] func (c CourseHandlerImpl) AddFaculty(w http.ResponseWriter, r *http.Request) { - payload := add.AddFacultyRequestPayload{} + payload := faculty.AddFacultyRequestPayload{} validate := validator.New() // Validate payload diff --git a/handler/course/addMajor.go b/handler/course/addMajor.go index 3f3c3ab..e73fb42 100644 --- a/handler/course/addMajor.go +++ b/handler/course/addMajor.go @@ -7,11 +7,27 @@ import ( "github.com/go-playground/validator/v10" "gitlab.informatika.org/ocw/ocw-backend/model/web" - "gitlab.informatika.org/ocw/ocw-backend/model/web/course/major/add" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course/major" ) +// Index godoc +// +// @Summary Add Major +// @Description Add a new major to a faculty +// @Tags course +// @Accept json +// @Produce json +// @Param Authorization header string true "AddMajorToken" +// @Param data body major.AddMajorRequestPayload true "Add Major payload" +// @Success 200 {object} web.BaseResponse "Success" +// @Failure 400 {object} web.BaseResponse "Bad Request" +// @Failure 401 {object} web.BaseResponse "Unauthorized" +// @Failure 403 {object} web.BaseResponse "Forbidden" +// @Failure 422 {object} web.BaseResponse "Unprocessable Entity" +// @Failure 500 {object} web.BaseResponse "Internal Server Error" +// @Router /course/major [put] func (c CourseHandlerImpl) AddMajor(w http.ResponseWriter, r *http.Request) { - payload := add.AddMajorRequestPayload{} + payload := major.AddMajorRequestPayload{} validate := validator.New() // Validate payload diff --git a/handler/course/deleteCourse.go b/handler/course/deleteCourse.go index a06a7a3..4f419dc 100644 --- a/handler/course/deleteCourse.go +++ b/handler/course/deleteCourse.go @@ -3,14 +3,31 @@ package course import ( "fmt" "net/http" + "path" "strings" "gitlab.informatika.org/ocw/ocw-backend/model/web" - "gitlab.informatika.org/ocw/ocw-backend/model/web/course/delete" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course" ) +// Index godoc +// +// @Summary Delete course by ID +// @Description Delete a course with the specified ID +// @Tags course +// @Accept json +// @Produce json +// @Param id path string true "Course ID" +// @Param Authorization header string true "DeleteCourseToken" +// @Success 200 {object} web.BaseResponse "Success" +// @Failure 400 {object} web.BaseResponse "Bad Request" +// @Failure 401 {object} web.BaseResponse "Unauthorized" +// @Failure 403 {object} web.BaseResponse "Forbidden" +// @Failure 422 {object} web.BaseResponse "Unprocessable Entity" +// @Failure 500 {object} web.BaseResponse "Internal Server Error" +// @Router /course/{id} [delete] func (c CourseHandlerImpl) DeleteCourse(w http.ResponseWriter, r *http.Request) { - payload := delete.DeleteByStringRequestPayload{} + payload := course.DeleteByStringRequestPayload{} validateTokenHeader := r.Header.Get("Authorization") if validateTokenHeader == "" { diff --git a/handler/course/getCourse.go b/handler/course/getCourse.go index 290087f..7f20ae8 100644 --- a/handler/course/getCourse.go +++ b/handler/course/getCourse.go @@ -6,11 +6,22 @@ import ( "path" "gitlab.informatika.org/ocw/ocw-backend/model/web" - "gitlab.informatika.org/ocw/ocw-backend/model/web/course/get" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course" ) +// Index godoc +// +// @Summary Get a course by ID +// @Description Retrieve a course by ID +// @Tags course +// @Produce json +// @Param id path string true "ID of the course to retrieve" +// @Success 200 {object} web.BaseResponse "OK" +// @Failure 401 {object} web.BaseResponse "Unauthorized" +// @Failure 500 {object} web.BaseResponse "Internal Server Error" +// @Router /course/{id} [get] func (c CourseHandlerImpl) GetCourse(w http.ResponseWriter, r *http.Request) { - payload := get.GetByStringRequestPayload{} + payload := course.GetByStringRequestPayload{} payload.ID = path.Base(r.URL.Path) packet, err := c.CourseService.GetCourse(payload) diff --git a/handler/course/getCourses.go b/handler/course/getCourses.go index 9280e47..e22ed91 100644 --- a/handler/course/getCourses.go +++ b/handler/course/getCourses.go @@ -7,6 +7,16 @@ import ( "gitlab.informatika.org/ocw/ocw-backend/model/web" ) +// Index godoc +// +// @Summary Get all courses +// @Description Retrieve a list of all available courses. +// @Tags course +// @Produce json +// @Success 200 {object} web.BaseResponse "OK" +// @Failure 401 {object} web.BaseResponse "Unauthorized" +// @Failure 500 {object} web.BaseResponse "Internal Server Error" +// @Router /course [get] func (c CourseHandlerImpl) GetCourses(w http.ResponseWriter, r *http.Request) { packet, err := c.CourseService.GetAllCourse() diff --git a/handler/course/getCoursesByFaculty.go b/handler/course/getCoursesByFaculty.go index a59f6a8..c708d4e 100644 --- a/handler/course/getCoursesByFaculty.go +++ b/handler/course/getCoursesByFaculty.go @@ -7,11 +7,23 @@ import ( "github.com/google/uuid" "gitlab.informatika.org/ocw/ocw-backend/model/web" - "gitlab.informatika.org/ocw/ocw-backend/model/web/course/get" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course" ) +// Index godoc +// +// @Summary Get all courses by faculty ID +// @Description Retrieve all courses that belong to the faculty with the given ID +// @Tags course +// @Produce json +// @Param id path string true "Faculty ID (UUID)" +// @Success 200 {object} web.BaseResponse "Success" +// @Failure 400 {object} web.BaseResponse "Invalid UUID provided in request path" +// @Failure 401 {object} web.BaseResponse "Unauthorized" +// @Failure 500 {object} web.BaseResponse "Internal Server Error" +// @Router /course/faculty/courses/{id} [get] func (c CourseHandlerImpl) GetCoursesByFaculty(w http.ResponseWriter, r *http.Request) { - payload := get.GetByUUIDRequestPayload{} + payload := course.GetByUUIDRequestPayload{} id, err := uuid.Parse(path.Base(r.URL.Path)) if err != nil { diff --git a/handler/course/getCoursesByMajor.go b/handler/course/getCoursesByMajor.go index 3f84138..5bfeadb 100644 --- a/handler/course/getCoursesByMajor.go +++ b/handler/course/getCoursesByMajor.go @@ -7,11 +7,23 @@ import ( "github.com/google/uuid" "gitlab.informatika.org/ocw/ocw-backend/model/web" - "gitlab.informatika.org/ocw/ocw-backend/model/web/course/get" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course" ) +// Index godoc +// +// @Summary Get courses by major +// @Description Retrieve all courses related to a major +// @Tags course +// @Produce json +// @Param id path string true "Major ID (UUID)" +// @Success 200 {object} web.BaseResponse "Success" +// @Failure 400 {object} web.BaseResponse "Invalid UUID provided in request path" +// @Failure 401 {object} web.BaseResponse "Unauthorized" +// @Failure 500 {object} web.BaseResponse "Internal Server Error" +// @Router /course/major/courses/{id} [get] func (c CourseHandlerImpl) GetCoursesByMajor(w http.ResponseWriter, r *http.Request) { - payload := get.GetByUUIDRequestPayload{} + payload := course.GetByUUIDRequestPayload{} id, err := uuid.Parse(path.Base(r.URL.Path)) if err != nil { diff --git a/handler/course/getFaculties.go b/handler/course/getFaculties.go index 65473e5..d51c809 100644 --- a/handler/course/getFaculties.go +++ b/handler/course/getFaculties.go @@ -6,7 +6,16 @@ import ( "gitlab.informatika.org/ocw/ocw-backend/model/web" ) - +// Index godoc +// +// @Summary Get all faculties +// @Description Retrieves a list of all faculties +// @Tags course +// @Produce json +// @Success 200 {object} web.BaseResponse "OK" +// @Failure 401 {object} web.BaseResponse "Unauthorized" +// @Failure 500 {object} web.BaseResponse "Internal Server Error" +// @Router /course/faculty [get] func (c CourseHandlerImpl) GetFaculties(w http.ResponseWriter, r *http.Request) { packet, err := c.CourseService.GetAllFaculty() diff --git a/handler/course/getFaculty.go b/handler/course/getFaculty.go index e50d77b..494d3c0 100644 --- a/handler/course/getFaculty.go +++ b/handler/course/getFaculty.go @@ -7,11 +7,23 @@ import ( "github.com/google/uuid" "gitlab.informatika.org/ocw/ocw-backend/model/web" - "gitlab.informatika.org/ocw/ocw-backend/model/web/course/get" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course" ) +// Index godoc +// +// @Summary Get faculty by ID +// @Description Retrieve faculty data by UUID +// @Tags course +// @Produce json +// @Param id path string true "Faculty ID (UUID)" +// @Success 200 {object} web.BaseResponse "Success" +// @Failure 400 {object} web.BaseResponse "Invalid UUID provided in request path" +// @Failure 401 {object} web.BaseResponse "Unauthorized" +// @Failure 500 {object} web.BaseResponse "Internal Server Error" +// @Router /course/faculty/{id} [get] func (c CourseHandlerImpl) GetFaculty(w http.ResponseWriter, r *http.Request) { - payload := get.GetByUUIDRequestPayload{} + payload := course.GetByUUIDRequestPayload{} id, err := uuid.Parse(path.Base(r.URL.Path)) if err != nil { diff --git a/handler/course/getMajor.go b/handler/course/getMajor.go index 8413ce7..fe3a495 100644 --- a/handler/course/getMajor.go +++ b/handler/course/getMajor.go @@ -7,11 +7,23 @@ import ( "github.com/google/uuid" "gitlab.informatika.org/ocw/ocw-backend/model/web" - "gitlab.informatika.org/ocw/ocw-backend/model/web/course/get" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course" ) +// Index godoc +// +// @Summary Get a major by ID +// @Description Get a major by ID +// @Tags course +// @Produce json +// @Param id path string true "Major ID (UUID)" +// @Success 200 {object} web.BaseResponse "Success" +// @Failure 400 {object} web.BaseResponse "Invalid UUID provided in request path" +// @Failure 401 {object} web.BaseResponse "Unauthorized" +// @Failure 500 {object} web.BaseResponse "Internal Server Error" +// @Router /course/major/{id} [get] func (c CourseHandlerImpl) GetMajor(w http.ResponseWriter, r *http.Request) { - payload := get.GetByUUIDRequestPayload{} + payload := course.GetByUUIDRequestPayload{} id, err := uuid.Parse(path.Base(r.URL.Path)) if err != nil { diff --git a/handler/course/getMajors.go b/handler/course/getMajors.go index 05466ce..cdb9d01 100644 --- a/handler/course/getMajors.go +++ b/handler/course/getMajors.go @@ -7,6 +7,16 @@ import ( "gitlab.informatika.org/ocw/ocw-backend/model/web" ) +// Index godoc +// +// @Summary Get all majors +// @Description Get a list of all majors +// @Tags course +// @Produce json +// @Success 200 {object} web.BaseResponse "OK" +// @Failure 401 {object} web.BaseResponse "Unauthorized" +// @Failure 500 {object} web.BaseResponse "Internal Server Error" +// @Router /course/major [get] func (c CourseHandlerImpl) GetMajors(w http.ResponseWriter, r *http.Request) { packet, err := c.CourseService.GetAllMajor() diff --git a/handler/course/getMajorsByFaculty.go b/handler/course/getMajorsByFaculty.go index abdedb8..9eafc3d 100644 --- a/handler/course/getMajorsByFaculty.go +++ b/handler/course/getMajorsByFaculty.go @@ -7,11 +7,22 @@ import ( "github.com/google/uuid" "gitlab.informatika.org/ocw/ocw-backend/model/web" - "gitlab.informatika.org/ocw/ocw-backend/model/web/course/get" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course" ) - +// Index godoc +// +// @Summary Get majors by faculty ID +// @Description Returns a list of majors associated with the given faculty ID +// @Tags course +// @Produce json +// @Param id path string true "Faculty ID (UUID)" +// @Success 200 {object} web.BaseResponse "Success" +// @Failure 400 {object} web.BaseResponse "Invalid UUID provided in request path" +// @Failure 401 {object} web.BaseResponse "Unauthorized" +// @Failure 500 {object} web.BaseResponse "Internal Server Error" +// @Router /course/faculty/majors/{id} [get] func (c CourseHandlerImpl) GetMajorsByFaculty(w http.ResponseWriter, r *http.Request) { - payload := get.GetByUUIDRequestPayload{} + payload := course.GetByUUIDRequestPayload{} id, err := uuid.Parse(path.Base(r.URL.Path)) if err != nil { diff --git a/handler/course/updateCourse.go b/handler/course/updateCourse.go index 8825ac1..4e2ded6 100644 --- a/handler/course/updateCourse.go +++ b/handler/course/updateCourse.go @@ -8,11 +8,28 @@ import ( "github.com/go-chi/chi/v5" "github.com/go-playground/validator/v10" "gitlab.informatika.org/ocw/ocw-backend/model/web" - "gitlab.informatika.org/ocw/ocw-backend/model/web/course/update" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course" ) +// Index godoc +// +// @Summary Update Course +// @Description Update an existing course. +// @Tags course +// @Accept json +// @Produce json +// @Param id path int true "Course ID" +// @Param Authorization header string true "UpdateCourseToken" +// @Param data body course.UpdateCourseRequestPayload true "Update Course Payload" +// @Success 200 {object} web.BaseResponse "Success" +// @Failure 400 {object} web.BaseResponse "Bad Request" +// @Failure 401 {object} web.BaseResponse "Unauthorized" +// @Failure 403 {object} web.BaseResponse "Forbidden" +// @Failure 422 {object} web.BaseResponse "Unprocessable Entity" +// @Failure 500 {object} web.BaseResponse "Internal Server Error" +// @Router /course/{id} [patch] func (c CourseHandlerImpl) UpdateCourse(w http.ResponseWriter, r *http.Request) { - payload := update.UpdateCourseRequestPayload{} + payload := course.UpdateCourseRequestPayload{} validate := validator.New() // Validate payload diff --git a/handler/course/updateFaculty.go b/handler/course/updateFaculty.go index afa885a..c27eca0 100644 --- a/handler/course/updateFaculty.go +++ b/handler/course/updateFaculty.go @@ -9,11 +9,26 @@ import ( "github.com/go-playground/validator/v10" "github.com/google/uuid" "gitlab.informatika.org/ocw/ocw-backend/model/web" - "gitlab.informatika.org/ocw/ocw-backend/model/web/course/faculty/update" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course/faculty" ) +// Index godoc +// +// @Summary Update a faculty +// @Description Update a faculty with the given ID +// @Tags course +// @Param id path string true "Faculty ID (UUID)" +// @Param payload body faculty.UpdateFacultyRequestPayload true "Update Faculty Payload" +// @Param Authorization header string true "UpdateFacultyToken" +// @Success 200 {object} web.BaseResponse "Success" +// @Failure 400 {object} web.BaseResponse "Bad Request" +// @Failure 401 {object} web.BaseResponse "Unauthorized" +// @Failure 403 {object} web.BaseResponse "Forbidden" +// @Failure 422 {object} web.BaseResponse "Unprocessable Entity" +// @Failure 500 {object} web.BaseResponse "Internal Server Error" +// @Router /course/faculty/{id} [patch] func (c CourseHandlerImpl) UpdateFaculty(w http.ResponseWriter, r *http.Request) { - payload := update.UpdateFacultyRequestPayload{} + payload := faculty.UpdateFacultyRequestPayload{} validate := validator.New() // Validate payload diff --git a/handler/course/updateMajor.go b/handler/course/updateMajor.go index a77bf94..ec80257 100644 --- a/handler/course/updateMajor.go +++ b/handler/course/updateMajor.go @@ -9,11 +9,25 @@ import ( "github.com/go-playground/validator/v10" "github.com/google/uuid" "gitlab.informatika.org/ocw/ocw-backend/model/web" - "gitlab.informatika.org/ocw/ocw-backend/model/web/course/major/update" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course/major" ) - +// @Summary Update a major +// @Description Update a major with the given ID +// @Tags course +// @Accept json +// @Produce json +// @Param id path string true "Major ID (UUID)" +// @Param Authorization header string true "UpdateMajorToken" +// @Param payload body major.UpdateMajorRequestPayload true "Update Major payload" +// @Success 200 {object} web.BaseResponse "Success" +// @Failure 400 {object} web.BaseResponse "Bad Request" +// @Failure 401 {object} web.BaseResponse "Unauthorized" +// @Failure 403 {object} web.BaseResponse "Forbidden" +// @Failure 422 {object} web.BaseResponse "Unprocessable Entity" +// @Failure 500 {object} web.BaseResponse "Internal Server Error" +// @Router /course/major/{id} [put] func (c CourseHandlerImpl) UpdateMajor(w http.ResponseWriter, r *http.Request) { - payload := update.UpdateMajorRequestPayload{} + payload := major.UpdateMajorRequestPayload{} validate := validator.New() // Validate payload diff --git a/handler/material/add_content.go b/handler/material/add_content.go index 4c8ab78..1f5511f 100644 --- a/handler/material/add_content.go +++ b/handler/material/add_content.go @@ -15,18 +15,18 @@ import ( // Index godoc // -// @Tags content -// @Summary Add Content +// @Tags content +// @Summary Add Content // @Description Add content of material -// @Produce json -// @Accept json -// @Param Authorization header string true "Access token" -// @Param data body material.NewContentRequest true "Add content request" -// @Param id path string true "Material id" Format(uuid) -// @Success 200 {object} web.BaseResponse{data=material.NewContentResponse} -// @Success 400 {object} web.BaseResponse -// @Success 401 {object} web.BaseResponse -// @Router /material/{id} [post] +// @Produce json +// @Accept json +// @Param Authorization header string true "Access token" +// @Param data body material.NewContentRequest true "Add content request" +// @Param id path string true "Material id" Format(uuid) +// @Success 200 {object} web.BaseResponse{data=material.NewContentResponse} +// @Success 400 {object} web.BaseResponse +// @Success 401 {object} web.BaseResponse +// @Router /material/{id} [post] func (m MaterialHandlerImpl) AddContent(w http.ResponseWriter, r *http.Request) { payload := material.NewContentRequest{} user, ok := r.Context().Value(guard.UserContext).(authToken.UserClaim) diff --git a/handler/material/create_material.go b/handler/material/create_material.go index 0c19f25..5556556 100644 --- a/handler/material/create_material.go +++ b/handler/material/create_material.go @@ -13,18 +13,18 @@ import ( // Index godoc // -// @Tags content -// @Summary Add Material +// @Tags content +// @Summary Add Material // @Description Add new material -// @Produce json -// @Accept json -// @Param Authorization header string true "Access token" -// @Param data body material.CreateMaterialRequest true "Material Request" -// @Param id path string true "Course id" example(IF3230) -// @Success 200 {object} web.BaseResponse{data=material.CreateMaterialResponse} -// @Success 400 {object} web.BaseResponse -// @Success 401 {object} web.BaseResponse -// @Router /course/{id}/material [post] +// @Produce json +// @Accept json +// @Param Authorization header string true "Access token" +// @Param data body material.CreateMaterialRequest true "Material Request" +// @Param id path string true "Course id" example(IF3230) +// @Success 200 {object} web.BaseResponse{data=material.CreateMaterialResponse} +// @Success 400 {object} web.BaseResponse +// @Success 401 {object} web.BaseResponse +// @Router /course/{id}/material [post] func (m MaterialHandlerImpl) CreateMaterial(w http.ResponseWriter, r *http.Request) { payload := material.CreateMaterialRequest{} courseId := chi.URLParam(r, "id") diff --git a/handler/material/delete_content.go b/handler/material/delete_content.go index e747539..f67bcc3 100644 --- a/handler/material/delete_content.go +++ b/handler/material/delete_content.go @@ -12,16 +12,16 @@ import ( // Index godoc // -// @Tags content -// @Summary Delete Content +// @Tags content +// @Summary Delete Content // @Description Delete content of material -// @Produce json -// @Accept json -// @Param Authorization header string true "Access token" -// @Param id path string true "Material id" Format(uuid) -// @Param content-id path string true "Content id" Format(uuid) -// @Success 200 {object} web.BaseResponse -// @Router /material/{id}/content/{content-id} [delete] +// @Produce json +// @Accept json +// @Param Authorization header string true "Access token" +// @Param id path string true "Material id" Format(uuid) +// @Param content-id path string true "Content id" Format(uuid) +// @Success 200 {object} web.BaseResponse +// @Router /material/{id}/content/{content-id} [delete] func (m MaterialHandlerImpl) DeleteContent(w http.ResponseWriter, r *http.Request) { materialIdUnparsed := chi.URLParam(r, "material-id") diff --git a/handler/material/delete_material.go b/handler/material/delete_material.go index 8f03fba..1bd275c 100644 --- a/handler/material/delete_material.go +++ b/handler/material/delete_material.go @@ -12,15 +12,15 @@ import ( // Index godoc // -// @Tags content -// @Summary Delete material +// @Tags content +// @Summary Delete material // @Description Delete material -// @Produce json -// @Accept json -// @Param Authorization header string true "Access token" -// @Param id path string true "Material id" Format(uuid) -// @Success 200 {object} web.BaseResponse -// @Router /material/{id} [delete] +// @Produce json +// @Accept json +// @Param Authorization header string true "Access token" +// @Param id path string true "Material id" Format(uuid) +// @Success 200 {object} web.BaseResponse +// @Router /material/{id} [delete] func (m MaterialHandlerImpl) DeleteMaterial(w http.ResponseWriter, r *http.Request) { materialIdUnparsed := chi.URLParam(r, "material-id") diff --git a/handler/material/get_material.go b/handler/material/get_material.go index b4b56e0..bc1009f 100644 --- a/handler/material/get_material.go +++ b/handler/material/get_material.go @@ -9,14 +9,14 @@ import ( // Index godoc // -// @Tags content -// @Summary Get materials +// @Tags content +// @Summary Get materials // @Description Get materials -// @Produce json -// @Accept json -// @Param id path string true "Course id" example(IF3270) -// @Success 200 {object} web.BaseResponse{data=[]material.Material} -// @Router /course/{id}/materials [get] +// @Produce json +// @Accept json +// @Param id path string true "Course id" example(IF3270) +// @Success 200 {object} web.BaseResponse{data=[]material.Material} +// @Router /course/{id}/materials [get] func (m MaterialHandlerImpl) GetMaterial(w http.ResponseWriter, r *http.Request) { courseId := chi.URLParam(r, "id") diff --git a/handler/reset/confirm.go b/handler/reset/confirm.go index da94201..24e5b09 100644 --- a/handler/reset/confirm.go +++ b/handler/reset/confirm.go @@ -12,14 +12,14 @@ import ( // Index godoc // -// @Tags reset -// @Summary Confirm Reset Password +// @Tags reset +// @Summary Confirm Reset Password // @Description Do confirmation to reset password -// @Produce json -// @Param Authorization header string true "Email validation token" -// @Param data body confirm.ConfirmRequestPayload true "payload" -// @Success 200 {object} web.BaseResponse "Login Success" -// @Router /reset/confirm [put] +// @Produce json +// @Param Authorization header string true "Email validation token" +// @Param data body confirm.ConfirmRequestPayload true "payload" +// @Success 200 {object} web.BaseResponse "Login Success" +// @Router /reset/confirm [put] func (rs ResetHandlerImpl) Confirm(w http.ResponseWriter, r *http.Request) { payload := confirm.ConfirmRequestPayload{} validate := validator.New() diff --git a/handler/reset/request.go b/handler/reset/request.go index e118a02..ecdea1b 100644 --- a/handler/reset/request.go +++ b/handler/reset/request.go @@ -12,13 +12,13 @@ import ( // Index godoc // -// @Tags reset -// @Summary Request Reset Password Token +// @Tags reset +// @Summary Request Reset Password Token // @Description Send Reset password token to email -// @Produce json -// @Param data body request.RequestRequestPayload true "payload" -// @Success 200 {object} web.BaseResponse "Login Success" -// @Router /reset/request [post] +// @Produce json +// @Param data body request.RequestRequestPayload true "payload" +// @Success 200 {object} web.BaseResponse "Login Success" +// @Router /reset/request [post] func (rs ResetHandlerImpl) Request(w http.ResponseWriter, r *http.Request) { payload := request.RequestRequestPayload{} validate := validator.New() diff --git a/handler/reset/validate.go b/handler/reset/validate.go index 1bfa4de..84be1fb 100644 --- a/handler/reset/validate.go +++ b/handler/reset/validate.go @@ -11,13 +11,13 @@ import ( // Index godoc // -// @Tags reset -// @Summary Request Reset Password Token +// @Tags reset +// @Summary Request Reset Password Token // @Description Send Reset password token to email -// @Produce json -// @Param Authorization header string true "Email validation token" -// @Success 200 {object} web.BaseResponse "Login Success" -// @Router /reset/validate [get] +// @Produce json +// @Param Authorization header string true "Email validation token" +// @Success 200 {object} web.BaseResponse "Login Success" +// @Router /reset/validate [get] func (rs ResetHandlerImpl) Validate(w http.ResponseWriter, r *http.Request) { payload := validate.ValidateRequestPayload{} validateTokenHeader := r.Header.Get("Authorization") diff --git a/main.go b/main.go index 3510a8d..bfd1104 100644 --- a/main.go +++ b/main.go @@ -1,8 +1,8 @@ package main -// @title Open Courseware Application -// @version 1.0.1 -// @description This is Open Couseware backend +// @title Open Courseware Application +// @version 1.0.1 +// @description This is Open Couseware backend func main() { server, err := CreateServer() diff --git a/model/web/admin/addUser/request.go b/model/web/admin/addUser/request.go index c08f743..d1166ee 100644 --- a/model/web/admin/addUser/request.go +++ b/model/web/admin/addUser/request.go @@ -1,7 +1,7 @@ package admin // AdminAddUserPayload Request Payload -// @Description Information that should be available when admin add user +// @Description Information that should be available when admin add user // TODO: find a way to make default password for new user diff --git a/model/web/admin/updateUser/request.go b/model/web/admin/updateUser/request.go index 437d35f..de60152 100644 --- a/model/web/admin/updateUser/request.go +++ b/model/web/admin/updateUser/request.go @@ -1,7 +1,7 @@ package admin // AdminUpdateUserPayload Request Payload -// @Description Information that should be available when admin update user +// @Description Information that should be available when admin update user type AdminUpdateUserPayload struct { // User name diff --git a/model/web/auth/login/request.go b/model/web/auth/login/request.go index 716c505..a5b9fa5 100644 --- a/model/web/auth/login/request.go +++ b/model/web/auth/login/request.go @@ -1,7 +1,7 @@ package login // Login Request Payload -// @Description Information that should be available when do a login process +// @Description Information that should be available when do a login process type LoginRequestPayload struct { // User Email Email string `json:"email" validate:"required,email" example:"someone@example.com"` diff --git a/model/web/auth/login/response.go b/model/web/auth/login/response.go index 8cb68ca..c961e2e 100644 --- a/model/web/auth/login/response.go +++ b/model/web/auth/login/response.go @@ -1,7 +1,7 @@ package login // Login Response Payload -// @Description Login response when process success +// @Description Login response when process success type LoginResponsePayload struct { // Token that used to generate new access token RefreshToken string `json:"refresh_token"` diff --git a/model/web/auth/refresh/response.go b/model/web/auth/refresh/response.go index f349ba6..80e3516 100644 --- a/model/web/auth/refresh/response.go +++ b/model/web/auth/refresh/response.go @@ -1,7 +1,7 @@ package refresh // Refresh Response Payload -// @Description Refresh endpoint response when process success +// @Description Refresh endpoint response when process success type RefreshResponsePayload struct { // Token that used to access the resources AccessToken string `json:"access_token"` diff --git a/model/web/auth/register/request.go b/model/web/auth/register/request.go index 48d5810..7a8a7d1 100644 --- a/model/web/auth/register/request.go +++ b/model/web/auth/register/request.go @@ -1,7 +1,7 @@ package register // Register Request Payload -// @Description Information that should be available when do a registration process +// @Description Information that should be available when do a registration process type RegisterRequestPayload struct { // User Email Email string `json:"email" validate:"required,email" example:"someone@example.com"` diff --git a/model/web/auth/verification/request.go b/model/web/auth/verification/request.go index dfddab4..cd408e9 100644 --- a/model/web/auth/verification/request.go +++ b/model/web/auth/verification/request.go @@ -1,7 +1,7 @@ package verification // Email Verification Request Payload -// @Description Information that should be passed when request verify +// @Description Information that should be passed when request verify type VerificationSendRequestPayload struct { // User Email Email string `json:"email" validate:"required,email" example:"someone@example.com"` diff --git a/model/web/course/add/request.go b/model/web/course/add/request.go deleted file mode 100644 index 0b86f3a..0000000 --- a/model/web/course/add/request.go +++ /dev/null @@ -1,31 +0,0 @@ -package add - -import "github.com/google/uuid" - -// AddCourse Request Payload -// @Description Information that should be available when you add a course -type AddCourseRequestPayload struct { - // Web Token that was appended to the link - AddCourseToken string - - // Course ID - ID string `json:"id" validate:"required"` - - // Course Name - Name string `json:"name" validate:"required"` - - // Course Major Abbreviation - MajAbbr string `json:"majabbr" validate:"required_without=MajorID"` - - // Major Id, will be set by the server - MajorID uuid.UUID `json:"major_id"` - - // Course Description (Can be left empty) - Description string `json:"description"` - - // Contributor Email - Email string `json:"email" validate:"required,email" example:"someone@example.com"` - - // Course Name Abbreviation - Abbreviation string `json:"abbreviation" validate:"required"` -} diff --git a/model/web/course/delete/request.go b/model/web/course/delete/request.go deleted file mode 100644 index fdfcdbc..0000000 --- a/model/web/course/delete/request.go +++ /dev/null @@ -1,11 +0,0 @@ -package delete - -// DeleteCourse Request Payload -// @Description Information that should be available when you delete using course id (string) -type DeleteByStringRequestPayload struct { - // Web Token that was appended to the link - DeleteCourseToken string - - // Course ID, provided by query - ID string -} diff --git a/model/web/course/faculty/add/request.go b/model/web/course/faculty/add/request.go deleted file mode 100644 index 166404a..0000000 --- a/model/web/course/faculty/add/request.go +++ /dev/null @@ -1,14 +0,0 @@ -package add - -// AddFaculty Request Payload -// @Description Information that should be available when you add a faculty -type AddFacultyRequestPayload struct { - // Web Token that was appended to the link - AddFacultyToken string `json:"faculty_token"` - - // Faculty Name - Name string `json:"name" validate:"required"` - - // Faculty Name Abbreviation - Abbreviation string `json:"abbreviation" validate:"required"` -} diff --git a/model/web/course/faculty/request.go b/model/web/course/faculty/request.go new file mode 100644 index 0000000..1c08bdd --- /dev/null +++ b/model/web/course/faculty/request.go @@ -0,0 +1,32 @@ +package faculty + +import "github.com/google/uuid" + +// AddFaculty Request Payload +// @Description Information that should be available when you add a faculty +type AddFacultyRequestPayload struct { + // Web Token that was appended to the link + AddFacultyToken string `json:"faculty_token"` + + // Faculty Name + Name string `json:"name" validate:"required"` + + // Faculty Name Abbreviation + Abbreviation string `json:"abbreviation" validate:"required"` +} + +// UpdateFaculty Request Payload +// @Description Information that should be available when you update a faculty +type UpdateFacultyRequestPayload struct { + // Web Token that was appended to the link + UpdateFacultyToken string + + // Faculty ID, Provided by Query + ID uuid.UUID + + // Faculty Name + Name string `json:"name" validate:"required"` + + // Faculty Name Abbreviation + Abbreviation string `json:"abbreviation" validate:"required"` +} \ No newline at end of file diff --git a/model/web/course/faculty/update/request.go b/model/web/course/faculty/update/request.go deleted file mode 100644 index 38f0486..0000000 --- a/model/web/course/faculty/update/request.go +++ /dev/null @@ -1,19 +0,0 @@ -package update - -import "github.com/google/uuid" - -// UpdateFaculty Request Payload -// @Description Information that should be available when you update a faculty -type UpdateFacultyRequestPayload struct { - // Web Token that was appended to the link - UpdateFacultyToken string - - // Faculty ID, Provided by Query - ID uuid.UUID - - // Faculty Name - Name string `json:"name" validate:"required"` - - // Faculty Name Abbreviation - Abbreviation string `json:"abbreviation" validate:"required"` -} diff --git a/model/web/course/get/request.go b/model/web/course/get/request.go deleted file mode 100644 index 7f1853e..0000000 --- a/model/web/course/get/request.go +++ /dev/null @@ -1,17 +0,0 @@ -package get - -import "github.com/google/uuid" - -// GetCourse Request Payload -// @Description Information that should be available when you get using course id (string) -type GetByStringRequestPayload struct { - // Course ID, provided by query - ID string -} - -// GetCourse Request Payload -// @Description Information that should be available when you get using major/faculty id (string) -type GetByUUIDRequestPayload struct { - // Major/Faculty ID, provided by query - ID uuid.UUID -} \ No newline at end of file diff --git a/model/web/course/major/add/request.go b/model/web/course/major/add/request.go deleted file mode 100644 index f7eafd0..0000000 --- a/model/web/course/major/add/request.go +++ /dev/null @@ -1,22 +0,0 @@ -package add - -import "github.com/google/uuid" - -// AddMajor Request Payload -// @Description Information that should be available when you add a major -type AddMajorRequestPayload struct { - // Web Token that was appended to the link - AddMajorToken string `json:"major_token"` - - // Major Name - Name string `json:"name" validate:"required"` - - // Major Faculty Abbreviation - FacAbbr string `json:"facabbr" validate:"required_without=FacultyID"` - - // Faculty Id, will be set by the server - FacultyID uuid.UUID `json:"faculty_id"` - - // Major Name Abbreviation - Abbreviation string `json:"abbreviation" validate:"required"` -} diff --git a/model/web/course/major/request.go b/model/web/course/major/request.go new file mode 100644 index 0000000..53bc733 --- /dev/null +++ b/model/web/course/major/request.go @@ -0,0 +1,45 @@ +package major + +import "github.com/google/uuid" + +// AddMajor Request Payload +// @Description Information that should be available when you add a major +type AddMajorRequestPayload struct { + // Web Token that was appended to the link + AddMajorToken string `json:"major_token"` + + // Major Name + Name string `json:"name" validate:"required"` + + // Major Faculty Abbreviation + FacAbbr string `json:"facabbr" validate:"required_without=FacultyID"` + + // Faculty Id, will be set by the server + FacultyID uuid.UUID `json:"faculty_id"` + + // Major Name Abbreviation + Abbreviation string `json:"abbreviation" validate:"required"` +} + + +// UpdateMajor Request Payload +// @Description Information that should be available when you update a major +type UpdateMajorRequestPayload struct { + // Web Token that was appended to the link + UpdateMajorToken string + + // Major ID, provided by query + ID uuid.UUID + + // Major Name + Name string `json:"name" validate:"required"` + + // Major Faculty Abbreviation + FacAbbr string `json:"facabbr" validate:"required_without=FacultyID"` + + // Faculty Id, will be set by the server + FacultyID uuid.UUID `json:"faculty_id"` + + // Major Name Abbreviation + Abbreviation string `json:"abbreviation" validate:"required"` +} diff --git a/model/web/course/major/update/request.go b/model/web/course/major/update/request.go deleted file mode 100644 index b024427..0000000 --- a/model/web/course/major/update/request.go +++ /dev/null @@ -1,25 +0,0 @@ -package update - -import "github.com/google/uuid" - -// UpdateMajor Request Payload -// @Description Information that should be available when you update a major -type UpdateMajorRequestPayload struct { - // Web Token that was appended to the link - UpdateMajorToken string - - // Major ID, provided by query - ID uuid.UUID - - // Major Name - Name string `json:"name" validate:"required"` - - // Major Faculty Abbreviation - FacAbbr string `json:"facabbr" validate:"required_without=FacultyID"` - - // Faculty Id, will be set by the server - FacultyID uuid.UUID `json:"faculty_id"` - - // Major Name Abbreviation - Abbreviation string `json:"abbreviation" validate:"required"` -} diff --git a/model/web/course/request.go b/model/web/course/request.go new file mode 100644 index 0000000..0fad2be --- /dev/null +++ b/model/web/course/request.go @@ -0,0 +1,89 @@ +package course + +import "github.com/google/uuid" + +// AddCourse Request Payload +// @Description Information that should be available when you add a course +type AddCourseRequestPayload struct { + // Web Token that was appended to the link + AddCourseToken string + + // Course ID + ID string `json:"id" validate:"required"` + + // Course Name + Name string `json:"name" validate:"required"` + + // Course Major Abbreviation + MajAbbr string `json:"majabbr" validate:"required_without=MajorID"` + + // Major Id, will be set by the server + MajorID uuid.UUID `json:"major_id"` + + // Course Description (Can be left empty) + Description string `json:"description"` + + // Contributor Email + Email string `json:"email" validate:"required,email" example:"someone@example.com"` + + // Course Name Abbreviation + Abbreviation string `json:"abbreviation" validate:"required"` +} + +// DeleteCourse Request Payload +// @Description Information that should be available when you delete using course id (string) +type DeleteByStringRequestPayload struct { + // Web Token that was appended to the link + DeleteCourseToken string + + // Course ID, provided by query + ID string +} + + +// GetID Request Payload +// @Description Information that should be available when you get using course id (string) +type GetByStringRequestPayload struct { + // Course ID, provided by query + ID string +} + +// GetUUID Request Payload +// @Description Information that should be available when you get using major/faculty id (string) +type GetByUUIDRequestPayload struct { + // Major/Faculty ID, provided by query + ID uuid.UUID +} + +// UpdateCourse Request Payload +// @Description Information that should be available when you add a course +type UpdateCourseRequestPayload struct { + // Web Token that was appended to the link + UpdateCourseToken string + + // Course ID, Provided by query + ID string `json:"id"` + + // Course Name + Name string `json:"name" validate:"required"` + + // Course Major Abbreviation + MajAbbr string `json:"majabbr" validate:"required_without=MajorID"` + + // Major Id, will be set by the server + MajorID uuid.UUID `json:"major_id"` + + // Course Description (Can be left empty) + Description string `json:"description"` + + // Contributor Email + Email string `json:"email" validate:"required,email" example:"someone@example.com"` + + // Course Name Abbreviation + Abbreviation string `json:"abbreviation" validate:"required"` + + // Course Lecturer + Lecturer string `json:"lecturer" validate:"required"` +} + + diff --git a/model/web/course/update/request.go b/model/web/course/update/request.go deleted file mode 100644 index f914cec..0000000 --- a/model/web/course/update/request.go +++ /dev/null @@ -1,34 +0,0 @@ -package update - -import "github.com/google/uuid" - -// UpdateCourse Request Payload -// @Description Information that should be available when you add a course -type UpdateCourseRequestPayload struct { - // Web Token that was appended to the link - UpdateCourseToken string - - // Course ID, Provided by query - ID string `json:"id"` - - // Course Name - Name string `json:"name" validate:"required"` - - // Course Major Abbreviation - MajAbbr string `json:"majabbr" validate:"required_without=MajorID"` - - // Major Id, will be set by the server - MajorID uuid.UUID `json:"major_id"` - - // Course Description (Can be left empty) - Description string `json:"description"` - - // Contributor Email - Email string `json:"email" validate:"required,email" example:"someone@example.com"` - - // Course Name Abbreviation - Abbreviation string `json:"abbreviation" validate:"required"` - - // Course Lecturer - Lecturer string `json:"lecturer" validate:"required"` -} diff --git a/model/web/reset/confirm/request.go b/model/web/reset/confirm/request.go index 6d864a3..78e16a1 100644 --- a/model/web/reset/confirm/request.go +++ b/model/web/reset/confirm/request.go @@ -1,7 +1,7 @@ package confirm // Confirm Request Payload -// @Description Information that should be available when you confirm a password reset +// @Description Information that should be available when you confirm a password reset type ConfirmRequestPayload struct { // Web Token that was appended to the link ConfirmToken string diff --git a/model/web/reset/request/request.go b/model/web/reset/request/request.go index cdd5d15..c589cce 100644 --- a/model/web/reset/request/request.go +++ b/model/web/reset/request/request.go @@ -1,7 +1,7 @@ package request // Request Request Payload -// @Description Information that should be available when password reset is requested +// @Description Information that should be available when password reset is requested type RequestRequestPayload struct { // User Email Email string `json:"email" validate:"required,email" example:"someone@example.com"` diff --git a/model/web/reset/validate/request.go b/model/web/reset/validate/request.go index f13973a..72f9499 100644 --- a/model/web/reset/validate/request.go +++ b/model/web/reset/validate/request.go @@ -1,7 +1,7 @@ package validate // Validate Request Payload -// @Description Information that should be available when link validation is done +// @Description Information that should be available when link validation is done type ValidateRequestPayload struct { // Web Token that was appended to the link ValidateToken string diff --git a/routes/course/route.go b/routes/course/route.go index ccafadb..23cb9f5 100644 --- a/routes/course/route.go +++ b/routes/course/route.go @@ -16,7 +16,6 @@ type CourseRoutes struct { func (c CourseRoutes) Register(r chi.Router) { r.Route("/course", func(r chi.Router) { - // Get r.Get("/", c.CourseHandler.GetCourses) r.Get("/{id}", c.CourseHandler.GetCourse) r.Get("/faculty", c.CourseHandler.GetFaculties) @@ -26,18 +25,12 @@ func (c CourseRoutes) Register(r chi.Router) { r.Get("/major", c.CourseHandler.GetMajors) r.Get("/major/{id}", c.CourseHandler.GetMajor) r.Get("/major/courses/{id}", c.CourseHandler.GetCoursesByMajor) - - // Add r.Put("/", c.CourseHandler.AddCourse) r.Put("/faculty", c.CourseHandler.AddFaculty) r.Put("/major", c.CourseHandler.AddMajor) - - // Update r.Patch("/{id}", c.CourseHandler.UpdateCourse) r.Patch("/faculty/{id}", c.CourseHandler.UpdateFaculty) r.Patch("/major/{id}", c.CourseHandler.UpdateMajor) - - // Delete r.Delete("/{id}", c.CourseHandler.DeleteCourse) r.Get("/{id}/materials", c.MaterialHandler.GetMaterial) }) diff --git a/service/course/add.go b/service/course/add.go index d4e4378..dc42d56 100644 --- a/service/course/add.go +++ b/service/course/add.go @@ -4,17 +4,17 @@ import ( "errors" "github.com/google/uuid" - "gitlab.informatika.org/ocw/ocw-backend/model/domain/course" + domCourse "gitlab.informatika.org/ocw/ocw-backend/model/domain/course" "gitlab.informatika.org/ocw/ocw-backend/model/domain/user" "gitlab.informatika.org/ocw/ocw-backend/model/web" "gitlab.informatika.org/ocw/ocw-backend/model/web/auth/token" - cadd "gitlab.informatika.org/ocw/ocw-backend/model/web/course/add" - fadd "gitlab.informatika.org/ocw/ocw-backend/model/web/course/faculty/add" - madd "gitlab.informatika.org/ocw/ocw-backend/model/web/course/major/add" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course/faculty" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course/major" "gorm.io/gorm" ) -func (c CourseServiceImpl) AddCourse(payload cadd.AddCourseRequestPayload) error { +func (c CourseServiceImpl) AddCourse(payload course.AddCourseRequestPayload) error { // Validate Role claim, err := c.TokenUtil.Validate(payload.AddCourseToken, token.Access) @@ -54,7 +54,7 @@ func (c CourseServiceImpl) AddCourse(payload cadd.AddCourseRequestPayload) error return web.NewResponseError("Course ID Already Exists", web.IDExists) } - err = c.CourseRepository.AddCourse(course.Course{ + err = c.CourseRepository.AddCourse(domCourse.Course{ ID: payload.ID, Name: payload.Name, Major_id: payload.MajorID, @@ -71,7 +71,7 @@ func (c CourseServiceImpl) AddCourse(payload cadd.AddCourseRequestPayload) error return nil } -func (c CourseServiceImpl) AddMajor(payload madd.AddMajorRequestPayload) error { +func (c CourseServiceImpl) AddMajor(payload major.AddMajorRequestPayload) error { // Validate Role claim, err := c.TokenUtil.Validate(payload.AddMajorToken, token.Access) @@ -106,7 +106,7 @@ func (c CourseServiceImpl) AddMajor(payload madd.AddMajorRequestPayload) error { return err } - err = c.CourseRepository.AddMajor(course.Major{ + err = c.CourseRepository.AddMajor(domCourse.Major{ ID: id, Name: payload.Name, Fac_id: payload.FacultyID, @@ -121,7 +121,7 @@ func (c CourseServiceImpl) AddMajor(payload madd.AddMajorRequestPayload) error { return nil } -func (c CourseServiceImpl) AddFaculty(payload fadd.AddFacultyRequestPayload) error { +func (c CourseServiceImpl) AddFaculty(payload faculty.AddFacultyRequestPayload) error { // Validate Role claim, err := c.TokenUtil.Validate(payload.AddFacultyToken, token.Access) @@ -141,7 +141,7 @@ func (c CourseServiceImpl) AddFaculty(payload fadd.AddFacultyRequestPayload) err return err } - err = c.CourseRepository.AddFaculty(course.Faculty{ + err = c.CourseRepository.AddFaculty(domCourse.Faculty{ ID: id, Name: payload.Name, Abbreviation: payload.Abbreviation, diff --git a/service/course/delete.go b/service/course/delete.go index a8bda5b..92b73e2 100644 --- a/service/course/delete.go +++ b/service/course/delete.go @@ -4,12 +4,10 @@ import ( "gitlab.informatika.org/ocw/ocw-backend/model/domain/user" "gitlab.informatika.org/ocw/ocw-backend/model/web" "gitlab.informatika.org/ocw/ocw-backend/model/web/auth/token" - "gitlab.informatika.org/ocw/ocw-backend/model/web/course/delete" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course" ) -// TODO: Authorization Checks - -func (c CourseServiceImpl) DeleteCourse(payload delete.DeleteByStringRequestPayload) error { +func (c CourseServiceImpl) DeleteCourse(payload course.DeleteByStringRequestPayload) error { // Validate Role claim, err := c.TokenUtil.Validate(payload.DeleteCourseToken, token.Access) diff --git a/service/course/get.go b/service/course/get.go index 001217d..3745ea3 100644 --- a/service/course/get.go +++ b/service/course/get.go @@ -3,13 +3,13 @@ package course import ( "errors" - "gitlab.informatika.org/ocw/ocw-backend/model/domain/course" + domCourse "gitlab.informatika.org/ocw/ocw-backend/model/domain/course" "gitlab.informatika.org/ocw/ocw-backend/model/web" - "gitlab.informatika.org/ocw/ocw-backend/model/web/course/get" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course" "gorm.io/gorm" ) -func (c CourseServiceImpl) GetCourse(payload get.GetByStringRequestPayload) (*course.Course, error) { +func (c CourseServiceImpl) GetCourse(payload course.GetByStringRequestPayload) (*domCourse.Course, error) { packet, err := c.CourseRepository.GetCourse(payload.ID) if err != nil { @@ -23,7 +23,7 @@ func (c CourseServiceImpl) GetCourse(payload get.GetByStringRequestPayload) (*co return packet, nil } -func (c CourseServiceImpl) GetMajor(payload get.GetByUUIDRequestPayload) (*course.Major, error) { +func (c CourseServiceImpl) GetMajor(payload course.GetByUUIDRequestPayload) (*domCourse.Major, error) { packet, err := c.CourseRepository.GetMajor(payload.ID) if err != nil { @@ -37,7 +37,7 @@ func (c CourseServiceImpl) GetMajor(payload get.GetByUUIDRequestPayload) (*cours return packet, nil } -func (c CourseServiceImpl) GetFaculty(payload get.GetByUUIDRequestPayload) (*course.Faculty, error) { +func (c CourseServiceImpl) GetFaculty(payload course.GetByUUIDRequestPayload) (*domCourse.Faculty, error) { packet, err := c.CourseRepository.GetFaculty(payload.ID) if err != nil { @@ -51,7 +51,7 @@ func (c CourseServiceImpl) GetFaculty(payload get.GetByUUIDRequestPayload) (*cou return packet, nil } -func (c CourseServiceImpl) GetAllCourse() ([]course.Course, error) { +func (c CourseServiceImpl) GetAllCourse() ([]domCourse.Course, error) { packet, err := c.CourseRepository.GetAllCourse() if err != nil { @@ -65,7 +65,7 @@ func (c CourseServiceImpl) GetAllCourse() ([]course.Course, error) { return packet, nil } -func (c CourseServiceImpl) GetAllMajor() ([]course.Major, error) { +func (c CourseServiceImpl) GetAllMajor() ([]domCourse.Major, error) { packet, err := c.CourseRepository.GetAllMajor() if err != nil { @@ -79,7 +79,7 @@ func (c CourseServiceImpl) GetAllMajor() ([]course.Major, error) { return packet, nil } -func (c CourseServiceImpl) GetAllFaculty() ([]course.Faculty, error) { +func (c CourseServiceImpl) GetAllFaculty() ([]domCourse.Faculty, error) { packet, err := c.CourseRepository.GetAllFaculty() if err != nil { @@ -94,7 +94,7 @@ func (c CourseServiceImpl) GetAllFaculty() ([]course.Faculty, error) { return packet, nil } -func (c CourseServiceImpl) GetAllCourseByMajor(payload get.GetByUUIDRequestPayload) ([]course.Course, error) { +func (c CourseServiceImpl) GetAllCourseByMajor(payload course.GetByUUIDRequestPayload) ([]domCourse.Course, error) { packet, err := c.CourseRepository.GetAllCourseByMajor(payload.ID) if err != nil { @@ -108,7 +108,7 @@ func (c CourseServiceImpl) GetAllCourseByMajor(payload get.GetByUUIDRequestPaylo return packet, nil } -func (c CourseServiceImpl) GetAllCourseByFaculty(payload get.GetByUUIDRequestPayload) ([]course.Course, error) { +func (c CourseServiceImpl) GetAllCourseByFaculty(payload course.GetByUUIDRequestPayload) ([]domCourse.Course, error) { packet, err := c.CourseRepository.GetAllCourseByFaculty(payload.ID) if err != nil { @@ -122,7 +122,7 @@ func (c CourseServiceImpl) GetAllCourseByFaculty(payload get.GetByUUIDRequestPay return packet, nil } -func (c CourseServiceImpl) GetAllMajorByFaculty(payload get.GetByUUIDRequestPayload) ([]course.Major, error) { +func (c CourseServiceImpl) GetAllMajorByFaculty(payload course.GetByUUIDRequestPayload) ([]domCourse.Major, error) { packet, err := c.CourseRepository.GetAllMajorByFaculty(payload.ID) if err != nil { diff --git a/service/course/type.go b/service/course/type.go index 33f4550..0fbc7ec 100644 --- a/service/course/type.go +++ b/service/course/type.go @@ -1,33 +1,28 @@ package course import ( - "gitlab.informatika.org/ocw/ocw-backend/model/domain/course" - "gitlab.informatika.org/ocw/ocw-backend/model/web/course/get" - "gitlab.informatika.org/ocw/ocw-backend/model/web/course/delete" - cadd "gitlab.informatika.org/ocw/ocw-backend/model/web/course/add" - madd "gitlab.informatika.org/ocw/ocw-backend/model/web/course/major/add" - fadd "gitlab.informatika.org/ocw/ocw-backend/model/web/course/faculty/add" - cupdate "gitlab.informatika.org/ocw/ocw-backend/model/web/course/update" - mupdate "gitlab.informatika.org/ocw/ocw-backend/model/web/course/major/update" - fupdate "gitlab.informatika.org/ocw/ocw-backend/model/web/course/faculty/update" + domCourse "gitlab.informatika.org/ocw/ocw-backend/model/domain/course" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course/major" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course/faculty" ) type CourseService interface { - AddCourse(payload cadd.AddCourseRequestPayload) error - AddMajor(payload madd.AddMajorRequestPayload) error - AddFaculty(payload fadd.AddFacultyRequestPayload) error - GetCourse(payload get.GetByStringRequestPayload) (*course.Course, error) - GetMajor(payload get.GetByUUIDRequestPayload) (*course.Major, error) - GetFaculty(payload get.GetByUUIDRequestPayload) (*course.Faculty, error) - GetAllCourse() ([]course.Course, error) - GetAllMajor() ([]course.Major, error) - GetAllFaculty() ([]course.Faculty, error) - GetAllCourseByMajor(payload get.GetByUUIDRequestPayload) ([]course.Course, error) - GetAllCourseByFaculty(payload get.GetByUUIDRequestPayload) ([]course.Course, error) - GetAllMajorByFaculty(payload get.GetByUUIDRequestPayload) ([]course.Major, error) - UpdateCourse(payload cupdate.UpdateCourseRequestPayload) error - UpdateMajor(payload mupdate.UpdateMajorRequestPayload) error - UpdateFaculty(payload fupdate.UpdateFacultyRequestPayload) error - DeleteCourse(payload delete.DeleteByStringRequestPayload) error + AddCourse(payload course.AddCourseRequestPayload) error + AddMajor(payload major.AddMajorRequestPayload) error + AddFaculty(payload faculty.AddFacultyRequestPayload) error + GetCourse(payload course.GetByStringRequestPayload) (*domCourse.Course, error) + GetMajor(payload course.GetByUUIDRequestPayload) (*domCourse.Major, error) + GetFaculty(payload course.GetByUUIDRequestPayload) (*domCourse.Faculty, error) + GetAllCourse() ([]domCourse.Course, error) + GetAllMajor() ([]domCourse.Major, error) + GetAllFaculty() ([]domCourse.Faculty, error) + GetAllCourseByMajor(payload course.GetByUUIDRequestPayload) ([]domCourse.Course, error) + GetAllCourseByFaculty(payload course.GetByUUIDRequestPayload) ([]domCourse.Course, error) + GetAllMajorByFaculty(payload course.GetByUUIDRequestPayload) ([]domCourse.Major, error) + UpdateCourse(payload course.UpdateCourseRequestPayload) error + UpdateMajor(payload major.UpdateMajorRequestPayload) error + UpdateFaculty(payload faculty.UpdateFacultyRequestPayload) error + DeleteCourse(payload course.DeleteByStringRequestPayload) error } diff --git a/service/course/update.go b/service/course/update.go index a08d0b3..76df6c2 100644 --- a/service/course/update.go +++ b/service/course/update.go @@ -3,19 +3,19 @@ package course import ( "errors" - "gitlab.informatika.org/ocw/ocw-backend/model/domain/course" + domCourse "gitlab.informatika.org/ocw/ocw-backend/model/domain/course" "gitlab.informatika.org/ocw/ocw-backend/model/domain/user" "gitlab.informatika.org/ocw/ocw-backend/model/web" "gitlab.informatika.org/ocw/ocw-backend/model/web/auth/token" - fupdate "gitlab.informatika.org/ocw/ocw-backend/model/web/course/faculty/update" - mupdate "gitlab.informatika.org/ocw/ocw-backend/model/web/course/major/update" - cupdate "gitlab.informatika.org/ocw/ocw-backend/model/web/course/update" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course/faculty" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course/major" + "gitlab.informatika.org/ocw/ocw-backend/model/web/course" "gorm.io/gorm" ) // TODO: Authorization Checks -func (c CourseServiceImpl) UpdateCourse(payload cupdate.UpdateCourseRequestPayload) error { +func (c CourseServiceImpl) UpdateCourse(payload course.UpdateCourseRequestPayload) error { // Validate Role claim, err := c.TokenUtil.Validate(payload.UpdateCourseToken, token.Access) @@ -44,7 +44,7 @@ func (c CourseServiceImpl) UpdateCourse(payload cupdate.UpdateCourseRequestPaylo payload.MajorID = major.ID } - err = c.CourseRepository.UpdateCourse(course.Course{ + err = c.CourseRepository.UpdateCourse(domCourse.Course{ ID: payload.ID, Name: payload.Name, Major_id: payload.MajorID, @@ -65,7 +65,7 @@ func (c CourseServiceImpl) UpdateCourse(payload cupdate.UpdateCourseRequestPaylo return nil } -func (c CourseServiceImpl) UpdateMajor(payload mupdate.UpdateMajorRequestPayload) error { +func (c CourseServiceImpl) UpdateMajor(payload major.UpdateMajorRequestPayload) error { // Validate Role claim, err := c.TokenUtil.Validate(payload.UpdateMajorToken, token.Access) @@ -95,7 +95,7 @@ func (c CourseServiceImpl) UpdateMajor(payload mupdate.UpdateMajorRequestPayload payload.FacultyID = faculty.ID } - err = c.CourseRepository.UpdateMajor(course.Major{ + err = c.CourseRepository.UpdateMajor(domCourse.Major{ ID: payload.ID, Name: payload.Name, Fac_id: payload.FacultyID, @@ -113,7 +113,7 @@ func (c CourseServiceImpl) UpdateMajor(payload mupdate.UpdateMajorRequestPayload return nil } -func (c CourseServiceImpl) UpdateFaculty(payload fupdate.UpdateFacultyRequestPayload) error { +func (c CourseServiceImpl) UpdateFaculty(payload faculty.UpdateFacultyRequestPayload) error { // Validate Role claim, err := c.TokenUtil.Validate(payload.UpdateFacultyToken, token.Access) @@ -127,7 +127,7 @@ func (c CourseServiceImpl) UpdateFaculty(payload fupdate.UpdateFacultyRequestPay return web.NewResponseErrorFromError(err, web.UnauthorizedAccess) } - err = c.CourseRepository.UpdateFaculty(course.Faculty{ + err = c.CourseRepository.UpdateFaculty(domCourse.Faculty{ ID: payload.ID, Name: payload.Name, Abbreviation: payload.Abbreviation, -- GitLab