更新接口相关

wysf
陈伟 9 months ago
parent d5f31e75ba
commit 6c6194555d
  1. 23
      app/store/controller/content/Maintenance.php
  2. 8
      app/store/model/Maintenance.php

@ -35,6 +35,17 @@ class Maintenance extends Controller
return $this->renderSuccess(compact('list'));
}
/**
* 文章详情
* @param int $maintenanceId
* @return Json
*/
public function detail(int $maintenanceId): Json
{
$detail = MaintenanceModel::detail($maintenanceId);
return $this->renderSuccess(compact('detail'));
}
/**
@ -51,13 +62,13 @@ class Maintenance extends Controller
}
/**
* @param int $articleId
* @param int $maintenanceId
* @return Json
*/
public function edit(int $articleId): Json
public function edit(int $maintenanceId): Json
{
// 文章详情
$model = MaintenanceModel::detail($articleId);
$model = MaintenanceModel::detail($maintenanceId);
// 更新记录
if ($model->edit($this->postForm())) {
return $this->renderSuccess('更新成功');
@ -67,13 +78,13 @@ class Maintenance extends Controller
/**
* 删除文章
* @param int $articleId
* @param int $maintenanceId
* @return Json
*/
public function delete(int $articleId): Json
public function delete(int $maintenanceId): Json
{
// 文章详情
$model = MaintenanceModel::detail($articleId);
$model = MaintenanceModel::detail($maintenanceId);
if (!$model->setDelete()) {
return $this->renderError($model->getError() ?: '删除失败');
}

@ -37,7 +37,7 @@ class Maintenance extends MaintenanceModel
]);
// 检索查询条件
$filter = [];
!empty($params['name']) && $filter[] = ['name', 'like', "%{$params['title']}%"];
!empty($params['name']) && $filter[] = ['name', 'like', "%{$params['name']}%"];
$params['status'] > -1 && $filter[] = ['status', '=', $params['status']];
$params['categoryId'] > 0 && $filter[] = ['category_id', '=', $params['categoryId']];
// 查询列表数据
@ -62,12 +62,16 @@ class Maintenance extends MaintenanceModel
return false;
}
if (($data['parent_id']) != 0) {
/* if (($data['parent_id']) != 0) {
if (empty($data['url'])) {
$this->error = '请输地址';
return false;
}
} */
if (empty($data['url'])) {
$this->error = '请输地址';
return false;
}
$data['store_id'] = self::$storeId;
return $this->save($data);

Loading…
Cancel
Save