feat: 产品分类新增设置排序值及是否显示接口

This commit is contained in:
2025-02-12 09:36:59 +08:00
parent 4891750afa
commit c157c507c7
2 changed files with 46 additions and 0 deletions

View File

@@ -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('操作成功!');
}
/**
* 删除商品分类
*/