mastering bridging
This commit is contained in:
58
internal/handler/allergancytoleran_handler.go
Normal file
58
internal/handler/allergancytoleran_handler.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type AllergancyToleranHandler struct {
|
||||
AllergancyToleran integration.AllergancyToleranInterface
|
||||
}
|
||||
|
||||
func NewAllergancyToleranHandler(AllergancyToleran integration.AllergancyToleranInterface) *AllergancyToleranHandler {
|
||||
return &AllergancyToleranHandler{AllergancyToleran: AllergancyToleran}
|
||||
}
|
||||
|
||||
func (a AllergancyToleranHandler) CreateAllergancyToleran(c *gin.Context) {
|
||||
var bodyParam model.AllergancyToleranRequest
|
||||
if err := c.ShouldBindJSON(&bodyParam); err != nil {
|
||||
c.JSON(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
res, err := a.AllergancyToleran.CreateAllergancyToleran(bodyParam)
|
||||
if err != nil {
|
||||
if res != nil {
|
||||
c.JSON(http.StatusInternalServerError, res)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
func (a AllergancyToleranHandler) UpdateAllergancyToleran(c *gin.Context) {
|
||||
var bodyParam model.AllergancyToleranRequest
|
||||
if err := c.ShouldBindJSON(&bodyParam); err != nil {
|
||||
c.JSON(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
bodyParam.Id = c.Param("id")
|
||||
res, err := a.AllergancyToleran.UpdateAllergancyToleran(bodyParam)
|
||||
if err != nil {
|
||||
if res != nil {
|
||||
c.JSON(http.StatusInternalServerError, res)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, res)
|
||||
}
|
||||
Reference in New Issue
Block a user