// +---------------------------------------------------------------------- declare (strict_types=1); namespace app\admin\controller; use app\store\model\RetailDescribe as retDescribeModel; use app\common\enum\RetailDescribeEnum; class RetailDescribe extends Controller { public function index() { $model = new retDescribeModel; $where = $this->request->get(); $list = $model->getList($where)->toArray(); foreach($list['data'] as &$item){ $item['plate_name'] = RetailDescribeEnum::$version[$item['plate_id']]??''; } return $this->renderSuccess(compact('list')); } public function add(){ $model = new retDescribeModel; if($model->add($this->postForm())){ return $this->renderSuccess('添加成功'); } return $this->renderError($model->getError() ?: '添加失败'); } public function edit(int $id){ $model = new retDescribeModel; if($model->edit($id,$this->postForm())){ return $this->renderSuccess('编辑成功'); } return $this->renderError($model->getError() ?: '编辑失败'); } public function delete(array $id){ $model = new retDescribeModel; if($model->del($id)){ return $this->renderSuccess('删除成功'); } return $this->renderError($model->getError() ?: '删除失败'); } public function getPlate(){ $list1 = RetailDescribeEnum::$version; $list = []; foreach($list1 as $key => $value){ $list[] = ['id' => $key, 'name' => $value]; }; return $this->renderSuccess(compact('list')); } }