From 5df25145e6fd11f4ae5a143f24e89b1931cbc88a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=98=89?= <445241500@qq.com> Date: Tue, 21 May 2024 21:39:41 +0800 Subject: [PATCH] 1 --- app/admin/controller/admin/Feedback.php | 75 +++++++++++++++++++++++++ app/admin/model/Feedback.php | 63 +++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 app/admin/controller/admin/Feedback.php create mode 100644 app/admin/model/Feedback.php diff --git a/app/admin/controller/admin/Feedback.php b/app/admin/controller/admin/Feedback.php new file mode 100644 index 00000000..920fb0b1 --- /dev/null +++ b/app/admin/controller/admin/Feedback.php @@ -0,0 +1,75 @@ + +// +---------------------------------------------------------------------- +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 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::getFileList($img_ids); + $list['data'][$kr]['imgs'] = $files ?: null; + } + } + return $this->renderSuccess($list); + } + + +} diff --git a/app/admin/model/Feedback.php b/app/admin/model/Feedback.php new file mode 100644 index 00000000..dddc21d1 --- /dev/null +++ b/app/admin/model/Feedback.php @@ -0,0 +1,63 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\admin\model; + + +/** + * Class Store + * @package app\store\model + */ +class Feedback extends \app\common\model\Feedback +{ + /** + * 更新记录 + * @param array $data + * @return bool + */ + public function edit(array $data): bool + { + // 是否删除图片 + !isset($data['logo_image_id']) && $data['logo_image_id'] = 0; + return $this->save($data) !== false; + } + + /** + * 新增记录 + * @param array $data + * @return bool + */ + public function add(array $data): bool + { + return $this->save($this->createData($data)); + } + + /** + * 创建数据 + * @param array $data + * @return array + */ + private function createData(array $data): array + { + $data['store_id'] = self::$storeId; + return $data; + } + + /** + * 软删除 + * @return bool + */ + public function setDelete(): bool + { + return $this->save(['is_delete' => 1]); + } +}