modify plugin name

This commit is contained in:
2022-02-23 16:32:08 +08:00
parent 71c95a824c
commit f5fd9401dd
8 changed files with 23 additions and 19 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ use Exception;
* Class Get
* @package Annotation\Model
*/
#[Attribute(Attribute::TARGET_METHOD)] class Get extends \Kiri\Annotation\Attribute
#[Attribute(Attribute::TARGET_METHOD)] class Get extends \Kiri\Annotation\AbstractAttribute
{
+2 -2
View File
@@ -4,7 +4,7 @@
namespace Database\Annotation;
use Kiri\Annotation\Attribute;
use Kiri\Annotation\AbstractAttribute;
use Database\Base\Relate;
use Exception;
@@ -13,7 +13,7 @@ use Exception;
* Class Relation
* @package Annotation\Model
*/
#[\Attribute(\Attribute::TARGET_METHOD)] class Relation extends Attribute
#[\Attribute(\Attribute::TARGET_METHOD)] class Relation extends AbstractAttribute
{
+2 -2
View File
@@ -4,11 +4,11 @@
namespace Database\Annotation;
use Kiri\Annotation\Attribute;
use Kiri\Annotation\AbstractAttribute;
use Database\Base\Setter;
use Exception;
#[\Attribute(\Attribute::TARGET_METHOD)] class Set extends Attribute
#[\Attribute(\Attribute::TARGET_METHOD)] class Set extends AbstractAttribute
{
+8 -5
View File
@@ -25,9 +25,11 @@ use Database\Relation;
use Database\SqlBuilder;
use Database\Traits\HasBase;
use Exception;
use Kiri\Abstracts\Component;
use Kiri\Exception\NotFindClassException;
use Kiri;
use Kiri\Abstracts\Component;
use Kiri\Annotation\Annotation;
use Kiri\Error\StdoutLogger;
use Kiri\Exception\NotFindClassException;
use Kiri\ToArray;
use ReflectionException;
use ReturnTypeWillChange;
@@ -198,7 +200,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
*/
public function init()
{
$an = Kiri::app()->getAnnotation();
$an = Kiri::getDi()->get(Annotation::class);
$an->injectProperty($this);
}
@@ -238,7 +240,8 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
*/
public function getLastError(): string
{
return Kiri::app()->getLogger()->getLastError('mysql');
$logger = Kiri::getDi()->get(StdoutLogger::class);
return $logger->getLastError('mysql');
}
@@ -646,7 +649,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
if (empty($rule)) return TRUE;
$validate = $this->resolve($rule);
if (!$validate->validation()) {
return $this->addError($validate->getError(), 'mysql');
return $this->logger->addError($validate->getError(), 'mysql');
} else {
return TRUE;
}
+3 -3
View File
@@ -133,7 +133,7 @@ class Command extends Component
private function _timeout_log(float $time, mixed $result): mixed
{
if (microtime(true) - $time >= 0.02) {
$this->warning('Mysql:' . Json::encode([$this->sql, $this->params]) . (microtime(true) - $time));
$this->logger->warning('Mysql:' . Json::encode([$this->sql, $this->params]) . (microtime(true) - $time));
}
return $result;
}
@@ -149,7 +149,7 @@ class Command extends Component
try {
$result = $pdo->execute($this->sql, $this->params);
} catch (\Throwable $exception) {
$result = $this->addError($this->sql . '. error: ' . $exception->getMessage(), 'mysql');
$result = $this->logger->addError($this->sql . '. error: ' . $exception->getMessage(), 'mysql');
} finally {
$this->db->release();
return $result;
@@ -168,7 +168,7 @@ class Command extends Component
try {
$data = $pdo->{$type}($this->sql, $this->params);
} catch (\Throwable $throwable) {
$data = $this->addError($this->sql . '. error: ' . $throwable->getMessage(), 'mysql');
$data = $this->logger->addError($this->sql . '. error: ' . $throwable->getMessage(), 'mysql');
} finally {
$this->db->releaseSlaveConnect($pdo);
return $data;
+4 -3
View File
@@ -16,6 +16,7 @@ use Exception;
use Kiri;
use Kiri\Exception\NotFindClassException;
use Kiri\ToArray;
use Kiri\Error\StdoutLogger;
use ReflectionException;
use Swoole\Coroutine;
@@ -108,7 +109,7 @@ class Model extends Base\Model
*/
public static function findOrCreate(array $condition, array $attributes): bool|static
{
$logger = Kiri::app()->getLogger();
$logger = Kiri::getDi()->get(StdoutLogger::class);
if (empty($attributes)) {
return $logger->addError(FIND_OR_CREATE_MESSAGE, 'mysql');
}
@@ -133,7 +134,7 @@ class Model extends Base\Model
*/
public static function createOrUpdate(array $condition, array $attributes = []): bool|static
{
$logger = Kiri::app()->getLogger();
$logger = Kiri::getDi()->get(StdoutLogger::class);
if (empty($attributes)) {
return $logger->addError(FIND_OR_CREATE_MESSAGE, 'mysql');
}
@@ -207,7 +208,7 @@ class Model extends Base\Model
{
$primary = $this->getPrimary();
if (empty($primary) || !$this->hasPrimaryValue()) {
return $this->addError("Only primary key operations are supported.", 'mysql');
return $this->logger->addError("Only primary key operations are supported.", 'mysql');
}
if ($this->beforeDelete()) {
$result = static::deleteByCondition([$primary => $this->getPrimaryValue()]);
+2 -2
View File
@@ -149,7 +149,7 @@ class Pagination extends Component
try {
call_user_func($this->_callback, $data, $param);
} catch (\Throwable $exception) {
$this->addError($exception, 'throwable');
$this->logger->addError($exception, 'throwable');
} finally {
$data = null;
}
@@ -179,7 +179,7 @@ class Pagination extends Component
try {
call_user_func($this->_callback, $data, $param);
} catch (\Throwable $exception) {
$this->addError($exception, 'throwable');
$this->logger->addError($exception, 'throwable');
}
}
+1 -1
View File
@@ -93,7 +93,7 @@ class SqlBuilder extends Component
private function __updateBuilder(array $string, array $params): array|bool
{
if (empty($string)) {
return $this->addError('None data update.');
return $this->logger->addError('None data update.');
}
$condition = $this->conditionToString();