mirror of
http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore.git
synced 2026-01-15 07:15:06 +08:00
Compare commits
5 Commits
v1.0.0-bet
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a296c56e9 | ||
|
|
2dace65933 | ||
|
|
e8596c9d30 | ||
|
|
b6dd7dd4ac | ||
|
|
0283c7286a |
1
.idea/HDK-Core.iml
generated
1
.idea/HDK-Core.iml
generated
@@ -143,7 +143,6 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-idn" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-normalizer" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php72" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php73" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php80" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php81" />
|
||||
|
||||
12
.idea/codeception.xml
generated
12
.idea/codeception.xml
generated
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Codeception">
|
||||
<option name="configurations">
|
||||
<list>
|
||||
<Configuration>
|
||||
<option name="path" value="$PROJECT_DIR$/tests" />
|
||||
</Configuration>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
5
.idea/php.xml
generated
5
.idea/php.xml
generated
@@ -84,7 +84,6 @@
|
||||
<path value="$PROJECT_DIR$/vendor/alibabacloud/tea-utils" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php81" />
|
||||
<path value="$PROJECT_DIR$/vendor/alibabacloud/gateway-spi" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php72" />
|
||||
<path value="$PROJECT_DIR$/vendor/alibabacloud/endpoint-util" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/translation" />
|
||||
<path value="$PROJECT_DIR$/vendor/alibabacloud/dysmsapi-20170525" />
|
||||
@@ -192,8 +191,6 @@
|
||||
<path value="$PROJECT_DIR$/vendor/spatie/pest-plugin-test-time" />
|
||||
<path value="$PROJECT_DIR$/vendor/carbonphp/carbon-doctrine-types" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php82" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/resource-operations" />
|
||||
<path value="$PROJECT_DIR$/vendor/facade/ignition-contracts" />
|
||||
<path value="$PROJECT_DIR$/vendor/cooper/hyperf-pest" />
|
||||
<path value="$PROJECT_DIR$/vendor/clue/ndjson-react" />
|
||||
<path value="$PROJECT_DIR$/vendor/evenement/evenement" />
|
||||
@@ -209,8 +206,6 @@
|
||||
<component name="PhpStan">
|
||||
<PhpStan_settings>
|
||||
<PhpStanConfiguration tool_path="$PROJECT_DIR$/vendor/bin/phpstan" />
|
||||
<PhpStanConfiguration tool_path="$PROJECT_DIR$/vendor/bin/phpstan" />
|
||||
<PhpStanConfiguration tool_path="$PROJECT_DIR$/vendor/bin/phpstan" />
|
||||
</PhpStan_settings>
|
||||
</component>
|
||||
<component name="PhpStanOptionsConfiguration">
|
||||
|
||||
45
.idea/phpspec.xml
generated
45
.idea/phpspec.xml
generated
@@ -5,51 +5,6 @@
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
</suites>
|
||||
</component>
|
||||
</project>
|
||||
19
CHANGELOG.md
19
CHANGELOG.md
@@ -1,4 +1,23 @@
|
||||
# 版本更新日志
|
||||
## [1.0.0-beta.6](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/compare/v1.0.0-beta.5...v1.0.0-beta.6) (2024-12-06)
|
||||
|
||||
|
||||
### 🐛 Bug Fixes | Bug 修复
|
||||
|
||||
* **exceptions:** 处理 HTTP 客户端和服务器异常 ([2dace65](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/commit/2dace65933d7361c1124f8c5c125a507894584fb))
|
||||
|
||||
## [1.0.0-beta.5](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/compare/v1.0.0-beta.4...v1.0.0-beta.5) (2024-09-12)
|
||||
|
||||
|
||||
### 📦 Build System | 打包构建
|
||||
|
||||
* **composer:** 更新依赖 ([0283c72](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/commit/0283c7286a58104c0ea649820fdab2dc781053c9))
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **email:** 对发送邮件增加密送,增加单独定制发件人的方法 ([b6dd7dd](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/commit/b6dd7dd4ace2623a4631d22fc4e6394e9d2ddda7))
|
||||
|
||||
## [1.0.0-beta.4](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/compare/v1.0.0-beta.3...v1.0.0-beta.4) (2024-06-23)
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.0.0-beta.4
|
||||
1.0.0-beta.6
|
||||
@@ -130,5 +130,5 @@
|
||||
"url": "https://mirrors.aliyun.com/composer/"
|
||||
}
|
||||
},
|
||||
"version": "1.0.0-beta.4"
|
||||
"version": "1.0.0-beta.6"
|
||||
}
|
||||
|
||||
4297
composer.lock
generated
4297
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,7 @@
|
||||
|
||||
namespace Singularity\HDK\Core\Events;
|
||||
|
||||
use Singularity\HDK\Core\Service\EmailService;
|
||||
use Symfony\Component\Mime\Email;
|
||||
|
||||
/**
|
||||
@@ -39,10 +40,19 @@ class EmailWillSent
|
||||
public string $content,
|
||||
|
||||
/**
|
||||
* 抄送
|
||||
*
|
||||
* @var string[] $cc
|
||||
*/
|
||||
public array $cc = [],
|
||||
|
||||
/**
|
||||
* 密送
|
||||
*
|
||||
* @var string[] $bcc
|
||||
*/
|
||||
public array $bcc = [],
|
||||
|
||||
/**
|
||||
* @var 'text'|'html' $type
|
||||
*/
|
||||
@@ -52,7 +62,12 @@ class EmailWillSent
|
||||
* @var int
|
||||
* @see Email::priority()
|
||||
*/
|
||||
public int $priority = Email::PRIORITY_NORMAL
|
||||
public int $priority = Email::PRIORITY_NORMAL,
|
||||
|
||||
/**
|
||||
* @var EmailService|null
|
||||
*/
|
||||
public ?EmailService $sender = null,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ declare(strict_types=1);
|
||||
namespace Singularity\HDK\Core\Exceptions\Handler;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use GuzzleHttp\Exception\ServerException;
|
||||
use Hyperf\Codec\Json;
|
||||
use Hyperf\Database\Exception\QueryException;
|
||||
use Hyperf\Database\Model\ModelNotFoundException;
|
||||
@@ -93,6 +95,26 @@ class CommonHandler extends ExceptionHandler
|
||||
$data['details'] = ['sql' => $throwable->getSql(), 'error' => $throwable->getMessage()];
|
||||
}
|
||||
}
|
||||
if ($throwable instanceof ClientException) {
|
||||
$content = $throwable->getResponse()->getBody()->getContents();
|
||||
|
||||
['errorCode' => $code, 'errorMsg' => $msg] = Json::decode($content);
|
||||
$data = [
|
||||
$code_name => $code,
|
||||
$message_name => $msg,
|
||||
];
|
||||
$status_code = 400;
|
||||
}
|
||||
if ($throwable instanceof ServerException) {
|
||||
$content = $throwable->getResponse()->getBody()->getContents();
|
||||
|
||||
['errorCode' => $code, 'errorMsg' => $msg] = Json::decode($content);
|
||||
$data = [
|
||||
$code_name => $code,
|
||||
$message_name => $msg,
|
||||
];
|
||||
$status_code = 500;
|
||||
}
|
||||
// 101 请求方式错误
|
||||
if ($throwable instanceof MethodNotAllowedHttpException) {
|
||||
$message = explode(': ', $throwable->getMessage());
|
||||
|
||||
@@ -55,7 +55,8 @@ class EmailWillSentListener implements ListenerInterface
|
||||
public function process(object $event): void
|
||||
{
|
||||
$stdoutLogger = $this->container->get(StdoutLoggerInterface::class);
|
||||
$emailService = $this->container->get(EmailService::class);
|
||||
// $emailService = $this->container->get(EmailService::class);
|
||||
$emailService = $event->sender ?? EmailService::make();
|
||||
try {
|
||||
$event->type === 'html'
|
||||
? $emailService->sendHtml(
|
||||
@@ -63,6 +64,7 @@ class EmailWillSentListener implements ListenerInterface
|
||||
subject: $event->subject,
|
||||
html: $event->content,
|
||||
cc: $event->cc,
|
||||
bcc: $event->bcc,
|
||||
priority: $event->priority
|
||||
)
|
||||
: $emailService->sendText(
|
||||
@@ -70,6 +72,7 @@ class EmailWillSentListener implements ListenerInterface
|
||||
subject: $event->subject,
|
||||
text: $event->content,
|
||||
cc: $event->cc,
|
||||
bcc: $event->bcc,
|
||||
priority: $event->priority
|
||||
);
|
||||
|
||||
|
||||
@@ -45,6 +45,18 @@ class EmailService
|
||||
);
|
||||
}
|
||||
|
||||
public static function make(
|
||||
?string $dsn = null,
|
||||
?string $mailSenderName = null,
|
||||
?string $mailSender = null,
|
||||
): static {
|
||||
return new static(
|
||||
dsn: $dsn,
|
||||
mailSenderName: $mailSenderName,
|
||||
mailSender: $mailSender,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
*
|
||||
@@ -68,9 +80,11 @@ class EmailService
|
||||
|
||||
/**
|
||||
* @param string|array<string> $target
|
||||
* @param string $subject
|
||||
* @param string $text
|
||||
* @param string $subject
|
||||
* @param string $text
|
||||
* @param array<string> $cc
|
||||
* @param array $bcc
|
||||
* @param int $priority
|
||||
*
|
||||
* @return bool
|
||||
* @throws TransportExceptionInterface
|
||||
@@ -80,12 +94,14 @@ class EmailService
|
||||
string $subject,
|
||||
string $text,
|
||||
array $cc = [],
|
||||
array $bcc = [],
|
||||
int $priority = Email::PRIORITY_NORMAL
|
||||
): bool {
|
||||
$email = (new Email())
|
||||
->from(Address::create($this->from))
|
||||
->to(...(is_array($target) ? $target : [$target]))
|
||||
->cc(...$cc)
|
||||
->bcc(...$bcc)
|
||||
->priority($priority)
|
||||
->subject($subject)
|
||||
->text($text);
|
||||
@@ -99,10 +115,12 @@ class EmailService
|
||||
* 以 HTML 格式发送邮件
|
||||
*
|
||||
* @param string|array<string> $target
|
||||
* @param string $subject
|
||||
* @param string $html
|
||||
* @param string $subject
|
||||
* @param string $html
|
||||
* @param array<string> $cc
|
||||
* @param int $priority
|
||||
* @param array $bcc
|
||||
* @param int $priority
|
||||
*
|
||||
* @return bool
|
||||
* @throws TransportExceptionInterface
|
||||
*/
|
||||
@@ -111,12 +129,14 @@ class EmailService
|
||||
string $subject,
|
||||
string $html,
|
||||
array $cc = [],
|
||||
array $bcc = [],
|
||||
int $priority = Email::PRIORITY_NORMAL
|
||||
): bool {
|
||||
$email = (new Email())
|
||||
->from(Address::create($this->from))
|
||||
->to(...(is_array($target) ? $target : [$target]))
|
||||
->cc(...$cc)
|
||||
->bcc(...$bcc)
|
||||
->priority($priority)
|
||||
->subject($subject)
|
||||
->html($html);
|
||||
|
||||
Reference in New Issue
Block a user