优化部分代码,增加微信公众号模板
This commit is contained in:
97
app/Http/Controllers/Api/WechatArticleController.php
Normal file
97
app/Http/Controllers/Api/WechatArticleController.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\BaseApp\BaseController;
|
||||
use App\Service\WechatArticleService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
* 公众号图文控制器:CRUD / 版本流水 / 版本回退 / 一键发布 / 发布状态
|
||||
* 图文正文(content_md)体量大且含任意字符,create/update 覆盖基类直接透传给 Service 白名单处理
|
||||
*/
|
||||
class WechatArticleController extends BaseController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->service = WechatArticleService::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Method NO
|
||||
*/
|
||||
public function option(): mixed
|
||||
{
|
||||
return jerr('不支持');
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增图文(标题必填在 Service 校验;创建即落 v1 版本流水)
|
||||
* @Method POST
|
||||
*/
|
||||
public function create(): JsonResponse
|
||||
{
|
||||
return jok($this->service->create(request()->post()), '创建成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新图文(版本号 +1 并落「修改」流水)
|
||||
* @Method POST
|
||||
*/
|
||||
public function update(): JsonResponse
|
||||
{
|
||||
$params = request()->post();
|
||||
$id = (int) ($params['id'] ?? 0);
|
||||
if ($id <= 0) {
|
||||
return jerr('参数错误');
|
||||
}
|
||||
unset($params['id']);
|
||||
return jok($this->service->update($id, $params), '更新成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 版本流水分页(?article_id=)
|
||||
* @Method GET
|
||||
*/
|
||||
public function versionList(): JsonResponse
|
||||
{
|
||||
return jok($this->service->versionList((int) request()->get('article_id', 0)), '获取成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 单版本详情(含正文快照,回退前预览)
|
||||
* @Method GET
|
||||
*/
|
||||
public function versionDetail(): JsonResponse
|
||||
{
|
||||
return jok($this->service->versionDetail((int) request()->get('id', 0)), '获取成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 版本回退 {id, version_id}
|
||||
* @Method POST
|
||||
*/
|
||||
public function rollback(): JsonResponse
|
||||
{
|
||||
return jok($this->service->rollback(request()->post()), '回退成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键发布 {id, content_html, account_id?}(content_html 为前端渲染好的内联样式 HTML)
|
||||
* @Method POST
|
||||
*/
|
||||
public function publish(): JsonResponse
|
||||
{
|
||||
return jok($this->service->publish(request()->post()), '已提交发布,正在审核');
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询发布状态并回填(?id=)
|
||||
* @Method GET
|
||||
*/
|
||||
public function publishStatus(): JsonResponse
|
||||
{
|
||||
return jok($this->service->publishStatus((int) request()->get('id', 0)), '获取成功');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user