Commit b71636db authored by zhuwei's avatar zhuwei

优化 根据ID获取标签名

parent 9f602fae
......@@ -96,8 +96,9 @@ class SquareService
}
$field = 'Square.id,';//
$field .= 'Square.title,';//标题
$field .= 'Square.agent_id,';//标题
$field .= 'Square.title,';
$field .= 'Square.agent_id,';
$field .= 'Square.district_lable_id,';//
$field .= 'Square.cover_img,';//cover_img
$field .= 'Site.name as site_name,';//城市
$field .= 'Square.create_time';//发布时间
......@@ -112,13 +113,7 @@ class SquareService
$res[$key]['image_path'] = AGENTHEADERIMGURL . $agent['img'];
//部门标签
$res[$key]['district_lable_name'] = '一部';
foreach ($this->getDistrictLable() as $key1 => $val1) {
if($res[$key1]['district_lable_id'] == $val1['id']){
$res[$key1]['district_lable_name'] = $val1['name'];
continue;
}
}
$res[$key]['district_lable_name'] = $this->getDistrictLableName($val['district_lable_id']);
//评论数
$res[$key]['comment_num'] = $this->getCommenNum($val['id']);
......@@ -187,14 +182,9 @@ class SquareService
$get_params['Square.id'] = $params['id'];
// $get_params['Square.status'] = 0;
$res = $this->m_square->getSquareInfo($field,$get_params);
$res['district_lable_name'] = '一部';
foreach ($this->getDistrictLable() as $key => $val) {
if($res['district_lable_id'] == $val['id']){
$res['district_lable_name'] = $val['name'];
continue;
}
}
$res['district_lable_name'] = $this->getDistrictLableName($res['district_lable_id']);
$agent = $this->redis->getRedisCache(2, $res['agent_id']) ;
$res['name'] = $agent['name'];
......@@ -359,4 +349,20 @@ class SquareService
$res = $this->m_coment->getCommenNum($get_params);
return $res;
}
/**
* 根据ID获取标签名
* @param $district_lable_id
* @return string
*/
public function getDistrictLableName($district_lable_id){
foreach ($this->getDistrictLable() as $k => $v) {
if($district_lable_id == $v['id']){
return $v['name'];
continue;
}
}
return '其他';
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment