新增了获取商品详情接口
This commit is contained in:
parent
da9cbc2156
commit
3de7415ff5
@ -13,7 +13,7 @@ type ItemController struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *ItemController) BeforeActivation(b mvc.BeforeActivation) {
|
func (c *ItemController) BeforeActivation(b mvc.BeforeActivation) {
|
||||||
b.Handle("GET", "/{id:uint}", "Get")
|
b.Handle("GET", "/detail/{id:uint}", "Detail")
|
||||||
//b.Handle("GET", "/list/{:type}", "GetList")
|
//b.Handle("GET", "/list/{:type}", "GetList")
|
||||||
|
|
||||||
// 管理员接口
|
// 管理员接口
|
||||||
@ -34,9 +34,15 @@ func (c *ItemController) BeforeActivation(b mvc.BeforeActivation) {
|
|||||||
// @Param id path uint true "商品ID"
|
// @Param id path uint true "商品ID"
|
||||||
// @Success 200 {object} map[string]interface{} "{"jwt": "jwt.jwt.jwt"}"
|
// @Success 200 {object} map[string]interface{} "{"jwt": "jwt.jwt.jwt"}"
|
||||||
// @Failure 400 {object} map[string]interface{} "{"msg": "错误信息","code":0}"
|
// @Failure 400 {object} map[string]interface{} "{"msg": "错误信息","code":0}"
|
||||||
// @Router /api/item/get/{id} [post]
|
// @Router /api/item/{id} [post]
|
||||||
func (c *ItemController) Get(id uint) mvc.Result {
|
func (c *ItemController) Detail(id uint) mvc.Result {
|
||||||
return nil
|
item, e := c.Service.Item.GetItem(id)
|
||||||
|
if e.Error() {
|
||||||
|
return e.Response()
|
||||||
|
}
|
||||||
|
return mvc.Response{
|
||||||
|
Object: item,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary 创建商品
|
// @Summary 创建商品
|
||||||
|
80
docs/docs.go
80
docs/docs.go
@ -262,46 +262,6 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/api/item/get/{id}": {
|
|
||||||
"post": {
|
|
||||||
"description": "获取相关ID的商品信息",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"item api"
|
|
||||||
],
|
|
||||||
"summary": "get item api",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "商品ID",
|
|
||||||
"name": "id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "{\"jwt\": \"jwt.jwt.jwt\"}",
|
|
||||||
"schema": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "{\"msg\": \"错误信息\",\"code\":0}",
|
|
||||||
"schema": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/api/item/oper/create": {
|
"/api/item/oper/create": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "创建商品接口",
|
"description": "创建商品接口",
|
||||||
@ -385,6 +345,46 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/api/item/{id}": {
|
||||||
|
"post": {
|
||||||
|
"description": "获取相关ID的商品信息",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"item api"
|
||||||
|
],
|
||||||
|
"summary": "get item api",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "商品ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{\"jwt\": \"jwt.jwt.jwt\"}",
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "{\"msg\": \"错误信息\",\"code\":0}",
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/api/user/auth/login": {
|
"/api/user/auth/login": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "the 用户登录接口",
|
"description": "the 用户登录接口",
|
||||||
|
@ -256,46 +256,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/api/item/get/{id}": {
|
|
||||||
"post": {
|
|
||||||
"description": "获取相关ID的商品信息",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"item api"
|
|
||||||
],
|
|
||||||
"summary": "get item api",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "商品ID",
|
|
||||||
"name": "id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "{\"jwt\": \"jwt.jwt.jwt\"}",
|
|
||||||
"schema": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "{\"msg\": \"错误信息\",\"code\":0}",
|
|
||||||
"schema": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/api/item/oper/create": {
|
"/api/item/oper/create": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "创建商品接口",
|
"description": "创建商品接口",
|
||||||
@ -379,6 +339,46 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/api/item/{id}": {
|
||||||
|
"post": {
|
||||||
|
"description": "获取相关ID的商品信息",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"item api"
|
||||||
|
],
|
||||||
|
"summary": "get item api",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "商品ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{\"jwt\": \"jwt.jwt.jwt\"}",
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "{\"msg\": \"错误信息\",\"code\":0}",
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/api/user/auth/login": {
|
"/api/user/auth/login": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "the 用户登录接口",
|
"description": "the 用户登录接口",
|
||||||
|
@ -287,7 +287,7 @@ paths:
|
|||||||
summary: 上传商品图片
|
summary: 上传商品图片
|
||||||
tags:
|
tags:
|
||||||
- file api
|
- file api
|
||||||
/api/item/get/{id}:
|
/api/item/{id}:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
- application/json
|
- application/json
|
||||||
|
@ -33,3 +33,13 @@ func (s *ItemService) DeleteItem(uid uint, item_id uint) *ecode.Ecode {
|
|||||||
|
|
||||||
return ecode.OK()
|
return ecode.OK()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ItemService) GetItem(id uint) (item *model.ItemModel, e *ecode.Ecode) {
|
||||||
|
item = new(model.ItemModel)
|
||||||
|
e = ecode.OK()
|
||||||
|
model.DB.Where("id=?", id).Where("state!=?", model.ItemStateDelete).First(item)
|
||||||
|
if item.ID == 0 {
|
||||||
|
return item, ecode.Item(ecode.ITEM_NOT_FOUND)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user