作者 lyh

gx

@@ -76,14 +76,15 @@ class ProductController extends BaseController @@ -76,14 +76,15 @@ class ProductController extends BaseController
76 return $v; 76 return $v;
77 } 77 }
78 78
79 - public function info(Request $request, ProductLogic $logic){  
80 - $request->validate([ 79 + public function info(Product $product){
  80 + $this->request->validate([
81 'id'=>'required' 81 'id'=>'required'
82 ],[ 82 ],[
83 'id.required' => 'ID不能为空' 83 'id.required' => 'ID不能为空'
84 ]); 84 ]);
85 - $data = $logic->getInfo($this->param['id']);  
86 - return $this->success($data); 85 + $info = $product->read(['id'=>$this->param['id']]);
  86 + $info = $this->handleParam($info);
  87 + return $this->response('success',Code::SUCCESS,$info);
87 } 88 }
88 89
89 public function save(ProductRequest $request, ProductLogic $logic) 90 public function save(ProductRequest $request, ProductLogic $logic)
@@ -27,36 +27,36 @@ class ProductLogic extends BaseLogic @@ -27,36 +27,36 @@ class ProductLogic extends BaseLogic
27 $this->model = new Product(); 27 $this->model = new Product();
28 } 28 }
29 29
30 - public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $row = 20)  
31 - {  
32 - $data = parent::getList($map, $sort, $columns, $row);  
33 - foreach ($data['list'] as &$v){  
34 - $v = $this->formatData($v);  
35 - }  
36 - return $this->success($data);  
37 - }  
38 -  
39 - public function getInfo($id)  
40 - {  
41 - $info = $this->model->read(['id'=>$id]);  
42 - $info = $this->formatData($info);  
43 - return $this->success($info);  
44 - } 30 +// public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $row = 20)
  31 +// {
  32 +// $data = parent::getList($map, $sort, $columns, $row);
  33 +// foreach ($data['list'] as &$v){
  34 +// $v = $this->formatData($v);
  35 +// }
  36 +// return $this->success($data);
  37 +// }
  38 +//
  39 +// public function getInfo($id)
  40 +// {
  41 +// $info = $this->model->read(['id'=>$id]);
  42 +// $info = $this->formatData($info);
  43 +// return $this->success($info);
  44 +// }
45 45
46 - public function formatData($info){  
47 - foreach ($info['category_id'] as $category_id) {  
48 - $info['category_id_text'][] = (new CategoryLogic())->getCacheInfo($category_id)['title'] ?? '';  
49 - }  
50 - foreach ($info['keyword_id'] as $keyword_id){  
51 - $info['keyword_id_text'][] =(new KeywordLogic())->getCacheInfo($keyword_id)['title']??'';  
52 - }  
53 - $info['category_id_text'] = Arr::arrToSet($info['category_id_text'], 'trim');  
54 - $info['keyword_id_text'] = Arr::arrToSet($info['keyword_id_text'], 'trim');  
55 - $info['status_text'] = Product::statusMap()[$info['status']] ?? '';  
56 - $info['created_uid_text'] = (new UserLogic())->getCacheInfo($info['created_uid'])['name'] ?? '';  
57 - $info['url'] = $this->user['domain'] . $info['route'] ;  
58 - return $info;  
59 - } 46 +// public function formatData($info){
  47 +// foreach ($info['category_id'] as $category_id) {
  48 +// $info['category_id_text'][] = (new CategoryLogic())->getCacheInfo($category_id)['title'] ?? '';
  49 +// }
  50 +// foreach ($info['keyword_id'] as $keyword_id){
  51 +// $info['keyword_id_text'][] =(new KeywordLogic())->getCacheInfo($keyword_id)['title']??'';
  52 +// }
  53 +// $info['category_id_text'] = Arr::arrToSet($info['category_id_text'], 'trim');
  54 +// $info['keyword_id_text'] = Arr::arrToSet($info['keyword_id_text'], 'trim');
  55 +// $info['status_text'] = Product::statusMap()[$info['status']] ?? '';
  56 +// $info['created_uid_text'] = (new UserLogic())->getCacheInfo($info['created_uid'])['name'] ?? '';
  57 +// $info['url'] = $this->user['domain'] . $info['route'] ;
  58 +// return $info;
  59 +// }
60 60
61 public function save($param){ 61 public function save($param){
62 //封面取第一个图片 62 //封面取第一个图片