供应商
This commit is contained in:
parent
3015514478
commit
24c555de63
|
@ -112,3 +112,31 @@ func UpdateCategory(c *gin.Context) {
|
||||||
|
|
||||||
app.OK(c, nil, "ok")
|
app.OK(c, nil, "ok")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DeleteCategoryRequest struct {
|
||||||
|
Id uint32 `json:"id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteCategory(c *gin.Context) {
|
||||||
|
req := new(DeleteCategoryRequest)
|
||||||
|
_ = c.ShouldBindJSON(req)
|
||||||
|
|
||||||
|
if err := tools.Validate(req); err != nil {
|
||||||
|
app.Error(c, 400, err, "参数错误")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
category, err := models.GetCategoryById(req.Id)
|
||||||
|
if err != nil {
|
||||||
|
app.Error(c, 500, err, "分类不存在")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = orm.Eloquent.Model(category).Delete(category.ID).Error
|
||||||
|
if err != nil {
|
||||||
|
app.Error(c, 500, err, "删除失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
app.OK(c, nil, "ok")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ func GetSupplier(req GetSupplierRequest) ([]*Supplier, error) {
|
||||||
var list []*Supplier
|
var list []*Supplier
|
||||||
m := orm.Eloquent.Model(Supplier{})
|
m := orm.Eloquent.Model(Supplier{})
|
||||||
if req.Name != "" {
|
if req.Name != "" {
|
||||||
m = m.Where("name = ?", req.Number)
|
m = m.Where("name = ?", req.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Number != "" {
|
if req.Number != "" {
|
||||||
|
|
|
@ -11,7 +11,7 @@ func registerSupplierRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddl
|
||||||
r := v1.Group("/supplier").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
r := v1.Group("/supplier").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
||||||
r.POST("create", basic.SupplierCreate)
|
r.POST("create", basic.SupplierCreate)
|
||||||
r.POST("update", basic.SupplierUpdate)
|
r.POST("update", basic.SupplierUpdate)
|
||||||
r.DELETE("delete/{id}", basic.SupplierDel)
|
r.DELETE("delete/:id", basic.SupplierDel)
|
||||||
r.GET("detail/{id}", basic.SupplierDetail)
|
r.GET("detail/:id", basic.SupplierDetail)
|
||||||
r.POST("list", basic.SupplierList)
|
r.POST("list", basic.SupplierList)
|
||||||
}
|
}
|
||||||
|
|
105
docs/docs.go
105
docs/docs.go
|
@ -19,6 +19,72 @@ const docTemplate = `{
|
||||||
"host": "{{.Host}}",
|
"host": "{{.Host}}",
|
||||||
"basePath": "{{.BasePath}}",
|
"basePath": "{{.BasePath}}",
|
||||||
"paths": {
|
"paths": {
|
||||||
|
"/api/v1/category/create": {
|
||||||
|
"post": {
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"商品分类"
|
||||||
|
],
|
||||||
|
"summary": "创建分类",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "商品分类创建模型",
|
||||||
|
"name": "request",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/basic.CreateCategoryRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/app.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/api/v1/category/update": {
|
||||||
|
"post": {
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"商品分类"
|
||||||
|
],
|
||||||
|
"summary": "编辑分类",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "商品分类编辑模型",
|
||||||
|
"name": "request",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/basic.UpdateCategoryRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/app.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/api/v1/config": {
|
"/api/v1/config": {
|
||||||
"put": {
|
"put": {
|
||||||
"security": [
|
"security": [
|
||||||
|
@ -2673,6 +2739,22 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"basic.CreateCategoryRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"name"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"description": "名称",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"pid": {
|
||||||
|
"description": "父分类id",
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"basic.SupplierCreateRequest": {
|
"basic.SupplierCreateRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
@ -2754,9 +2836,11 @@ const docTemplate = `{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"name": {
|
"name": {
|
||||||
|
"description": "供应商名称",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"number": {
|
"number": {
|
||||||
|
"description": "供应商编号",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2842,6 +2926,27 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"basic.UpdateCategoryRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"name"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"description": "分类id",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"description": "名称",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"pid": {
|
||||||
|
"description": "父分类id",
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"models.DictType": {
|
"models.DictType": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
@ -11,6 +11,72 @@
|
||||||
"version": "1.0.1"
|
"version": "1.0.1"
|
||||||
},
|
},
|
||||||
"paths": {
|
"paths": {
|
||||||
|
"/api/v1/category/create": {
|
||||||
|
"post": {
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"商品分类"
|
||||||
|
],
|
||||||
|
"summary": "创建分类",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "商品分类创建模型",
|
||||||
|
"name": "request",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/basic.CreateCategoryRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/app.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/api/v1/category/update": {
|
||||||
|
"post": {
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"商品分类"
|
||||||
|
],
|
||||||
|
"summary": "编辑分类",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "商品分类编辑模型",
|
||||||
|
"name": "request",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/basic.UpdateCategoryRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/app.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/api/v1/config": {
|
"/api/v1/config": {
|
||||||
"put": {
|
"put": {
|
||||||
"security": [
|
"security": [
|
||||||
|
@ -2665,6 +2731,22 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"basic.CreateCategoryRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"name"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"description": "名称",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"pid": {
|
||||||
|
"description": "父分类id",
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"basic.SupplierCreateRequest": {
|
"basic.SupplierCreateRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
@ -2746,9 +2828,11 @@
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"name": {
|
"name": {
|
||||||
|
"description": "供应商名称",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"number": {
|
"number": {
|
||||||
|
"description": "供应商编号",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2834,6 +2918,27 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"basic.UpdateCategoryRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"name"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"description": "分类id",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"description": "名称",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"pid": {
|
||||||
|
"description": "父分类id",
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"models.DictType": {
|
"models.DictType": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
@ -23,6 +23,17 @@ definitions:
|
||||||
requestId:
|
requestId:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
basic.CreateCategoryRequest:
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
description: 名称
|
||||||
|
type: string
|
||||||
|
pid:
|
||||||
|
description: 父分类id
|
||||||
|
type: integer
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
type: object
|
||||||
basic.SupplierCreateRequest:
|
basic.SupplierCreateRequest:
|
||||||
properties:
|
properties:
|
||||||
account_holder:
|
account_holder:
|
||||||
|
@ -85,8 +96,10 @@ definitions:
|
||||||
basic.SupplierListRequest:
|
basic.SupplierListRequest:
|
||||||
properties:
|
properties:
|
||||||
name:
|
name:
|
||||||
|
description: 供应商名称
|
||||||
type: string
|
type: string
|
||||||
number:
|
number:
|
||||||
|
description: 供应商编号
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
basic.SupplierUpdateRequest:
|
basic.SupplierUpdateRequest:
|
||||||
|
@ -151,6 +164,21 @@ definitions:
|
||||||
- province
|
- province
|
||||||
- tel
|
- tel
|
||||||
type: object
|
type: object
|
||||||
|
basic.UpdateCategoryRequest:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
description: 分类id
|
||||||
|
type: integer
|
||||||
|
name:
|
||||||
|
description: 名称
|
||||||
|
type: string
|
||||||
|
pid:
|
||||||
|
description: 父分类id
|
||||||
|
type: integer
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
- name
|
||||||
|
type: object
|
||||||
models.DictType:
|
models.DictType:
|
||||||
properties:
|
properties:
|
||||||
createBy:
|
createBy:
|
||||||
|
@ -984,6 +1012,48 @@ info:
|
||||||
title: go-admin API
|
title: go-admin API
|
||||||
version: 1.0.1
|
version: 1.0.1
|
||||||
paths:
|
paths:
|
||||||
|
/api/v1/category/create:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: 商品分类创建模型
|
||||||
|
in: body
|
||||||
|
name: request
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/basic.CreateCategoryRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/app.Response'
|
||||||
|
summary: 创建分类
|
||||||
|
tags:
|
||||||
|
- 商品分类
|
||||||
|
/api/v1/category/update:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: 商品分类编辑模型
|
||||||
|
in: body
|
||||||
|
name: request
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/basic.UpdateCategoryRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/app.Response'
|
||||||
|
summary: 编辑分类
|
||||||
|
tags:
|
||||||
|
- 商品分类
|
||||||
/api/v1/config:
|
/api/v1/config:
|
||||||
put:
|
put:
|
||||||
consumes:
|
consumes:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user