| | |
| | | import ( |
| | | "apsClient/conf" |
| | | "apsClient/model" |
| | | "apsClient/model/response" |
| | | "apsClient/pkg/logx" |
| | | "github.com/jinzhu/gorm" |
| | | "os" |
| | |
| | | return deviceIds, nil |
| | | } |
| | | |
| | | func GetDeviceList() (deviceList []*response.Device, err error) { |
| | | devices, err := model.NewDeviceSearch().SetDeviceMac(conf.Conf.System.DeviceId).FindNotTotal() |
| | | if err == gorm.ErrRecordNotFound { |
| | | return nil, nil |
| | | } |
| | | if err != nil { |
| | | return nil, err |
| | | } |
| | | deviceList = make([]*response.Device, 0, len(devices)) |
| | | for _, device := range devices { |
| | | deviceList = append(deviceList, &response.Device{ |
| | | DeviceID: device.DeviceID, |
| | | DeviceName: device.DeviceName, |
| | | }) |
| | | } |
| | | return deviceList, nil |
| | | } |
| | | |
| | | func InitCurrentDeviceID() (err error) { |
| | | currentDeviceID := ReadDeviceIDFromFile() |
| | | if currentDeviceID != "" { |