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
dfd27c45
Commit
dfd27c45
authored
Jan 24, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增模块
parent
efab9ff8
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
290 additions
and
5 deletions
+290
-5
FollowUp.php
application/api_broker/controller/FollowUp.php
+27
-0
Index.php
application/api_broker/controller/Index.php
+10
-0
Basic.php
application/api_broker/extend/Basic.php
+231
-0
build.php
build.php
+3
-5
broker.php
public/broker.php
+19
-0
No files found.
application/api_broker/controller/FollowUp.php
0 → 100644
View file @
dfd27c45
<?php
use
app\api_broker\extend\Basic
;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/24
* Time : 14:24
* Intro:
*/
class
FollowUp
extends
Basic
{
public
function
__construct
(
$request
=
null
)
{
parent
::
__construct
(
$request
);
}
/**
* 跟进
*/
public
function
report
(){
$this
->
response
(
"200"
,
"request success"
,[]);
}
}
\ No newline at end of file
application/api_broker/controller/Index.php
0 → 100644
View file @
dfd27c45
<?php
namespace
app\api_broker\controller
;
class
Index
{
public
function
index
()
{
return
'<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p> ThinkPHP V5<br/><span style="font-size:30px">十年磨一剑 - 为API开发设计的高性能框架</span></p><span style="font-size:22px;">[ V5.0 版本由 <a href="http://www.qiniu.com" target="qiniu">七牛云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script><script type="text/javascript" src="http://ad.topthink.com/Public/static/client.js"></script><thinkad id="ad_bd568ce7058a1091"></thinkad>'
;
}
}
application/api_broker/extend/Basic.php
0 → 100644
View file @
dfd27c45
<?php
namespace
app\api_broker\extend
;
/**
* Created by PhpStorm.
* User: zw
* Date: 2018/1/24
* Time: 9:35
* 基类
*/
use
app\model\Users
;
use
think\Controller
;
use
think\Request
;
use
think\Response
;
use
Qiniu
;
class
Basic
extends
Controller
{
/**
* 访问请求对象
* @var Request
*/
public
$request
;
public
$params
;
protected
$authToken
;
/**
* @var int userId
*/
protected
$userId
;
protected
$userNick
;
protected
$phone
;
protected
$timeStamp_
;
protected
$filterVerify
=
array
(
);
/**
* 基础接口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
;
}
/* if (isset($this->params['AuthToken']) && $this->params['AuthToken'] != 'null' && !empty($this->params['AuthToken'])) {
$jwt = new \Firebase\JWT\JWT();
$this->authToken = $this->params['AuthToken'];
$result = $jwt->decode($this->authToken, config('jwt_key'), array( 'HS256' )); //解码token
$this->userId = $result->data->id;
$this->phone = $result->data->phone;
$this->userNick = $result->data->userNick;
$this->timeStamp_ = $result->timeStamp_;
}
$requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1];
//过滤掉不需要验证token的接口
if (!in_array(trim($requestPath), $this->filterVerify)) {
$this->tokenVerify();
}*/
}
/**
* token 验证
*/
public
function
tokenVerify
()
{
if
(
!
isset
(
$this
->
params
[
'AuthToken'
]))
{
echo
json_encode
(
array
(
"code"
=>
"300"
,
"msg"
=>
"AuthToken不能为空!"
,
"data"
=>
[],
"type"
=>
"json"
));
exit
;
}
$this
->
verifyUserInfo
();
$this
->
verifyTime
();
}
public
function
verifyTime
()
{
//authToken有效期为30天
if
((
time
()
-
$this
->
timeStamp_
)
>
2592000
)
{
echo
json_encode
(
array
(
"code"
=>
"300"
,
"msg"
=>
"AuthToken失效,请重新登录!"
,
"data"
=>
[],
"type"
=>
"json"
));
exit
;
}
}
public
function
verifyUserInfo
()
{
$userModel
=
new
Users
();
$userArr
=
$userModel
->
selectUser
(
$this
->
userId
);
if
(
count
(
$userArr
)
>
0
&&
(
$userArr
[
"id"
]
!=
$this
->
userId
||
$userArr
[
"user_phone"
]
!=
$this
->
phone
))
{
echo
json_encode
(
array
(
"code"
=>
"300"
,
"msg"
=>
"用户验证失败,重新登录!"
,
"data"
=>
[],
"type"
=>
"json"
));
exit
;
}
return
true
;
}
/**
* 输出返回数据
* @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
);
}
/**
* 一维数据数组生成数据树
* @param array $list 数据列表
* @param string $id 父ID Key
* @param string $pid ID Key
* @param string $son 定义子数据Key
* @return array
*/
public
static
function
arr2tree
(
$list
,
$id
=
'id'
,
$pid
=
'pid'
,
$son
=
'sub'
)
{
list
(
$tree
,
$map
)
=
[
[],
[]
];
foreach
(
$list
as
$item
)
{
$map
[
$item
[
$id
]]
=
$item
;
}
foreach
(
$list
as
$item
)
{
if
(
isset
(
$item
[
$pid
])
&&
isset
(
$map
[
$item
[
$pid
]]))
{
$map
[
$item
[
$pid
]][
$son
][]
=
&
$map
[
$item
[
$id
]];
}
else
{
$tree
[]
=
&
$map
[
$item
[
$id
]];
}
}
unset
(
$map
);
return
$tree
;
}
/**
* 一维数据数组生成数据树
* @param array $list 数据列表
* @param string $id ID Key
* @param string $pid 父ID Key
* @param string $path
* @param string $ppath
* @return array
*/
public
static
function
arr2table
(
array
$list
,
$id
=
'id'
,
$pid
=
'pid'
,
$path
=
'path'
,
$ppath
=
''
)
{
$tree
=
[];
foreach
(
self
::
arr2tree
(
$list
,
$id
,
$pid
)
as
$attr
)
{
$attr
[
$path
]
=
"
{
$ppath
}
-
{
$attr
[
$id
]
}
"
;
$attr
[
'sub'
]
=
isset
(
$attr
[
'sub'
])
?
$attr
[
'sub'
]
:
[];
$attr
[
'spl'
]
=
str_repeat
(
" ├ "
,
substr_count
(
$ppath
,
'-'
));
$sub
=
$attr
[
'sub'
];
unset
(
$attr
[
'sub'
]);
$tree
[]
=
$attr
;
if
(
!
empty
(
$sub
))
{
$tree
=
array_merge
(
$tree
,
(
array
)
self
::
arr2table
(
$sub
,
$id
,
$pid
,
$path
,
$attr
[
$path
]));
}
}
return
$tree
;
}
/**
* 获取数据树子ID
* @param array $list 数据列表
* @param int $id 起始ID
* @param string $key 子Key
* @param string $pkey 父Key
* @return array
*/
public
static
function
getArrSubIds
(
$list
,
$id
=
0
,
$key
=
'id'
,
$pkey
=
'pid'
)
{
$ids
=
[
intval
(
$id
)
];
foreach
(
$list
as
$vo
)
{
if
(
intval
(
$vo
[
$pkey
])
>
0
&&
intval
(
$vo
[
$pkey
])
===
intval
(
$id
))
{
$ids
=
array_merge
(
$ids
,
self
::
getArrSubIds
(
$list
,
intval
(
$vo
[
$key
]),
$key
,
$pkey
));
}
}
return
$ids
;
}
/**
* 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
;
}
}
/**
* Cors Request Header信息
* @return array
*/
public
static
function
corsRequestHander
()
{
return
[
'Access-Control-Allow-Origin'
=>
'*'
,
'Access-Control-Allow-Credentials'
=>
true
,
'Access-Control-Allow-Methods'
=>
'GET,POST,OPTIONS'
,
'Access-Defined-X-Support'
=>
'service@cuci.cc'
,
'Access-Defined-X-Servers'
=>
'Guangzhou Cuci Technology Co. Ltd'
,
];
}
}
build.php
View file @
dfd27c45
...
@@ -22,11 +22,9 @@ return [
...
@@ -22,11 +22,9 @@ return [
'view' => ['index/index'],
'view' => ['index/index'],
],*/
],*/
// 其他更多的模块定义
// 其他更多的模块定义
'ap
p
'
=>
[
'ap
i-broker
'
=>
[
'__file__'
=>
[
'common.php'
],
'__file__'
=>
[
'common.php'
],
'__dir__'
=>
[
'behavior'
,
'controller'
,
'model'
,
'view'
],
'__dir__'
=>
[
'behavior'
,
'controller'
,
'service'
,
'utils'
],
'controller'
=>
[
'Index'
,
'Test'
,
'UserType'
],
'controller'
=>
[
'Index'
],
'model'
=>
[
'User'
,
'UserType'
],
'view'
=>
[
'index/index'
],
],
],
];
];
public/broker.php
0 → 100644
View file @
dfd27c45
<?php
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/24
* Time : 14:13
* Intro:
*/
// [ 应用入口文件 ]
// 定义应用目录
define
(
'APP_PATH'
,
__DIR__
.
'/../application/'
);
// 加载框架引导文件
require
__DIR__
.
'/../thinkphp/start.php'
;
// 读取自动生成定义文件
$build
=
include
'./../build.php'
;
// 运行自动生成
\think\Build
::
run
(
$build
);
\ 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