This commit is contained in:
@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
namespace App\Repository\Company;
|
||||
|
||||
use App\Dao\Company\FirstCompanyDao;
|
||||
use App\Exception\ApiException;
|
||||
use App\Repository\AbstractRepository;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
@ -99,13 +100,31 @@ class FirstCompanyRepository extends AbstractRepository
|
||||
/**
|
||||
* 根据公司全称获取公司信息.
|
||||
* @param string $fullName
|
||||
* @param bool $isVerify
|
||||
* @return array|null
|
||||
*/
|
||||
public function getCompanyByFullName(string $fullName): ?array
|
||||
public function getCompanyByFullName(string $fullName, bool $isVerify = true): ?array
|
||||
{
|
||||
return $this->dao->builder()
|
||||
->select($this->dao->getFields())
|
||||
->where('full_name', '=', $fullName)
|
||||
->first()?->toArray();
|
||||
$fields = $this->dao->getFields();
|
||||
$query = $this->dao->builder()->select($fields)->where('full_name', '=', $fullName);
|
||||
$company = $query->first();
|
||||
if (!$company && $isVerify) {
|
||||
throw new ApiException('公司不存在');
|
||||
}
|
||||
return $company?->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据公司ID查询公司信息.
|
||||
*/
|
||||
public function getCompanyById(int $companyId, bool $isVerify = true): array
|
||||
{
|
||||
$fields = $this->dao->getFields();
|
||||
$query = $this->dao->builder()->select($fields)->where('id', $companyId);
|
||||
$company = $query->first()?->toArray();
|
||||
if (!$company && $isVerify) {
|
||||
throw new ApiException('公司不存在');
|
||||
}
|
||||
return $company ?? [];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user