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.
37 lines
985 B
37 lines
985 B
package diamond_show
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/gin-gonic/gin"
|
|
"recook/internal/back"
|
|
"recook/internal/dbc"
|
|
"recook/internal/model/activity"
|
|
"recook/internal/model/diamond_show"
|
|
"recook/internal/model/goods"
|
|
)
|
|
|
|
type queryResp struct {
|
|
diamond_show.Information
|
|
GoodsName string `gorm:"column:goods_name" json:"goodsName"`
|
|
GoodOrActivity int8 `json:"goodOrActivity"` // goods activity--->1
|
|
}
|
|
|
|
func QueryDiamondShow(c *gin.Context) {
|
|
var list []queryResp
|
|
dbc.DB.Table((&diamond_show.Information{}).TableName()).Where("is_active=?", 1).Find(&list)
|
|
for i, v := range list {
|
|
if v.GoodsID > 0 {
|
|
var goodsInfo goods.Information
|
|
dbc.DB.Select("goods_name").First(&goodsInfo, v.GoodsID)
|
|
list[i].GoodsName = goodsInfo.GoodsName
|
|
} else {
|
|
var activityInfo activity.Info
|
|
dbc.DB.Select("name").First(&activityInfo, v.ActiveID)
|
|
fmt.Println(activityInfo)
|
|
list[i].GoodsName = activityInfo.Name
|
|
list[i].GoodOrActivity = 1
|
|
}
|
|
}
|
|
back.Suc(c, "", &list)
|
|
}
|