hospital-applets-api/app/Services/DetectionService.php

70 lines
1.9 KiB
PHP

<?php
namespace App\Services;
use App\Model\BasicCompany;
use App\Model\DetectionProject;
class DetectionService extends BaseService
{
/**
* 获取合作公司检测项目列表
* @return array
*/
public function getDetectionProjectList(): array
{
$company_id = $this->request->input("company_id",1);
// 获取合作公司数据
$params = array();
$params['company_id'] = $company_id;
$basic_company = BasicCompany::getOne($params);
if (empty($basic_company)){
return fail();
}
// 获取项目数据
$params = array();
$params['company_id'] = $company_id;
$detection_projects = DetectionProject::getList($params);
if (empty($detection_projects)){
return fail();
}
foreach ($detection_projects as &$value){
$value['img_path'] = addAliyunOssWebsite($value['img_path']);
}
return success($detection_projects->toArray());
}
/**
* 获取合作公司检测项目
* @return array
*/
public function getDetectionProject(): array
{
$company_id = $this->request->input("company_id",1);
$detection_project_id = $this->request->route('detection_project_id',1);
// 获取合作公司数据
$params = array();
$params['company_id'] = $company_id;
$basic_company = BasicCompany::getOne($params);
if (empty($basic_company)){
return fail();
}
// 获取项目数据
$params = array();
$params['detection_project_id'] = $detection_project_id;
$detection_project = DetectionProject::getOne($params);
if (empty($detection_project)){
return fail();
}
$detection_project['img_path'] = addAliyunOssWebsite($detection_project['img_path']);
return success($detection_project->toArray());
}
}