wangpengfei
2023-08-09 30ecf91d875042d461457cdade7b55113a8ec4ab
Merge branch 'master' into fly
6个文件已添加
16个文件已修改
1976 ■■■■ 已修改文件
api/v1/file.go 102 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/product.go 107 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
conf/aps-crm.json 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
conf/config.go 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 324 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 324 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 215 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
go.mod 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
go.sum 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/file.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/common.go 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/file.go 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/product.go 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/response/common.go 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
proto/product.proto 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
proto/product/product.pb.go 565 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
proto/product/product_grpc.pb.go 146 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/file.go 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/index.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/product.go 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/file.go 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/file.go
@@ -3,7 +3,6 @@
import (
    "aps_crm/model"
    "aps_crm/model/request"
    "aps_crm/model/response"
    "aps_crm/pkg/contextx"
    "aps_crm/pkg/ecode"
    "aps_crm/pkg/httpx"
@@ -11,6 +10,7 @@
    "aps_crm/utils/upload"
    "github.com/gin-gonic/gin"
    "github.com/spf13/cast"
    "io"
    "os"
    "path/filepath"
)
@@ -131,28 +131,100 @@
//    ctx.Ok()
//}
// List
// @Tags        附件管理
// @Summary    获取附件列表
//// List
//// @Tags        附件管理
//// @Summary    获取附件列表
//// @Produce    application/json
//// @Param        object    query        request.GetFileList    true    "参数"
//// @Success    200    {object}    response.ListResponse{data=[]model.File}
//// @Router        /api/file/list [get]
//func (s *FileApi) List(c *gin.Context) {
//    var params request.GetFileList
//    ctx, ok := contextx.NewContext(c, &params)
//    if !ok {
//        return
//    }
//
//    file, total, errCode := service.NewFileService().GetFileList()
//    if errCode != ecode.OK {
//        ctx.Fail(errCode)
//        return
//    }
//
//    ctx.OkWithDetailed(response.ListResponse{
//        Data:  file,
//        Count: total,
//    })
//}
// Download
// @Tags    附件管理
// @Summary    附件下载
// @Produce    application/json
// @Param        object    query        request.GetFileList    true    "参数"
// @Success    200    {object}    response.ListResponse{data=[]model.File}
// @Router        /api/file/list [get]
func (s *FileApi) List(c *gin.Context) {
    var params request.GetFileList
// @Param        object    body        request.DownloadFile    true    "参数"
// @Success    200        {object}    contextx.Response{}
// @Router        /api/file/download [post]
func (s *FileApi) Download(c *gin.Context) {
    var params request.DownloadFile
    ctx, ok := contextx.NewContext(c, &params)
    if !ok {
        return
    }
    file, total, errCode := service.NewFileService().GetFileList()
    file, errCode := service.NewFileService().GetFile(params.Id)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    if file.SourceType != params.SourceType || file.SourceId != params.SourceId || file.Key != params.Key {
        ctx.FailWithMsg(ecode.ParamsErr, "文件不存在")
        return
    }
    f, err := os.Open(file.FilePath)
    if err != nil {
        ctx.FailWithMsg(ecode.ParamsErr, "文件不存在")
        return
    }
    file.DownloadCount++
    service.NewFileService().UpdateFile(file)
    ctx.OkWithDetailed(response.ListResponse{
        Data:  file,
        Count: total,
    })
    data, err := io.ReadAll(f)
    c.Writer.Header().Set("Content-Type", "application/octect-stream")
    c.Writer.Header().Set("Content-Disposition", "attachment;filename="+file.Name)
    c.Writer.Write(data)
}
// Preview
// @Tags    附件管理
// @Summary    附件预览
// @Produce    application/json
// @Param        object    body        request.DownloadFile    true    "参数"
// @Success    200        {object}    contextx.Response{}
// @Router        /api/file/preview [post]
func (s *FileApi) Preview(c *gin.Context) {
    var params request.DownloadFile
    ctx, ok := contextx.NewContext(c, &params)
    if !ok {
        return
    }
    file, errCode := service.NewFileService().GetFile(params.Id)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    if file.SourceType != params.SourceType || file.SourceId != params.SourceId || file.Key != params.Key {
        ctx.FailWithMsg(ecode.ParamsErr, "文件不存在")
        return
    }
    f, err := os.Open(file.FilePath)
    if err != nil {
        ctx.FailWithMsg(ecode.ParamsErr, "文件不存在")
        return
    }
    file.PreviewCount++
    service.NewFileService().UpdateFile(file)
    data, err := io.ReadAll(f)
    c.Writer.Header().Set("Content-Type", "application/octect-stream")
    c.Writer.Header().Set("Content-Disposition", "attachment;filename="+file.Name)
    c.Writer.Write(data)
}
api/v1/product.go
New file
@@ -0,0 +1,107 @@
package v1
import (
    "aps_crm/conf"
    "aps_crm/model/request"
    "aps_crm/model/response"
    "aps_crm/pkg/contextx"
    "aps_crm/pkg/ecode"
    "aps_crm/pkg/logx"
    "aps_crm/proto/product"
    "fmt"
    "github.com/gin-gonic/gin"
    "github.com/spf13/cast"
    "google.golang.org/grpc"
    "google.golang.org/grpc/credentials/insecure"
)
type ProductApi struct{}
var (
    productServiceConn *grpc.ClientConn
)
func InitProductServiceConn() {
    fmt.Println(conf.Conf.GrpcServiceAddr.Aps)
    var err error
    productServiceConn, err = grpc.Dial(conf.Conf.GrpcServiceAddr.Aps, grpc.WithTransportCredentials(insecure.NewCredentials()))
    if err != nil {
        logx.Errorf("grpc dial product service error: %v", err.Error())
        return
    }
}
// List
//
// @Tags        产品
// @Summary    获取产品列表
// @Produce    application/json
// @Param        object    query        request.GetProductList    true    "参数"
// @Success    200    {object}    response.ListResponse{data=[]product.Product}
//
//    @Router        /api/product/list [get]
func (ci *ProductApi) List(c *gin.Context) {
    var params request.GetProductList
    ctx, ok := contextx.NewContext(c, &params)
    if !ok {
        return
    }
    if !params.Check() {
        ctx.FailWithMsg(ecode.ParamsErr, "page, pageSize超出范围")
        return
    }
    cli := product.NewProductServiceClient(productServiceConn)
    getProductListResponse, err := cli.GetProductList(ctx.GetCtx(), &product.GetProductListRequest{
        Page:          cast.ToInt32(params.Page),
        PageSize:      cast.ToInt32(params.PageSize),
        ProductNumber: params.ProductNumber,
        ProductName:   params.ProductName,
    })
    if err != nil {
        logx.Errorf("GetProductList err: %v", err.Error())
        ctx.FailWithMsg(ecode.UnknownErr, "内部错误")
        return
    }
    if getProductListResponse.Code != 0 {
        logx.Errorf("GetProductList err: %v", err.Error())
        ctx.FailWithMsg(ecode.UnknownErr, "内部错误")
        return
    }
    ctx.OkWithDetailed(response.ListResponse{
        Data:  getProductListResponse.List,
        Count: getProductListResponse.Total,
    })
}
// Info
// @Tags        产品
// @Summary    获取产品详情
// @Produce    application/json
// @Param    productNumber query string         true    "参数"
// @Success    200     {object} contextx.Response{data=product.Product}    "成功"
// @Router        /api/product/info [get]
func (ci *ProductApi) Info(c *gin.Context) {
    ctx, ok := contextx.NewContext(c, nil)
    if !ok {
        return
    }
    // 获取产品ID
    productId := c.Query("productNumber")
    cli := product.NewProductServiceClient(productServiceConn)
    getProductInfoResponse, err := cli.GetProductInfo(ctx.GetCtx(), &product.GetProductInfoRequest{ProductId: productId})
    if err != nil {
        logx.Errorf("GetProductInfo err: %v", err.Error())
        ctx.FailWithMsg(ecode.UnknownErr, "内部错误")
        return
    }
    if getProductInfoResponse.Code != 0 {
        logx.Errorf("GetProductInfo err: %v", err.Error())
        ctx.FailWithMsg(ecode.UnknownErr, "内部错误")
        return
    }
    ctx.OkWithDetailed(getProductInfoResponse.Data)
}
conf/aps-crm.json
@@ -40,6 +40,15 @@
    "ExpiresTime": "7d",
    "BufferTime": "1d",
    "Issuer": "qmPlus"
  },
  "jwt2": {
    "SigningKey": "327a9457-899a-481e-8b30-58cc97e5b808",
    "ExpiresTime": "7d",
    "BufferTime": "1d",
    "Issuer": "qmPlus"
  },
  "GrpcServiceAddr": {
    "Aps": "192.168.20.120:9091"
  }
}
conf/config.go
@@ -38,6 +38,13 @@
        Issuer      string // 签发者
    }
    JWT2 struct {
        SigningKey  string // jwt签名
        ExpiresTime string // 过期时间
        BufferTime  string // 缓冲时间
        Issuer      string // 签发者
    }
    System struct {
        Env           string // 环境值 develop test public
        Port          int    // 端口
@@ -48,6 +55,10 @@
        LimitTimeIP   int
        RouterPrefix  string // 路由前缀
        SudoPassword  string // sudo密码
    }
    GrpcServiceAddr struct {
        Aps string // jwt签名
    }
    config struct {
@@ -68,6 +79,8 @@
        // JWT配置
        JWT JWT
        GrpcServiceAddr GrpcServiceAddr
    }
)
@@ -117,5 +130,6 @@
    log.Printf("   Mysql:                 %+v", Conf.Mysql)
    log.Printf("   Captcha:               %+v", Conf.Captcha)
    log.Printf("   JWT:                   %+v", Conf.JWT)
    log.Printf("   GrpcServiceAddr:       %+v", Conf.GrpcServiceAddr)
    log.Println("......................................................")
}
docs/docs.go
@@ -2727,76 +2727,61 @@
                }
            }
        },
        "/api/file/list": {
            "get": {
        "/api/file/download": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "附件管理"
                ],
                "summary": "获取附件列表",
                "summary": "附件下载",
                "parameters": [
                    {
                        "type": "string",
                        "name": "keyword",
                        "in": "query"
                    },
                    {
                        "enum": [
                            ""
                        ],
                        "type": "string",
                        "x-enum-varnames": [
                            "FileKeywordCustomerName"
                        ],
                        "name": "keywordType",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "页码",
                        "name": "page",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "每页大小",
                        "name": "pageSize",
                        "in": "query"
                    },
                    {
                        "enum": [
                            ""
                        ],
                        "type": "string",
                        "x-enum-varnames": [
                            "FileQueryClassExpireLessThen60Days"
                        ],
                        "name": "queryClass",
                        "in": "query"
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.DownloadFile"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/response.ListResponse"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/model.File"
                                            }
                                        }
                                    }
                                }
                            ]
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/file/preview": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "附件管理"
                ],
                "summary": "附件预览",
                "parameters": [
                    {
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.DownloadFile"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
@@ -4766,6 +4751,106 @@
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/product/info": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "产品"
                ],
                "summary": "获取产品详情",
                "parameters": [
                    {
                        "type": "string",
                        "description": "参数",
                        "name": "productNumber",
                        "in": "query",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/contextx.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/product.Product"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api/product/list": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "产品"
                ],
                "summary": "获取产品列表",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "页码",
                        "name": "page",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "每页大小",
                        "name": "pageSize",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "产品名称",
                        "name": "productName",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "产品编码",
                        "name": "productNumber",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/response.ListResponse"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/product.Product"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
@@ -9470,24 +9555,6 @@
                "FaqQueryClassExpireLessThen60Days"
            ]
        },
        "constvar.FileKeywordType": {
            "type": "string",
            "enum": [
                ""
            ],
            "x-enum-varnames": [
                "FileKeywordCustomerName"
            ]
        },
        "constvar.FileQueryClass": {
            "type": "string",
            "enum": [
                ""
            ],
            "x-enum-varnames": [
                "FileQueryClassExpireLessThen60Days"
            ]
        },
        "constvar.InvoiceKeywordType": {
            "type": "string",
            "enum": [
@@ -10269,50 +10336,6 @@
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "model.File": {
            "type": "object",
            "properties": {
                "bucket": {
                    "description": "对象存储bucket",
                    "type": "string"
                },
                "downloadCount": {
                    "description": "下次次数",
                    "type": "integer"
                },
                "filePath": {
                    "description": "文件路径",
                    "type": "string"
                },
                "fileType": {
                    "description": "文件类型",
                    "type": "string"
                },
                "key": {
                    "description": "对象存储key",
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "previewCount": {
                    "description": "预览次数",
                    "type": "integer"
                },
                "size": {
                    "description": "文件大小",
                    "type": "integer"
                },
                "sourceId": {
                    "description": "来源id",
                    "type": "integer"
                },
                "sourceType": {
                    "description": "附件来源",
                    "type": "string"
                }
            }
@@ -11799,6 +11822,44 @@
                    "type": "string"
                },
                "uuid": {
                    "type": "string"
                }
            }
        },
        "product.Product": {
            "type": "object",
            "properties": {
                "Amount": {
                    "description": "库存剩余量",
                    "type": "number"
                },
                "IsSale": {
                    "description": "是否销售",
                    "type": "boolean"
                },
                "MaterialMode": {
                    "description": "物料类型",
                    "type": "string"
                },
                "MinInventory": {
                    "description": "安全库存",
                    "type": "integer"
                },
                "Name": {
                    "type": "string"
                },
                "Number": {
                    "type": "string"
                },
                "PurchaseType": {
                    "description": "采购类型",
                    "type": "string"
                },
                "SalePrice": {
                    "description": "销售价格",
                    "type": "number"
                },
                "Unit": {
                    "type": "string"
                }
            }
@@ -13516,6 +13577,33 @@
                }
            }
        },
        "request.DownloadFile": {
            "type": "object",
            "required": [
                "id",
                "key",
                "sourceId",
                "sourceType"
            ],
            "properties": {
                "id": {
                    "description": "附件id",
                    "type": "integer"
                },
                "key": {
                    "description": "附件存储key",
                    "type": "string"
                },
                "sourceId": {
                    "description": "来源id",
                    "type": "integer"
                },
                "sourceType": {
                    "description": "附件来源",
                    "type": "string"
                }
            }
        },
        "request.FollowRecord": {
            "type": "object",
            "properties": {
docs/swagger.json
@@ -2715,76 +2715,61 @@
                }
            }
        },
        "/api/file/list": {
            "get": {
        "/api/file/download": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "附件管理"
                ],
                "summary": "获取附件列表",
                "summary": "附件下载",
                "parameters": [
                    {
                        "type": "string",
                        "name": "keyword",
                        "in": "query"
                    },
                    {
                        "enum": [
                            ""
                        ],
                        "type": "string",
                        "x-enum-varnames": [
                            "FileKeywordCustomerName"
                        ],
                        "name": "keywordType",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "页码",
                        "name": "page",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "每页大小",
                        "name": "pageSize",
                        "in": "query"
                    },
                    {
                        "enum": [
                            ""
                        ],
                        "type": "string",
                        "x-enum-varnames": [
                            "FileQueryClassExpireLessThen60Days"
                        ],
                        "name": "queryClass",
                        "in": "query"
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.DownloadFile"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/response.ListResponse"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/model.File"
                                            }
                                        }
                                    }
                                }
                            ]
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/file/preview": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "附件管理"
                ],
                "summary": "附件预览",
                "parameters": [
                    {
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.DownloadFile"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
@@ -4754,6 +4739,106 @@
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/product/info": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "产品"
                ],
                "summary": "获取产品详情",
                "parameters": [
                    {
                        "type": "string",
                        "description": "参数",
                        "name": "productNumber",
                        "in": "query",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/contextx.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/product.Product"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api/product/list": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "产品"
                ],
                "summary": "获取产品列表",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "页码",
                        "name": "page",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "每页大小",
                        "name": "pageSize",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "产品名称",
                        "name": "productName",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "产品编码",
                        "name": "productNumber",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/response.ListResponse"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/product.Product"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
@@ -9458,24 +9543,6 @@
                "FaqQueryClassExpireLessThen60Days"
            ]
        },
        "constvar.FileKeywordType": {
            "type": "string",
            "enum": [
                ""
            ],
            "x-enum-varnames": [
                "FileKeywordCustomerName"
            ]
        },
        "constvar.FileQueryClass": {
            "type": "string",
            "enum": [
                ""
            ],
            "x-enum-varnames": [
                "FileQueryClassExpireLessThen60Days"
            ]
        },
        "constvar.InvoiceKeywordType": {
            "type": "string",
            "enum": [
@@ -10257,50 +10324,6 @@
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "model.File": {
            "type": "object",
            "properties": {
                "bucket": {
                    "description": "对象存储bucket",
                    "type": "string"
                },
                "downloadCount": {
                    "description": "下次次数",
                    "type": "integer"
                },
                "filePath": {
                    "description": "文件路径",
                    "type": "string"
                },
                "fileType": {
                    "description": "文件类型",
                    "type": "string"
                },
                "key": {
                    "description": "对象存储key",
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "previewCount": {
                    "description": "预览次数",
                    "type": "integer"
                },
                "size": {
                    "description": "文件大小",
                    "type": "integer"
                },
                "sourceId": {
                    "description": "来源id",
                    "type": "integer"
                },
                "sourceType": {
                    "description": "附件来源",
                    "type": "string"
                }
            }
@@ -11787,6 +11810,44 @@
                    "type": "string"
                },
                "uuid": {
                    "type": "string"
                }
            }
        },
        "product.Product": {
            "type": "object",
            "properties": {
                "Amount": {
                    "description": "库存剩余量",
                    "type": "number"
                },
                "IsSale": {
                    "description": "是否销售",
                    "type": "boolean"
                },
                "MaterialMode": {
                    "description": "物料类型",
                    "type": "string"
                },
                "MinInventory": {
                    "description": "安全库存",
                    "type": "integer"
                },
                "Name": {
                    "type": "string"
                },
                "Number": {
                    "type": "string"
                },
                "PurchaseType": {
                    "description": "采购类型",
                    "type": "string"
                },
                "SalePrice": {
                    "description": "销售价格",
                    "type": "number"
                },
                "Unit": {
                    "type": "string"
                }
            }
@@ -13504,6 +13565,33 @@
                }
            }
        },
        "request.DownloadFile": {
            "type": "object",
            "required": [
                "id",
                "key",
                "sourceId",
                "sourceType"
            ],
            "properties": {
                "id": {
                    "description": "附件id",
                    "type": "integer"
                },
                "key": {
                    "description": "附件存储key",
                    "type": "string"
                },
                "sourceId": {
                    "description": "来源id",
                    "type": "integer"
                },
                "sourceType": {
                    "description": "附件来源",
                    "type": "string"
                }
            }
        },
        "request.FollowRecord": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -46,18 +46,6 @@
    type: string
    x-enum-varnames:
    - FaqQueryClassExpireLessThen60Days
  constvar.FileKeywordType:
    enum:
    - ""
    type: string
    x-enum-varnames:
    - FileKeywordCustomerName
  constvar.FileQueryClass:
    enum:
    - ""
    type: string
    x-enum-varnames:
    - FileQueryClassExpireLessThen60Days
  constvar.InvoiceKeywordType:
    enum:
    - ""
