Commit 9bed56f8 authored by zhuwei's avatar zhuwei

发布开盘

parent 69b6cd64
<?php
namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\api_broker\service\SquareService;
class Square extends Basic
{
private $s_square;
public function __construct($request = null)
{
parent::__construct($request);
$this->s_square = new SquareService();
}
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'])) {
return $this->response("101", "参数不全");
}
$result= $this->s_square->saveSquare($this->agentId,$params['title'],$params['content'],$params['cover_img'],$params['site_id'],$params['district_id']);
return $this->response("200", "request success", $result);
}
}
\ No newline at end of file
<?php
namespace app\api_broker\service;
use app\model\BSquare;
class SquareService
{
private $m_square;
public function __construct()
{
$this->m_square = new BSquare();
}
public function saveSquare($agent_id,$title,$content,$cover_img,$site_id,$district_id)
{
$insert["agent_id"] = $agent_id;//经纪人id
$insert["title"] = $title;//标题
$insert["content"] = $content;//text
$insert["cover_img"] = $cover_img;//封面图
$insert["site_id"] = $site_id;//站点id
$insert["district_id"] = $district_id;//部门id
$insert["status"] = 0;//状态: 0正常 1删除
$res = $this->m_square->saveSquare($insert);//int(1)
if($res == 1){
return true;
}else{
return false;
}
}
}
\ No newline at end of file
<?php
namespace app\index\controller;
use app\api_broker\service\SquareService;
use app\index\extend\Basic;
use app\model\ASite;
use think\Request;
class Square extends Basic
{
protected $s_square;
public function __construct($request = null)
{
parent::__construct($request);
$this->s_square = new SquareService();
}
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'])) {
return $this->response("101", "参数不全");
}
$res= $this->s_square->saveSquare($this->userId,$params['title'],$params['content'],$params['cover_img'],$params['site_id'],$params['district_id']);
if ($res) {
return $this->response("200", "成功");
} else {
return $this->response("101", "失败");
}
}
}
\ No newline at end of file
<?php
namespace app\model;
use think\Db;
use think\Model;
class BSquare extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'b_square';
public function saveSquare($data) {
$time = date("Y-m-d H:i:s", time());
$data['create_time'] = $time;
$data['update_time'] = $time;
return $this->insert($data);
}
/**
* 查询数据
*/
public function getSquare($field,$params)
{
$result = Db::table($this->table)
->field($field)
//->alias('a')
->where($params)
->select();
//dump($this->getLastSql());
return $result;
}
/**
* 更新数据
*/
public function updateSquare($params)
{
$result = $this->update($params);
//dump($this->getLastSql());
return $result;
}
// /**
// * 查询收藏数据
// */
// public function getCollectList($pageNo,$pageSize,$field,$params)
// {
// $order = "CollectUser.update_time desc";
// $result = Db::table($this->table)
// ->field($field)
// ->alias('CollectUser')
// ->join('g_houses Houses', 'CollectUser.house_id = Houses.id', 'right')
// ->where($params)
// ->limit($pageSize)
// ->page($pageNo)
// ->order($order)
// ->select();
// //dump($this->getLastSql());
// 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;
// }
}
......@@ -439,6 +439,9 @@ Route::group('index', [
'check' => ['index/AccountBalance/check', ['method' => 'get|post']],
'videoCheckList' => ['index/VideoCheck/videoCheckList', ['method' => 'get|post']],
//开盘广场
'addSquare' => ['index/Square/addSquare', ['method' => 'GET|POST']],
]);
......@@ -843,6 +846,9 @@ Route::group('broker', [
'getRandKingListByAgentId' => ['api_broker/RankingList/getRandKingListByAgentId', ['method' => 'GET|POST']],
'getStoreRandKingListByAgentId' => ['api_broker/RankingList/getStoreRandKingListByAgentId', ['method' => 'GET|POST']],
//开盘广场
'addSquare' => ['api_broker/Square/addSquare', ['method' => 'GET|POST']],
]);
//Route::miss('api/index/miss');//处理错误的url
\ No newline at end of file
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