feat: 产品相关接口

This commit is contained in:
2025-01-24 17:54:04 +08:00
parent 65bd37042a
commit db489a8429
18 changed files with 787 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
<?php
declare (strict_types = 1);
namespace app\common\model;
use think\Model;
/**
* @mixin \think\Model
*/
class BaseModel extends Model
{
/**
* 根据主键查询
*/
public function scopeBypk($query, $pk)
{
$query->where((new static)->pk, '=', $pk);
}
/**
* 根据多主键查询
*/
public function scopeBypks($query, $pks)
{
if (!is_array($pks) && (is_string($pks) && false === strpos($pks, ','))) {
throw new \Exception('pks参数为级数或逗号分隔字符串');
}
$query->where((new static)->pk, 'in', $pks);
}
}