@@ -601,38 +589,6 @@
      id:
        type: integer
      name:
        type: string
    type: object
  model.File:
    properties:
      bucket:
        description: 对象存储bucket
        type: string
      downloadCount:
        description: 下次次数
        type: integer
      filePath:
        description: 文件路径
        type: string
      fileType:
        description: 文件类型
        type: string
      key:
        description: 对象存储key
        type: string
      name:
        type: string
      previewCount:
        description: 预览次数
        type: integer
      size:
        description: 文件大小
        type: integer
      sourceId:
        description: 来源id
        type: integer
      sourceType:
        description: 附件来源
        type: string
    type: object
  model.FollowRecord:
@@ -1625,6 +1581,33 @@
      username:
        type: string
      uuid:
        type: string
    type: object
  product.Product:
    properties:
      Amount:
        description: 库存剩余量
        type: number
      IsSale:
        description: 是否销售
        type: boolean
      MaterialMode:
        description: 物料类型
        type: string
      MinInventory:
        description: 安全库存
        type: integer
      Name:
        type: string
      Number:
        type: string
      PurchaseType:
        description: 采购类型
        type: string
      SalePrice:
        description: 销售价格
        type: number
      Unit:
        type: string
    type: object
  request.AddAccountId:
@@ -2788,6 +2771,26 @@
        items:
          type: integer
        type: array
    type: object
  request.DownloadFile:
    properties:
      id:
        description: 附件id
        type: integer
      key:
        description: 附件存储key
        type: string
      sourceId:
        description: 来源id
        type: integer
      sourceType:
        description: 附件来源
        type: string
    required:
    - id
    - key
    - sourceId
    - sourceType
    type: object
  request.FollowRecord:
    properties:
