diff --git a/src/module/topic_allocation/internal/repository/topic_allocation.go b/src/module/topic_allocation/internal/repository/topic_allocation.go index e6172a426658e8f2616b339f7311b32bae5f332d..525e9d3223aa34d063657142fb5b7bbdd7365592 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 3461dcbcb787a1f13377006aaa9b74589659a458..3e1a7725edc14b62ef4d45f8296f9cb24e8b485e 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 abebe74509fff4829efcca2b17341ae532ff7bf4..82e3ee221f22738d343191171e34c9de2d14add3 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 935aa707f91a16a72acf9124dc66d709afd7d7c4..8a56bbb4a42a6787b279f6e397b59605e23220da 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)