初始化
缺陷:主题配色需要优化整体的同风格
This commit is contained in:
91
app/Http/Controllers/Api/WxTemplateController.php
Normal file
91
app/Http/Controllers/Api/WxTemplateController.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\BaseApp\BaseController;
|
||||
use App\Service\business\WxTemplateSchemaService;
|
||||
use App\Service\business\WxTemplateService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
* 小程序装修模板
|
||||
*/
|
||||
class WxTemplateController extends BaseController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->service = WxTemplateService::getInstance();
|
||||
$this->insertField = ['name', 'code'];
|
||||
$this->updateField = ['id'];
|
||||
$this->notRequest = [
|
||||
'preview', 'style_tag', 'tokens', 'layout', 'app_code', 'sort', 'name', 'code',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用/停用
|
||||
* @Method POST
|
||||
*/
|
||||
public function status(): JsonResponse
|
||||
{
|
||||
return jok(
|
||||
$this->service->status(request()->post('id'), request()->post('status')),
|
||||
'操作成功'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设为默认
|
||||
* @Method POST
|
||||
*/
|
||||
public function setDefault(): JsonResponse
|
||||
{
|
||||
return jok($this->service->setDefault((int) request()->post('id', 0)), '已设为默认');
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出模板 JSON
|
||||
* @Method POST
|
||||
*/
|
||||
public function export(): JsonResponse
|
||||
{
|
||||
return jok($this->service->export((array) request()->post('ids', [])));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入模板 JSON
|
||||
* @Method POST
|
||||
*/
|
||||
public function import(): JsonResponse
|
||||
{
|
||||
return jok(
|
||||
$this->service->import((array) request()->post('payload', []), (bool) request()->post('overwrite', false)),
|
||||
'导入完成'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用内置 20 套预设初始化模板库
|
||||
* @Method POST
|
||||
*/
|
||||
public function initPresets(): JsonResponse
|
||||
{
|
||||
return jok(
|
||||
$this->service->initPresets((bool) request()->post('overwrite', false)),
|
||||
'初始化完成'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 令牌与布局的可选项,前端渲染编辑表单用
|
||||
* @Method GET
|
||||
*/
|
||||
public function schema(): JsonResponse
|
||||
{
|
||||
return jok([
|
||||
'tokens' => WxTemplateSchemaService::TOKEN_SCHEMA,
|
||||
'layout' => WxTemplateSchemaService::LAYOUT_SCHEMA,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user