作者 lyh

gx

... ... @@ -45,6 +45,17 @@ class ProductController extends BaseController
return $this->response('success',Code::SUCCESS,$lists);
}
public function info(Product $product){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$info = $product->read(['id'=>$this->param['id']]);
$info = $this->handleParam($info);
return $this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :处理列表参数
* @name :handleParam
... ... @@ -76,17 +87,13 @@ class ProductController extends BaseController
return $v;
}
public function info(Product $product){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$info = $product->read(['id'=>$this->param['id']]);
$info = $this->handleParam($info);
return $this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :保存产品数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/8/17 15:01
*/
public function save(ProductRequest $request, ProductLogic $logic)
{
$data = $logic->save($this->param);
... ...
... ... @@ -27,37 +27,6 @@ class ProductLogic extends BaseLogic
$this->model = new Product();
}
// public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $row = 20)
// {
// $data = parent::getList($map, $sort, $columns, $row);
// foreach ($data['list'] as &$v){
// $v = $this->formatData($v);
// }
// return $this->success($data);
// }
//
// public function getInfo($id)
// {
// $info = $this->model->read(['id'=>$id]);
// $info = $this->formatData($info);
// return $this->success($info);
// }
// public function formatData($info){
// foreach ($info['category_id'] as $category_id) {
// $info['category_id_text'][] = (new CategoryLogic())->getCacheInfo($category_id)['title'] ?? '';
// }
// foreach ($info['keyword_id'] as $keyword_id){
// $info['keyword_id_text'][] =(new KeywordLogic())->getCacheInfo($keyword_id)['title']??'';
// }
// $info['category_id_text'] = Arr::arrToSet($info['category_id_text'], 'trim');
// $info['keyword_id_text'] = Arr::arrToSet($info['keyword_id_text'], 'trim');
// $info['status_text'] = Product::statusMap()[$info['status']] ?? '';
// $info['created_uid_text'] = (new UserLogic())->getCacheInfo($info['created_uid'])['name'] ?? '';
// $info['url'] = $this->user['domain'] . $info['route'] ;
// return $info;
// }
public function save($param){
//封面取第一个图片
$param['thumb'] = $param['gallery'][0] ?? '';
... ...