feature/main20240421
guojia 7 months ago
parent 09fdbc6440
commit 8b36409cf9
  1. 19
      app/store/controller/Merchant.php
  2. 21
      app/store/model/Merchant.php

@ -48,6 +48,25 @@ class Merchant extends Controller
return $this->renderError($model->getError() ?: '更新失败'); return $this->renderError($model->getError() ?: '更新失败');
} }
return $this->renderSuccess('更新成功'); return $this->renderSuccess('更新成功');
}
/**
* 更新商城信息
* @return Json
*/
public function add(): Json
{
// 商城详情
//$model = MerchantModel::detail($this->storeId);
// 新增记录
$model = new MerchantModel;
$data = $this->postForm();
if ($model->add($data)) {
return $this->renderSuccess('添加成功');
}
return $this->renderError($model->getError() ?: '添加失败');
} }
/** /**

@ -32,4 +32,25 @@ class Merchant extends StoreModel
!isset($data['logo_image_id']) && $data['logo_image_id'] = 0; !isset($data['logo_image_id']) && $data['logo_image_id'] = 0;
return $this->save($data) !== false; 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;
}
} }

Loading…
Cancel
Save