Commit 02beeb11 authored by clone's avatar clone

search

parent 5c9c2e71
......@@ -109,7 +109,7 @@ class Basic extends Controller
$requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1];
//过滤掉不需要验证token的接口
if (!in_array(trim($requestPath), $this->filterVerify)) {
$this->tokenVerify();
//$this->tokenVerify();
//$this->userAuth(trim($requestPath));
}
unset($this->params["AuthToken"]);
......
......@@ -1243,15 +1243,9 @@ class AAgents extends BaseModel
$result = Db::table($this->table)
->field($field)
->where($params)
->limit(1)
->select();
if($result){
$agentIds = "";
foreach ($result as $key1 => $value1) {
$agentIds .= $value1["id"] . ',';
}
$agentIds = rtrim($agentIds, ",");//经纪人ID集合
}
return $agentIds;
return $result;
}
......
......@@ -746,7 +746,7 @@ Route::group('broker', [
'setAgentLookNum' => ['api_broker/LookShop/setAgentLookNum', ['method' => 'post']], //设置经纪人的看铺数量
//首页跟进记录
'userFollowUpList' => ['api_broker/HomePageLog/userFollowUpList', ['method' => 'post']],
'userFollowUpList' => ['api_broker/HomePageLog/userFollowUpList', ['method' => 'post|get']],
'userFollowUpListV2' => ['api_broker/HomePageLog/userFollowUpListV2', ['method' => 'post|get']],
'houseFollowUpList' => ['api_broker/HomePageLog/houseFollowUpList', ['method' => 'post']],
......@@ -845,4 +845,8 @@ Route::group('broker', [
]);
Route::group('search', [
'search' => ['search/Search/search', ['method' => 'get|post']],
]);
//Route::miss('api/index/miss');//处理错误的url
\ No newline at end of file
<?php
namespace app\search\consts;
/**
* Created by PhpStorm.
* User : zw
* Date : 2019/1/9
* Time : 13:27
* Intro:
*/
class ConfigConst
{
const ACCESS_KEY_ID = "LTAIEeZUju3PFZlJ";
const SECRET = "ljKCItiUp19F7wtzfn225WoBH0Qe8Y";
const END_POINT = "http://opensearch-cn-shanghai.aliyuncs.com";//公网=>本地
//const END_POINT = "http://intranet.opensearch-cn-shanghai.aliyuncs.com";//内网==>线上
}
\ No newline at end of file
<?php
namespace app\search\controller;
use app\search\extend\Basic;
use app\search\service\SearchService;
use think\Request;
/**
* Created by PhpStorm.
* User: zw
* Date: 2019/4/10
* Time: 14:26
*/
class Search extends Basic {
private $service_;
public function __construct(Request $request = null)
{
parent::__construct($request);
$this->service_ = new SearchService();
}
public function search(){
$this->service_ ->search();
}
}
\ No newline at end of file
<?php
namespace app\search\extend;
use think\Cache;
use think\Controller;
use think\Request;
use think\Response;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/8
* Time : 16:54
* Intro:
*/
class Basic extends Controller
{
/**
* 访问请求对象
* @var Request
*/
public $request;
/**
* 请求参数
* @var mixed|null
*/
public $params;
/**
* app通讯接口授权token
* @var
*/
public $accessToken;
/**
* 基础接口SDK
* @param Request|null $request
*/
public function __construct(Request $request = null)
{
// CORS 跨域 Options 检测响应
$this->corsOptionsHandler();
// 输入对象
$this->request = is_null($request) ? Request::instance() : $request;
if (strtoupper($this->request->method()) === "GET") {
$this->params = $this->request->param();
} elseif (strtoupper($this->request->method()) === "POST") {
$this->params = $this->request->param() != null ? $this->request->param() : null;
}
}
/**
* 输出返回数据
* @param string $msg 提示消息内容
* @param string $code 业务状态码
* @param mixed $data 要返回的数据
* @param string $type 返回类型 JSON XML
* @return Response
*/
public function response($code = 'SUCCESS', $msg, $data = [], $type = 'json')
{
$result = [ 'code' => $code, 'msg' => $msg, 'data' => $data, 'type' => strtolower($type) ];
return Response::create($result, $type);
}
/**
* Cors Options 授权处理
*/
public static function corsOptionsHandler()
{
if (request()->isOptions()) {
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Headers:Accept,Referer,Host,Keep-Alive,User-Agent,X-Requested-With,Cache-Control,Content-Type,Cookie,token');
header('Access-Control-Allow-Credentials:true');
header('Access-Control-Allow-Methods:GET,POST,OPTIONS');
header('Access-Control-Max-Age:1728000');
header('Content-Type:text/plain charset=UTF-8');
header('Content-Length: 0', true);
header('status: 204');
header('HTTP/1.0 204 No Content');
exit;
}
}
}
<?php
namespace app\search\service;
use app\search\consts\ConfigConst;
use OpenSearch\Client\OpenSearchClient;
use OpenSearch\Client\SearchClient;
use OpenSearch\Util\SearchParamsBuilder;
/**
* Created by PhpStorm.
* User: zw
* Date: 2019/4/10
* Time: 14:38
*/
require_once EXTEND_PATH . 'OpenSearch/Autoloader/Autoloader.php';
class SearchService
{
private $client;
public function __construct()
{
$options = array('debug' => true);
$this->client = new OpenSearchClient(ConfigConst::ACCESS_KEY_ID, ConfigConst::SECRET, ConfigConst::END_POINT, $options);
}
/**
* @param $params
* @param $page_no
* @param $page_size
* @param $agentId
* @return mixed|string
*/
public function searchByKeyword($params, $page_no, $page_size, $agentId)
{
$start_time = $params["start_time"] . "000";
$end_time = $params["end_time"] . "000";
$searchClient = new SearchClient($this->client);
$condition = new SearchParamsBuilder();
$condition->setStart($page_no);
$condition->setHits($page_size);
$condition->setAppName("tl_estate");
$search_content = !empty($params["search_content"]) ? $params["search_content"] : null;
if ($search_content && $agentId <= 0) {
$condition->setQuery("content:'$search_content'");
} else if ($search_content && $agentId > 0) {
$condition->setQuery("content:'$search_content'");
$condition->setFilter("agent_id = '$agentId'");
} else if (!$search_content && $agentId > 0) {
$condition->setQuery("agent_id:'$agentId'");
}
$condition->addFilter("create_time > '$start_time'", " and create_time < '$end_time'");
$condition->setFormat("json");
$condition->addSort('id', SearchParamsBuilder::SORT_DECREASE);
$condition->setFetchFields(array('id', 'user_id', 'agent_id', 'type', 'content', 'create_time', 'city', 'user_status', 'labels_id'));
$ret = $searchClient->execute($condition->build())->result;
return $ret;
}
}
\ 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