@@ -6960,49 +6963,42 @@
      summary: 删除附件
      tags:
      - 附件管理
  /api/file/list:
    get:
  /api/file/download:
    post:
      parameters:
      - in: query
        name: keyword
        type: string
      - enum:
        - ""
        in: query
        name: keywordType
        type: string
        x-enum-varnames:
        - FileKeywordCustomerName
      - description: 页码
        in: query
        name: page
        type: integer
      - description: 每页大小
        in: query
        name: pageSize
        type: integer
      - enum:
        - ""
        in: query
        name: queryClass
        type: string
        x-enum-varnames:
        - FileQueryClassExpireLessThen60Days
      - description: 参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.DownloadFile'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            allOf:
            - $ref: '#/definitions/response.ListResponse'
            - properties:
                data:
                  items:
                    $ref: '#/definitions/model.File'
                  type: array
              type: object
      summary: 获取附件列表
            $ref: '#/definitions/contextx.Response'
      summary: 附件下载
      tags:
      - 附件管理
  /api/file/preview:
    post:
      parameters:
      - description: 参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.DownloadFile'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
      summary: 附件预览
      tags:
      - 附件管理
  /api/followRecord/add:
@@ -8213,6 +8209,65 @@
      summary: 更新优先级别
      tags:
      - 优先级别管理
  /api/product/info:
    get:
      parameters:
      - description: 参数
        in: query
        name: productNumber
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            allOf:
            - $ref: '#/definitions/contextx.Response'
            - properties:
                data:
                  $ref: '#/definitions/product.Product'
              type: object
      summary: 获取产品详情
      tags:
      - 产品
  /api/product/list:
    get:
      parameters:
      - description: 页码
        in: query
        name: page
        type: integer
      - description: 每页大小
        in: query
        name: pageSize
        type: integer
      - description: 产品名称
        in: query
        name: productName
        type: string
      - description: 产品编码
        in: query
        name: productNumber
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            allOf:
            - $ref: '#/definitions/response.ListResponse'
            - properties:
                data:
                  items:
                    $ref: '#/definitions/product.Product'
                  type: array
              type: object
      summary: 获取产品列表
      tags:
      - 产品
  /api/province/add:
    post:
      parameters:
