diff --git a/src/module/pendaftaran/entity/pendaftaran.go b/src/module/pendaftaran/entity/pendaftaran.go index 9a93908c228e846b3c770fe170a68de5f96c1a66..667ccc0337859090b34b5826b84be4fb9d9a4596 100644 --- a/src/module/pendaftaran/entity/pendaftaran.go +++ b/src/module/pendaftaran/entity/pendaftaran.go @@ -139,3 +139,9 @@ type StatsItem struct { Amount int64 `json:"amount"` Percentage int64 `json:"percentage"` } + +type Pengguna struct { + ID string `gorm:"type:uuid;primaryKey" json:"id"` + Nama string `json:"nama"` + Email string `json:"email"` +} \ No newline at end of file diff --git a/src/module/pendaftaran/internal/repository/pendaftaran.go b/src/module/pendaftaran/internal/repository/pendaftaran.go index a25df0bf6c7559daef9199cf5d6a2b6715c83606..cbc80aa9dc053a91577c9edd90e13499e1fab7a9 100644 --- a/src/module/pendaftaran/internal/repository/pendaftaran.go +++ b/src/module/pendaftaran/internal/repository/pendaftaran.go @@ -283,6 +283,21 @@ func (repo *PendaftaranRepo) CountRejected(idDosen string) (int64, error) { return count, nil } +func (repo *PendaftaranRepo) GetListofDosbing() ([]entity.Pengguna, error) { + var dosbings []entity.Pengguna + + result := repo.DBRead.Table("pengguna"). + Joins("JOIN LATERAL unnest(roles) AS role ON true"). + Where("role = ?", models.S1_PEMBIMBING). + Group("pengguna.id"). + Find(&dosbings) + if result.Error != nil { + return nil, result.Error + } + + return dosbings, nil +} + func (repo *PendaftaranRepo) CountApprovedAll() (int64, error) { var count int64 diff --git a/src/module/pendaftaran/internal/usecase/pendaftaran.go b/src/module/pendaftaran/internal/usecase/pendaftaran.go index 554a76619551ed61bcb69a46901ca760349482bb..d365212d779f5208e0fd24f1dc34c392b6c89908 100644 --- a/src/module/pendaftaran/internal/usecase/pendaftaran.go +++ b/src/module/pendaftaran/internal/usecase/pendaftaran.go @@ -22,6 +22,7 @@ type PendaftaranUsecase interface { UpdateInterview(interviewAt string, idDosen string, idMahasiswa string) error UpdateStatus(status string, idDosen string, idMahasiswa string) error GetStatisticsPendaftaran(idDosen string) (entity.Stats, error) + GetListofDosbing() ([]entity.Pengguna, error) GetRekapPendaftaranTimta() ([]entity.RekapPendaftaranTimta, error) GetStatisticsPendaftaranTimta() (entity.Stats, error) UpdateStatusById(status string, idPendaftaran string) error @@ -223,6 +224,15 @@ func (uc *PendaftaranUc) GetStatisticsPendaftaran(idDosen string) (entity.Stats, return stats, nil } +func (uc *PendaftaranUc) GetListofDosbing() ([]entity.Pengguna, error) { + dosbings, err := uc.pendaftaranRepo.GetListofDosbing() + if err != nil { + return nil, err + } + + return dosbings, nil +} + func (uc *PendaftaranUc) GetStatisticsPendaftaranTimta() (entity.Stats, error) { approved, err := uc.pendaftaranRepo.CountApprovedAll() if err != nil { @@ -258,4 +268,4 @@ func (uc *PendaftaranUc) GetStatisticsPendaftaranTimta() (entity.Stats, error) { Ditolak: ditolak, } return stats, nil -} +} \ No newline at end of file diff --git a/src/module/pendaftaran/internal/usecase/repository.go b/src/module/pendaftaran/internal/usecase/repository.go index 999d4b28aca174c077f5fde624083bf9d34563d0..53cd676c6bc26ac0e002daf1273dbabd4f51d19e 100644 --- a/src/module/pendaftaran/internal/usecase/repository.go +++ b/src/module/pendaftaran/internal/usecase/repository.go @@ -23,6 +23,7 @@ type PendaftaranRepository interface { CountApproved(idDosen string) (int64, error) CountProses(idDosen string) (int64, error) CountRejected(idDosen string) (int64, error) + GetListofDosbing() ([]entity.Pengguna, error) CountApprovedAll() (int64, error) CountProsesAll() (int64, error) CountRejectedAll() (int64, error) diff --git a/src/module/pendaftaran/transport/admin_handler.go b/src/module/pendaftaran/transport/admin_handler.go index 97992c8b30e1f5269f4bf2162d5d14d8383ca040..63e0d96fc839301e0fcd874ef1aa3d72907b745f 100644 --- a/src/module/pendaftaran/transport/admin_handler.go +++ b/src/module/pendaftaran/transport/admin_handler.go @@ -42,6 +42,7 @@ func (t *AdminPendaftaranHandler) MountAdmin(group *echo.Group) { group.PUT("/update-status", t.UpdateStatus) group.PUT("/update-status-by-id", t.UpdateStatusById) group.GET("/statistics", t.GetStatistics) + group.GET("/dosen-bimbingan", t.GetListofDosbing) group.GET("/statistics-timta", t.GetStatisticsTimta) group.GET("/riwayat-pendaftaran", t.GetRiwayatPendaftaran) group.GET("/all-dosbing", t.GetAllDosbing) @@ -329,3 +330,12 @@ func (t *AdminPendaftaranHandler) GetPendaftaranByPeriode(c echo.Context) error return c.JSON(http.StatusOK, utils.ResponseDetailOutput(true, http.StatusOK, "Pendaftaran successfully retreived", pendaftaran)) } + +func (t *AdminPendaftaranHandler) GetListofDosbing(c echo.Context) error { + dosbings, err := t.pendaftaranUsecase.GetListofDosbing() + if err != nil { + return c.JSON(http.StatusInternalServerError, utils.ResponseDetailOutput(false, http.StatusInternalServerError, err.Error(), nil)) + } + + return c.JSON(http.StatusOK, utils.ResponseDetailOutput(true, http.StatusOK, "List of Dosbing successfully retrieved", dosbings)) +} \ No newline at end of file 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)