更新时间:2024-05-20 02:38:30下载pdf
参数说明
| 参数名 | 类型 | 是否必填 | 说明 | 
|---|---|---|---|
| name | String | 是 | 要创建的空间的名称 | 
| parentSpaceId | String | 否 | 父空间的 ID | 
| success | (() -> Void)? | 否 | 成功回调函数 | 
| failure | ((Error) -> Void)? | 否 | 失败回调函数 | 
代码示例
SpaceService.shared.create(name: text, parentSpaceId: self.spaceId) {
    print("创建成功")
    self.requestSpaceList()
} failure: { error in
    print("创建失败:\(error.localizedDescription)")
}
参数说明
| 参数名 | 类型 | 是否必填 | 说明 | 
|---|---|---|---|
| spaceId | String | 是 | 要修改的空间的 ID | 
| name | String | 是 | 修改后的名称 | 
| success | (() -> Void)? | 否 | 成功回调函数 | 
| failure | ((Error) -> Void)? | 否 | 失败回调函数 | 
代码示例
SpaceService.shared.update(spaceId: space.spaceId, name: text) {
    print("修改成功")
    self.requestSpaceList()
} failure: { error in
    print("修改失败:\(error.localizedDescription)")
}
参数说明
| 参数名 | 类型 | 是否必填 | 说明 | 
|---|---|---|---|
| spaceId | String | 是 | 要删除的空间的 ID | 
| success | (() -> Void)? | 否 | 成功回调函数 | 
| failure | ((Error) -> Void)? | 否 | 失败回调函数 | 
代码示例
SpaceService.shared.remove(spaceId: spaceId) {
    print("删除成功")
} failure: { error in
    print("删除失败:\(error.localizedDescription)")
}
参数说明
| 参数名 | 类型 | 是否必填 | 说明 | 
|---|---|---|---|
| spaceId | String | 是 | 要查询的空间的 ID | 
| success | ((ISpace) -> Void)? | 否 | 成功回调函数,返回查询到的空间实例 | 
| failure | ((Error) -> Void)? | 否 | 失败回调函数 | 
代码示例
SpaceService.shared.space(spaceId: "123", success: { space in
    print("查询到的空间名称:\(space.name)")
}, failure: { error in
    print("查询失败:\(error.localizedDescription)")
})
参数说明
| 参数名 | 类型 | 是否必填 | 说明 | 
|---|---|---|---|
| spaceId | String? | 否 | 要查询的空间的 ID。如果为 nil,则查询所有子空间 | 
| success | (([ISpace]) -> Void)? | 否 | 成功回调函数,返回查询到的子空间实例数组 | 
| failure | ((Error) -> Void)? | 否 | 失败回调函数 | 
代码示例
SpaceService.shared.subSpaces(spaceId: "123", success: { spaces in
    print("查询到的子空间数量:\(spaces.count)")
}, failure: { error in
    print("查询失败:\(error.localizedDescription)")
})
参数说明
| 参数名 | 类型 | 是否必填 | 说明 | 
|---|---|---|---|
| spaceId | String | 是 | 要查询的空间的 ID | 
| lastRowKey | String? | 否 | 上一次查询返回的最后一行的 RowKey,用于分页查询 | 
| success | ((ISpaceDeviceListResult) -> Void)? | 否 | 成功回调函数,返回查询到的设备列表 | 
| failure | ((Error) -> Void)? | 否 | 失败回调函数 | 
代码示例
SpaceService.shared.devices(spaceId: "123", lastRowKey: nil, success: { result in
    print("查询到的设备数量:\(result.devices.count)")
    if let nextRowKey = result.nextRowKey {
        print("下一页数据的lastRowKey:\(nextRowKey)")
    }
}, failure: { error in
    print("查询失败:\(error.localizedDescription)")
})
参数说明
| 参数名 | 类型 | 是否必填 | 说明 | 
|---|---|---|---|
| spaceId | String | 是 | 要查询的空间的 ID | 
| success | ((IAssociatedModel) -> Void)? | 否 | 成功回调函数,返回查询到的关联模型 | 
| failure | ((Error) -> Void)? | 否 | 失败回调函数 | 
代码示例
SpaceService.shared.associatedModel(spaceId: "123", success: { model in
    print("查询到的关联模型:\(model)")
}, failure: { error in
    print("查询失败:\(error.localizedDescription)")
})
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