From 8d847fe2921a2a5b9b4de694c40fb8374b27ae66 Mon Sep 17 00:00:00 2001
From: arieljovananda88 <jovanandaa@gmail.com>
Date: Mon, 10 Jun 2024 02:26:01 +0700
Subject: [PATCH] fix: change dosen bimbingan table too when update dosbing

---
 .../pendaftaran/internal/repository/pendaftaran.go  | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/module/pendaftaran/internal/repository/pendaftaran.go b/src/module/pendaftaran/internal/repository/pendaftaran.go
index 1d224aa..a25df0b 100644
--- a/src/module/pendaftaran/internal/repository/pendaftaran.go
+++ b/src/module/pendaftaran/internal/repository/pendaftaran.go
@@ -225,13 +225,22 @@ func (repo *PendaftaranRepo) UpdateStatusById(status string, idPendaftaran strin
 }
 
 func (repo *PendaftaranRepo) UpdateDosbing(idDosbing string, idPendaftaran string) error {
-	updates := map[string]interface{}{
+	pendaftaranTaUpdates := map[string]interface{}{
 		"id_dosen": idDosbing,
 	}
+	dosenBimbinganUpdate := map[string]interface{}{
+		"dosen_id": idDosbing,
+	}
 
 	if err := repo.DBWrite.Table("pendaftaran_ta").
 		Where("id = ?", idPendaftaran).
-		Updates(updates).Error; err != nil {
+		Updates(pendaftaranTaUpdates).Error; err != nil {
+		return err
+	}
+
+	if err := repo.DBWrite.Table("dosen_bimbingan").
+		Where("pendaftaran_id = ?", idPendaftaran).
+		Updates(dosenBimbinganUpdate).Error; err != nil {
 		return err
 	}
 
-- 
GitLab