Commit 2e86f9f6 authored by zhuwei's avatar zhuwei

getSquareInfo

parent be41f417
...@@ -42,6 +42,21 @@ class Square extends Basic ...@@ -42,6 +42,21 @@ class Square extends Basic
} }
} }
public function getSquareCommentList()
{
$params = $this->params;
if (!isset($params['square_id'])) {
return $this->response("101", "参数不全");
}
$result= $this->s_square->getSquareCommentList($params);
if($result){
return $this->response("200", "成功",$result);
}else{
return $this->response("200", "成功",$result);
}
}
public function getSquareInfo(){ public function getSquareInfo(){
...@@ -59,7 +74,7 @@ class Square extends Basic ...@@ -59,7 +74,7 @@ class Square extends Basic
} }
} }
public function addcoment() public function addComent()
{ {
$params = $this->params; $params = $this->params;
...@@ -73,10 +88,10 @@ class Square extends Basic ...@@ -73,10 +88,10 @@ class Square extends Basic
} }
$result = $this->s_square->addBCommentExt($params['comment_id'],$params['agent_id_a'],$params['agent_id_b'],$params['comment'],$params['level']); $result = $this->s_square->addBCommentExt($params['comment_id'],$params['agent_id_a'],$params['agent_id_b'],$params['comment'],$params['level']);
}else{ }else{
if (!isset($params['title']) or !isset($params['square_id']) or !isset($params['comment']) or !isset($params['agent_id'])) { if (!isset($params['square_id']) or !isset($params['square_id']) or !isset($params['comment'])) {
return $this->response("101", "参数不全"); return $this->response("101", "参数不全");
} }
$result = $this->s_square->addBComent($params['square_id'],$params['comment'],$params['agent_id']); $result = $this->s_square->addBComent($params['square_id'],$params['comment'],$this->agentId);
} }
if($result){ if($result){
......
...@@ -79,6 +79,36 @@ class SquareService ...@@ -79,6 +79,36 @@ class SquareService
return [ 'data' => $res, 'total' => $res_total ]; return [ 'data' => $res, 'total' => $res_total ];
} }
public function getSquareCommentList($params){
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
$pageSize = empty($params['page_size']) ? 15 : $params['page_size'];
$field = 'Comment.id,';//
$field .= 'Comment.comment,';//
$field .= 'Comment.sort,';//
$field .= 'Comment.create_time,';//
$field .= 'Agent.name,';//
$field .= 'Agent.img';//
$get_params['Comment.square_id'] = $params['square_id'];
$res = $this->m_coment->getSquareCommentList($pageNo, $pageSize, $field, $get_params);
$res_total = $this->m_coment->getSquareCommentListTotal($field, $get_params);
foreach ($res as $key => $val) {
$res[$key]['img'] = 'http://n.sinaimg.cn/ent/transform/20170921/FVGl-fymesmp0851702.jpg';
$field = 'CommentExt.id,';//
$field .= 'CommentExt.comment,';//
$field .= 'Agent.name,';//
$field .= 'Agent.img';//
$get_params['CommentExt.comment_id'] = $val['id'];
$res = $this->m_coment_ext->getSquareCommentExtList(1, 2, $field, $get_params);
$res[$key]['comment_ext'] = 'http://n.sinaimg.cn/ent/transform/20170921/FVGl-fymesmp0851702.jpg';
}
return [ 'data' => $res, 'total' => $res_total ];
}
public function getSquareInfo($params){ public function getSquareInfo($params){
...@@ -86,12 +116,12 @@ class SquareService ...@@ -86,12 +116,12 @@ class SquareService
$field .= 'Square.title,';//标题 $field .= 'Square.title,';//标题
$field .= 'Square.content,';//标题 $field .= 'Square.content,';//标题
$field .= 'Agent.name,';//发布人 $field .= 'Agent.name,';//发布人
$field .= 'Site.name as site_name,';//城市 $field .= 'Square.site_id,';//城市
$field .= 'District.district_name,';//部门 $field .= 'Square.district_id,';//部门
$field .= 'Square.create_time';//发布时间 $field .= 'Square.create_time';//发布时间
$get_params['Square.id'] = $params['id']; $get_params['Square.id'] = $params['id'];
$get_params['Square.status'] = 0; // $get_params['Square.status'] = 0;
$res = $this->m_square->getSquareInfo($field,$get_params); $res = $this->m_square->getSquareInfo($field,$get_params);
......
...@@ -19,5 +19,34 @@ class BComment extends Model ...@@ -19,5 +19,34 @@ class BComment extends Model
return $this->insert($data); return $this->insert($data);
} }
public function getSquareCommentList($pageNo,$pageSize,$field,$params)
{
$order = "Comment.create_time desc";
$result = Db::table($this->table)
->field($field)
->alias('Comment')
->join('a_agents Agent', 'Agent.id = Comment.agent_id', 'right')
->where($params)
->limit($pageSize)
->page($pageNo)
->order($order)
->select();
//dump($this->getLastSql());
return $result;
}
public function getSquareCommentListTotal($field,$params)
{
$order = "Comment.create_time desc";
$result = Db::table($this->table)
->field($field)
->alias('Comment')
->join('a_agents Agent', 'Agent.id = Comment.agent_id', 'right')
->where($params)
->count();
//dump($this->getLastSql());
return $result;
}
} }
...@@ -19,5 +19,34 @@ class BCommentExt extends Model ...@@ -19,5 +19,34 @@ class BCommentExt extends Model
return $this->insert($data); return $this->insert($data);
} }
public function getSquareCommentExtList($pageNo,$pageSize,$field,$params)
{
$order = "CommentExt.create_time desc";
$result = Db::table($this->table)
->field($field)
->alias('CommentExt')
->join('a_agents Agent', 'Agent.id = Comment.agent_id', 'right')
->where($params)
->limit($pageSize)
->page($pageNo)
->order($order)
->select();
//dump($this->getLastSql());
return $result;
}
public function getSquareCommentExtListTotal($field,$params)
{
$order = "CommentExt.create_time desc";
$result = Db::table($this->table)
->field($field)
->alias('CommentExt')
->join('a_agents Agent', 'Agent.id = Comment.agent_id', 'right')
->where($params)
->count();
//dump($this->getLastSql());
return $result;
}
} }
...@@ -53,6 +53,7 @@ class BSquare extends Model ...@@ -53,6 +53,7 @@ class BSquare extends Model
->join('a_agents Agent', 'Agent.id = Square.agent_id', 'right') ->join('a_agents Agent', 'Agent.id = Square.agent_id', 'right')
->join('a_site Site', 'Site.id = Square.site_id', 'right') ->join('a_site Site', 'Site.id = Square.site_id', 'right')
->join('a_district District', 'District.id = Square.district_id', 'right') ->join('a_district District', 'District.id = Square.district_id', 'right')
// ->join('b_comment Comment', 'Square.id = Comment.square_id', 'right')
->where($params) ->where($params)
->limit($pageSize) ->limit($pageSize)
->page($pageNo) ->page($pageNo)
...@@ -71,7 +72,7 @@ class BSquare extends Model ...@@ -71,7 +72,7 @@ class BSquare extends Model
->join('a_agents Agent', 'Agent.id = Square.agent_id', 'right') ->join('a_agents Agent', 'Agent.id = Square.agent_id', 'right')
->join('a_site Site', 'Site.id = Square.site_id', 'right') ->join('a_site Site', 'Site.id = Square.site_id', 'right')
->join('a_district District', 'District.id = Square.district_id', 'right') ->join('a_district District', 'District.id = Square.district_id', 'right')
// ->join('b_comment Comment', 'Square.id = Comment.square_id', 'right')
->where($params) ->where($params)
->count(); ->count();
//dump($this->getLastSql()); //dump($this->getLastSql());
...@@ -90,7 +91,7 @@ class BSquare extends Model ...@@ -90,7 +91,7 @@ class BSquare extends Model
->where($params) ->where($params)
->order($order) ->order($order)
->find(); ->find();
//dump($this->getLastSql()); // dump($this->getLastSql());
return $result; return $result;
} }
......
...@@ -854,9 +854,11 @@ Route::group('broker', [ ...@@ -854,9 +854,11 @@ Route::group('broker', [
'getStoreRandKingListByAgentId' => ['api_broker/RankingList/getStoreRandKingListByAgentId', ['method' => 'GET|POST']], 'getStoreRandKingListByAgentId' => ['api_broker/RankingList/getStoreRandKingListByAgentId', ['method' => 'GET|POST']],
//开盘广场 //开盘广场
'addSquare' => ['api_broker/Square/addSquare', ['method' => 'GET|POST']], 'addSquare' => [ 'api_broker/Square/addSquare', [ 'method' => 'GET|POST' ] ],
'getSquareList' => ['api_broker/Square/getSquareList', ['method' => 'GET|POST']], 'getSquareList' => [ 'api_broker/Square/getSquareList', [ 'method' => 'GET|POST' ] ],
'getSquareInfo' => ['api_broker/Square/getSquareInfo', ['method' => 'GET|POST']], 'getSquareInfo' => [ 'api_broker/Square/getSquareInfo', [ 'method' => 'GET|POST' ] ],
'addComent' => [ 'api_broker/Square/addComent', [ 'method' => 'GET|POST' ] ],
'getSquareCommentList' => [ 'api_broker/Square/getSquareCommentList', [ 'method' => 'GET|POST' ] ],
]); ]);
......
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