弹幕、分类下拉、属性下拉、
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\BarrageService;
|
||||
|
||||
class BarrageController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new BarrageService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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']);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,27 @@ class PostCategoryController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类树
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function preset(Request $request)
|
||||
{
|
||||
try {
|
||||
$params = $request->all();
|
||||
$result = $this->service->preset($params);
|
||||
foreach ($result as $k => $r){
|
||||
unset($r['created_at']);
|
||||
unset($r['updated_at']);
|
||||
$result[$k] = $this->indexFormat($r);
|
||||
}
|
||||
return $this->success($result, '获取分类下拉');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace app\admin\controller;
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\SkuAttributeService;
|
||||
use support\Request;
|
||||
|
||||
class SkuAttributeController extends BaseController
|
||||
{
|
||||
@@ -16,18 +17,63 @@ class SkuAttributeController extends BaseController
|
||||
$this->service = new SkuAttributeService();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分类树
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function preset(Request $request)
|
||||
{
|
||||
try {
|
||||
$params = $request->all();
|
||||
$result = $this->service->preset($params);
|
||||
foreach ($result as $k => $r){
|
||||
unset($r['created_at']);
|
||||
unset($r['updated_at']);
|
||||
$result[$k] = $this->indexFormat($r);
|
||||
}
|
||||
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']);
|
||||
// return $data;
|
||||
// }
|
||||
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']);
|
||||
if (isset($data['options_json'])){
|
||||
$data['options_json'] = json_decode($data['options_json'], true);
|
||||
// foreach ($data['options_json'] as $k => $v){
|
||||
// $data['options_json'][$k] = ['value' => $v];
|
||||
// }
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return mixed 返回创建成功的数据或信息
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $this->validate($this->service->getValidator(), $request->post(), 'store');
|
||||
$res = $this->service->serviceStore($request, $data);
|
||||
return $this->success($res, '创建成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage().$e->getFile().$e->getLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user