Commit 84830494 authored by zhuwei's avatar zhuwei

开盘广场-删除

parent eea7f83f
......@@ -43,6 +43,24 @@ class Square extends Basic
}
public function getSquareInfo(){
$params = $this->params;
if (!isset($params['id'])) {
return $this->response("101", "参数不全");
}
$result= $this->s_square->getSquareInfo($params);
if($result){
return $this->response("200", "成功",$result);
}else{
return $this->response("200", "成功",$result);
}
}
}
\ No newline at end of file
......@@ -55,6 +55,7 @@ class SquareService
$field = 'Square.id,';//
$field .= 'Square.title,';//标题
$field .= 'Square.cover_img,';//cover_img
$field .= 'Agent.name,';//发布人
$field .= 'Site.name as site_name,';//城市
$field .= 'District.district_name,';//部门
......@@ -65,11 +66,41 @@ class SquareService
$res = $this->m_square->getSquareList($pageNo, $pageSize, $field, $get_params);
$res_total = $this->m_square->getSquareListTotal($field, $get_params);
foreach ($res as $key => $val) {
$res[$key]['image_path'] = 'http://n.sinaimg.cn/ent/transform/20170921/FVGl-fymesmp0851702.jpg';
}
return [ 'data' => $res, 'total' => $res_total ];
}
public function getSquareInfo($params){
$field = 'Square.id,';//
$field .= 'Square.title,';//标题
$field .= 'Square.content,';//标题
$field .= 'Agent.name,';//发布人
$field .= 'Site.name as site_name,';//城市
$field .= 'District.district_name,';//部门
$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, 'total' => $res_total ];
return [ 'data' => $res];
}
public function delSquare($id)
{
$where_params['id'] = $id;
$update_params['status'] = 1;
$res = $this->m_square->updateStatus($where_params,$update_params);
return $res;
}
}
\ No newline at end of file
......@@ -42,6 +42,9 @@ class Square extends Basic
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'])) {
return $this->response("101", "参数不全");
}
$result= $this->s_square->getSquareList($params);
......@@ -52,6 +55,44 @@ class Square extends Basic
}
}
public function getSquareInfo(){
header('Access-Control-Allow-Origin:*');
$params = $this->params;
if (!isset($params['id'])) {
return $this->response("101", "参数不全");
}
$result= $this->s_square->getSquareInfo($params);
if($result){
return $this->response("200", "成功",$result);
}else{
return $this->response("200", "成功",$result);
}
}
public function delSquare()
{
header('Access-Control-Allow-Origin:*');
$params = $this->params;
if (!isset($params['id'])) {
return $this->response("101", "参数不全");
}
if (!is_numeric($params['id'])) {
return $this->response("101", "参数错误");
}
$result= $this->s_square->delSquare($params['id']);
if($result){
return $this->response("200", "成功",$result);
}else{
return $this->response("200", "成功",$result);
}
}
......
......@@ -78,45 +78,31 @@ class BSquare extends Model
return $result;
}
//
//
// /**
// * 查询收藏数据统计
// * 朱伟 2018-08-10
// */
// public function getCollectListTotal($field,$params)
// {
// $order = "CollectUser.create_time desc";
// $result = Db::table($this->table)
// ->field($field)
// ->alias('CollectUser')
// ->join('g_houses Houses', 'CollectUser.house_id = Houses.id', 'left')
// ->where($params)
// ->count();
// //dump($this->getLastSql());
// return $result;
// }
//
//
// /**
// * 更新数据
// * 朱伟 2018-08-08
// */
// public function delCollectHouse($id)
// {
// $result = Db::table($this->table)
// ->where('house_id', $id)
// ->update([ 'status' => 3 ]);
// //dump($this->getLastSql());
// return $result;
// }
//
// public function updateStatus($agents_id,$house_id)
// {
// $result = $this->where(['agents_id'=>$agents_id,'house_id'=>$house_id])->update(['status'=>2]);
// //dump($this->getLastSql());
// // big_log($this->getLastSql());
// return $result;
// }
public function getSquareInfo($field,$params)
{
$order = "Square.create_time desc";
$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')
->where($params)
->order($order)
->find();
//dump($this->getLastSql());
return $result;
}
public function updateStatus($where_params,$update_params)
{
$result = $this->where($where_params)->update($update_params);
// dump($this->getLastSql());
// big_log($this->getLastSql());
return $result;
}
}
......@@ -443,6 +443,8 @@ Route::group('index', [
//开盘广场
'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']],
]);
......@@ -851,6 +853,7 @@ Route::group('broker', [
//开盘广场
'addSquare' => ['api_broker/Square/addSquare', ['method' => 'GET|POST']],
'getSquareList' => ['api_broker/Square/getSquareList', ['method' => 'GET|POST']],
'getSquareInfo' => ['api_broker/Square/getSquareInfo', ['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