package handler import ( "net/http" "satusehat-rssa/internal/integration" "satusehat-rssa/internal/model" "github.com/gin-gonic/gin" ) type MedicineHandler struct { Medicine integration.MedicineIntegrationInterface } func NewMedicineHandler(medicine integration.MedicineIntegrationInterface) *MedicineHandler { return &MedicineHandler{Medicine: medicine} } func (m MedicineHandler) GetMedicineKfa(c *gin.Context) { var req model.MedicineKfaRequest if err := c.ShouldBindQuery(&req); err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } res, err := m.Medicine.GetMedicineKfa(req) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } c.JSON(http.StatusOK, res) } func (m MedicineHandler) GetMedicineByKfaCode(c *gin.Context) { kfaCode := c.Param("kfa_code") res, err := m.Medicine.GetMedicineByKfaCode(kfaCode) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } c.JSON(http.StatusOK, res) }