|
...
|
...
|
@@ -4,16 +4,14 @@ namespace App\Http\Controllers\Bside; |
|
|
|
|
|
|
|
use App\Enums\Common\Code;
|
|
|
|
use App\Exceptions\BsideGlobalException;
|
|
|
|
use App\Models\Template\AHeadFoot;
|
|
|
|
use App\Models\Template\BCustom;
|
|
|
|
use App\Models\Template\BHeadFoot;
|
|
|
|
use App\Models\Template\ATemplate;
|
|
|
|
use App\Models\Template\BTemplate;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 自定义 页面
|
|
|
|
* 模板
|
|
|
|
* @author:dc
|
|
|
|
* @time 2023/5/4 15:59
|
|
|
|
* @time 2023/5/9 14:00
|
|
|
|
* Class TemplateController
|
|
|
|
* @package App\Http\Controllers\Bside
|
|
|
|
*/
|
|
...
|
...
|
@@ -22,141 +20,26 @@ class TemplateController extends BaseController |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 头部底部的 html
|
|
|
|
* 列表
|
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
|
* @throws \Psr\Container\ContainerExceptionInterface
|
|
|
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
|
|
|
* @author:dc
|
|
|
|
* @time 2023/5/4 16:15
|
|
|
|
* @time 2023/5/9 14:20
|
|
|
|
*/
|
|
|
|
public function index(){
|
|
|
|
|
|
|
|
$data = BTemplate::_get($this->user['project_id']);
|
|
|
|
$limit = intval($this->param['limit']??20);
|
|
|
|
|
|
|
|
// todo::这里要进行html的替换
|
|
|
|
|
|
|
|
$data = ATemplate::_bAll($limit);
|
|
|
|
|
|
|
|
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 读取编辑的html
|
|
|
|
* @author:dc
|
|
|
|
* @time 2023/5/4 16:19
|
|
|
|
*/
|
|
|
|
public function edit_html(){
|
|
|
|
$data = BHeadFoot::_get($this->user['project_id']);
|
|
|
|
|
|
|
|
if(!$data){
|
|
|
|
$data = AHeadFoot::_bDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->success([
|
|
|
|
'header' => $data[BHeadFoot::TYPE_HEADER]??'',
|
|
|
|
'footer' => $data[BHeadFoot::TYPE_FOOTER]??'',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 保存
|
|
|
|
* @author:dc
|
|
|
|
* @time 2023/5/4 17:42
|
|
|
|
*/
|
|
|
|
public function edit_save(){
|
|
|
|
|
|
|
|
$header = $this->param['header']??'';
|
|
|
|
|
|
|
|
$footer = $this->param['footer']??'';
|
|
|
|
|
|
|
|
if(!$header && !$footer){
|
|
|
|
throw new BsideGlobalException('B01024','不能为空');
|
|
|
|
}
|
|
|
|
|
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
|
|
try {
|
|
|
|
if($header){
|
|
|
|
BHeadFoot::_save($this->user['project_id'],BHeadFoot::TYPE_HEADER,$header);
|
|
|
|
}
|
|
|
|
|
|
|
|
if($footer){
|
|
|
|
BHeadFoot::_save($this->user['project_id'],BHeadFoot::TYPE_FOOTER,$footer);
|
|
|
|
}
|
|
|
|
}catch (\Throwable $e){
|
|
|
|
DB::rollBack();
|
|
|
|
|
|
|
|
throw new BsideGlobalException('B01024','保存失败');
|
|
|
|
}
|
|
|
|
|
|
|
|
DB::commit();
|
|
|
|
|
|
|
|
|
|
|
|
$this->success([]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取系统的模板
|
|
|
|
* @author:dc
|
|
|
|
* @time 2023/5/4 16:21
|
|
|
|
*/
|
|
|
|
public function system_all_html(){
|
|
|
|
|
|
|
|
$data = AHeadFoot::_ball();
|
|
|
|
|
|
|
|
$lists = [];
|
|
|
|
// 以名字为单位区分
|
|
|
|
foreach ($data as $datum){
|
|
|
|
if(empty($lists[$datum['name']])) $lists[$datum['name']] = [];
|
|
|
|
$lists[$datum['name']]['name'] = $datum['name'];
|
|
|
|
$lists[$datum['name']]['default'] = $datum['is_default'];
|
|
|
|
$lists[$datum['name']][$datum['type']==AHeadFoot::TYPE_HEADER?'header':'footer'] = $datum['html'];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $this->success(array_values($lists));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 自定义 列表
|
|
|
|
* @author:dc
|
|
|
|
* @time 2023/5/4 17:13
|
|
|
|
*/
|
|
|
|
public function custom(){
|
|
|
|
|
|
|
|
$data = BCustom::_all($this->user['project_id']);
|
|
|
|
|
|
|
|
|
|
|
|
return $this->success($data->toArray());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function custom_create(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function custom_edit($id){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function custom_delete($id){
|
|
|
|
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|