first commit
This commit is contained in:
37
pkg/handlers/Practitioner/Practitioner.go
Normal file
37
pkg/handlers/Practitioner/Practitioner.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package Practitioner
|
||||
|
||||
import (
|
||||
"api-poliklinik/internal/database"
|
||||
connDatabase "api-poliklinik/pkg/database/satu_data"
|
||||
"api-poliklinik/pkg/models/satu_data"
|
||||
|
||||
"api-poliklinik/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetDataPractitioner(c *gin.Context) {
|
||||
db := database.New().GetDB("satudata")
|
||||
satudata := connDatabase.NewDatabaseService(db)
|
||||
|
||||
log.Println("REQUEST")
|
||||
dataPractitioner := satudata.PractitionerGetData()
|
||||
var responsePractitioner []satu_data.DataResponse
|
||||
for _, k := range dataPractitioner {
|
||||
gelarDepan := utils.ReplaceGelar(k.GelarDepan)
|
||||
gelarBelakang := utils.ReplaceGelar(k.GelarBelakang)
|
||||
namaLengkap := gelarDepan + " " + k.NamaLengkap + " " + gelarBelakang
|
||||
namaLengkap = strings.TrimPrefix(namaLengkap, " ")
|
||||
namaLengkap = strings.TrimSuffix(namaLengkap, " ")
|
||||
|
||||
responsePractitioner = append(responsePractitioner, satu_data.DataResponse{
|
||||
ID: k.ID,
|
||||
NIP: k.NIP,
|
||||
NamaLengkapFull: namaLengkap,
|
||||
})
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, responsePractitioner)
|
||||
}
|
||||
Reference in New Issue
Block a user