func NewMedicine(c *gin.Context) {
  request := struct {
    Name        string `json:"name" example:"Paracetamol" gorm:"unique" binding:"required"`
    Description string `json:"description" example:"Something" binding:"required"`
    Laboratory  string `json:"laboratory" example:"Roche" binding:"required"`
    EanCode     string `json:"ean_code" example:"122000000021" gorm:"unique" binding:"required"`
  }{}
  if err := controllers.BindJSON(c, &request); err != nil {
    appError := errorModels.NewAppError(err, errorModels.ValidationError)
    _ = c.Error(appError)
    return
  }
  medicine := models.Medicine{
    Name:        request.Name,
    Description: request.Description,
    Laboratory:  request.Laboratory,
    EANCode:     request.EanCode,
  }
  err := models.CreateMedicine(&medicine)
  if err != nil {
    _ = c.Error(err)
    return
  }
  c.JSON(http.StatusOK, medicine)
}
NewMedicine godoc
@Tags medicine
@Summary Create New Medicine
@Description Create new medicine on the system
@Accept  json
@Produce  json
@Param data body medicineController true "body data"
@Success 200 {object} models.Medicine
@Failure 400 {object} generalResponse
@Failure 500 {object} generalResponse
@Router /medicine/new [post]
package medicine
import (
  "errors"
  "github.com/gbrayhan/microservices-go/controllers"
  "github.com/gin-gonic/gin"
  "net/http"
  "strconv"
  "github.com/gbrayhan/microservices-go/models"
  errorModels "github.com/gbrayhan/microservices-go/models/errors"
)