dust_all.go 706 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package device
  4. import (
  5. "context"
  6. "smart-auth/consts"
  7. "smart-auth/model"
  8. "smart-auth/pb/v1"
  9. "github.com/jaryhe/gopkgs/database"
  10. )
  11. func GetAllDustSn(ctx context.Context, req *v1.GetAllDustSnRequest) (reply *v1.GetAllDustSnReply, err error) {
  12. p := model.DeviceAll{}
  13. where := map[string]interface{}{
  14. "DeviceCode":consts.DeviceTypeDust,
  15. "VerifyStatus":1,
  16. }
  17. list, err := p.QueryAll(database.DB(), where)
  18. if err != nil {
  19. return nil, err
  20. }
  21. reply = &v1.GetAllDustSnReply{}
  22. reply.Sns = make([]string, len(list))
  23. for i, v := range list {
  24. reply.Sns[i] = v.SN
  25. }
  26. return reply, nil
  27. }