样机小程序
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\service\OssService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\PostCategoryService;
|
||||
use support\Request;
|
||||
|
||||
class PostCategoryController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new PostCategoryService();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分类树
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function tree(Request $request)
|
||||
{
|
||||
try {
|
||||
$params = $request->all();
|
||||
$result = $this->service->getList($params);
|
||||
return $this->success($result, '获取分类列表');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
$ossservice = new OssService();
|
||||
if (!empty($data['icon_active'])){
|
||||
$data['icon_active_pull'] = $ossservice->generatePrivateUrl($data['icon_active']);
|
||||
}
|
||||
if (!empty($data['icon_inactive'])){
|
||||
$data['icon_inactive_pull'] = $ossservice->generatePrivateUrl($data['icon_inactive']);
|
||||
}
|
||||
if (!empty($data['icon_preset'])){
|
||||
$data['icon_preset_pull'] = $ossservice->generatePrivateUrl($data['icon_preset']);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user