Skip to content
Snippets Groups Projects
Commit 9c81f879 authored by arieljovananda88's avatar arieljovananda88
Browse files

feat: full wiring for reka pendaftaran tim ta

parent 845f89ed
Branches
Tags
No related merge requests found
Pipeline #66125 passed with stage
in 2 minutes and 53 seconds
...@@ -84,6 +84,11 @@ type DosenPembimbing struct { ...@@ -84,6 +84,11 @@ type DosenPembimbing struct {
Nama string `json:"nama"` Nama string `json:"nama"`
} }
type DosenPembimbings struct {
ID string `json:"id"`
Nama string `json:"nama"`
Email string `json:"email"`
}
type RiwayatPendaftaranRes struct { type RiwayatPendaftaranRes struct {
ID string `json:"id"` ID string `json:"id"`
InterviewAt string `json:"jadwalInterview"` InterviewAt string `json:"jadwalInterview"`
...@@ -114,6 +119,11 @@ type UpdateStatusReq struct { ...@@ -114,6 +119,11 @@ type UpdateStatusReq struct {
Status string `json:"status"` Status string `json:"status"`
} }
type UpdateDosbingReq struct {
IdDosen []string `json:"pembimbing_ids"`
IDPendaftaran string `json:"id_pendaftaran"`
}
type UpdateStatusByIdReq struct { type UpdateStatusByIdReq struct {
IDPendaftaran string `json:"id_pendaftaran"` IDPendaftaran string `json:"id_pendaftaran"`
Status string `json:"status"` Status string `json:"status"`
......
...@@ -224,6 +224,20 @@ func (repo *PendaftaranRepo) UpdateStatusById(status string, idPendaftaran strin ...@@ -224,6 +224,20 @@ func (repo *PendaftaranRepo) UpdateStatusById(status string, idPendaftaran strin
return nil return nil
} }
func (repo *PendaftaranRepo) UpdateDosbing(idDosbing string, idPendaftaran string) error {
updates := map[string]interface{}{
"id_dosen": idDosbing,
}
if err := repo.DBWrite.Table("pendaftaran_ta").
Where("id = ?", idPendaftaran).
Updates(updates).Error; err != nil {
return err
}
return nil
}
func (repo *PendaftaranRepo) CountApproved(idDosen string) (int64, error) { func (repo *PendaftaranRepo) CountApproved(idDosen string) (int64, error) {
var count int64 var count int64
...@@ -356,3 +370,16 @@ func (repo *PendaftaranRepo) GetDosbingForPendaftaran(idMahasiswa string) ([]ent ...@@ -356,3 +370,16 @@ func (repo *PendaftaranRepo) GetDosbingForPendaftaran(idMahasiswa string) ([]ent
return res, nil return res, nil
} }
func (repo *PendaftaranRepo) GetAllDosbing() ([]entity.DosenPembimbings, error) {
var res []entity.DosenPembimbings
err := repo.DBRead.Table("pengguna").
Select("pengguna.id, pengguna.nama, pengguna.email").
Where("? = ANY(pengguna.roles)", "S1_PEMBIMBING").
Scan(&res).Error
if err != nil {
return nil, err
}
return res, nil
}
...@@ -26,6 +26,8 @@ type PendaftaranUsecase interface { ...@@ -26,6 +26,8 @@ type PendaftaranUsecase interface {
GetStatisticsPendaftaranTimta() (entity.Stats, error) GetStatisticsPendaftaranTimta() (entity.Stats, error)
UpdateStatusById(status string, idPendaftaran string) error UpdateStatusById(status string, idPendaftaran string) error
GetRiwayatPendaftaran(idMahasiswa string) ([]entity.RiwayatPendaftaranRes, error) GetRiwayatPendaftaran(idMahasiswa string) ([]entity.RiwayatPendaftaranRes, error)
GetAllDosbing() ([]entity.DosenPembimbings, error)
UpdateDosbing(idDosen []string, idPendaftaran string) error
} }
type PendaftaranUc struct { type PendaftaranUc struct {
...@@ -85,6 +87,10 @@ func (uc *PendaftaranUc) GetDetailRekapPendafataran(idDosen string, idMahasiswa ...@@ -85,6 +87,10 @@ func (uc *PendaftaranUc) GetDetailRekapPendafataran(idDosen string, idMahasiswa
return uc.pendaftaranRepo.GetDetailRekapPendafataran(idDosen, idMahasiswa) return uc.pendaftaranRepo.GetDetailRekapPendafataran(idDosen, idMahasiswa)
} }
func (uc *PendaftaranUc) GetAllDosbing() ([]entity.DosenPembimbings, error) {
return uc.pendaftaranRepo.GetAllDosbing()
}
func (uc *PendaftaranUc) UpdateInterview(interviewAt string, idDosen string, idMahasiswa string) error { func (uc *PendaftaranUc) UpdateInterview(interviewAt string, idDosen string, idMahasiswa string) error {
if interviewAt == "" { if interviewAt == "" {
return errors.New("interview timestamp cannot be empty") return errors.New("interview timestamp cannot be empty")
...@@ -99,6 +105,10 @@ func (uc *PendaftaranUc) UpdateStatus(status string, idDosen string, idMahasiswa ...@@ -99,6 +105,10 @@ func (uc *PendaftaranUc) UpdateStatus(status string, idDosen string, idMahasiswa
return uc.pendaftaranRepo.UpdateStatus(status, idDosen, idMahasiswa) return uc.pendaftaranRepo.UpdateStatus(status, idDosen, idMahasiswa)
} }
func (uc *PendaftaranUc) UpdateDosbing(idDosen []string, idPendaftaran string) error {
return uc.pendaftaranRepo.UpdateDosbing(idDosen[0], idPendaftaran)
}
func (uc *PendaftaranUc) UpdateStatusById(status string, idPendaftaran string) error { func (uc *PendaftaranUc) UpdateStatusById(status string, idPendaftaran string) error {
if status == "" { if status == "" {
return errors.New("interview timestamp cannot be empty") return errors.New("interview timestamp cannot be empty")
......
...@@ -31,4 +31,6 @@ type PendaftaranRepository interface { ...@@ -31,4 +31,6 @@ type PendaftaranRepository interface {
UpdateStatusById(status string, idPendaftaran string) error UpdateStatusById(status string, idPendaftaran string) error
GetRiwayatPendaftaran(idMahasiswa string) ([]entity.RiwayatPendaftaran, error) GetRiwayatPendaftaran(idMahasiswa string) ([]entity.RiwayatPendaftaran, error)
GetDosbingForPendaftaran(idMahasiswa string) ([]entity.DosenPembimbing, error) GetDosbingForPendaftaran(idMahasiswa string) ([]entity.DosenPembimbing, error)
GetAllDosbing() ([]entity.DosenPembimbings, error)
UpdateDosbing(idDosbing string, idPendaftaran string) error
} }
...@@ -44,6 +44,8 @@ func (t *AdminPendaftaranHandler) MountAdmin(group *echo.Group) { ...@@ -44,6 +44,8 @@ func (t *AdminPendaftaranHandler) MountAdmin(group *echo.Group) {
group.GET("/statistics", t.GetStatistics) group.GET("/statistics", t.GetStatistics)
group.GET("/statistics-timta", t.GetStatisticsTimta) group.GET("/statistics-timta", t.GetStatisticsTimta)
group.GET("/riwayat-pendaftaran", t.GetRiwayatPendaftaran) group.GET("/riwayat-pendaftaran", t.GetRiwayatPendaftaran)
group.GET("/all-dosbing", t.GetAllDosbing)
group.PUT("/update-dosbing", t.UpdateDosbing)
} }
// AddPendaftaran adds a new pendaftaran record. // AddPendaftaran adds a new pendaftaran record.
...@@ -93,6 +95,15 @@ func (t *AdminPendaftaranHandler) GetPendaftaran(c echo.Context) error { ...@@ -93,6 +95,15 @@ func (t *AdminPendaftaranHandler) GetPendaftaran(c echo.Context) error {
return c.JSON(http.StatusOK, utils.ResponseDetailOutput(true, http.StatusOK, "Pendaftaran successfully retreived", listGroupLimit)) return c.JSON(http.StatusOK, utils.ResponseDetailOutput(true, http.StatusOK, "Pendaftaran successfully retreived", listGroupLimit))
} }
func (t *AdminPendaftaranHandler) GetAllDosbing(c echo.Context) error {
dosbings, err := t.pendaftaranUsecase.GetAllDosbing()
if err != nil {
return c.JSON(http.StatusBadRequest, utils.ResponseDetailOutput(false, http.StatusBadRequest, err.Error(), nil))
}
return c.JSON(http.StatusOK, utils.ResponseDetailOutput(true, http.StatusOK, "All dosbing successfully retreived", dosbings))
}
func (t *AdminPendaftaranHandler) GetPendaftaranByIdDosen(c echo.Context) error { func (t *AdminPendaftaranHandler) GetPendaftaranByIdDosen(c echo.Context) error {
payload, ok := c.Get("authPayload").(utils.Payload) payload, ok := c.Get("authPayload").(utils.Payload)
if !ok { if !ok {
...@@ -186,6 +197,19 @@ func (t *AdminPendaftaranHandler) UpdateStatus(c echo.Context) error { ...@@ -186,6 +197,19 @@ func (t *AdminPendaftaranHandler) UpdateStatus(c echo.Context) error {
return c.JSON(http.StatusOK, utils.ResponseDetailOutput(true, http.StatusOK, "Interview successfully updated", err)) return c.JSON(http.StatusOK, utils.ResponseDetailOutput(true, http.StatusOK, "Interview successfully updated", err))
} }
func (t *AdminPendaftaranHandler) UpdateDosbing(c echo.Context) error {
request := new(entity.UpdateDosbingReq)
if err := c.Bind(&request); err != nil {
return c.JSON(http.StatusBadRequest, utils.ResponseDetailOutput(false, http.StatusBadRequest, err.Error(), nil))
}
err := t.pendaftaranUsecase.UpdateDosbing(request.IdDosen, request.IDPendaftaran)
if err != nil {
return c.JSON(http.StatusBadRequest, utils.ResponseDetailOutput(false, http.StatusBadRequest, err.Error(), nil))
}
return c.JSON(http.StatusOK, utils.ResponseDetailOutput(true, http.StatusOK, "Interview successfully updated", err))
}
func (t *AdminPendaftaranHandler) UpdateStatusById(c echo.Context) error { func (t *AdminPendaftaranHandler) UpdateStatusById(c echo.Context) error {
request := new(entity.UpdateStatusByIdReq) request := new(entity.UpdateStatusByIdReq)
if err := c.Bind(&request); err != nil { if err := c.Bind(&request); err != nil {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment