1、商品规格列表接口优化;
This commit is contained in:
parent
fcba75ba00
commit
b705ba65b7
|
@ -166,16 +166,56 @@ func GoodsSpecCreate(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
// GoodsSpecList 查询商品规格列表
|
||||
// @Summary 查询商品规格列表
|
||||
// @Tags 租卡系统-商城管理
|
||||
// @Produce json
|
||||
// @Accept json
|
||||
// @Param request body models.GoodsSpecListReq true "查询商品规格列表"
|
||||
// @Success 200 {object} models.GoodsSpecListResp
|
||||
// @Router /api/v1/mall/spec/list [post]
|
||||
func GoodsSpecList(c *gin.Context) {
|
||||
req := &models.GoodsSpecListReq{}
|
||||
if c.ShouldBindJSON(req) != nil {
|
||||
logger.Errorf("para err")
|
||||
app.Error(c, http.StatusBadRequest, errors.New("para err"), "参数错误")
|
||||
return
|
||||
}
|
||||
|
||||
page := req.PageIndex - 1
|
||||
if page < 0 {
|
||||
page = 0
|
||||
}
|
||||
if req.PageSize == 0 {
|
||||
req.PageSize = 10
|
||||
}
|
||||
|
||||
var count int64
|
||||
err := orm.Eloquent.Table("spec").Count(&count).Error
|
||||
if err != nil {
|
||||
logger.Errorf("err:", err)
|
||||
app.Error(c, http.StatusInternalServerError, errors.New("create spec err"), "获取规格列表失败")
|
||||
return
|
||||
}
|
||||
|
||||
var specs []models.Spec
|
||||
err := orm.Eloquent.Table("spec").Order("sort DESC").Find(&specs).Error
|
||||
err = orm.Eloquent.Table("spec").Order("sort DESC").Offset(page * req.PageSize).
|
||||
Limit(req.PageSize).Find(&specs).Error
|
||||
if err != nil {
|
||||
logger.Error("create spec list err:", logger.Field("err", err))
|
||||
app.Error(c, http.StatusInternalServerError, errors.New("create spec err"), "获取规格列表失败")
|
||||
return
|
||||
}
|
||||
models.SpecListSetValue(specs)
|
||||
app.OK(c, specs, "")
|
||||
|
||||
resp := models.GoodsSpecListResp{
|
||||
List: specs,
|
||||
Total: int(count),
|
||||
PageIndex: page,
|
||||
PageSize: req.PageSize,
|
||||
}
|
||||
|
||||
app.OK(c, resp, "")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -184,6 +184,18 @@ type SpecValue struct {
|
|||
// spec_value
|
||||
}
|
||||
|
||||
type GoodsSpecListReq struct {
|
||||
PageIndex int `json:"pageIndex"`
|
||||
PageSize int `json:"pageSize"`
|
||||
}
|
||||
|
||||
type GoodsSpecListResp struct {
|
||||
Total int `json:"total"` // 总条数/记录数
|
||||
PageIndex int `json:"pageIndex"` // 页码
|
||||
PageSize int `json:"pageSize"` // 页面条数
|
||||
List []Spec `json:"list"` // 商品规格列表
|
||||
}
|
||||
|
||||
func CreateGoodsSerialNo() string {
|
||||
for {
|
||||
serialNo := utils.GenSerialNo()
|
||||
|
@ -924,7 +936,7 @@ func (m *MallUserVmRecordReq) MallUserVmRecordList() ([]MallUserVmRecordData, in
|
|||
|
||||
qs = qs.Select("user_vm_record.*, user.tel").
|
||||
Joins("Left JOIN user ON user_vm_record.uid = user.uid")
|
||||
err := qs.Offset(page * m.PageSize).Limit(m.PageSize).Order("created_at desc").Find(&list).Error
|
||||
err := qs.Offset(page * m.PageSize).Limit(m.PageSize).Order("created_at desc, id desc").Find(&list).Error
|
||||
if err != nil {
|
||||
logger.Errorf("err:", err)
|
||||
return nil, 0, err
|
||||
|
|
104
docs/docs.go
104
docs/docs.go
|
@ -5615,6 +5615,39 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/mall/spec/list": {
|
||||
"post": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"租卡系统-商城管理"
|
||||
],
|
||||
"summary": "查询商品规格列表",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "查询商品规格列表",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/models.GoodsSpecListReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/models.GoodsSpecListResp"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/marketing/coupon/create": {
|
||||
"post": {
|
||||
"consumes": [
|
||||
|
@ -17603,6 +17636,41 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"models.GoodsSpecListReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"pageIndex": {
|
||||
"type": "integer"
|
||||
},
|
||||
"pageSize": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.GoodsSpecListResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"list": {
|
||||
"description": "商品规格列表",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/models.Spec"
|
||||
}
|
||||
},
|
||||
"pageIndex": {
|
||||
"description": "页码",
|
||||
"type": "integer"
|
||||
},
|
||||
"pageSize": {
|
||||
"description": "页面条数",
|
||||
"type": "integer"
|
||||
},
|
||||
"total": {
|
||||
"description": "总条数/记录数",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.GroupSendMessageCreateTemplateListReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -22607,6 +22675,42 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"models.Spec": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createdAt": {
|
||||
"description": "创建时间",
|
||||
"type": "string"
|
||||
},
|
||||
"display_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"description": "数据库记录编号",
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"sort": {
|
||||
"type": "integer"
|
||||
},
|
||||
"state": {
|
||||
"description": "1-未使用 2-使用",
|
||||
"type": "integer"
|
||||
},
|
||||
"updatedAt": {
|
||||
"description": "更新时间",
|
||||
"type": "string"
|
||||
},
|
||||
"values": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/models.SpecValue"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.SpecValue": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
|
@ -5604,6 +5604,39 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/mall/spec/list": {
|
||||
"post": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"租卡系统-商城管理"
|
||||
],
|
||||
"summary": "查询商品规格列表",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "查询商品规格列表",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/models.GoodsSpecListReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/models.GoodsSpecListResp"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/marketing/coupon/create": {
|
||||
"post": {
|
||||
"consumes": [
|
||||
|
@ -17592,6 +17625,41 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"models.GoodsSpecListReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"pageIndex": {
|
||||
"type": "integer"
|
||||
},
|
||||
"pageSize": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.GoodsSpecListResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"list": {
|
||||
"description": "商品规格列表",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/models.Spec"
|
||||
}
|
||||
},
|
||||
"pageIndex": {
|
||||
"description": "页码",
|
||||
"type": "integer"
|
||||
},
|
||||
"pageSize": {
|
||||
"description": "页面条数",
|
||||
"type": "integer"
|
||||
},
|
||||
"total": {
|
||||
"description": "总条数/记录数",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.GroupSendMessageCreateTemplateListReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -22596,6 +22664,42 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"models.Spec": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createdAt": {
|
||||
"description": "创建时间",
|
||||
"type": "string"
|
||||
},
|
||||
"display_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"description": "数据库记录编号",
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"sort": {
|
||||
"type": "integer"
|
||||
},
|
||||
"state": {
|
||||
"description": "1-未使用 2-使用",
|
||||
"type": "integer"
|
||||
},
|
||||
"updatedAt": {
|
||||
"description": "更新时间",
|
||||
"type": "string"
|
||||
},
|
||||
"values": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/models.SpecValue"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.SpecValue": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
|
@ -6446,6 +6446,30 @@ definitions:
|
|||
uid:
|
||||
type: integer
|
||||
type: object
|
||||
models.GoodsSpecListReq:
|
||||
properties:
|
||||
pageIndex:
|
||||
type: integer
|
||||
pageSize:
|
||||
type: integer
|
||||
type: object
|
||||
models.GoodsSpecListResp:
|
||||
properties:
|
||||
list:
|
||||
description: 商品规格列表
|
||||
items:
|
||||
$ref: '#/definitions/models.Spec'
|
||||
type: array
|
||||
pageIndex:
|
||||
description: 页码
|
||||
type: integer
|
||||
pageSize:
|
||||
description: 页面条数
|
||||
type: integer
|
||||
total:
|
||||
description: 总条数/记录数
|
||||
type: integer
|
||||
type: object
|
||||
models.GroupSendMessageCreateTemplateListReq:
|
||||
properties:
|
||||
pageIndex:
|
||||
|
@ -10062,6 +10086,31 @@ definitions:
|
|||
user:
|
||||
$ref: '#/definitions/models.UserInfo'
|
||||
type: object
|
||||
models.Spec:
|
||||
properties:
|
||||
createdAt:
|
||||
description: 创建时间
|
||||
type: string
|
||||
display_name:
|
||||
type: string
|
||||
id:
|
||||
description: 数据库记录编号
|
||||
type: integer
|
||||
name:
|
||||
type: string
|
||||
sort:
|
||||
type: integer
|
||||
state:
|
||||
description: 1-未使用 2-使用
|
||||
type: integer
|
||||
updatedAt:
|
||||
description: 更新时间
|
||||
type: string
|
||||
values:
|
||||
items:
|
||||
$ref: '#/definitions/models.SpecValue'
|
||||
type: array
|
||||
type: object
|
||||
models.SpecValue:
|
||||
properties:
|
||||
createdAt:
|
||||
|
@ -15481,6 +15530,27 @@ paths:
|
|||
tags:
|
||||
- 数据统计
|
||||
- V1.2.0
|
||||
/api/v1/mall/spec/list:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
parameters:
|
||||
- description: 查询商品规格列表
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/models.GoodsSpecListReq'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/models.GoodsSpecListResp'
|
||||
summary: 查询商品规格列表
|
||||
tags:
|
||||
- 租卡系统-商城管理
|
||||
/api/v1/marketing/coupon/create:
|
||||
post:
|
||||
consumes:
|
||||
|
|
Loading…
Reference in New Issue
Block a user