From 7827116a8f42e80852dd040a2c30fcb9a064f908 Mon Sep 17 00:00:00 2001 From: guojia <445241500@qq.com> Date: Tue, 30 Apr 2024 14:11:42 +0800 Subject: [PATCH] t --- app/store/controller/Merchant.php | 16 +++++++++++----- app/store/model/Style.php | 2 -- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/store/controller/Merchant.php b/app/store/controller/Merchant.php index 9b40f56e..5d8c932e 100644 --- a/app/store/controller/Merchant.php +++ b/app/store/controller/Merchant.php @@ -131,14 +131,20 @@ class Merchant extends Controller */ public function setPageStyle(): Json { - // 新增记录 $model = new StyleModel; + $detail = StyleModel::detail(1); $data = $this->postForm(); - $data['style_id'] = 1; - if ($model->edit($data)) { - return $this->renderSuccess('添加成功'); + if (empty($detail)) { + if ($model->add($data)) { + return $this->renderSuccess('操作成功'); + } + } else { + if ($model->edit($data)) { + return $this->renderSuccess('操作成功'); + } } - return $this->renderError($model->getError() ?: '添加失败'); + + return $this->renderError($model->getError() ?: '操作失败'); } public function getPageStyle(): Json diff --git a/app/store/model/Style.php b/app/store/model/Style.php index ada6cd9e..04a3cfdd 100644 --- a/app/store/model/Style.php +++ b/app/store/model/Style.php @@ -28,8 +28,6 @@ class Style extends model */ public function edit(array $data): bool { - // 是否删除图片 - !isset($data['logo_image_id']) && $data['logo_image_id'] = 0; return $this->save($data) !== false; }