You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
974 B

package brand
import (
"github.com/gin-gonic/gin"
"recook/internal/back"
"recook/internal/dbc"
"recook/internal/model/goods"
"recook/tools"
)
type createBrandParams struct {
Name string `json:"name" validate:"required"`
Desc string `json:"desc" validate:"required"`
Web string `json:"web" validate:"required"`
LogoURL string `json:"logoUrl" validate:"required"`
AuthUrl string `json:"authUrl" validate:"required"`
ShowUrl string `json:"showUrl" validate:"required"`
}
/*
录入品牌
*/
func CreateBrand(c *gin.Context) {
var p createBrandParams
err := tools.Params(&p, c)
if err != nil {
back.Fail(c, err.Error())
return
}
b := goods.Brand{
Name: p.Name,
Desc: p.Desc,
Web: p.Web,
LogoURL: p.LogoURL,
AuthUrl: p.AuthUrl,
ShowUrl: p.ShowUrl,
}
tx := dbc.DB.Begin()
{
err = tx.Create(&b).Error
if err != nil {
back.Fail(c, err.Error())
return
}
}
tx.Commit()
back.Suc(c, "品牌录入成功", b)
}