新增 获取检测项目用途列表 接口

This commit is contained in:
wucongxing 2023-07-27 16:34:33 +08:00
parent 33c7cb98c5
commit b3d0576013
5 changed files with 129 additions and 18 deletions

View File

@ -13,14 +13,9 @@ class DetectionController extends AbstractController
/**
* 获取合作公司检测项目列表
* @return ResponseInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getDetectionProjectList(): ResponseInterface
{
$request = $this->container->get(DetectionRequest::class);
$request->scene('getDetectionProjectList')->validateResolved();
$detectionService = new DetectionService();
$data = $detectionService->getDetectionProjectList();
return $this->response->json($data);
@ -40,13 +35,29 @@ class DetectionController extends AbstractController
/**
* 获取检测机构合作医生列表
* @return ResponseInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getDetectionDoctorList(): ResponseInterface
{
$detectionService = new DetectionService();
$data = $detectionService->getDetectionDoctorList();
return $this->response->json($data);
}
/**
* 获取检测项目用途列表
* @return ResponseInterface
*/
public function getDetectionProjectPurposeList(): ResponseInterface
{
$detectionService = new DetectionService();
$data = $detectionService->getDetectionProjectPurposeList();
return $this->response->json($data);
}
// 创建检测订单
public function addDetectionOrder(){
$request = $this->container->get(DetectionRequest::class);
$request->scene('getDetectionDoctorList')->validateResolved();
$request->scene('addDetectionOrder')->validateResolved();
$detectionService = new DetectionService();
$data = $detectionService->getDetectionDoctorList();

View File

@ -0,0 +1,74 @@
<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\Database\Model\Collection;
/**
* @property int $purpose_id 主键id
* @property int $detection_project_id 检测项目id
* @property string $purpose_name 用途名称
* @property \Carbon\Carbon $created_at 创建时间
* @property \Carbon\Carbon $updated_at 修改时间
*/
class DetectionProjectPurpose extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'detection_project_purpose';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['purpose_id', 'detection_project_id', 'purpose_name', 'created_at', 'updated_at'];
protected string $primaryKey = "purpose_id";
/**
* 获取信息-单条
* @param array $params
* @param array $fields
* @return object|null
*/
public static function getOne(array $params, array $fields = ['*']): object|null
{
return self::where($params)->first($fields);
}
/**
* 获取数据-
* @param array $params
* @param array $fields
* @return Collection|array
*/
public static function getList(array $params = [], array $fields = ['*']): Collection|array
{
return self::where($params)->get($fields);
}
/**
* 新增-批量
* @param array $data 新增数据
* @return \Hyperf\Database\Model\Model|DetectionProjectPurpose
*/
public static function addDetectionProjectPurpose(array $data): \Hyperf\Database\Model\Model|DetectionProjectPurpose
{
return self::create($data);
}
/**
* 修改-批量
* @param array $params
* @param array $data
* @return int
*/
public static function editDetectionProjectPurpose(array $params = [], array $data = []): int
{
return self::where($params)->update($data);
}
}

View File

@ -10,11 +10,12 @@ use Hyperf\Validation\Request\FormRequest;
class DetectionRequest extends FormRequest
{
protected array $scenes = [
'getDetectionProjectList' => [ // 获取合作公司检测项目列表
'company_id',
],
'getDetectionDoctorList' => [ // 获取检测机构合作医生列表
'addDetectionOrder' => [ // 创建检测订单
'company_id',
'patient_id',
'family_id',
'nation_id',
'detection_disease_class_ids',
],
];
@ -32,7 +33,6 @@ class DetectionRequest extends FormRequest
public function rules(): array
{
return [
'company_id' => 'required',
'detection_project_id' => 'required',
];
}

View File

@ -5,6 +5,7 @@ namespace App\Services;
use App\Model\Area;
use App\Model\BasicCompany;
use App\Model\DetectionProject;
use App\Model\DetectionProjectPurpose;
use App\Model\UserDoctor;
use App\Model\UserLocation;
@ -237,4 +238,23 @@ class DetectionService extends BaseService
return success($response_data);
}
/**
* 获取检测项目用途列表
* @return array
*/
public function getDetectionProjectPurposeList(): array
{
$detection_project_id = $this->request->input("detection_project_id",1);
// 获取项目数据
$params = array();
$params['detection_project_id'] = $detection_project_id;
$detection_project_purpose = DetectionProjectPurpose::getList($params);
if (empty($detection_project_purpose)){
return fail();
}
return success($detection_project_purpose->toArray());
}
}

View File

@ -269,16 +269,22 @@ Router::addGroup('/patient', function () {
// 检测
Router::addGroup('/detection', function () {
// 创建检测订单
Router::post('', [InquiryController::class, 'addDetectionOrder']);
Router::post('', [DetectionController::class, 'addDetectionOrder']);
// 获取检测机构合作医生列表
Router::get('/doctor', [DetectionController::class, 'getDetectionDoctorList']);
// 检测项目
Router::addGroup('/project', function () {
// 获取合作公司检测项目列表
Router::get('/project', [DetectionController::class, 'getDetectionProjectList']);
Router::get('', [DetectionController::class, 'getDetectionProjectList']);
// 获取合作公司检测项目详情
Router::get('/project/{detection_project_id:\d+}', [DetectionController::class, 'getDetectionProject']);
Router::get('/{detection_project_id:\d+}', [DetectionController::class, 'getDetectionProject']);
// 获取检测项目用途列表
Router::get('/purpose', [DetectionController::class, 'getDetectionProjectPurposeList']);
});
});
// 医生数据