| | |
| | | storePath: uploads/file |
| | | grpcServer: |
| | | apsAddr: 192.168.20.119:9091 |
| | | crmAddr: 192.168.20.118:9092 |
| | | crmAddr: :9092 |
| | | srmAddr: 192.168.20.118:9093 |
| | |
| | | "wms/opa" |
| | | "wms/pkg/logx" |
| | | "wms/pkg/structx" |
| | | "wms/proto/client" |
| | | "wms/proto/product_inventory" |
| | | "wms/proto/purchase_wms" |
| | | "wms/proto/supplier" |
| | |
| | | } |
| | | util.ResponseFormat(c, code.Success, resp.List) |
| | | } |
| | | |
| | | // GetClientList |
| | | // @Tags 入库/出库 |
| | | // @Summary 获取物流公司列表 |
| | | // @Produce application/json |
| | | // |
| | | // @Success 200 {object} util.Response "成功" |
| | | // |
| | | // @Router /api-wms/v1/operation/getClientList [get] |
| | | func (slf OperationController) GetClientList(c *gin.Context) { |
| | | cli := client.NewClientServiceClient(client.ClientConn) |
| | | resp, err := cli.GetClientList(c, &client.ClientListRequest{}) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "grpc调用失败:"+err.Error()) |
| | | return |
| | | } |
| | | util.ResponseFormat(c, code.Success, resp.List) |
| | | } |
| | |
| | | "wms/controllers" |
| | | "wms/models" |
| | | "wms/pkg/logx" |
| | | "wms/proto/client" |
| | | "wms/proto/product_inventory" |
| | | "wms/proto/purchase_wms" |
| | | "wms/proto/supplier" |
| | |
| | | go controllers.InitProductInventoryServiceConn() |
| | | go controllers.InitCodeServiceConn() |
| | | go supplier.InitConn() |
| | | go client.InitConn() |
| | | //启动grpc服务 |
| | | go func() { |
| | | ln, err := net.Listen("tcp", ":"+conf.WebConf.GrpcPort) |
| | |
| | | controllers.CloseProductInventoryServiceConn() |
| | | controllers.CloseCodeServiceConn() |
| | | supplier.CloseConn() |
| | | client.CloseConn() |
| | | // 关闭HTTP服务器 |
| | | if err := server.Shutdown(ctx); err != nil { |
| | | logx.Infof("服务优雅退出失败: %v", err) |
New file |
| | |
| | | syntax = "proto3"; |
| | | |
| | | option go_package = "./client"; |
| | | |
| | | service ClientService { |
| | | rpc GetClientList(ClientListRequest) returns (ClientListResponse); |
| | | } |
| | | |
| | | message ClientListRequest { |
| | | |
| | | } |
| | | |
| | | message ClientInfo { |
| | | int32 ClientId =1; |
| | | string ClientName =2; |
| | | } |
| | | |
| | | message ClientListResponse { |
| | | repeated ClientInfo List =1; |
| | | } |
New file |
| | |
| | | package client |
| | | |
| | | import ( |
| | | "google.golang.org/grpc" |
| | | "google.golang.org/grpc/credentials/insecure" |
| | | "wms/conf" |
| | | "wms/pkg/logx" |
| | | ) |
| | | |
| | | var ( |
| | | ClientConn *grpc.ClientConn |
| | | ) |
| | | |
| | | func InitConn() { |
| | | var err error |
| | | ClientConn, err = grpc.Dial(conf.GrpcServerConf.CrmAddr, grpc.WithTransportCredentials(insecure.NewCredentials())) |
| | | if err != nil { |
| | | logx.Errorf("grpc dial product service error: %v", err.Error()) |
| | | return |
| | | } |
| | | } |
| | | |
| | | func CloseConn() { |
| | | if ClientConn != nil { |
| | | ClientConn.Close() |
| | | } |
| | | } |
| | |
| | | operationAPI.PUT("cancel/:id", operationController.Cancel) |
| | | operationAPI.PUT("outputOperation/:id", operationController.OutputOperation) |
| | | operationAPI.GET("getSupplierList", operationController.GetSupplierList) |
| | | operationAPI.GET("getClientList", operationController.GetClientList) |
| | | |
| | | } |
| | | |