Commit 32226a42 authored by zhuwei's avatar zhuwei

1

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