弹幕屏蔽
This commit is contained in:
@@ -4,6 +4,7 @@ namespace app\admin\controller;
|
|||||||
use app\common\controller\BaseController;
|
use app\common\controller\BaseController;
|
||||||
use app\common\traits\crud\CrudControllerTrait;
|
use app\common\traits\crud\CrudControllerTrait;
|
||||||
use app\common\service\BarrageService;
|
use app\common\service\BarrageService;
|
||||||
|
use support\Request;
|
||||||
|
|
||||||
class BarrageController extends BaseController
|
class BarrageController extends BaseController
|
||||||
{
|
{
|
||||||
@@ -16,6 +17,25 @@ class BarrageController extends BaseController
|
|||||||
$this->service = new BarrageService();
|
$this->service = new BarrageService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取列表
|
||||||
|
*
|
||||||
|
* @param Request $request 请求对象
|
||||||
|
* @return mixed 返回分页数据及总数
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$raw = $this->service->serviceList($request, 'default');
|
||||||
|
$data = $this->transformData($raw, method_exists($this, 'indexFormat')
|
||||||
|
? [$this, 'indexFormat']
|
||||||
|
: null);
|
||||||
|
return $this->success($data);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return $this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表页数据格式化
|
* 列表页数据格式化
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -53,9 +53,9 @@ class SkuAttributeController extends BaseController
|
|||||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||||
if (isset($data['options_json'])){
|
if (isset($data['options_json'])){
|
||||||
$data['options_json'] = json_decode($data['options_json'], true);
|
$data['options_json'] = json_decode($data['options_json'], true);
|
||||||
// foreach ($data['options_json'] as $k => $v){
|
foreach ($data['options_json'] as $k => $v){
|
||||||
// $data['options_json'][$k] = ['value' => $v];
|
$data['options_json'][$k] = ['value' => $v];
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace app\common\controller;
|
|||||||
use app\common\controller\BaseController;
|
use app\common\controller\BaseController;
|
||||||
use app\common\traits\crud\CrudControllerTrait;
|
use app\common\traits\crud\CrudControllerTrait;
|
||||||
use app\common\service\BarrageService;
|
use app\common\service\BarrageService;
|
||||||
|
use support\Request;
|
||||||
|
|
||||||
class BarrageController extends BaseController
|
class BarrageController extends BaseController
|
||||||
{
|
{
|
||||||
@@ -16,6 +17,25 @@ class BarrageController extends BaseController
|
|||||||
$this->service = new BarrageService();
|
$this->service = new BarrageService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取列表
|
||||||
|
*
|
||||||
|
* @param Request $request 请求对象
|
||||||
|
* @return mixed 返回分页数据及总数
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$raw = $this->service->serviceList($request, 'index');
|
||||||
|
$data = $this->transformData($raw, method_exists($this, 'indexFormat')
|
||||||
|
? [$this, 'indexFormat']
|
||||||
|
: null);
|
||||||
|
return $this->success($data);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return $this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表页数据格式化
|
* 列表页数据格式化
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -31,6 +31,41 @@ class BarrageService
|
|||||||
return new $this->validator;
|
return new $this->validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造 CrudUtil 查询配置
|
||||||
|
*/
|
||||||
|
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
|
||||||
|
{
|
||||||
|
$p = $request->all();
|
||||||
|
|
||||||
|
$config = [];
|
||||||
|
$config['model'] = $this->modelClass;
|
||||||
|
switch ($scene) {
|
||||||
|
case 'default':
|
||||||
|
$config['order']['sort'] = 'desc';
|
||||||
|
$config['order']['id'] = 'desc';
|
||||||
|
break;
|
||||||
|
case 'index':
|
||||||
|
$config['order']['is_blocked'] = '0';
|
||||||
|
$config['order']['sort'] = 'desc';
|
||||||
|
$config['order']['id'] = 'desc';
|
||||||
|
break;
|
||||||
|
case 'show':
|
||||||
|
$config['where']['id'] = $p['id'];
|
||||||
|
$config['where']['status'] = 1;
|
||||||
|
break;
|
||||||
|
case 'store':
|
||||||
|
break;
|
||||||
|
case 'update':
|
||||||
|
$config['where']['id'] = $p['id'];
|
||||||
|
break;
|
||||||
|
case 'destroy':
|
||||||
|
$config['where']['id'] = $p['id'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加前置处理
|
* 添加前置处理
|
||||||
|
|||||||
@@ -72,11 +72,11 @@ class SkuAttributeService
|
|||||||
*/
|
*/
|
||||||
public function beforeServiceStore($data, Request $request)
|
public function beforeServiceStore($data, Request $request)
|
||||||
{
|
{
|
||||||
// $options = [];
|
$options = [];
|
||||||
// foreach ($data['options_json'] as $v){
|
foreach ($data['options_json'] as $v){
|
||||||
// $options[] = $v['value'];
|
$options[] = $v['value'];
|
||||||
// }
|
}
|
||||||
// $data['options_json'] = json_encode($options, JSON_UNESCAPED_UNICODE);
|
$data['options_json'] = json_encode($options, JSON_UNESCAPED_UNICODE);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user