小程序后端增强绑定能力并支持多设备列表

This commit is contained in:
stu2not
2026-04-16 18:20:56 +08:00
parent 0683de528a
commit fb78863ee6
3 changed files with 79 additions and 1 deletions

View File

@@ -31,6 +31,12 @@ class BindingService:
def get_current_binding(self, user_id: int) -> Optional[Mapping]:
return self.dao.get_current_by_user(user_id)
def list_bindings(self, user_id: int, limit: int = 20, cursor: int = None) -> tuple[list, bool]:
rows = self.dao.list_by_user(user_id, limit, cursor)
has_more = len(rows) > limit
rows = rows[:limit]
return rows, has_more
def direct_bind(self, device_id: str, child_id: int | None, user_id: int) -> Mapping:
self.dao.direct_bind(device_id, child_id, user_id)
return {"device_id": device_id, "child_id": child_id}