| | |
| | | package v1 |
| | | |
| | | import ( |
| | | "aps_crm/conf" |
| | | "aps_crm/constvar" |
| | | "aps_crm/model" |
| | | "aps_crm/model/grpc_init" |
| | | "aps_crm/model/request" |
| | | "aps_crm/model/response" |
| | | "aps_crm/pkg/contextx" |
| | |
| | | "aps_crm/proto/code" |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/spf13/cast" |
| | | "google.golang.org/grpc" |
| | | "google.golang.org/grpc/credentials/insecure" |
| | | ) |
| | | |
| | | type CodeApi struct{} |
| | | |
| | | var ( |
| | | codeServiceConn *grpc.ClientConn |
| | | ) |
| | | |
| | | func InitCodeServiceConn() { |
| | | var err error |
| | | codeServiceConn, 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 |
| | | } |
| | | } |
| | | |
| | | func CloseCodeServiceConn() { |
| | | if codeServiceConn != nil { |
| | | codeServiceConn.Close() |
| | | } |
| | | } |
| | | //var ( |
| | | // codeServiceConn *grpc.ClientConn |
| | | //) |
| | | // |
| | | //func InitCodeServiceConn() { |
| | | // var err error |
| | | // codeServiceConn, 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 |
| | | // } |
| | | //} |
| | | // |
| | | //func CloseCodeServiceConn() { |
| | | // if codeServiceConn != nil { |
| | | // codeServiceConn.Close() |
| | | // } |
| | | //} |
| | | |
| | | // GetCodeList |
| | | // |
| | |
| | | params.CodeStandID = c.Query("codeStandID") |
| | | params.Name = c.Query("name") |
| | | params.Type = c.Query("type") |
| | | client := code.NewCodeServiceClient(codeServiceConn) |
| | | client := code.NewCodeServiceClient(grpc_init.CrmApsGrpcServiceConn) |
| | | list, err := client.GetCodeList(ctx.GetCtx(), &code.GetCodeListRequest{ |
| | | Page: cast.ToInt32(params.Page), |
| | | PageSize: cast.ToInt32(params.PageSize), |