提交 e92b6c5e 编写于 作者: kanyxmo's avatar kanyxmo

fix and refactor

上级 b83abb47
......@@ -16,7 +16,6 @@ use App\Setting\Model\SettingDatasource;
use Hyperf\Database\Model\Builder;
use Hyperf\DbConnection\Db;
use Mine\Abstracts\AbstractMapper;
use Mine\Annotation\Transaction;
use Mine\Exception\MineException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
......@@ -93,7 +92,7 @@ class SettingDatasourceMapper extends AbstractMapper
*/
public function createTable(string $sql): bool
{
return Db::connection()->getPdo()->exec($sql) > 0;
return Db::connection('default')->getPdo()->exec($sql) > 0;
}
public function connectionDb(Object|array $params): \PDO
......
......@@ -6,7 +6,7 @@ namespace App\System\Listener;
use App\System\Model\SystemUploadfile;
use Hyperf\Event\Annotation\Listener;
use Hyperf\Event\Contract\ListenerInterface;
use League\Flysystem\FileNotFoundException;
use League\Flysystem\FilesystemException;
use Mine\Event\RealDeleteUploadFile;
/**
......@@ -24,14 +24,15 @@ class DeleteUploadFileListener implements ListenerInterface
}
/**
* @param RealDeleteUploadFile $event
* @param object $event
* @throws FilesystemException
*/
public function process(object $event): void
{
$filePath = $this->getFilePath($event->getModel());
try {
$event->getFilesystem()->delete($filePath);
} catch (FileNotFoundException $e) {
} catch (\Exception $e) {
// 文件删除失败,跳过删除数据
$event->setConfirm(false);
}
......
......@@ -210,7 +210,7 @@ class SystemAppService extends AbstractService
if ($apiData['app_id'] != $appInfo['app_id']) {
return MineCode::API_UNBIND_APP;
}
} else if (! $this->checkAppHasBindApi($appId, (int) $appInfo['id'])) {
} else if (! $this->checkAppHasBindApi($apiData['app_id'], (int) $appInfo['id'])) {
return MineCode::API_UNBIND_APP;
}
......
......@@ -13,11 +13,9 @@ use Mine\Event\UserAdd;
use Mine\Event\UserDelete;
use Mine\Exception\MineException;
use Mine\Exception\NormalStatusException;
use Mine\Helper\MineCaptcha;
use Mine\MineRequest;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\SimpleCache\CacheInterface;
use Psr\SimpleCache\InvalidArgumentException;
/**
......@@ -73,23 +71,6 @@ class SystemUserService extends AbstractService
$this->container = $container;
}
/**
* 获取验证码
* @return string
* @throws InvalidArgumentException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
public function getCaptcha(): string
{
$cache = container()->get(CacheInterface::class);
$captcha = new MineCaptcha();
$info = $captcha->getCaptchaInfo();
$key = $this->request->ip() .'-'. \Mine\Helper\Str::lower($info['code']);
$cache->set(sprintf('captcha:%s', $key), $info['code'], 60);
return $info['image'];
}
/**
* 获取用户信息
* @return array
......
......@@ -10,19 +10,19 @@
"description": "Quickly build a background management system for web applications",
"license": "Apache-2.0",
"require": {
"xmo/mine": "dev-main",
"xmo/mine-office": "dev-main",
"xmo/mine-core": "1.3.*",
"xmo/mine-office": "1.3.*",
"xmo/jwt-auth": "0.6.*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.9",
"friendsofphp/php-cs-fixer": "^3.0",
"hyperf/devtool": "3.0.*",
"hyperf/ide-helper": "3.0.*",
"hyperf/testing": "3.0.*",
"hyperf/watcher": "3.0.*",
"mockery/mockery": "^1.0",
"phpstan/phpstan": "^0.12",
"swoole/ide-helper": "^4.5"
"phpstan/phpstan": "^1.0",
"swoole/ide-helper": "^5.0"
},
"suggest": {
"ext-openssl": "Required to use HTTPS.",
......@@ -62,20 +62,10 @@
],
"test": "co-phpunit --prepend test/bootstrap.php -c phpunit.xml --colors=always",
"cs-fix": "php-cs-fixer fix $1",
"analyse": "phpstan analyse --memory-limit 300M -l 0 -c phpstan.neon ./app ./config ./mine",
"analyse": "phpstan analyse --memory-limit 300M -l 0 -c phpstan.neon ./app ./config ./vendor/xmo",
"start": [
"Composer\\Config::disableProcessTimeout",
"php ./bin/hyperf.php start"
]
},
"repositories": {
"mine": {
"type": "path",
"url": "/opt/mine"
},
"mine-office": {
"type": "path",
"url": "/opt/office"
}
}
}
此差异已折叠。
......@@ -12,5 +12,4 @@ declare(strict_types=1);
return [
Hyperf\Database\Commands\Ast\ModelUpdateVisitor::class => Mine\MineModelVisitor::class,
Hyperf\HttpServer\CoreMiddleware::class => Mine\Middlewares\HttpCoreMiddleware::class,
// Mine\Interfaces\UserServiceInterface::class => App\System\Service\Dependencies\UserAuthService::class,
];
......@@ -16,7 +16,7 @@ use Hyperf\Di\Container;
use Hyperf\Di\Definition\DefinitionSourceFactory;
use Hyperf\Context\ApplicationContext;
$container = new Container((new DefinitionSourceFactory(true))());
$container = new Container((new DefinitionSourceFactory())());
if (! $container instanceof \Psr\Container\ContainerInterface) {
throw new RuntimeException('The dependency injection container is invalid.');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册