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.

74 lines
1.6 KiB

package goods
import (
"recook/internal/libs/bean"
"recook/internal/v2/lib/back"
"recook/internal/v2/lib/common"
"recook/internal/v2/logic/supplier/goods"
goods2 "recook/internal/v2/model/gys/goods"
strict "recook/internal/v2/model/http/goods"
"recook/tools"
"github.com/gin-gonic/gin"
)
type Box struct {
}
// List 草稿箱.
func (b *Box) List(c *gin.Context) {
args := strict.ArgsGoodsList{}
if err := tools.Params(&args, c); err != nil {
back.Fail(c, err.Error())
return
}
user, _ := common.GetGysMainId(c)
args.Status = goods2.GysGoodsInfoPublishStatusDraft
result, total := goods.Logic.List(user, &args)
back.Suc(c, "操作成功", bean.ResultLists{
Total: total,
List: result,
})
}
// Search 搜索分类.
func (b *Box) Search(c *gin.Context) {
args := goods.ArgsSearchList{}
if err := tools.Params(&args, c); err != nil {
back.Fail(c, err.Error())
return
}
result := goods.Logic.SearchCategory(&args)
back.Suc(c, "操作成功", result)
}
// Delete 删除.
func (b *Box) Delete(c *gin.Context) {
args := strict.ArgsDelete{}
if err := tools.Params(&args, c); err != nil {
back.Fail(c, err.Error())
return
}
user, _ := common.GetGysMainId(c)
if err := goods.Logic.DeleteBox(user, &args); err != nil {
back.Fail(c, err.Error())
} else {
back.Suc(c, "操作成功", "")
}
}
// Modify 修改.
func (b *Box) Modify(c *gin.Context) {
args := strict.ArgsModify{}
if err := tools.Params(&args, c); err != nil {
back.Fail(c, err.Error())
return
}
user, _ := common.GetGysMainId(c)
if err := goods.Logic.Modify(user, &args); err != nil {
back.Fail(c, err.Error())
} else {
back.Suc(c, "操作成功", "")
}
}