From ab5303e55fb88f03ab569c241975c4156d479c50b764e552e8e6412a46677ace Mon Sep 17 00:00:00 2001 From: mirza Date: Tue, 22 Oct 2024 09:53:16 +0700 Subject: [PATCH] fix prod --- .env | 2 +- .../satu_data/surat_kontrol/surat_kontrol.go | 10 +++++++ handlers/bpjs/surat_kontrol/surat_kontrol.go | 30 +++++++++++-------- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/.env b/.env index b5d92d6..7960c82 100644 --- a/.env +++ b/.env @@ -15,7 +15,7 @@ USER_KEY_DEV=467a2817fde5070f66c9a41fbeb8dc2c SECRET_KEY_DEV=8pP3D5431E BASEURL_BPJS_DEV=https://apijkn-dev.bpjs-kesehatan.go.id/ -SURAT_KONTROL_RS_DEV=vclaim-rest-dev +SURAT_KONTROL_RS=vclaim-rest INSERT_SURAT_KONTROL=/RencanaKontrol/insert UPDATE_SURAT_KONTROL=/RencanaKontrol/Update DELETE_SURAT_KONTROL=/RencanaKontrol/Delete diff --git a/database/satu_data/surat_kontrol/surat_kontrol.go b/database/satu_data/surat_kontrol/surat_kontrol.go index c8eea7e..b8595ac 100644 --- a/database/satu_data/surat_kontrol/surat_kontrol.go +++ b/database/satu_data/surat_kontrol/surat_kontrol.go @@ -115,6 +115,11 @@ func GetDataSuratKontrol() ([]*suratkontrol.GetDataSuratKontrol, error) { left join daftar_subspesialis ds on dp."Subspesialis" = ds."id" where dsk."Status_surat_kontrol" = '1'`).Scan(&dataSurKon).Error if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + errMsg := errors.New("DPJP anda belum ada subspesialis") + log.Println(errMsg) + return nil, errMsg + } log.Println(err) return nil, err } @@ -159,6 +164,11 @@ func GetDataSuratKontrolByID(idxdaftar string) (*suratkontrol.GetDataSuratKontro left join daftar_subspesialis ds on dp."Subspesialis" = ds."id" where dsk."Status_surat_kontrol" = '1' and dkp2."IDXDAFTAR" = ?`, idxdaftar).First(&dataSurKon).Error if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + errMsg := errors.New("DPJP anda belum ada subspesialis") + log.Println(errMsg) + return nil, errMsg + } log.Println(err) return nil, err } diff --git a/handlers/bpjs/surat_kontrol/surat_kontrol.go b/handlers/bpjs/surat_kontrol/surat_kontrol.go index 265b8d1..2ed6f9f 100644 --- a/handlers/bpjs/surat_kontrol/surat_kontrol.go +++ b/handlers/bpjs/surat_kontrol/surat_kontrol.go @@ -17,8 +17,8 @@ import ( ) func InsertSuratKontrol(c *gin.Context) { - baseUrl := os.Getenv("BASEURL_BPJS_DEV") - endpoint := os.Getenv("SURAT_KONTROL_RS_DEV") + baseUrl := os.Getenv("BASEURL_BPJS") + endpoint := os.Getenv("SURAT_KONTROL_RS") param := os.Getenv("INSERT_SURAT_KONTROL") url := baseUrl + endpoint + param @@ -157,8 +157,8 @@ func InsertSuratKontrol(c *gin.Context) { } func UpdateSuratKontrol(c *gin.Context) { - baseUrl := os.Getenv("BASEURL_BPJS_DEV") - endpoint := os.Getenv("SURAT_KONTROL_RS_DEV") + baseUrl := os.Getenv("BASEURL_BPJS") + endpoint := os.Getenv("SURAT_KONTROL_RS") param := os.Getenv("UPDATE_SURAT_KONTROL") url := baseUrl + endpoint + param @@ -299,8 +299,8 @@ func UpdateSuratKontrol(c *gin.Context) { } func DeleteSuratKontrol(c *gin.Context) { - baseUrl := os.Getenv("BASEURL_BPJS_DEV") - endpoint := os.Getenv("SURAT_KONTROL_RS_DEV") + baseUrl := os.Getenv("BASEURL_BPJS") + endpoint := os.Getenv("SURAT_KONTROL_RS") param := os.Getenv("DELETE_SURAT_KONTROL") url := baseUrl + endpoint + param @@ -384,8 +384,8 @@ func DeleteSuratKontrol(c *gin.Context) { } func GetNomorSuratKontrol(c *gin.Context) { - baseUrl := os.Getenv("BASEURL_BPJS_DEV") - endpoint := os.Getenv("SURAT_KONTROL_RS_DEV") + baseUrl := os.Getenv("BASEURL_BPJS") + endpoint := os.Getenv("SURAT_KONTROL_RS") param := os.Getenv("GET_NOMOR_SURAT_KONTROL") noSurat := c.Param("noSuratKontrol") url := baseUrl + endpoint + param + noSurat @@ -414,8 +414,8 @@ func GetNomorSuratKontrol(c *gin.Context) { } func GetSuratKontrolBySEP(c *gin.Context) { - baseUrl := os.Getenv("BASEURL_BPJS_DEV") - endpoint := os.Getenv("SURAT_KONTROL_RS_DEV") + baseUrl := os.Getenv("BASEURL_BPJS") + endpoint := os.Getenv("SURAT_KONTROL_RS") param := os.Getenv("GET_SURAT_KONTROL_SEP") noSEP := c.Param("noSEP") url := baseUrl + endpoint + param + noSEP @@ -447,7 +447,10 @@ func GetDataSurKon(c *gin.Context) { data, err := suratkontrol.GetDataSuratKontrol() if err != nil { log.Println(err) - c.JSON(http.StatusInternalServerError, err) + c.JSON(http.StatusInternalServerError, &sk.MetadataString{ + Code: "", + Message: err.Error(), + }) return } var resSurKon []*sk.ResponseGetDataSuratKontrol @@ -533,7 +536,10 @@ func PrintSurKon(c *gin.Context) { data, err := suratkontrol.GetDataSuratKontrolByID(id) if err != nil { log.Println(err) - c.JSON(http.StatusInternalServerError, err) + c.JSON(http.StatusInternalServerError, &sk.MetadataString{ + Code: "", + Message: err.Error(), + }) return }