feat: 附件(下载管理)添加禁/启用操作接口
This commit is contained in:
@@ -173,6 +173,25 @@ class Attachment
|
|||||||
return success('操作成功');
|
return success('操作成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 禁/启用
|
||||||
|
*/
|
||||||
|
public function enable()
|
||||||
|
{
|
||||||
|
$id = request()->param('id');
|
||||||
|
|
||||||
|
$attachment = AttachmentModel::bypk($id)->find();
|
||||||
|
if (empty($attachment)) {
|
||||||
|
return error('请确认操作对象是否存在');
|
||||||
|
}
|
||||||
|
|
||||||
|
$attachment->status = $attachment->status == 1 ? -1 : 1;
|
||||||
|
if (!$attachment->save()) {
|
||||||
|
return error('操作失败');
|
||||||
|
}
|
||||||
|
return success('操作成功');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 附件删除
|
* 附件删除
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -292,6 +292,9 @@ Route::group('v1', function () {
|
|||||||
// 附件(下载管理)设置排序值
|
// 附件(下载管理)设置排序值
|
||||||
Route::post('sort/:id', 'Attachment/sort');
|
Route::post('sort/:id', 'Attachment/sort');
|
||||||
|
|
||||||
|
// 附件(下载管理)禁/启用
|
||||||
|
Route::get('enable/:id', 'Attachment/enable');
|
||||||
|
|
||||||
// 附件(下载管理)删除
|
// 附件(下载管理)删除
|
||||||
Route::delete('delete/:id', 'Attachment/delete');
|
Route::delete('delete/:id', 'Attachment/delete');
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class AttachmentBaseModel extends BaseModel
|
|||||||
'attach' => 'string',
|
'attach' => 'string',
|
||||||
'sort' => 'int',
|
'sort' => 'int',
|
||||||
'recommend' => 'int',
|
'recommend' => 'int',
|
||||||
|
'status' => 'int',
|
||||||
'seo_title' => 'string',
|
'seo_title' => 'string',
|
||||||
'seo_keywords' => 'string',
|
'seo_keywords' => 'string',
|
||||||
'seo_desc' => 'string',
|
'seo_desc' => 'string',
|
||||||
|
|||||||
Reference in New Issue
Block a user