From 21d437e7120ca41f882868e0192f7b637433a781 Mon Sep 17 00:00:00 2001 From: HoseaNA <13521057@std.stei.itb.ac.id> Date: Mon, 10 Jun 2024 16:58:04 +0700 Subject: [PATCH] fix: adjust get topic by id from topic id to pembimbing id --- .../internal/repository/topic_allocation.go | 8 ++++---- .../topic_allocation/internal/usecase/repository.go | 2 +- .../topic_allocation/internal/usecase/topic_allocation.go | 4 ++-- src/module/topic_allocation/transport/admin_handler.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/module/topic_allocation/internal/repository/topic_allocation.go b/src/module/topic_allocation/internal/repository/topic_allocation.go index e6172a4..525e9d3 100644 --- a/src/module/topic_allocation/internal/repository/topic_allocation.go +++ b/src/module/topic_allocation/internal/repository/topic_allocation.go @@ -82,12 +82,12 @@ func (repo *TopicAllocationRepo) GetTopic(page int, limit int, search string, id return data, nil } -func (repo *TopicAllocationRepo) GetTopicByID(ID string) (output entity.Topik, err error) { - var topic entity.Topik +func (repo *TopicAllocationRepo) GetTopicByID(ID string) (output []entity.Topik, err error) { + var topic []entity.Topik - result := repo.DBRead.Preload("Pengguna").Where("id = ?", ID).First(&topic) + result := repo.DBRead.Preload("Pengguna").Where("pengaju_id = ?", ID).Find(&topic) if result.Error != nil { - return entity.Topik{}, result.Error + return nil, result.Error } return topic, nil diff --git a/src/module/topic_allocation/internal/usecase/repository.go b/src/module/topic_allocation/internal/usecase/repository.go index 3461dcb..3e1a772 100644 --- a/src/module/topic_allocation/internal/usecase/repository.go +++ b/src/module/topic_allocation/internal/usecase/repository.go @@ -5,7 +5,7 @@ import "gitlab.informatika.org/k-01-11/graduit-be/src/module/topic_allocation/en type TopicAllocationRepo interface { NewTopic(topic entity.TopikPostPutReqData) (output entity.TopikPostPutReqData, err error) GetTopic(page int, limit int, search string, id string) (output entity.GetAllReturnType, err error) - GetTopicByID(ID string) (output entity.Topik, err error) + GetTopicByID(ID string) (output []entity.Topik, err error) UpdateTopic(topic entity.TopikPostPutReqData, id string) (output entity.TopikPostPutReqData, err error) DeleteTopic(ID string) (err error) } diff --git a/src/module/topic_allocation/internal/usecase/topic_allocation.go b/src/module/topic_allocation/internal/usecase/topic_allocation.go index abebe74..82e3ee2 100644 --- a/src/module/topic_allocation/internal/usecase/topic_allocation.go +++ b/src/module/topic_allocation/internal/usecase/topic_allocation.go @@ -8,7 +8,7 @@ import ( type TopicUsecase interface { AddTopic(topic []entity.TopikPostPutReqData) ([]entity.TopikPostPutReqData, error) GetTopic(param utils.PageLimitSearchID) (entity.GetAllReturnType, error) - GetTopicByID(param string) (entity.Topik, error) + GetTopicByID(param string) ([]entity.Topik, error) UpdateTopic(topic entity.TopikPostPutReqData, id string) (entity.TopikPostPutReqData, error) DeleteTopic(param string) error } @@ -38,7 +38,7 @@ func (uc *TopicUc) GetTopic(param utils.PageLimitSearchID) (entity.GetAllReturnT return uc.topicAllocationRepo.GetTopic(param.Page, param.Limit, param.Search, param.ID) } -func (uc *TopicUc) GetTopicByID(param string) (entity.Topik, error) { +func (uc *TopicUc) GetTopicByID(param string) ([]entity.Topik, error) { return uc.topicAllocationRepo.GetTopicByID(param) } diff --git a/src/module/topic_allocation/transport/admin_handler.go b/src/module/topic_allocation/transport/admin_handler.go index 935aa70..8a56bbb 100644 --- a/src/module/topic_allocation/transport/admin_handler.go +++ b/src/module/topic_allocation/transport/admin_handler.go @@ -146,7 +146,7 @@ func (admin *AdminTopicAllocationHandler) UpdateTopic(c echo.Context) error { // @Success 200 {object} nil // @Router /alokasi-topik/{id} [delete] func (admin *AdminTopicAllocationHandler) DeleteTopic(c echo.Context) error { - id := c.Param("id") + id := c.Param("idPembimbing") if id != "" { err := admin.topicUsecase.DeleteTopic(id) -- GitLab