Merge pull request '添加详情' (#100) from test into master

Reviewed-on: https://git.oa00.com/recook/backend_v2/pulls/100
master
杨赟 3 years ago
commit 98d5de6fc1

@ -185,8 +185,9 @@ func fetchRecommends(goodsId int64, brandId uint) []recommend {
}
type DetailImg struct {
List []goods.DetailPhoto `json:"list"`
Brand goods.Brand `json:"brand"`
List []goods.DetailPhoto `json:"list"`
Brand goods.Brand `json:"brand"`
Content string `json:"content"`
}
func QueryGoodsPhotosDetail(c *gin.Context) {
@ -197,12 +198,6 @@ func QueryGoodsPhotosDetail(c *gin.Context) {
return
}
var list []goods.DetailPhoto
err = dbc.DB.Order("order_no asc").Find(&list, "goods_id = ?", p.GoodsID).Error
if err != nil && gorm.IsRecordNotFoundError(err) {
back.Err(c, err.Error())
return
}
//获取品牌数据
var info goods.Information
err = dbc.DB.First(&info, "id= ?", p.GoodsID).Error
@ -217,9 +212,14 @@ func QueryGoodsPhotosDetail(c *gin.Context) {
back.Err(c, err.Error())
return
}
var list []goods.DetailPhoto
dbc.DB.Order("order_no asc").Find(&list, "goods_id = ?", p.GoodsID)
var content goods.Content
dbc.DB.First(&content, "goods_id= ?", info.BrandID)
var gd = DetailImg{
List: list,
Brand: brand,
List: list,
Brand: brand,
Content: content.Content,
}
back.Suc(c, "操作成功", &gd)

@ -0,0 +1,12 @@
package goods
type Content struct {
ID uint `gorm:"column:id;primary_key" json:"id"`
GoodsID uint `gorm:"column:goods_id" json:"goodsId"`
Content string `gorm:"column:content" json:"content"`
}
// TableName sets the insert table name for this struct type
func (c *Content) TableName() string {
return "recook_goods_content"
}
Loading…
Cancel
Save