go.mod
@@ -35,6 +35,8 @@
    moul.io/zapgorm2 v1.3.0
)
require google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e // indirect
require (
    github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
    github.com/KyleBanks/depth v1.2.1 // indirect
@@ -100,13 +102,14 @@
    go.uber.org/multierr v1.10.0 // indirect
    golang.org/x/arch v0.3.0 // indirect
    golang.org/x/image v0.5.0 // indirect
    golang.org/x/net v0.10.0 // indirect
    golang.org/x/net v0.14.0 // indirect
    golang.org/x/sys v0.11.0 // indirect
    golang.org/x/text v0.12.0 // indirect
    golang.org/x/tools v0.9.1 // indirect
    google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
    google.golang.org/grpc v1.55.0 // indirect
    google.golang.org/protobuf v1.30.0 // indirect
    google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect
    google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 // indirect
    google.golang.org/grpc v1.57.0
    google.golang.org/protobuf v1.31.0
    gopkg.in/ini.v1 v1.67.0 // indirect
    gopkg.in/yaml.v3 v3.0.1 // indirect
    gorm.io/driver/postgres v1.5.2 // indirect
go.sum
@@ -501,8 +501,9 @@
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -717,8 +718,12 @@
google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A=
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU=
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 h1:L6iMMGrtzgHsWofoFcihmDEMYeDR9KN/ThbPWGrh++g=
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5/go.mod h1:oH/ZOT02u4kWEp7oYBGYFFkCdKS/uYR9Z7+0/xuuFp8=
google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e h1:z3vDksarJxsAKM5dmEGv0GHwE2hKJ096wZra71Vs4sw=
google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 h1:wukfNtZmZUurLN/atp2hiIeTKn7QJWIQdHzqmsOnAOk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
@@ -735,8 +740,8 @@
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8=
google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag=
google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8=
google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw=
google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@@ -750,8 +755,8 @@
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
main.go
@@ -1,6 +1,7 @@
package main
import (
    v1 "aps_crm/api/v1"
    "aps_crm/conf"
    "aps_crm/initialize"
    "aps_crm/model"
@@ -43,6 +44,9 @@
        ReadTimeout:  5 * time.Second,
        WriteTimeout: 5 * time.Second,
    }
    go v1.InitProductServiceConn()
    logx.Error(server.ListenAndServe().Error())
}
model/file.go
@@ -13,9 +13,9 @@
    File struct {
        Name          string `gorm:"name" json:"name"`
        Size          int64  `gorm:"size" json:"size"`                    // 文件大小
        FilePath      string `gorm:"file_path" json:"filePath"`           // 文件路径
        FilePath      string `gorm:"file_path" json:"-"`                  // 文件路径
        Key           string `gorm:"key" json:"key"`                      // 对象存储key
        Bucket        string `gorm:"bucket" json:"bucket"`                // 对象存储bucket
        Bucket        string `gorm:"bucket" json:"-"`                     // 对象存储bucket
        DownloadCount int    `gorm:"download_count" json:"downloadCount"` // 下次次数
        PreviewCount  int    `gorm:"preview_count" json:"previewCount"`   // 预览次数
        FileType      string `gorm:"file_type" json:"fileType"`           // 文件类型
model/request/common.go
@@ -12,3 +12,13 @@
type GetByUserId struct {
    UserId string `json:"userId"` // 用户ID
}
func (p PageInfo) Check() bool {
    if p.Page <= 0 {
        return false
    }
    if p.PageSize <= 0 || p.PageSize > 500 {
        return false
    }
    return true
}
model/request/file.go
@@ -21,3 +21,10 @@
    KeywordType constvar.FileKeywordType `json:"keywordType"  form:"keywordType"`
    Keyword     string                   `json:"keyword" form:"keyword"`
}
type DownloadFile struct {
    SourceType string `json:"sourceType" form:"sourceType" binding:"required"` // 附件来源
    SourceId   int    `json:"sourceId" form:"sourceId"  binding:"required"`    // 来源id
    Id         uint   `json:"id" form:"id"  binding:"required"`                // 附件id
    Key        string `json:"key" form:"key"  binding:"required"`              // 附件存储key
}
model/request/product.go
New file
@@ -0,0 +1,7 @@
package request
type GetProductList struct {
    PageInfo
    ProductNumber string `json:"productNumber" form:"productNumber"` // 产品编码
    ProductName   string `json:"productName" form:"productName"`     // 产品名称
}
model/response/common.go
@@ -1,15 +1,21 @@
package response
type PageResult struct {
    List     interface{} `json:"list"`
    Total    int64       `json:"total"`
    Page     int         `json:"page"`
    PageSize int         `json:"pageSize"`
}
type ListResponse struct {
    Code  int         `json:"code"`
    Msg   string      `json:"msg"`
    Data  interface{} `json:"data"`
    Count int64       `json:"count"`
}
package response
type PageResult struct {
    List     interface{} `json:"list"`
    Total    int64       `json:"total"`
    Page     int         `json:"page"`
    PageSize int         `json:"pageSize"`
}
type ListResponse struct {
    Code  int         `json:"code"`
    Msg   string      `json:"msg"`
    Data  interface{} `json:"data"`
    Count int64       `json:"count"`
}
type Response struct {
    Code int         `json:"code"`
    Msg  string      `json:"msg"`
    Data interface{} `json:"data"`
}
proto/product.proto
New file
@@ -0,0 +1,43 @@
syntax = "proto3";
option go_package = "./product";
service productService {
  rpc GetProductInfo(GetProductInfoRequest) returns(GetProductInfoResponse) {}
  rpc GetProductList(GetProductListRequest) returns(GetProductListResponse) {}
}
message GetProductInfoRequest{
  string ProductId = 1; //产品id
}
message GetProductInfoResponse{
  int32   Code  = 1;
  string  Msg   = 2;
  Product Data = 3;
}
message Product {
  string Number = 1;
  string Name = 2;
  string  Unit = 3;
  bool IsSale = 4; //是否销售
  float SalePrice = 5; //销售价格
  float Amount = 6;//库存剩余量
  int32 MinInventory = 7;//安全库存
  string MaterialMode = 8; //物料类型
  string PurchaseType = 9;//采购类型
}
message GetProductListRequest{
  int32 page = 1;
  int32 pageSize = 2;
  string ProductNumber = 3;
  string ProductName = 4;
}
message GetProductListResponse{
  int32   Code  = 1;
  string  Msg   = 2;
  repeated Product List = 3;
  int64 Total = 4;
}
proto/product/product.pb.go
New file
@@ -0,0 +1,565 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
//     protoc-gen-go v1.31.0
//     protoc        v3.19.0
// source: product.proto
package product
import (
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    sync "sync"
)
const (
    // Verify that this generated code is sufficiently up-to-date.
    _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
    // Verify that runtime/protoimpl is sufficiently up-to-date.
    _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type GetProductInfoRequest struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields
    ProductId string `protobuf:"bytes,1,opt,name=ProductId,proto3" json:"ProductId,omitempty"` //产品id
}
func (x *GetProductInfoRequest) Reset() {
    *x = GetProductInfoRequest{}
    if protoimpl.UnsafeEnabled {
        mi := &file_product_proto_msgTypes[0]
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        ms.StoreMessageInfo(mi)
    }
}
func (x *GetProductInfoRequest) String() string {
    return protoimpl.X.MessageStringOf(x)
}
func (*GetProductInfoRequest) ProtoMessage() {}
func (x *GetProductInfoRequest) ProtoReflect() protoreflect.Message {
    mi := &file_product_proto_msgTypes[0]
    if protoimpl.UnsafeEnabled && x != nil {
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        if ms.LoadMessageInfo() == nil {
            ms.StoreMessageInfo(mi)
        }
        return ms
    }
    return mi.MessageOf(x)
}
// Deprecated: Use GetProductInfoRequest.ProtoReflect.Descriptor instead.
func (*GetProductInfoRequest) Descriptor() ([]byte, []int) {
    return file_product_proto_rawDescGZIP(), []int{0}
}
func (x *GetProductInfoRequest) GetProductId() string {
    if x != nil {
        return x.ProductId
    }
    return ""
}
type GetProductInfoResponse struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields
    Code int32    `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"`
    Msg  string   `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
    Data *Product `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"`
}
func (x *GetProductInfoResponse) Reset() {
    *x = GetProductInfoResponse{}
    if protoimpl.UnsafeEnabled {
        mi := &file_product_proto_msgTypes[1]
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        ms.StoreMessageInfo(mi)
    }
}
func (x *GetProductInfoResponse) String() string {
    return protoimpl.X.MessageStringOf(x)
}
func (*GetProductInfoResponse) ProtoMessage() {}
func (x *GetProductInfoResponse) ProtoReflect() protoreflect.Message {
    mi := &file_product_proto_msgTypes[1]
    if protoimpl.UnsafeEnabled && x != nil {
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        if ms.LoadMessageInfo() == nil {
            ms.StoreMessageInfo(mi)
        }
        return ms
    }
    return mi.MessageOf(x)
}
// Deprecated: Use GetProductInfoResponse.ProtoReflect.Descriptor instead.
func (*GetProductInfoResponse) Descriptor() ([]byte, []int) {
    return file_product_proto_rawDescGZIP(), []int{1}
}
func (x *GetProductInfoResponse) GetCode() int32 {
    if x != nil {
        return x.Code
    }
    return 0
}
func (x *GetProductInfoResponse) GetMsg() string {
    if x != nil {
        return x.Msg
    }
    return ""
}
func (x *GetProductInfoResponse) GetData() *Product {
    if x != nil {
        return x.Data
    }
    return nil
}
type Product struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields
    Number       string  `protobuf:"bytes,1,opt,name=Number,proto3" json:"Number,omitempty"`
    Name         string  `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"`
    Unit         string  `protobuf:"bytes,3,opt,name=Unit,proto3" json:"Unit,omitempty"`
    IsSale       bool    `protobuf:"varint,4,opt,name=IsSale,proto3" json:"IsSale,omitempty"`             //是否销售
    SalePrice    float32 `protobuf:"fixed32,5,opt,name=SalePrice,proto3" json:"SalePrice,omitempty"`      //销售价格
    Amount       float32 `protobuf:"fixed32,6,opt,name=Amount,proto3" json:"Amount,omitempty"`            //库存剩余量
    MinInventory int32   `protobuf:"varint,7,opt,name=MinInventory,proto3" json:"MinInventory,omitempty"` //安全库存
    MaterialMode string  `protobuf:"bytes,8,opt,name=MaterialMode,proto3" json:"MaterialMode,omitempty"`  //物料类型
    PurchaseType string  `protobuf:"bytes,9,opt,name=PurchaseType,proto3" json:"PurchaseType,omitempty"`  //采购类型
}
func (x *Product) Reset() {
    *x = Product{}
    if protoimpl.UnsafeEnabled {
        mi := &file_product_proto_msgTypes[2]
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        ms.StoreMessageInfo(mi)
    }
}
func (x *Product) String() string {
    return protoimpl.X.MessageStringOf(x)
}
func (*Product) ProtoMessage() {}
func (x *Product) ProtoReflect() protoreflect.Message {
    mi := &file_product_proto_msgTypes[2]
    if protoimpl.UnsafeEnabled && x != nil {
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        if ms.LoadMessageInfo() == nil {
            ms.StoreMessageInfo(mi)
        }
        return ms
    }
    return mi.MessageOf(x)
}
// Deprecated: Use Product.ProtoReflect.Descriptor instead.
func (*Product) Descriptor() ([]byte, []int) {
    return file_product_proto_rawDescGZIP(), []int{2}
}
func (x *Product) GetNumber() string {
    if x != nil {
        return x.Number
    }
    return ""
}
func (x *Product) GetName() string {
    if x != nil {
        return x.Name
    }
    return ""
}
func (x *Product) GetUnit() string {
    if x != nil {
        return x.Unit
    }
    return ""
}
func (x *Product) GetIsSale() bool {
    if x != nil {
        return x.IsSale
    }
    return false
}
func (x *Product) GetSalePrice() float32 {
    if x != nil {
        return x.SalePrice
    }
    return 0
}
func (x *Product) GetAmount() float32 {
    if x != nil {
        return x.Amount
    }
    return 0
}
func (x *Product) GetMinInventory() int32 {
    if x != nil {
        return x.MinInventory
    }
    return 0
}
func (x *Product) GetMaterialMode() string {
    if x != nil {
        return x.MaterialMode
    }
    return ""
}
func (x *Product) GetPurchaseType() string {
    if x != nil {
        return x.PurchaseType
    }
    return ""
}
type GetProductListRequest struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields
    Page          int32  `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"`
    PageSize      int32  `protobuf:"varint,2,opt,name=pageSize,proto3" json:"pageSize,omitempty"`
    ProductNumber string `protobuf:"bytes,3,opt,name=ProductNumber,proto3" json:"ProductNumber,omitempty"`
    ProductName   string `protobuf:"bytes,4,opt,name=ProductName,proto3" json:"ProductName,omitempty"`
}
func (x *GetProductListRequest) Reset() {
    *x = GetProductListRequest{}
    if protoimpl.UnsafeEnabled {
        mi := &file_product_proto_msgTypes[3]
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        ms.StoreMessageInfo(mi)
    }
}
func (x *GetProductListRequest) String() string {
    return protoimpl.X.MessageStringOf(x)
}
func (*GetProductListRequest) ProtoMessage() {}
func (x *GetProductListRequest) ProtoReflect() protoreflect.Message {
    mi := &file_product_proto_msgTypes[3]
    if protoimpl.UnsafeEnabled && x != nil {
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        if ms.LoadMessageInfo() == nil {
            ms.StoreMessageInfo(mi)
        }
        return ms
    }
    return mi.MessageOf(x)
}
// Deprecated: Use GetProductListRequest.ProtoReflect.Descriptor instead.
func (*GetProductListRequest) Descriptor() ([]byte, []int) {
    return file_product_proto_rawDescGZIP(), []int{3}
}
func (x *GetProductListRequest) GetPage() int32 {
    if x != nil {
        return x.Page
    }
    return 0
}
func (x *GetProductListRequest) GetPageSize() int32 {
    if x != nil {
        return x.PageSize
    }
    return 0
}
func (x *GetProductListRequest) GetProductNumber() string {
    if x != nil {
        return x.ProductNumber
    }
    return ""
}
func (x *GetProductListRequest) GetProductName() string {
    if x != nil {
        return x.ProductName
    }
    return ""
}
type GetProductListResponse struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields
    Code  int32      `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"`
    Msg   string     `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
    List  []*Product `protobuf:"bytes,3,rep,name=List,proto3" json:"List,omitempty"`
    Total int64      `protobuf:"varint,4,opt,name=Total,proto3" json:"Total,omitempty"`
}
func (x *GetProductListResponse) Reset() {
    *x = GetProductListResponse{}
    if protoimpl.UnsafeEnabled {
        mi := &file_product_proto_msgTypes[4]
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        ms.StoreMessageInfo(mi)
    }
}
func (x *GetProductListResponse) String() string {
    return protoimpl.X.MessageStringOf(x)
}
func (*GetProductListResponse) ProtoMessage() {}
func (x *GetProductListResponse) ProtoReflect() protoreflect.Message {
    mi := &file_product_proto_msgTypes[4]
    if protoimpl.UnsafeEnabled && x != nil {
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        if ms.LoadMessageInfo() == nil {
            ms.StoreMessageInfo(mi)
        }
        return ms
    }
    return mi.MessageOf(x)
}
// Deprecated: Use GetProductListResponse.ProtoReflect.Descriptor instead.
func (*GetProductListResponse) Descriptor() ([]byte, []int) {
    return file_product_proto_rawDescGZIP(), []int{4}
}
func (x *GetProductListResponse) GetCode() int32 {
    if x != nil {
        return x.Code
    }
    return 0
}
func (x *GetProductListResponse) GetMsg() string {
    if x != nil {
        return x.Msg
    }
    return ""
}
func (x *GetProductListResponse) GetList() []*Product {
    if x != nil {
        return x.List
    }
    return nil
}
func (x *GetProductListResponse) GetTotal() int64 {
    if x != nil {
        return x.Total
    }
    return 0
}
var File_product_proto protoreflect.FileDescriptor
var file_product_proto_rawDesc = []byte{
    0x0a, 0x0d, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
    0x35, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66,
    0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x64,
    0x75, 0x63, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x72, 0x6f,
    0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x22, 0x5c, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f,
    0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
    0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04,
    0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28,
    0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x1c, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03,
    0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x04,
    0x44, 0x61, 0x74, 0x61, 0x22, 0x83, 0x02, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74,
    0x12, 0x16, 0x0a, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
    0x52, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65,
    0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04,
    0x55, 0x6e, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x55, 0x6e, 0x69, 0x74,
    0x12, 0x16, 0x0a, 0x06, 0x49, 0x73, 0x53, 0x61, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08,
    0x52, 0x06, 0x49, 0x73, 0x53, 0x61, 0x6c, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x61, 0x6c, 0x65,
    0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x02, 0x52, 0x09, 0x53, 0x61, 0x6c,
    0x65, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74,
    0x18, 0x06, 0x20, 0x01, 0x28, 0x02, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x22,
    0x0a, 0x0c, 0x4d, 0x69, 0x6e, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x07,
    0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x4d, 0x69, 0x6e, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f,
    0x72, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x4d, 0x6f,
    0x64, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69,
    0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61,
    0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x50, 0x75,
    0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x22, 0x8f, 0x01, 0x0a, 0x15, 0x47,
    0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71,
    0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01,
    0x28, 0x05, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67, 0x65,
    0x53, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65,
    0x53, 0x69, 0x7a, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4e,
    0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x50, 0x72, 0x6f,
    0x64, 0x75, 0x63, 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x50, 0x72,
    0x6f, 0x64, 0x75, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
    0x0b, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x72, 0x0a, 0x16,
    0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65,
    0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01,
    0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73,
    0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x1c, 0x0a, 0x04,
    0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x50, 0x72, 0x6f,
    0x64, 0x75, 0x63, 0x74, 0x52, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x6f,
    0x74, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x54, 0x6f, 0x74, 0x61, 0x6c,
    0x32, 0x9a, 0x01, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x65, 0x72, 0x76,
    0x69, 0x63, 0x65, 0x12, 0x43, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63,
    0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75,
    0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e,
    0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65,
    0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x50,
    0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x16, 0x2e, 0x47, 0x65, 0x74,
    0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65,
    0x73, 0x74, 0x1a, 0x17, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c,
    0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0b, 0x5a,
    0x09, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
    0x6f, 0x33,
}
var (
    file_product_proto_rawDescOnce sync.Once
    file_product_proto_rawDescData = file_product_proto_rawDesc
)
func file_product_proto_rawDescGZIP() []byte {
    file_product_proto_rawDescOnce.Do(func() {
        file_product_proto_rawDescData = protoimpl.X.CompressGZIP(file_product_proto_rawDescData)
    })
    return file_product_proto_rawDescData
}
var file_product_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_product_proto_goTypes = []interface{}{
    (*GetProductInfoRequest)(nil),  // 0: GetProductInfoRequest
    (*GetProductInfoResponse)(nil), // 1: GetProductInfoResponse
    (*Product)(nil),                // 2: Product
    (*GetProductListRequest)(nil),  // 3: GetProductListRequest
    (*GetProductListResponse)(nil), // 4: GetProductListResponse
}
var file_product_proto_depIdxs = []int32{
    2, // 0: GetProductInfoResponse.Data:type_name -> Product
    2, // 1: GetProductListResponse.List:type_name -> Product
    0, // 2: productService.GetProductInfo:input_type -> GetProductInfoRequest
    3, // 3: productService.GetProductList:input_type -> GetProductListRequest
    1, // 4: productService.GetProductInfo:output_type -> GetProductInfoResponse
    4, // 5: productService.GetProductList:output_type -> GetProductListResponse
    4, // [4:6] is the sub-list for method output_type
    2, // [2:4] is the sub-list for method input_type
    2, // [2:2] is the sub-list for extension type_name
    2, // [2:2] is the sub-list for extension extendee
    0, // [0:2] is the sub-list for field type_name
}
func init() { file_product_proto_init() }
func file_product_proto_init() {
    if File_product_proto != nil {
        return
    }
    if !protoimpl.UnsafeEnabled {
        file_product_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
            switch v := v.(*GetProductInfoRequest); i {
            case 0:
                return &v.state
            case 1:
                return &v.sizeCache
            case 2:
                return &v.unknownFields
            default:
                return nil
            }
        }
        file_product_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
            switch v := v.(*GetProductInfoResponse); i {
            case 0:
                return &v.state
            case 1:
                return &v.sizeCache
            case 2:
                return &v.unknownFields
            default:
                return nil
            }
        }
        file_product_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
            switch v := v.(*Product); i {
            case 0:
                return &v.state
            case 1:
                return &v.sizeCache
            case 2:
                return &v.unknownFields
            default:
                return nil
            }
        }
        file_product_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
            switch v := v.(*GetProductListRequest); i {
            case 0:
                return &v.state
            case 1:
                return &v.sizeCache
            case 2:
                return &v.unknownFields
            default:
                return nil
            }
        }
        file_product_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
            switch v := v.(*GetProductListResponse); i {
            case 0:
                return &v.state
            case 1:
                return &v.sizeCache
            case 2:
                return &v.unknownFields
            default:
                return nil
            }
        }
    }
    type x struct{}
    out := protoimpl.TypeBuilder{
        File: protoimpl.DescBuilder{
            GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
            RawDescriptor: file_product_proto_rawDesc,
            NumEnums:      0,
            NumMessages:   5,
            NumExtensions: 0,
            NumServices:   1,
        },
        GoTypes:           file_product_proto_goTypes,
        DependencyIndexes: file_product_proto_depIdxs,
        MessageInfos:      file_product_proto_msgTypes,
    }.Build()
    File_product_proto = out.File
    file_product_proto_rawDesc = nil
    file_product_proto_goTypes = nil
    file_product_proto_depIdxs = nil
}
proto/product/product_grpc.pb.go
New file
@@ -0,0 +1,146 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc             v3.19.0
// source: product.proto
package product
import (
    context "context"
    grpc "google.golang.org/grpc"
    codes "google.golang.org/grpc/codes"
    status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
const (
    ProductService_GetProductInfo_FullMethodName = "/productService/GetProductInfo"
    ProductService_GetProductList_FullMethodName = "/productService/GetProductList"
)
// ProductServiceClient is the client API for ProductService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type ProductServiceClient interface {
    GetProductInfo(ctx context.Context, in *GetProductInfoRequest, opts ...grpc.CallOption) (*GetProductInfoResponse, error)
    GetProductList(ctx context.Context, in *GetProductListRequest, opts ...grpc.CallOption) (*GetProductListResponse, error)
}
type productServiceClient struct {
    cc grpc.ClientConnInterface
}
func NewProductServiceClient(cc grpc.ClientConnInterface) ProductServiceClient {
    return &productServiceClient{cc}
}
func (c *productServiceClient) GetProductInfo(ctx context.Context, in *GetProductInfoRequest, opts ...grpc.CallOption) (*GetProductInfoResponse, error) {
    out := new(GetProductInfoResponse)
    err := c.cc.Invoke(ctx, ProductService_GetProductInfo_FullMethodName, in, out, opts...)
    if err != nil {
        return nil, err
    }
    return out, nil
}
func (c *productServiceClient) GetProductList(ctx context.Context, in *GetProductListRequest, opts ...grpc.CallOption) (*GetProductListResponse, error) {
    out := new(GetProductListResponse)
    err := c.cc.Invoke(ctx, ProductService_GetProductList_FullMethodName, in, out, opts...)
    if err != nil {
        return nil, err
    }
    return out, nil
}
// ProductServiceServer is the server API for ProductService service.
// All implementations must embed UnimplementedProductServiceServer
// for forward compatibility
type ProductServiceServer interface {
    GetProductInfo(context.Context, *GetProductInfoRequest) (*GetProductInfoResponse, error)
    GetProductList(context.Context, *GetProductListRequest) (*GetProductListResponse, error)
    mustEmbedUnimplementedProductServiceServer()
}
// UnimplementedProductServiceServer must be embedded to have forward compatible implementations.
type UnimplementedProductServiceServer struct {
}
func (UnimplementedProductServiceServer) GetProductInfo(context.Context, *GetProductInfoRequest) (*GetProductInfoResponse, error) {
    return nil, status.Errorf(codes.Unimplemented, "method GetProductInfo not implemented")
}
func (UnimplementedProductServiceServer) GetProductList(context.Context, *GetProductListRequest) (*GetProductListResponse, error) {
    return nil, status.Errorf(codes.Unimplemented, "method GetProductList not implemented")
}
func (UnimplementedProductServiceServer) mustEmbedUnimplementedProductServiceServer() {}
// UnsafeProductServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to ProductServiceServer will
// result in compilation errors.
type UnsafeProductServiceServer interface {
    mustEmbedUnimplementedProductServiceServer()
}
func RegisterProductServiceServer(s grpc.ServiceRegistrar, srv ProductServiceServer) {
    s.RegisterService(&ProductService_ServiceDesc, srv)
}
func _ProductService_GetProductInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
    in := new(GetProductInfoRequest)
    if err := dec(in); err != nil {
        return nil, err
    }
    if interceptor == nil {
        return srv.(ProductServiceServer).GetProductInfo(ctx, in)
    }
    info := &grpc.UnaryServerInfo{
        Server:     srv,
        FullMethod: ProductService_GetProductInfo_FullMethodName,
    }
    handler := func(ctx context.Context, req interface{}) (interface{}, error) {
        return srv.(ProductServiceServer).GetProductInfo(ctx, req.(*GetProductInfoRequest))
    }
    return interceptor(ctx, in, info, handler)
}
func _ProductService_GetProductList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
    in := new(GetProductListRequest)
    if err := dec(in); err != nil {
        return nil, err
    }
    if interceptor == nil {
        return srv.(ProductServiceServer).GetProductList(ctx, in)
    }
    info := &grpc.UnaryServerInfo{
        Server:     srv,
        FullMethod: ProductService_GetProductList_FullMethodName,
    }
    handler := func(ctx context.Context, req interface{}) (interface{}, error) {
        return srv.(ProductServiceServer).GetProductList(ctx, req.(*GetProductListRequest))
    }
    return interceptor(ctx, in, info, handler)
}
// ProductService_ServiceDesc is the grpc.ServiceDesc for ProductService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var ProductService_ServiceDesc = grpc.ServiceDesc{
    ServiceName: "productService",
    HandlerType: (*ProductServiceServer)(nil),
    Methods: []grpc.MethodDesc{
        {
            MethodName: "GetProductInfo",
            Handler:    _ProductService_GetProductInfo_Handler,
        },
        {
            MethodName: "GetProductList",
            Handler:    _ProductService_GetProductList_Handler,
        },
    },
    Streams:  []grpc.StreamDesc{},
    Metadata: "product.proto",
}
router/file.go
@@ -11,6 +11,8 @@
    {
        FileRouter.POST("add", FileApi.Add)             // 添加附件
        FileRouter.DELETE("delete/:id", FileApi.Delete) // 删除附件
        FileRouter.GET("list", FileApi.List)            // 附件列表
        //FileRouter.GET("list", FileApi.List)            // 附件列表
        FileRouter.POST("download", FileApi.Download) // 附件下载
        FileRouter.POST("preview", FileApi.Preview)   // 附件预览
    }
}
router/index.go
@@ -175,6 +175,7 @@
        InitInvoiceStatusRouter(PrivateGroup)
        InitInvoiceTypeRouter(PrivateGroup)
        InitCourierCompanyRouter(PrivateGroup)
        InitProductRouter(PrivateGroup)
    }
    return Router
router/product.go
New file
@@ -0,0 +1,15 @@
package router
import (
    v1 "aps_crm/api/v1"
    "github.com/gin-gonic/gin"
)
func InitProductRouter(router *gin.RouterGroup) {
    productRouter := router.Group("product")
    productApi := v1.ProductApi{}
    {
        productRouter.GET("info", productApi.Info) // 产品详情
        productRouter.GET("list", productApi.List) // 产品列表
    }
}
service/file.go
@@ -12,6 +12,15 @@
    return FileService{}
}
func (FileService) GetFile(id uint) (*model.File, int) {
    file, err := model.NewFileSearch().SetId(id).First()
    if err != nil {
        return nil, ecode.DBErr
    }
    return file, ecode.OK
}
func (FileService) AddFile(fileRecord *model.File) int {
    err := model.NewFileSearch().Create(fileRecord)