update terbaru
This commit is contained in:
@@ -27,3 +27,29 @@ func Getlocation(c *gin.Context) {
|
||||
"message": "location Sukses Ter-ambil ",
|
||||
})
|
||||
}
|
||||
|
||||
func Getlocationbysubs(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
|
||||
}
|
||||
subsistem := c.Param("subsistem")
|
||||
|
||||
if subsistem == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"message": "Parameter 'subs' dibutuhkan"})
|
||||
return
|
||||
}
|
||||
mongoDB := mongo.NewDatabaseServiceMongo(db)
|
||||
locationsmf, errSelect := mongoDB.Getlocationbysubs(subsistem)
|
||||
if errSelect != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": locationsmf,
|
||||
"count": len(locationsmf),
|
||||
"message": "location Sukses Ter-ambil ",
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user