feat:活动添加is_sale

master
howell 3 years ago
parent 04bf952c20
commit f55f1e4e92

@ -1,12 +1,13 @@
package activity
import (
"github.com/gin-gonic/gin"
"recook/internal/back"
"recook/internal/dbc"
"recook/internal/model/activity"
"recook/internal/model/manage"
"recook/tools"
"github.com/gin-gonic/gin"
)
type subGoodsInfo struct {
@ -24,6 +25,7 @@ type createActivityParam struct {
TopUrl string `json:"topUrl" validator:"required"`
GoodsList []subGoodsInfo `json:"goodsList" validator:"required"`
Status uint `json:"status"` //新增模块选项 传1或2 1单个2并列
IsSale bool `json:"is_sale"`
}
func CreateActivity(c *gin.Context) {
@ -78,6 +80,7 @@ func CreateActivity(c *gin.Context) {
UserID: user.ID,
UserName: user.Name,
Status: p.Status,
IsSale: p.IsSale,
}
if err = tx.Create(info).Error; err != nil {
back.Fail(c, err.Error())

@ -1,11 +1,12 @@
package activity
import (
"github.com/gin-gonic/gin"
"recook/internal/back"
"recook/internal/dbc"
"recook/internal/model/activity"
"recook/tools"
"github.com/gin-gonic/gin"
)
type queryParam struct {
@ -24,7 +25,8 @@ type customResp struct {
}
type queryPageParam struct {
Page int64 `json:"page" validate:"numeric"`
Page int64 `json:"page" validate:"numeric"`
IsSale bool `json:"is_sale"`
}
func QueryActivityList(c *gin.Context) {
@ -104,8 +106,9 @@ func QueryNewActivityList(c *gin.Context) {
// 页面只显示 id name 创建时间
var activities = make([]activity.Info, 10)
dbc.DB.Table("recook_activity_info").Limit(limit).Offset((page.Page-1)*limit).Where("is_active=?", isActive).Scan(&activities)
dbc.DB.Table("recook_activity_info").Where("is_active=?", 1).Count(&count)
dbc.DB.Table("recook_activity_info").
Limit(limit).Offset((page.Page-1)*limit).Where("is_sale = ?", page.IsSale).Where("is_active=?", isActive).Scan(&activities)
dbc.DB.Table("recook_activity_info").Where("is_sale = ?", page.IsSale).Where("is_active=?", 1).Count(&count)
back.Suc(c, "", &queryActListResp{
List: activities,

@ -1,12 +1,13 @@
package activity
import (
"github.com/gin-gonic/gin"
"recook/internal/back"
"recook/internal/dbc"
"recook/internal/model/activity"
"recook/internal/model/manage"
"recook/tools"
"github.com/gin-gonic/gin"
)
type removeGoodsParams struct {
@ -108,6 +109,7 @@ func UpdateActivity(c *gin.Context) {
UserID: user.ID,
UserName: user.Name,
Status: p.Status,
IsSale: actInfo.IsSale,
}
if err = tx.Save(&info).Error; err != nil {
back.Fail(c, err.Error())

@ -16,6 +16,7 @@ type Info struct {
UserName string `gorm:"user_name" json:"user_name"`
UpdatedAt formatime.Second `gorm:"updated_at" json:"updated_at"`
Status uint `gorm:"column:status" json:"status"`
IsSale bool `gorm:"column:is_sale" json:"is_sale"`
}
func (*Info) TableName() string {

Loading…
Cancel
Save