// Copyright 2019 github.com. All rights reserved. // Use of this source code is governed by github.com. package impl import ( "context" "smart-auth/impl/v1/device" "smart-auth/pb" "smart-auth/pb/v1" "github.com/jaryhe/gopkgs/tasker/rpctasker" "google.golang.org/grpc" ) // 具体实现 type Rcvr struct { } func Register(s *grpc.Server) { pb.RegisterSmartAuthServer(s, &Rcvr{}) } // 设备信息获取 func (c *Rcvr) DeviceInfo(ctx context.Context, req *v1.DeviceInfoRequest) (reply *v1.DeviceInfoReply, err error) { t1 := func() error { reply, err = device.DeviceInfo(ctx, req) return err } return reply, rpctasker.Exec(ctx, t1) } func (c *Rcvr) DeviceInfoById(ctx context.Context, req *v1.DeviceInfoByIdRequest) (reply *v1.DeviceInfoByIdReply, err error) { t1 := func() error { reply, err = device.DeviceInfoById(ctx, req) return err } return reply, rpctasker.Exec(ctx, t1) } // 设备参数设置 func (c *Rcvr) DeviceParamSet(ctx context.Context, req *v1.DeviceParamSetRequest) (reply *v1.DeviceParamSetReply, err error) { t1 := func() error { reply, err = device.DeviceParamSet(ctx, req) return err } return reply, rpctasker.Exec(ctx, t1) } // 设备状态更新 func (c *Rcvr) DeviceStatusUpdate(ctx context.Context, req *v1.DeviceStatusUpdateRequest) (reply *v1.DeviceStatusUpdateReply, err error) { t1 := func() error { reply, err = device.DeviceStatusUpdate(ctx, req) return err } return reply, rpctasker.Exec(ctx, t1) } // 设备改变通知 func (c *Rcvr) DeviceChangeNotify(ctx context.Context, req *v1.DeviceChangeNotifyRequest) (reply *v1.DeviceChangeNotifyReply, err error) { t1 := func() error { reply, err = device.DeviceChangeNotify(ctx, req) return err } return reply, rpctasker.Exec(ctx, t1) } // 获取所有扬尘sn码 func (c *Rcvr) GetAllDustSn(ctx context.Context, req *v1.GetAllDustSnRequest) (reply *v1.GetAllDustSnReply, err error) { t1 := func() error { reply, err = device.GetAllDustSn(ctx, req) return err } return reply, rpctasker.Exec(ctx, t1) }