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.

61 lines
1.6 KiB

package v1
import (
"pure-admin/global"
"pure-admin/model/request"
"pure-admin/model/response"
"pure-admin/service"
"github.com/gin-gonic/gin"
)
// @Tags Goods
// @Summary 商品列表
// @Security ApiKeyAuth
// @accept application/json
// @Param data body request.PageInfo true "分页获取商品列表"
// @Success 200 {object} model.TbGoods4List "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /goods/list [get]
func ListGoods(c *gin.Context) {
var info request.PageInfo
_ = c.ShouldBindQuery(&info)
if info.Page == 0 {
info.Page = 1
}
if list, total, err := service.ListGoods(info); err != nil {
global.MG_LOG.Error("获取失败!" + err.Error())
response.FailWithMessage("获取失败", c)
} else {
response.OkWithDetailed(response.PageResult{
List: list,
Total: total,
Page: info.Page,
PageSize: info.PageSize,
}, "获取成功", c)
}
}
// @Tags Goods
// @Summary 商品搜索
// @Security ApiKeyAuth
// @accept application/json
// @Param data body request.PageInfo true "分页获取商品列表"
// @Success 200 {object} model.TbGoods4List "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /goods/search [get]
func SearchGoods(c *gin.Context) {
var info request.SearchGoods
_ = c.ShouldBindQuery(&info)
if info.Page == 0 {
info.Page = 1
}
if list, total, err := service.SearchGoods(info); err != nil {
global.MG_LOG.Error("获取失败!" + err.Error())
response.FailWithMessage("获取失败", c)
} else {
response.OkWithDetailed(response.PageResult{
List: list,
Total: total,
Page: info.Page,
PageSize: info.PageSize,
}, "获取成功", c)
}
}