Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
数据应用
ThinkLibrary
提交
32f4f331
T
ThinkLibrary
项目概览
数据应用
/
ThinkLibrary
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
代码片段
项目成员
Pages
T
ThinkLibrary
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
32f4f331
编写于
11月 26, 2020
作者:
李光春
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- 优化服务
上级
0ec70f1f
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
88 addition
and
200 deletion
+88
-200
CHANGELOG.md
CHANGELOG.md
+3
-0
src/common.php
src/common.php
+1
-1
src/service/aliyun/OssService.php
src/service/aliyun/OssService.php
+5
-23
src/service/amap/AmApService.php
src/service/amap/AmApService.php
+39
-19
src/service/baidu/BosService.php
src/service/baidu/BosService.php
+5
-26
src/service/baidu/LbsYunService.php
src/service/baidu/LbsYunService.php
+0
-16
src/service/huaweicloud/ObsService.php
src/service/huaweicloud/ObsService.php
+5
-25
src/service/ksyun/Ks3Service.php
src/service/ksyun/Ks3Service.php
+15
-24
src/service/qiniu/KodoService.php
src/service/qiniu/KodoService.php
+6
-21
src/service/tencent/CosService.php
src/service/tencent/CosService.php
+6
-25
src/service/upyun/UssService.php
src/service/upyun/UssService.php
+3
-20
未找到文件。
CHANGELOG.md
浏览文件 @
32f4f331
## v6.0.127 / 2020-11-26
-
优化服务
## v6.0.127 / 2020-11-25
-
修复腾讯云存储
-
数组门面增加方法
...
...
src/common.php
浏览文件 @
32f4f331
...
...
@@ -25,7 +25,7 @@ use DtApp\ThinkLibrary\service\SystemService;
/**
* 定义当前版本
*/
const
VERSION
=
'6.0.12
7
'
;
const
VERSION
=
'6.0.12
8
'
;
if
(
!
function_exists
(
'get_ip_info'
))
{
/**
...
...
src/service/aliyun/OssService.php
浏览文件 @
32f4f331
...
...
@@ -77,33 +77,15 @@ class OssService extends Service
}
/**
* 获取配置信息
* @return $this
*/
private
function
getConfig
():
self
{
$this
->
accessKeyId
=
config
(
'dtapp.aliyun.oss.access_key_id'
);
$this
->
accessKeySecret
=
config
(
'dtapp.aliyun.oss.access_key_secret'
);
$this
->
endpoint
=
config
(
'dtapp.aliyun.oss.endpoint'
);
$this
->
bucket
=
config
(
'dtapp.aliyun.oss.bucket'
);
return
$this
;
}
/**
* 上传文件
* @param $object
* @param $filePath
* @return bool|string
* @param string $object
* @param string $filePath
* @return string|null
*/
public
function
upload
(
string
$object
,
string
$filePath
)
public
function
upload
(
string
$object
,
string
$filePath
)
:
?string
{
if
(
empty
(
$this
->
accessKeySecret
)
||
empty
(
$this
->
accessKeySecret
)
||
empty
(
$this
->
endpoint
)
||
empty
(
$this
->
bucket
))
{
$this
->
getConfig
();
}
try
{
$ossClient
=
new
OssClient
(
$this
->
accessKeyId
,
$this
->
accessKeySecret
,
$this
->
endpoint
);
$ossClient
->
uploadFile
(
$this
->
bucket
,
$object
,
$filePath
);
return
config
(
'dtapp.aliyun.oss.url'
,
''
)
.
$object
;
return
$ossClient
->
uploadFile
(
$this
->
bucket
,
$object
,
$filePath
);
}
catch
(
OssException
$e
)
{
return
$e
->
getMessage
();
}
...
...
src/service/amap/AmApService.php
浏览文件 @
32f4f331
...
...
@@ -19,7 +19,6 @@
namespace
DtApp\ThinkLibrary\service\amap
;
use
DtApp\ThinkLibrary\exception\DtaException
;
use
DtApp\ThinkLibrary\Service
;
use
DtApp\ThinkLibrary\service\curl\HttpService
;
...
...
@@ -50,38 +49,21 @@ class AmApService extends Service
* @param string $key
* @return $this
*/
public
function
key
(
string
$key
)
public
function
key
(
string
$key
)
:
self
{
$this
->
key
=
$key
;
return
$this
;
}
/**
* 获取配置信息
* @return $this
*/
private
function
getConfig
():
self
{
$this
->
key
=
config
(
'dtapp.amap.key'
);
return
$this
;
}
/**
* 天气查询
* https://lbs.amap.com/api/webservice/guide/api/weatherinfo
* @param string $city
* @param string $extensions
* @return array|bool|mixed|string
* @throws DtaException
*/
public
function
weather
(
$city
=
"110101"
,
$extensions
=
"base"
)
{
if
(
empty
(
$this
->
key
))
{
$this
->
getConfig
();
}
if
(
empty
(
$this
->
key
))
{
throw
new
DtaException
(
'请检查key参数'
);
}
$data
=
http_build_query
([
"city"
=>
$city
,
"extensions"
=>
$extensions
,
...
...
@@ -92,4 +74,42 @@ class AmApService extends Service
->
url
(
"
{
$this
->
url
}
weather/weatherInfo?
{
$data
}
"
)
->
toArray
();
}
/**
* 地理编码
* https://lbs.amap.com/api/webservice/guide/api/georegeo#geo
* @param $address
* @param string $city
* @return array|bool|mixed|string
*/
public
function
gCoderGeo
(
$address
,
$city
=
''
)
{
$data
=
http_build_query
([
"city"
=>
$city
,
"address"
=>
$address
,
"key"
=>
$this
->
key
,
"output"
=>
$this
->
output
,
]);
return
HttpService
::
instance
()
->
url
(
"
{
$this
->
url
}
geocode/geo?
{
$data
}
"
)
->
toArray
();
}
/**
* 逆地理编码
* https://lbs.amap.com/api/webservice/guide/api/georegeo#regeo
* @param $location
* @return array|bool|mixed|string
*/
public
function
gCoderReGeo
(
$location
)
{
$data
=
http_build_query
([
"location"
=>
$location
,
"key"
=>
$this
->
key
,
"output"
=>
$this
->
output
,
]);
return
HttpService
::
instance
()
->
url
(
"
{
$this
->
url
}
geocode/regeo?
{
$data
}
"
)
->
toArray
();
}
}
src/service/baidu/BosService.php
浏览文件 @
32f4f331
...
...
@@ -77,30 +77,13 @@ class BosService extends Service
}
/**
* 获取配置信息
* @return $this
*/
private
function
getConfig
():
self
{
$this
->
accessKeyId
=
config
(
'dtapp.baidu.bos.access_key_id'
);
$this
->
secretAccessKey
=
config
(
'dtapp.baidu.bos.secret_access_key'
);
$this
->
endpoint
=
config
(
'dtapp.baidu.bos.endpoint'
);
$this
->
bucket
=
config
(
'dtapp.baidu.bos.bucket'
);
return
$this
;
}
/**
* 上传文件
* @param $object
* @param $filePath
* @return bool
* @param string $object
* @param string $filePath
* @return mixed
* @throws Exception
*/
public
function
upload
(
string
$object
,
string
$filePath
)
:
bool
public
function
upload
(
string
$object
,
string
$filePath
)
{
if
(
empty
(
$this
->
accessKeyId
)
||
empty
(
$this
->
secretAccessKey
)
||
empty
(
$this
->
endpoint
))
{
$this
->
getConfig
();
}
// 设置BosClient的Access Key ID、Secret Access Key和ENDPOINT
$BOS_TEST_CONFIG
=
array
(
'credentials'
=>
array
(
...
...
@@ -111,10 +94,6 @@ class BosService extends Service
);
$client
=
new
BosClient
(
$BOS_TEST_CONFIG
);
// 从文件中直接上传Object
if
(
empty
(
$this
->
bucket
))
{
$this
->
getConfig
();
}
$client
->
putObjectFromFile
(
$this
->
bucket
,
$object
,
$filePath
);
return
config
(
'dtapp.baidu.bos.url'
,
''
)
.
$object
;
return
$client
->
putObjectFromFile
(
$this
->
bucket
,
$object
,
$filePath
);
}
}
src/service/baidu/LbsYunService.php
浏览文件 @
32f4f331
...
...
@@ -51,16 +51,6 @@ class LbsYunService extends Service
return
$this
;
}
/**
* 获取配置信息
* @return $this
*/
private
function
getConfig
():
self
{
$this
->
ak
=
config
(
'dtapp.baidu.lbs.ak'
);
return
$this
;
}
/**
* 国内天气查询
* http://lbsyun.baidu.com/index.php?title=webapi/weather
...
...
@@ -72,9 +62,6 @@ class LbsYunService extends Service
*/
public
function
weather
(
$district_id
=
110100
,
string
$coordtype
=
"bd09ll"
,
string
$location
=
""
)
{
if
(
empty
(
$this
->
ak
))
{
$this
->
getConfig
();
}
if
(
empty
(
$this
->
ak
))
{
throw
new
DtaException
(
'请检查ak参数'
);
}
...
...
@@ -103,9 +90,6 @@ class LbsYunService extends Service
*/
public
function
weatherAbroad
(
$district_id
=
110100
,
string
$coordtype
=
"bd09ll"
,
string
$location
=
""
,
string
$language
=
"cn"
)
{
if
(
empty
(
$this
->
ak
))
{
$this
->
getConfig
();
}
if
(
empty
(
$this
->
ak
))
{
throw
new
DtaException
(
'请检查ak参数'
);
}
...
...
src/service/huaweicloud/ObsService.php
浏览文件 @
32f4f331
...
...
@@ -76,45 +76,25 @@ class ObsService extends Service
}
/**
* 获取配置信息
* @return $this
* @param string $object
* @param string $filePath
* @return bool|\Obs\Internal\Common\Model
*/
p
rivate
function
getConfig
():
self
p
ublic
function
upload
(
string
$object
,
string
$filePath
)
{
$this
->
key
=
config
(
'dtapp.huaweicloud.obs.key'
);
$this
->
secret
=
config
(
'dtapp.huaweicloud.obs.secret'
);
$this
->
endpoint
=
config
(
'dtapp.huaweicloud.obs.endpoint'
);
$this
->
bucket
=
config
(
'dtapp.huaweicloud.obs.bucket'
);
return
$this
;
}
/**
* 上传到华为云
* @param $object
* @param $filePath
* @return bool
*/
public
function
upload
(
string
$object
,
string
$filePath
):
bool
{
if
(
empty
(
$this
->
key
)
||
empty
(
$this
->
secret
)
||
empty
(
$this
->
endpoint
))
{
$this
->
getConfig
();
}
// 创建ObsClient实例
$obsClient
=
new
ObsClient
([
'key'
=>
$this
->
key
,
'secret'
=>
$this
->
secret
,
'endpoint'
=>
$this
->
endpoint
]);
if
(
empty
(
$this
->
bucket
))
{
$this
->
getConfig
();
}
$resp
=
$obsClient
->
putObject
([
'Bucket'
=>
$this
->
bucket
,
'Key'
=>
$object
,
'SourceFile'
=>
$filePath
// localfile为待上传的本地文件路径,需要指定到具体的文件名
]);
if
(
isset
(
$resp
[
'RequestId'
]))
{
return
config
(
'dtapp.huaweicloud.obs.url'
,
''
)
.
$object
;
return
$resp
;
}
return
false
;
...
...
src/service/ksyun/Ks3Service.php
浏览文件 @
32f4f331
...
...
@@ -77,34 +77,26 @@ class Ks3Service extends Service
}
/**
* 获取配置信息
* @return $this
*/
private
function
getConfig
():
self
{
$this
->
accessKeyID
=
config
(
'dtapp.ksyun.ks3.access_key_iD'
);
$this
->
accessKeySecret
=
config
(
'dtapp.ksyun.ks3.access_key_secret'
);
$this
->
endpoint
=
config
(
'dtapp.ksyun.ks3.endpoint'
);
$this
->
bucket
=
config
(
'dtapp.ksyun.ks3.bucket'
);
return
$this
;
}
/**
* 上传文件
* @param string $object
* @param string $filePath
* @return bool
|string
* @return bool
*/
public
function
upload
(
string
$object
,
string
$filePath
)
public
function
upload
(
string
$object
,
string
$filePath
)
:
?bool
{
if
(
empty
(
$this
->
accessKeyID
)
||
empty
(
$this
->
accessKeySecret
)
||
empty
(
$this
->
endpoint
))
{
$this
->
getConfig
();
}
//是否使用VHOST
define
(
"KS3_API_VHOST"
,
FALSE
);
//是否开启日志(写入日志文件)
define
(
"KS3_API_LOG"
,
FALSE
);
//是否显示日志(直接输出日志)
define
(
"KS3_API_DISPLAY_LOG"
,
FALSE
);
//定义日志目录(默认是该项目log下)
define
(
"KS3_API_LOG_PATH"
,
""
);
//是否使用HTTPS
define
(
"KS3_API_USE_HTTPS"
,
FALSE
);
//是否开启curl debug模式
define
(
"KS3_API_DEBUG_MODE"
,
FALSE
);
require_once
(
__DIR__
.
"/bin/Ks3Client.class.php"
);
$client
=
new
Ks3Client
(
$this
->
accessKeyID
,
$this
->
accessKeySecret
,
$this
->
endpoint
);
if
(
empty
(
$this
->
bucket
))
{
$this
->
getConfig
();
}
$content
=
fopen
(
$filePath
,
'rb'
);
$args
=
[
"Bucket"
=>
$this
->
bucket
,
...
...
@@ -126,8 +118,7 @@ class Ks3Service extends Service
]
];
try
{
$client
->
putObjectByFile
(
$args
);
return
config
(
'dtapp.ksyun.ks3.url'
,
''
)
.
$object
;
return
$client
->
putObjectByFile
(
$args
);
}
catch
(
Ks3ServiceException
$e
)
{
return
false
;
}
...
...
src/service/qiniu/KodoService.php
浏览文件 @
32f4f331
...
...
@@ -68,29 +68,13 @@ class KodoService extends Service
}
/**
* 获取配置信息
* @return $this
*/
private
function
getConfig
():
self
{
$this
->
accessKey
=
config
(
'dtapp.qiniu.kodo.access_key'
);
$this
->
secretKey
=
config
(
'dtapp.qiniu.kodo.secret_key'
);
$this
->
bucket
=
config
(
'dtapp.qiniu.kodo.bucket'
);
return
$this
;
}
/**
* 上传文件
* @param $object
* @param $filePath
* @return bool
* @param string $object
* @param string $filePath
* @return bool|mixed
* @throws Exception
*/
public
function
upload
(
string
$object
,
string
$filePath
)
:
bool
public
function
upload
(
string
$object
,
string
$filePath
)
{
if
(
empty
(
$this
->
accessKey
)
||
empty
(
$this
->
secretKey
)
||
empty
(
$this
->
bucket
))
{
$this
->
getConfig
();
}
// 初始化签权对象
$auth
=
new
Auth
(
$this
->
accessKey
,
$this
->
secretKey
);
// 生成上传Token
...
...
@@ -103,6 +87,7 @@ class KodoService extends Service
return
false
;
}
return
config
(
'dtapp.qiniu.kodo.url'
,
''
)
.
$object
;
return
$ret
;
}
}
src/service/tencent/CosService.php
浏览文件 @
32f4f331
...
...
@@ -20,7 +20,6 @@
namespace
DtApp\ThinkLibrary\service\tencent
;
use
DtApp\ThinkLibrary\Service
;
use
Exception
;
use
Qcloud\Cos\Client
;
/**
...
...
@@ -77,30 +76,12 @@ class CosService extends Service
}
/**
* 获取配置信息
* @return $this
*/
private
function
getConfig
():
self
{
$this
->
secretId
=
config
(
'dtapp.tencent.cos.secret_id'
);
$this
->
secretKey
=
config
(
'dtapp.tencent.cos.secret_key'
);
$this
->
region
=
config
(
'dtapp.tencent.cos.region'
);
$this
->
bucket
=
config
(
'dtapp.tencent.cos.bucket'
);
return
$this
;
}
/**
* 上传文件
* @param $object
* @param $filePath
* @param string $object
* @param string $filePath
* @return bool
* @throws Exception
*/
public
function
upload
(
string
$object
,
string
$filePath
):
bool
{
if
(
empty
(
$this
->
secretId
)
||
empty
(
$this
->
secretKey
)
||
empty
(
$this
->
region
))
{
$this
->
getConfig
();
}
$cosClient
=
new
Client
([
'region'
=>
$this
->
region
,
'schema'
=>
'https'
,
...
...
@@ -111,14 +92,14 @@ class CosService extends Service
]);
$key
=
$object
;
$file
=
fopen
(
$filePath
,
"rb"
);
if
(
$file
&&
empty
(
$this
->
bucket
))
{
$this
->
getConfig
();
$result
=
$cosClient
->
putObject
([
if
(
$file
)
{
return
$cosClient
->
putObject
([
'Bucket'
=>
$this
->
bucket
,
'Key'
=>
$key
,
'Body'
=>
$file
]);
}
return
config
(
'dtapp.tencent.cos.url'
,
''
)
.
$object
;
return
false
;
}
}
src/service/upyun/UssService.php
浏览文件 @
32f4f331
...
...
@@ -68,33 +68,16 @@ class UssService extends Service
}
/**
* 获取配置信息
* @return $this
*/
private
function
getConfig
():
self
{
$this
->
serviceName
=
config
(
'dtapp.upyun.uss.service_name'
);
$this
->
operatorName
=
config
(
'dtapp.upyun.uss.operator_name'
);
$this
->
operatorPassword
=
config
(
'dtapp.upyun.uss.operator_password'
);
return
$this
;
}
/**
* 上传文件
* @param string $object
* @param string $filePath
* @return bool
* @return
array|
bool
* @throws Exception
*/
public
function
upload
(
string
$object
,
string
$filePath
)
:
bool
public
function
upload
(
string
$object
,
string
$filePath
)
{
if
(
empty
(
$this
->
serviceName
)
||
empty
(
$this
->
operatorName
)
||
empty
(
$this
->
operatorPassword
))
{
$this
->
getConfig
();
}
$serviceConfig
=
new
Config
(
$this
->
serviceName
,
$this
->
operatorName
,
$this
->
operatorPassword
);
$client
=
new
Upyun
(
$serviceConfig
);
$file
=
fopen
(
$filePath
,
'r'
);
$client
->
write
(
$object
,
$file
);
return
config
(
'dtapp.upyun.uss.url'
,
''
)
.
$object
;
return
$client
->
write
(
$object
,
$file
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录