feature/main20240421
guojia 7 months ago
parent c9d99f7975
commit d4015f4e8d
  1. 15
      app/common/model/Style.php
  2. 5
      app/store/controller/Merchant.php

@ -34,16 +34,13 @@ class Style extends BaseModel
* @param int $storeId
* @return static|array|null
*/
public static function detail()
public static function detail(int $styleId)
{
try {
$list = self::withoutGlobalScope()
->where('1', '=', 1)
->find();
return $list ?? null;
} catch (\Exception $e) {
return null;
}
$where = [
'style_id' => $styleId,
'store_id' => self::$storeId
];
return static::get($where, []);
}
/**

@ -134,7 +134,8 @@ class Merchant extends Controller
// 新增记录
$model = new StyleModel;
$data = $this->postForm();
if ($model->add($data)) {
$data['style_id'] = 1;
if ($model->edit($data)) {
return $this->renderSuccess('添加成功');
}
return $this->renderError($model->getError() ?: '添加失败');
@ -143,7 +144,7 @@ class Merchant extends Controller
public function getPageStyle(): Json
{
// 新增记录
$detail = StyleModel::detail();
$detail = StyleModel::detail(1);
return $this->renderSuccess(compact('detail'));
}

Loading…
Cancel
Save