feat: worksheet发布功能开发

This commit is contained in:
R524809
2026-04-24 17:49:11 +08:00
parent 5106dbbd7c
commit bb69d5c49d
24 changed files with 2540 additions and 1014 deletions
+37 -34
View File
@@ -66,32 +66,35 @@
### 3.3 集合:`worksheets`(题型配置)
| 字段 | BSON 类型 | 必填 | 说明 |
| ------------------ | --------------- | ---- | --------------------------------------------------------------- |
| `_id` | string | 是 | 主键;建议与后端一致用 cuid 或可读业务 ID。 |
| `title` | string | 是 | 标题,建议 ≤100 字符。 |
| `desc` | string | 是 | 描述,建议 ≤500 字符。 |
| `category` | string | 是 | 大类`math` \| `chinese` \| `english` \| `puzzle` \| `craft` |
| `subcategory` | string | 是 | 子类,建议 ≤50 字符。 |
| `ageMin` | int | 是 | 适龄最小值(与 Prisma 一致;替代原 `ageRange` 数组)。 |
| `ageMax` | int | 是 | 适龄最大值 |
| `difficulty` | int | 是 | 难度 1–4。 |
| `previewImage` | string | 是 | 预览图 URL/云存储 fileID,建议 ≤500 字符。 |
| `tags` | array\<string\> | 是 | 标签列表。 |
| `isNew` | bool | 是 | 是否新品,默认 `false` |
| `isHot` | bool | 是 | 是否热门,默认 `false` |
| `sortOrder` | int | 是 | 排序权重,默认 `0` |
| `downloadCount` | int | 是 | 下载次数,默认 `0` |
| `status` | string | 是 | `active` \| `draft` \| `hidden`,默认 `active` |
| `template` | string | 是 | 渲染模板类型 `TemplateType`,建议 ≤30 字符。 |
| `generator` | string | 是 | 生成器类型 `GeneratorType`,建议 ≤30 字符。 |
| `generatorConfig` | object | 是 | 生成器参数(JSON 对象)。 |
| `layoutConfig` | object | 是 | 排版参数(JSON 对象)。 |
| `userConfigurable` | object \| null | 否 | 用户可调整参数定义(JSON)。 |
| `legacyPage` | string \| null | 否 | 旧页面路径,迁移过渡用,建议 ≤200 字符。 |
| `createdAt` | date | 是 | 创建时间。 |
| `updatedAt` | date | 是 | 更新时间。 |
| 字段 | BSON 类型 | 必填 | 说明 |
| ------------- | --------------- | ---- | --------------------------------------------------- |
| `_id` | string | 是 | 主键;唯一的可读业务 ID。 |
| `title` | string | 是 | 标题,建议 ≤8 字符。 |
| `subtitle` | string | 是 | 副标题,建议 ≤12 字符。 |
| `category` | string | 是 | 大类 对应categories 表中parentId=null 的分类 |
| `subcategory` | string | 是 | 子类,建议 ≤50 字符。 |
| `ageMin` | int | 是 | 适龄最小值 |
| `ageMax` | int | 是 | 适龄最大值 |
| `grade` | int | 是 | 年级(-4=托班,-3=小班 ... 0=幼小衔接,1=一年级..) |
| `difficulty` | int | 是 | 难度 1-4(1=入门,2=基础,3=进阶,4=挑战) |
| `previewImg` | string | 是 | 预览图 URL/云存储 fileID |
| `tags` | array\<string\> | 是 | 标签列表。 |
| `isNew` | bool | 是 | 是否新品,默认 `false`。 |
| `isHot` | bool | 是 | 是否热门,默认 `false` |
| `sortOrder` | int | 是 | 排序权重,默认 `0`。 |
| `downloads` | int | 是 | 下载次数,默认 `0` |
| `likes` | int | 是 | 收藏此时,默认 `0` |
| `status` | string | 是 | `active` \| `draft` \| `hidden`,默认 `draft` |
| `createdAt` | date | 是 | 创建时间。 |
| `updatedAt` | date | 是 | 更新时间。 |
后续可能需要使用的字段,现在先不用
| `template` | string | 是 | 渲染模板类型 `TemplateType`,建议 ≤30 字符。 |
| `generator` | string | 是 | 生成器类型 `GeneratorType`,建议 ≤30 字符。 |
| `generatorConfig` | object | 是 | 生成器参数(JSON 对象)。 |
| `layoutConfig` | object | 是 | 排版参数(JSON 对象)。 |
| `userConfigurable` | object \| null | 否 | 用户可调整参数定义(JSON)。 |
| `legacyPage` | string \| null | 否 | 旧页面路径,迁移过渡用,建议 ≤200 字符。 |
**索引建议**
| 索引键 | 类型 | 说明 |
@@ -122,16 +125,16 @@
对应 Prisma `User``@@map("users")`)。**`openid` / `unionid``_id` 的取舍、`unionid` 写入方式**见 §3.2。
| 字段 | BSON 类型 | 必填 | 说明 |
| ---------------- | -------------- | ---- | -------------------------------------------------------------------- |
| 字段 | BSON 类型 | 必填 | 说明 |
| ---------------- | -------------- | ---- | ----------------------------------------------------------------------------------------------------- |
| `_id` | string | 是 | 主键;可与 Prisma `User.id` 一样使用 cuid,也可自定义为其它字符串,团队内与用户档案查询方式统一即可。 |
| `openid` | string | 是 | 当前小程序下微信用户标识;与 Prisma 一致建议 ≤100 字符;**业务唯一**,索引见下表。 |
| `unionid` | string \| null | 否 | 开放平台下跨应用用户标识;建议 ≤100 字符;未绑开放平台或未返回时为空。 |
| `nickName` | string \| null | 否 | 用户昵称;建议 ≤50 字符。 |
| `avatarUrl` | string \| null | 否 | 头像 URL 或云存储 fileID;建议 ≤500 字符。 |
| `totalDownloads` | int | 是 | 累计下载次数,默认 `0`。 |
| `createdAt` | date | 是 | 首次创建时间。 |
| `lastActiveAt` | date | 是 | 最近一次活跃时间(登录、打开小程序、写库等策略由实现约定)。 |
| `openid` | string | 是 | 当前小程序下微信用户标识;与 Prisma 一致建议 ≤100 字符;**业务唯一**,索引见下表。 |
| `unionid` | string \| null | 否 | 开放平台下跨应用用户标识;建议 ≤100 字符;未绑开放平台或未返回时为空。 |
| `nickName` | string \| null | 否 | 用户昵称;建议 ≤50 字符。 |
| `avatarUrl` | string \| null | 否 | 头像 URL 或云存储 fileID;建议 ≤500 字符。 |
| `totalDownloads` | int | 是 | 累计下载次数,默认 `0` |
| `createdAt` | date | 是 | 首次创建时间。 |
| `lastActiveAt` | date | 是 | 最近一次活跃时间(登录、打开小程序、写库等策略由实现约定)。 |
**索引建议**