mastering bridging
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type PracticionerHandler struct {
|
||||
Practicioner integration.PracticionerInterface
|
||||
}
|
||||
|
||||
func NewPracticionerHandler(practicioner integration.PracticionerInterface) *PracticionerHandler {
|
||||
return &PracticionerHandler{Practicioner: practicioner}
|
||||
}
|
||||
|
||||
func (p PracticionerHandler) GetPracticionerByNik(c *gin.Context) {
|
||||
nik := c.Query("identifier")
|
||||
if nik == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "identifier is required"})
|
||||
return
|
||||
}
|
||||
|
||||
practicioner, err := p.Practicioner.GetPracticionerByNIK(nik)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if practicioner == nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"message": "Practicioner not found"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, practicioner)
|
||||
}
|
||||
Reference in New Issue
Block a user