Cron_Admin/app/http/controllers/backend/product.go

35 lines
813 B
Go

package backend
import (
"github.com/gin-gonic/gin"
"github.com/qit-team/snow-core/log/logger"
"qteam/app/constants/errorcode"
"qteam/app/http/controllers"
"qteam/app/http/controllers/backend/view_model"
"qteam/app/services"
)
func ProductCreateHandler(c *gin.Context) {
req, exists := c.Get("request")
if !exists {
controllers.Error(c, errorcode.ParamError)
logger.Error(c.Request.Context(), "req不存在")
return
}
in, ok := req.(view_model.ProductCreateRequest)
if !ok {
controllers.Error(c, errorcode.ParamError)
logger.Error(c.Request.Context(), "req不匹配")
return
}
do, _ := in.ToDomain()
if err := services.ProductCreate(do); err != nil {
controllers.Error(c, errorcode.SystemError)
} else {
controllers.Success(c, errorcode.Success, "product create success")
}
}