1
This commit is contained in:
@@ -53,13 +53,58 @@ class ExpertFinder extends Base
|
||||
return jsonSuccess($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试单个专家的国家解析(同步执行,立刻返回结果)
|
||||
*/
|
||||
public function cityTest(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"expert_id"=>"require",
|
||||
"aff"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$service = new ExpertFinderService();
|
||||
$service->fillExpertCountry($data['expert_id'], $data['aff']);
|
||||
$expert = Db::name('expert')->where('expert_id', intval($data['expert_id']))->find();
|
||||
return jsonSuccess([
|
||||
'country_id' => isset($expert['country_id']) ? $expert['country_id'] : null,
|
||||
'country' => isset($expert['country']) ? $expert['country'] : null,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动国家解析:找到第一个缺 country 的专家推入队列,
|
||||
* 队列处理完后会自动链式找下一个,直到全部处理完。
|
||||
* 只需调一次即可。
|
||||
*/
|
||||
public function batchFillCountry(){
|
||||
$service = new ExpertFinderService();
|
||||
$started = $service->enqueueNextCountryFill(0);
|
||||
|
||||
$pending = Db::name('expert')
|
||||
->where('affiliation', '<>', '')
|
||||
->where(function ($q) {
|
||||
$q->where('country_id', 0)
|
||||
->whereOr('country_id', 'null')
|
||||
->whereOr('country', '');
|
||||
})
|
||||
->where('state', '<>', 5)
|
||||
->count();
|
||||
|
||||
return jsonSuccess([
|
||||
'started' => $started,
|
||||
'pending' => $pending,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get experts from local database
|
||||
*/
|
||||
public function getList()
|
||||
{
|
||||
$field = trim($this->request->param('field', ''));
|
||||
$majorId = intval($this->request->param('major_id', 0));
|
||||
$state = $this->request->param('state', '-1');
|
||||
$keyword = trim($this->request->param('keyword', ''));
|
||||
$noRecent = intval($this->request->param('no_recent', 0));
|
||||
@@ -69,16 +114,13 @@ class ExpertFinder extends Base
|
||||
$minExperts = max(0, intval($this->request->param('min_experts', 50)));
|
||||
|
||||
$query = Db::name('expert')->alias('e');
|
||||
$needJoin = ($field !== '' || $majorId > 0);
|
||||
$needJoin = ($field !== '');
|
||||
|
||||
if ($needJoin) {
|
||||
$query->join('t_expert_field ef', 'ef.expert_id = e.expert_id AND ef.state = 0', 'inner');
|
||||
if ($field !== '') {
|
||||
$query->where('ef.field', 'like', '%' . $field . '%');
|
||||
}
|
||||
if ($majorId > 0) {
|
||||
$query->where('ef.major_id', $majorId);
|
||||
}
|
||||
$query->group('e.expert_id');
|
||||
}
|
||||
|
||||
@@ -108,6 +150,7 @@ class ExpertFinder extends Base
|
||||
$item['fields'] = Db::name('expert_field')
|
||||
->where('expert_id', $item['expert_id'])
|
||||
->where('state', 0)
|
||||
->group('field')
|
||||
->column('field');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user