150 lines
3.9 KiB
Go
150 lines
3.9 KiB
Go
package Master
|
|
|
|
import (
|
|
"api-poliklinik/internal/database"
|
|
"api-poliklinik/pkg/database/mongo"
|
|
"github.com/gin-gonic/gin"
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
func GetCommunication(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)
|
|
dataCommunication, errSelect := mongoDB.Getcommunication()
|
|
if errSelect != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"data": dataCommunication,
|
|
"message": "komunikasi Sukses Ter-ambil ",
|
|
})
|
|
}
|
|
|
|
func Getdisability(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)
|
|
dataDisability, errSelect := mongoDB.Getdisability()
|
|
if errSelect != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"data": dataDisability,
|
|
"message": "disabilitas Sukses Ter-ambil ",
|
|
})
|
|
}
|
|
|
|
func Geteducation(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)
|
|
dataEducation, errSelect := mongoDB.Geteducation()
|
|
if errSelect != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"data": dataEducation,
|
|
"message": "disabilitas Sukses Ter-ambil ",
|
|
})
|
|
}
|
|
|
|
func Getjob(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)
|
|
dataJob, errSelect := mongoDB.Getjob()
|
|
if errSelect != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"data": dataJob,
|
|
"message": "pekerjaan Sukses Ter-ambil ",
|
|
})
|
|
}
|
|
|
|
func Getmartial(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)
|
|
dataMartial, errSelect := mongoDB.Getmartial()
|
|
if errSelect != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"data": dataMartial,
|
|
"message": "pernikahan Sukses Ter-ambil ",
|
|
})
|
|
}
|
|
|
|
func Getreligion(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)
|
|
dataReligion, errSelect := mongoDB.Getreligion()
|
|
if errSelect != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"data": dataReligion,
|
|
"message": "agama Sukses Ter-ambil ",
|
|
})
|
|
}
|
|
|
|
func Gettribe(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)
|
|
dataTribe, errSelect := mongoDB.Getsuku()
|
|
if errSelect != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"data": dataTribe,
|
|
"message": "suku Sukses Ter-ambil ",
|
|
})
|
|
}
|