Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
5c8bf6e9
Commit
5c8bf6e9
authored
Aug 07, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
默认城市
parent
4a7eb351
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
103 additions
and
3 deletions
+103
-3
Location.php
application/api_broker/controller/Location.php
+48
-0
Basic.php
application/api_broker/extend/Basic.php
+20
-3
LocationValidate.php
application/api_broker/validate/LocationValidate.php
+31
-0
route.php
application/route.php
+4
-0
No files found.
application/api_broker/controller/Location.php
0 → 100644
View file @
5c8bf6e9
<?php
namespace
app\api_broker\controller
;
use
app\api_broker\extend\Basic
;
use
app\extra\RedisExt
;
use
think\Request
;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/8/7
* Time : 11:31
* Intro:
*/
class
Location
extends
Basic
{
private
$redis_
;
const
CITY_AGENTS
=
"agent_city_"
;
public
function
__construct
(
$request
=
null
)
{
parent
::
__construct
(
$request
);
$this
->
redis_
=
RedisExt
::
getRedis
();
}
public
function
saveSiteCity
()
{
$params
=
$this
->
params
;
/* $params = array(
"agent_id" => 1,
"city" => "上海"
);*/
$checkResult
=
$this
->
validate
(
$params
,
"LocationValidate.saveSiteCityVerify"
);
if
(
true
!==
$checkResult
)
{
return
$this
->
response
(
"101"
,
$checkResult
);
}
$city
=
"上海"
;
$agent_id
=
$params
[
"agent_id"
];
if
(
$params
[
"city"
]
==
"杭州"
)
{
$city
=
"杭州"
;
}
$this
->
redis_
->
set
(
self
::
CITY_AGENTS
.
$agent_id
,
$city
);
}
}
\ No newline at end of file
application/api_broker/extend/Basic.php
View file @
5c8bf6e9
...
...
@@ -9,6 +9,7 @@ namespace app\api_broker\extend;
* Time: 9:35
* 基类
*/
use
app\extra\RedisExt
;
use
app\model\AAgents
;
use
app\model\GOperatingRecords
;
use
UnexpectedValueException
;
...
...
@@ -25,9 +26,8 @@ class Basic extends Controller
* @var Request
*/
public
$request
;
public
$params
;
public
$city
;
protected
$authToken
;
/**
...
...
@@ -65,6 +65,7 @@ class Basic extends Controller
*/
public
function
__construct
(
Request
$request
=
null
)
{
// CORS 跨域 Options 检测响应
$this
->
corsOptionsHandler
();
// 输入对象
...
...
@@ -76,7 +77,6 @@ class Basic extends Controller
$this
->
params
=
$this
->
request
->
param
()
!=
null
?
$this
->
request
->
param
()
:
null
;
}
if
(
isset
(
$this
->
params
[
'AuthToken'
])
&&
$this
->
params
[
'AuthToken'
]
!=
'null'
&&
!
empty
(
$this
->
params
[
'AuthToken'
]))
{
$jwt
=
new
\Firebase\JWT\JWT
();
...
...
@@ -96,6 +96,9 @@ class Basic extends Controller
$this
->
agentName
=
isset
(
$result
->
data
->
name
)
?
$result
->
data
->
name
:
""
;
$this
->
timeStamp_
=
$result
->
timeStamp_
;
}
//获取默认城市
$this
->
getCity
(
$this
->
agentId
);
$requestPath
=
$this
->
request
->
routeInfo
()[
"rule"
][
0
]
.
"/"
.
$this
->
request
->
routeInfo
()[
"rule"
][
1
];
//过滤掉不需要验证token的接口
if
(
!
in_array
(
trim
(
$requestPath
),
$this
->
filterVerify
))
{
...
...
@@ -105,6 +108,20 @@ class Basic extends Controller
unset
(
$this
->
params
[
"AuthToken"
]);
}
/**
* 默认城市选择
* @param $agentId
*/
public
function
getCity
(
$agentId
){
$redis_
=
RedisExt
::
getRedis
();
if
(
$redis_
){
$this
->
city
=
$redis_
->
get
(
"agent_city_"
.
$agentId
);
}
else
{
$this
->
city
=
"上海"
;
}
}
/**
* token 验证
*/
...
...
application/api_broker/validate/LocationValidate.php
0 → 100644
View file @
5c8bf6e9
<?php
namespace
app\api_broker\validate
;
use
think\Validate
;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/8/7
* Time : 13:17
* Intro:
*/
class
LocationValidate
extends
Validate
{
protected
$rule
=
[
'city'
=>
'require'
,
'agent_id'
=>
'require|number'
,
];
protected
$message
=
[
'city.require'
=>
'city为必填字段'
,
'agent_id.require'
=>
'经纪人id为必填字段'
,
'agent_id.number'
=>
'经纪人id只能为数字'
,
];
protected
$scene
=
[
'saveSiteCityVerify'
=>
[
'city'
,
'agent_id'
],
];
}
\ No newline at end of file
application/route.php
View file @
5c8bf6e9
...
...
@@ -536,6 +536,9 @@ Route::group('broker', [
'getCollectHouseList'
=>
[
'api_broker/CollectHouse/getCollectHouseList'
,
[
'method'
=>
'POST|GET'
]
],
//查询收藏数据 朱伟 2018-07-04
'saveSiteCity'
=>
[
'api_broker/Location/saveSiteCity'
,
[
'method'
=>
'POST|GET'
]
],
//保存默认城市选择
]);
//Route::miss('api/index/miss');//处理错误的url
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment