service/device.go
@@ -95,3 +95,14 @@ device.NeedSetProcessParams = needSetProcessParams return model.NewDeviceSearch().SetID(device.ID).Save(device) } func GetCurrentDevice() (device *model.Device, err error) { if conf.Conf.CurrentDeviceID == "" { return nil, errors.New("当前设备ID不存在,请检查") } device, err = model.NewDeviceSearch().SetDeviceId(conf.Conf.CurrentDeviceID).First() if err == gorm.ErrRecordNotFound { return nil, errors.New("设备不存在") } return device, nil }