lengkap belum account
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func GetProvinsi(c *gin.Context) {
|
||||
@@ -179,3 +180,57 @@ func GetHierarchyFromProvinsi(c *gin.Context) {
|
||||
"message": "Hierarki dari provinsi berhasil diambil",
|
||||
})
|
||||
}
|
||||
|
||||
func GetSMF(c *gin.Context) {
|
||||
local := os.Getenv("MONGODB_DEV_MASTER")
|
||||
db := database.New(local).GetMongoDB()
|
||||
if db == nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"})
|
||||
return
|
||||
}
|
||||
|
||||
mongoDB := mongo.NewDatabaseServiceMongo(db)
|
||||
dataSmf, errSelect := mongoDB.Getsmf()
|
||||
if errSelect != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": dataSmf,
|
||||
"message": "SMF Sukses Ter-ambil ",
|
||||
})
|
||||
}
|
||||
|
||||
func GetICD(c *gin.Context) {
|
||||
local := os.Getenv("MONGODB_DEV_MASTER")
|
||||
db := database.New(local).GetMongoDB()
|
||||
if db == nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"})
|
||||
return
|
||||
}
|
||||
// Default values
|
||||
limit := int64(0)
|
||||
skip := int64(0)
|
||||
|
||||
// Ambil dari query jika tersedia
|
||||
if l := c.Query("limit"); l != "" {
|
||||
if parsed, err := strconv.ParseInt(l, 10, 64); err == nil {
|
||||
limit = parsed
|
||||
}
|
||||
}
|
||||
if s := c.Query("skip"); s != "" {
|
||||
if parsed, err := strconv.ParseInt(s, 10, 64); err == nil {
|
||||
skip = parsed
|
||||
}
|
||||
}
|
||||
mongoDB := mongo.NewDatabaseServiceMongo(db)
|
||||
dataSmf, errSelect := mongoDB.GetICD(limit, skip)
|
||||
if errSelect != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": dataSmf,
|
||||
"message": "ICD Sukses Ter-ambil ",
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user