update terbaru
This commit is contained in:
@@ -72,3 +72,31 @@ func Getdatadokter(c *gin.Context) {
|
||||
"message": "Practitioner Dengan SMF berhasil di cari",
|
||||
})
|
||||
}
|
||||
|
||||
func GetPractitionerbyID(c *gin.Context) {
|
||||
local := os.Getenv("MONGODB_DEV_LOCAL")
|
||||
db := database.New(local).GetMongoDB()
|
||||
if db == nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"})
|
||||
return
|
||||
}
|
||||
|
||||
id := c.Param("id")
|
||||
|
||||
if id == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"message": "Parameter 'id' dibutuhkan"})
|
||||
return
|
||||
}
|
||||
|
||||
mongoDB := mongo.NewDatabaseServiceMongo(db)
|
||||
dataID, err := mongoDB.GetDokterByid(id)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": dataID,
|
||||
"message": "Practitioner Dengan ID berhasil di cari",
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user