12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- package middleground
- import (
- "context"
- "log"
- "bp.jydev.jianyu360.cn/BaseService/entManageApplication/rpc/entmanageapplication"
- "bp.jydev.jianyu360.cn/BaseService/entManageApplication/rpc/pb"
- "github.com/zeromicro/go-zero/core/discov"
- "github.com/zeromicro/go-zero/zrpc"
- )
- type entManageApplication struct {
- hosts []string
- key string
- client zrpc.Client
- }
- func newEntManageApplication(hosts []string, key string) *entManageApplication {
- r := &entManageApplication{
- hosts: hosts,
- key: key,
- }
- r.client = r.NewClient()
- return r
- }
- func (e *entManageApplication) NewClient() zrpc.Client {
- if r.client != nil && r.client.Conn() != nil {
- return r.client
- }
- client, err := zrpc.NewClient(zrpc.RpcClientConf{
- Etcd: discov.EtcdConf{
- Hosts: e.hosts,
- Key: e.key,
- },
- })
- if err != nil {
- log.Println(err)
- return nil
- }
- r.client = client
- return client
- }
- //
- func (e *entManageApplication) EmpowerUserIds(ids []int64) *pb.EmpowerUserIds {
- client := e.NewClient()
- if client == nil {
- return nil
- }
- //defer client.Conn().Close()
- resp, err := entmanageapplication.NewEntManageApplication(client).EmpowerUserIds(context.Background(), &pb.EmpowerUserIds{
- Ids: ids,
- })
- if err != nil {
- log.Println(err)
- return nil
- }
- return resp
- }
|