liujiandao
2023-11-18 115bd9b51f5d8eade4658f844de37516486c60e7
api/v1/code.go
@@ -1,9 +1,9 @@
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"
@@ -12,30 +12,28 @@
   "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
//
@@ -55,7 +53,7 @@
   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),