feat(xinhan): scaffold xinhan folder; add schema.md with SQL docs; plan for xinhan UI

This commit is contained in:
root
2026-04-04 06:04:47 +00:00
Unverified
parent c08afe33d9
commit 4e467f5e66
2 changed files with 53 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
# Xinhan 数据表结构说明
本文档提供针对 xinhan 表的 SQL 创建语句与示例查询。注意:以下 SQL 仅用于创建结构;本任务仅生成 MD 文档,不执行 SQL。
## 数据字段与含义
- recipient: 收件人,为文本类型,必填
- content: 内容物,文本型,可包含多行描述
- sent_date: 寄出日期,时间戳(timestamptz/ TIMESTAMP),必填
- destination: 寄达地,文本
- arrival_date: 寄达日期,时间戳
## 建表 SQLPostgreSQLSupabase/ Postgres 兼容)
```sql
CREATE TABLE xinhan (
id SERIAL PRIMARY KEY,
recipient TEXT NOT NULL,
content TEXT,
sent_date TIMESTAMP WITHOUT TIME ZONE NOT NULL,
destination TEXT,
arrival_date TIMESTAMP WITHOUT TIME ZONE
);
-- 索引,提升按收件人、寄出日期/寄达日期的查询性能
CREATE INDEX IF NOT EXISTS idx_xinhan_recipient ON xinhan (recipient);
CREATE INDEX IF NOT EXISTS idx_xinhan_sent_date ON xinhan (sent_date);
CREATE INDEX IF NOT EXISTS idx_xinhan_arrival_date ON xinhan (arrival_date);
```
## 示例查询
```sql
-- 查询某个收件人相关信函的简单示例
SELECT * FROM xinhan
WHERE recipient ILIKE '%张三%'
ORDER BY sent_date DESC
LIMIT 100;
-- 根据日期范围查询示例
SELECT * FROM xinhan
WHERE sent_date BETWEEN '2024-01-01' AND '2026-12-31'
ORDER BY sent_date DESC;
```
> 说明:此文件仅用于记录数据库结构与查询示例,实际部署请在你的数据库实例中执行上述 SQL。