Skip to content

Commit

Permalink
Merge pull request #115 from mineadmin/2.0
Browse files Browse the repository at this point in the history
2.0
  • Loading branch information
zds-s authored Jan 31, 2024
2 parents cdf4500 + e792b3e commit 54688e5
Show file tree
Hide file tree
Showing 45 changed files with 1,264 additions and 330 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,22 @@ env:
SWOW_VERSION: 'develop'

jobs:
ci:
mineadmin:
name: Test PHP ${{ matrix.php-version }} on ${{ matrix.engine }}
runs-on: "${{ matrix.os }}"
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
# How to use Redis
redis:
image: redis
ports:
- 6379/tcp
strategy:
matrix:
os: [ ubuntu-latest ]
Expand All @@ -26,6 +39,11 @@ jobs:
tools: phpize
ini-values: opcache.enable_cli=0
coverage: none
- name: Verify MySQL connection from host
run: |
sudo apt-get install -y mysql-client libmysqlclient-dev
mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports[3306] }} -uroot -proot -e "SHOW GRANTS FOR 'root'@'localhost'"
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports[3306] }} -uroot -proot mysql
- name: Setup Swoole
if: ${{ matrix.engine == 'swoole' }}
run: |
Expand All @@ -46,6 +64,11 @@ jobs:
- name: Setup Packages
run: composer install -o --no-scripts
- name: Run Test Cases
env:
DB_PASSWORD: root
DB_USERNAME: root
DB_PORT: ${{ job.services.mysql.ports[3306] }}
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
run: |
vendor/bin/php-cs-fixer fix --dry-run # cs-fixer 格式化代码
composer analyse # phpstan 静态代码分析
Expand Down
1 change: 1 addition & 0 deletions .phpunit.cache/test-results
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"pest_2.33.1","defects":[],"times":{"P\\Tests\\HttpCases\\ExampleTest::__pest_evaluable_index_testing":0.015}}
2 changes: 1 addition & 1 deletion app/Setting/Mapper/SettingConfigGroupMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function assignModel()
* 删除组和所属配置.
* @throws \Exception
*/
public function deleteGroupAndConfig(int $id): bool
public function deleteGroupAndConfig(mixed $id): bool
{
/* @var $model SettingConfigGroup */
$model = $this->read($id);
Expand Down
6 changes: 3 additions & 3 deletions app/Setting/Mapper/SettingConfigMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ public function save(array $data): mixed
*/
public function handleSearch(Builder $query, array $params): Builder
{
if (! empty($params['group_id'])) {
if (isset($params['group_id']) && filled($params['group_id'])) {
$query->where('group_id', $params['group_id']);
}
if (! empty($params['name'])) {
if (isset($params['name']) && filled($params['name'])) {
$query->where('name', $params['name']);
}
if (! empty($params['key'])) {
if (isset($params['key']) && filled($params['key'])) {
$query->where('key', 'like', '%' . $params['key'] . '%');
}
return $query;
Expand Down
8 changes: 4 additions & 4 deletions app/Setting/Mapper/SettingCrontabMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ public function delete(array $ids): bool
*/
public function handleSearch(Builder $query, array $params): Builder
{
if (! empty($params['name'])) {
if (isset($params['name']) && filled($params['name'])) {
$query->where('name', 'like', '%' . $params['name'] . '%');
}
if (! empty($params['status'])) {
if (isset($params['status']) && filled($params['status'])) {
$query->where('status', $params['status']);
}
if (! empty($params['type'])) {
if (isset($params['type']) && filled($params['type'])) {
$query->where('type', $params['type']);
}
if (! empty($params['created_at']) && is_array($params['created_at']) && count($params['created_at']) == 2) {
if (isset($params['created_at']) && filled($params['created_at']) && is_array($params['created_at']) && count($params['created_at']) == 2) {
$query->whereBetween(
'created_at',
[$params['created_at'][0] . ' 00:00:00', $params['created_at'][1] . ' 23:59:59']
Expand Down
2 changes: 1 addition & 1 deletion app/Setting/Mapper/SettingDatasourceMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function assignModel()
public function handleSearch(Builder $query, array $params): Builder
{
// 数据源名称
if (! empty($params['source_name'])) {
if (isset($params['source_name']) && filled($params['source_name'])) {
$query->where('source_name', 'like', '%' . $params['source_name'] . '%');
}

Expand Down
4 changes: 2 additions & 2 deletions app/Setting/Mapper/SettingGenerateTablesMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public function delete(array $ids): bool
*/
public function handleSearch(Builder $query, array $params): Builder
{
if (! empty($params['table_name'])) {
if (isset($params['table_name']) && filled($params['table_name'])) {
$query->where('table_name', 'like', '%' . $params['table_name'] . '%');
}
if (! empty($params['minDate']) && ! empty($params['maxDate'])) {
if (isset($params['minDate']) && filled($params['minDate']) && isset($params['maxDate']) && filled($params['maxDate'])) {
$query->whereBetween(
'created_at',
[$params['minDate'] . ' 00:00:00', $params['maxDate'] . ' 23:59:59']
Expand Down
2 changes: 1 addition & 1 deletion app/Setting/Service/SettingConfigGroupService.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(SettingConfigGroupMapper $mapper)
* 删除配置组和其所属配置.
*/
#[Transaction]
public function deleteConfigGroup(int $id): bool
public function deleteConfigGroup(mixed $id): bool
{
return $this->mapper->deleteGroupAndConfig($id);
}
Expand Down
11 changes: 5 additions & 6 deletions app/Setting/Service/SettingCrontabService.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(
/**
* 保存.
*/
public function save(array $data): int
public function save(array $data): mixed
{
return parent::save($data);
}
Expand All @@ -52,7 +52,7 @@ public function save(array $data): int
* 更新.
*/
#[CacheEvict(prefix: 'setting:crontab:read', value: '_#{id}')]
public function update(int $id, array $data): bool
public function update(mixed $id, array $data): bool
{
return parent::update($id, $data);
}
Expand All @@ -64,18 +64,17 @@ public function delete(array $ids): bool
}

#[Cacheable(prefix: 'setting:crontab:read', value: '_#{id}', ttl: 600)]
public function read(int $id, array $column = ['*']): ?MineModel
public function read(mixed $id, array $column = ['*']): ?MineModel
{
return parent::read($id, $column);
}

/**
* 立即执行一次定时任务
* @param mixed $id
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function run($id): ?bool
public function run(mixed $id): ?bool
{
$crontab = new MineCrontab();
$model = $this->read($id);
Expand All @@ -90,7 +89,7 @@ public function run($id): ?bool
}

#[DeleteCache('crontab')]
public function changeStatus(int $id, string $value, string $filed = 'status'): bool
public function changeStatus(mixed $id, string $value, string $filed = 'status'): bool
{
return parent::changeStatus($id, $value, $filed);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Setting/Service/SettingDatasourceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getDataSourceTablePageList(?array $params = [], bool $isScope =
/**
* 同步远程库表结构到本地.
*/
public function syncRemoteTableStructToLocal(int $id, array $tableInfo): bool
public function syncRemoteTableStructToLocal(mixed $id, array $tableInfo): bool
{
if (empty($id)) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions app/Setting/Service/SettingGenerateColumnsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(SettingGenerateColumnsMapper $mapper)
/**
* 循环插入数据.
*/
public function save(array $data): int
public function save(array $data): mixed
{
$default_column = ['created_at', 'updated_at', 'created_by', 'updated_by', 'deleted_at', 'remark'];
// 组装数据
Expand Down Expand Up @@ -81,7 +81,7 @@ public function save(array $data): int
return 1;
}

public function update(int $id, array $data): bool
public function update(mixed $id, array $data): bool
{
$data['is_insert'] = $data['is_insert'] ? SettingGenerateColumns::YES : SettingGenerateColumns::NO;
$data['is_edit'] = $data['is_edit'] ? SettingGenerateColumns::YES : SettingGenerateColumns::NO;
Expand Down
6 changes: 3 additions & 3 deletions app/Setting/Service/SettingGenerateTablesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function loadTable(array $params): bool
* 同步数据表.
*/
#[Transaction]
public function sync(int $id): bool
public function sync(mixed $id): bool
{
$table = $this->read($id);
$columns = $this->dataMaintainService->getColumnList(
Expand Down Expand Up @@ -212,7 +212,7 @@ public function getModels(): array
* 预览代码
* @throws \Exception
*/
public function preview(int $id): array
public function preview(mixed $id): array
{
/** @var SettingGenerateTables $model */
$model = $this->read($id);
Expand Down Expand Up @@ -281,7 +281,7 @@ public function preview(int $id): array
* @throws NotFoundExceptionInterface
* @throws \Exception
*/
protected function generateCodeFile(int $id, int $adminId): SettingGenerateTables
protected function generateCodeFile(mixed $id, int $adminId): SettingGenerateTables
{
/** @var SettingGenerateTables $model */
$model = $this->read($id);
Expand Down
12 changes: 6 additions & 6 deletions app/System/Mapper/SystemApiColumnMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,32 @@ public function assignModel()
public function handleSearch(Builder $query, array $params): Builder
{
// 接口ID
if (! empty($params['api_id'])) {
if (isset($params['api_id']) && filled($params['api_id'])) {
$query->where('api_id', '=', $params['api_id']);
}

// 字段类型
if (! empty($params['type'])) {
if (isset($params['type']) && filled($params['type'])) {
$query->where('type', '=', $params['type']);
}

// 字段名称
if (! empty($params['name'])) {
if (isset($params['name']) && filled($params['name'])) {
$query->where('name', '=', $params['name']);
}

// 数据类型
if (! empty($params['data_type'])) {
if (isset($params['data_type']) && filled($params['data_type'])) {
$query->where('data_type', '=', $params['data_type']);
}

// 是否必填 1 非必填 2 必填
if (! empty($params['is_required'])) {
if (isset($params['is_required']) && filled($params['is_required'])) {
$query->where('is_required', '=', $params['is_required']);
}

// 状态 (1正常 2停用)
if (! empty($params['status'])) {
if (isset($params['status']) && filled($params['status'])) {
$query->where('status', '=', $params['status']);
}
return $query;
Expand Down
6 changes: 3 additions & 3 deletions app/System/Mapper/SystemApiGroupMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ public function assignModel()
public function handleSearch(Builder $query, array $params): Builder
{
// 应用组名称
if (! empty($params['name'])) {
if (isset($params['name']) && filled($params['name'])) {
$query->where('name', '=', $params['name']);
}

// 状态
if (! empty($params['status'])) {
if (isset($params['status']) && filled($params['status'])) {
$query->where('status', '=', $params['status']);
}

// 关联查询api列表
if (! empty($params['getApiList']) && $params['getApiList'] == true) {
if (isset($params['getApiList']) && filled($params['getApiList']) && $params['getApiList'] == true) {
$query->with(['apis' => function ($query) {
$query->where('status', SystemApi::ENABLE)->select(['id', 'group_id', 'name', 'access_name']);
}]);
Expand Down
8 changes: 4 additions & 4 deletions app/System/Mapper/SystemApiLogMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ public function assignModel()
*/
public function handleSearch(Builder $query, array $params): Builder
{
if (! empty($params['api_name'])) {
if (isset($params['api_name']) && filled($params['api_name'])) {
$query->where('api_name', 'like', '%' . $params['api_name'] . '%');
}
if (! empty($params['ip'])) {
if (isset($params['ip']) && filled($params['ip'])) {
$query->where('ip', 'like', '%' . $params['ip'] . '%');
}
if (! empty($params['access_name'])) {
if (isset($params['access_name']) && filled($params['access_name'])) {
$query->where('access_name', 'like', '%' . $params['access_name'] . '%');
}
if (! empty($params['access_time']) && is_array($params['access_time']) && count($params['access_time']) == 2) {
if (isset($params['access_time']) && filled($params['access_time']) && is_array($params['access_time']) && count($params['access_time']) == 2) {
$query->whereBetween(
'access_time',
[$params['access_time'][0] . ' 00:00:00', $params['access_time'][1] . ' 23:59:59']
Expand Down
4 changes: 2 additions & 2 deletions app/System/Mapper/SystemAppGroupMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public function assignModel()
public function handleSearch(Builder $query, array $params): Builder
{
// 应用组名称
if (! empty($params['name'])) {
if (isset($params['name']) && filled($params['name'])) {
$query->where('name', '=', $params['name']);
}

// 状态
if (! empty($params['status'])) {
if (isset($params['status']) && filled($params['status'])) {
$query->where('status', '=', $params['status']);
}
return $query;
Expand Down
8 changes: 4 additions & 4 deletions app/System/Mapper/SystemAppMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ public function assignModel()
*/
public function handleSearch(Builder $query, array $params): Builder
{
if (! empty($params['app_name'])) {
if (isset($params['app_name']) && filled($params['app_name'])) {
$query->where('app_name', $params['app_name']);
}

if (! empty($params['app_id'])) {
if (isset($params['app_id']) && filled($params['app_id'])) {
$query->where('app_id', $params['app_id']);
}

if (! empty($params['group_id'])) {
if (isset($params['group_id']) && filled($params['group_id'])) {
$query->where('group_id', $params['group_id']);
}

if (! empty($params['status'])) {
if (isset($params['status']) && filled($params['status'])) {
$query->where('status', $params['status']);
}
return $query;
Expand Down
Loading

0 comments on commit 54688e5

Please sign in to comment.