Commit 5515a564 authored by clone's avatar clone

1

parent 5e3dac54
......@@ -4,6 +4,7 @@ namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\api_broker\service\SquareService;
use app\api_broker\service\SquareSortService;
class Square extends Basic
......@@ -20,17 +21,18 @@ class Square extends Basic
public function getDistrictLable()
{
$res = $this->s_square->getDistrictLable();
return $this->response("200", "成功",$res);
return $this->response("200", "成功", $res);
}
public function addSquare() {
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_lable_id'])) {
return $this->response("101", "参数不全");
}
$result= $this->s_square->saveSquare($this->agentId,$params['title'],$params['house_id'],$params['content'],$params['cover_img'],$params['site_id'],$params['district_lable_id']);
$result = $this->s_square->saveSquare($this->agentId, $params['title'], $params['house_id'], $params['content'], $params['cover_img'], $params['site_id'], $params['district_lable_id']);
return $this->response("200", "request success", $result);
}
......@@ -39,12 +41,12 @@ class Square extends Basic
{
$params = $this->params;
$result= $this->s_square->getSquareList($params);
$result = $this->s_square->getSquareList($params);
if($result){
return $this->response("200", "成功",$result);
}else{
return $this->response("200", "成功",$result);
if ($result) {
return $this->response("200", "成功", $result);
} else {
return $this->response("200", "成功", $result);
}
}
......@@ -56,17 +58,18 @@ class Square extends Basic
if (!isset($params['square_id'])) {
return $this->response("101", "参数不全");
}
$result= $this->s_square->getSquareCommentList($params);
$result = $this->s_square->getSquareCommentList($params);
if($result){
return $this->response("200", "成功",$result);
}else{
return $this->response("200", "成功",$result);
if ($result) {
return $this->response("200", "成功", $result);
} else {
return $this->response("200", "成功", $result);
}
}
public function getSquareInfo(){
public function getSquareInfo()
{
header('Access-Control-Allow-Origin:*');
$params = $this->params;
......@@ -74,56 +77,80 @@ class Square extends Basic
return $this->response("101", "参数不全");
}
$result= $this->s_square->getSquareInfo($params,$this->agentId);
$result = $this->s_square->getSquareInfo($params, $this->agentId);
if($result){
return $this->response("200", "成功",$result);
}else{
return $this->response("200", "成功",$result);
if ($result) {
return $this->response("200", "成功", $result);
} else {
return $this->response("200", "成功", $result);
}
}
public function addComent()
/**
* 评价开盘广场
* @return \think\Response
*/
public function addComment()
{
$params = $this->params;
if (!$params) {
return $this->response("101", "参数不全");
}
if (isset($params['level'])) {
if (!isset($params['comment_id']) or !isset($params['agent_id_b']) or !isset($params['comment']) or !isset($params['square_id'])) {
return $this->response("101", "参数不全");
}
$result = $this->s_square->addBCommentExt($params['comment_id'],$this->agentId,$params['agent_id_b'],$params['comment'],$params['level'], $this->agentName, $params['square_id']);
}else{
if (!isset($params['square_id']) or !isset($params['author_id']) or !isset($params['comment'])) {
return $this->response("101", "参数不全");
}
$result = $this->s_square->addBComent($params['square_id'],$params['comment'],$this->agentId, $this->params['author_id'], $this->agentName);
}
if($result){
return $this->response("200", "成功",$result);
}else{
return $this->response("200", "成功",$result);
$params = $this->params;
/* $params = array(
"level" => 1,//不传是主评论 1是主评论第一级回复 2是第一级回复的回复
"comment_id" => 1, //主评论ID
"agent_id_b" => 1, //被回复人的id
"square_id" => 1, // 开盘id
"author_id" => 1, // 主要做推送
);*/
$square_id = $params['square_id'];
$comment = $params['comment'];
if (!$square_id || $square_id <= 0 || !$comment) {
return $this->response("101", "开盘编号或评论不能为空");
}
$level = isset($params['level']) ? 0 : $params['level'];
switch ($level) {
case 0:
if ( !isset($params['author_id'])) {
return $this->response("101", "参数不全");
}
$result = $this->s_square->addBComment($square_id, $comment, $this->agentId, $this->params['author_id'], $this->agentName);
break;
case 1:
case 2:
if (!isset($params['comment_id']) || !isset($params['agent_id_b']) ) {
return $this->response("101", "参数不全");
}
$result = $this->s_square->addBCommentExt($params['comment_id'], $this->agentId, $params['agent_id_b'],
$comment, $level, $this->agentName, $square_id);
break;
default:
return $this->response("101", "请求参数level错误");
}
if ($result) {
$squareSort = new SquareSortService();
$squareSort->setSortSquareSort($square_id);
return $this->response("200", "成功", $result);
} else {
return $this->response("101", "保存失败");
}
}
public function getCommenInfo(){
public function getCommenInfo()
{
$params = $this->params;
if (!isset($params['id'])) {
return $this->response("101", "参数不全");
}
$result= $this->s_square->getCommenInfo($params,$this->agentId);
$result = $this->s_square->getCommenInfo($params, $this->agentId);
if($result){
return $this->response("200", "成功",$result);
}else{
return $this->response("200", "成功",$result);
if ($result) {
return $this->response("200", "成功", $result);
} else {
return $this->response("200", "成功", $result);
}
}
......@@ -131,16 +158,17 @@ class Square extends Basic
{
$params = $this->params;
$result= $this->s_square->getSquareCommentExtList($params);
$result = $this->s_square->getSquareCommentExtList($params);
if($result){
return $this->response("200", "成功",$result);
}else{
return $this->response("200", "成功",$result);
if ($result) {
return $this->response("200", "成功", $result);
} else {
return $this->response("200", "成功", $result);
}
}
public function editCommenSort() {
public function editCommenSort()
{
$params = $this->params;
if (!isset($params['id']) or !isset($params['sort'])) {
......@@ -161,15 +189,14 @@ class Square extends Basic
return $this->response("101", "参数错误");
}
$result= $this->s_square->delSquare($params);
$result = $this->s_square->delSquare($params);
if($result){
return $this->response("200", "成功",$result);
}else{
return $this->response("200", "成功",$result);
if ($result) {
return $this->response("200", "成功", $result);
} else {
return $this->response("200", "成功", $result);
}
}
}
\ No newline at end of file
......@@ -281,7 +281,7 @@ class SquareService
public function addSquare($square_id,$comment,$agent_id, $agent_b, $agent_name)
public function addBComment($square_id,$comment,$agent_id, $agent_b, $agent_name)
{
$insert["square_id"] = $square_id;//文章id
$insert["comment"] = $comment;//评价内容
......
......@@ -880,7 +880,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' ] ],
'addComent' => [ 'api_broker/Square/addComent', [ 'method' => 'GET|POST' ] ],
'addComent' => [ 'api_broker/Square/addComment', [ 'method' => 'GET|POST' ] ],
'getSquareCommentList' => [ 'api_broker/Square/getSquareCommentList', [ 'method' => 'GET|POST' ] ],
'getCommenInfo' => [ 'api_broker/Square/getCommenInfo', [ 'method' => 'GET|POST' ] ],
'getSquareCommentExtList' => [ 'api_broker/Square/getSquareCommentExtList', [ '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