feat: Device snapshot delete api (#1294)

### **快照删除 API 详情**

* **请求地址**: `http://[手机IP]:[端口]/api/deleteSnapshot`
* **请求方法**: `POST`
* **请求头**: `Content-Type: application/json`
* **请求体 (JSON)**:
```json
{
  "id": 123456789
}

```

*(注:`id` 为长整型数字,不加引号)*
* **预期响应**:
```json
{
  "message": "快照删除成功"
}

```
This commit is contained in:
Ling0402
2026-03-05 19:41:07 +08:00
committed by GitHub
parent 5cbfab329f
commit 2d701d46fc

View File

@@ -214,6 +214,18 @@ private fun CoroutineScope.createServer(port: Int) = embeddedServer(CIO, port) {
}
call.respond(list)
}
post("/deleteSnapshot") {
val data = call.receive<ReqId>()
val allSnapshots = DbSet.snapshotDao.query().first()
val snapshot = allSnapshots.find { it.id == data.id }
if (snapshot != null) {
SnapshotExt.removeSnapshot(data.id)
DbSet.snapshotDao.delete(snapshot)
call.respond(RpcOk("快照删除成功"))
} else {
throw RpcError("快照不存在或已被删除")
}
}
post("/updateSubscription") {
val subscription =
RawSubscription.parse(call.receiveText(), json5 = false)