模型与约定
APP 与后台共用的字段语义、状态枚举
User
表:users
· API 永不返回 password_hash、last_login_*、deleted_at 等敏感/内部字段。
| 字段 | 说明 |
|---|---|
id |
int, 用户 ID |
email |
string, 登录邮箱 |
username |
string, 用户名;可空串 |
nickname |
string, 昵称 |
avatar_url |
string, 头像路径/URL;可空串 |
signature |
string, 个性签名;可空串 |
bio |
string, 自我介绍;可空串 |
country |
string, 国家/地区 ISO 3166-1 alpha-2,如 US / JP / KR;可空串 |
device_lang |
string, 设备系统语言 BCP 47,如 en-US / ja-JP;可空串 |
locale |
string, 当前 APP 使用语言:en/zh/ja/ko/de/fr/es/it/pt/nl/pl;可空串 |
timezone |
string, 设备时区 IANA,如 America/New_York / Asia/Tokyo;可空串 |
status |
int, 0待验证 1正常 2禁用 3注销 |
email_verified_at |
string|null, 邮箱验证时间 UTC |
created_at |
string|null, 注册时间 UTC |
JSON 示例
{
"id": 1,
"email": "[email protected]",
"username": "demo_user",
"nickname": "Demo",
"avatar_url": "/uploads/avatars/u1_a8fdeec9ac68d6ff.jpg",
"signature": "热爱串珠的手作人",
"bio": "分享串珠作品与材料心得。",
"country": "US",
"device_lang": "en-US",
"locale": "en",
"timezone": "America/New_York",
"status": 1,
"email_verified_at": "2026-08-01 10:00:00",
"created_at": "2026-08-01 10:00:00"
}
PatternCard
表:patterns
· 列表接口 list[] 元素结构。
| 字段 | 说明 |
|---|---|
id |
int, 图纸 ID |
title |
string, 标题 |
description |
string, 简介 |
cover_url |
string, 封面图 URL |
category |
object|null, {id, slug, name};name 随语言本地化,slug 固定;未分类为 null |
width |
int, 格数宽 |
height |
int, 格数高 |
color_count |
int, 用色数 |
bead_count |
int, 拼豆数量 |
difficulty |
int, 难度 1–5 |
view_count |
int, 浏览量 |
like_count |
int, 点赞数 |
favorite_count |
int, 收藏数 |
heat |
int, 热度=like×3+favorite×2+view |
published_at |
string|null, 发布时间 UTC |
created_at |
string|null, 创建时间 UTC |
author |
object, {id, username, nickname, avatar_url};作者已注销时 nickname 为本地化文案 |
JSON 示例
{
"id": 2,
"title": "草莓拼豆图纸",
"description": "可爱草莓,粉红主色,适合钥匙扣。",
"cover_url": "/uploads/patterns/demo_strawberry.png",
"category": {
"id": 5,
"slug": "fruit",
"name": "Fruit"
},
"width": 24,
"height": 28,
"color_count": 12,
"bead_count": 520,
"difficulty": 1,
"view_count": 920,
"like_count": 86,
"favorite_count": 30,
"heat": 1238,
"published_at": "2026-08-02 08:04:54",
"created_at": "2026-08-02 08:04:54",
"author": {
"id": 2,
"username": "pixel_cat",
"nickname": "像素猫",
"avatar_url": ""
}
}
PatternDetail
表:patterns
· 详情在 data.pattern 下。
| 字段 | 说明 |
|---|---|
id |
int, 图纸 ID |
title |
string, 标题 |
description |
string, 简介 |
cover_url |
string, 封面图 URL |
category |
object|null, {id, slug, name};name 随语言本地化,slug 固定;未分类为 null |
width |
int, 格数宽 |
height |
int, 格数高 |
color_count |
int, 用色数 |
bead_count |
int, 拼豆数量 |
difficulty |
int, 难度 1–5 |
view_count |
int, 浏览量 |
like_count |
int, 点赞数 |
favorite_count |
int, 收藏数 |
heat |
int, 热度=like×3+favorite×2+view |
published_at |
string|null, 发布时间 UTC |
created_at |
string|null, 创建时间 UTC |
author |
object, {id, username, nickname, avatar_url};作者已注销时 nickname 为本地化文案 |
images |
array<string> |
status |
int |
liked |
bool |
author.followed |
bool |
JSON 示例
{
"id": 2,
"title": "草莓拼豆图纸",
"description": "可爱草莓,粉红主色,适合钥匙扣。",
"cover_url": "/uploads/patterns/demo_strawberry.png",
"category": {
"id": 5,
"slug": "fruit",
"name": "Fruit"
},
"width": 24,
"height": 28,
"color_count": 12,
"bead_count": 520,
"difficulty": 1,
"view_count": 920,
"like_count": 86,
"favorite_count": 30,
"heat": 1238,
"published_at": "2026-08-02 08:04:54",
"created_at": "2026-08-02 08:04:54",
"author": {
"id": 2,
"username": "pixel_cat",
"nickname": "像素猫",
"avatar_url": "",
"followed": false
},
"images": [
"/uploads/patterns/demo_strawberry.png",
"/uploads/patterns/demo_strawberry_2.png"
],
"status": 1,
"liked": false
}
PatternCategory
表:pattern_categories
| 字段 | 说明 |
|---|---|
id |
int |
slug |
string |
name |
string |
sort_order |
int |
JSON 示例
{
"id": 5,
"slug": "fruit",
"name": "Fruit",
"sort_order": 50
}
Author
表:users
· 图纸上的画师摘要,不含 email。
| 字段 | 说明 |
|---|---|
id |
int |
username |
string |
nickname |
string |
avatar_url |
string |
followed |
bool, 仅详情等场景 |
JSON 示例
{
"id": 2,
"username": "pixel_cat",
"nickname": "像素猫",
"avatar_url": "",
"followed": false
}
通用约定
- 仅 Email 注册登录
- 密码只存 hash,API 永不回传
password_hash - 时间:UTC 文本,如
2026-08-01 12:00:00 - 统一响应:
{ "code":0, "message":"ok", "data": ... } - 验证码 mock 固定
1111;会话 refresh 哈希存user_sessions - 当前范围:认证 + 用户资料 + 图纸社区