mirror of
http://124.126.16.154:8888/singularity/hyperf-admin.git
synced 2026-01-15 05:15:06 +08:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4484fb1eea | ||
|
|
606672b1d6 | ||
|
|
44105f8e47 | ||
|
|
db34c59acc | ||
|
|
43275f365c | ||
|
|
ff7e959daa | ||
|
|
55e2b0477a | ||
|
|
21ddc159aa | ||
|
|
98ba4a13dc | ||
|
|
bb438b5996 | ||
|
|
5f75dc1afb | ||
|
|
0d4e80fe15 | ||
|
|
5e327fbbc5 | ||
|
|
e60d9174e5 | ||
|
|
6330f5e390 | ||
|
|
dfd814c817 | ||
|
|
27b5f54d57 | ||
|
|
dabfbdf861 | ||
|
|
e9e6084e97 | ||
|
|
3c5b77dda6 | ||
|
|
c2b56cf978 | ||
|
|
254989e992 | ||
|
|
8f5592ecc8 | ||
|
|
710eefc4c6 | ||
|
|
c6ab3dbad4 | ||
|
|
a780c3b3b8 | ||
|
|
2b579e8c5f | ||
|
|
5084d4596d | ||
|
|
4b9cea60ff |
30
.gitea/workflows/publish_on_tagged.yml
Normal file
30
.gitea/workflows/publish_on_tagged.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
name: Release development version to registry
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '**.**'
|
||||
|
||||
jobs:
|
||||
Publish on Tagged:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||
- name: List files in the repository
|
||||
run: |
|
||||
ls ${{ gitea.workspace }}
|
||||
- name: Zip files in the repository
|
||||
run: |
|
||||
sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list
|
||||
sed -i 's|security.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list
|
||||
apt-get update
|
||||
apt-get install zip
|
||||
zip -r dist.zip *
|
||||
- name: Publish to registry
|
||||
run: |
|
||||
curl --user ch4o5:4fd300672472e666014314c1c94c604c634165a9 \
|
||||
--upload-file ./dist.zip \
|
||||
https://nest.doylee.cn/api/packages/HDK/composer?version=${{ gitea.ref_name }}
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,3 +1,5 @@
|
||||
.idea
|
||||
composer.lock
|
||||
vendor
|
||||
.idea/
|
||||
vendor/
|
||||
runtime/
|
||||
.phpunit.result.cache
|
||||
.php-cs-fixer.cache
|
||||
23
.php-cs-fixer.dist.php
Normal file
23
.php-cs-fixer.dist.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* .php-cs-fixer.dist.php@HDK-Core
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2023/1/9
|
||||
*/
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()->in([
|
||||
__DIR__ . '/publish',
|
||||
__DIR__ . '/src',
|
||||
__DIR__ . '/tests',
|
||||
]);
|
||||
|
||||
$config = new PhpCsFixer\Config();
|
||||
return $config->setRules([
|
||||
'@PSR12' => true,
|
||||
'strict_param' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
])
|
||||
->setUsingCache(false)
|
||||
->setFinder($finder);
|
||||
68
.versionrc
Normal file
68
.versionrc
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"header": "# 版本更新日志",
|
||||
"preMajor": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "feat",
|
||||
"section": "✨ Features | 新功能"
|
||||
},
|
||||
{
|
||||
"type": "fix",
|
||||
"section": "🐛 Bug Fixes | Bug 修复"
|
||||
},
|
||||
{
|
||||
"type": "init",
|
||||
"section": "🎉 Init | 初始化"
|
||||
},
|
||||
{
|
||||
"type": "docs",
|
||||
"section": "✏️ Documentation | 文档"
|
||||
},
|
||||
{
|
||||
"type": "style",
|
||||
"section": "💄 Styles | 风格"
|
||||
},
|
||||
{
|
||||
"type": "refactor",
|
||||
"section": "♻️ Code Refactoring | 代码重构"
|
||||
},
|
||||
{
|
||||
"type": "perf",
|
||||
"section": "⚡ Performance Improvements | 性能优化"
|
||||
},
|
||||
{
|
||||
"type": "tests",
|
||||
"section": "✅ Tests | 测试"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"section": "✅ Tests | 测试"
|
||||
},
|
||||
{
|
||||
"type": "revert",
|
||||
"section": "⏪ Revert | 回退"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"section": "📦 Build System | 打包构建"
|
||||
},
|
||||
{
|
||||
"type": "chore",
|
||||
"section": "🚀 Chore | 构建/工程依赖/工具"
|
||||
},
|
||||
{
|
||||
"type": "ci",
|
||||
"section": "👷 Continuous Integration | CI 配置"
|
||||
}
|
||||
],
|
||||
"bumpFiles": [
|
||||
{
|
||||
"filename": "VERSION_TRACKER.txt",
|
||||
"type": "plain-text"
|
||||
},
|
||||
{
|
||||
"filename": "composer.json",
|
||||
"type": "json"
|
||||
}
|
||||
]
|
||||
}
|
||||
85
CHANGELOG.md
Normal file
85
CHANGELOG.md
Normal file
@@ -0,0 +1,85 @@
|
||||
# 版本更新日志
|
||||
### [0.5.1](http://124.126.16.154:8888/singularity/hyperf-admin/compare/v0.5.0...v0.5.1) (2025-09-26)
|
||||
|
||||
|
||||
### 🚀 Chore | 构建/工程依赖/工具
|
||||
|
||||
* **workflow:** 更新发布工作流配置 ([db34c59](http://124.126.16.154:8888/singularity/hyperf-admin/commit/db34c59acc7825f6f10298b4a3ce34500639fe24))
|
||||
|
||||
## [0.5.0](http://124.126.16.154:8888/singularity/hyperf-admin/compare/v0.4.3...v0.5.0) (2025-09-26)
|
||||
|
||||
|
||||
### 🚀 Chore | 构建/工程依赖/工具
|
||||
|
||||
* **workflow:** 修改发布任务名称 ([ff7e959](http://124.126.16.154:8888/singularity/hyperf-admin/commit/ff7e959daaec12a3f8fa5b52054f3ab2b5d13612))
|
||||
|
||||
### [0.4.3](http://124.126.16.154:8888/singularity/hyperf-admin/compare/v0.4.2...v0.4.3) (2025-09-26)
|
||||
|
||||
### [0.4.2](http://124.126.16.154:8888/singularity/hyperf-admin/compare/v0.3.4...v0.4.2) (2025-09-26)
|
||||
|
||||
|
||||
### 🚀 Chore | 构建/工程依赖/工具
|
||||
|
||||
* 更新文件权限并添加发布脚本和CI配置 ([bb438b5](http://124.126.16.154:8888/singularity/hyperf-admin/commit/bb438b59963bb2a1906fc33311bbce85c60db5ce))
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **ci:** 添加基于标签的自动发布工作流 ([98ba4a1](http://124.126.16.154:8888/singularity/hyperf-admin/commit/98ba4a13dc9d3317351c0c549a94d017ee48d6e0))
|
||||
|
||||
### [0.3.4](http://124.126.16.154:8888/singularity/hyperf-admin/compare/v0.3.3...v0.3.4) (2023-04-19)
|
||||
|
||||
|
||||
### ✏️ Documentation | 文档
|
||||
|
||||
* **admin:** 修改了登录的验证文案 ([0d4e80f](http://124.126.16.154:8888/singularity/hyperf-admin/commit/0d4e80fe15e0e9a3de447012669ec2045323f1a5))
|
||||
|
||||
### [0.3.3](http://124.126.16.154:8888/singularity/hyperf-admin/compare/v0.3.2...v0.3.3) (2023-04-18)
|
||||
|
||||
|
||||
### 📦 Build System | 打包构建
|
||||
|
||||
* **composer:** 最低依赖版本改为 php7.4 ([254989e](http://124.126.16.154:8888/singularity/hyperf-admin/commit/254989e9922bdb333e57e2cbd69e31464d4de1bf))
|
||||
* **composer:** 更新包名 ([710eefc](http://124.126.16.154:8888/singularity/hyperf-admin/commit/710eefc4c6a3305c5653841c8f851e0b613f54e2))
|
||||
* **composer:** 限制 flysystem-oss 的版本 ([e9e6084](http://124.126.16.154:8888/singularity/hyperf-admin/commit/e9e6084e97620dda06cc9bde7fbe5e5162bbf894))
|
||||
* **composer:** 限制 flysystem-oss 的版本 ([3c5b77d](http://124.126.16.154:8888/singularity/hyperf-admin/commit/3c5b77dda68973e2fac9ce4c32a8cf8803129d33))
|
||||
* **hdk:** 引入 hdk-core ([dabfbdf](http://124.126.16.154:8888/singularity/hyperf-admin/commit/dabfbdf8612188043b7a4354bbe5c6e518422af9))
|
||||
* **semver:** 初始化版本记录文件 ([27b5f54](http://124.126.16.154:8888/singularity/hyperf-admin/commit/27b5f54d575ccc26747b00bf8c549c0935fb41d3))
|
||||
* 工程化项目 ([c2b56cf](http://124.126.16.154:8888/singularity/hyperf-admin/commit/c2b56cf9783cca6f69067a5434d2a0fd19ec89d6))
|
||||
|
||||
|
||||
### 🐛 Bug Fixes | Bug 修复
|
||||
|
||||
* **menu:** 修复添加菜单不选择权限时候的报错 ([8f5592e](http://124.126.16.154:8888/singularity/hyperf-admin/commit/8f5592ecc8a93e4749558ba2362ca357151bcf1c))
|
||||
* **scaffold:** 修复级联时菜单显示有误的问题 ([6330f5e](http://124.126.16.154:8888/singularity/hyperf-admin/commit/6330f5e390f432e2541724219a3297cdcea6fb5a))
|
||||
|
||||
|
||||
### 🚀 Chore | 构建/工程依赖/工具
|
||||
|
||||
* **release:** 0.4.0 ([dfd814c](http://124.126.16.154:8888/singularity/hyperf-admin/commit/dfd814c817d38521c764d83cec765ca0886e0467))
|
||||
* **release:** 0.4.1 ([e60d917](http://124.126.16.154:8888/singularity/hyperf-admin/commit/e60d9174e571a5d71f5a1b5280b336f0b6d05abb))
|
||||
|
||||
### [0.4.1](http://124.126.16.154:8888/singularity/hyperf-admin/compare/v0.4.0...v0.4.1) (2023-04-18)
|
||||
|
||||
|
||||
### 🐛 Bug Fixes | Bug 修复
|
||||
|
||||
* **scaffold:** 修复级联时菜单显示有误的问题 ([6330f5e](http://124.126.16.154:8888/singularity/hyperf-admin/commit/6330f5e390f432e2541724219a3297cdcea6fb5a))
|
||||
|
||||
## [0.4.0](http://124.126.16.154:8888/singularity/hyperf-admin/compare/v0.3.2...v0.4.0) (2023-04-07)
|
||||
|
||||
|
||||
### 🐛 Bug Fixes | Bug 修复
|
||||
|
||||
* **menu:** 修复添加菜单不选择权限时候的报错 ([8f5592e](http://124.126.16.154:8888/singularity/hyperf-admin/commit/8f5592ecc8a93e4749558ba2362ca357151bcf1c))
|
||||
|
||||
|
||||
### 📦 Build System | 打包构建
|
||||
|
||||
* **composer:** 最低依赖版本改为 php7.4 ([254989e](http://124.126.16.154:8888/singularity/hyperf-admin/commit/254989e9922bdb333e57e2cbd69e31464d4de1bf))
|
||||
* **composer:** 更新包名 ([710eefc](http://124.126.16.154:8888/singularity/hyperf-admin/commit/710eefc4c6a3305c5653841c8f851e0b613f54e2))
|
||||
* **composer:** 限制 flysystem-oss 的版本 ([e9e6084](http://124.126.16.154:8888/singularity/hyperf-admin/commit/e9e6084e97620dda06cc9bde7fbe5e5162bbf894))
|
||||
* **composer:** 限制 flysystem-oss 的版本 ([3c5b77d](http://124.126.16.154:8888/singularity/hyperf-admin/commit/3c5b77dda68973e2fac9ce4c32a8cf8803129d33))
|
||||
* **hdk:** 引入 hdk-core ([dabfbdf](http://124.126.16.154:8888/singularity/hyperf-admin/commit/dabfbdf8612188043b7a4354bbe5c6e518422af9))
|
||||
* **semver:** 初始化版本记录文件 ([27b5f54](http://124.126.16.154:8888/singularity/hyperf-admin/commit/27b5f54d575ccc26747b00bf8c549c0935fb41d3))
|
||||
* 工程化项目 ([c2b56cf](http://124.126.16.154:8888/singularity/hyperf-admin/commit/c2b56cf9783cca6f69067a5434d2a0fd19ec89d6))
|
||||
1
VERSION_TRACKER.txt
Normal file
1
VERSION_TRACKER.txt
Normal file
@@ -0,0 +1 @@
|
||||
0.5.1
|
||||
32
bin/hyperf.php
Normal file
32
bin/hyperf.php
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Hyperf\Di\ClassLoader;
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Di\Definition\DefinitionSource;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Swoole\Runtime;
|
||||
|
||||
ini_set('display_errors', 'on');
|
||||
ini_set('display_startup_errors', 'on');
|
||||
|
||||
error_reporting(E_ALL);
|
||||
date_default_timezone_set('Asia/Shanghai');
|
||||
|
||||
|
||||
!defined('BASE_PATH') && define('BASE_PATH', dirname(__DIR__, 1));
|
||||
!defined('SWOOLE_HOOK_FLAGS') && define('SWOOLE_HOOK_FLAGS', SWOOLE_HOOK_ALL);
|
||||
|
||||
Runtime::enableCoroutine();
|
||||
|
||||
require BASE_PATH . '/vendor/autoload.php';
|
||||
ClassLoader::init();
|
||||
|
||||
$container = new Container(new DefinitionSource([]));
|
||||
if (!$container instanceof ContainerInterface) {
|
||||
throw new RuntimeException('The dependency injection container is invalid.');
|
||||
}
|
||||
$container = ApplicationContext::setContainer($container);
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
if (( "$#" != 1 ))
|
||||
then
|
||||
echo "Tag has to be provided"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NOW=$(date +%s)
|
||||
CURRENT_BRANCH="master"
|
||||
VERSION=$1
|
||||
BASEPATH=$(cd `dirname $0`; cd ../src/; pwd)
|
||||
|
||||
# Always prepend with "v"
|
||||
if [[ $VERSION != v* ]]
|
||||
then
|
||||
VERSION="v$VERSION"
|
||||
fi
|
||||
|
||||
git tag $VERSION
|
||||
git push origin --tags
|
||||
|
||||
repos=$(ls $BASEPATH)
|
||||
|
||||
for REMOTE in $repos
|
||||
do
|
||||
echo ""
|
||||
echo ""
|
||||
echo "Cloning $REMOTE";
|
||||
TMP_DIR="/tmp/hyperf-split"
|
||||
REMOTE_URL="git@github.com:hyperf-admin/$REMOTE.git"
|
||||
|
||||
rm -rf $TMP_DIR;
|
||||
mkdir $TMP_DIR;
|
||||
|
||||
(
|
||||
cd $TMP_DIR;
|
||||
|
||||
git clone $REMOTE_URL .
|
||||
git checkout "$CURRENT_BRANCH";
|
||||
|
||||
if [[ $(git log --pretty="%d" -n 1 | grep tag --count) -eq 0 ]]; then
|
||||
echo "Releasing $REMOTE"
|
||||
git tag $VERSION
|
||||
git push origin --tags
|
||||
fi
|
||||
)
|
||||
done
|
||||
|
||||
TIME=$(echo "$(date +%s) - $NOW" | bc)
|
||||
|
||||
printf "Execution time: %f seconds" $TIME
|
||||
30
bin/split.sh
30
bin/split.sh
@@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
CURRENT_BRANCH="master"
|
||||
BASEPATH=$(cd `dirname $0`; cd ../src/; pwd)
|
||||
REPOS=$@
|
||||
|
||||
function split()
|
||||
{
|
||||
SHA1=`./bin/splitsh-lite --prefix=$1`
|
||||
git push $2 "$SHA1:refs/heads/$CURRENT_BRANCH" -f
|
||||
}
|
||||
|
||||
function remote()
|
||||
{
|
||||
git remote add $1 $2 || true
|
||||
}
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
REPOS=$(ls $BASEPATH)
|
||||
fi
|
||||
|
||||
for REPO in $REPOS ; do
|
||||
remote $REPO git@github.com:hyperf-admin/$REPO.git
|
||||
split "src/$REPO" $REPO
|
||||
done
|
||||
|
||||
git pull origin $CURRENT_BRANCH
|
||||
BIN
bin/splitsh-lite
BIN
bin/splitsh-lite
Binary file not shown.
232
composer.json
232
composer.json
@@ -1,104 +1,136 @@
|
||||
{
|
||||
"name": "hyperf-admin/hyperf-admin",
|
||||
"description": "hyperf-admin",
|
||||
"authors": [
|
||||
{
|
||||
"name": "daodao97",
|
||||
"email": "daodao97@foxmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.3",
|
||||
"ext-json": "*",
|
||||
"ext-pdo": "*",
|
||||
"ext-swoole": ">=4.4",
|
||||
"aliyuncs/oss-sdk-php": "^2.3",
|
||||
"box/spout": "^3.1",
|
||||
"hyperf/amqp": "~2.2.0",
|
||||
"hyperf/async-queue": "~2.2.0",
|
||||
"hyperf/cache": "~2.2.0",
|
||||
"hyperf/command": "~2.2.0",
|
||||
"hyperf/config": "~2.2.0",
|
||||
"hyperf/constants": "~2.2.0",
|
||||
"hyperf/crontab": "~2.2.0",
|
||||
"hyperf/database": "~2.2.0",
|
||||
"hyperf/db-connection": "~2.2.0",
|
||||
"hyperf/filesystem": "^2.0",
|
||||
"hyperf/framework": "~2.2.0",
|
||||
"hyperf/guzzle": "~2.2.0",
|
||||
"hyperf/http-server": "~2.2.0",
|
||||
"hyperf/logger": "~2.2.0",
|
||||
"hyperf/memory": "~2.2.0",
|
||||
"hyperf/metric": "~2.2.0",
|
||||
"hyperf/nsq": "~2.2.0",
|
||||
"hyperf/process": "~2.2.0",
|
||||
"hyperf/redis": "~2.2.0",
|
||||
"hyperf/snowflake": "~2.2.0",
|
||||
"hyperf/validation": "~2.2.0",
|
||||
"nette/php-generator": "^3.4",
|
||||
"xxtime/flysystem-aliyun-oss": "^1.5",
|
||||
"yadakhov/insert-on-duplicate-key": "^1.2",
|
||||
"zoujingli/ip2region": "^1.0"
|
||||
"name": "singularity/hyperf-admin",
|
||||
"description": "hyperf-admin",
|
||||
"authors": [
|
||||
{
|
||||
"name": "ch4o5",
|
||||
"email": "dongyun.li@luxcreo.ai"
|
||||
},
|
||||
"replace": {
|
||||
"hyperf-admin/base-utils": "self.version",
|
||||
"hyperf-admin/admin": "self.version",
|
||||
"hyperf-admin/alert-manager": "self.version",
|
||||
"hyperf-admin/cron-center": "self.version",
|
||||
"hyperf-admin/event-bus": "self.version",
|
||||
"hyperf-admin/process-manager": "self.version",
|
||||
"hyperf-admin/rule-engine": "self.version",
|
||||
"hyperf-admin/validation": "self.version",
|
||||
"hyperf-admin/workflow": "self.version",
|
||||
"hyperf-admin/data-focus": "self.version",
|
||||
"hyperf-admin/dev-tools": "self.version"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"HyperfAdmin\\BaseUtils\\": "src/base-utils/src",
|
||||
"HyperfAdmin\\Admin\\": "src/admin/src",
|
||||
"HyperfAdmin\\AlertManager\\": "src/alert-manager/src",
|
||||
"HyperfAdmin\\CronCenter\\": "src/cron-center/src",
|
||||
"HyperfAdmin\\DataFocus\\": "src/data-focus/src",
|
||||
"HyperfAdmin\\DevTools\\": "src/dev-tools/src",
|
||||
"HyperfAdmin\\EventBus\\": "src/event-bus/src",
|
||||
"HyperfAdmin\\ProcessManager\\": "src/process-manager/src",
|
||||
"HyperfAdmin\\RuleEngine\\": "src/rule-engine/src",
|
||||
"HyperfAdmin\\Validation\\": "src/validation/src",
|
||||
"HyperfAdmin\\ConfigCenter\\": "src/config-center/src"
|
||||
},
|
||||
"files": [
|
||||
"src/base-utils/src/Helper/array.php",
|
||||
"src/base-utils/src/Helper/common.php",
|
||||
"src/base-utils/src/Helper/constants.php",
|
||||
"src/base-utils/src/Helper/system.php",
|
||||
"src/data-focus/src/Util/func.php",
|
||||
"src/event-bus/src/funcs.php",
|
||||
"src/admin/src/funcs/common.php",
|
||||
"src/data-focus/src/Util/SimpleHtmlDom.php"
|
||||
],
|
||||
"classmap": [
|
||||
"src/base-utils/src/classmap"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"hyperf": {
|
||||
"config": [
|
||||
"HyperfAdmin\\Admin\\ConfigProvider",
|
||||
"HyperfAdmin\\BaseUtils\\ConfigProvider@99",
|
||||
"HyperfAdmin\\AlertManager\\ConfigProvider",
|
||||
"HyperfAdmin\\CronCenter\\ConfigProvider",
|
||||
"HyperfAdmin\\DataFocus\\ConfigProvider",
|
||||
"HyperfAdmin\\DevTools\\ConfigProvider",
|
||||
"HyperfAdmin\\EventBus\\ConfigProvider",
|
||||
"HyperfAdmin\\ProcessManager\\ConfigProvider",
|
||||
"HyperfAdmin\\ConfigCenter\\ConfigProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
{
|
||||
"name": "daodao97",
|
||||
"email": "daodao97@foxmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.2",
|
||||
"ext-json": "*",
|
||||
"ext-pdo": "*",
|
||||
"ext-swoole": ">=4.4",
|
||||
"aliyuncs/oss-sdk-php": "^2.3",
|
||||
"box/spout": "^3.1",
|
||||
"hyperf/amqp": "3.0.*",
|
||||
"hyperf/async-queue": "3.0.*",
|
||||
"hyperf/cache": "3.0.*",
|
||||
"hyperf/code-generator": "^0.3.3",
|
||||
"hyperf/command": "3.0.*",
|
||||
"hyperf/config": "3.0.*",
|
||||
"hyperf/constants": "3.0.*",
|
||||
"hyperf/crontab": "3.0.*",
|
||||
"hyperf/database": "3.0.*",
|
||||
"hyperf/db-connection": "3.0.*",
|
||||
"hyperf/filesystem": "3.0.*",
|
||||
"hyperf/framework": "3.0.*",
|
||||
"hyperf/guzzle": "3.0.*",
|
||||
"hyperf/http-server": "3.0.*",
|
||||
"hyperf/logger": "3.0.*",
|
||||
"hyperf/memory": "3.0.*",
|
||||
"hyperf/metric": "3.0.*",
|
||||
"hyperf/nsq": "3.0.*",
|
||||
"hyperf/process": "3.0.*",
|
||||
"hyperf/redis": "3.0.*",
|
||||
"hyperf/snowflake": "3.0.*",
|
||||
"hyperf/validation": "3.0.*",
|
||||
"nette/php-generator": "^3.4",
|
||||
"singularity/hdk-core": "^1.0.0",
|
||||
"xxtime/flysystem-aliyun-oss": "~1.5.0",
|
||||
"yadakhov/insert-on-duplicate-key": "^1.2",
|
||||
"zoujingli/ip2region": "^1.0"
|
||||
},
|
||||
"replace": {
|
||||
"hyperf-admin/base-utils": "self.version",
|
||||
"hyperf-admin/admin": "self.version",
|
||||
"hyperf-admin/alert-manager": "self.version",
|
||||
"hyperf-admin/cron-center": "self.version",
|
||||
"hyperf-admin/event-bus": "self.version",
|
||||
"hyperf-admin/process-manager": "self.version",
|
||||
"hyperf-admin/rule-engine": "self.version",
|
||||
"hyperf-admin/validation": "self.version",
|
||||
"hyperf-admin/workflow": "self.version",
|
||||
"hyperf-admin/data-focus": "self.version",
|
||||
"hyperf-admin/dev-tools": "self.version"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"HyperfAdmin\\BaseUtils\\": "src/base-utils/src",
|
||||
"HyperfAdmin\\Admin\\": "src/admin/src",
|
||||
"HyperfAdmin\\AlertManager\\": "src/alert-manager/src",
|
||||
"HyperfAdmin\\CronCenter\\": "src/cron-center/src",
|
||||
"HyperfAdmin\\DataFocus\\": "src/data-focus/src",
|
||||
"HyperfAdmin\\DevTools\\": "src/dev-tools/src",
|
||||
"HyperfAdmin\\EventBus\\": "src/event-bus/src",
|
||||
"HyperfAdmin\\ProcessManager\\": "src/process-manager/src",
|
||||
"HyperfAdmin\\RuleEngine\\": "src/rule-engine/src",
|
||||
"HyperfAdmin\\Validation\\": "src/validation/src",
|
||||
"HyperfAdmin\\ConfigCenter\\": "src/config-center/src"
|
||||
},
|
||||
"files": [
|
||||
"src/base-utils/src/Helper/array.php",
|
||||
"src/base-utils/src/Helper/common.php",
|
||||
"src/base-utils/src/Helper/constants.php",
|
||||
"src/base-utils/src/Helper/system.php",
|
||||
"src/data-focus/src/Util/func.php",
|
||||
"src/event-bus/src/funcs.php",
|
||||
"src/admin/src/funcs/common.php",
|
||||
"src/data-focus/src/Util/SimpleHtmlDom.php"
|
||||
],
|
||||
"classmap": [
|
||||
"src/base-utils/src/classmap"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"hyperf": {
|
||||
"config": [
|
||||
"HyperfAdmin\\Admin\\ConfigProvider",
|
||||
"HyperfAdmin\\BaseUtils\\ConfigProvider@99",
|
||||
"HyperfAdmin\\AlertManager\\ConfigProvider",
|
||||
"HyperfAdmin\\CronCenter\\ConfigProvider",
|
||||
"HyperfAdmin\\DataFocus\\ConfigProvider",
|
||||
"HyperfAdmin\\DevTools\\ConfigProvider",
|
||||
"HyperfAdmin\\EventBus\\ConfigProvider",
|
||||
"HyperfAdmin\\ProcessManager\\ConfigProvider",
|
||||
"HyperfAdmin\\ConfigCenter\\ConfigProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"config": {
|
||||
"sort-packages": true,
|
||||
"secure-http": false
|
||||
},
|
||||
"scripts": {
|
||||
"post-root-package-install": [],
|
||||
"test": "vendor/bin/pest $1",
|
||||
"cs-fix": "vendor/bin/php-cs-fixer fix $1 --rules=@PSR12 --allow-risky=yes",
|
||||
"analyse": "vendor/bin/phpstan analyse $1",
|
||||
"ci": [
|
||||
"@analyse publish/ src/ tests/",
|
||||
"@cs-fix",
|
||||
"@test --ci",
|
||||
"echo CI Success"
|
||||
]
|
||||
},
|
||||
"repositories": {
|
||||
"nest": {
|
||||
"type": "composer",
|
||||
"url": "https://nest.doylee.cn/api/packages/HDK/composer"
|
||||
},
|
||||
"packagist": {
|
||||
"type": "composer",
|
||||
"url": "https://mirrors.aliyun.com/composer/"
|
||||
}
|
||||
},
|
||||
"version": "0.5.1",
|
||||
"require-dev": {
|
||||
"rector/rector": "^2.0"
|
||||
}
|
||||
}
|
||||
|
||||
10129
composer.lock
generated
Normal file
10129
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
128
guide.md
Normal file
128
guide.md
Normal file
@@ -0,0 +1,128 @@
|
||||
# PHP Package boilerplate project explanation
|
||||
|
||||
PHP is a general-purpose server-side scripting language primarily used in web development. Originally created by Rasmus Lerdorf in 1994, it is now by The PHP Development Team.
|
||||
|
||||
PHP originally stood for "Personal Home Page", but now stands for "PHP: Hypertext Preprocessor".
|
||||
|
||||
## Further Material
|
||||
|
||||
- Homepage: [php.net](https://secure.php.net/)
|
||||
- Documentation: [php.net/docs.php](https://secure.php.net/docs.php)
|
||||
- PHP: The Right Way: [phptherightway.com](http://www.phptherightway.com/)
|
||||
- Interactive PHP Tutorial: [learn-php.org](http://www.learn-php.org/)
|
||||
|
||||
## Topics, Tools and Terms
|
||||
|
||||
PHP packages were traditionally installed via PEAR (PHP Extension and Application Repository), but more recently the standard package and dependency management tool is Composer.
|
||||
|
||||
Composer lets us run install commands to add packages to our system, for example `composer require phpunit` would add the unit testing framework PHPUnit to our system.
|
||||
|
||||
For instructions on how to install Composer visit [getcomposer.org](https://getcomposer.org/download/).
|
||||
|
||||
### Dependency Management
|
||||
|
||||
Managing dependencies manually is time-consuming, fortunately Composer can automate this.
|
||||
|
||||
We can list our dependencies in a `composer.json` file and run `composer install` to bring these into our project.
|
||||
|
||||
An example `composer.json` file looks like this:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "example-project",
|
||||
"require": {
|
||||
"twig/twig": "^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^8.4"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The "require" block tells Composer that the Twig templating package is required for production use and can install Twig with a version of 3.x.x (ie. up to, but not including, version 4).
|
||||
|
||||
The "require-dev" block tells Composer that PHPUnit is required in development, but not in production.
|
||||
|
||||
Dependencies can be added to `composer.json` by
|
||||
|
||||
```bash
|
||||
composer require author/package-name
|
||||
```
|
||||
|
||||
Development dependencies can be added by
|
||||
|
||||
```bash
|
||||
composer require author/package-name --dev
|
||||
```
|
||||
|
||||
Dependencies can be updated to their latest maximum version by running
|
||||
|
||||
```bash
|
||||
composer update
|
||||
```
|
||||
|
||||
Composer will also generate a `composer.lock` file on each `composer update` and the initial `composer install`. This is not meant to be edited directly, it tells Composer to use specific versions of packages - particularly useful when hyhou want your development dependencies to match what you will push to production.
|
||||
|
||||
### Testing Tools
|
||||
|
||||
There are a number of testing tools available for PHP. The most popular one is [PHPUnit](https://phpunit.de/). PHPUnit follows the classic xUnit approach.
|
||||
|
||||
[Behat](http://behat.org/en/latest/) is the most popular behaviour-driven development (BDD) testing framework.
|
||||
|
||||
[Codeception](http://codeception.com/) is a framework combining BDD, unit testing, and integration testing, and is cross-compatible with PHPUnit.
|
||||
|
||||
In this guide we will be using PHPUnit as the testing framework.
|
||||
|
||||
## Directory Structure
|
||||
|
||||
A typical directory structure for a PHP project consists of a `src` directory that contains all source files and a `tests` directory that includes all tests. For web applications the publicly accessible files (eg. `index.php`) would reside in a `public` directory which would then be your webservers document root.
|
||||
|
||||
Another common convention is having a `bin` directory that may contain executable files to start your application.
|
||||
|
||||
- src/
|
||||
- test/
|
||||
- public/
|
||||
- composer.json
|
||||
- composer.lock
|
||||
|
||||
### Naming Conventions
|
||||
|
||||
Directory names are in lower case. Class and interface files should be in upper case and match the class or interface names.
|
||||
Configuration, routes, and publicly accessible files should be in lower case.
|
||||
|
||||
For example the class `Example` should be contained in file `Example.php`, the publicly accessible route to the application should be `index.php`.
|
||||
|
||||
Tests match their production code file names with a `Test` suffix, e.g. tests for code in `src/Example.php` should be written in `test/ExampleTest.php`.
|
||||
|
||||
## Example Project
|
||||
|
||||
The main application consists of basically two files:
|
||||
|
||||
- `public/example.php` is the main executable that instantiates and runs:
|
||||
- `src/Example/Greeting.php` contains the main application.
|
||||
|
||||
### Running the Tests
|
||||
|
||||
All tests can be run by executing
|
||||
|
||||
```bash
|
||||
vendor/phpunit/phpunit/phpunit
|
||||
```
|
||||
|
||||
`phpunit` will automatically find all tests inside the `test` directory and run them based on the configuration in the `phpunit.xml` file.
|
||||
|
||||
#### Testing Approach
|
||||
|
||||
The test for the class `Greeting` verifies that the return value of the `sayHello` method returns the string "Hello {name}", where {name} is the value passed through to the constructor.
|
||||
|
||||
### Running the Application
|
||||
|
||||
PHP has an in-built server for local development. To run this change into the directory `public` and run
|
||||
|
||||
```bash
|
||||
php -S localhost:8000
|
||||
```
|
||||
|
||||
Then open your browser at `http://localhost:8000/example.php`
|
||||
|
||||
You should see the text "Hello Ada Lovelace" being printed.
|
||||
13
phpstan.dist.neon
Normal file
13
phpstan.dist.neon
Normal file
@@ -0,0 +1,13 @@
|
||||
parameters:
|
||||
level: 6
|
||||
reportUnmatchedIgnoredErrors: false
|
||||
checkGenericClassInNonGenericObjectType: false
|
||||
paths:
|
||||
- publish
|
||||
- src
|
||||
- tests
|
||||
ignoreErrors:
|
||||
- '#Constant BASE_PATH not found#'
|
||||
- '#Property [a-zA-Z0-9\\_]+::\$[a-zA-Z0-9]+ is never written, only read\.#'
|
||||
- '#Method [a-zA-Z0-9\\_]+::[a-zA-Z0-9]+\(\) is unused\.#'
|
||||
- '#Method [a-zA-Z0-9\\_]+::[a-zA-Z0-9]+\(\) has parameter \$response with no value type specified in iterable type array\.#'
|
||||
10
phpunit.xml
Normal file
10
phpunit.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php"
|
||||
colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd">
|
||||
<coverage/>
|
||||
<testsuites>
|
||||
<testsuite name="Unit">
|
||||
<directory>./tests/Unit/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
30
rector.php
Normal file
30
rector.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// rector.php
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Set\ValueObject\LevelSetList;
|
||||
use Rector\Set\ValueObject\SetList;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
// 1. 定义需要扫描的文件/目录
|
||||
$rectorConfig->paths([
|
||||
__DIR__ . '/src', // 替换为你项目代码的路径,例如:/app, /backend 等
|
||||
// __DIR__ . '/tests', // 如果你想升级测试代码,也加入
|
||||
]);
|
||||
|
||||
// 2. 一次性应用所有规则到 PHP 8.2 (推荐用于大型升级)
|
||||
$rectorConfig->sets([
|
||||
// 这将包含从 7.4 到 8.1 的所有升级规则,以及 8.2 的所有新规则
|
||||
LevelSetList::UP_TO_PHP_82,
|
||||
// 建议同时加入一些代码质量改进的规则
|
||||
SetList::DEAD_CODE, // 移除无用代码
|
||||
]);
|
||||
|
||||
// 可选:跳过某些文件或规则
|
||||
// $rectorConfig->skip([
|
||||
// // 例如:跳过特定文件
|
||||
// // __DIR__ . '/src/Legacy/old_file.php',
|
||||
// ]);
|
||||
};
|
||||
10
scripts/docker-env.sh
Executable file
10
scripts/docker-env.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
docker run \
|
||||
--pull always \
|
||||
-ti --rm --name "hdk-admin" \
|
||||
-w "/srv/www" \
|
||||
-v "$(pwd)":/srv/www \
|
||||
-v ~/.ssh:/root/.ssh \
|
||||
-v ~/.gitconfig:/root/.gitconfig \
|
||||
harbor.luxcreo.cn/library/hyperf:8.2-swoole /bin/ash
|
||||
5
scripts/release.sh
Executable file
5
scripts/release.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
docker run --rm -it \
|
||||
-v $(pwd):/app -e "GIT_AUTHOR_NAME=$(git config user.name)" -e "EMAIL=$(git config user.email)" \
|
||||
detouched/standard-version:latest $1
|
||||
28
src/admin/.gitea/workflows/publish_on_tagged.yml
Normal file
28
src/admin/.gitea/workflows/publish_on_tagged.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
name: Release development version to registry
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '**.**'
|
||||
|
||||
jobs:
|
||||
Publish on Tagged:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||
- name: List files in the repository
|
||||
run: |
|
||||
ls ${{ gitea.workspace }}
|
||||
- name: Zip files in the repository
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install zip
|
||||
zip -r dist.zip *
|
||||
- name: Publish to registry
|
||||
run: |
|
||||
curl --user ch4o5:4fd300672472e666014314c1c94c604c634165a9 \
|
||||
--upload-file ./dist.zip \
|
||||
https://nest.doylee.cn/api/packages/HDK/composer?version=${{ gitea.ref_name }}
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||
68
src/admin/.versionrc
Normal file
68
src/admin/.versionrc
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"header": "# 版本更新日志",
|
||||
"preMajor": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "feat",
|
||||
"section": "✨ Features | 新功能"
|
||||
},
|
||||
{
|
||||
"type": "fix",
|
||||
"section": "🐛 Bug Fixes | Bug 修复"
|
||||
},
|
||||
{
|
||||
"type": "init",
|
||||
"section": "🎉 Init | 初始化"
|
||||
},
|
||||
{
|
||||
"type": "docs",
|
||||
"section": "✏️ Documentation | 文档"
|
||||
},
|
||||
{
|
||||
"type": "style",
|
||||
"section": "💄 Styles | 风格"
|
||||
},
|
||||
{
|
||||
"type": "refactor",
|
||||
"section": "♻️ Code Refactoring | 代码重构"
|
||||
},
|
||||
{
|
||||
"type": "perf",
|
||||
"section": "⚡ Performance Improvements | 性能优化"
|
||||
},
|
||||
{
|
||||
"type": "tests",
|
||||
"section": "✅ Tests | 测试"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"section": "✅ Tests | 测试"
|
||||
},
|
||||
{
|
||||
"type": "revert",
|
||||
"section": "⏪ Revert | 回退"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"section": "📦 Build System | 打包构建"
|
||||
},
|
||||
{
|
||||
"type": "chore",
|
||||
"section": "🚀 Chore | 构建/工程依赖/工具"
|
||||
},
|
||||
{
|
||||
"type": "ci",
|
||||
"section": "👷 Continuous Integration | CI 配置"
|
||||
}
|
||||
],
|
||||
"bumpFiles": [
|
||||
{
|
||||
"filename": "VERSION_TRACKER.txt",
|
||||
"type": "plain-text"
|
||||
},
|
||||
{
|
||||
"filename": "composer.json",
|
||||
"type": "json"
|
||||
}
|
||||
]
|
||||
}
|
||||
0
src/admin/README.md
Normal file → Executable file
0
src/admin/README.md
Normal file → Executable file
4
src/admin/composer.json
Normal file → Executable file
4
src/admin/composer.json
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "hyperf-admin/admin",
|
||||
"name": "hdk/hdk-admin",
|
||||
"type": "project",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
@@ -28,4 +28,4 @@
|
||||
"config": "HyperfAdmin\\Admin\\ConfigProvider"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
9
src/admin/scripts/docker-env.sh
Executable file
9
src/admin/scripts/docker-env.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
docker run \
|
||||
--pull always \
|
||||
-ti --rm --name "hdk-admin" \
|
||||
-w "/srv/www" \
|
||||
-v "$(pwd)":/srv/www \
|
||||
-v ~/.ssh:/root/.ssh \
|
||||
harbor.luxcreo.cn/library/hyperf:7.4-swoole /bin/ash
|
||||
5
src/admin/scripts/release.sh
Executable file
5
src/admin/scripts/release.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
docker run --rm -it \
|
||||
-v $(pwd):/app -e "GIT_AUTHOR_NAME=ch4o5" -e "EMAIL=li_dongyun@outlook.com" \
|
||||
detouched/standard-version:latest $1
|
||||
0
src/admin/src/ConfigProvider.php
Normal file → Executable file
0
src/admin/src/ConfigProvider.php
Normal file → Executable file
5
src/admin/src/Controller/AdminAbstractController.php
Normal file → Executable file
5
src/admin/src/Controller/AdminAbstractController.php
Normal file → Executable file
@@ -36,7 +36,7 @@ abstract class AdminAbstractController extends AbstractController
|
||||
public function getRecordHistory()
|
||||
{
|
||||
$history_versions = $this->getEntity()->lastVersion($this->previous_version_number);
|
||||
$history_versions = array_node_append($history_versions, 'user_id', 'username', function ($uids) {
|
||||
return array_node_append($history_versions, 'user_id', 'username', function ($uids) {
|
||||
$ret = User::query()->select(['id', 'username'])->whereIn('id', $uids)->get();
|
||||
if (!$ret) {
|
||||
return [];
|
||||
@@ -49,14 +49,11 @@ abstract class AdminAbstractController extends AbstractController
|
||||
}
|
||||
return $ret;
|
||||
});
|
||||
return $history_versions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新版本检查
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $last_ver_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
||||
0
src/admin/src/Controller/CommonConfigController.php
Normal file → Executable file
0
src/admin/src/Controller/CommonConfigController.php
Normal file → Executable file
4
src/admin/src/Controller/LogController.php
Normal file → Executable file
4
src/admin/src/Controller/LogController.php
Normal file → Executable file
@@ -94,7 +94,7 @@ class LogController extends AdminAbstractController
|
||||
'width' => '480px',
|
||||
'render' => function ($field, $row) {
|
||||
if (!is_array($row['detail_json'])) {
|
||||
$row['detail_json'] = json_decode($row['detail_json'], true);
|
||||
$row['detail_json'] = json_decode((string) $row['detail_json'], true);
|
||||
}
|
||||
|
||||
return $row['detail_json']['description'] ?? '';
|
||||
@@ -112,7 +112,7 @@ class LogController extends AdminAbstractController
|
||||
'width' => '200px',
|
||||
'render' => function ($field, $row) {
|
||||
if (!is_array($row['detail_json'])) {
|
||||
$row['detail_json'] = json_decode($row['detail_json'], true);
|
||||
$row['detail_json'] = json_decode((string) $row['detail_json'], true);
|
||||
}
|
||||
|
||||
return $row['detail_json']['remark'] ?? '';
|
||||
|
||||
28
src/admin/src/Controller/MenuController.php
Normal file → Executable file
28
src/admin/src/Controller/MenuController.php
Normal file → Executable file
@@ -201,7 +201,7 @@ class MenuController extends AdminAbstractController
|
||||
],
|
||||
'permission|权限标识' => [
|
||||
'type' => 'select',
|
||||
'default' => [],
|
||||
'default' => '',
|
||||
'props' => [
|
||||
'multiple' => true,
|
||||
'selectApi' => '/system/routes?module={module}'
|
||||
@@ -252,13 +252,11 @@ class MenuController extends AdminAbstractController
|
||||
'tabs' => function() {
|
||||
$conf = \HyperfAdmin\Admin\Service\CommonConfig::getValByName('website_config');
|
||||
$system_module = $conf['system_module'] ?? [];
|
||||
return array_map(function ($item) {
|
||||
return [
|
||||
'label' => $item['label'],
|
||||
'value' => $item['name'],
|
||||
'icon' => $item['icon']
|
||||
];
|
||||
}, $system_module);
|
||||
return array_map(fn($item) => [
|
||||
'label' => $item['label'],
|
||||
'value' => $item['name'],
|
||||
'icon' => $item['icon']
|
||||
], $system_module);
|
||||
},
|
||||
'rowActions' => [
|
||||
[
|
||||
@@ -382,9 +380,9 @@ class MenuController extends AdminAbstractController
|
||||
}
|
||||
|
||||
return $item;
|
||||
}, array_filter(explode(',', $record['permission'])));
|
||||
}, array_filter(explode(',', (string) $record['permission'])));
|
||||
}
|
||||
$scaffold_action = json_decode($record['scaffold_action'], true);
|
||||
$scaffold_action = json_decode((string) $record['scaffold_action'], true);
|
||||
$record['scaffold_action'] = $scaffold_action ? array_keys($scaffold_action) : [];
|
||||
$record['pid'] = (new Menu())->getPathNodeIds($id);
|
||||
}
|
||||
@@ -395,7 +393,7 @@ class MenuController extends AdminAbstractController
|
||||
if ($data['path'] == '#' || $data['path'] == '') {
|
||||
$this->exception('菜单路由地址不能为空或"#"', ErrorCode::CODE_ERR_PARAM);
|
||||
}
|
||||
$paths = array_filter(explode('/', $data['path']));
|
||||
$paths = array_filter(explode('/', (string) $data['path']));
|
||||
if (count($paths) > 5) {
|
||||
$this->exception('路由地址层级过深>5,请设置精简一些', ErrorCode::CODE_ERR_PARAM);
|
||||
}
|
||||
@@ -423,14 +421,14 @@ class MenuController extends AdminAbstractController
|
||||
protected function afterSave($pk_val, $data, $entity)
|
||||
{
|
||||
// 更新预置的脚手架权限
|
||||
$scaffold_action = json_decode($entity->scaffold_action, true);
|
||||
$scaffold_action = json_decode((string) $entity->scaffold_action, true);
|
||||
$action_keys = $scaffold_action ? array_keys($scaffold_action) : [];
|
||||
$need_del_ids = $scaffold_action ? array_values($scaffold_action) : [];
|
||||
$router_ids = [];
|
||||
if (!empty($data['scaffold_action'])) {
|
||||
$need_del_ids = collect($scaffold_action)->except($data['scaffold_action'])->values()->toArray();
|
||||
$scaffold_action = collect($scaffold_action)->only($data['scaffold_action'])->toArray();
|
||||
$paths = array_filter(explode('/', $data['path']));
|
||||
$paths = array_filter(explode('/', (string) $data['path']));
|
||||
array_pop($paths);
|
||||
$prefix = implode('/', $paths);
|
||||
foreach ($data['scaffold_action'] as $k => $action) {
|
||||
@@ -530,7 +528,7 @@ class MenuController extends AdminAbstractController
|
||||
$route_list = $routes;
|
||||
}
|
||||
foreach ($route_list as $route => $v) {
|
||||
$route = is_string($route) ? rtrim($route) : rtrim($v[0]->route);
|
||||
$route = is_string($route) ? rtrim($route) : rtrim((string) $v[0]->route);
|
||||
$route_key = "$http_method::{$route}";
|
||||
if (in_array($route_key, $conf)) {
|
||||
continue;
|
||||
@@ -555,7 +553,7 @@ class MenuController extends AdminAbstractController
|
||||
}
|
||||
$right_options = [];
|
||||
foreach ($conf as $route) {
|
||||
[$http_method, $uri] = explode("::", $route, 2);
|
||||
[$http_method, $uri] = explode("::", (string) $route, 2);
|
||||
$dispatcher = container(DispatcherFactory::class)->getDispatcher('http');
|
||||
$route_info = $dispatcher->dispatch($http_method, $uri);
|
||||
if (!empty($route_info[1]->callback[0])) {
|
||||
|
||||
2
src/admin/src/Controller/RoleController.php
Normal file → Executable file
2
src/admin/src/Controller/RoleController.php
Normal file → Executable file
@@ -132,7 +132,7 @@ class RoleController extends AdminAbstractController
|
||||
|
||||
protected function afterSave($pk_val, $data)
|
||||
{
|
||||
$data['permissions'] = json_decode($data['permissions'], true);
|
||||
$data['permissions'] = json_decode((string) $data['permissions'], true);
|
||||
if (empty($data['permissions'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
8
src/admin/src/Controller/SystemController.php
Normal file → Executable file
8
src/admin/src/Controller/SystemController.php
Normal file → Executable file
@@ -29,9 +29,7 @@ class SystemController extends AdminAbstractController
|
||||
if (isset($config['system_module']) && !$this->auth_service->isSupperAdmin()) {
|
||||
$user_id = $this->auth_service->get('id');
|
||||
$modules = $this->permission_service->getModules($user_id);
|
||||
$config['system_module'] = array_filter($config['system_module'], function ($item) use ($modules) {
|
||||
return in_array($item['name'], $modules);
|
||||
});
|
||||
$config['system_module'] = array_filter($config['system_module'], fn($item) => in_array($item['name'], $modules));
|
||||
}
|
||||
|
||||
return $this->success($config);
|
||||
@@ -46,9 +44,7 @@ class SystemController extends AdminAbstractController
|
||||
|
||||
$kw = $this->request->input('kw', '');
|
||||
$routes = $this->permission_service->getSystemRouteOptions();
|
||||
$routes = array_filter($routes, function ($item) use ($kw) {
|
||||
return Str::contains($item['value'], $kw);
|
||||
});
|
||||
$routes = array_filter($routes, fn($item) => Str::contains($item['value'], $kw));
|
||||
return $this->success(array_values($routes));
|
||||
}
|
||||
|
||||
|
||||
0
src/admin/src/Controller/UploadController.php
Normal file → Executable file
0
src/admin/src/Controller/UploadController.php
Normal file → Executable file
20
src/admin/src/Controller/UserController.php
Normal file → Executable file
20
src/admin/src/Controller/UserController.php
Normal file → Executable file
@@ -90,9 +90,7 @@ class UserController extends AdminAbstractController
|
||||
'type' => 'date_range',
|
||||
],
|
||||
],
|
||||
'hasOne' => function ($field, $row) {
|
||||
return 'hyperf_admin.'.env('HYPERF_ADMIN_DB_NAME').'.user_role:user_id,role_id';
|
||||
},
|
||||
'hasOne' => fn($field, $row) => 'hyperf_admin.'.env('HYPERF_ADMIN_DB_NAME').'.user_role:user_id,role_id',
|
||||
'table' => [
|
||||
'columns' => [
|
||||
'id',
|
||||
@@ -100,9 +98,7 @@ class UserController extends AdminAbstractController
|
||||
'username',
|
||||
[
|
||||
'field' => 'mobile',
|
||||
'render' => function ($field, $row) {
|
||||
return data_desensitization($field, 3, 4);
|
||||
},
|
||||
'render' => fn($field, $row) => data_desensitization($field, 3, 4),
|
||||
],
|
||||
['field' => 'avatar', 'render' => 'avatarRender'],
|
||||
'email',
|
||||
@@ -205,10 +201,10 @@ class UserController extends AdminAbstractController
|
||||
}
|
||||
$user = $this->getModel()->where('username', $username)->first();
|
||||
if (!$user || $user['status'] !== YES) {
|
||||
return $this->fail(ErrorCode::CODE_ERR_PARAM, '该用户不存在或已被禁用');
|
||||
return $this->fail(ErrorCode::CODE_ERR_PARAM, 'Incorrect or invalid username');
|
||||
}
|
||||
if ($user->password !== $this->passwordHash($password)) {
|
||||
return $this->fail(ErrorCode::CODE_ERR_PARAM);
|
||||
return $this->fail(ErrorCode::CODE_ERR_PARAM, 'Incorrect password');
|
||||
}
|
||||
$data = [
|
||||
'iat' => Carbon::now()->timestamp,
|
||||
@@ -235,12 +231,12 @@ class UserController extends AdminAbstractController
|
||||
|
||||
public function passwordHash($password)
|
||||
{
|
||||
return sha1(md5($password) . md5(config('password.salt')));
|
||||
return sha1(md5((string) $password) . md5((string) config('password.salt')));
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
$user = $this->auth_service->logout();
|
||||
$this->auth_service->logout();
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
@@ -259,9 +255,7 @@ class UserController extends AdminAbstractController
|
||||
$task = new ExportTasks();
|
||||
$task->name = $this->request->input('name');
|
||||
$task->list_api = $url;
|
||||
$task->filters = array_filter($this->request->input('filters'), function ($item) {
|
||||
return $item !== '';
|
||||
});
|
||||
$task->filters = array_filter($this->request->input('filters'), fn($item) => $item !== '');
|
||||
$task->operator_id = $this->userId() ?? 0;
|
||||
if ((new ExportService())->getFirstSameTask($task->list_api, $task->filters, $task->operator_id)) { // 如果当天已经有相同过滤条件且还未成功生成文件的任务
|
||||
return $this->success([], '已经有相同的任务,请勿重复导出');
|
||||
|
||||
0
src/admin/src/Crontab/ExportTask.php
Normal file → Executable file
0
src/admin/src/Crontab/ExportTask.php
Normal file → Executable file
2
src/admin/src/Install/InstallCommand.php
Normal file → Executable file
2
src/admin/src/Install/InstallCommand.php
Normal file → Executable file
@@ -22,7 +22,7 @@ class InstallCommand extends HyperfCommand
|
||||
|
||||
$sql = file_get_contents(__DIR__ . '/install.sql');
|
||||
|
||||
$re = Db::connection('hyperf_admin')->getPdo()->exec($sql);
|
||||
Db::connection('hyperf_admin')->getPdo()->exec($sql);
|
||||
|
||||
$this->output->success('hyperf-admin db install success');
|
||||
}
|
||||
|
||||
2
src/admin/src/Install/UpdateCommand.php
Normal file → Executable file
2
src/admin/src/Install/UpdateCommand.php
Normal file → Executable file
@@ -36,7 +36,7 @@ class UpdateCommand extends HyperfCommand
|
||||
|
||||
$sql = file_get_contents($update_sql_file);
|
||||
|
||||
$re = Db::connection('hyperf_admin')->getPdo()->exec($sql);
|
||||
Db::connection('hyperf_admin')->getPdo()->exec($sql);
|
||||
|
||||
$this->output->success('hyperf-admin db update success');
|
||||
|
||||
|
||||
2
src/admin/src/Install/install.sql
Normal file → Executable file
2
src/admin/src/Install/install.sql
Normal file → Executable file
@@ -56,7 +56,7 @@ CREATE TABLE `front_routes` (
|
||||
`scaffold_action` varchar(255) NOT NULL DEFAULT '' COMMENT '脚手架预置权限',
|
||||
`config` text COMMENT '配置化脚手架',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=90 DEFAULT CHARSET=utf8mb4 COMMENT='前端路由(菜单)';;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=90 DEFAULT CHARSET=utf8mb4 COMMENT='前端路由(菜单)';
|
||||
|
||||
CREATE TABLE `global_config` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
|
||||
0
src/admin/src/Middleware/AuthMiddleware.php
Normal file → Executable file
0
src/admin/src/Middleware/AuthMiddleware.php
Normal file → Executable file
4
src/admin/src/Middleware/PermissionMiddleware.php
Normal file → Executable file
4
src/admin/src/Middleware/PermissionMiddleware.php
Normal file → Executable file
@@ -116,8 +116,6 @@ class PermissionMiddleware extends CoreMiddleware
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $code
|
||||
* @param string|null $message
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
@@ -152,7 +150,7 @@ class PermissionMiddleware extends CoreMiddleware
|
||||
} else {
|
||||
$body = '';
|
||||
}
|
||||
$ak = str_replace('ha ', '', explode(':', $client_token)[0] ?? '');
|
||||
$ak = str_replace('ha ', '', explode(':', (string) $client_token)[0] ?? '');
|
||||
$sk = config('client_user')[$ak] ?? '';
|
||||
$auth = new AKSK($ak, $sk);
|
||||
$token = $auth->token($method, $path, $host, $query, $content_type, $body);
|
||||
|
||||
0
src/admin/src/Model/CommonConfig.php
Normal file → Executable file
0
src/admin/src/Model/CommonConfig.php
Normal file → Executable file
0
src/admin/src/Model/ExportTasks.php
Normal file → Executable file
0
src/admin/src/Model/ExportTasks.php
Normal file → Executable file
0
src/admin/src/Model/FrontRoutes.php
Normal file → Executable file
0
src/admin/src/Model/FrontRoutes.php
Normal file → Executable file
6
src/admin/src/Model/GlobalConfig.php
Normal file → Executable file
6
src/admin/src/Model/GlobalConfig.php
Normal file → Executable file
@@ -57,7 +57,7 @@ class GlobalConfig extends BaseModel
|
||||
if(empty($item)) {
|
||||
return $default;
|
||||
}
|
||||
$config = json_decode($item[0]['value'], true);
|
||||
$config = json_decode((string) $item[0]['value'], true);
|
||||
if(is_null($config)) {
|
||||
return $default;
|
||||
}
|
||||
@@ -76,8 +76,8 @@ class GlobalConfig extends BaseModel
|
||||
public static function setConfig($name, $value, $ext = [], $raw = true)
|
||||
{
|
||||
$namespace = '';
|
||||
if(($pos = strpos($name, '.')) !== false) {
|
||||
$namespace = substr($name, 0, $pos);
|
||||
if(($pos = strpos((string) $name, '.')) !== false) {
|
||||
$namespace = substr((string) $name, 0, $pos);
|
||||
}
|
||||
if($raw) {
|
||||
$value = json_encode($value);
|
||||
|
||||
0
src/admin/src/Model/OperatorLog.php
Normal file → Executable file
0
src/admin/src/Model/OperatorLog.php
Normal file → Executable file
0
src/admin/src/Model/RequestLog.php
Normal file → Executable file
0
src/admin/src/Model/RequestLog.php
Normal file → Executable file
0
src/admin/src/Model/Role.php
Normal file → Executable file
0
src/admin/src/Model/Role.php
Normal file → Executable file
0
src/admin/src/Model/RoleMenu.php
Normal file → Executable file
0
src/admin/src/Model/RoleMenu.php
Normal file → Executable file
2
src/admin/src/Model/User.php
Normal file → Executable file
2
src/admin/src/Model/User.php
Normal file → Executable file
@@ -70,7 +70,7 @@ class User extends BaseModel
|
||||
|
||||
public function getRolesAttribute($value)
|
||||
{
|
||||
return explode(',', $value);
|
||||
return explode(',', (string) $value);
|
||||
}
|
||||
|
||||
public function setRolesAttribute($value)
|
||||
|
||||
0
src/admin/src/Model/UserRole.php
Normal file → Executable file
0
src/admin/src/Model/UserRole.php
Normal file → Executable file
0
src/admin/src/Model/Version.php
Normal file → Executable file
0
src/admin/src/Model/Version.php
Normal file → Executable file
9
src/admin/src/Model/Versionable.php
Normal file → Executable file
9
src/admin/src/Model/Versionable.php
Normal file → Executable file
@@ -53,7 +53,7 @@ trait Versionable
|
||||
|
||||
public function getMorphClass()
|
||||
{
|
||||
if (strpos($this->getTable(), '.') !== false) {
|
||||
if (str_contains($this->getTable(), '.')) {
|
||||
return $this->getTable();
|
||||
}
|
||||
return $this->getConnectionName() . '.' . $this->getTable();
|
||||
@@ -89,8 +89,6 @@ trait Versionable
|
||||
|
||||
/**
|
||||
* 监听saved事件保存表更数据
|
||||
*
|
||||
* @param Saved $event
|
||||
*/
|
||||
public function saved(Saved $event)
|
||||
{
|
||||
@@ -119,8 +117,6 @@ trait Versionable
|
||||
|
||||
/**
|
||||
* 记录数据版本前先记录请求
|
||||
*
|
||||
* @return RequestLog
|
||||
*/
|
||||
private function processRequest(): RequestLog
|
||||
{
|
||||
@@ -152,7 +148,7 @@ trait Versionable
|
||||
{
|
||||
$keep = $this->keep_version_count ?? 100;
|
||||
$count = $this->versions()->count();
|
||||
if ($keep > 0 && $count > $keep) {
|
||||
if ($count > $keep) {
|
||||
$this->versions()->limit($count - $keep)->delete();
|
||||
}
|
||||
}
|
||||
@@ -170,7 +166,6 @@ trait Versionable
|
||||
/**
|
||||
* 前几个版本
|
||||
*
|
||||
* @param int $previous
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
0
src/admin/src/Service/AuthService.php
Normal file → Executable file
0
src/admin/src/Service/AuthService.php
Normal file → Executable file
0
src/admin/src/Service/CommonConfig.php
Normal file → Executable file
0
src/admin/src/Service/CommonConfig.php
Normal file → Executable file
9
src/admin/src/Service/ExportService.php
Normal file → Executable file
9
src/admin/src/Service/ExportService.php
Normal file → Executable file
@@ -80,7 +80,7 @@ class ExportService
|
||||
}
|
||||
$task->fill(['status' => ExportTasks::STATUS_PROCESSING])->save();
|
||||
$list_api = 'http://127.0.0.1:' . config('server.servers.0.port') . $task->list_api;
|
||||
$query['_page'] = ($query['_page'] ?? 1);
|
||||
$query['_page'] ??= 1;
|
||||
$size = 100;
|
||||
$query['_size'] = $size;
|
||||
$query = array_merge($query, $task->filters);
|
||||
@@ -95,9 +95,7 @@ class ExportService
|
||||
$info_api = 'http://127.0.0.1:' . config('server.servers.0.port') . '/' . $subject . '/info';
|
||||
}
|
||||
$info = Guzzle::get($info_api, [], $headers);
|
||||
$table_headers = array_filter($info['payload']['tableHeader'], function ($item) {
|
||||
return $item['hidden'] ?? true;
|
||||
});
|
||||
$table_headers = array_filter($info['payload']['tableHeader'], fn($item) => $item['hidden'] ?? true);
|
||||
$table_headers_str = [];
|
||||
foreach($table_headers as $item) {
|
||||
$table_headers_str[] = $item['title'];
|
||||
@@ -166,9 +164,8 @@ class ExportService
|
||||
}
|
||||
$arr = array_map(function ($item) {
|
||||
$item = csv_big_num($item);
|
||||
$item = preg_replace('/\\n/', ' ', $item);
|
||||
|
||||
return $item;
|
||||
return preg_replace('/\\n/', ' ', (string) $item);
|
||||
}, $arr);
|
||||
|
||||
return implode(',', array_map(function ($item) {
|
||||
|
||||
4
src/admin/src/Service/GlobalConfig.php
Normal file → Executable file
4
src/admin/src/Service/GlobalConfig.php
Normal file → Executable file
@@ -9,8 +9,8 @@ class GlobalConfig
|
||||
public static function setConfig($name, $value, $ext = [], $raw = true)
|
||||
{
|
||||
$namespace = '';
|
||||
if(($pos = strpos($name, '.')) !== false) {
|
||||
$namespace = substr($name, 0, $pos);
|
||||
if(($pos = strpos((string) $name, '.')) !== false) {
|
||||
$namespace = substr((string) $name, 0, $pos);
|
||||
}
|
||||
if($raw) {
|
||||
$value = json_encode($value);
|
||||
|
||||
6
src/admin/src/Service/Menu.php
Normal file → Executable file
6
src/admin/src/Service/Menu.php
Normal file → Executable file
@@ -14,11 +14,7 @@ class Menu
|
||||
{
|
||||
$query = $this->query();
|
||||
if (!empty($menu_ids)) {
|
||||
$query->where(function ($query) use ($menu_ids) {
|
||||
return $query->whereIn('id', $menu_ids)->orWhere(function ($query) use ($menu_ids) {
|
||||
return $query->where('is_menu', 0)->whereIn('pid', $menu_ids);
|
||||
});
|
||||
});
|
||||
$query->where(fn($query) => $query->whereIn('id', $menu_ids)->orWhere(fn($query) => $query->where('is_menu', 0)->whereIn('pid', $menu_ids)));
|
||||
}
|
||||
$query = $query->select([
|
||||
'id',
|
||||
|
||||
0
src/admin/src/Service/ModuleProxy.php
Normal file → Executable file
0
src/admin/src/Service/ModuleProxy.php
Normal file → Executable file
4
src/admin/src/Service/OperatorLogService.php
Normal file → Executable file
4
src/admin/src/Service/OperatorLogService.php
Normal file → Executable file
@@ -31,11 +31,11 @@ class OperatorLogService
|
||||
try {
|
||||
// 页面url和名称
|
||||
$page_url = request()->header('page-url');
|
||||
$parse_url = parse_url($page_url);
|
||||
$parse_url = parse_url((string) $page_url);
|
||||
$fragment = $parse_url['fragment'] ?? '/'; // 抽出#后面的部分
|
||||
$fragments = explode('?', $fragment); // 去掉querystring
|
||||
$page_url = array_shift($fragments);
|
||||
$page_name = urldecode(request()->header('page-name', '')); // 页面名称
|
||||
$page_name = urldecode((string) request()->header('page-name', '')); // 页面名称
|
||||
$relation_ids = json_encode($ids, JSON_UNESCAPED_UNICODE); // 如果没有版本启用,则只记录操作的id
|
||||
// 关联id-版本id记录
|
||||
if(is_string($model) && $model) {
|
||||
|
||||
21
src/admin/src/Service/PermissionService.php
Normal file → Executable file
21
src/admin/src/Service/PermissionService.php
Normal file → Executable file
@@ -53,7 +53,7 @@ class PermissionService
|
||||
if (!is_array($callback)) {
|
||||
continue;
|
||||
}
|
||||
$route = is_string($route) ? rtrim($route) : rtrim($v[0]->route);
|
||||
$route = is_string($route) ? rtrim($route) : rtrim((string) $v[0]->route);
|
||||
$route_key = "$http_method::{$route}";
|
||||
$options[] = [
|
||||
'value' => $route_key,
|
||||
@@ -127,7 +127,7 @@ class PermissionService
|
||||
if (empty($role_ids)) {
|
||||
return [];
|
||||
}
|
||||
$routes = RoleMenu::query()->distinct(true)->select(['router_id'])->whereIn('role_id', $role_ids)->get()->toArray();
|
||||
$routes = RoleMenu::query()->distinct()->select(['router_id'])->whereIn('role_id', $role_ids)->get()->toArray();
|
||||
|
||||
return $routes ? array_column($routes, 'router_id') : [];
|
||||
}
|
||||
@@ -193,7 +193,7 @@ class PermissionService
|
||||
$resources = [];
|
||||
foreach ($list as $route) {
|
||||
if (Str::contains($route['permission'], '::')) {
|
||||
$permissions = array_filter(explode(',', $route['permission']));
|
||||
$permissions = array_filter(explode(',', (string) $route['permission']));
|
||||
foreach ($permissions as $permission) {
|
||||
[
|
||||
$http_method,
|
||||
@@ -206,7 +206,7 @@ class PermissionService
|
||||
}
|
||||
} else {
|
||||
// 这段代码为兼容老的数据
|
||||
$paths = array_filter(explode('/', $route['path']));
|
||||
$paths = array_filter(explode('/', (string) $route['path']));
|
||||
$suffix = array_pop($paths);
|
||||
$prefix = implode('/', $paths);
|
||||
if ($suffix == 'list') {
|
||||
@@ -245,7 +245,7 @@ class PermissionService
|
||||
])->value('value')[$field] ?? [];
|
||||
$data = [];
|
||||
foreach ($open_apis as $route) {
|
||||
[$http_method, $uri] = explode("::", $route, 2);
|
||||
[$http_method, $uri] = explode("::", (string) $route, 2);
|
||||
$data[] = compact('http_method', 'uri');
|
||||
}
|
||||
|
||||
@@ -256,13 +256,12 @@ class PermissionService
|
||||
{
|
||||
$cache_key = $this->getPermissionCacheKey($user_id);
|
||||
$options = [
|
||||
'routeParser' => 'FastRoute\\RouteParser\\Std',
|
||||
'dataGenerator' => 'FastRoute\\DataGenerator\\GroupCountBased',
|
||||
'dispatcher' => 'FastRoute\\Dispatcher\\GroupCountBased',
|
||||
'routeCollector' => 'FastRoute\\RouteCollector',
|
||||
'routeParser' => \FastRoute\RouteParser\Std::class,
|
||||
'dataGenerator' => \FastRoute\DataGenerator\GroupCountBased::class,
|
||||
'dispatcher' => \FastRoute\Dispatcher\GroupCountBased::class,
|
||||
'routeCollector' => \FastRoute\RouteCollector::class,
|
||||
];
|
||||
if (!$dispatch_data = json_decode(Redis::get($cache_key), true)) {
|
||||
/** @var RouteCollector $routeCollector */
|
||||
$route_collector = new $options['routeCollector'](new $options['routeParser'], new $options['dataGenerator']);
|
||||
$this->processUserResource($route_collector, $user_id, $auth_type);
|
||||
$dispatch_data = $route_collector->getData();
|
||||
@@ -359,7 +358,7 @@ class PermissionService
|
||||
protected function prepareHandler($handler): array
|
||||
{
|
||||
if (is_string($handler)) {
|
||||
if (strpos($handler, '@') !== false) {
|
||||
if (str_contains($handler, '@')) {
|
||||
return explode('@', $handler);
|
||||
}
|
||||
|
||||
|
||||
0
src/admin/src/Service/UserService.php
Normal file → Executable file
0
src/admin/src/Service/UserService.php
Normal file → Executable file
0
src/admin/src/config/config.php
Normal file → Executable file
0
src/admin/src/config/config.php
Normal file → Executable file
0
src/admin/src/config/routes.php
Normal file → Executable file
0
src/admin/src/config/routes.php
Normal file → Executable file
0
src/admin/src/funcs/common.php
Normal file → Executable file
0
src/admin/src/funcs/common.php
Normal file → Executable file
@@ -9,8 +9,8 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"hyperf/async-queue": "~2.1.0",
|
||||
"hyperf/process": "~2.1.0",
|
||||
"hyperf/async-queue": "~2.2.0",
|
||||
"hyperf/process": "~2.2.0",
|
||||
"hyperf-admin/rule-engine": "dev-master"
|
||||
},
|
||||
"autoload": {
|
||||
|
||||
@@ -10,12 +10,8 @@ use HyperfAdmin\RuleEngine\Context\TimeContext;
|
||||
|
||||
class AlertJob extends Job
|
||||
{
|
||||
public $params;
|
||||
|
||||
public function __construct($params)
|
||||
public function __construct(public $params)
|
||||
{
|
||||
// 这里最好是普通数据,不要使用携带 IO 的对象,比如 PDO 对象
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
|
||||
@@ -22,8 +22,6 @@ class AlertService
|
||||
*
|
||||
* @param $params 数据
|
||||
* @param int $delay 延时时间 单位秒
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function push($params, int $delay = 0): bool
|
||||
{
|
||||
|
||||
@@ -16,31 +16,31 @@
|
||||
"ext-yaml": "*",
|
||||
"aliyuncs/oss-sdk-php": "^2.3",
|
||||
"box/spout": "^3.1",
|
||||
"hyperf/amqp": "~2.1.0",
|
||||
"hyperf/cache": "~2.1.0",
|
||||
"hyperf/command": "~2.1.0",
|
||||
"hyperf/config": "~2.1.0",
|
||||
"hyperf/constants": "~2.1.0",
|
||||
"hyperf/database": "~2.1.0",
|
||||
"hyperf/db-connection": "~2.1.0",
|
||||
"hyperf/filesystem": "~2.1.0",
|
||||
"hyperf/framework": "~2.1.0",
|
||||
"hyperf/guzzle": "~2.1.0",
|
||||
"hyperf/http-server": "~2.1.0",
|
||||
"hyperf/logger": "~2.1.0",
|
||||
"hyperf/memory": "~2.1.0",
|
||||
"hyperf/metric": "~2.1.0",
|
||||
"hyperf/nsq": "~2.1.0",
|
||||
"hyperf/process": "~2.1.0",
|
||||
"hyperf/redis": "~2.1.0",
|
||||
"hyperf/snowflake": "~2.1.0",
|
||||
"hyperf/amqp": "~2.2.0",
|
||||
"hyperf/cache": "~2.2.0",
|
||||
"hyperf/command": "~2.2.0",
|
||||
"hyperf/config": "~2.2.0",
|
||||
"hyperf/constants": "~2.2.0",
|
||||
"hyperf/database": "~2.2.0",
|
||||
"hyperf/db-connection": "~2.2.0",
|
||||
"hyperf/filesystem": "~2.2.0",
|
||||
"hyperf/framework": "~2.2.0",
|
||||
"hyperf/guzzle": "~2.2.0",
|
||||
"hyperf/http-server": "~2.2.0",
|
||||
"hyperf/logger": "~2.2.0",
|
||||
"hyperf/memory": "~2.2.0",
|
||||
"hyperf/metric": "~2.2.0",
|
||||
"hyperf/nsq": "~2.2.0",
|
||||
"hyperf/process": "~2.2.0",
|
||||
"hyperf/redis": "~2.2.0",
|
||||
"hyperf/snowflake": "~2.2.0",
|
||||
"yadakhov/insert-on-duplicate-key": "^1.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"swoft/swoole-ide-helper": "^4.2",
|
||||
"phpstan/phpstan": "^0.11.2",
|
||||
"hyperf/devtool": "~2.1.0",
|
||||
"hyperf/testing": "~2.1.0",
|
||||
"hyperf/devtool": "~2.2.0",
|
||||
"hyperf/testing": "~2.2.0",
|
||||
"daodao97/hyperf-watch": "dev-master",
|
||||
"symfony/var-dumper": "^5.0"
|
||||
},
|
||||
|
||||
@@ -6,14 +6,8 @@ namespace HyperfAdmin\BaseUtils;
|
||||
*/
|
||||
class AKSK
|
||||
{
|
||||
private $access_key;
|
||||
|
||||
private $secret_key;
|
||||
|
||||
public function __construct($access_key, $secret_key)
|
||||
public function __construct(private $access_key, private $secret_key)
|
||||
{
|
||||
$this->access_key = $access_key;
|
||||
$this->secret_key = $secret_key;
|
||||
}
|
||||
|
||||
public function token($method, $path, $host, $query, $content_type, $body)
|
||||
@@ -40,7 +34,7 @@ class AKSK
|
||||
|
||||
private function digest($secret, $data)
|
||||
{
|
||||
return hash_hmac('sha1', $data, $secret, true);
|
||||
return hash_hmac('sha1', (string) $data, (string) $secret, true);
|
||||
}
|
||||
|
||||
private function sign($secret, $data)
|
||||
|
||||
@@ -128,14 +128,14 @@ class AliyunOSS
|
||||
$conditions[] = [
|
||||
'starts-with',
|
||||
'$key',
|
||||
rtrim($dir, '/') . '/',
|
||||
rtrim((string) $dir, '/') . '/',
|
||||
];
|
||||
}
|
||||
$base64_policy = base64_encode(json_encode([
|
||||
'expiration' => $expiration,
|
||||
'conditions' => $conditions,
|
||||
]));
|
||||
$signature = base64_encode(hash_hmac('sha1', $base64_policy, $this->access_key_secret, true));
|
||||
$signature = base64_encode(hash_hmac('sha1', $base64_policy, (string) $this->access_key_secret, true));
|
||||
|
||||
return [
|
||||
'OSSAccessKeyId' => $this->access_key,
|
||||
@@ -144,7 +144,7 @@ class AliyunOSS
|
||||
'Signature' => $signature,
|
||||
'expire' => $end,
|
||||
'dir' => $dir, //这个参数是设置用户上传指定的前缀
|
||||
'cdn' => $this->cdn ? rtrim($this->cdn, '/') : '',
|
||||
'cdn' => $this->cdn ? rtrim((string) $this->cdn, '/') : '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
namespace HyperfAdmin\BaseUtils;
|
||||
|
||||
use Monolog\Formatter\LineFormatter;
|
||||
use Monolog\LogRecord;
|
||||
|
||||
class ColorLineFormatter extends LineFormatter
|
||||
{
|
||||
@@ -11,7 +12,7 @@ class ColorLineFormatter extends LineFormatter
|
||||
'WARNING' => "\e[0;33m{log_str}\e[0m",
|
||||
];
|
||||
|
||||
public function format(array $record): string
|
||||
public function format(LogRecord $record): string
|
||||
{
|
||||
$log = parent::format($record);
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@ use GuzzleHttp\Cookie\CookieJar;
|
||||
class Guzzle
|
||||
{
|
||||
/**
|
||||
* @param array $config
|
||||
*
|
||||
* @return Client
|
||||
*/
|
||||
public static function create(array $config = [])
|
||||
@@ -39,9 +37,9 @@ class Guzzle
|
||||
$client = self::create([
|
||||
'timeout' => $headers['timeout'] ?? 10.0,
|
||||
]);
|
||||
$method = strtoupper($method);
|
||||
$method = strtoupper((string) $method);
|
||||
$options = [];
|
||||
$headers['charset'] = $headers['charset'] ?? 'UTF-8';
|
||||
$headers['charset'] ??= 'UTF-8';
|
||||
$options['headers'] = $headers;
|
||||
if($method == 'GET' && $params) {
|
||||
$options['query'] = $params;
|
||||
@@ -49,7 +47,7 @@ class Guzzle
|
||||
if($method == 'POST') {
|
||||
$options['headers']['Content-Type'] = $headers['Content-Type'] ?? 'application/json';
|
||||
if($options['headers']['Content-Type'] == 'application/json' && $params) {
|
||||
$options['body'] = \GuzzleHttp\json_encode($params ? $params : (object)[]);
|
||||
$options['body'] = \GuzzleHttp\json_encode($params ?: (object)[]);
|
||||
}
|
||||
if($options['headers']['Content-Type'] == 'application/x-www-form-urlencoded' && $params) {
|
||||
$options['form_params'] = $params;
|
||||
@@ -92,9 +90,7 @@ class Guzzle
|
||||
try {
|
||||
$options['headers']['X-No-Proxy'] = true;
|
||||
|
||||
$options['headers'] = array_merge($options['headers'], array_map(function ($item) {
|
||||
return $item[0];
|
||||
}, request_header()));
|
||||
$options['headers'] = array_merge($options['headers'], array_map(fn($item) => $item[0], request_header()));
|
||||
|
||||
foreach ($options['headers'] as $key => $val) {
|
||||
$new_key = implode('-', array_map('ucfirst', explode('-', $key)));
|
||||
@@ -102,7 +98,7 @@ class Guzzle
|
||||
unset($options['headers'][$key]);
|
||||
}
|
||||
|
||||
$parse =parse_url($url);
|
||||
$parse =parse_url((string) $url);
|
||||
$domain = isset($parse['port']) ? $parse['host'] . ':' . $parse['port'] : $parse['host'];
|
||||
$options['cookies'] = CookieJar::fromArray(cookie(), $domain);
|
||||
|
||||
@@ -116,16 +112,11 @@ class Guzzle
|
||||
$options['form_params'] = $form_data;
|
||||
}
|
||||
|
||||
$request = retry(3, function () use ($client, $request, $url, $options) {
|
||||
return $client->request($request->getMethod(), $url, $options);
|
||||
}, 50);
|
||||
$request = retry(3, fn() => $client->request($request->getMethod(), $url, $options), 50);
|
||||
$content = $request->getBody()->getContents();
|
||||
$logger->info('proxy_success', compact('url', 'options'));
|
||||
return my_json_decode($content);
|
||||
} catch (\GuzzleHttp\Exception\GuzzleException $e) {
|
||||
$logger->error('proxy_fail', compact('url', 'options', 'e'));
|
||||
throw new \Exception("proxy exception {$e}", 500);
|
||||
} catch (\Throwable $e) {
|
||||
} catch (\GuzzleHttp\Exception\GuzzleException|\Throwable $e) {
|
||||
$logger->error('proxy_fail', compact('url', 'options', 'e'));
|
||||
throw new \Exception("proxy exception {$e}", 500);
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ if(!function_exists('array_remove')) {
|
||||
if(!function_exists('array_get_node')) {
|
||||
function array_get_node($key, $arr = [])
|
||||
{
|
||||
$path = explode('.', $key);
|
||||
$path = explode('.', (string) $key);
|
||||
foreach($path as $key) {
|
||||
$key = trim($key);
|
||||
if(empty($arr) || !isset($arr[$key])) {
|
||||
|
||||
@@ -183,11 +183,11 @@ if (!function_exists('encrypt')) {
|
||||
{
|
||||
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=+";
|
||||
//$nh = rand(0,64);
|
||||
$nh = strlen($txt) % 65;
|
||||
$nh = strlen((string) $txt) % 65;
|
||||
$ch = $chars[$nh];
|
||||
$mdKey = md5($key . $ch);
|
||||
$mdKey = substr($mdKey, $nh % 8, $nh % 8 + 7);
|
||||
$txt = base64_encode($txt);
|
||||
$txt = base64_encode((string) $txt);
|
||||
$tmp = '';
|
||||
$i = 0;
|
||||
$j = 0;
|
||||
@@ -239,7 +239,7 @@ if (!function_exists('is_valid_date')) {
|
||||
if (!function_exists('str_var_replace')) {
|
||||
function str_var_replace($str, $data)
|
||||
{
|
||||
preg_match_all('/{([\s\S]*?)}/', $str, $match);
|
||||
preg_match_all('/{([\s\S]*?)}/', (string) $str, $match);
|
||||
$values = [];
|
||||
$vars = [];
|
||||
foreach (($match && $match[1] ? $match[1] : []) as $item) {
|
||||
@@ -256,7 +256,7 @@ if (!function_exists('convert_memory')) {
|
||||
{
|
||||
$unit = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];
|
||||
|
||||
return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $unit[$i];
|
||||
return @round($size / 1024 ** $i = floor(log($size, 1024)), 2) . ' ' . $unit[$i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ if (!function_exists('read_file')) {
|
||||
if (!function_exists('get_extension')) {
|
||||
function get_extension($file)
|
||||
{
|
||||
return substr(strrchr($file, '.'), 1);
|
||||
return substr(strrchr((string) $file, '.'), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ if (!function_exists('http_build_url')) {
|
||||
if (!function_exists('replace_url_query')) {
|
||||
function replace_url_query($url, array $query)
|
||||
{
|
||||
$parse = parse_url($url);
|
||||
$parse = parse_url((string) $url);
|
||||
parse_str($parse['query'], $p);
|
||||
$parse['query'] = urldecode(http_build_query(array_merge($p, $query)));
|
||||
|
||||
@@ -425,7 +425,7 @@ if (!function_exists('my_json_decode')) {
|
||||
if (!$json) {
|
||||
return $default;
|
||||
}
|
||||
$json = preg_replace('@//[^"]+?$@mui', '', $json);
|
||||
$json = preg_replace('@//[^"]+?$@mui', '', (string) $json);
|
||||
$json = preg_replace('@^\s*//.*?$@mui', '', $json);
|
||||
$json = $json ? @json_decode($json, true) : $default;
|
||||
if (is_null($json)) {
|
||||
@@ -524,10 +524,10 @@ if (!function_exists('generate_random_str')) {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$random_str = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$random_str .= $characters[rand(0, strlen($characters) - 1)];
|
||||
$random_str .= $characters[random_int(0, strlen($characters) - 1)];
|
||||
}
|
||||
|
||||
return trim($prefix) . $random_str;
|
||||
return trim((string) $prefix) . $random_str;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,7 +537,7 @@ if (!function_exists('get_dir_filename')) {
|
||||
$handler = opendir($dir);
|
||||
$files = [];
|
||||
while (($filename = readdir($handler)) !== false) {
|
||||
$filter_extension = $extension === '' ? true : strpos($filename, $extension);
|
||||
$filter_extension = $extension === '' ? true : strpos($filename, (string) $extension);
|
||||
if (!($filename !== "." && $filename !== ".." && $filter_extension)) {
|
||||
continue;
|
||||
}
|
||||
@@ -556,34 +556,33 @@ if (!function_exists('get_dir_filename')) {
|
||||
if (!function_exists('sp_encrypt')) {
|
||||
function sp_encrypt($plaintext, $key)
|
||||
{
|
||||
$key = substr(sha1($key, true), 0, 16);
|
||||
$key = substr(sha1((string) $key, true), 0, 16);
|
||||
$iv = openssl_random_pseudo_bytes(16);
|
||||
$ciphertext = openssl_encrypt($plaintext, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $iv);
|
||||
$ciphertext_base64 = urlsafe_b64encode($iv . $ciphertext);
|
||||
|
||||
return $ciphertext_base64;
|
||||
return urlsafe_b64encode($iv . $ciphertext);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('sp_decrypt')) {
|
||||
function sp_decrypt($ciphertext_base64, $key)
|
||||
{
|
||||
$key = substr(sha1($key, true), 0, 16);
|
||||
$key = substr(sha1((string) $key, true), 0, 16);
|
||||
$ciphertext_dec = urlsafe_b64decode($ciphertext_base64);
|
||||
$iv_size = 16;
|
||||
$iv_dec = substr($ciphertext_dec, 0, $iv_size);
|
||||
$ciphertext_dec = substr($ciphertext_dec, $iv_size);
|
||||
$plaintext_dec = openssl_decrypt($ciphertext_dec, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $iv_dec);
|
||||
$iv_dec = substr((string) $ciphertext_dec, 0, $iv_size);
|
||||
$ciphertext_dec = substr((string) $ciphertext_dec, $iv_size);
|
||||
|
||||
return $plaintext_dec;
|
||||
return openssl_decrypt($ciphertext_dec, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $iv_dec);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('urlsafe_b64encode')) {
|
||||
function urlsafe_b64encode($string)
|
||||
{
|
||||
$data = base64_encode($string);
|
||||
$data = str_replace([
|
||||
$data = base64_encode((string) $string);
|
||||
|
||||
return str_replace([
|
||||
'+',
|
||||
'/',
|
||||
// '=',
|
||||
@@ -592,8 +591,6 @@ if (!function_exists('urlsafe_b64encode')) {
|
||||
'_',
|
||||
// '',
|
||||
], $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -662,7 +659,6 @@ if (!function_exists('cookie')) {
|
||||
/**
|
||||
* 快捷方式,返回 request 相关 cookie
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -684,7 +680,6 @@ if (!function_exists('request_header')) {
|
||||
/**
|
||||
* 快捷方式,返回 request 相关 header
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -754,10 +749,10 @@ if (!function_exists('is_cli')) {
|
||||
if (!function_exists('xml2array')) {
|
||||
function xml2array($xml_string, $key = '')
|
||||
{
|
||||
if (strpos($xml_string, '<') === false) {
|
||||
if (!str_contains((string) $xml_string, '<')) {
|
||||
return [];
|
||||
}
|
||||
$array = (array)@simplexml_load_string($xml_string, 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||
$array = (array)@simplexml_load_string((string) $xml_string, 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||
if (!$key) {
|
||||
return $array;
|
||||
}
|
||||
@@ -804,7 +799,7 @@ if (!function_exists('now')) {
|
||||
if (!function_exists('is_json_str')) {
|
||||
function is_json_str($string)
|
||||
{
|
||||
json_decode($string);
|
||||
json_decode((string) $string);
|
||||
return (json_last_error() == JSON_ERROR_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,17 +123,16 @@ if (!function_exists('filesystem_private_url')) {
|
||||
}
|
||||
$filesystem = make(FilesystemFactory::class)->get($bucket);
|
||||
if (Str::startsWith($save_file_path, 'http')) {
|
||||
$save_file_path = parse_url($save_file_path)['path'];
|
||||
$save_file_path = parse_url((string) $save_file_path)['path'];
|
||||
$parts = explode('/', $save_file_path);
|
||||
unset($parts[0]);
|
||||
$save_file_path = implode('/', $parts);
|
||||
}
|
||||
$save_file_path = preg_replace('@^oss/@', '', $save_file_path);
|
||||
$save_file_path = preg_replace('@^oss/@', '', (string) $save_file_path);
|
||||
try {
|
||||
switch (config("file.storage.{$bucket}.driver")) {
|
||||
case \Hyperf\Filesystem\Adapter\LocalAdapterFactory::class:
|
||||
return config("file.storage.{$bucket}.cdn") . $save_file_path;
|
||||
break;
|
||||
case \Hyperf\Filesystem\Adapter\AliyunOssAdapterFactory::class;
|
||||
$adapter = $filesystem->getAdapter();
|
||||
if (method_exists($adapter, 'signUrl')) {
|
||||
@@ -188,11 +187,7 @@ if (!function_exists('process_list_filter')) {
|
||||
$processes = [];
|
||||
}
|
||||
if (is_array($ignore)) {
|
||||
$processes = array_filter($processes, function ($item) use ($ignore) {
|
||||
return !Str::startsWith($item, array_map(function ($each) {
|
||||
return Str::replaceLast('*', '', $each);
|
||||
}, $ignore));
|
||||
});
|
||||
$processes = array_filter($processes, fn($item) => !Str::startsWith($item, array_map(fn($each) => Str::replaceLast('*', '', $each), $ignore)));
|
||||
}
|
||||
}
|
||||
if ($active = $rule['active'] ?? []) {
|
||||
|
||||
@@ -37,9 +37,8 @@ class JWT
|
||||
}
|
||||
$base64_header = self::base64UrlEncode(json_encode(self::$header, JSON_UNESCAPED_UNICODE));
|
||||
$base64_payload = self::base64UrlEncode(json_encode($payload, JSON_UNESCAPED_UNICODE));
|
||||
$token = $base64_header . '.' . $base64_payload . '.' . self::signature($base64_header . '.' . $base64_payload, self::$key, self::$header['alg']);
|
||||
|
||||
return $token;
|
||||
return $base64_header . '.' . $base64_payload . '.' . self::signature($base64_header . '.' . $base64_payload, self::$key, self::$header['alg']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,9 +115,7 @@ class JWT
|
||||
* HMACSHA256签名 https://jwt.io/ 中HMACSHA256签名实现
|
||||
*
|
||||
* @param string $input 为base64UrlEncode(header).".".base64UrlEncode(payload)
|
||||
* @param string $key
|
||||
* @param string $alg 算法方式
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private static function signature(string $input, string $key, string $alg = 'HS256')
|
||||
|
||||
@@ -15,7 +15,7 @@ class BootAppConfListener implements ListenerInterface
|
||||
];
|
||||
}
|
||||
|
||||
public function process(object $event)
|
||||
public function process(object $event): void
|
||||
{
|
||||
Builder::macro('getAsArray', function () {
|
||||
/** @var \Hyperf\Database\Query\Builder $this */
|
||||
|
||||
@@ -15,10 +15,7 @@ class DbQueryExecutedListener implements ListenerInterface
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $event
|
||||
*/
|
||||
public function process(object $event)
|
||||
public function process(object $event): void
|
||||
{
|
||||
if($event instanceof QueryExecuted) {
|
||||
if(is_production()) {
|
||||
@@ -73,9 +70,7 @@ class DbQueryExecutedListener implements ListenerInterface
|
||||
/**
|
||||
* 获取sql类型
|
||||
*
|
||||
* @param string $sql
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getSqlType(string $sql): string
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ class FetchModeListener implements ListenerInterface
|
||||
];
|
||||
}
|
||||
|
||||
public function process(object $event)
|
||||
public function process(object $event): void
|
||||
{
|
||||
if($event instanceof StatementPrepared) {
|
||||
$event->statement->setFetchMode(PDO::FETCH_ASSOC);
|
||||
|
||||
@@ -35,7 +35,7 @@ class BaseModel extends Model
|
||||
*/
|
||||
public function where2query($where, $query = null)
|
||||
{
|
||||
$query = $query ?? $this->newQuery();
|
||||
$query ??= $this->newQuery();
|
||||
if (!$where) {
|
||||
return $query;
|
||||
}
|
||||
@@ -43,9 +43,7 @@ class BaseModel extends Model
|
||||
unset($where['__logic']);
|
||||
foreach ($where as $key => $item) {
|
||||
if (is_numeric($key) && is_array($item)) {
|
||||
$query->where(function ($query) use ($item) {
|
||||
return $this->where2query($item, $query);
|
||||
}, null, null, $boolean);
|
||||
$query->where(fn($query) => $this->where2query($item, $query), null, null, $boolean);
|
||||
continue;
|
||||
}
|
||||
if (!is_array($item)) {
|
||||
@@ -105,20 +103,20 @@ class BaseModel extends Model
|
||||
$where = [];
|
||||
$kw = request()->input('kw');
|
||||
if ($kw) {
|
||||
if (preg_match_all('/^\d+$/', $kw)) {
|
||||
if (preg_match_all('/^\d+$/', (string) $kw)) {
|
||||
$where[$id_key] = $kw;
|
||||
} elseif (preg_match_all('/^\d+?,/', $kw)) {
|
||||
$where[$id_key] = explode(',', $kw);
|
||||
} elseif (preg_match_all('/^\d+?,/', (string) $kw)) {
|
||||
$where[$id_key] = explode(',', (string) $kw);
|
||||
} else {
|
||||
$where[$name_key] = ['like' => "%{$kw}%"];
|
||||
}
|
||||
}
|
||||
$id = request()->input('id');
|
||||
if ($id) {
|
||||
if (preg_match_all('/^\d+$/', $id)) {
|
||||
if (preg_match_all('/^\d+$/', (string) $id)) {
|
||||
$where[$id_key] = $id;
|
||||
} elseif (preg_match_all('/^\d+?,/', $id)) {
|
||||
$where[$id_key] = explode(',', $id);
|
||||
} elseif (preg_match_all('/^\d+?,/', (string) $id)) {
|
||||
$where[$id_key] = explode(',', (string) $id);
|
||||
}
|
||||
}
|
||||
if (!$default_query && !$where) {
|
||||
@@ -126,7 +124,7 @@ class BaseModel extends Model
|
||||
}
|
||||
$where['__logic'] = $logic;
|
||||
$where = array_merge($where, $extra_where);
|
||||
$attr['limit'] = $attr['limit'] ?? 100;
|
||||
$attr['limit'] ??= 100;
|
||||
return $this->list($where, $attr)->toArray();
|
||||
}
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ class EsBaseModel
|
||||
];
|
||||
try {
|
||||
return $this->client->get($params);
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -491,7 +491,7 @@ class EsBaseModel
|
||||
foreach ($val_tile as $operator => $each) {
|
||||
if (isset($this->operator_map[$operator])) {
|
||||
$mapping_date_format = $this->mapping['properties'][$key]['format'] ?? null;
|
||||
$query['bool']['filter']['bool']['must'][$index]['range'][$key][$this->operator_map[$operator]] = $is_time_field ? date($mapping_date_format ? $this->transDateFormat($mapping_date_format) : "Y-m-d\TH:i:s", strtotime($each)) : $each;
|
||||
$query['bool']['filter']['bool']['must'][$index]['range'][$key][$this->operator_map[$operator]] = $is_time_field ? date($mapping_date_format ? $this->transDateFormat($mapping_date_format) : "Y-m-d\TH:i:s", strtotime((string) $each)) : $each;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
@@ -500,9 +500,7 @@ class EsBaseModel
|
||||
if (is_array($val)) {
|
||||
$query['bool']['filter']['bool']['must'][] = [
|
||||
'terms' => [
|
||||
$key => array_map(function ($each) {
|
||||
return is_numeric($each) ? $each * 1 : $each;
|
||||
}, $val),
|
||||
$key => array_map(fn($each) => is_numeric($each) ? $each * 1 : $each, $val),
|
||||
],
|
||||
];
|
||||
continue;
|
||||
|
||||
@@ -12,17 +12,14 @@ use HyperfAdmin\BaseUtils\Log;
|
||||
*/
|
||||
class Redis
|
||||
{
|
||||
private $pool;
|
||||
|
||||
/**
|
||||
* @var \Redis
|
||||
*/
|
||||
private $redis;
|
||||
|
||||
public function __construct($pool = 'default')
|
||||
public function __construct(private $pool = 'default')
|
||||
{
|
||||
$this->pool = $pool;
|
||||
$this->redis = container(RedisFactory::class)->get($pool);
|
||||
$this->redis = container(RedisFactory::class)->get($this->pool);
|
||||
}
|
||||
|
||||
public static function conn($pool = 'default')
|
||||
@@ -73,8 +70,6 @@ class Redis
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param int $expired
|
||||
* @param mixed $callable
|
||||
*
|
||||
* @return array|null
|
||||
@@ -84,7 +79,7 @@ class Redis
|
||||
if ($this->redis->exists($name)) {
|
||||
Log::get('redis')->info(sprintf('get %s from cache', $name));
|
||||
|
||||
return json_decode($this->redis->get($name), true);
|
||||
return json_decode((string) $this->redis->get($name), true);
|
||||
}
|
||||
$data = call($callable);
|
||||
if ($data) {
|
||||
|
||||
@@ -16,29 +16,29 @@ class RedisArray implements \ArrayAccess
|
||||
$this->redis = container(RedisFactory::class)->get($cluster);
|
||||
}
|
||||
|
||||
public function offsetExists($offset)
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return $this->redis->hExists($this->name, (string)$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset)
|
||||
public function offsetGet($offset): mixed
|
||||
{
|
||||
$val = $this->redis->hGet($this->name, (string)$offset);
|
||||
if(is_json_str($val)) {
|
||||
return json_decode($val, true);
|
||||
return json_decode((string) $val, true);
|
||||
}
|
||||
|
||||
return $val;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value)
|
||||
public function offsetSet($offset, $value): void
|
||||
{
|
||||
return $this->redis->hSet($this->name, (string)$offset, is_array($value) ? json_encode($value) : $value);
|
||||
$this->redis->hSet($this->name, (string)$offset, is_array($value) ? json_encode($value) : $value);
|
||||
}
|
||||
|
||||
public function offsetUnset($offset)
|
||||
public function offsetUnset($offset): void
|
||||
{
|
||||
return $this->redis->hDel($this->name, (string)$offset);
|
||||
$this->redis->hDel($this->name, (string)$offset);
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
|
||||
@@ -5,10 +5,6 @@ use Hyperf\Redis\RedisFactory;
|
||||
|
||||
class RedisQueue
|
||||
{
|
||||
protected $cluster = 'default';
|
||||
|
||||
protected $queue_name = 'redis_queue_default';
|
||||
|
||||
protected $queue_wait_ack_suffix = 'wait_ack';
|
||||
|
||||
protected $wait_timeout = 10;
|
||||
@@ -20,11 +16,9 @@ class RedisQueue
|
||||
*/
|
||||
protected $redis;
|
||||
|
||||
public function __construct($queue_name, $cluster = 'default')
|
||||
public function __construct(protected $queue_name, protected $cluster = 'default')
|
||||
{
|
||||
$this->queue_name = $queue_name;
|
||||
$this->cluster = $cluster;
|
||||
$this->redis = container(RedisFactory::class)->get($cluster);
|
||||
$this->redis = container(RedisFactory::class)->get($this->cluster);
|
||||
}
|
||||
|
||||
public function length($name = '')
|
||||
@@ -65,8 +59,8 @@ class RedisQueue
|
||||
}
|
||||
$msg = $this->getOne($this->queue_name, $filter);
|
||||
if($msg) {
|
||||
$msg_id = md5($msg);
|
||||
$data = json_decode($msg, true);
|
||||
$msg_id = md5((string) $msg);
|
||||
$data = json_decode((string) $msg, true);
|
||||
$ret = array_merge($data, ['_queue_msg_id' => $msg_id]);
|
||||
$this->redis->rPush($this->getAckQueueName(), json_encode(array_merge($ret, ['_time' => time()])));
|
||||
|
||||
@@ -87,7 +81,7 @@ class RedisQueue
|
||||
}
|
||||
foreach(range(0, $len - 1) as $index) {
|
||||
$ele = $this->redis->lIndex($queue_name, $index);
|
||||
$ele_array = json_decode($ele, true);
|
||||
$ele_array = json_decode((string) $ele, true);
|
||||
if(array_intersect($ele_array, $filter)) {
|
||||
$this->redis->lRem($queue_name, $ele, 1);
|
||||
|
||||
@@ -132,7 +126,7 @@ class RedisQueue
|
||||
{
|
||||
$list = $this->redis->lRange($this->getAckQueueName(), 0, -1);
|
||||
foreach($list as &$item) {
|
||||
$item = json_decode($item, true);
|
||||
$item = json_decode((string) $item, true);
|
||||
}
|
||||
unset($item);
|
||||
|
||||
|
||||
@@ -77,9 +77,7 @@ abstract class AbstractController extends Controller
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$tableHeader = array_values(array_filter($this->getListHeader(), function ($item) {
|
||||
return !($item['hidden'] ?? false);
|
||||
}));
|
||||
$tableHeader = array_values(array_filter($this->getListHeader(), fn($item) => !($item['hidden'] ?? false)));
|
||||
$filter = $this->getListFilters();
|
||||
$actions = $this->options['table']['rowActions'] ?? [];
|
||||
$actions = $this->buttonConfigConvert($actions);
|
||||
@@ -125,7 +123,7 @@ abstract class AbstractController extends Controller
|
||||
foreach ($config as $key => $item) {
|
||||
$buttons[$key]['text'] = $item['text'] ?? '';
|
||||
$buttons[$key]['type'] = isset($item['target']) ? $item['type'] ?? 'jump' : (isset($item['rules']) ? 'form' : (isset($item['api']) ? 'api' : 'jump'));
|
||||
$buttons[$key]['target'] = isset($item['target']) ? $item['target'] : (isset($item['api']) ? $item['api'] : ($item['action'] ?? ''));
|
||||
$buttons[$key]['target'] = $item['target'] ?? $item['api'] ?? $item['action'] ?? '';
|
||||
$buttons[$key]['props'] = isset($item['target']) ? $item['props'] ?? [] : [
|
||||
'icon' => $item['icon'] ?? '',
|
||||
'circle' => $item['circle'] ?? false,
|
||||
@@ -160,11 +158,7 @@ abstract class AbstractController extends Controller
|
||||
$page = $this->request->input('_page', 1);
|
||||
$size = $this->request->input('_size', 20);
|
||||
$table_options = $this->getListHeader();
|
||||
$columns = array_unique(array_values(array_map(function ($item) {
|
||||
return explode('.', $item)[0];
|
||||
}, array_column(array_filter($table_options, function ($each) {
|
||||
return isset($each['virtual_field']) ? !$each['virtual_field'] : true;
|
||||
}), 'field'))));
|
||||
$columns = array_unique(array_values(array_map(fn($item) => explode('.', (string) $item)[0], array_column(array_filter($table_options, fn($each) => isset($each['virtual_field']) ? !$each['virtual_field'] : true), 'field'))));
|
||||
$filter_options = $this->getListFilters();
|
||||
$filters = [];
|
||||
if (!empty($filter_options)) {
|
||||
@@ -184,23 +178,13 @@ abstract class AbstractController extends Controller
|
||||
}
|
||||
$conditions = $this->options['where'] ?? [];
|
||||
foreach ($filters as $field => $value) {
|
||||
switch ($filter_options[$field]['search_type'] ?? '') {
|
||||
case 'between':
|
||||
$conditions[$field] = ['between' => $value];
|
||||
break;
|
||||
case 'full_like':
|
||||
$conditions[$field] = ['like' => "%{$value}%"];
|
||||
break;
|
||||
case 'suffix_like':
|
||||
$conditions[$field] = ['like' => "{$value}%"];
|
||||
break;
|
||||
case 'prefix_like':
|
||||
$conditions[$field] = ['like' => "%{$value}"];
|
||||
break;
|
||||
default:
|
||||
$conditions[$field] = $value;
|
||||
break;
|
||||
}
|
||||
$conditions[$field] = match ($filter_options[$field]['search_type'] ?? '') {
|
||||
'between' => ['between' => $value],
|
||||
'full_like' => ['like' => "%{$value}%"],
|
||||
'suffix_like' => ['like' => "{$value}%"],
|
||||
'prefix_like' => ['like' => "%{$value}"],
|
||||
default => $value,
|
||||
};
|
||||
}
|
||||
$order_by = $this->options['order_by'] ?? '';
|
||||
$group_by = $this->options['group_by'] ?? '';
|
||||
@@ -322,7 +306,7 @@ abstract class AbstractController extends Controller
|
||||
$ret = Db::connection($pool)->table("{$db}.{$table}")->whereIn($foreign_key, $where)->get($columns)->toArray();
|
||||
array_change_v2k($ret, $foreign_key);
|
||||
foreach ($list as &$item) {
|
||||
$append = isset($ret[$item[$local_key]]) ? $ret[$item[$local_key]] : $default;
|
||||
$append = $ret[$item[$local_key]] ?? $default;
|
||||
unset($append[$foreign_key]);
|
||||
$item = array_merge($item, $append);
|
||||
}
|
||||
@@ -352,7 +336,7 @@ abstract class AbstractController extends Controller
|
||||
$ret = Db::connection($pool)->table("{$db}.{$table}")->whereIn($foreign_key, $where)->get($columns)->toArray();
|
||||
$ret = array_group_by($ret, $foreign_key);
|
||||
foreach ($list as &$item) {
|
||||
$group = isset($ret[$item[$local_key]]) ? $ret[$item[$local_key]] : $default;
|
||||
$group = $ret[$item[$local_key]] ?? $default;
|
||||
$append = [];
|
||||
foreach (array_keys($default) as $field) {
|
||||
$append[$field] = array_values(array_unique(array_filter(array_column($group, $field))));
|
||||
@@ -366,7 +350,7 @@ abstract class AbstractController extends Controller
|
||||
|
||||
public function explodeHasStr($has_str)
|
||||
{
|
||||
$check = preg_match('/([a-zA-Z_0-9]+\.)?([a-zA-Z_0-9]+)\.([a-zA-Z_0-9]+):([a-zA-Z_0-9]+->)?([a-zA-Z_,0-9 ]+)/', $has_str, $match);
|
||||
$check = preg_match('/([a-zA-Z_0-9]+\.)?([a-zA-Z_0-9]+)\.([a-zA-Z_0-9]+):([a-zA-Z_0-9]+->)?([a-zA-Z_,0-9 ]+)/', (string) $has_str, $match);
|
||||
if ($check === 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -377,11 +361,9 @@ abstract class AbstractController extends Controller
|
||||
$table,
|
||||
$local_key,
|
||||
$foreign_key,
|
||||
] = array_map(function ($item) {
|
||||
return str_replace(['.', '->'], '', $item);
|
||||
}, $match);
|
||||
$pool = $pool ? $pool : 'default';
|
||||
$local_key = $local_key ? $local_key : 'id';
|
||||
] = array_map(fn($item) => str_replace(['.', '->'], '', $item), $match);
|
||||
$pool = $pool ?: 'default';
|
||||
$local_key = $local_key ?: 'id';
|
||||
$columns = explode(',', $foreign_key);
|
||||
if (!$columns) {
|
||||
return false;
|
||||
@@ -389,7 +371,7 @@ abstract class AbstractController extends Controller
|
||||
$foreign_key = $columns[0];
|
||||
$default = [];
|
||||
foreach ($columns as $each) {
|
||||
$default[trim(preg_replace('/[\w ]+as +/i', '', trim($each)))] = null;
|
||||
$default[trim((string) preg_replace('/[\w ]+as +/i', '', trim($each)))] = null;
|
||||
}
|
||||
return array_values(compact('pool', 'db', 'table', 'local_key', 'foreign_key', 'columns', 'default'));
|
||||
}
|
||||
@@ -397,11 +379,7 @@ abstract class AbstractController extends Controller
|
||||
public function getTreeNodeChilds($id)
|
||||
{
|
||||
$tableOptions = $this->getListHeader();
|
||||
$columns = array_unique(array_values(array_map(function ($item) {
|
||||
return explode('.', $item)[0];
|
||||
}, array_column(array_filter($tableOptions, function ($each) {
|
||||
return isset($each['virtual_field']) ? !$each['virtual_field'] : true;
|
||||
}), 'field'))));
|
||||
$columns = array_unique(array_values(array_map(fn($item) => explode('.', (string) $item)[0], array_column(array_filter($tableOptions, fn($each) => isset($each['virtual_field']) ? !$each['virtual_field'] : true), 'field'))));
|
||||
$order_by = $this->options['order_by'] ?? '';
|
||||
$attr['select'] = $columns;
|
||||
$order_by && $attr['order_by'] = $order_by;
|
||||
@@ -677,13 +655,9 @@ abstract class AbstractController extends Controller
|
||||
public function getFields()
|
||||
{
|
||||
$form = $this->formOptionsConvert();
|
||||
$form = array_filter($form, function ($item) {
|
||||
return !($item['virtual_field'] ?? false);
|
||||
});
|
||||
$form = array_filter($form, fn($item) => !($item['virtual_field'] ?? false));
|
||||
$fields = array_column($form, 'field');
|
||||
$fields = array_map(function ($item) {
|
||||
return explode('.', $item)[0];
|
||||
}, $fields);
|
||||
$fields = array_map(fn($item) => explode('.', (string) $item)[0], $fields);
|
||||
return array_unique($fields);
|
||||
}
|
||||
|
||||
@@ -700,7 +674,7 @@ abstract class AbstractController extends Controller
|
||||
$filter_options = [];
|
||||
foreach ($this->options['filter'] as $key => $item) {
|
||||
$filter_option_key = is_array($item) ? $key : str_replace('%', '', $item);
|
||||
$field_extra = explode('|', $filter_option_key);
|
||||
$field_extra = explode('|', (string) $filter_option_key);
|
||||
$field = $field_extra[0];
|
||||
$form_option = [];
|
||||
if (isset($form_fields[$field]) && isset($form_options[$form_fields[$field]])) {
|
||||
@@ -726,7 +700,7 @@ abstract class AbstractController extends Controller
|
||||
if (Str::startsWith($item, '%') !== false && Str::endsWith($item, '%') !== false) {
|
||||
$search_type = 'full_like';
|
||||
}
|
||||
if (strpos(($filter_options[$filter_option_key]['type'] ?? ''), 'range') !== false) {
|
||||
if (str_contains(($filter_options[$filter_option_key]['type'] ?? ''), 'range')) {
|
||||
$search_type = 'between';
|
||||
}
|
||||
$filter_options[$filter_option_key]['search_type'] = $search_type;
|
||||
@@ -803,7 +777,7 @@ abstract class AbstractController extends Controller
|
||||
}
|
||||
$form = [];
|
||||
foreach ($formOption as $key => $val) {
|
||||
$field_extra = explode('|', $key);
|
||||
$field_extra = explode('|', (string) $key);
|
||||
$field = $field_extra[0];
|
||||
$title = $field_extra[1] ?? $field_extra[0];
|
||||
$biz = [];
|
||||
@@ -817,7 +791,7 @@ abstract class AbstractController extends Controller
|
||||
continue;
|
||||
}
|
||||
$rule = $biz['rule'] ?? '';
|
||||
$rules = is_array($rule) ? $rule : explode('|', $rule);
|
||||
$rules = is_array($rule) ? $rule : explode('|', (string) $rule);
|
||||
$_form = [
|
||||
'title' => $title,
|
||||
'field' => $field,
|
||||
@@ -827,18 +801,19 @@ abstract class AbstractController extends Controller
|
||||
switch ($_form['type']) {
|
||||
case 'checkbox':
|
||||
case 'cascader':
|
||||
$_form['value'] = array_map('intval', is_array($_form['value']) ? $_form['value'] : (array)$_form['value']);
|
||||
// $_form['value'] = array_map('intval', is_array($_form['value']) ? $_form['value'] : (array)$_form['value']);
|
||||
$_form['value'] = (array)$_form['value'];
|
||||
break;
|
||||
case 'image':
|
||||
$biz['props']['limit'] = $biz['props']['limit'] ?? 1;
|
||||
$biz['props']['limit'] ??= 1;
|
||||
break;
|
||||
case 'select':
|
||||
if (isset($biz['props']['selectApi']) && $_form['value']) {
|
||||
$biz['options'] = select_options($biz['props']['selectApi'], is_array($_form['value']) ? $_form['value'] : explode(',', $_form['value']));
|
||||
$biz['options'] = select_options($biz['props']['selectApi'], is_array($_form['value']) ? $_form['value'] : explode(',', (string) $_form['value']));
|
||||
}
|
||||
// fixme sub-form value 不好取, 先默认查一次
|
||||
if (isset($biz['props']['selectApi']) && $depth) {
|
||||
$biz['options'] = select_options($biz['props']['selectApi'], is_array($_form['value']) ? $_form['value'] : explode(',', $_form['value']));
|
||||
$biz['options'] = select_options($biz['props']['selectApi'], is_array($_form['value']) ? $_form['value'] : explode(',', (string) $_form['value']));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -942,7 +917,7 @@ abstract class AbstractController extends Controller
|
||||
*/
|
||||
public function getFormRules($options = null)
|
||||
{
|
||||
$formOptions = $options ? $options : ($this->options['form'] ?? []);
|
||||
$formOptions = $options ?: $this->options['form'] ?? [];
|
||||
$rules = [];
|
||||
foreach ($formOptions as $key => $val) {
|
||||
if (is_array($val) && ($val['form'] ?? true) === false) {
|
||||
@@ -977,7 +952,7 @@ abstract class AbstractController extends Controller
|
||||
$data_source = $this->request->all();
|
||||
$pk_val = $data_source[$pk] ?? null;
|
||||
foreach ($rules as &$val) {
|
||||
$rule_parts = is_array($val) ? $val : explode('|', $val);
|
||||
$rule_parts = is_array($val) ? $val : explode('|', (string) $val);
|
||||
foreach ($rule_parts as &$rule) {
|
||||
if ($pk_val && is_string($rule) && Str::startsWith($rule, 'unique')) {
|
||||
// unique rule without itself in update
|
||||
@@ -1087,7 +1062,7 @@ abstract class AbstractController extends Controller
|
||||
$up = $this->request->all();
|
||||
$up_fields = array_keys($up);
|
||||
foreach ($rules as $key => $val) {
|
||||
$field_extra = explode('|', $key);
|
||||
$field_extra = explode('|', (string) $key);
|
||||
$field = $field_extra[0];
|
||||
if (!in_array($field, $up_fields)) {
|
||||
unset($rules[$key]);
|
||||
@@ -1116,7 +1091,6 @@ abstract class AbstractController extends Controller
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param \Throwable $previous
|
||||
*
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
@@ -1140,7 +1114,7 @@ abstract class AbstractController extends Controller
|
||||
{
|
||||
$validates = [];
|
||||
foreach ($rules as $item) {
|
||||
$parts = explode(':', $item);
|
||||
$parts = explode(':', (string) $item);
|
||||
$rule = array_shift($parts);
|
||||
switch ($rule) {
|
||||
case 'required':
|
||||
@@ -1231,9 +1205,7 @@ abstract class AbstractController extends Controller
|
||||
$filters = [];
|
||||
if ($filter_options = $this->getListFilters()) {
|
||||
array_change_v2k($filter_options, 'field');
|
||||
$filters = array_filter($this->request->inputs(array_keys($filter_options)), function ($item) {
|
||||
return !in_array($item, [null, '']);
|
||||
});
|
||||
$filters = array_filter($this->request->inputs(array_keys($filter_options)), fn($item) => !in_array($item, [null, '']));
|
||||
}
|
||||
$list = [];
|
||||
if (is_array($notices)) {
|
||||
@@ -1288,7 +1260,7 @@ abstract class AbstractController extends Controller
|
||||
{
|
||||
$const = [];
|
||||
if ($model = $this->model_class ?? '') {
|
||||
$const = constant($model . '::' . strtoupper($field)) ?? [];
|
||||
$const = constant($model . '::' . strtoupper((string) $field)) ?? [];
|
||||
}
|
||||
$options = [];
|
||||
foreach ($const as $k => $v) {
|
||||
@@ -1304,8 +1276,6 @@ abstract class AbstractController extends Controller
|
||||
/**
|
||||
* 新版本检查
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $last_ver_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
||||
@@ -82,7 +82,7 @@ abstract class Controller
|
||||
protected function getCalledSource($get_arr = false)
|
||||
{
|
||||
$uri = $this->getRequestUri();
|
||||
$parts = array_filter(explode('/', $uri));
|
||||
$parts = array_filter(explode('/', (string) $uri));
|
||||
if ($get_arr) {
|
||||
return array_values($parts);
|
||||
}
|
||||
@@ -98,9 +98,7 @@ abstract class Controller
|
||||
/**
|
||||
* 返回成功的请求
|
||||
*
|
||||
* @param array $data
|
||||
* @param string $message
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function success(array $data = [], $message = '操作成功')
|
||||
@@ -115,8 +113,6 @@ abstract class Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $code
|
||||
* @param string|null $message
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
||||
@@ -47,26 +47,21 @@ class OssAdapter extends AbstractAdapter
|
||||
$isCName = false;
|
||||
$token = null;
|
||||
$this->supports = new Supports();
|
||||
try {
|
||||
$this->bucket = $config['bucket'];
|
||||
empty($config['endpoint']) ? null : $this->endpoint = $config['endpoint'];
|
||||
empty($config['timeout']) ? $config['timeout'] = 3600 : null;
|
||||
empty($config['connectTimeout']) ? $config['connectTimeout'] = 10 : null;
|
||||
|
||||
if (!empty($config['isCName'])) {
|
||||
$isCName = true;
|
||||
}
|
||||
if (!empty($config['token'])) {
|
||||
$token = $config['token'];
|
||||
}
|
||||
$this->oss = new OssClient(
|
||||
$config['accessId'], $config['accessSecret'], $this->endpoint, $isCName, $token
|
||||
);
|
||||
$this->oss->setTimeout($config['timeout']);
|
||||
$this->oss->setConnectTimeout($config['connectTimeout']);
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
$this->bucket = $config['bucket'];
|
||||
empty($config['endpoint']) ? null : $this->endpoint = $config['endpoint'];
|
||||
empty($config['timeout']) ? $config['timeout'] = 3600 : null;
|
||||
empty($config['connectTimeout']) ? $config['connectTimeout'] = 10 : null;
|
||||
if (!empty($config['isCName'])) {
|
||||
$isCName = true;
|
||||
}
|
||||
if (!empty($config['token'])) {
|
||||
$token = $config['token'];
|
||||
}
|
||||
$this->oss = new OssClient(
|
||||
$config['accessId'], $config['accessSecret'], $this->endpoint, $isCName, $token
|
||||
);
|
||||
$this->oss->setTimeout($config['timeout']);
|
||||
$this->oss->setConnectTimeout($config['connectTimeout']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,7 +209,6 @@ class OssAdapter extends AbstractAdapter
|
||||
* Create a directory.
|
||||
*
|
||||
* @param string $dirname directory name
|
||||
* @param Config $config
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
@@ -422,7 +416,6 @@ class OssAdapter extends AbstractAdapter
|
||||
|
||||
/**
|
||||
* Get OSS Options
|
||||
* @param Config $config
|
||||
* @return array
|
||||
*/
|
||||
private function getOssOptions(Config $config)
|
||||
|
||||
@@ -22,15 +22,13 @@ class ProviderConfig
|
||||
{
|
||||
if (!static::$providerConfigs) {
|
||||
$providers = Composer::getMergedExtra('hyperf')['config'] ?? [];
|
||||
$handel = function ($arr) {
|
||||
return array_map(function ($item) {
|
||||
$explode = explode('@', $item);
|
||||
return [
|
||||
'provider' => $explode[0],
|
||||
'weight' => $explode[1] ?? 0,
|
||||
];
|
||||
}, $arr);
|
||||
};
|
||||
$handel = (fn($arr) => array_map(function ($item) {
|
||||
$explode = explode('@', $item);
|
||||
return [
|
||||
'provider' => $explode[0],
|
||||
'weight' => $explode[1] ?? 0,
|
||||
];
|
||||
}, $arr));
|
||||
$package = $handel($providers);
|
||||
array_change_v2k($package, 'provider');
|
||||
|
||||
@@ -43,9 +41,7 @@ class ProviderConfig
|
||||
}
|
||||
|
||||
$providers = array_values($package);
|
||||
usort($providers, function ($a, $b) {
|
||||
return intval($a['weight'] > $b['weight']);
|
||||
});
|
||||
usort($providers, fn($a, $b) => intval($a['weight'] > $b['weight']));
|
||||
$providers = array_column($providers, 'provider');
|
||||
static::$providerConfigs = static::loadProviders($providers);
|
||||
}
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
use Hyperf\HttpServer\Router\Router;
|
||||
|
||||
// 健康检查
|
||||
Router::get('/ping', function () {
|
||||
return [
|
||||
'code' => 200,
|
||||
'message' => 'ok',
|
||||
];
|
||||
});
|
||||
Router::get('/ping', fn() => [
|
||||
'code' => 200,
|
||||
'message' => 'ok',
|
||||
]);
|
||||
|
||||
@@ -94,7 +94,7 @@ class ConfigCenterController extends AdminAbstractController
|
||||
|
||||
public function beforeFormResponse($id, &$data)
|
||||
{
|
||||
$data['owner_uids'] = array_filter(array_map('intval', explode(',', $data['owner_uids'])));
|
||||
$data['owner_uids'] = array_filter(array_map('intval', explode(',', (string) $data['owner_uids'])));
|
||||
}
|
||||
|
||||
public function beforeSave($id, &$data)
|
||||
|
||||
@@ -22,7 +22,7 @@ class InstallCommand extends HyperfCommand
|
||||
|
||||
$sql = file_get_contents(__DIR__ . '/install.sql');
|
||||
|
||||
$re = Db::connection('config_center')->getPdo()->exec($sql);
|
||||
Db::connection('config_center')->getPdo()->exec($sql);
|
||||
|
||||
$this->output->success('config_center db install success');
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"hyperf/crontab": "~2.1.0",
|
||||
"hyperf/process": "~2.1.0",
|
||||
"hyperf/command": "~2.1.0",
|
||||
"hyperf/event": "~2.1.0",
|
||||
"hyperf/crontab": "~2.2.0",
|
||||
"hyperf/process": "~2.2.0",
|
||||
"hyperf/command": "~2.2.0",
|
||||
"hyperf/event": "~2.2.0",
|
||||
"hyperf-admin/base-utils": "dev-master"
|
||||
},
|
||||
"autoload": {
|
||||
|
||||
@@ -55,7 +55,7 @@ class CommandJobAbstract extends HyperfCommand
|
||||
$callback = function () {
|
||||
try {
|
||||
$this->beforeRun();
|
||||
call([$this, 'handle']);
|
||||
call($this->handle(...));
|
||||
$this->afterRun();
|
||||
} catch (\Throwable $throwable) {
|
||||
$this->onError($throwable);
|
||||
|
||||
@@ -51,7 +51,7 @@ class CronNodeController extends AbstractController
|
||||
CronNodes::STATUS_LOSS => 'danger',
|
||||
],
|
||||
'render' => function ($status, $row) {
|
||||
if ((time() - strtotime($row['updated_at'])) > 60) {
|
||||
if ((time() - strtotime((string) $row['updated_at'])) > 60) {
|
||||
return CronNodes::STATUS_LOSS;
|
||||
}
|
||||
|
||||
|
||||
@@ -168,9 +168,7 @@ class CrontabController extends AbstractController
|
||||
'运行次数: {state.counter}',
|
||||
],
|
||||
],
|
||||
'render' => function () {
|
||||
return '悬浮查看';
|
||||
},
|
||||
'render' => fn() => '悬浮查看',
|
||||
],
|
||||
],
|
||||
'rowActions' => [
|
||||
@@ -207,7 +205,7 @@ class CrontabController extends AbstractController
|
||||
|
||||
public function beforeFormResponse($id, &$record)
|
||||
{
|
||||
$record['bind_nodes'] = array_map('intval', explode(',', $record['bind_nodes']));
|
||||
$record['bind_nodes'] = array_map('intval', explode(',', (string) $record['bind_nodes']));
|
||||
}
|
||||
|
||||
public function trigger($id)
|
||||
|
||||
@@ -13,13 +13,10 @@ class CronManager
|
||||
*/
|
||||
private $config;
|
||||
|
||||
private $db;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$container = ApplicationContext::getContainer();
|
||||
$this->config = $container->get(ConfigInterface::class);
|
||||
$this->db = $this->getConn();
|
||||
}
|
||||
|
||||
public function addConfig()
|
||||
@@ -71,9 +68,9 @@ class CronManager
|
||||
}
|
||||
$list = $query->where('status', 1)->where('is_deleted', 0)->get()->toArray();
|
||||
foreach ($list as &$item) {
|
||||
$item['config'] = json_decode($item['config'], true);
|
||||
$item['state'] = json_decode($item['state'], true);
|
||||
$item['alert_rule'] = json_decode($item['alert_rule'], true);
|
||||
$item['config'] = json_decode((string) $item['config'], true);
|
||||
$item['state'] = json_decode((string) $item['state'], true);
|
||||
$item['alert_rule'] = json_decode((string) $item['alert_rule'], true);
|
||||
unset($item);
|
||||
}
|
||||
|
||||
@@ -106,7 +103,7 @@ class CronManager
|
||||
if (!$job) {
|
||||
return false;
|
||||
}
|
||||
$job['config'] = json_decode($job['config'], true);
|
||||
$job['config'] = json_decode((string) $job['config'], true);
|
||||
|
||||
return $this->convertCrontab($job);
|
||||
}
|
||||
@@ -127,9 +124,8 @@ class CronManager
|
||||
->setSingleton($item['singleton'] ?? true)
|
||||
->setOnOneServer($item['on_one_server'] ?? true)
|
||||
->setCallback($callback);
|
||||
break;
|
||||
case 'class':
|
||||
$class = explode('::', $config['execute']);
|
||||
$class = explode('::', (string) $config['execute']);
|
||||
$callback = [$class[0], 'run', $config['params']];
|
||||
|
||||
return (new Crontab)->setId($item['id'])
|
||||
@@ -138,7 +134,6 @@ class CronManager
|
||||
->setSingleton($item['singleton'] ?? true)
|
||||
->setOnOneServer($item['on_one_server'] ?? false)
|
||||
->setCallback($callback);
|
||||
break;
|
||||
case 'gateway':
|
||||
$callback = [
|
||||
'api' => $config['api'],
|
||||
@@ -154,7 +149,6 @@ class CronManager
|
||||
->setSingleton($item['singleton'] ?? true)
|
||||
->setOnOneServer($item['on_one_server'] ?? false)
|
||||
->setCallback($callback);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -214,7 +208,7 @@ class CronManager
|
||||
{
|
||||
$state = $this->getConn()->table('cron_jobs')->find($id)['state'];
|
||||
|
||||
return $state ? json_decode($state, true) : [];
|
||||
return $state ? json_decode((string) $state, true) : [];
|
||||
}
|
||||
|
||||
public function setJobState($id, $data)
|
||||
|
||||
@@ -58,7 +58,7 @@ class CrontabDispatcherProcess extends ProcessCrontabDispatcherProcess
|
||||
$crontabs = $this->getCrontabs();
|
||||
$this->logger->info(sprintf('Crontab dispatcher the %s time, jobs total %s', $this->counter, count($crontabs)));
|
||||
$last = time();
|
||||
foreach ($crontabs ?? [] as $key => $crontab) {
|
||||
foreach ($crontabs ?? [] as $crontab) {
|
||||
$time = $this->parser->parse($crontab->getRule(), $last);
|
||||
if ($time) {
|
||||
foreach ($time as $t) {
|
||||
|
||||
@@ -14,17 +14,14 @@ use Symfony\Component\Console\Output\NullOutput;
|
||||
|
||||
class Executor extends StrategyExecutor
|
||||
{
|
||||
private $manager;
|
||||
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
parent::__construct($container);
|
||||
$this->manager = new CronManager();
|
||||
}
|
||||
|
||||
public function execute(Crontab $crontab)
|
||||
{
|
||||
if (!($crontab instanceof Crontab) || !$crontab->getCallback()) {
|
||||
if (!$crontab->getCallback()) {
|
||||
return false;
|
||||
}
|
||||
$handle = $crontab->getType() . 'Handle';
|
||||
@@ -90,9 +87,7 @@ class Executor extends StrategyExecutor
|
||||
|
||||
public function evalHandle(Crontab $crontab)
|
||||
{
|
||||
return function () use ($crontab) {
|
||||
return eval($crontab->getCallback());
|
||||
};
|
||||
return fn() => eval($crontab->getCallback());
|
||||
}
|
||||
|
||||
protected function runInSingleton(Crontab $crontab, Closure $runnable): Closure
|
||||
|
||||
@@ -22,7 +22,7 @@ class InstallCommand extends HyperfCommand
|
||||
|
||||
$sql = file_get_contents(__DIR__ . '/install.sql');
|
||||
|
||||
$re = Db::connection('cron_center')->getPdo()->exec($sql);
|
||||
Db::connection('cron_center')->getPdo()->exec($sql);
|
||||
|
||||
$this->output->success('cron_center db install success');
|
||||
}
|
||||
|
||||
@@ -48,9 +48,7 @@ class DsnController extends AbstractController
|
||||
[
|
||||
'field' => 'create_uid',
|
||||
'title' => '创建者',
|
||||
'render' => function ($val, $row) {
|
||||
return $row['realname'];
|
||||
},
|
||||
'render' => fn($val, $row) => $row['realname'],
|
||||
],
|
||||
],
|
||||
'rowActions' => [
|
||||
|
||||
@@ -22,7 +22,7 @@ class InstallCommand extends HyperfCommand
|
||||
|
||||
$sql = file_get_contents(__DIR__ . '/install.sql');
|
||||
|
||||
$re = Db::connection('cron_center')->getPdo()->exec($sql);
|
||||
Db::connection('cron_center')->getPdo()->exec($sql);
|
||||
|
||||
$this->output->success('data_focus db install success');
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user