新增获取我的问诊、关注医生列表接口
This commit is contained in:
@@ -8,6 +8,7 @@ namespace App\Model;
|
||||
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Database\Model\Relations\BelongsTo;
|
||||
use Hyperf\Database\Model\Relations\HasMany;
|
||||
use Hyperf\Database\Model\Relations\HasOne;
|
||||
use Hyperf\Database\Model\Relations\HasOneThrough;
|
||||
use Hyperf\DbConnection\Db;
|
||||
@@ -70,6 +71,15 @@ class PatientHistoryInquiry extends Model
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联医生专长表
|
||||
* @return HasMany
|
||||
*/
|
||||
public function DoctorExpertise(): HasMany
|
||||
{
|
||||
return $this->hasMany(DoctorExpertise::class, "doctor_id", "doctor_id");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
@@ -120,7 +130,6 @@ class PatientHistoryInquiry extends Model
|
||||
->where($params)
|
||||
->limit($limit)
|
||||
->get($fields);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,4 +159,34 @@ class PatientHistoryInquiry extends Model
|
||||
{
|
||||
return self::where($params)->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页数据
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @param int|null $page
|
||||
* @param int|null $per_page
|
||||
* @return array
|
||||
*/
|
||||
public static function getPage(array $params,array $fields = ["*"], int $page = null, ?int $per_page = 10): array
|
||||
{
|
||||
$query = self::with([
|
||||
'DoctorExpertise:doctor_expertise_id,doctor_id,expertise_id',
|
||||
'DoctorExpertise.DiseaseClassExpertise:expertise_id,expertise_name',
|
||||
"UserDoctor:doctor_id,user_name,avatar,doctor_title,hospital_id,multi_point_status,department_custom_name,be_good_at",
|
||||
"UserDoctor.Hospital:hospital_id,hospital_name"
|
||||
])
|
||||
->where($params)
|
||||
->groupBy('doctor_id')
|
||||
->paginate($per_page, $fields, "page", $page);
|
||||
|
||||
$data = array();
|
||||
$data['current_page'] = $query->currentPage();// 当前页码
|
||||
$data['total'] = $query->total();//数据总数
|
||||
$data['data'] = $query->items();//数据
|
||||
$data['per_page'] = $query->perPage();//每页个数
|
||||
$data['last_page'] = $query->lastPage();//最后一页
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user