This commit is contained in:
@ -55,10 +55,28 @@ abstract class AbstractDao
|
||||
private array $queryResult;
|
||||
|
||||
/**
|
||||
* 获取模型
|
||||
* @return Model
|
||||
*/
|
||||
abstract protected function getModel(): string;
|
||||
|
||||
/**
|
||||
* 获取query selector 字段
|
||||
* @return array
|
||||
*/
|
||||
abstract public function getFields(): array;
|
||||
|
||||
/**
|
||||
* 构建查询条件.
|
||||
* @throws Exception
|
||||
*/
|
||||
public function buildWhere(Builder $builder, array $params = []): Builder
|
||||
{
|
||||
// 根据字段查询数据库,params存在的条件进行查询
|
||||
$fields = $this->getFields();
|
||||
return self::daoBuildWhere($builder, $params, $fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据操作.
|
||||
*/
|
||||
|
@ -35,4 +35,9 @@ class CompanyDao extends AbstractDao
|
||||
{
|
||||
return Company::class;
|
||||
}
|
||||
|
||||
public function getFields(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
32
app/Dao/Company/CompanyModulesDao.php
Normal file
32
app/Dao/Company/CompanyModulesDao.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: ykxiao
|
||||
* Date: 2025/7/10
|
||||
* Time: 下午8:59
|
||||
* Description:
|
||||
*
|
||||
* (c) ykxiao <yk_9001@hotmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Dao\Company;
|
||||
|
||||
use App\Dao\AbstractDao;
|
||||
use App\Model\CompanyModules;
|
||||
|
||||
class CompanyModulesDao extends AbstractDao
|
||||
{
|
||||
public function getModel(): string
|
||||
{
|
||||
return CompanyModules::class;
|
||||
}
|
||||
|
||||
public function getFields(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
@ -35,4 +35,9 @@ class PurchaseDao extends AbstractDao
|
||||
{
|
||||
return Purchase::class;
|
||||
}
|
||||
|
||||
public function getFields(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user