45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
|
|
<?php
|
|||
|
|
|
|||
|
|
namespace App\Http\Controllers\Api;
|
|||
|
|
|
|||
|
|
use App\BaseApp\BaseController;
|
|||
|
|
use App\Service\WechatThemeService;
|
|||
|
|
use Illuminate\Http\JsonResponse;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 自定义排版主题控制器:图文编辑器「我的模板」导入/列表/更新/删除
|
|||
|
|
* list/delete 走基类;create/update 覆盖直传 Service(清洗校验都在 Service 内)
|
|||
|
|
*/
|
|||
|
|
class WechatThemeController extends BaseController
|
|||
|
|
{
|
|||
|
|
public function __construct()
|
|||
|
|
{
|
|||
|
|
parent::__construct();
|
|||
|
|
$this->service = WechatThemeService::getInstance();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 导入模板(JSON 清洗入库)
|
|||
|
|
* @Method POST
|
|||
|
|
*/
|
|||
|
|
public function create(): JsonResponse
|
|||
|
|
{
|
|||
|
|
return jok($this->service->create(request()->post()), '导入成功');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 更新模板(名称/色板/样式整体覆盖)
|
|||
|
|
* @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), '更新成功');
|
|||
|
|
}
|
|||
|
|
}
|