// +---------------------------------------------------------------------- declare (strict_types=1); namespace app\admin\controller; use app\common\model\store\StoreSettle; use app\api\service\User as UserService; use think\response\Json; use app\admin\model\Feedback as feedbackModel; use app\common\model\UploadFile; use app\common\model\Channel; /** * 意见反馈 * Class Store * @package app\store\controller */ class Feedback extends Controller { /** * @notes:新增文章 * @return Json * @throws BaseException * @author: wanghousheng */ public function add(): Json { $suggest = $this->request->post('suggest'); if (!$suggest) { return $this->renderError('内容不能为空'); } $data = $this->postData(); //$data['merchant_id'] = $this->merchantId; if ((new feedbackModel)->add($data)) { return $this->renderSuccess('添加成功'); } return $this->renderError('添加失败'); } public function edit(): Json { // 商城详情 $model = feedbackModel::detail($this->postForm()['feedback_id']); // 更新记录 if (!$model->edit($this->postForm())) { return $this->renderError($model->getError() ?: '更新失败'); } return $this->renderSuccess('更新成功'); } /** * 列表 */ public function list(): Json { $pageSize = $this->request->param('pageSize'); $pageSize = empty($pageSize) ? 15 : $pageSize; $model = new feedbackModel; $params = $this->request->param(); $list = $model->getList($params, intval($pageSize))->toArray(); foreach ($list['data'] as $kr => $r) { $res[$kr]['imgs'] = []; if ($r['imgs']) { $img_ids = explode(",", $r['imgs']); $files = UploadFile::getFileListBySuper($img_ids); $list['data'][$kr]['imgs'] = $files ?: null; } } return $this->renderSuccess($list); } }