feat: 新增产品分类增/删/改/查接口

This commit is contained in:
2025-02-11 16:30:58 +08:00
parent 1b220392d4
commit c0b2c5c89d
5 changed files with 308 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ declare (strict_types = 1);
namespace app\admin\model\v1;
use app\common\model\ProductCategoryBaseModel;
use think\model\concern\SoftDelete;
/**
* 产品分类模型
@@ -11,5 +12,25 @@ use app\common\model\ProductCategoryBaseModel;
*/
class ProductCategoryModel extends ProductCategoryBaseModel
{
//
// 启用软件删除
use SoftDelete;
// 软件字段
protected $deleteTime = 'deleted_at';
// 修改自动写入时间格式
protected $autoWriteTimestamp = 'datetime';
// 根据pid查询
public function scopePid($query, $pid)
{
$query->where('pid', $pid);
}
// 搜索分类名称
public function searchNameNullableAttr($query, $value, $data)
{
if (is_null($value)) {
return;
}
$query->where('name', 'like', '%' . $value . '%');
}
}