add
wangpengfei
2023-08-24 5fd608f17fca7e1c3c0e339831b226a3bcd8af41
add

add model supplier
5个文件已添加
8个文件已修改
1481 ■■■■■ 已修改文件
api/v1/test/enter.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/test/supplier.go 183 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 441 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 441 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 270 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
initialize/gorm.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
initialize/router.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/test/request/supplier.go 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/test/supplier.go 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/test/enter.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/test/supplier.go 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/test/enter.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/test/supplier.go 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/test/enter.go
@@ -3,4 +3,5 @@
type ApiGroup struct {
    SupplierTypeApi
    IndustryApi
    SupplierApi
}
api/v1/test/supplier.go
New file
@@ -0,0 +1,183 @@
package test
import (
    "github.com/flipped-aurora/gin-vue-admin/server/global"
    "github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
    "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
    "github.com/flipped-aurora/gin-vue-admin/server/model/test"
    testReq "github.com/flipped-aurora/gin-vue-admin/server/model/test/request"
    "github.com/flipped-aurora/gin-vue-admin/server/service"
    "github.com/flipped-aurora/gin-vue-admin/server/utils"
    "github.com/gin-gonic/gin"
    "go.uber.org/zap"
)
type SupplierApi struct {
}
var sService = service.ServiceGroupApp.TestServiceGroup.SupplierService
// CreateSupplier 创建Supplier
// @Tags Supplier
// @Summary 创建Supplier
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body test.Supplier true "创建Supplier"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /s/createSupplier [post]
func (sApi *SupplierApi) CreateSupplier(c *gin.Context) {
    var s test.Supplier
    err := c.ShouldBindJSON(&s)
    if err != nil {
        response.FailWithMessage(err.Error(), c)
        return
    }
    verify := utils.Rules{
        "Name":                {utils.NotEmpty()},
        "ResponsiblePersonId": {utils.NotEmpty()},
    }
    if err := utils.Verify(s, verify); err != nil {
        response.FailWithMessage(err.Error(), c)
        return
    }
    if err := sService.CreateSupplier(&s); err != nil {
        global.GVA_LOG.Error("创建失败!", zap.Error(err))
        response.FailWithMessage("创建失败", c)
    } else {
        response.OkWithMessage("创建成功", c)
    }
}
// DeleteSupplier 删除Supplier
// @Tags Supplier
// @Summary 删除Supplier
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body test.Supplier true "删除Supplier"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /s/deleteSupplier [delete]
func (sApi *SupplierApi) DeleteSupplier(c *gin.Context) {
    var s test.Supplier
    err := c.ShouldBindJSON(&s)
    if err != nil {
        response.FailWithMessage(err.Error(), c)
        return
    }
    if err := sService.DeleteSupplier(s); err != nil {
        global.GVA_LOG.Error("删除失败!", zap.Error(err))
        response.FailWithMessage("删除失败", c)
    } else {
        response.OkWithMessage("删除成功", c)
    }
}
// DeleteSupplierByIds 批量删除Supplier
// @Tags Supplier
// @Summary 批量删除Supplier
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "批量删除Supplier"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
// @Router /s/deleteSupplierByIds [delete]
func (sApi *SupplierApi) DeleteSupplierByIds(c *gin.Context) {
    var IDS request.IdsReq
    err := c.ShouldBindJSON(&IDS)
    if err != nil {
        response.FailWithMessage(err.Error(), c)
        return
    }
    if err := sService.DeleteSupplierByIds(IDS); err != nil {
        global.GVA_LOG.Error("批量删除失败!", zap.Error(err))
        response.FailWithMessage("批量删除失败", c)
    } else {
        response.OkWithMessage("批量删除成功", c)
    }
}
// UpdateSupplier 更新Supplier
// @Tags Supplier
// @Summary 更新Supplier
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body test.Supplier true "更新Supplier"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /s/updateSupplier [put]
func (sApi *SupplierApi) UpdateSupplier(c *gin.Context) {
    var s test.Supplier
    err := c.ShouldBindJSON(&s)
    if err != nil {
        response.FailWithMessage(err.Error(), c)
        return
    }
    verify := utils.Rules{
        "Name":                {utils.NotEmpty()},
        "ResponsiblePersonId": {utils.NotEmpty()},
    }
    if err := utils.Verify(s, verify); err != nil {
        response.FailWithMessage(err.Error(), c)
        return
    }
    if err := sService.UpdateSupplier(s); err != nil {
        global.GVA_LOG.Error("更新失败!", zap.Error(err))
        response.FailWithMessage("更新失败", c)
    } else {
        response.OkWithMessage("更新成功", c)
    }
}
// FindSupplier 用id查询Supplier
// @Tags Supplier
// @Summary 用id查询Supplier
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query test.Supplier true "用id查询Supplier"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /s/findSupplier [get]
func (sApi *SupplierApi) FindSupplier(c *gin.Context) {
    var s test.Supplier
    err := c.ShouldBindQuery(&s)
    if err != nil {
        response.FailWithMessage(err.Error(), c)
        return
    }
    if res, err := sService.GetSupplier(s.ID); err != nil {
        global.GVA_LOG.Error("查询失败!", zap.Error(err))
        response.FailWithMessage("查询失败", c)
    } else {
        response.OkWithData(gin.H{"res": res}, c)
    }
}
// GetSupplierList 分页获取Supplier列表
// @Tags Supplier
// @Summary 分页获取Supplier列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query testReq.SupplierSearch true "分页获取Supplier列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /s/getSupplierList [get]
func (sApi *SupplierApi) GetSupplierList(c *gin.Context) {
    var pageInfo testReq.SupplierSearch
    err := c.ShouldBindQuery(&pageInfo)
    if err != nil {
        response.FailWithMessage(err.Error(), c)
        return
    }
    if list, total, err := sService.GetSupplierInfoList(pageInfo); err != nil {
        global.GVA_LOG.Error("获取失败!", zap.Error(err))
        response.FailWithMessage("获取失败", c)
    } else {
        response.OkWithDetailed(response.PageResult{
            List:     list,
            Total:    total,
            Page:     pageInfo.Page,
            PageSize: pageInfo.PageSize,
        }, "获取成功", c)
    }
}
docs/docs.go
@@ -3253,6 +3253,396 @@
                }
            }
        },
        "/s/createSupplier": {
            "post": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Supplier"
                ],
                "summary": "创建Supplier",
                "parameters": [
                    {
                        "description": "创建Supplier",
                        "name": "data",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/test.Supplier"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/s/deleteSupplier": {
            "delete": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Supplier"
                ],
                "summary": "删除Supplier",
                "parameters": [
                    {
                        "description": "删除Supplier",
                        "name": "data",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/test.Supplier"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"删除成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/s/deleteSupplierByIds": {
            "delete": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Supplier"
                ],
                "summary": "批量删除Supplier",
                "parameters": [
                    {
                        "description": "批量删除Supplier",
                        "name": "data",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.IdsReq"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"批量删除成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/s/findSupplier": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Supplier"
                ],
                "summary": "用id查询Supplier",
                "parameters": [
                    {
                        "type": "string",
                        "name": "account",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "accountName",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "bank",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "contact",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "detailAddress",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "email",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "file",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "主键ID",
                        "name": "id",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "industry",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "name",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "number",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "phone",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "responsiblePersonId",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "supplierType",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "url",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"查询成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/s/getSupplierList": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Supplier"
                ],
                "summary": "分页获取Supplier列表",
                "parameters": [
                    {
                        "type": "string",
                        "name": "account",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "accountName",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "bank",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "contact",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "detailAddress",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "email",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "endCreatedAt",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "file",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "主键ID",
                        "name": "id",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "industry",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "关键字",
                        "name": "keyword",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "name",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "number",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "页码",
                        "name": "page",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "每页大小",
                        "name": "pageSize",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "phone",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "responsiblePersonId",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "startCreatedAt",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "supplierType",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "url",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/s/updateSupplier": {
            "put": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Supplier"
                ],
                "summary": "更新Supplier",
                "parameters": [
                    {
                        "description": "更新Supplier",
                        "name": "data",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/test.Supplier"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"更新成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/st/createSupplierType": {
            "post": {
                "security": [
@@ -7335,6 +7725,57 @@
                }
            }
        },
        "test.Supplier": {
            "type": "object",
            "properties": {
                "account": {
                    "type": "string"
                },
                "accountName": {
                    "type": "string"
                },
                "bank": {
                    "type": "string"
                },
                "contact": {
                    "type": "string"
                },
                "detailAddress": {
                    "type": "string"
                },
                "email": {
                    "type": "string"
                },
                "file": {
                    "type": "string"
                },
                "id": {
                    "description": "主键ID",
                    "type": "integer"
                },
                "industry": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "number": {
                    "type": "string"
                },
                "phone": {
                    "type": "string"
                },
                "responsiblePersonId": {
                    "type": "integer"
                },
                "supplierType": {
                    "type": "string"
                },
                "url": {
                    "type": "string"
                }
            }
        },
        "test.SupplierType": {
            "type": "object",
            "properties": {
docs/swagger.json
@@ -3244,6 +3244,396 @@
                }
            }
        },
        "/s/createSupplier": {
            "post": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Supplier"
                ],
                "summary": "创建Supplier",
                "parameters": [
                    {
                        "description": "创建Supplier",
                        "name": "data",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/test.Supplier"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/s/deleteSupplier": {
            "delete": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Supplier"
                ],
                "summary": "删除Supplier",
                "parameters": [
                    {
                        "description": "删除Supplier",
                        "name": "data",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/test.Supplier"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"删除成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/s/deleteSupplierByIds": {
            "delete": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Supplier"
                ],
                "summary": "批量删除Supplier",
                "parameters": [
                    {
                        "description": "批量删除Supplier",
                        "name": "data",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.IdsReq"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"批量删除成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/s/findSupplier": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Supplier"
                ],
                "summary": "用id查询Supplier",
                "parameters": [
                    {
                        "type": "string",
                        "name": "account",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "accountName",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "bank",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "contact",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "detailAddress",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "email",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "file",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "主键ID",
                        "name": "id",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "industry",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "name",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "number",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "phone",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "responsiblePersonId",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "supplierType",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "url",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"查询成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/s/getSupplierList": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Supplier"
                ],
                "summary": "分页获取Supplier列表",
                "parameters": [
                    {
                        "type": "string",
                        "name": "account",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "accountName",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "bank",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "contact",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "detailAddress",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "email",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "endCreatedAt",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "file",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "主键ID",
                        "name": "id",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "industry",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "关键字",
                        "name": "keyword",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "name",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "number",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "页码",
                        "name": "page",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "每页大小",
                        "name": "pageSize",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "phone",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "responsiblePersonId",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "startCreatedAt",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "supplierType",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "url",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/s/updateSupplier": {
            "put": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Supplier"
                ],
                "summary": "更新Supplier",
                "parameters": [
                    {
                        "description": "更新Supplier",
                        "name": "data",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/test.Supplier"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"更新成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/st/createSupplierType": {
            "post": {
                "security": [
@@ -7326,6 +7716,57 @@
                }
            }
        },
        "test.Supplier": {
            "type": "object",
            "properties": {
                "account": {
                    "type": "string"
                },
                "accountName": {
                    "type": "string"
                },
                "bank": {
                    "type": "string"
                },
                "contact": {
                    "type": "string"
                },
                "detailAddress": {
                    "type": "string"
                },
                "email": {
                    "type": "string"
                },
                "file": {
                    "type": "string"
                },
                "id": {
                    "description": "主键ID",
                    "type": "integer"
                },
                "industry": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "number": {
                    "type": "string"
                },
                "phone": {
                    "type": "string"
                },
                "responsiblePersonId": {
                    "type": "integer"
                },
                "supplierType": {
                    "type": "string"
                },
                "url": {
                    "type": "string"
                }
            }
        },
        "test.SupplierType": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -1474,6 +1474,40 @@
      name:
        type: string
    type: object
  test.Supplier:
    properties:
      account:
        type: string
      accountName:
        type: string
      bank:
        type: string
      contact:
        type: string
      detailAddress:
        type: string
      email:
        type: string
      file:
        type: string
      id:
        description: 主键ID
        type: integer
      industry:
        type: string
      name:
        type: string
      number:
        type: string
      phone:
        type: string
      responsiblePersonId:
        type: integer
      supplierType:
        type: string
      url:
        type: string
    type: object
  test.SupplierType:
    properties:
      id:
@@ -3330,6 +3364,242 @@
      summary: 更新菜单
      tags:
      - Menu
  /s/createSupplier:
    post:
      consumes:
      - application/json
      parameters:
      - description: 创建Supplier
        in: body
        name: data
        required: true
        schema:
          $ref: '#/definitions/test.Supplier'
      produces:
      - application/json
      responses:
        "200":
          description: '{"success":true,"data":{},"msg":"获取成功"}'
          schema:
            type: string
      security:
      - ApiKeyAuth: []
      summary: 创建Supplier
      tags:
      - Supplier
  /s/deleteSupplier:
    delete:
      consumes:
      - application/json
      parameters:
      - description: 删除Supplier
        in: body
        name: data
        required: true
        schema:
          $ref: '#/definitions/test.Supplier'
      produces:
      - application/json
      responses:
        "200":
          description: '{"success":true,"data":{},"msg":"删除成功"}'
          schema:
            type: string
      security:
      - ApiKeyAuth: []
      summary: 删除Supplier
      tags:
      - Supplier
  /s/deleteSupplierByIds:
    delete:
      consumes:
      - application/json
      parameters:
      - description: 批量删除Supplier
        in: body
        name: data
        required: true
        schema:
          $ref: '#/definitions/request.IdsReq'
      produces:
      - application/json
      responses:
        "200":
          description: '{"success":true,"data":{},"msg":"批量删除成功"}'
          schema:
            type: string
      security:
      - ApiKeyAuth: []
      summary: 批量删除Supplier
      tags:
      - Supplier
  /s/findSupplier:
    get:
      consumes:
      - application/json
      parameters:
      - in: query
        name: account
        type: string
      - in: query
        name: accountName
        type: string
      - in: query
        name: bank
        type: string
      - in: query
        name: contact
        type: string
      - in: query
        name: detailAddress
        type: string
      - in: query
        name: email
        type: string
      - in: query
        name: file
        type: string
      - description: 主键ID
        in: query
        name: id
        type: integer
      - in: query
        name: industry
        type: string
      - in: query
        name: name
        type: string
      - in: query
        name: number
        type: string
      - in: query
        name: phone
        type: string
      - in: query
        name: responsiblePersonId
        type: integer
      - in: query
        name: supplierType
        type: string
      - in: query
        name: url
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: '{"success":true,"data":{},"msg":"查询成功"}'
          schema:
            type: string
      security:
      - ApiKeyAuth: []
      summary: 用id查询Supplier
      tags:
      - Supplier
  /s/getSupplierList:
    get:
      consumes:
      - application/json
      parameters:
      - in: query
        name: account
        type: string
      - in: query
        name: accountName
        type: string
      - in: query
        name: bank
        type: string
      - in: query
        name: contact
        type: string
      - in: query
        name: detailAddress
        type: string
      - in: query
        name: email
        type: string
      - in: query
        name: endCreatedAt
        type: string
      - in: query
        name: file
        type: string
      - description: 主键ID
        in: query
        name: id
        type: integer
      - in: query
        name: industry
        type: string
      - description: 关键字
        in: query
        name: keyword
        type: string
      - in: query
        name: name
        type: string
      - in: query
        name: number
        type: string
      - description: 页码
        in: query
        name: page
        type: integer
      - description: 每页大小
        in: query
        name: pageSize
        type: integer
      - in: query
        name: phone
        type: string
      - in: query
        name: responsiblePersonId
        type: integer
      - in: query
        name: startCreatedAt
        type: string
      - in: query
        name: supplierType
        type: string
      - in: query
        name: url
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: '{"success":true,"data":{},"msg":"获取成功"}'
          schema:
            type: string
      security:
      - ApiKeyAuth: []
      summary: 分页获取Supplier列表
      tags:
      - Supplier
  /s/updateSupplier:
    put:
      consumes:
      - application/json
      parameters:
      - description: 更新Supplier
        in: body
        name: data
        required: true
        schema:
          $ref: '#/definitions/test.Supplier'
      produces:
      - application/json
      responses:
        "200":
          description: '{"success":true,"data":{},"msg":"更新成功"}'
          schema:
            type: string
      security:
      - ApiKeyAuth: []
      summary: 更新Supplier
      tags:
      - Supplier
  /st/createSupplierType:
    post:
      consumes:
initialize/gorm.go
@@ -51,7 +51,7 @@
        example.ExaFile{},
        example.ExaCustomer{},
        example.ExaFileChunk{},
        example.ExaFileUploadAndDownload{}, test.Industry{}, test.SupplierType{},
        example.ExaFileUploadAndDownload{}, test.Industry{}, test.SupplierType{}, test.Supplier{},
    )
    if err != nil {
        global.GVA_LOG.Error("register table failed", zap.Error(err))
initialize/router.go
@@ -75,6 +75,7 @@
        testRouter := router.RouterGroupApp.Test
        testRouter.InitIndustryRouter(PrivateGroup)
        testRouter.InitSupplierTypeRouter(PrivateGroup)
        testRouter.InitSupplierRouter(PrivateGroup)
    }
    global.GVA_LOG.Info("router register success")
model/test/request/supplier.go
New file
@@ -0,0 +1,14 @@
package request
import (
    "github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
    "github.com/flipped-aurora/gin-vue-admin/server/model/test"
    "time"
)
type SupplierSearch struct {
    test.Supplier
    StartCreatedAt *time.Time `json:"startCreatedAt" form:"startCreatedAt"`
    EndCreatedAt   *time.Time `json:"endCreatedAt" form:"endCreatedAt"`
    request.PageInfo
}
model/test/supplier.go
New file
@@ -0,0 +1,30 @@
// 自动生成模板Supplier
package test
import (
    "github.com/flipped-aurora/gin-vue-admin/server/global"
)
// Supplier 结构体
type Supplier struct {
    global.GVA_MODEL
    Number              string `json:"number" form:"number" gorm:"column:number;comment:供应商编号;size:255;"`
    Name                string `json:"name" form:"name" gorm:"column:name;comment:名称;size:255;"`
    SupplierType        string `json:"supplierType" form:"supplierType" gorm:"column:supplier_type;comment:供应商类型;size:255;"`
    Industry            string `json:"industry" form:"industry" gorm:"column:industry;comment:所属行业;size:255;"`
    Contact             string `json:"contact" form:"contact" gorm:"column:contact;comment:联系人;size:255;"`
    Phone               string `json:"phone" form:"phone" gorm:"column:phone;comment:电话;size:255;"`
    ResponsiblePersonId *int   `json:"responsiblePersonId" form:"responsiblePersonId" gorm:"column:responsible_person_id;comment:负责人id;size:11;"`
    Email               string `json:"email" form:"email" gorm:"column:email;comment:邮箱;size:255;"`
    DetailAddress       string `json:"detailAddress" form:"detailAddress" gorm:"column:detail_address;comment:详细地址;type:text;"`
    Url                 string `json:"url" form:"url" gorm:"column:url;comment:网址;size:255;"`
    AccountName         string `json:"accountName" form:"accountName" gorm:"column:account_name;comment:户名;size:255;"`
    Account             string `json:"account" form:"account" gorm:"column:account;comment:账号;size:255;"`
    Bank                string `json:"bank" form:"bank" gorm:"column:bank;comment:开户行;size:255;"`
    File                string `json:"file" form:"file" gorm:"column:file;comment:文件;"`
}
// TableName Supplier 表名
func (Supplier) TableName() string {
    return "supplier"
}
router/test/enter.go
@@ -3,4 +3,5 @@
type RouterGroup struct {
    SupplierTypeRouter
    IndustryRouter
    SupplierRouter
}
router/test/supplier.go
New file
@@ -0,0 +1,26 @@
package test
import (
    "github.com/flipped-aurora/gin-vue-admin/server/api/v1"
    "github.com/gin-gonic/gin"
)
type SupplierRouter struct {
}
// InitSupplierRouter 初始化 Supplier 路由信息
func (s *SupplierRouter) InitSupplierRouter(Router *gin.RouterGroup) {
    sRouter := Router.Group("s")
    sRouterWithoutRecord := Router.Group("s")
    var sApi = v1.ApiGroupApp.TestApiGroup.SupplierApi
    {
        sRouter.POST("createSupplier", sApi.CreateSupplier)             // 新建Supplier
        sRouter.DELETE("deleteSupplier", sApi.DeleteSupplier)           // 删除Supplier
        sRouter.DELETE("deleteSupplierByIds", sApi.DeleteSupplierByIds) // 批量删除Supplier
        sRouter.PUT("updateSupplier", sApi.UpdateSupplier)              // 更新Supplier
    }
    {
        sRouterWithoutRecord.GET("findSupplier", sApi.FindSupplier)       // 根据ID获取Supplier
        sRouterWithoutRecord.GET("getSupplierList", sApi.GetSupplierList) // 获取Supplier列表
    }
}
service/test/enter.go
@@ -3,4 +3,5 @@
type ServiceGroup struct {
    SupplierTypeService
    IndustryService
    SupplierService
}
service/test/supplier.go
New file
@@ -0,0 +1,70 @@
package test
import (
    "github.com/flipped-aurora/gin-vue-admin/server/global"
    "github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
    "github.com/flipped-aurora/gin-vue-admin/server/model/test"
    testReq "github.com/flipped-aurora/gin-vue-admin/server/model/test/request"
)
type SupplierService struct {
}
// CreateSupplier 创建Supplier记录
// Author [piexlmax](https://github.com/piexlmax)
func (sService *SupplierService) CreateSupplier(s *test.Supplier) (err error) {
    err = global.GVA_DB.Create(s).Error
    return err
}
// DeleteSupplier 删除Supplier记录
// Author [piexlmax](https://github.com/piexlmax)
func (sService *SupplierService) DeleteSupplier(s test.Supplier) (err error) {
    err = global.GVA_DB.Delete(&s).Error
    return err
}
// DeleteSupplierByIds 批量删除Supplier记录
// Author [piexlmax](https://github.com/piexlmax)
func (sService *SupplierService) DeleteSupplierByIds(ids request.IdsReq) (err error) {
    err = global.GVA_DB.Delete(&[]test.Supplier{}, "id in ?", ids.Ids).Error
    return err
}
// UpdateSupplier 更新Supplier记录
// Author [piexlmax](https://github.com/piexlmax)
func (sService *SupplierService) UpdateSupplier(s test.Supplier) (err error) {
    err = global.GVA_DB.Save(&s).Error
    return err
}
// GetSupplier 根据id获取Supplier记录
// Author [piexlmax](https://github.com/piexlmax)
func (sService *SupplierService) GetSupplier(id uint) (s test.Supplier, err error) {
    err = global.GVA_DB.Where("id = ?", id).First(&s).Error
    return
}
// GetSupplierInfoList 分页获取Supplier记录
// Author [piexlmax](https://github.com/piexlmax)
func (sService *SupplierService) GetSupplierInfoList(info testReq.SupplierSearch) (list []test.Supplier, total int64, err error) {
    limit := info.PageSize
    offset := info.PageSize * (info.Page - 1)
    // 创建db
    db := global.GVA_DB.Model(&test.Supplier{})
    var ss []test.Supplier
    // 如果有条件搜索 下方会自动创建搜索语句
    if info.StartCreatedAt != nil && info.EndCreatedAt != nil {
        db = db.Where("created_at BETWEEN ? AND ?", info.StartCreatedAt, info.EndCreatedAt)
    }
    if info.Name != "" {
        db = db.Where("name LIKE ?", "%"+info.Name+"%")
    }
    err = db.Count(&total).Error
    if err != nil {
        return
    }
    err = db.Limit(limit).Offset(offset).Find(&ss).Error
    return ss, total, err
}