登录
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\service\OssService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\admin\service\BrandService;
|
||||
use support\Request;
|
||||
|
||||
class BrandController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new BrandService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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']);
|
||||
if (!empty($data['logo']))
|
||||
$data['logo_full'] = (new OssService)->generatePrivateUrl($data['logo']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function showFormat($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 (empty($data['logo']))
|
||||
$data['logo_full'] = (new OssService)->generatePrivateUrl($data['logo']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 抓取品牌系列
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function crawlSeries(Request $request){
|
||||
try {
|
||||
$result = $this->service->crawlSeries($request);
|
||||
if($result){
|
||||
return $this->success($result,'成功');
|
||||
}else{
|
||||
return $this->error('抓取任务提交失败');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建被抓取且选中的品牌系列
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function crawlSeriesCreate(Request $request){
|
||||
try {
|
||||
$result = $this->service->crawlSeriesCreate($request);
|
||||
if($result){
|
||||
return $this->success([],$result);
|
||||
}else{
|
||||
return $this->error('创建失败');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user