Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
数据应用
ThinkLibrary
提交
fe11b7ad
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 搜索 >>
提交
fe11b7ad
编写于
5月 07, 2020
作者:
李光春
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- add notice
上级
e1182174
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
280 addition
and
1 deletion
+280
-1
src/exception/NoticeException.php
src/exception/NoticeException.php
+32
-0
src/service/curl/HttpService.php
src/service/curl/HttpService.php
+1
-1
src/service/notice/BeAryChatService.php
src/service/notice/BeAryChatService.php
+22
-0
src/service/notice/DingDingService.php
src/service/notice/DingDingService.php
+82
-0
src/service/notice/QyWeiXinService.php
src/service/notice/QyWeiXinService.php
+99
-0
src/service/notice/SendCloudService.php
src/service/notice/SendCloudService.php
+22
-0
src/service/notice/WorkKileService.php
src/service/notice/WorkKileService.php
+22
-0
未找到文件。
src/exception/NoticeException.php
0 → 100644
浏览文件 @
fe11b7ad
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 :https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 :https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace
DtApp\ThinkLibrary\exception
;
use
Exception
;
/**
* 通知错误处理
* Class NoticeException
* @package DtApp\ThinkLibrary\exception
*/
class
NoticeException
extends
Exception
{
public
function
errorMessage
()
{
return
$this
->
getMessage
();
}
}
src/service/curl/HttpService.php
浏览文件 @
fe11b7ad
...
...
@@ -47,7 +47,7 @@ class HttpService extends Service
/**
* 需要请求的数据
* @param
string
$str
* @param $str
* @return $this
*/
public
function
data
(
$str
)
...
...
src/service/notice/BeAryChatService.php
0 → 100644
浏览文件 @
fe11b7ad
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 :https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 :https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace
DtApp\ThinkLibrary\service\notice
;
class
BeAryChatService
{
}
src/service/notice/DingDingService.php
0 → 100644
浏览文件 @
fe11b7ad
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 :https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 :https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace
DtApp\ThinkLibrary\service\notice
;
use
DtApp\ThinkLibrary\exception\CurlException
;
use
DtApp\ThinkLibrary\exception\NoticeException
;
use
DtApp\ThinkLibrary\service\curl\HttpService
;
/**
* 通知 - 钉钉
* Class DingDingService
* @package DtApp\ThinkLibrary\service\notice
*/
class
DingDingService
{
/**
* 消息类型
* @var string
*/
private
$msgType
=
'text'
;
private
$access_token
;
/**
* 配置access_token
* @param $str
* @return $this
*/
public
function
accessToken
(
$str
)
{
$this
->
access_token
=
$str
;
return
$this
;
}
/**
* 发送文本消息
* @param string $content 消息内容
* @return bool 发送结果
* @throws NoticeException|CurlException
*/
public
function
text
(
string
$content
)
{
$this
->
msgType
=
'text'
;
return
$this
->
sendMsg
([
'text'
=>
[
'content'
=>
$content
,
],
]);
}
/**
* 组装发送消息
* @param array $data 消息内容数组
* @return bool 发送结果
* @throws NoticeException|CurlException
*/
private
function
sendMsg
(
array
$data
)
{
if
(
empty
(
$this
->
access_token
))
throw
new
NoticeException
(
"请检查access_token"
);
if
(
empty
(
$data
[
'msgtype'
]))
$data
[
'msgtype'
]
=
$this
->
msgType
;
$result
=
HttpService
::
instance
()
->
url
(
"https://oapi.dingtalk.com/robot/send?access_token="
.
$this
->
access_token
)
->
data
(
$data
)
->
toArray
();
if
(
$result
[
'errcode'
]
==
0
)
return
true
;
return
false
;
}
}
src/service/notice/QyWeiXinService.php
0 → 100644
浏览文件 @
fe11b7ad
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 :https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 :https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace
DtApp\ThinkLibrary\service\notice
;
use
DtApp\ThinkLibrary\exception\CurlException
;
use
DtApp\ThinkLibrary\exception\NoticeException
;
use
DtApp\ThinkLibrary\service\curl\HttpService
;
/**
* 通知 - 企业微信
* Class QyWeiXinService
* @package DtApp\ThinkLibrary\service\notice
*/
class
QyWeiXinService
{
/**
* 消息类型
* @var string
*/
private
$msgType
=
'text'
;
private
$key
;
/**
* 配置Key
* @param $str
* @return $this
*/
public
function
key
(
$str
)
{
$this
->
key
=
$str
;
return
$this
;
}
/**
* 发送文本消息
* @param string $content 消息内容
* @return bool
* @throws CurlException
* @throws NoticeException
*/
public
function
text
(
string
$content
=
''
)
{
$this
->
msgType
=
'text'
;
return
$this
->
sendMsg
([
'text'
=>
[
'content'
=>
$content
,
],
]);
}
/**
* 发送markdown消息
* @param string $content 消息内容
* @return bool
* @throws CurlException
* @throws NoticeException
*/
public
function
markdown
(
string
$content
=
''
)
{
$this
->
msgType
=
'markdown'
;
return
$this
->
sendMsg
([
'markdown'
=>
[
'content'
=>
$content
,
],
]);
}
/**
* 组装发送消息
* @param array $data 消息内容数组
* @return bool
* @throws NoticeException|CurlException
*/
private
function
sendMsg
(
array
$data
)
{
if
(
empty
(
$this
->
key
))
throw
new
NoticeException
(
"请检查KEY"
);
if
(
empty
(
$data
[
'msgtype'
]))
$data
[
'msgtype'
]
=
$this
->
msgType
;
$result
=
HttpService
::
instance
()
->
url
(
"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key="
.
$this
->
key
)
->
data
(
$data
)
->
toArray
();
if
(
$result
[
'errcode'
]
==
0
)
return
true
;
return
false
;
}
}
src/service/notice/SendCloudService.php
0 → 100644
浏览文件 @
fe11b7ad
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 :https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 :https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace
DtApp\ThinkLibrary\service\notice
;
class
SendCloudService
{
}
src/service/notice/WorkKileService.php
0 → 100644
浏览文件 @
fe11b7ad
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 :https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 :https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace
DtApp\ThinkLibrary\service\notice
;
class
WorkKileService
{
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录