zhangqian
2023-08-28 e517b1a99b6edfa24c8cc4e109a6a10488f23b6a
merge
8个文件已添加
10个文件已修改
1895 ■■■■■ 已修改文件
.gitignore 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
.idea/srm.iml 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/purchase/purchase.go 194 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
config.yaml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 472 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 472 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 287 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
go.mod 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
go.sum 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
initialize/gorm.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
initialize/router.go 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
log/2023-08-26/info.log 200 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/purchase/purchase.go 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/purchase/purchase_products.go 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/purchase/request/purchase.go 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/purchase/response/purchase.go 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/purchase/purchase.go 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/purchase/purchase.go 140 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -16,4 +16,6 @@
_testmain.go
*.exe
*.test
/log/*
/log/*
srm
.idea
.idea/srm.iml
@@ -1,9 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<module version="4">
  <component name="Go" enabled="true" />
  <component name="NewModuleRootManager">
    <content url="file://$MODULE_DIR$" />
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
  </component>
</module>
api/v1/purchase/purchase.go
New file
@@ -0,0 +1,194 @@
package purchase
import (
    "github.com/gin-gonic/gin"
    "go.uber.org/zap"
    "srm/global"
    "srm/model/common/request"
    "srm/model/common/response"
    purchaserequest "srm/model/purchase/request"
    "strconv"
    //"srm/model/purchase"
    //"srm/model/purchase"
    purchaseRes "srm/model/purchase/response"
    service "srm/service/purchase"
    "srm/utils"
)
type PurchaseApi struct{}
// CreatePurchase
// @Tags      Purchase
// @Summary   创建采购单
// @Security  ApiKeyAuth
// @accept    application/json
// @Produce   application/json
// @Param     data  body     purchaserequest.AddPurchase   true  "采购单用户名, 采购单手机号码"
// @Success   200   {object}  response.Response{msg=string}  "创建采购单"
// @Router    /purchase/purchase [post]
func (e *PurchaseApi) CreatePurchase(c *gin.Context) {
    var params purchaserequest.AddPurchase
    err := c.ShouldBindJSON(&params)
    if err != nil {
        response.FailWithMessage(err.Error(), c)
        return
    }
    err = service.NewPurchaseService().CreatePurchase(params)
    if err != nil {
        global.GVA_LOG.Error("创建失败!", zap.Error(err))
        response.FailWithMessage("创建失败", c)
        return
    }
    response.OkWithMessage("创建成功", c)
}
// DeletePurchase
// @Tags      Purchase
// @Summary   删除采购单
// @Security  ApiKeyAuth
// @accept    application/json
// @Produce   application/json
// @Param        id    path        int    true    "采购单ID"
// @Success   200   {object}  response.Response{msg=string}  "删除采购单"
// @Router    /purchase/purchase/{id} [delete]
func (e *PurchaseApi) DeletePurchase(c *gin.Context) {
    id, _ := strconv.Atoi(c.Param("id"))
    if id == 0 {
        response.FailWithMessage("参数缺失", c)
        return
    }
    err := service.NewPurchaseService().DeletePurchase(uint(id))
    if err != nil {
        global.GVA_LOG.Error("删除失败!", zap.Error(err))
        response.FailWithMessage("删除失败", c)
        return
    }
    response.OkWithMessage("删除成功", c)
}
// UpdatePurchase
// @Tags      Purchase
// @Summary   更新采购单信息
// @Security  ApiKeyAuth
// @accept    application/json
// @Produce   application/json
// @Param     data  body      purchaserequest.AddPurchase            true  "采购单ID, 采购单信息"
// @Success   200   {object}  response.Response{msg=string}  "更新采购单信息"
// @Router    /purchase/purchase [put]
func (e *PurchaseApi) UpdatePurchase(c *gin.Context) {
    var params purchaserequest.AddPurchase
    err := c.ShouldBindJSON(&params)
    if err != nil {
        response.FailWithMessage(err.Error(), c)
        return
    }
    err = utils.Verify(params.Purchase.GVA_MODEL, utils.IdVerify)
    if err != nil {
        response.FailWithMessage(err.Error(), c)
        return
    }
    err = service.NewPurchaseService().UpdatePurchase(&params)
    if err != nil {
        global.GVA_LOG.Error("更新失败!", zap.Error(err))
        response.FailWithMessage("更新失败", c)
        return
    }
    response.OkWithMessage("更新成功", c)
}
// GetPurchase
// @Tags      Purchase
// @Summary   获取单一采购单信息
// @Security  ApiKeyAuth
// @accept    application/json
// @Produce   application/json
// @Param        id    path        int    true    "采购单ID"                                           true  "采购单ID"
// @Success   200   {object}  response.Response{data=purchaseRes.PurchaseResponse,msg=string}  "获取单一采购单信息,返回包括采购单详情"
// @Router    /purchase/purchase/{id} [get]
func (e *PurchaseApi) GetPurchase(c *gin.Context) {
    id, _ := strconv.Atoi(c.Param("id"))
    if id == 0 {
        response.FailWithMessage("参数缺失", c)
        return
    }
    data, err := service.NewPurchaseService().GetPurchase(uint(id))
    if err != nil {
        global.GVA_LOG.Error("获取失败!", zap.Error(err))
        response.FailWithMessage("获取失败", c)
        return
    }
    productList, err := service.NewPurchaseService().GetPurchaseProductList(uint(id))
    if err != nil {
        global.GVA_LOG.Error("获取失败!", zap.Error(err))
        response.FailWithMessage("获取失败", c)
        return
    }
    response.OkWithDetailed(purchaseRes.PurchaseResponse{Purchase: data, ProductList: productList}, "获取成功", c)
}
// GetPurchaseList
// @Tags      Purchase
// @Summary   分页获取采购单列表
// @Security  ApiKeyAuth
// @accept    application/json
// @Produce   application/json
// @Param     data  query     request.PageInfo                                        true  "页码, 每页大小"
// @Success   200   {object}  response.Response{data=response.PageResult,msg=string}  "分页获取采购单列表,返回包括列表,总数,页码,每页数量"
// @Router    /purchase/purchaseList [get]
func (e *PurchaseApi) GetPurchaseList(c *gin.Context) {
    var pageInfo request.PageInfo
    err := c.ShouldBindQuery(&pageInfo)
    if err != nil {
        response.FailWithMessage(err.Error(), c)
        return
    }
    err = utils.Verify(pageInfo, utils.PageInfoVerify)
    if err != nil {
        response.FailWithMessage(err.Error(), c)
        return
    }
    PurchaseList, total, err := service.NewPurchaseService().GetPurchaseList(pageInfo)
    if err != nil {
        global.GVA_LOG.Error("获取失败!", zap.Error(err))
        response.FailWithMessage("获取失败"+err.Error(), c)
        return
    }
    response.OkWithDetailed(response.PageResult{
        List:     PurchaseList,
        Total:    total,
        Page:     pageInfo.Page,
        PageSize: pageInfo.PageSize,
    }, "获取成功", c)
}
// Submit
// @Tags      Purchase
// @Summary   提交采购单
// @Security  ApiKeyAuth
// @accept    application/json
// @Produce   application/json
// @Param        id    path        int    true    "采购单ID"
// @Success   200   {object}  response.Response{msg=string}  "提交采购单"
// @Router    /purchase/submit/{id} [post]
func (e *PurchaseApi) Submit(c *gin.Context) {
    var params purchaserequest.AddPurchase
    err := c.ShouldBindJSON(&params)
    if err != nil {
        response.FailWithMessage(err.Error(), c)
        return
    }
    err = utils.Verify(params.Purchase.GVA_MODEL, utils.IdVerify)
    if err != nil {
        response.FailWithMessage(err.Error(), c)
        return
    }
    err = service.NewPurchaseService().UpdatePurchase(&params)
    if err != nil {
        global.GVA_LOG.Error("更新失败!", zap.Error(err))
        response.FailWithMessage("更新失败", c)
        return
    }
    response.OkWithMessage("更新成功", c)
}
config.yaml
@@ -173,6 +173,7 @@
  singular: false
  log-zap: false
system:
<<<<<<< HEAD
  env: public
  db-type: mysql
  oss-type: local
@@ -184,6 +185,17 @@
  use-redis: false
  grpc-url: 192.168.20.119:9091
  grpc-admin-url: 192.168.20.119:50051
=======
    env: public
    db-type: mysql
    oss-type: local
    router-prefix: "/api"
    addr: 8004
    iplimit-count: 15000
    iplimit-time: 3600
    use-multipoint: false
    use-redis: false
>>>>>>> zq
tencent-cos:
  bucket: xxxxx-10005608
  region: ap-shanghai
docs/docs.go
@@ -4428,6 +4428,119 @@
                }
            }
        },
        "/p/getProductListFromGrpc": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Product"
                ],
                "summary": "分页获取Product列表",
                "parameters": [
                    {
                        "type": "integer",
                        "name": "deliveryTime",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "endCreatedAt",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "主键ID",
                        "name": "id",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "关键字",
                        "name": "keyword",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "maximumStock",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "minimumStock",
                        "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": "productType",
                        "in": "query"
                    },
                    {
                        "type": "number",
                        "name": "purchasePrice",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "remark",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "shippingDuration",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "startCreatedAt",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "unit",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/p/updateProduct": {
            "put": {
                "security": [
@@ -4461,6 +4574,263 @@
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"更新成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/purchase/purchase": {
            "put": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Purchase"
                ],
                "summary": "更新采购单信息",
                "parameters": [
                    {
                        "description": "采购单ID, 采购单信息",
                        "name": "data",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/purchaserequest.AddPurchase"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "更新采购单信息",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/response.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "msg": {
                                            "type": "string"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "post": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Purchase"
                ],
                "summary": "创建采购单",
                "parameters": [
                    {
                        "description": "采购单用户名, 采购单手机号码",
                        "name": "data",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/purchaserequest.AddPurchase"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "创建采购单",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/response.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "msg": {
                                            "type": "string"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/purchase/purchase/{id}": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Purchase"
                ],
                "summary": "获取单一采购单信息",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "采购单ID",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "获取单一采购单信息,返回包括采购单详情",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/response.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/response.PurchaseResponse"
                                        },
                                        "msg": {
                                            "type": "string"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "delete": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Purchase"
                ],
                "summary": "删除采购单",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "采购单ID",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "删除采购单",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/response.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "msg": {
                                            "type": "string"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/purchase/purchaseList": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Purchase"
                ],
                "summary": "分页获取权限采购单列表",
                "parameters": [
                    {
                        "type": "string",
                        "description": "关键字",
                        "name": "keyword",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "页码",
                        "name": "page",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "每页大小",
                        "name": "pageSize",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "分页获取权限采购单列表,返回包括列表,总数,页码,每页数量",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/response.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/response.PageResult"
                                        },
                                        "msg": {
                                            "type": "string"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
@@ -7818,6 +8188,94 @@
                }
            }
        },
        "purchase.Purchase": {
            "type": "object",
            "properties": {
                "contact": {
                    "description": "联系人",
                    "type": "string"
                },
                "deliveryDate": {
                    "description": "交付日期",
                    "type": "string"
                },
                "id": {
                    "description": "主键ID",
                    "type": "integer"
                },
                "name": {
                    "description": "采购名称",
                    "type": "string"
                },
                "phone": {
                    "description": "联系人电话",
                    "type": "string"
                },
                "purchaseTypeId": {
                    "description": "采购类型id",
                    "type": "integer"
                },
                "remark": {
                    "description": "备注",
                    "type": "string"
                },
                "signingDate": {
                    "description": "签约日期",
                    "type": "string"
                },
                "supplierId": {
                    "description": "供应商id",
                    "type": "integer"
                }
            }
        },
        "purchase.PurchaseProducts": {
            "type": "object",
            "properties": {
                "amount": {
                    "description": "采购数量",
                    "type": "number"
                },
                "id": {
                    "description": "主键ID",
                    "type": "integer"
                },
                "price": {
                    "description": "采购单价",
                    "type": "number"
                },
                "productId": {
                    "description": "产品id",
                    "type": "integer"
                },
                "purchaseId": {
                    "description": "采购id",
                    "type": "integer"
                },
                "remark": {
                    "description": "描述",
                    "type": "string"
                },
                "total": {
                    "description": "采购总价",
                    "type": "number"
                }
            }
        },
        "purchaserequest.AddPurchase": {
            "type": "object",
            "properties": {
                "productList": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/purchase.PurchaseProducts"
                    }
                },
                "purchase": {
                    "$ref": "#/definitions/purchase.Purchase"
                }
            }
        },
        "request.AddMenuAuthorityInfo": {
            "type": "object",
            "properties": {
@@ -8270,6 +8728,20 @@
                }
            }
        },
        "response.PurchaseResponse": {
            "type": "object",
            "properties": {
                "productList": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/purchase.PurchaseProducts"
                    }
                },
                "purchase": {
                    "$ref": "#/definitions/purchase.Purchase"
                }
            }
        },
        "response.Response": {
            "type": "object",
            "properties": {
docs/swagger.json
@@ -4419,6 +4419,119 @@
                }
            }
        },
        "/p/getProductListFromGrpc": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Product"
                ],
                "summary": "分页获取Product列表",
                "parameters": [
                    {
                        "type": "integer",
                        "name": "deliveryTime",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "endCreatedAt",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "主键ID",
                        "name": "id",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "关键字",
                        "name": "keyword",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "maximumStock",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "minimumStock",
                        "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": "productType",
                        "in": "query"
                    },
                    {
                        "type": "number",
                        "name": "purchasePrice",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "remark",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "shippingDuration",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "startCreatedAt",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "unit",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/p/updateProduct": {
            "put": {
                "security": [
@@ -4452,6 +4565,263 @@
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"更新成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/purchase/purchase": {
            "put": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Purchase"
                ],
                "summary": "更新采购单信息",
                "parameters": [
                    {
                        "description": "采购单ID, 采购单信息",
                        "name": "data",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/purchaserequest.AddPurchase"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "更新采购单信息",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/response.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "msg": {
                                            "type": "string"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "post": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Purchase"
                ],
                "summary": "创建采购单",
                "parameters": [
                    {
                        "description": "采购单用户名, 采购单手机号码",
                        "name": "data",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/purchaserequest.AddPurchase"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "创建采购单",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/response.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "msg": {
                                            "type": "string"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/purchase/purchase/{id}": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Purchase"
                ],
                "summary": "获取单一采购单信息",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "采购单ID",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "获取单一采购单信息,返回包括采购单详情",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/response.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/response.PurchaseResponse"
                                        },
                                        "msg": {
                                            "type": "string"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "delete": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Purchase"
                ],
                "summary": "删除采购单",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "采购单ID",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "删除采购单",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/response.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "msg": {
                                            "type": "string"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/purchase/purchaseList": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Purchase"
                ],
                "summary": "分页获取权限采购单列表",
                "parameters": [
                    {
                        "type": "string",
                        "description": "关键字",
                        "name": "keyword",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "页码",
                        "name": "page",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "每页大小",
                        "name": "pageSize",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "分页获取权限采购单列表,返回包括列表,总数,页码,每页数量",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/response.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/response.PageResult"
                                        },
                                        "msg": {
                                            "type": "string"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
@@ -7809,6 +8179,94 @@
                }
            }
        },
        "purchase.Purchase": {
            "type": "object",
            "properties": {
                "contact": {
                    "description": "联系人",
                    "type": "string"
                },
                "deliveryDate": {
                    "description": "交付日期",
                    "type": "string"
                },
                "id": {
                    "description": "主键ID",
                    "type": "integer"
                },
                "name": {
                    "description": "采购名称",
                    "type": "string"
                },
                "phone": {
                    "description": "联系人电话",
                    "type": "string"
                },
                "purchaseTypeId": {
                    "description": "采购类型id",
                    "type": "integer"
                },
                "remark": {
                    "description": "备注",
                    "type": "string"
                },
                "signingDate": {
                    "description": "签约日期",
                    "type": "string"
                },
                "supplierId": {
                    "description": "供应商id",
                    "type": "integer"
                }
            }
        },
        "purchase.PurchaseProducts": {
            "type": "object",
            "properties": {
                "amount": {
                    "description": "采购数量",
                    "type": "number"
                },
                "id": {
                    "description": "主键ID",
                    "type": "integer"
                },
                "price": {
                    "description": "采购单价",
                    "type": "number"
                },
                "productId": {
                    "description": "产品id",
                    "type": "integer"
                },
                "purchaseId": {
                    "description": "采购id",
                    "type": "integer"
                },
                "remark": {
                    "description": "描述",
                    "type": "string"
                },
                "total": {
                    "description": "采购总价",
                    "type": "number"
                }
            }
        },
        "purchaserequest.AddPurchase": {
            "type": "object",
            "properties": {
                "productList": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/purchase.PurchaseProducts"
                    }
                },
                "purchase": {
                    "$ref": "#/definitions/purchase.Purchase"
                }
            }
        },
        "request.AddMenuAuthorityInfo": {
            "type": "object",
            "properties": {
@@ -8261,6 +8719,20 @@
                }
            }
        },
        "response.PurchaseResponse": {
            "type": "object",
            "properties": {
                "productList": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/purchase.PurchaseProducts"
                    }
                },
                "purchase": {
                    "$ref": "#/definitions/purchase.Purchase"
                }
            }
        },
        "response.Response": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -665,6 +665,69 @@
        description: 文件地址
        type: string
    type: object
  purchase.Purchase:
    properties:
      contact:
        description: 联系人
        type: string
      deliveryDate:
        description: 交付日期
        type: string
      id:
        description: 主键ID
        type: integer
      name:
        description: 采购名称
        type: string
      phone:
        description: 联系人电话
        type: string
      purchaseTypeId:
        description: 采购类型id
        type: integer
      remark:
        description: 备注
        type: string
      signingDate:
        description: 签约日期
        type: string
      supplierId:
        description: 供应商id
        type: integer
    type: object
  purchase.PurchaseProducts:
    properties:
      amount:
        description: 采购数量
        type: number
      id:
        description: 主键ID
        type: integer
      price:
        description: 采购单价
        type: number
      productId:
        description: 产品id
        type: integer
      purchaseId:
        description: 采购id
        type: integer
      remark:
        description: 描述
        type: string
      total:
        description: 采购总价
        type: number
    type: object
  purchaserequest.AddPurchase:
    properties:
      productList:
        items:
          $ref: '#/definitions/purchase.PurchaseProducts'
        type: array
      purchase:
        $ref: '#/definitions/purchase.Purchase'
    type: object
  request.AddMenuAuthorityInfo:
    properties:
      authorityId:
@@ -973,6 +1036,15 @@
        items:
          $ref: '#/definitions/request.CasbinInfo'
        type: array
    type: object
  response.PurchaseResponse:
    properties:
      productList:
        items:
          $ref: '#/definitions/purchase.PurchaseProducts'
        type: array
      purchase:
        $ref: '#/definitions/purchase.Purchase'
    type: object
  response.Response:
    properties:
@@ -4176,6 +4248,75 @@
      summary: 分页获取Product列表
      tags:
      - Product
  /p/getProductListFromGrpc:
    get:
      consumes:
      - application/json
      parameters:
      - in: query
        name: deliveryTime
        type: integer
      - in: query
        name: endCreatedAt
        type: string
      - description: 主键ID
        in: query
        name: id
        type: integer
      - description: 关键字
        in: query
        name: keyword
        type: string
      - in: query
        name: maximumStock
        type: integer
      - in: query
        name: minimumStock
        type: integer
      - 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: productType
        type: string
      - in: query
        name: purchasePrice
        type: number
      - in: query
        name: remark
        type: string
      - in: query
        name: shippingDuration
        type: integer
      - in: query
        name: startCreatedAt
        type: string
      - in: query
        name: unit
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: '{"success":true,"data":{},"msg":"获取成功"}'
          schema:
            type: string
      security:
      - ApiKeyAuth: []
      summary: 分页获取Product列表
      tags:
      - Product
  /p/updateProduct:
    put:
      consumes:
@@ -4199,6 +4340,152 @@
      summary: 更新Product
      tags:
      - Product
  /purchase/purchase:
    post:
      consumes:
      - application/json
      parameters:
      - description: 采购单用户名, 采购单手机号码
        in: body
        name: data
        required: true
        schema:
          $ref: '#/definitions/purchaserequest.AddPurchase'
      produces:
      - application/json
      responses:
        "200":
          description: 创建采购单
          schema:
            allOf:
            - $ref: '#/definitions/response.Response'
            - properties:
                msg:
                  type: string
              type: object
      security:
      - ApiKeyAuth: []
      summary: 创建采购单
      tags:
      - Purchase
    put:
      consumes:
      - application/json
      parameters:
      - description: 采购单ID, 采购单信息
        in: body
        name: data
        required: true
        schema:
          $ref: '#/definitions/purchaserequest.AddPurchase'
      produces:
      - application/json
      responses:
        "200":
          description: 更新采购单信息
          schema:
            allOf:
            - $ref: '#/definitions/response.Response'
            - properties:
                msg:
                  type: string
              type: object
      security:
      - ApiKeyAuth: []
      summary: 更新采购单信息
      tags:
      - Purchase
  /purchase/purchase/{id}:
    delete:
      consumes:
      - application/json
      parameters:
      - description: 采购单ID
        in: path
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: 删除采购单
          schema:
            allOf:
            - $ref: '#/definitions/response.Response'
            - properties:
                msg:
                  type: string
              type: object
      security:
      - ApiKeyAuth: []
      summary: 删除采购单
      tags:
      - Purchase
    get:
      consumes:
      - application/json
      parameters:
      - description: 采购单ID
        in: path
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: 获取单一采购单信息,返回包括采购单详情
          schema:
            allOf:
            - $ref: '#/definitions/response.Response'
            - properties:
                data:
                  $ref: '#/definitions/response.PurchaseResponse'
                msg:
                  type: string
              type: object
      security:
      - ApiKeyAuth: []
      summary: 获取单一采购单信息
      tags:
      - Purchase
  /purchase/purchaseList:
    get:
      consumes:
      - application/json
      parameters:
      - description: 关键字
        in: query
        name: keyword
        type: string
      - description: 页码
        in: query
        name: page
        type: integer
      - description: 每页大小
        in: query
        name: pageSize
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: 分页获取权限采购单列表,返回包括列表,总数,页码,每页数量
          schema:
            allOf:
            - $ref: '#/definitions/response.Response'
            - properties:
                data:
                  $ref: '#/definitions/response.PageResult'
                msg:
                  type: string
              type: object
      security:
      - ApiKeyAuth: []
      summary: 分页获取权限采购单列表
      tags:
      - Purchase
  /s/changeSupplierStatus:
    post:
      consumes:
go.mod
@@ -105,6 +105,7 @@
    github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
    github.com/rogpeppe/go-internal v1.11.0 // indirect
    github.com/shoenig/go-m1cpu v0.1.6 // indirect
    github.com/shopspring/decimal v1.3.1 // indirect
    github.com/spf13/afero v1.9.5 // indirect
    github.com/spf13/jwalterweatherman v1.1.0 // indirect
    github.com/spf13/pflag v1.0.5 // indirect
go.sum
@@ -47,6 +47,7 @@
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
@@ -56,6 +57,7 @@
github.com/aws/aws-sdk-go v1.44.307 h1:2R0/EPgpZcFSUwZhYImq/srjaOrOfLv5MNRzrFyAM38=
github.com/aws/aws-sdk-go v1.44.307/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao=
github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
@@ -159,6 +161,7 @@
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=
@@ -263,10 +266,16 @@
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.21.8+incompatible/go.mod h1:l7VUhRbTKCzdOacdT4oWCwATKyvZqUOlOqr0Ous3k4s=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI=
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
github.com/jackc/pgx/v4 v4.17.2/go.mod h1:lcxIZN44yMIrWI78a5CpucdD14hX0SBDbNRvjDBItsw=
github.com/jackc/pgx/v5 v5.3.1 h1:Fcr8QJ1ZeLi5zsPZqQeUZhNhxfkkKBOgJuYkJHoBOtU=
github.com/jackc/pgx/v5 v5.3.1/go.mod h1:t3JDKnCBlYIc0ewLF0Q7B8MXmoIaBOZj/ic7iHozM/8=
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
@@ -323,6 +332,7 @@
github.com/lestrrat-go/strftime v1.0.6 h1:CFGsDEt1pOpFNU+TJB0nhz9jl+K0hZSLE205AhTIGQQ=
github.com/lestrrat-go/strftime v1.0.6/go.mod h1:f7jQKgV5nnJpYgdEasS+/y7EsTb8ykN2z68n3TtcTaw=
github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8=
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
@@ -397,6 +407,8 @@
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/songzhibin97/gkit v1.2.11 h1:O8+l6eLMrZ2yNbT6Vohc6ggWnH5zt4P8/3ZEkf8jUL4=
github.com/songzhibin97/gkit v1.2.11/go.mod h1:axjYsiJWnn/kf/uGiUr9JPHRlt2CQrqfq/fPZ3xIY+M=
github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM=
@@ -474,6 +486,7 @@
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
initialize/gorm.go
@@ -2,6 +2,7 @@
import (
    "os"
    "srm/model/purchase"
    "srm/global"
    "srm/model/example"
@@ -58,6 +59,7 @@
        test.Contract{},
        test.Product{},
        test.Member{},
        purchase.Purchase{}, purchase.PurchaseProducts{},
    )
    if err != nil {
        global.GVA_LOG.Error("register table failed", zap.Error(err))
initialize/router.go
@@ -2,6 +2,7 @@
import (
    "net/http"
    "srm/router/purchase"
    "github.com/gin-gonic/gin"
    ginSwagger "github.com/swaggo/gin-swagger"
@@ -70,6 +71,8 @@
        exampleRouter.InitCustomerRouter(PrivateGroup)              // 客户路由
        exampleRouter.InitFileUploadAndDownloadRouter(PrivateGroup) // 文件上传下载功能路由
        purchase.InitPurchaseRouter(PrivateGroup) //采购单路由
    }
    {
        testRouter := router.RouterGroupApp.Test
log/2023-08-26/info.log
New file
@@ -0,0 +1,200 @@
[srm]2023/08/26 - 11:53:44.694    info    D:/basic.com/srm/initialize/gorm.go:60    register table success
[srm]2023/08/26 - 11:53:44.703    info    D:/basic.com/srm/initialize/router.go:37    register swagger handler
[srm]2023/08/26 - 11:53:44.734    info    D:/basic.com/srm/initialize/router.go:82    router register success
[srm]2023/08/26 - 11:53:44.748    info    D:/basic.com/srm/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 11:54:33.203    info    D:/basic.com/srm/initialize/gorm.go:60    register table success
[srm]2023/08/26 - 11:54:33.210    info    D:/basic.com/srm/initialize/router.go:37    register swagger handler
[srm]2023/08/26 - 11:54:33.230    info    D:/basic.com/srm/initialize/router.go:83    router register success
[srm]2023/08/26 - 11:54:33.231    info    D:/basic.com/srm/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 13:44:25.704    info    D:/basic.com/srm/initialize/gorm.go:60    register table success
[srm]2023/08/26 - 13:44:25.708    info    D:/basic.com/srm/initialize/router.go:37    register swagger handler
[srm]2023/08/26 - 13:44:25.729    info    D:/basic.com/srm/initialize/router.go:83    router register success
[srm]2023/08/26 - 13:44:25.742    info    D:/basic.com/srm/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 16:49:58.217    info    C:/code/SRM/initialize/gorm.go:60    register table success
[srm]2023/08/26 - 16:49:58.222    info    C:/code/SRM/initialize/router.go:37    register swagger handler
[srm]2023/08/26 - 16:49:58.251    info    C:/code/SRM/initialize/router.go:83    router register success
[srm]2023/08/26 - 16:49:58.253    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 17:10:06.472    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 17:10:06.476    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 17:10:06.512    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 17:10:06.515    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 17:11:06.776    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 17:11:06.780    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 17:11:06.818    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 17:11:06.820    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 17:15:59.775    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 17:15:59.779    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 17:15:59.813    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 17:15:59.815    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 17:30:05.661    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 17:30:05.667    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 17:30:05.708    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 17:30:05.712    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 17:36:16.975    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 17:36:16.990    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 17:36:17.035    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 17:36:17.037    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 17:38:59.423    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 17:38:59.428    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 17:38:59.474    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 17:38:59.482    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 17:40:16.251    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 17:40:16.256    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 17:40:16.292    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 17:40:16.294    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 17:40:31.564    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 17:40:31.567    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 17:40:31.600    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 17:40:31.602    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 17:42:51.356    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 17:42:51.361    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 17:42:51.400    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 17:42:51.402    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 18:39:02.597    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 18:39:02.602    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 18:39:02.645    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 18:39:02.648    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 18:40:17.619    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 18:40:17.623    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 18:40:17.657    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 18:40:17.658    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 18:49:21.505    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 18:49:21.509    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 18:49:21.563    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 18:49:21.566    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 18:50:33.209    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 18:50:33.215    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 18:50:33.243    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 18:50:33.246    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 19:22:26.287    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 19:22:26.291    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 19:22:26.326    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 19:22:26.329    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 19:23:55.076    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 19:23:55.099    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 19:23:55.145    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 19:23:55.146    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 19:24:34.239    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 19:24:34.245    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 19:24:34.280    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 19:24:34.282    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 20:21:34.289    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 20:21:34.293    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 20:21:34.328    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 20:21:34.331    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 20:27:34.758    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 20:27:34.762    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 20:27:34.795    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 20:27:34.798    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 20:30:26.442    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 20:30:26.447    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 20:30:26.483    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 20:30:26.485    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 20:32:15.119    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 20:32:15.123    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 20:32:15.156    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 20:32:15.158    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 20:33:28.660    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 20:33:28.665    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 20:33:28.701    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 20:33:28.702    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 20:38:53.908    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 20:38:53.914    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 20:38:53.960    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 20:38:53.963    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 20:42:35.822    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 20:42:35.828    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 20:42:35.864    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 20:42:35.866    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 20:53:05.924    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 20:53:05.931    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 20:53:05.970    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 20:53:05.973    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 20:54:29.870    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 20:54:29.875    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 20:54:29.913    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 20:54:29.915    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 20:57:07.314    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 20:57:07.320    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 20:57:07.357    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 20:57:07.359    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 20:57:33.410    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 20:57:33.415    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 20:57:33.451    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 20:57:33.453    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:14:07.779    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:14:07.785    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:14:07.822    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:14:07.824    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:16:31.088    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:16:31.096    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:16:31.134    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:16:31.136    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:16:52.392    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:16:52.398    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:16:52.435    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:16:52.437    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:17:51.062    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:17:51.068    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:17:51.101    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:17:51.104    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:19:02.264    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:19:02.270    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:19:02.307    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:19:02.309    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:33:26.368    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:33:26.374    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:33:26.408    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:33:26.410    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:35:27.609    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:35:27.614    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:35:27.646    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:35:27.648    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:36:56.927    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:36:56.933    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:36:56.971    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:36:56.972    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:37:11.352    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:37:11.357    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:37:11.392    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:37:11.394    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:39:03.593    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:39:03.600    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:39:03.645    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:39:03.647    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:43:07.633    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:43:07.640    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:43:07.671    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:43:07.673    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:44:30.508    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:44:30.514    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:44:30.555    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:44:30.558    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:44:59.082    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:44:59.087    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:44:59.120    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:44:59.122    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:45:58.412    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:45:58.419    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:45:58.460    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:45:58.461    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:46:24.396    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:46:24.402    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:46:24.437    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:46:24.440    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:47:42.992    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:47:42.998    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:47:43.032    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:47:43.034    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:54:05.501    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:54:05.506    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:54:05.546    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:54:05.547    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:54:31.449    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:54:31.453    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:54:31.489    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:54:31.491    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 21:55:01.173    info    C:/code/SRM/initialize/gorm.go:62    register table success
[srm]2023/08/26 - 21:55:01.178    info    C:/code/SRM/initialize/router.go:38    register swagger handler
[srm]2023/08/26 - 21:55:01.224    info    C:/code/SRM/initialize/router.go:86    router register success
[srm]2023/08/26 - 21:55:01.226    info    C:/code/SRM/core/server.go:36    server run success on     {"address": ":8889"}
model/purchase/purchase.go
New file
@@ -0,0 +1,27 @@
package purchase
import (
    "srm/global"
)
type Purchase struct {
    global.GVA_MODEL
    PurchaseTypeId int    `json:"purchaseTypeId" form:"purchaseType" gorm:"type:int(11);not null;default 0;comment:采购类型id"`   // 采购类型id
    SupplierId     int    `json:"supplierId" form:"supplierId" gorm:"type:int(11);not null;default 0;comment:供应商id"`          // 供应商id
    Name           string `json:"name" form:"name" gorm:"type:varchar(255);not null;default '';comment:采购名称"`                 // 采购名称
    Contact        string `json:"contact" form:"contact" gorm:"type:varchar(255);not null;default '';comment:联系人"`            // 联系人
    Phone          string `json:"phone" form:"phone" gorm:"type:varchar(255);not null;default '';comment:联系人电话"`              // 联系人电话
    SigningDate    string `json:"signingDate" form:"signingDate" gorm:"type:varchar(255);not null;default '';comment:签约日期"`   // 签约日期
    DeliveryDate   string `json:"deliveryDate" form:"deliveryDate" gorm:"type:varchar(255);not null;default '';comment:交付日期"` //交付日期
    Remark         string `json:"remark" form:"remark" gorm:"type:varchar(1000);not null;default '';comment:备注"`              //备注
    Status         string `json:"remark" form:"remark" gorm:"type:varchar(1000);not null;default '';comment:备注"`              //备注
}
type OrderStatus int
const (
// PurchaseOrderStatusConfirmed OrderStatus = 1 //已下单
// PurchaseOrderStatusReceived  OrderStatus = 2 //已到货
// PurchaseOrderStatus          OrderStatus = 3 //已入库
// PurchaseOrderStatusReceived  OrderStatus = 4 //已完成
)
model/purchase/purchase_products.go
New file
@@ -0,0 +1,16 @@
package purchase
import (
    "github.com/shopspring/decimal"
    "srm/global"
)
type PurchaseProducts struct {
    global.GVA_MODEL
    PurchaseId int             `json:"purchaseId" form:"purchaseType" gorm:"type:int(11);not null;default 0;comment:采购类型id"` // 采购id
    ProductId  int             `json:"productId" form:"supplierId" gorm:"type:int(11);not null;default 0;comment:供应商id"`     // 产品id
    Amount     decimal.Decimal `json:"amount" form:"amount" gorm:"type:decimal(12,2);not null;default 0;comment:采购数量"`       // 采购数量
    Price      decimal.Decimal `json:"price" form:"price" gorm:"type:decimal(12,2);not null;default 0.00;comment:采购单价"`      // 采购单价
    Total      decimal.Decimal `json:"total" form:"total" gorm:"type:decimal(12,2);not null;default 0.00;comment:采购总价"`      // 采购总价
    Remark     string          `json:"remark" form:"remark" gorm:"type:varchar(1000);not null; default '';comment:描述"`       //描述
}
model/purchase/request/purchase.go
New file
@@ -0,0 +1,18 @@
package purchaserequest
import (
    "srm/model/common/request"
    "srm/model/purchase"
    "time"
)
type PurchaseSearch struct {
    StartCreatedAt *time.Time `json:"startCreatedAt" form:"startCreatedAt"`
    EndCreatedAt   *time.Time `json:"endCreatedAt" form:"endCreatedAt"`
    request.PageInfo
}
type AddPurchase struct {
    Purchase    purchase.Purchase
    ProductList []*purchase.PurchaseProducts `json:"productList"`
}
model/purchase/response/purchase.go
New file
@@ -0,0 +1,8 @@
package response
import "srm/model/purchase"
type PurchaseResponse struct {
    Purchase    purchase.Purchase            `json:"purchase"`
    ProductList []*purchase.PurchaseProducts `json:"productList"`
}
router/purchase/purchase.go
New file
@@ -0,0 +1,19 @@
package purchase
import (
    "github.com/gin-gonic/gin"
    "srm/api/v1/purchase"
)
func InitPurchaseRouter(Router *gin.RouterGroup) {
    purchaseRouter := Router.Group("purchase")
    purchaseRouterWithoutRecord := Router.Group("purchase")
    PurchaseApi := purchase.PurchaseApi{}
    {
        purchaseRouter.POST("purchase", PurchaseApi.CreatePurchase)                  // 创建采购单
        purchaseRouter.PUT("purchase", PurchaseApi.UpdatePurchase)                   // 更新采购单
        purchaseRouter.DELETE("purchase/:id", PurchaseApi.DeletePurchase)            // 删除采购单
        purchaseRouterWithoutRecord.GET("purchase/:id", PurchaseApi.GetPurchase)     // 获取单一采购单信息
        purchaseRouterWithoutRecord.GET("purchaseList", PurchaseApi.GetPurchaseList) // 获取采购单列表
    }
}
service/purchase/purchase.go
New file
@@ -0,0 +1,140 @@
package purchase
import (
    "github.com/spf13/cast"
    "gorm.io/gorm"
    "srm/global"
    "srm/model/common/request"
    "srm/model/purchase"
    purchaserequest "srm/model/purchase/request"
)
type PurchaseService struct{}
func NewPurchaseService() *PurchaseService {
    return &PurchaseService{}
}
//@function: CreatePurchase
//@description: 创建采购单
//@param: params *purchaserequest.AddPurchase
//@return: err error
func (exa *PurchaseService) CreatePurchase(params purchaserequest.AddPurchase) (err error) {
    err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
        err = global.GVA_DB.Create(&params.Purchase).Error
        if err != nil {
            return err
        }
        for _, product := range params.ProductList {
            product.PurchaseId = cast.ToInt(params.Purchase.ID)
        }
        return global.GVA_DB.Create(params.ProductList).Error
    })
    return err
}
//@function: DeletePurchase
//@description: 删除采购单
//@param: id uint
//@return: err error
func (exa *PurchaseService) DeletePurchase(id uint) (err error) {
    err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
        err = global.GVA_DB.Where("id = ?", id).Delete(&purchase.Purchase{}).Error
        if err != nil {
            return err
        }
        return global.GVA_DB.Where("purchase_id = ?", id).Delete(&purchase.PurchaseProducts{}).Error
    })
    return err
}
//@function: UpdatePurchase
//@description: 更新采购单
//@param: params *purchaserequest.AddPurchase
//@return: err error
func (exa *PurchaseService) UpdatePurchase(params *purchaserequest.AddPurchase) (err error) {
    err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
        err = global.GVA_DB.Updates(params.Purchase).Error
        if err != nil {
            return err
        }
        err = global.GVA_DB.Where("purchase_id = ?", params.Purchase.ID).Delete(&purchase.PurchaseProducts{}).Error
        if err != nil {
            return err
        }
        for _, product := range params.ProductList {
            product.ID = 0
            product.PurchaseId = cast.ToInt(params.Purchase.ID)
        }
        return global.GVA_DB.Create(params.ProductList).Error
    })
    return err
}
//@function: GetPurchase
//@description: 获取采购单信息
//@param: id uint
//@return: purchase model.Purchase, err error
func (exa *PurchaseService) GetPurchase(id uint) (purchase purchase.Purchase, err error) {
    err = global.GVA_DB.Where("id = ?", id).First(&purchase).Error
    return
}
//@function: GetPurchaseList
//@description: 分页获取采购单列表
//@param: info request.PageInfo
//@return: list interface{}, total int64, err error
func (exa *PurchaseService) GetPurchaseList(info request.PageInfo) (list interface{}, total int64, err error) {
    limit := info.PageSize
    offset := info.PageSize * (info.Page - 1)
    db := global.GVA_DB.Model(&purchase.Purchase{})
    if info.Keyword != "" {
        db.Distinct("purchases.id").Joins("left join purchase_products on purchase_products.purchase_id = purchases.id").
            Joins("left join Product on Product.Id = purchase_products.product_id").
            Joins("left join supplier on supplier.Id = purchases.supplier_id").
            Where("purchases.name like ?", "%"+info.Keyword+"%").
            Or("Product.name like ?", "%"+info.Keyword+"%").
            Or("supplier.name like ?", "%"+info.Keyword+"%")
    }
    var purchaseList []purchase.Purchase
    err = db.Count(&total).Error
    if err != nil {
        return purchaseList, total, err
    }
    err = db.Limit(limit).Offset(offset).Find(&purchaseList).Error
    return purchaseList, total, err
}
//@function: GetPurchaseProductList
//@description: 分页获取采购单产品列表
//@param: purchaseId int
//@return: list interface{},  err error
func (exa *PurchaseService) GetPurchaseProductList(purchaseId uint) (list []*purchase.PurchaseProducts, err error) {
    db := global.GVA_DB.Model(&purchase.PurchaseProducts{})
    list = make([]*purchase.PurchaseProducts, 0)
    err = db.Where("purchase_id = ?", purchaseId).Find(&list).Error
    return list, err
}
//@function: Submit
//@description: 提交采购单
//@param: id uint
//@return: err error
func (exa *PurchaseService) Submit(id uint) (err error) {
    err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
        err = global.GVA_DB.Where("id = ?", id).Model(&purchase.Purchase{}).Updates(map[string]interface{}{"status": 1}).Error
        if err != nil {
            return err
        }
        return global.GVA_DB.Where("purchase_id = ?", id).Delete(&purchase.PurchaseProducts{}).Error
    })
    return err
}