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.
73 lines
1.6 KiB
73 lines
1.6 KiB
package brand
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"recook/internal/back"
|
|
"recook/internal/dbc"
|
|
"recook/internal/model/goods"
|
|
"recook/tools"
|
|
)
|
|
|
|
type brandInfoParam struct {
|
|
BrandID uint `json:"brandId" validate:"required"`
|
|
Desc string `json:"desc"`
|
|
Web string `json:"web"`
|
|
LogoURL string `json:"logoUrl"`
|
|
AuthUrl string `json:"authUrl"`
|
|
ShowUrl string `json:"showUrl"`
|
|
}
|
|
|
|
func UpdateBrandInfo(c *gin.Context) {
|
|
var p brandInfoParam
|
|
if err := tools.Params(&p, c); err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
|
|
if err := dbc.DB.Model(goods.Brand{
|
|
ID: p.BrandID,
|
|
}).Updates(goods.Brand{
|
|
Desc: p.Desc,
|
|
Web: p.Web,
|
|
LogoURL: p.LogoURL,
|
|
AuthUrl: p.AuthUrl,
|
|
ShowUrl: p.ShowUrl,
|
|
}).Error; err != nil {
|
|
back.Err(c, err.Error())
|
|
return
|
|
}
|
|
back.Suc(c, "", nil)
|
|
}
|
|
|
|
type brandImgParam struct {
|
|
BrandID uint `json:"brand" validate:"required"`
|
|
FirstImg string `json:"firstImg"`
|
|
LastImg string `json:"lastImg"`
|
|
FirstWidth int `json:"firstWidth"`
|
|
FirstHeight int `json:"firstHeight"`
|
|
LastWidth int `json:"lastWidth"`
|
|
LastHeight int `json:"lastHeight"`
|
|
}
|
|
|
|
func UpdateBrandImg(c *gin.Context) {
|
|
var p brandImgParam
|
|
if err := tools.Params(&p, c); err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
brand := goods.Brand{}
|
|
dbc.DB.Model(&brand).Where("id = ?", p.BrandID).First(&brand)
|
|
brand.FirstImg = p.FirstImg
|
|
brand.LastImg = p.LastImg
|
|
brand.FirstWidth = p.FirstWidth
|
|
brand.FirstHeight = p.FirstHeight
|
|
brand.LastWidth = p.LastWidth
|
|
brand.LastHeight = p.LastHeight
|
|
if err := dbc.DB.Model(&goods.Brand{}).Save(&brand).Error; err != nil {
|
|
back.Err(c, err.Error())
|
|
return
|
|
}
|
|
|
|
back.Suc(c, "", nil)
|
|
}
|