变更命名空间
This commit is contained in:
parent
868b98e0b5
commit
cb25278417
|
@ -22,7 +22,7 @@ composer require ykxiao/easy-message -vvv
|
||||||
发布配置文件`config/message.php`
|
发布配置文件`config/message.php`
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
hyperf vendor:publish ykxiao/easy-message
|
php bin/hyperf.php vendor:publish ykxiao/easy-message
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,27 +2,27 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use MessageNotify\Channel\DingTalkChannel;
|
use EasyMessage\Channel\DingTalkChannel;
|
||||||
use MessageNotify\Channel\FeiShuChannel;
|
use EasyMessage\Channel\FeiShuChannel;
|
||||||
use MessageNotify\Channel\MailChannel;
|
use EasyMessage\Channel\MailChannel;
|
||||||
use MessageNotify\Channel\WechatChannel;
|
use EasyMessage\Channel\WechatChannel;
|
||||||
use MessageNotify\Contracts\MessageNotifyInterface;
|
use EasyMessage\Contracts\EasyMessageInterface;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'default' => env('NOTIFY_DEFAULT_CHANNEL', 'mail'),
|
'default' => env('NOTIFY_DEFAULT_CHANNEL', 'mail'),
|
||||||
'channels' => [
|
'channels' => [
|
||||||
// 钉钉群机器人
|
// 钉钉群机器人
|
||||||
DingTalkChannel::class => [
|
DingTalkChannel::class => [
|
||||||
'default' => MessageNotifyInterface::INFO,
|
'default' => EasyMessageInterface::INFO,
|
||||||
'pipeline' => [
|
'pipeline' => [
|
||||||
// 业务信息告警群
|
// 业务信息告警群
|
||||||
MessageNotifyInterface::INFO => [
|
EasyMessageInterface::INFO => [
|
||||||
'token' => env('NOTIFY_DINGTALK_TOKEN', ''),
|
'token' => env('NOTIFY_DINGTALK_TOKEN', ''),
|
||||||
'secret' => env('NOTIFY_DINGTALK_SECRET', ''),
|
'secret' => env('NOTIFY_DINGTALK_SECRET', ''),
|
||||||
'keyword' => env('NOTIFY_DINGTALK_KEYWORD', []),
|
'keyword' => env('NOTIFY_DINGTALK_KEYWORD', []),
|
||||||
],
|
],
|
||||||
// 错误信息告警群
|
// 错误信息告警群
|
||||||
MessageNotifyInterface::ERROR => [
|
EasyMessageInterface::ERROR => [
|
||||||
'token' => env('NOTIFY_DINGTALK_TOKEN', ''),
|
'token' => env('NOTIFY_DINGTALK_TOKEN', ''),
|
||||||
'secret' => env('NOTIFY_DINGTALK_SECRET', ''),
|
'secret' => env('NOTIFY_DINGTALK_SECRET', ''),
|
||||||
'keyword' => env('NOTIFY_DINGTALK_KEYWORD', []),
|
'keyword' => env('NOTIFY_DINGTALK_KEYWORD', []),
|
||||||
|
@ -32,7 +32,7 @@ return [
|
||||||
|
|
||||||
// 飞书群机器人
|
// 飞书群机器人
|
||||||
FeiShuChannel::class => [
|
FeiShuChannel::class => [
|
||||||
'default' => MessageNotifyInterface::INFO,
|
'default' => EasyMessageInterface::INFO,
|
||||||
'pipeline' => [
|
'pipeline' => [
|
||||||
'info' => [
|
'info' => [
|
||||||
'token' => env('NOTIFY_FEISHU_TOKEN', ''),
|
'token' => env('NOTIFY_FEISHU_TOKEN', ''),
|
||||||
|
@ -44,7 +44,7 @@ return [
|
||||||
|
|
||||||
// 邮件
|
// 邮件
|
||||||
MailChannel::class => [
|
MailChannel::class => [
|
||||||
'default' => MessageNotifyInterface::INFO,
|
'default' => EasyMessageInterface::INFO,
|
||||||
'pipeline' => [
|
'pipeline' => [
|
||||||
'info' => [
|
'info' => [
|
||||||
'dsn' => env('NOTIFY_MAIL_DSN'),
|
'dsn' => env('NOTIFY_MAIL_DSN'),
|
||||||
|
@ -56,7 +56,7 @@ return [
|
||||||
|
|
||||||
// 企业微信群机器人
|
// 企业微信群机器人
|
||||||
WechatChannel::class => [
|
WechatChannel::class => [
|
||||||
'default' => MessageNotifyInterface::INFO,
|
'default' => EasyMessageInterface::INFO,
|
||||||
'pipeline' => [
|
'pipeline' => [
|
||||||
'info' => [
|
'info' => [
|
||||||
'token' => env('NOTIFY_WECHAT_TOKEN'),
|
'token' => env('NOTIFY_WECHAT_TOKEN'),
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace MessageNotify\Channel;
|
namespace EasyMessage\Channel;
|
||||||
|
|
||||||
use Hyperf\Contract\ConfigInterface;
|
use Hyperf\Contract\ConfigInterface;
|
||||||
use MessageNotify\Exceptions\MessageNotificationException;
|
use EasyMessage\Exceptions\MessageNotificationException;
|
||||||
use MessageNotify\Template\AbstractTemplate;
|
use EasyMessage\Template\AbstractTemplate;
|
||||||
|
|
||||||
abstract class AbstractChannel
|
abstract class AbstractChannel
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace MessageNotify\Channel;
|
namespace EasyMessage\Channel;
|
||||||
|
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use GuzzleHttp\RequestOptions;
|
use GuzzleHttp\RequestOptions;
|
||||||
use MessageNotify\Exceptions\MessageNotificationException;
|
use EasyMessage\Exceptions\MessageNotificationException;
|
||||||
use MessageNotify\Template\AbstractTemplate;
|
use EasyMessage\Template\AbstractTemplate;
|
||||||
|
|
||||||
class DingTalkChannel extends AbstractChannel
|
class DingTalkChannel extends AbstractChannel
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace MessageNotify\Channel;
|
namespace EasyMessage\Channel;
|
||||||
|
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use GuzzleHttp\RequestOptions;
|
use GuzzleHttp\RequestOptions;
|
||||||
use MessageNotify\Exceptions\MessageNotificationException;
|
use EasyMessage\Exceptions\MessageNotificationException;
|
||||||
use MessageNotify\Template\AbstractTemplate;
|
use EasyMessage\Template\AbstractTemplate;
|
||||||
|
|
||||||
class FeiShuChannel extends AbstractChannel
|
class FeiShuChannel extends AbstractChannel
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace MessageNotify\Channel;
|
namespace EasyMessage\Channel;
|
||||||
|
|
||||||
use MessageNotify\Template\AbstractTemplate;
|
use EasyMessage\Template\AbstractTemplate;
|
||||||
|
|
||||||
class MailChannel extends AbstractChannel
|
class MailChannel extends AbstractChannel
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace MessageNotify\Channel;
|
namespace EasyMessage\Channel;
|
||||||
|
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\RequestOptions;
|
use GuzzleHttp\RequestOptions;
|
||||||
use MessageNotify\Exceptions\MessageNotificationException;
|
use EasyMessage\Exceptions\MessageNotificationException;
|
||||||
use MessageNotify\Template\AbstractTemplate;
|
use EasyMessage\Template\AbstractTemplate;
|
||||||
|
|
||||||
class WechatChannel extends AbstractChannel
|
class WechatChannel extends AbstractChannel
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace MessageNotify;
|
namespace EasyMessage;
|
||||||
|
|
||||||
use MessageNotify\Channel\AbstractChannel;
|
use EasyMessage\Channel\AbstractChannel;
|
||||||
use MessageNotify\Contracts\MessageNotifyInterface;
|
use EasyMessage\Contracts\EasyMessageInterface;
|
||||||
use MessageNotify\Exceptions\MessageNotificationException;
|
use EasyMessage\Exceptions\MessageNotificationException;
|
||||||
use MessageNotify\Template\AbstractTemplate;
|
use EasyMessage\Template\AbstractTemplate;
|
||||||
use MessageNotify\Template\Text;
|
use EasyMessage\Template\Text;
|
||||||
|
|
||||||
class Client
|
class Client
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,7 @@ class Client
|
||||||
|
|
||||||
protected array $at = [];
|
protected array $at = [];
|
||||||
|
|
||||||
protected string $pipeline = MessageNotifyInterface::INFO;
|
protected string $pipeline = EasyMessageInterface::INFO;
|
||||||
|
|
||||||
protected string $title = '';
|
protected string $title = '';
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ class Client
|
||||||
|
|
||||||
public function setPipeline(string $pipeline = ''): Client
|
public function setPipeline(string $pipeline = ''): Client
|
||||||
{
|
{
|
||||||
$this->pipeline = $pipeline ?? MessageNotifyInterface::INFO;
|
$this->pipeline = $pipeline ?? EasyMessageInterface::INFO;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace MessageNotify;
|
namespace EasyMessage;
|
||||||
|
|
||||||
use MessageNotify\Contracts\MessageNotifyInterface;
|
use EasyMessage\Contracts\EasyMessageInterface;
|
||||||
|
|
||||||
class ConfigProvider
|
class ConfigProvider
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ class ConfigProvider
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'dependencies' => [
|
'dependencies' => [
|
||||||
MessageNotifyInterface::class => Client::class,
|
EasyMessageInterface::class => Client::class,
|
||||||
],
|
],
|
||||||
'annotations' => [
|
'annotations' => [
|
||||||
'scan' => [
|
'scan' => [
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace MessageNotify\Contracts;
|
namespace EasyMessage\Contracts;
|
||||||
|
|
||||||
interface MessageNotifyInterface
|
interface EasyMessageInterface
|
||||||
{
|
{
|
||||||
public const INFO = 'info';
|
public const INFO = 'info';
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace MessageNotify\Exceptions;
|
namespace EasyMessage\Exceptions;
|
||||||
|
|
||||||
class MessageNotificationException extends \RuntimeException
|
class MessageNotificationException extends \RuntimeException
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace MessageNotify;
|
namespace EasyMessage;
|
||||||
|
|
||||||
use Hyperf\Utils\ApplicationContext;
|
use Hyperf\Utils\ApplicationContext;
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace MessageNotify\Template;
|
namespace EasyMessage\Template;
|
||||||
|
|
||||||
use MessageNotify\Contracts\MessageNotifyInterface;
|
use EasyMessage\Contracts\EasyMessageInterface;
|
||||||
|
|
||||||
abstract class AbstractTemplate
|
abstract class AbstractTemplate
|
||||||
{
|
{
|
||||||
protected array $at = [];
|
protected array $at = [];
|
||||||
|
|
||||||
protected string $pipeline = MessageNotifyInterface::INFO;
|
protected string $pipeline = EasyMessageInterface::INFO;
|
||||||
|
|
||||||
protected string $text = '';
|
protected string $text = '';
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace MessageNotify\Template;
|
namespace EasyMessage\Template;
|
||||||
|
|
||||||
class Markdown extends AbstractTemplate
|
class Markdown extends AbstractTemplate
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace MessageNotify\Template;
|
namespace EasyMessage\Template;
|
||||||
|
|
||||||
class Text extends AbstractTemplate
|
class Text extends AbstractTemplate
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace MessageNotifyTest;
|
namespace EasyMessageTest;
|
||||||
|
|
||||||
use MessageNotify\Channel\DingTalkChannel;
|
use EasyMessage\Channel\DingTalkChannel;
|
||||||
use MessageNotify\Channel\FeiShuChannel;
|
use EasyMessage\Channel\FeiShuChannel;
|
||||||
use MessageNotify\Channel\WechatChannel;
|
use EasyMessage\Channel\WechatChannel;
|
||||||
use MessageNotify\Contracts\MessageNotifyInterface;
|
use EasyMessage\Contracts\EasyMessageInterface;
|
||||||
use MessageNotify\Notify;
|
use EasyMessage\Notify;
|
||||||
use MessageNotify\Template\Markdown;
|
use EasyMessage\Template\Markdown;
|
||||||
use MessageNotify\Template\Text;
|
use EasyMessage\Template\Text;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +32,7 @@ class NotifyTest extends TestCase
|
||||||
->setAt(['all'])
|
->setAt(['all'])
|
||||||
->setTitle('标题')
|
->setTitle('标题')
|
||||||
->setText('测试')
|
->setText('测试')
|
||||||
->setPipeline(MessageNotifyInterface::INFO)
|
->setPipeline(EasyMessageInterface::INFO)
|
||||||
->setTemplate(Markdown::class)
|
->setTemplate(Markdown::class)
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue