签入版本

This commit is contained in:
小蚂蚁云
2026-10-25 17:24:27 +08:00
parent 48911cc08f
commit fdbeae092a
1010 changed files with 30682 additions and 95274 deletions
+49 -45
View File
@@ -1,59 +1,63 @@
# 3.10 完整代码清单
# 3.11 完整代码清单
:::tip 概述
本节汇总 example(案例演示)模块涉及的所有文件,方便开发时快速定位。
本页汇总 example 模块的全部文件与职责,作为手工开发的核对清单。各文件完整实现见本章对应小节。
:::
## 后端文件清单
## 文件总览
| 文件路径 | 说明 | 核心内容 |
|----------|------|----------|
| `app/model/Example.php` | 数据模型 | 继承 BaseModel,声明表名 `example` |
| `app/validate/ExampleValidate.php` | 验证器 | name 字段必填,add/update 场景 |
| `app/logic/ExampleLogic.php` | 业务逻辑 | 属性配置 + import/export 方法 |
| `app/controller/ExampleController.php` | 控制器 | 9 个接口(page/list/detail/add/update/delete/batchDelete/import/export) |
| `route/app.php` | 路由 | 第 371~383 行,9 条路由 |
| 文件 | 层 | 核心内容 |
|---|---|---|
| 数据库 `gin_example` | — | 11 列(含审计四件套 + del_flag),3 个普通索引 |
| `internal/model/dto/example.go` | 契约 | ExampleItem / PageReq / ListReq / DetailReq / AddReq / UpdateReq / StatusReq / DeleteReq / BatchDeleteReq / ImportReq+UnmarshalBody / ImportRes+ResMsg / ExportReq / ExportRes |
| `internal/repository/example.go` | 数据访问 | ExampleRepo + NewExampleRepo(表名 gin_example)+ Ctx |
| `internal/service/example.go` | 业务 | sExample 三段式;exampleSpec(ModuleSpec 声明);exampleToData;标准七方法 + Status/Import/Export 手写 |
| `internal/handler/example.go` | 接口 | CExample + 十个委托方法 |
| `internal/router/router.go` | 路由 | CExample 的 RouteSpec 表(10 条声明) |
| `ui/src/api/tool/example.ts` | 前端 API | 与十个接口对应的请求函数 |
| `ui/src/views/tool/example/` | 前端页面 | 列表 + 编辑 |
## 前端文件清单
## 接口一览(RouteSpec 派生)
| 文件路径 | 说明 |
|----------|------|
| `ui/src/api/tool/example.ts` | API 接口模块(9 个函数) |
| `ui/src/views/tool/example/index.vue` | 列表页 |
| `ui/src/views/tool/example/edit.vue` | 新增/编辑弹窗 |
| `ui/src/views/tool/example/detail.vue` | 详情弹窗 |
| `ui/src/views/tool/example/columns.ts` | 表格列配置 |
| `ui/src/views/tool/example/querySchemas.ts` | 查询条件配置 |
| 方法 | 路径 | 权限码 | 日志类型 |
|---|---|---|---|
| Page | GET /api/example/page | sys:example:page | query |
| List | GET /api/example/list | sys:example:list | query |
| Detail | GET /api/example/detail/:id | sys:example:detail | query |
| Add | POST /api/example/add | sys:example:add | add |
| Update | PUT /api/example/update | sys:example:update | update |
| Status | PUT /api/example/status | sys:example:status | update |
| Delete | DELETE /api/example/delete/:id | sys:example:delete | delete |
| BatchDelete | DELETE /api/example/batchDelete | sys:example:batchDelete | delete |
| Import | POST /api/example/import | sys:example:import | import |
| Export | GET /api/example/export | sys:example:export | export |
## 数据库
## 能力与实现对照
| 对象 | 说明 |
|------|------|
| `think_example` 表 | 案例演示数据表 |
| 能力 | 实现位置 |
|---|---|
| name 模糊 / type、status 等值过滤 | exampleSpec.LikeFields / EqFields |
| status → statusText 字典回填 | exampleSpec.SerializeMaps |
| avatar 写侧转正、读侧补域名 | exampleSpec.FileFields + FileSaveDir |
| 全量表单语义更新 | ToData + 全局 Update 钩子盖章 |
| 软删除 | 基座 Delete/BatchDelete(del_flag=1) |
| 单列状态更新 | 手写 Status |
| 导入逐行校验 | 手写 Import + UnmarshalBody |
| 导出过滤复用 + 字典翻译 | 手写 Export(applyFilters + DictGetText) |
| 权限/日志 | RouteSpec.Permission / Log 声明,中间件执行 |
## 权限节点
## 自检
| 权限码 | 说明 |
|--------|------|
| `sys:example:page` | 案例演示分页列表 |
| `sys:example:add` | 添加案例演示 |
| `sys:example:update` | 修改案例演示 |
| `sys:example:delete` | 删除案例演示 |
| `sys:example:import` | 导入案例演示 |
| `sys:example:export` | 导出案例演示 |
完成后逐项核对:
## 字典数据
- [ ] 十个接口全部可访问,权限码与菜单节点一致
- [ ] 分页返回 `PageData` 五字段(records/total/size/current/pages)
- [ ] statusText 有值(字典 example_status 已配置项)
- [ ] avatar 上传后转正到 `upload/example/yyyymmdd/`,读侧返回完整 URL
- [ ] 导入失败行有逐行原因,ResMsg 提示语正确
- [ ] 导出返回可下载的文件 URL
- [ ] 删除后列表不可见(软删),数据库 del_flag=1
| 字典编码 | 说明 | 字典项 |
|---------|------|--------|
| `example_type` | 案例类型 | 按实际配置 |
| `example_status` | 案例状态 | 0=禁用, 1=启用 |
## 下一步
## 代码生成器替代方案
example 模块本身就是代码生成器的参考模板。如果需要生成类似模块:
1. 建好数据库表
2. 访问代码生成器页面
3. 选择表,点击生成
4. 自动创建 Controller / Logic / Model / Validate / 前端文件
→ [3.12 常见问题与排错](/zh/guide/faq.html)