12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package gate
- import (
- "context"
- "encoding/json"
- "fmt"
- "git.getensh.com/common/gopkgs/logger"
- "go.uber.org/zap"
- "google.golang.org/grpc/status"
- pb_v1 "property-device/pb/v1"
- "property-device/utils/gate_utils"
- )
- func GateProtocols(ctx context.Context, req *pb_v1.GateProtocolsRequest) (reply *pb_v1.GateProtocolsReply, err error) {
- reply = &pb_v1.GateProtocolsReply{}
- // 捕获各个task中的异常并返回给调用者
- defer func() {
- if r := recover(); r != nil {
- err = fmt.Errorf("%+v", r)
- e := &status.Status{}
- if er := json.Unmarshal([]byte(err.Error()), e); er != nil {
- logger.Error("err",
- zap.String("system_err", err.Error()),
- zap.Stack("stacktrace"))
- }
- }
- }()
- reply.List = make([]*pb_v1.GateProtocolData, len(gate_utils.GateProtocolFuntionMap))
- i := 0
- for k, array := range gate_utils.GateProtocolFuntionMap {
- reply.List[i] = &pb_v1.GateProtocolData{
- Protocol: k,
- Desc: gate_utils.GateProtocolNameMap[k],
- QcodeSupport: array[0],
- FaceSupport: array[1],
- CardSupport: array[2],
- }
- i++
- }
- return reply, nil
- }
|