react-phone-apps/.blueprint/modules/local-data-layer.md
lanrtop 3dbc6f0ff5 refactor: 标记点序号显示、布局叠加方式及照片选择器重构
- 标记点角标从物品数量改为按楼层顺序编号,角标背景色跟随标记颜色
- FoldableLayout 改为绝对定位叠加布局,移除 LayoutAnimation(解决 Android 地图渲染空白及卡顿)
- PhotoPicker 拆分为拍照/选图两个独立按钮;选图改用 expo-document-picker 绕过三星 Photo Picker 崩溃问题
- AndroidManifest 移除手动 FileProvider 声明(改由 Expo 插件自动注入)
- 同步更新蓝图文档:新增 category-management 模块、补全各模块已完成任务卡

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-10 02:17:34 +09:00

53 lines
2.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
id: local-data-layer
name: 本地数据持久化层
area: data
status: done
---
## 概述
基于 Expo SQLite 的本地数据库层,管理标记点、物品记录、照片路径、物品分类四张核心表。所有写操作使用事务保证原子性,供上层功能模块调用。支持在线迁移:每次启动检测旧库结构并补列/重建表,无需用户操作。
## 任务卡
### ✅ SQLite 初始化与 Schema 建表
- status: done
- complexity: M
- files: apps/property-survey/src/db/database.ts, apps/property-survey/src/db/schema.ts
- acceptance: App 启动时自动执行 CREATE TABLE IF NOT EXISTS建立 markers / items / photos / categories 四张表,重复启动不报错;首次启动写入默认分类;字段与设计文档一致
### ✅ 在线迁移脚本
- status: done
- complexity: M
- files: apps/property-survey/src/db/database.ts
- acceptance: 启动时检测旧库并执行:①为 items 添加 reference_price / spec / unit / confirmed_at 列;②重建 markers 表以扩展 floor CHECK 约束支持第4楼楼顶③为旧库初始化 categories 默认数据;所有迁移幂等,多次执行不报错
### ✅ 标记点 CRUD 操作
- status: done
- complexity: M
- files: apps/property-survey/src/db/markers.ts
- depends: local-data-layer
- acceptance: 提供 insertMarker / getMarkersByFloor / updateMarker / deleteMarker 四个函数deleteMarker 级联删除关联 items 和 photos所有函数返回类型安全的 Promisefloor 支持 1/2/3/4
### ✅ 物品记录 CRUD 操作
- status: done
- complexity: M
- files: apps/property-survey/src/db/items.ts
- depends: local-data-layer
- acceptance: 提供 insertItem / getItemsByMarker / updateItem / deleteItem 四个函数;字段含 name / category / quantity / unit / spec / estimatedValue / referencePrice / remark / confirmedAt返回带关联照片数量的扩展类型
### ✅ 照片路径 CRUD 操作
- status: done
- complexity: S
- files: apps/property-survey/src/db/photos.ts
- depends: local-data-layer
- acceptance: 提供 insertPhoto / getPhotosByItem / deletePhoto / reorderPhotos 四个函数deletePhoto 同步删除设备文件系统中的对应图片文件
### ✅ 分类 CRUD 操作
- status: done
- complexity: S
- files: apps/property-survey/src/db/categories.ts
- depends: local-data-layer
- acceptance: 提供 getCategories / insertCategory / updateCategory / deleteCategory 四个函数;新增时自动计算 sort_order追加到末尾name 字段有 UNIQUE 约束