Files
nl-admin-api/app/Http/Controllers/Api/WechatThemeController.php
李琦 6e2769c528
Some checks failed
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled
优化部分代码,增加微信公众号模板
2026-08-13 19:02:05 +08:00

45 lines
1.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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), '更新成功');
}
}