238 lines
4.5 KiB
Markdown
238 lines
4.5 KiB
Markdown
|
|
# 企业自建站点自动发文系统 v1
|
|||
|
|
|
|||
|
|
## 定位
|
|||
|
|
|
|||
|
|
企业自建站点不是 UGC 媒体账号,也不应该走桌面客户端登录态。它是客户自有 CMS 的站点连接,由 Geo SaaS 服务端通过 CMS 适配器直接调用发布接口。
|
|||
|
|
|
|||
|
|
媒体管理建议分三类:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
UGC媒体平台 走桌面客户端账号授权和发布队列
|
|||
|
|
第三方新闻源 走资源/订单/投稿线索
|
|||
|
|
企业自建站点 走 CMS 连接、栏目同步、服务端发布
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 核心模型
|
|||
|
|
|
|||
|
|
建议新增站点连接表:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
enterprise_site_connections
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
关键字段:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
id
|
|||
|
|
tenant_id
|
|||
|
|
name
|
|||
|
|
site_url
|
|||
|
|
cms_type pbootcms / wordpress / dedecms / phpcms
|
|||
|
|
auth_type native_api / application_password / plugin_token
|
|||
|
|
credential_ref 凭证密文或凭证引用
|
|||
|
|
status draft / connected / error / disabled
|
|||
|
|
last_ping_at
|
|||
|
|
last_sync_at
|
|||
|
|
last_error
|
|||
|
|
created_at
|
|||
|
|
updated_at
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
栏目缓存表:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
enterprise_site_categories
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
关键字段:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
id
|
|||
|
|
tenant_id
|
|||
|
|
connection_id
|
|||
|
|
remote_id
|
|||
|
|
parent_remote_id
|
|||
|
|
name
|
|||
|
|
slug
|
|||
|
|
raw_payload
|
|||
|
|
synced_at
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
发布记录可复用现有发布记录体系,也可以增加 `target_type=enterprise_site` 与 `target_connection_id`。不要把企业站点伪装成 `platform_account`,否则后续 WordPress、PBootCMS 插件、DedeCMS 插件会和桌面端账号模型缠在一起。
|
|||
|
|
|
|||
|
|
## 统一适配器协议
|
|||
|
|
|
|||
|
|
所有 CMS 适配器都实现:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
ping(connection) -> SiteCapability
|
|||
|
|
categories(connection, options) -> Category[]
|
|||
|
|
publish(connection, article, options) -> PublishResult
|
|||
|
|
update(connection, remoteId, article, options) -> PublishResult
|
|||
|
|
status(connection, remoteId) -> RemoteContentStatus
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
返回结构:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
SiteCapability:
|
|||
|
|
cms_type
|
|||
|
|
plugin_version
|
|||
|
|
site_url
|
|||
|
|
site_name
|
|||
|
|
api_auth
|
|||
|
|
|
|||
|
|
Category:
|
|||
|
|
id
|
|||
|
|
parent_id
|
|||
|
|
title
|
|||
|
|
slug
|
|||
|
|
raw
|
|||
|
|
|
|||
|
|
PublishResult:
|
|||
|
|
remote_id
|
|||
|
|
url
|
|||
|
|
status
|
|||
|
|
raw
|
|||
|
|
|
|||
|
|
RemoteContentStatus:
|
|||
|
|
remote_id
|
|||
|
|
title
|
|||
|
|
status
|
|||
|
|
url
|
|||
|
|
updated_at
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## PBootCMS v1
|
|||
|
|
|
|||
|
|
集成方式:站点放置单文件插件。
|
|||
|
|
|
|||
|
|
插件路径:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
integrations/pbootcms/apps/api/controller/GeoPublisherController.php
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
客户站点安装到:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
apps/api/controller/GeoPublisherController.php
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
接口:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
GET /api/GeoPublisher/ping
|
|||
|
|
GET /api/GeoPublisher/categories
|
|||
|
|
POST /api/GeoPublisher/publish
|
|||
|
|
POST /api/GeoPublisher/update
|
|||
|
|
GET /api/GeoPublisher/status
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
鉴权使用 PBootCMS 原生 API 参数:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
appid
|
|||
|
|
timestamp
|
|||
|
|
signature = md5(md5(appid + api_secret + timestamp))
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
适配器保存:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
site_url
|
|||
|
|
appid
|
|||
|
|
api_secret
|
|||
|
|
default_acode
|
|||
|
|
default_mcode
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## WordPress v1
|
|||
|
|
|
|||
|
|
优先使用 WordPress REST API 和 Application Password:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
GET /wp-json/
|
|||
|
|
GET /wp-json/wp/v2/categories
|
|||
|
|
POST /wp-json/wp/v2/posts
|
|||
|
|
POST /wp-json/wp/v2/posts/{id}
|
|||
|
|
GET /wp-json/wp/v2/posts/{id}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
鉴权:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
Basic base64(username:application_password)
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
WordPress 不需要客户安装插件即可完成基础发文;如果后续要支持自定义字段、SEO 插件字段、图片本地化、内链策略,再提供 WordPress 插件增强。
|
|||
|
|
|
|||
|
|
## DedeCMS / PHPCMS v1
|
|||
|
|
|
|||
|
|
建议走与 PBootCMS 相同的单文件插件协议,不直接侵入后台登录。
|
|||
|
|
|
|||
|
|
原因:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
老版本安全差异大
|
|||
|
|
后台路径常被改名
|
|||
|
|
字段模型定制多
|
|||
|
|
原生 API 能力不统一
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
插件统一暴露:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
ping / categories / publish / update / status
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
SaaS 侧只新增 `cms_type` 适配器,不改发布业务协议。
|
|||
|
|
|
|||
|
|
## 发布链路
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
文章生成完成
|
|||
|
|
选择发布目标:企业自建站点
|
|||
|
|
读取 connection + category mapping
|
|||
|
|
服务端调用 CmsPublisherAdapter.publish
|
|||
|
|
保存 remote_id/url/raw response
|
|||
|
|
同步状态和错误
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
失败重试策略:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
网络超时:可重试
|
|||
|
|
401/403:标记连接异常,要求重新绑定
|
|||
|
|
栏目不存在:停止重试,要求重新同步栏目
|
|||
|
|
CMS 返回字段错误:停止重试,记录原始响应
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 安全要求
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
凭证不得明文回显给前端
|
|||
|
|
日志不得打印 api_secret/application_password/plugin_token
|
|||
|
|
发布接口只允许 HTTPS 站点进入生产发布
|
|||
|
|
支持手动禁用连接
|
|||
|
|
记录每次 ping/sync/publish 的错误摘要和时间
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 后台页面 v1
|
|||
|
|
|
|||
|
|
媒体管理页新增 `企业自建站点` 标签。
|
|||
|
|
|
|||
|
|
首版页面应提供:
|
|||
|
|
|
|||
|
|
```text
|
|||
|
|
站点连接列表
|
|||
|
|
CMS 类型
|
|||
|
|
连通状态
|
|||
|
|
栏目同步时间
|
|||
|
|
最近发布结果
|
|||
|
|
安装插件入口
|
|||
|
|
新增连接入口
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
在后端 API 完成前,前端可以先展示结构化空态和接入流程,但路由/术语要按最终模型命名,避免后续返工。
|