zhangqian
2023-08-08 a583fb5fdd2ccdc20e22cebf9428237915645c57
增加产品列表产品详情接口(代前端请求aps grpc接口)
6个文件已添加
11个文件已修改
1340 ■■■■■ 已修改文件
api/v1/product.go 109 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
conf/aps-crm.json 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
conf/config.go 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 134 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 134 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
go.mod 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
go.sum 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/common.go 10 ●●●●● 补丁 | 查看 | 原始文档 | 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/index.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/product.go 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/product.go
New file
@@ -0,0 +1,109 @@
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}, nil)
    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(contextx.Response{
        Data: 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
@@ -4756,6 +4756,102 @@
                }
            }
        },
        "/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": "string",
                        "name": "ProductName",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "ProductNumber",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "page",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "pageSize",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/response.ListResponse"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/product.Product"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api/province/add": {
            "post": {
                "produces": [
@@ -11690,6 +11786,44 @@
                }
            }
        },
        "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"
                }
            }
        },
        "request.AddAccountId": {
            "type": "object",
            "required": [
docs/swagger.json
@@ -4744,6 +4744,102 @@
                }
            }
        },
        "/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": "string",
                        "name": "ProductName",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "ProductNumber",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "page",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "pageSize",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/response.ListResponse"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/product.Product"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api/province/add": {
            "post": {
                "produces": [
@@ -11678,6 +11774,44 @@
                }
            }
        },
        "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"
                }
            }
        },
        "request.AddAccountId": {
            "type": "object",
            "required": [
docs/swagger.yaml
@@ -1579,6 +1579,33 @@
      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:
    properties:
      name:
@@ -8160,6 +8187,61 @@
      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:
      - in: query
        name: ProductName
        type: string
      - in: query
        name: ProductNumber
        type: string
      - in: query
        name: page
        type: integer
      - in: query
        name: pageSize
        type: integer
      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
@@ -26,7 +26,7 @@
    go.etcd.io/etcd/client/pkg/v3 v3.5.9
    go.etcd.io/etcd/client/v3 v3.5.9
    go.uber.org/zap v1.24.0
    golang.org/x/crypto v0.10.0
    golang.org/x/crypto v0.12.0
    golang.org/x/sync v0.3.0
    gopkg.in/natefinch/lumberjack.v2 v2.2.1
    gorm.io/driver/mysql v1.5.1
@@ -113,14 +113,15 @@
    go.uber.org/multierr v1.8.0 // indirect
    golang.org/x/arch v0.3.0 // indirect
    golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb // indirect
    golang.org/x/net v0.10.0 // indirect
    golang.org/x/sys v0.9.0 // indirect
    golang.org/x/text 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/time v0.1.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 // indirect
    google.golang.org/protobuf v1.31.0 // indirect
    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
@@ -563,6 +563,8 @@
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM=
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -646,6 +648,8 @@
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=
@@ -734,6 +738,8 @@
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -753,6 +759,8 @@
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58=
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -888,6 +896,10 @@
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/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=
@@ -906,6 +918,8 @@
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=
@@ -921,6 +935,8 @@
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/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/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/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) // 产品列表
    }
}