完善expert领域
This commit is contained in:
@@ -44,17 +44,22 @@ class ExpertManage extends Base
|
||||
|
||||
$query = Db::name('expert')->alias('e');
|
||||
$countQuery = Db::name('expert')->alias('e');
|
||||
$needJoin = ($field !== '');
|
||||
|
||||
if ($needJoin) {
|
||||
$query->join('t_expert_field ef', 'ef.expert_id = e.expert_id AND ef.state = 0', 'inner');
|
||||
$countQuery->join('t_expert_field ef', 'ef.expert_id = e.expert_id AND ef.state = 0', 'inner');
|
||||
if ($field !== '') {
|
||||
$query->where('ef.field', 'like', '%' . $field . '%');
|
||||
$countQuery->where('ef.field', 'like', '%' . $field . '%');
|
||||
}
|
||||
$query->group('e.expert_id');
|
||||
$countQuery->group('e.expert_id');
|
||||
if ($field !== '') {
|
||||
$fieldExpertIds = Db::name('expert_field')
|
||||
->where('state', 0)
|
||||
->where('field', 'like', '%' . $field . '%')
|
||||
->column('expert_id');
|
||||
$fieldExpertIds = array_values(array_unique(array_filter(array_map('intval', $fieldExpertIds))));
|
||||
|
||||
$fieldWhere = function ($q) use ($field, $fieldExpertIds) {
|
||||
$q->where('e.field_ai', 'like', '%' . $field . '%');
|
||||
if (!empty($fieldExpertIds)) {
|
||||
$q->whereOr('e.expert_id', 'in', $fieldExpertIds);
|
||||
}
|
||||
};
|
||||
$query->where($fieldWhere);
|
||||
$countQuery->where($fieldWhere);
|
||||
}
|
||||
|
||||
if ($state !== '-1' && $state !== '') {
|
||||
@@ -62,8 +67,8 @@ class ExpertManage extends Base
|
||||
$countQuery->where('e.state', intval($state));
|
||||
}
|
||||
if ($keyword !== '') {
|
||||
$query->where('e.name|e.email|e.affiliation', 'like', '%' . $keyword . '%');
|
||||
$countQuery->where('e.name|e.email|e.affiliation', 'like', '%' . $keyword . '%');
|
||||
$query->where('e.name|e.email|e.affiliation|e.field_ai', 'like', '%' . $keyword . '%');
|
||||
$countQuery->where('e.name|e.email|e.affiliation|e.field_ai', 'like', '%' . $keyword . '%');
|
||||
}
|
||||
if ($source !== '') {
|
||||
$query->where('e.source', $source);
|
||||
@@ -72,7 +77,7 @@ class ExpertManage extends Base
|
||||
|
||||
// $countQuery = clone $query;
|
||||
// $total = $countQuery->distinct('e.expert_id')->count();
|
||||
$total = $needJoin ? count($countQuery->group('e.expert_id')->column('e.expert_id')) : $countQuery->count();
|
||||
$total = $countQuery->count();
|
||||
|
||||
$list = $query
|
||||
->field('e.*')
|
||||
|
||||
Reference in New Issue
Block a user