feat: 产品分类新增设置排序值及是否显示接口
This commit is contained in:
@@ -170,6 +170,46 @@ class ProductCategory
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置排序值
|
||||
*/
|
||||
public function sort()
|
||||
{
|
||||
$id = request()->param('id');
|
||||
$sort = request()->post('sort');
|
||||
|
||||
$category = ProductCategoryModel::bypk($id)->find();
|
||||
if (empty($category)) {
|
||||
return error('请确认操作对对象是否存在!');
|
||||
}
|
||||
if ($sort != $category->sort) {
|
||||
$category->sort = $sort;
|
||||
if (!$category->save()) {
|
||||
return error('操作失败!');
|
||||
}
|
||||
}
|
||||
return success('操作成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否显示
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
$id = request()->param('id');
|
||||
|
||||
$category = ProductCategoryModel::bypk($id)->find();
|
||||
if (empty($category)) {
|
||||
return error('请确认操作对对象是否存在!');
|
||||
}
|
||||
|
||||
$category->is_show = (int)!$category->is_show;
|
||||
if (!$category->save()) {
|
||||
return error('操作失败!');
|
||||
}
|
||||
return success('操作成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品分类
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user