add
add get product list from grpc
| | |
| | | "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" |
| | |
| | | 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 { |
| | |
| | | |
| | | response.OkWithDetailed(response.PageResult{ |
| | | List: productList, |
| | | Total: 0, |
| | | Total: int64(len(productList)), |
| | | Page: pageInfo.Page, |
| | | PageSize: pageInfo.PageSize, |
| | | }, "获取成功", c) |
| | |
| | | iplimit-time: 3600 |
| | | use-multipoint: false |
| | | use-redis: false |
| | | grpc-url: 192.168.20.119:9091 |
| | | tencent-cos: |
| | | bucket: xxxxx-10005608 |
| | | region: ap-shanghai |
| | |
| | | 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服务地址 |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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": [ |
| | |
| | | "description": "环境值", |
| | | "type": "string" |
| | | }, |
| | | "grpc-url": { |
| | | "description": "grpc服务地址", |
| | | "type": "string" |
| | | }, |
| | | "iplimit-count": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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": [ |
| | |
| | | "description": "环境值", |
| | | "type": "string" |
| | | }, |
| | | "grpc-url": { |
| | | "description": "grpc服务地址", |
| | | "type": "string" |
| | | }, |
| | | "iplimit-count": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | env: |
| | | description: 环境值 |
| | | type: string |
| | | grpc-url: |
| | | description: grpc服务地址 |
| | | type: string |
| | | iplimit-count: |
| | | type: integer |
| | | iplimit-time: |
| | |
| | | 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: |
| | |
| | | [srm]2023/08/26 - 13:44:25.708 [34minfo[0m D:/basic.com/srm/initialize/router.go:37 register swagger handler |
| | | [srm]2023/08/26 - 13:44:25.729 [34minfo[0m D:/basic.com/srm/initialize/router.go:83 router register success |
| | | [srm]2023/08/26 - 13:44:25.742 [34minfo[0m D:/basic.com/srm/core/server.go:36 server run success on {"address": ":8889"} |
| | | [srm]2023/08/26 - 15:04:13.291 [34minfo[0m D:/basic.com/srm/initialize/gorm.go:60 register table success |
| | | [srm]2023/08/26 - 15:04:13.295 [34minfo[0m D:/basic.com/srm/initialize/router.go:37 register swagger handler |
| | | [srm]2023/08/26 - 15:04:13.312 [34minfo[0m D:/basic.com/srm/initialize/router.go:83 router register success |
| | | [srm]2023/08/26 - 15:04:13.324 [34minfo[0m D:/basic.com/srm/core/server.go:36 server run success on {"address": ":8889"} |
| | |
| | | |
| | | import ( |
| | | "go.uber.org/zap" |
| | | "srm/api/v1/test" |
| | | |
| | | "srm/core" |
| | | "srm/global" |
| | |
| | | db, _ := global.GVA_DB.DB() |
| | | defer db.Close() |
| | | } |
| | | |
| | | go test.InitProductServiceConn() |
| | | |
| | | core.RunWindowsServer() |
| | | } |
| | |
| | | { |
| | | pRouterWithoutRecord.GET("findProduct", pApi.FindProduct) // 根据ID获取Product |
| | | pRouterWithoutRecord.GET("getProductList", pApi.GetProductList) // 获取Product列表 |
| | | pRouterWithoutRecord.GET("getProductListFromGrpc", pApi.GetProductListFromGrpc) // 通过grpc获取Product列表 |
| | | } |
| | | } |