作者 lyh

gx

@@ -45,6 +45,17 @@ class ProductController extends BaseController @@ -45,6 +45,17 @@ class ProductController extends BaseController
45 return $this->response('success',Code::SUCCESS,$lists); 45 return $this->response('success',Code::SUCCESS,$lists);
46 } 46 }
47 47
  48 + public function info(Product $product){
  49 + $this->request->validate([
  50 + 'id'=>'required'
  51 + ],[
  52 + 'id.required' => 'ID不能为空'
  53 + ]);
  54 + $info = $product->read(['id'=>$this->param['id']]);
  55 + $info = $this->handleParam($info);
  56 + return $this->response('success',Code::SUCCESS,$info);
  57 + }
  58 +
48 /** 59 /**
49 * @remark :处理列表参数 60 * @remark :处理列表参数
50 * @name :handleParam 61 * @name :handleParam
@@ -76,17 +87,13 @@ class ProductController extends BaseController @@ -76,17 +87,13 @@ class ProductController extends BaseController
76 return $v; 87 return $v;
77 } 88 }
78 89
79 - public function info(Product $product){  
80 - $this->request->validate([  
81 - 'id'=>'required'  
82 - ],[  
83 - 'id.required' => 'ID不能为空'  
84 - ]);  
85 - $info = $product->read(['id'=>$this->param['id']]);  
86 - $info = $this->handleParam($info);  
87 - return $this->response('success',Code::SUCCESS,$info);  
88 - }  
89 - 90 + /**
  91 + * @remark :保存产品数据
  92 + * @name :save
  93 + * @author :lyh
  94 + * @method :post
  95 + * @time :2023/8/17 15:01
  96 + */
90 public function save(ProductRequest $request, ProductLogic $logic) 97 public function save(ProductRequest $request, ProductLogic $logic)
91 { 98 {
92 $data = $logic->save($this->param); 99 $data = $logic->save($this->param);
@@ -27,37 +27,6 @@ class ProductLogic extends BaseLogic @@ -27,37 +27,6 @@ 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 -// }  
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 -// }  
60 -  
61 public function save($param){ 30 public function save($param){
62 //封面取第一个图片 31 //封面取第一个图片
63 $param['thumb'] = $param['gallery'][0] ?? ''; 32 $param['thumb'] = $param['gallery'][0] ?? '';