Commit 32226a42 authored by zhuwei's avatar zhuwei

1

parent 41a19163
......@@ -17,14 +17,20 @@ class Square extends Basic
}
public function getDistrictLable()
{
$res = $this->s_square->getDistrictLable();
return $this->response("200", "成功",$res);
}
public function addSquare() {
$params = $this->params;
if (!isset($params['title']) or !isset($params['content']) or !isset($params['site_id']) or !isset($params['cover_img']) or !isset($params['district_id'])) {
if (!isset($params['title']) or !isset($params['content']) or !isset($params['site_id']) or !isset($params['cover_img']) or !isset($params['district_lable_id'])) {
return $this->response("101", "参数不全");
}
$result= $this->s_square->saveSquare($this->agentId,$params['title'],$params['content'],$params['cover_img'],$params['site_id'],$params['district_id']);
$result= $this->s_square->saveSquare($this->agentId,$params['title'],$params['content'],$params['cover_img'],$params['site_id'],$params['district_lable_id']);
return $this->response("200", "request success", $result);
}
......@@ -83,10 +89,10 @@ class Square extends Basic
}
if (isset($params['level'])) {
if (!isset($params['comment_id']) or !isset($params['agent_id_a']) or !isset($params['agent_id_b']) or !isset($params['comment'])) {
if (!isset($params['comment_id']) or !isset($params['agent_id_b']) or !isset($params['comment'])) {
return $this->response("101", "参数不全");
}
$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'],$this->agentId,$params['agent_id_b'],$params['comment'],$params['level']);
}else{
if (!isset($params['square_id']) or !isset($params['square_id']) or !isset($params['comment'])) {
return $this->response("101", "参数不全");
......
......@@ -19,6 +19,22 @@ class SquareService
$this->m_coment_ext = new BCommentExt();
}
public function getDistrictLable(){
$res[]=['id'=>1,'name'=>'一部'];
$res[]=['id'=>2,'name'=>'二部'];
$res[]=['id'=>3,'name'=>'三部'];
$res[]=['id'=>4,'name'=>'四部'];
$res[]=['id'=>5,'name'=>'五部'];
$res[]=['id'=>6,'name'=>'六部'];
$res[]=['id'=>7,'name'=>'七部'];
$res[]=['id'=>8,'name'=>'八部'];
$res[]=['id'=>9,'name'=>'九部'];
$res[]=['id'=>10,'name'=>'十部'];
return $res;
}
public function saveSquare($agent_id,$title,$content,$cover_img,$site_id,$district_id)
{
$insert["agent_id"] = $agent_id;//经纪人id
......@@ -26,7 +42,7 @@ class SquareService
$insert["content"] = $content;//text
$insert["cover_img"] = $cover_img;//封面图
$insert["site_id"] = $site_id;//站点id
$insert["district_id"] = $district_id;//部门id
$insert["district_lable_id"] = $district_id;//部门id
$insert["status"] = 0;//状态: 0正常 1删除
$res = $this->m_square->saveSquare($insert);//int(1)
......@@ -51,8 +67,8 @@ class SquareService
$get_params['Square.site_id'] = $params['site_id'];
}
//部门
if (!empty($params['district_id'])) {
$get_params['Square.district_id'] = $params['district_id'];
if (!empty($params['district_lable_id'])) {
$get_params['Square.district_lable_id'] = $params['district_lable_id'];
}
//文章标题
if (!empty($params['title'])) {
......@@ -85,6 +101,7 @@ class SquareService
$field = 'Comment.id,';//
$field .= 'Comment.comment,';//
$field .= 'Comment.agent_id,';//
$field .= 'Comment.sort,';//
$field .= 'Comment.create_time,';//
$field .= 'Agent.name,';//
......@@ -97,14 +114,15 @@ class SquareService
foreach ($res as $key => $val) {
$res[$key]['img'] = 'http://n.sinaimg.cn/ent/transform/20170921/FVGl-fymesmp0851702.jpg';
$field = 'CommentExt.id,';//
$field .= 'CommentExt.comment,';//
$get_params = [];
$field .= 'Agent.name,';//
$field .= 'Agent.img';//
$field = 'CommentExt.id,CommentExt.comment,AgentA.name as agent_id_a,AgentB.name as agent_id_b';//
$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';
// dump($val);
// dump($field);
// dump($get_params);
$res[$key]['comment_ext']= $this->m_coment_ext->getSquareCommentExtList(1, 2, $field, $get_params);
}
return [ 'data' => $res, 'total' => $res_total ];
......@@ -118,17 +136,22 @@ class SquareService
$field .= 'Square.cover_img,';//cover_img
$field .= 'Agent.name,';//发布人
$field .= 'Square.site_id,';//城市
$field .= 'Square.district_id,';//部门
$field .= 'Site.name as site_name,';//城市
$field .= 'Square.district_lable_id,';//部门
$field .= 'Square.create_time';//发布时间
$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;
}
}
// foreach ($res as $key => $val) {
//
// }
return [ 'data' => $res];
}
......@@ -149,8 +172,8 @@ class SquareService
$update_params['site_id'] = $params['site_id'];
}
//部门
if (!empty($params['district_id'])) {
$update_params['district_id'] = $params['district_id'];
if (!empty($params['district_lable_id'])) {
$update_params['district_lable_id'] = $params['district_lable_id'];
}
if (!empty($params['title'])) {
$update_params['title'] = $params['title'];
......@@ -207,4 +230,27 @@ class SquareService
}
}
public function getCommenInfo($params){
$field = 'Square.id,';//
$field .= 'Square.title,';//标题
$field .= 'Square.content,';//标题
$field .= 'Square.cover_img,';//cover_img
$field .= 'Agent.name,';//发布人
$field .= 'Square.site_id,';//城市
$field .= 'Square.district_lable_id,';//部门
$field .= 'Square.create_time';//发布时间
$get_params['Square.id'] = $params['id'];
// $get_params['Square.status'] = 0;
$res = $this->m_square->getSquareInfo($field,$get_params);
// foreach ($res as $key => $val) {
//
// }
return [ 'data' => $res];
}
}
\ No newline at end of file
......@@ -19,16 +19,22 @@ class Square extends Basic
$this->s_square = new SquareService();
}
public function getDistrictLable()
{
$res = $this->s_square->getDistrictLable();
return $this->response("200", "成功",$res);
}
public function addSquare() {
header('Access-Control-Allow-Origin:*');
$params = $this->params;
if (!isset($params['title']) or !isset($params['content']) or !isset($params['site_id']) or !isset($params['cover_img']) or !isset($params['district_id'])) {
if (!isset($params['title']) or !isset($params['content']) or !isset($params['site_id']) or !isset($params['cover_img']) or !isset($params['district_lable_id'])) {
return $this->response("101", "参数不全");
}
$res= $this->s_square->saveSquare($this->userId,$params['title'],$params['content'],$params['cover_img'],$params['site_id'],$params['district_id']);
$res= $this->s_square->saveSquare($this->userId,$params['title'],$params['content'],$params['cover_img'],$params['site_id'],$params['district_lable_id']);
if ($res) {
return $this->response("200", "成功");
} else {
......
......@@ -49,4 +49,20 @@ class BComment extends Model
}
public function getCommenInfo($field,$params)
{
$order = "Comment.create_time desc";
$result = Db::table($this->table)
->field($field)
->alias('Comment')
->join('a_agents Agent', 'Agent.id = Square.agent_id', 'left')
->join('a_site Site', 'Site.id = Square.site_id', 'left')
->join('a_district District', 'District.id = Square.district_id', 'left')
->where($params)
->order($order)
->find();
// dump($this->getLastSql());
return $result;
}
}
......@@ -25,7 +25,8 @@ class BCommentExt extends Model
$result = Db::table($this->table)
->field($field)
->alias('CommentExt')
->join('a_agents Agent', 'Agent.id = Comment.agent_id', 'right')
->join('a_agents AgentA', 'AgentA.id = CommentExt.agent_id_a', 'left')
->join('a_agents AgentB', 'AgentB.id = CommentExt.agent_id_b', 'left')
->where($params)
->limit($pageSize)
->page($pageNo)
......@@ -41,7 +42,7 @@ class BCommentExt extends Model
$result = Db::table($this->table)
->field($field)
->alias('CommentExt')
->join('a_agents Agent', 'Agent.id = Comment.agent_id', 'right')
->join('a_agents Agent', 'Agent.id = Comment.agent_id', 'left')
->where($params)
->count();
//dump($this->getLastSql());
......
......@@ -50,9 +50,9 @@ class BSquare extends Model
$result = Db::table($this->table)
->field($field)
->alias('Square')
->join('a_agents Agent', 'Agent.id = Square.agent_id', 'right')
->join('a_site Site', 'Site.id = Square.site_id', 'right')
->join('a_district District', 'District.id = Square.district_id', 'right')
->join('a_agents Agent', 'Agent.id = Square.agent_id', 'left')
->join('a_site Site', 'Site.id = Square.site_id', 'left')
->join('a_district District', 'District.id = Square.district_id', 'left')
// ->join('b_comment Comment', 'Square.id = Comment.square_id', 'right')
->where($params)
->limit($pageSize)
......@@ -69,9 +69,9 @@ class BSquare extends Model
$result = Db::table($this->table)
->field($field)
->alias('Square')
->join('a_agents Agent', 'Agent.id = Square.agent_id', 'right')
->join('a_site Site', 'Site.id = Square.site_id', 'right')
->join('a_district District', 'District.id = Square.district_id', 'right')
->join('a_agents Agent', 'Agent.id = Square.agent_id', 'left')
->join('a_site Site', 'Site.id = Square.site_id', 'left')
->join('a_district District', 'District.id = Square.district_id', 'left')
// ->join('b_comment Comment', 'Square.id = Comment.square_id', 'right')
->where($params)
->count();
......@@ -85,9 +85,9 @@ class BSquare extends Model
$result = Db::table($this->table)
->field($field)
->alias('Square')
->join('a_agents Agent', 'Agent.id = Square.agent_id', 'right')
->join('a_site Site', 'Site.id = Square.site_id', 'right')
->join('a_district District', 'District.id = Square.district_id', 'right')
->join('a_agents Agent', 'Agent.id = Square.agent_id', 'left')
->join('a_site Site', 'Site.id = Square.site_id', 'left')
// ->join('a_district District', 'District.id = Square.district_id', 'left')
->where($params)
->order($order)
->find();
......
......@@ -442,11 +442,12 @@ Route::group('index', [
'videoCheckList' => ['index/VideoCheck/videoCheckList', ['method' => 'get|post']],
//开盘广场
'addSquare' => ['index/Square/addSquare', ['method' => 'GET|POST']],
'getSquareList' => ['index/Square/getSquareList', ['method' => 'GET|POST']],
'getSquareInfo' => ['index/Square/getSquareInfo', ['method' => 'GET|POST']],
'delSquare' => ['index/Square/delSquare', ['method' => 'GET|POST']],
'editSquare' => ['index/Square/editSquare', ['method' => 'GET|POST']],
'getDistrictLable' => [ 'index/Square/getDistrictLable', [ 'method' => 'GET|POST' ] ],
'addSquare' => [ 'index/Square/addSquare', [ 'method' => 'GET|POST' ] ],
'getSquareList' => [ 'index/Square/getSquareList', [ 'method' => 'GET|POST' ] ],
'getSquareInfo' => [ 'index/Square/getSquareInfo', [ 'method' => 'GET|POST' ] ],
'delSquare' => [ 'index/Square/delSquare', [ 'method' => 'GET|POST' ] ],
'editSquare' => [ 'index/Square/editSquare', [ '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