This commit is contained in:
@ -57,4 +57,21 @@ class FirstCompanyController extends AbstractController
|
||||
$data = $this->firstCompanyRepository->getList($page, $pageSize, $params);
|
||||
return $this->apiResponse->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司详情.
|
||||
* @throws Exception
|
||||
*/
|
||||
#[Scene(scene: 'companyInfo', argument: 'request')]
|
||||
public function companyInfo(FirstCompanyRequest $request): Response
|
||||
{
|
||||
$companyId = $request->input('company_id');
|
||||
$info = $this->firstCompanyRepository->companyInfo($companyId);
|
||||
// 获取公司管理员工信息
|
||||
$url = parse_url($info['domain']);
|
||||
$domainUrl = $url['host'] ?? '';
|
||||
$arrTmp = explode('.', $domainUrl, 2);
|
||||
$info['domain'] = current($arrTmp);
|
||||
return $this->apiResponse->success($info);
|
||||
}
|
||||
}
|
@ -144,4 +144,21 @@ class FirstCompanyRepository extends AbstractRepository
|
||||
$this->dao->buildWhere($query, $params);
|
||||
return $this->dao->paginate($query, compact('page', 'pageSize'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公司信息.
|
||||
* @param int|string $companyId
|
||||
* @return array|null
|
||||
* @throws Exception
|
||||
*/
|
||||
public function companyInfo(int|string $companyId): ?array
|
||||
{
|
||||
$query = $this->dao->builder()
|
||||
->where('id', '=', $companyId);
|
||||
if (!$query->exists()) {
|
||||
throw new ApiException('公司不存在');
|
||||
}
|
||||
|
||||
return $query->first()?->toArray();
|
||||
}
|
||||
}
|
@ -33,6 +33,7 @@ class FirstCompanyRequest extends AbstractRequest
|
||||
'active_status',
|
||||
'activation_date',
|
||||
],
|
||||
'companyInfo' => ['company_id']
|
||||
];
|
||||
|
||||
public function rules(): array
|
||||
@ -55,6 +56,7 @@ class FirstCompanyRequest extends AbstractRequest
|
||||
'active_status' => 'required|integer|in:0,1',
|
||||
// 激活日期:不能小于当前时间
|
||||
'activation_date' => 'date|date_format:Y-m-d|after_or_equal:today',
|
||||
'company_id' => 'required|integer',
|
||||
];
|
||||
}
|
||||
|
||||
@ -75,6 +77,7 @@ class FirstCompanyRequest extends AbstractRequest
|
||||
'remark' => '备注',
|
||||
'active_status' => '激活状态',
|
||||
'activation_date' => '激活日期',
|
||||
'company_id' => '公司ID',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,7 @@ Router::addGroup('/api/v1', function () {
|
||||
*/
|
||||
Router::post('company.add.first', [FirstCompanyController::class, 'addFirstCompany']); # 新增平台公司
|
||||
Router::post('company.list', [FirstCompanyController::class, 'companyList']); # 公司列表
|
||||
Router::post('company.info', [FirstCompanyController::class, 'companyInfo']); # 公司信息
|
||||
|
||||
/**
|
||||
* 供应商&客户管理
|
||||
|
Reference in New Issue
Block a user