diff --git a/docs/docs.go b/docs/docs.go index 2bbdaff8e1a5b157ee32e364f8fc3b8f0cdd7ecf..da6b6c74c66925ee7179c4fc60eded6029337fe3 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 347524a7ed0d12d203491c11bb782fd25477e17f..bd54fa79acde64283132c228ee6d12d8201c84b3 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 54712e298fb607ef19d713de3f948d5e9ce255de..0e381a980569f74f97153c28a3f8273611fd7fd8 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 02c631be6d59ed66f628b57dfa4ace8191b05249..71adae1097c94697a7666f4798f3ea65abfb43fb 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 9979a47a2279814f9de6c9302c3a555531a659aa..c9757d2d663584b0e675a1a27f3c4bc89a445a3f 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 32771d8d99fcf9d82f53279bd70706a35d30f1b7..31732077a1ef80d9745efb59dc2891a95e0c0366 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 fd21301db325bf6d59eb8df4404f352ba4fd2b29..7326be4653cd8fc165d60e49b24c152e14e4ea97 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 877d5c84a3785626e9736ecf1d433d37fdf1df40..a2f91cbd93fb181c23983e9aae3b1ef9d89293e1 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 3ab6f0759cde01fa545c1299fb1d2f9b056afafa..309db782e4547e931c301bf4a4dd5a452aeb37a6 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 20eaed5d8803d078beed923cf0855b9bc394f438..78a8a9b03f7386b7830f20fc30725e50e39b67d7 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 8a24f5da071967f00ddcea7e973bd6a46230fa1b..37a50b67dc97cdb86f925e54ff07439629a35571 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 b2b4a2e70eaca89ac5de5f26a76fb4210d894416..b2b41d0473dcdd91c72840c20e903ac635fce7b3 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 a118518f67d6d8e4dff329541d93d406f545cbca..1e264a7cb810bad925d579dc67df080987961244 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 7266a95ec32bcbccd657df123bb8fad5e0ef689a..272eda7d2f19bce70362e0de12c23c749323b23f 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 ebe3d703a68bc143f720be2dbb8d6cd22405c9f1..4db1e673301c5b16d6de69ee20de09df593af416 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 a0430da8c4541a971771b86ef0d8cd3a1a002927..02269011fae0b1eb68de8ed75d52037dc02704df 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 3f3c3ab0faaf177ab6fc12a1da902dac2b8d7ad8..e73fb420cc51a7b8efe71b666a741e909b14cc8b 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 a06a7a3e41c72742cb6bda478ecb34def0791056..4f419dcbc9ccc7ac0ad761e298dbfa5ccbafe83b 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 290087fda55ac0219d3ad037f5c3a38415453056..7f20ae8af1d132fd515b2a6507ba54a8948cbc04 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 9280e47c7d96abd7f12d5188cc1c11c6ce927bab..e22ed91542d2442ffae6b580aba3505bec8b857a 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 a59f6a82342b6f3989c4f7b95585c4e59f1b7ff1..c708d4ecaf0984319d1d7a945b15622ceeefa2ea 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 3f8413871825b2bcc11ad1579f3c82d56b294f58..5bfeadbbd47bd56fdab00cf9ef1b3ce4ad168601 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 65473e5b47aa33f10c47f696dd4dd974896773d2..d51c8090ad70355bd0c3c9b0903c57c8bb10dde7 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 e50d77b17d5ec0482e1b96ee3a9901dc7b58b43b..494d3c0aeeb91699c6c62c92fc12d3f3a807b1a5 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 8413ce7f474dc9a6e4259ea3a65fed1ee770cd02..fe3a4952790af76aee0ccf74423146390963dddb 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 05466ce40e6e430b284a0e98f905fd0c14fe3869..cdb9d01fc3abd37c2faab0f53e02c69cc00adc5b 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 abdedb8b72337808f4f092806784ddcf3bdefd5b..9eafc3d088a810f5879c27b2b20d7e21da995d3e 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 8825ac1452c8b256edc79d9237c24a677ec71359..4e2ded686a6281dd2e6baebd5b8868fdcf92c150 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 afa885a71061ff033fa5e3615cc85b215cd5c384..c27eca05f9aff3ab7f3d50984e0760a69e67d3b8 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 a77bf944a731f684b288fb5c52201fa339ec4f93..ec802574680fb8f046bae1b7bb2e11031a41f282 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 4c8ab785092385bbfe8a17c750fdb715edd9d57a..1f5511f2e9ddc83640d3429d67128fdbc6a23ff1 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 0c19f25596b9d60fa158dd9dd5981c4632b6a1de..55565566908a318265a647ba142e3047d875a003 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 e7475399e30439489365fabb048bcf0837a97ca7..f67bcc3aec47601aeaec8dbfacfc4e3c79285095 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 8f03fba29e225be9ef5954945a4dcf525ebe422c..1bd275c35e0d690045f67f9b61b5f4f5cc705e92 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 b4b56e07691ce5a96294c380a93b6404eee0bb2a..bc1009f92b06b087eeee36b8806257a5f5af0558 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 da9420190d78f8c5938860b8bfca3e9375c90c16..24e5b0934e4e5eb06a639bd63bca7b1946b162c4 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 e118a0261b97d7bd0dbec2cde86644293d786313..ecdea1bf67e9eb60eb729760ca15ea4538e130e0 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 1bfa4dec36c2c1f3f2d2ff94110c80070906c3db..84be1fb797e3217866538dce680306f72bbf8dbb 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 3510a8d8544bff0deb21be27d74fdfeabec819cd..bfd1104b3b07646a97ee856600db25c929e34255 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 c08f743abc16843b3c0ca60c3725ac24d348db05..d1166ee9bdbcf0b870f7452c317c1fa295592c36 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 437d35fa7e7f5f415fea0ab49ec84f09c246ff7e..de60152fab122e1d48b48a172096c5d7a0db334c 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 716c505d9eb29cfcaf8a55c7561d4885fb1f2e7c..a5b9fa5000728b8884fdcc9c6118c7876739f480 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 8cb68ca68d2c5491b090dba2f96240d9d6f143af..c961e2e24673721959fc1999c8210ad10d45399b 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 f349ba6e3e2d9b70ad0fd08680d046e1a6ad9ba8..80e35164afd41fd54b1d02902a72ed1872e57232 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 48d58105956364d445c27ea82129f2d0c27581eb..7a8a7d1394b5c151c4926fdc6e3795d9e1464fd5 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 dfddab4ba7adb0585a2147daa85ecfbfce77b25e..cd408e92fdd61b01d43fd857cfecbeefd314a006 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 0b86f3ab6618ef4ec1f7f299b0fd45c81bfb61dc..0000000000000000000000000000000000000000 --- 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 fdfcdbc2809b1e2ad428cae959569dc84703b6d3..0000000000000000000000000000000000000000 --- 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 166404aeabe25478c70deaddedbffff5845199a1..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..1c08bddf6fc2410cc7bdec8542c9edc17f5a95e9 --- /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 38f04860abe184ab7e61182c538c8a4b39003885..0000000000000000000000000000000000000000 --- 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 7f1853ea4ad2051e145d01cb86b45f68c7804f44..0000000000000000000000000000000000000000 --- 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 f7eafd08bef07e1d9b97318e52e2d31323a3542c..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..53bc733584b8c437905b7bf7ef9d3a636866262b --- /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 b024427a8fdc6ed1d3851d10be75bec67a40aa71..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..0fad2befd53b36b1722fa4d295123606277841e3 --- /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 f914cec0d5abee1951de6b6935acc4131b98d8c9..0000000000000000000000000000000000000000 --- 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 6d864a35e49373198dfff3fe18da82094519c052..78e16a1ca1ade345d4b76c693034a17d8f6e9043 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 cdd5d15bfbbf4cdccbe381d1af776bf58a299b36..c589cce1e380c001b0f8d5d248f7f2c513bf19d9 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 f13973a086b4048d637a660d08c75076a5ec3378..72f94995730c4a8410eb5efe37dcd24d6bb9b349 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 ccafadb198e645425c1374f6edf70265111a8cb5..23cb9f533b686bbf87655fcf1186ff319f1a0f6a 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 d4e4378cd33aa9ba431ff64dfd312be17ee460c2..dc42d5698abbb725b15e52d533ffd7ef9c719226 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 a8bda5bc6baf2331980b2b7056282b34b2b272d8..92b73e22d8bd6f3f9380cd421550108d67b280d0 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 001217d32d6604eae10f6150b1519935e2ffbe7a..3745ea3d47fa2182e3968050fe5a0011c5edf98b 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 33f45503ef7a54876001a7d15f15464c9a6cdfe4..0fbc7ecc14c129a318fe93f77d37f3299f0e2f4c 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 a08d0b3573c456651ab7287c4e9c9f160285edd3..76df6c292d130c3595bbd85a1d0061c1a20ff553 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,