From b77fc175314c63c1ec76beb66aa0b5d1143c59c7 Mon Sep 17 00:00:00 2001 From: linda Date: Thu, 15 Oct 2026 15:25:13 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E8=A1=A5=E5=85=85=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=AB=AF=E5=AE=9E=E7=8E=B0=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=EF=BC=88=E7=94=9F=E6=88=90=E6=96=B9=E5=BC=8F/=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E7=BB=93=E6=9E=84/=E4=B8=9A=E5=8A=A1=E5=8A=A8?= =?UTF-8?q?=E4=BD=9C/=E9=AA=8C=E8=AF=81=E6=96=B9=E6=B3=95=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/05-后端实现规范.md | 78 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/docs/05-后端实现规范.md b/docs/05-后端实现规范.md index 7bed718..b8e328d 100644 --- a/docs/05-后端实现规范.md +++ b/docs/05-后端实现规范.md @@ -132,3 +132,81 @@ $this->fail('信息不存在', 404); // 自定义业务码 - 金额 `round($x, 2)`;时间统一 `time()` - 后台写入类动作需调用 `$this->adminLog('动作描述')` 留痕 - **不要**修改 `V1.php` / `route.php` / `FcInstall.php` / `Auth.php` + +--- + +## 七、后台管理端(FastAdmin PC) + +### 7.1 为什么需要它 + +`/api/v1/admin/**` 的 35 个接口此前**没有任何可用界面**: +FastAdmin PC 后台 110 条菜单中 0 条业务菜单,小程序端仅有 1 个 LOGO/图标设置页。 +即「后台功能」实际无处可操作 —— 这是「后台功能与前端不同步」的根本原因。 + +### 7.2 生成方式(FastAdmin 原生) + +用框架自带的 CRUD 生成器为 17 张业务表生成标准管理模块: + +```bash +php think crud -t fc_post -c fc/post -m FcPost -u 1 -f 1 --no-interaction \ + --intdatesuffix=createtime,updatetime,paytime,settletime \ + --switchsuffix=enabled,status,isread,is_member,top,is_paid,is_top \ + --imagefield=logo,license,cover,image --editorsuffix=content \ + --jsonsuffix=media,images +``` + +产出物(均已纳入版本库): + +| 类型 | 路径 | +| --- | --- | +| 控制器 | `application/admin/controller/fc/*.php`(继承 `app\common\controller\Backend`) | +| 模型 | `application/admin/model/Fc*.php` | +| 视图 | `application/admin/view/fc//{index,add,edit}.html` | +| 后台 JS | `public/assets/js/backend/fc/*.js` | +| 语言包 | `application/admin/lang/zh-cn/fc/*.php` | + +### 7.3 菜单结构(固化在 `FcInstall::menu()`,幂等) + +执行 `php think fc:install` 会自动建成如下菜单树(可重复执行): + +``` +同城业务 (fc) +├── 内容管理 分类管理 / 轮播管理 / 信息管理 / 评价管理 / 举报处理 +├── 用户与商家 商家管理 / 会员管理 / 消息管理 +├── 交易管理 订单管理 / 会员套餐 / 资金流水 / 佣金明细 / 付费查看记录 +├── 分销管理 分销关系 / 提现审核 +└── 基础数据 服务区域 / 草稿箱 +``` + +> 超级管理员组(`fa_auth_group.id=1`)的 `rules` 为 `*`,新菜单自动全部可见。 +> 其它角色组需在「权限管理 → 角色管理」中勾选授权。 + +### 7.4 一键业务操作(在 CRUD 之上补的业务动作) + +| 路由 | 动作 | 说明 | +| --- | --- | --- | +| `fc/post/audit` | 审核通过/驳回 | BR-11 校验;通过时分类信息量 +1;发站内信 | +| `fc/post/offline` | 下架 | `status=0` + 站内信 | +| `fc/merchant/audit` | 商家资质审核 | 通过时同步用户身份为商家、`shop_status=normal` | +| `fc/withdraw/pay` | 打款/驳回 | 驳回必须填原因(BR-09);打款写资金流水 | +| `fc/order/refund` | 退款 | 金额须 >0(BR-10) | +| `fc/order/supplement` | 按订单号补单 | 幂等;写资金流水 | +| `fc/comment/reply` | 回复评价 | 内容必填;发站内信 | +| `fc/comment/top` | 置顶/取消置顶 | — | +| `fc/report/handle` | 举报标记已处理 | — | + +以上动作的错误文案与 `/api/v1/**` **完全一致**(复用同一套业务规则)。 + +### 7.5 验证方式 + +```bash +# 登录取 cookie(FastAdmin 表单需 __token__) +PAGE=$(curl -s -c /tmp/cj.txt 'http://127.0.0.1/s.php/index/login' -H 'Host: 域名') +TOKEN=$(echo "$PAGE" | grep -oE 'name="__token__"[^>]*value="[^"]+"' | grep -oE 'value="[^"]+"' | cut -d'"' -f2) +curl -s -c /tmp/cj.txt -b /tmp/cj.txt -X POST 'http://127.0.0.1/s.php/index/login' -H 'Host: 域名' \ + --data-urlencode "username=admin" --data-urlencode "password=***" --data-urlencode "__token__=$TOKEN" + +# 列表数据(bootstrap-table) +curl -s -b /tmp/cj.txt 'http://127.0.0.1/s.php/fc/post/index?offset=0&limit=3&sort=id&order=desc' \ + -H 'Host: 域名' -H 'X-Requested-With: XMLHttpRequest' +```