add
wangpengfei
2023-08-26 1bb2d1d1f4ed5cd0409d17180844b445bf63f213
add

add get product list from grpc
9个文件已修改
334 ■■■■■ 已修改文件
api/v1/test/product.go 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
config.yaml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
config/system.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 117 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 117 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
log/2023-08-26/info.log 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/test/product.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/test/product.go
@@ -5,6 +5,7 @@
    "github.com/spf13/cast"
    "go.uber.org/zap"
    "google.golang.org/grpc"
    "google.golang.org/grpc/credentials/insecure"
    "srm/global"
    "srm/model/common/request"
    "srm/model/common/response"
@@ -172,14 +173,14 @@
    productServiceConn *grpc.ClientConn
)
//func InitProductServiceConn() {
//    var err error
//    productServiceConn, err = grpc.Dial(conf.Conf.GrpcServiceAddr.Aps, grpc.WithTransportCredentials(insecure.NewCredentials()))
//    if err != nil {
func InitProductServiceConn() {
    var err error
    productServiceConn, err = grpc.Dial(global.GVA_CONFIG.System.GrpcUrl, grpc.WithTransportCredentials(insecure.NewCredentials()))
    if err != nil {
//        logx.Errorf("grpc dial product service error: %v", err.Error())
//        return
//    }
//}
        return
    }
}
func CloseProductServiceConn() {
    if productServiceConn != nil {
@@ -233,7 +234,7 @@
    response.OkWithDetailed(response.PageResult{
        List:     productList,
        Total:    0,
        Total:    int64(len(productList)),
        Page:     pageInfo.Page,
        PageSize: pageInfo.PageSize,
    }, "获取成功", c)
config.yaml
@@ -182,6 +182,7 @@
    iplimit-time: 3600
    use-multipoint: false
    use-redis: false
  grpc-url: 192.168.20.119:9091
tencent-cos:
    bucket: xxxxx-10005608
    region: ap-shanghai
config/system.go
@@ -10,4 +10,5 @@
    LimitTimeIP   int    `mapstructure:"iplimit-time" json:"iplimit-time" yaml:"iplimit-time"`
    UseMultipoint bool   `mapstructure:"use-multipoint" json:"use-multipoint" yaml:"use-multipoint"` // 多点登录拦截
    UseRedis      bool   `mapstructure:"use-redis" json:"use-redis" yaml:"use-redis"`                // 使用redis
    GrpcUrl       string `mapstructure:"grpc-url" json:"grpc-url" yaml:"grpc-url"`                   // grpc服务地址
}
docs/docs.go
@@ -3912,6 +3912,119 @@
                }
            }
        },
        "/p/getProductListFromGrpc": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Product"
                ],
                "summary": "分页获取Product列表",
                "parameters": [
                    {
                        "type": "integer",
                        "name": "deliveryTime",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "endCreatedAt",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "主键ID",
                        "name": "id",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "关键字",
                        "name": "keyword",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "maximumStock",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "minimumStock",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "name",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "number",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "页码",
                        "name": "page",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "每页大小",
                        "name": "pageSize",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "productType",
                        "in": "query"
                    },
                    {
                        "type": "number",
                        "name": "purchasePrice",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "remark",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "shippingDuration",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "startCreatedAt",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "unit",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/p/updateProduct": {
            "put": {
                "security": [
@@ -7078,6 +7191,10 @@
                    "description": "环境值",
                    "type": "string"
                },
                "grpc-url": {
                    "description": "grpc服务地址",
                    "type": "string"
                },
                "iplimit-count": {
                    "type": "integer"
                },
docs/swagger.json
@@ -3903,6 +3903,119 @@
                }
            }
        },
        "/p/getProductListFromGrpc": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Product"
                ],
                "summary": "分页获取Product列表",
                "parameters": [
                    {
                        "type": "integer",
                        "name": "deliveryTime",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "endCreatedAt",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "主键ID",
                        "name": "id",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "关键字",
                        "name": "keyword",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "maximumStock",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "minimumStock",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "name",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "number",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "页码",
                        "name": "page",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "每页大小",
                        "name": "pageSize",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "productType",
                        "in": "query"
                    },
                    {
                        "type": "number",
                        "name": "purchasePrice",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "remark",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "name": "shippingDuration",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "startCreatedAt",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "name": "unit",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "/p/updateProduct": {
            "put": {
                "security": [
@@ -7069,6 +7182,10 @@
                    "description": "环境值",
                    "type": "string"
                },
                "grpc-url": {
                    "description": "grpc服务地址",
                    "type": "string"
                },
                "iplimit-count": {
                    "type": "integer"
                },
docs/swagger.yaml
@@ -510,6 +510,9 @@
      env:
        description: 环境值
        type: string
      grpc-url:
        description: grpc服务地址
        type: string
      iplimit-count:
        type: integer
      iplimit-time:
@@ -3829,6 +3832,75 @@
      summary: 分页获取Product列表
      tags:
      - Product
  /p/getProductListFromGrpc:
    get:
      consumes:
      - application/json
      parameters:
      - in: query
        name: deliveryTime
        type: integer
      - in: query
        name: endCreatedAt
        type: string
      - description: 主键ID
        in: query
        name: id
        type: integer
      - description: 关键字
        in: query
        name: keyword
        type: string
      - in: query
        name: maximumStock
        type: integer
      - in: query
        name: minimumStock
        type: integer
      - in: query
        name: name
        type: string
      - in: query
        name: number
        type: string
      - description: 页码
        in: query
        name: page
        type: integer
      - description: 每页大小
        in: query
        name: pageSize
        type: integer
      - in: query
        name: productType
        type: string
      - in: query
        name: purchasePrice
        type: number
      - in: query
        name: remark
        type: string
      - in: query
        name: shippingDuration
        type: integer
      - in: query
        name: startCreatedAt
        type: string
      - in: query
        name: unit
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: '{"success":true,"data":{},"msg":"获取成功"}'
          schema:
            type: string
      security:
      - ApiKeyAuth: []
      summary: 分页获取Product列表
      tags:
      - Product
  /p/updateProduct:
    put:
      consumes:
log/2023-08-26/info.log
@@ -10,3 +10,7 @@
[srm]2023/08/26 - 13:44:25.708    info    D:/basic.com/srm/initialize/router.go:37    register swagger handler
[srm]2023/08/26 - 13:44:25.729    info    D:/basic.com/srm/initialize/router.go:83    router register success
[srm]2023/08/26 - 13:44:25.742    info    D:/basic.com/srm/core/server.go:36    server run success on     {"address": ":8889"}
[srm]2023/08/26 - 15:04:13.291    info    D:/basic.com/srm/initialize/gorm.go:60    register table success
[srm]2023/08/26 - 15:04:13.295    info    D:/basic.com/srm/initialize/router.go:37    register swagger handler
[srm]2023/08/26 - 15:04:13.312    info    D:/basic.com/srm/initialize/router.go:83    router register success
[srm]2023/08/26 - 15:04:13.324    info    D:/basic.com/srm/core/server.go:36    server run success on     {"address": ":8889"}
main.go
@@ -2,6 +2,7 @@
import (
    "go.uber.org/zap"
    "srm/api/v1/test"
    "srm/core"
    "srm/global"
@@ -34,5 +35,8 @@
        db, _ := global.GVA_DB.DB()
        defer db.Close()
    }
    go test.InitProductServiceConn()
    core.RunWindowsServer()
}
router/test/product.go
@@ -23,5 +23,6 @@
    {
        pRouterWithoutRecord.GET("findProduct", pApi.FindProduct)       // 根据ID获取Product
        pRouterWithoutRecord.GET("getProductList", pApi.GetProductList) // 获取Product列表
        pRouterWithoutRecord.GET("getProductListFromGrpc", pApi.GetProductListFromGrpc) // 通过grpc获取Product列表
    }
}