新增热门搜索
This commit is contained in:
parent
113f9e34a1
commit
06fa3e6efd
@ -4,9 +4,7 @@ namespace App\Controller;
|
||||
|
||||
use App\Model\BasicNation;
|
||||
use App\Request\BasicDataRequest;
|
||||
use App\Request\DiseaseRequest;
|
||||
use App\Services\BasicDataService;
|
||||
use App\Services\DiseaseService;
|
||||
use App\Services\SafeService;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
@ -190,4 +188,20 @@ class BasicDataController extends AbstractController
|
||||
$data = $BasicDataService->getDoctorTitle();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取热门搜索关键词
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getHotSearchKeyword(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(BasicDataRequest::class);
|
||||
$request->scene('getHotSearchKeyword')->validateResolved();
|
||||
|
||||
$BasicDataService = new BasicDataService();
|
||||
$data = $BasicDataService->getHotSearchKeyword();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
}
|
||||
57
app/Model/HotSearchKeyword.php
Normal file
57
app/Model/HotSearchKeyword.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $keyword_id 主键id
|
||||
* @property string $keyword_name 名称
|
||||
* @property int $client_type 类型(1:患者端 2:医生端 3:药师端)
|
||||
* @property int $keyword_status 状态(0:删除 1:正常 2:禁用)
|
||||
* @property int $keyword_place 位置(1:患者端热门搜索)
|
||||
* @property int $keyword_sort 排序值(越小越靠前)
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class HotSearchKeyword extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'hot_search_keyword';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['keyword_id', 'keyword_name', 'client_type', 'keyword_status', 'keyword_place', 'keyword_sort', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @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)->orderBy('keyword_sort')->get($fields);
|
||||
}
|
||||
}
|
||||
@ -24,6 +24,10 @@ class BasicDataRequest extends FormRequest
|
||||
'getDiseaseIcdSearch' => [ // 搜索平台疾病分类
|
||||
'icd_keyword',
|
||||
],
|
||||
'getHotSearchKeyword' => [ // 获取热门搜索关键词
|
||||
'client_type',
|
||||
'keyword_place',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
@ -43,6 +47,8 @@ class BasicDataRequest extends FormRequest
|
||||
'province_id' => 'required_with:city_id,county_id',
|
||||
'city_id' => 'required_with:county_id',
|
||||
'disease_class_name' => 'required',
|
||||
'client_type' => 'required|integer|min:1|max:1',
|
||||
'keyword_place' => 'required|integer|min:1|max:1',
|
||||
];
|
||||
}
|
||||
|
||||
@ -55,6 +61,14 @@ class BasicDataRequest extends FormRequest
|
||||
'province_id.required_with' => "请选择省份",
|
||||
'city_id.required_with' => "请选择城市",
|
||||
'disease_class_name.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'client_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'client_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'client_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'client_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'keyword_place.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'keyword_place.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'keyword_place.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'keyword_place.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ use App\Model\DiseaseClassExpertise;
|
||||
use App\Model\DiseaseClassIcd;
|
||||
use App\Model\Hospital;
|
||||
use App\Model\HospitalDepartmentCustom;
|
||||
use App\Model\HotSearchKeyword;
|
||||
use App\Model\OperationManual;
|
||||
use App\Model\Product;
|
||||
use Hyperf\Redis\Redis;
|
||||
@ -366,4 +367,31 @@ class BasicDataService extends BaseService
|
||||
}
|
||||
return success($basic_doctor_title->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取热门搜索关键词
|
||||
* @return array
|
||||
*/
|
||||
public function getHotSearchKeyword(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$client_type = $this->request->input('client_type');
|
||||
$keyword_place = $this->request->input('keyword_place');
|
||||
|
||||
$params = array();
|
||||
$params['client_type'] = $client_type;
|
||||
$params['keyword_status'] = 1;
|
||||
$params['keyword_place'] = $keyword_place;
|
||||
|
||||
$fields = [
|
||||
'keyword_name'
|
||||
];
|
||||
$hot_search_keyword = HotSearchKeyword::getList($params,$fields);
|
||||
if (empty($hot_search_keyword)){
|
||||
return success();
|
||||
}
|
||||
|
||||
return success($hot_search_keyword->toArray());
|
||||
}
|
||||
}
|
||||
@ -32,6 +32,7 @@ class Auth
|
||||
"/callback/platform/logistics" => "post", // 处方平台物流回调
|
||||
"/callback/logistics" => "post", // 快递100订阅回调
|
||||
"/popup" => "get", // 获取弹窗数据
|
||||
"/basic/keyword/search" => "get", // 获取热门搜索关键词
|
||||
|
||||
"/test/refund" => "get", // 测试退款
|
||||
"/test" => "get", // 测试
|
||||
|
||||
@ -540,6 +540,9 @@ Router::addGroup('/basic', function () {
|
||||
|
||||
// 获取医生职称数据
|
||||
Router::get('/doctor/title', [BasicDataController::class, 'getDoctorTitle']);
|
||||
|
||||
// 获取热门搜索关键词
|
||||
Router::get('/keyword/search', [BasicDataController::class, 'getHotSearchKeyword']);
|
||||
});
|
||||
|
||||
// 获取医生评价
|
||||
@ -653,4 +656,4 @@ Router::addGroup('/inquiry', function () {
|
||||
});
|
||||
|
||||
// 获取弹窗数据
|
||||
Router::get('/popup', [UserController::class, 'getUserPopup']);
|
||||
Router::get('/popup', [UserController::class, 'getUserPopup']);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user