From 00f155ce5dee07227b7947b0ba9ecb6d3c47aab1 Mon Sep 17 00:00:00 2001 From: nart4hire <13520129@std.stei.itb.ac.id> Date: Thu, 4 May 2023 19:32:06 +0700 Subject: [PATCH] fix(course): added back manual lecturer entry --- docs/docs.go | 8 ++++++++ docs/swagger.json | 8 ++++++++ docs/swagger.yaml | 6 ++++++ model/web/course/request.go | 9 ++++++--- service/course/add.go | 1 + service/course/update.go | 29 +++++++++++++++-------------- 6 files changed, 44 insertions(+), 17 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index 5355131..871b248 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -2711,6 +2711,10 @@ const docTemplate = `{ "description": "Course ID", "type": "string" }, + "lecturer": { + "description": "Course Lecturer Name", + "type": "string" + }, "majabbr": { "description": "Course Major Abbreviation", "type": "string" @@ -2746,6 +2750,10 @@ const docTemplate = `{ "type": "string", "example": "someone@example.com" }, + "lecturer": { + "description": "Course Lecturer Name", + "type": "string" + }, "majabbr": { "description": "Course Major Abbreviation", "type": "string" diff --git a/docs/swagger.json b/docs/swagger.json index 1ac89a2..c9f33d2 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -2703,6 +2703,10 @@ "description": "Course ID", "type": "string" }, + "lecturer": { + "description": "Course Lecturer Name", + "type": "string" + }, "majabbr": { "description": "Course Major Abbreviation", "type": "string" @@ -2738,6 +2742,10 @@ "type": "string", "example": "someone@example.com" }, + "lecturer": { + "description": "Course Lecturer Name", + "type": "string" + }, "majabbr": { "description": "Course Major Abbreviation", "type": "string" diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 83c7b97..3735fa3 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -75,6 +75,9 @@ definitions: id: description: Course ID type: string + lecturer: + description: Course Lecturer Name + type: string majabbr: description: Course Major Abbreviation type: string @@ -102,6 +105,9 @@ definitions: description: Contributor Email example: someone@example.com type: string + lecturer: + description: Course Lecturer Name + type: string majabbr: description: Course Major Abbreviation type: string diff --git a/model/web/course/request.go b/model/web/course/request.go index f070a06..e1f84ca 100644 --- a/model/web/course/request.go +++ b/model/web/course/request.go @@ -28,6 +28,9 @@ type AddCourseRequestPayload struct { // Course Name Abbreviation Abbreviation string `json:"abbreviation"` + + // Course Lecturer Name + Lecturer string `json:"lecturer"` } // DeleteCourse Request Payload @@ -40,7 +43,6 @@ type DeleteByStringRequestPayload struct { ID string `json:"-" validate:"required"` } - // GetID Request Payload // @Description Information that should be available when you get using course id (string) type GetByStringRequestPayload struct { @@ -81,6 +83,7 @@ type UpdateCourseRequestPayload struct { // Course Name Abbreviation Abbreviation string `json:"abbreviation"` -} - + // Course Lecturer Name + Lecturer string `json:"lecturer"` +} diff --git a/service/course/add.go b/service/course/add.go index a94a59b..bbed9cc 100644 --- a/service/course/add.go +++ b/service/course/add.go @@ -61,6 +61,7 @@ func (c CourseServiceImpl) AddCourse(payload course.AddCourseRequestPayload) err Description: payload.Description, Email: payload.Email, Abbreviation: payload.Abbreviation, + Lecturer: payload.Lecturer, }) if err != nil { diff --git a/service/course/update.go b/service/course/update.go index 0ab6dcd..757847e 100644 --- a/service/course/update.go +++ b/service/course/update.go @@ -7,9 +7,9 @@ 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" "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" ) @@ -45,12 +45,13 @@ func (c CourseServiceImpl) UpdateCourse(payload course.UpdateCourseRequestPayloa } err = c.CourseRepository.UpdateCourse(domCourse.Course{ - ID: payload.ID, - Name: payload.Name, - Major_id: payload.MajorID, - Description: payload.Description, - Email: payload.Email, + ID: payload.ID, + Name: payload.Name, + Major_id: payload.MajorID, + Description: payload.Description, + Email: payload.Email, Abbreviation: payload.Abbreviation, + Lecturer: payload.Lecturer, }) if err != nil { @@ -65,7 +66,7 @@ func (c CourseServiceImpl) UpdateCourse(payload course.UpdateCourseRequestPayloa } func (c CourseServiceImpl) UpdateMajor(payload major.UpdateMajorRequestPayload) error { - + // Validate Role claim, err := c.TokenUtil.Validate(payload.UpdateMajorToken, token.Access) @@ -93,11 +94,11 @@ func (c CourseServiceImpl) UpdateMajor(payload major.UpdateMajorRequestPayload) payload.FacultyID = faculty.ID } - + err = c.CourseRepository.UpdateMajor(domCourse.Major{ - ID: payload.ID, - Name: payload.Name, - Fac_id: payload.FacultyID, + ID: payload.ID, + Name: payload.Name, + Fac_id: payload.FacultyID, Abbreviation: payload.Abbreviation, }) @@ -125,10 +126,10 @@ func (c CourseServiceImpl) UpdateFaculty(payload faculty.UpdateFacultyRequestPay if claim.Role != user.Admin { return web.NewResponseErrorFromError(err, web.UnauthorizedAccess) } - + err = c.CourseRepository.UpdateFaculty(domCourse.Faculty{ - ID: payload.ID, - Name: payload.Name, + ID: payload.ID, + Name: payload.Name, Abbreviation: payload.Abbreviation, }) -- GitLab