mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-31 06:50:51 +00:00
Merge branch 'v5.0.0dev' of https://gitee.com/ZhongBangKeJi/CRMEB into v5.0.0dev
This commit is contained in:
commit
b361986c0d
@ -88,11 +88,13 @@ class SystemCrud extends AuthController
|
||||
}
|
||||
//收集列表展示数据
|
||||
if ($item['is_table'] && !in_array($item['field_type'], ['primaryKey', 'addSoftDelete', 'addSoftDelete'])) {
|
||||
$columnField[] = [
|
||||
'field' => $item['field'],
|
||||
'name' => $item['table_name'],
|
||||
'type' => $item['from_type'],
|
||||
];
|
||||
if (isset($item['primaryKey']) && !$item['primaryKey']) {
|
||||
$columnField[] = [
|
||||
'field' => $item['field'],
|
||||
'name' => $item['table_name'],
|
||||
'type' => $item['from_type'],
|
||||
];
|
||||
}
|
||||
}
|
||||
//收集表单展示数据
|
||||
if ($item['from_type']) {
|
||||
@ -252,10 +254,10 @@ class SystemCrud extends AuthController
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//调整排序
|
||||
$makeData = [];
|
||||
$names = ['model', 'dao', 'service', 'controller', 'validate', 'router', 'api', 'pages'];
|
||||
$names = ['controller', 'validate', 'service', 'dao', 'model', 'route', 'router', 'api', 'pages'];
|
||||
foreach ($names as $name) {
|
||||
if (isset($data[$name])) {
|
||||
$makeData[] = $data[$name];
|
||||
@ -272,6 +274,7 @@ class SystemCrud extends AuthController
|
||||
$item['default_comment'] = $item['comment'];
|
||||
$item['default_default'] = $item['default'];
|
||||
$item['is_table'] = !!$item['is_table'];
|
||||
$item['required'] = !!$item['required'];
|
||||
$item['primaryKey'] = isset($item['primaryKey']) ? (int)$item['primaryKey'] : 0;
|
||||
$info['field']['tableField'][$key] = $item;
|
||||
}
|
||||
@ -569,6 +572,9 @@ class SystemCrud extends AuthController
|
||||
]
|
||||
];
|
||||
foreach ((array)$info->field['tableField'] as $item) {
|
||||
if (isset($item['primaryKey']) && $item['primaryKey']) {
|
||||
continue;
|
||||
}
|
||||
if (isset($item['is_table']) && $item['is_table']) {
|
||||
if (in_array($item['from_type'], ['frameImageOne', 'frameImages'])) {
|
||||
$keyName = 'slot';
|
||||
|
||||
@ -130,14 +130,45 @@ class SystemMenus extends AuthController
|
||||
}
|
||||
$data = [];
|
||||
|
||||
$uniqueAuthAll = $this->services->getColumn(['is_del' => 0, 'is_show' => 1], 'unique_auth');
|
||||
$uniqueAuthAll = array_filter($uniqueAuthAll, function ($item) {
|
||||
return !!$item;
|
||||
});
|
||||
$uniqueAuthAll = array_unique($uniqueAuthAll);
|
||||
|
||||
$uniqueFn = function ($path) use ($uniqueAuthAll) {
|
||||
$attPath = explode('/', $path);
|
||||
$uniqueAuth = '';
|
||||
if ($attPath) {
|
||||
$pathData = [];
|
||||
foreach ($attPath as $vv) {
|
||||
if (strstr($vv, '<') === false || strstr($vv, '?>') === false) {
|
||||
$pathData[] = $vv;
|
||||
}
|
||||
}
|
||||
$uniqueAuth = implode('-', $pathData);
|
||||
}
|
||||
|
||||
if (in_array($uniqueAuth, $uniqueAuthAll)) {
|
||||
$uniqueAuth .= '-' . uniqid();
|
||||
}
|
||||
|
||||
array_push($uniqueAuthAll, $uniqueAuth);
|
||||
|
||||
return $uniqueAuth;
|
||||
};
|
||||
|
||||
foreach ($menus as $menu) {
|
||||
if (empty($menu['menu_name'])) {
|
||||
return app('json')->fail(400198);
|
||||
}
|
||||
if (isset($menu['unique_auth']) && $menu['unique_auth']) {
|
||||
$menu['unique_auth'] = explode('/', $menu['api_url']);
|
||||
}
|
||||
$data[] = [
|
||||
'methods' => $menu['method'],
|
||||
'menu_name' => $menu['menu_name'],
|
||||
'unique_auth' => $menu['unique_auth'] ?? '',
|
||||
'unique_auth' => !empty($menu['unique_auth']) ? $menu['unique_auth'] : $uniqueFn($menu['api_url']),
|
||||
'api_url' => $menu['api_url'],
|
||||
'pid' => $menu['path'],
|
||||
'auth_type' => 2,
|
||||
|
||||
@ -102,4 +102,4 @@ Route::group('agent', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'agent', 'mark_name' => '分销']);
|
||||
])->option(['mark' => 'agent', 'mark_name' => '分销模块']);
|
||||
|
||||
@ -136,4 +136,4 @@ Route::group('app', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'app', 'mark_name' => '应用']);
|
||||
])->option(['mark' => 'app', 'mark_name' => '应用模块']);
|
||||
|
||||
@ -33,7 +33,7 @@ Route::group('cms', function () {
|
||||
Route::put('cms/relation/:id', 'v1.cms.Article/relation')->name('Relation')->option(['real_name' => '文章关联商品']);
|
||||
//取消关联
|
||||
Route::put('cms/unrelation/:id', 'v1.cms.Article/unrelation')->name('UnRelation')->option(['real_name' => '取消文章关联商品']);
|
||||
})->option(['parent' => 'cms', 'cate_name' => '文章']);
|
||||
})->option(['parent' => 'cms', 'cate_name' => '文章管理']);
|
||||
|
||||
/** 文章分类 */
|
||||
Route::group(function () {
|
||||
@ -61,4 +61,4 @@ Route::group('cms', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'cms', 'mark_name' => '文章']);
|
||||
])->option(['mark' => 'cms', 'mark_name' => '文章模块']);
|
||||
|
||||
@ -32,4 +32,4 @@ Route::group(function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'crud', 'mark_name' => 'CRUD']);
|
||||
])->option(['mark' => 'crud', 'mark_name' => '代码生成']);
|
||||
|
||||
@ -73,4 +73,4 @@ Route::group('diy', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'diy', 'mark_name' => 'DIY']);
|
||||
])->option(['mark' => 'diy', 'mark_name' => '页面装修']);
|
||||
|
||||
@ -43,4 +43,4 @@ Route::group('export', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'export', 'mark_name' => '导出']);
|
||||
])->option(['mark' => 'export', 'mark_name' => '数据导出']);
|
||||
|
||||
@ -47,4 +47,4 @@ Route::group('file', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'file', 'mark_name' => '附件']);
|
||||
])->option(['mark' => 'file', 'mark_name' => '素材管理']);
|
||||
|
||||
@ -66,4 +66,4 @@ Route::group('finance', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'finance', 'mark_name' => '财务']);
|
||||
])->option(['mark' => 'finance', 'mark_name' => '财务管理']);
|
||||
|
||||
@ -39,4 +39,4 @@ Route::group('freight', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'freight', 'mark_name' => '物流']);
|
||||
])->option(['mark' => 'freight', 'mark_name' => '物流管理']);
|
||||
|
||||
@ -68,11 +68,11 @@ Route::group('live', function () {
|
||||
Route::get('room/set_show/:id/:is_show', 'v1.marketing.live.LiveRoom/setShow')->option(['real_name' => '设置直播间是否显示']);
|
||||
//同步直播间状态
|
||||
Route::get('room/syncRoom', 'v1.marketing.live.LiveRoom/syncRoom')->option(['real_name' => '同步直播间状态']);
|
||||
})->option(['parent' => 'live', 'cate_name' => '主播间']);
|
||||
})->option(['parent' => 'live', 'cate_name' => '直播间']);
|
||||
|
||||
})->middleware([
|
||||
\app\http\middleware\AllowOriginMiddleware::class,
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'live', 'mark_name' => '直播']);
|
||||
])->option(['mark' => 'live', 'mark_name' => '直播管理']);
|
||||
|
||||
@ -203,4 +203,4 @@ Route::group('marketing', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'marketing', 'mark_name' => '营销']);
|
||||
])->option(['mark' => 'marketing', 'mark_name' => '营销活动']);
|
||||
|
||||
@ -66,4 +66,4 @@ Route::group('merchant', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'merchant', 'mark_name' => '物流']);
|
||||
])->option(['mark' => 'merchant', 'mark_name' => '门店核销']);
|
||||
|
||||
@ -48,4 +48,4 @@ Route::group('notify', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'notify', 'mark_name' => '消息']);
|
||||
])->option(['mark' => 'notify', 'mark_name' => '消息通知']);
|
||||
|
||||
@ -110,7 +110,7 @@ Route::group('order', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'order', 'mark_name' => '订单']);
|
||||
])->option(['mark' => 'order', 'mark_name' => '订单管理']);
|
||||
|
||||
/**
|
||||
* 售后 相关路由
|
||||
@ -137,4 +137,4 @@ Route::group('refund', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'refund', 'mark_name' => '退款']);
|
||||
])->option(['mark' => 'refund', 'mark_name' => '退款订单']);
|
||||
|
||||
@ -118,4 +118,4 @@ Route::group('product', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'product', 'mark_name' => '商品']);
|
||||
])->option(['mark' => 'product', 'mark_name' => '商品管理']);
|
||||
|
||||
@ -36,7 +36,7 @@ Route::group(function () {
|
||||
Route::get('get_workerman_url', 'PublicController/getWorkerManUrl')->option(['real_name' => '获取客服数据']);
|
||||
//测试
|
||||
Route::get('index', 'Test/index')->option(['real_name' => '测试地址']);
|
||||
})->middleware(AllowOriginMiddleware::class)->option(['mark' => 'login', 'mark_name' => '登录']);
|
||||
})->middleware(AllowOriginMiddleware::class)->option(['mark' => 'login', 'mark_name' => '登录相关']);
|
||||
|
||||
/**
|
||||
* miss 路由
|
||||
|
||||
@ -363,4 +363,4 @@ Route::group('setting', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'setting', 'mark_name' => '设置']);
|
||||
])->option(['mark' => 'setting', 'mark_name' => '系统设置']);
|
||||
|
||||
@ -89,4 +89,4 @@ Route::group('statistic', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'statistic', 'mark_name' => '统计']);
|
||||
])->option(['mark' => 'statistic', 'mark_name' => '程序统计']);
|
||||
|
||||
@ -189,7 +189,7 @@ Route::group('system', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'system', 'mark_name' => '维护']);
|
||||
])->option(['mark' => 'system', 'mark_name' => '系统维护']);
|
||||
|
||||
Route::group('system', function () {
|
||||
|
||||
@ -217,5 +217,5 @@ Route::group('system', function () {
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminEditorTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'system_file', 'mark_name' => '文件']);
|
||||
])->option(['mark' => 'system_file', 'mark_name' => '文件管理']);
|
||||
|
||||
|
||||
@ -185,4 +185,4 @@ Route::group('user', function () {
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
])->option(['mark' => 'user', 'mark_name' => '用户']);
|
||||
])->option(['mark' => 'user', 'mark_name' => '用户管理']);
|
||||
|
||||
@ -47,6 +47,8 @@ class SystemRouteDao extends BaseDao
|
||||
*/
|
||||
public function deleteRoutes(array $ids)
|
||||
{
|
||||
return $this->getModel()->where('id', 'in', $ids)->delete();
|
||||
return $this->getModel()::destroy(function ($q) use ($ids) {
|
||||
$q->whereIn('id', $ids);
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,8 +56,7 @@ class SystemCrud extends BaseModel
|
||||
return json_decode($value, true);
|
||||
}
|
||||
|
||||
|
||||
public function getRoutesIdAttr($value)
|
||||
public function getRouteIdsAttr($value)
|
||||
{
|
||||
return json_decode($value, true);
|
||||
}
|
||||
|
||||
@ -29,7 +29,6 @@ use crmeb\services\crud\ViewPages;
|
||||
use crmeb\services\crud\ViewRouter;
|
||||
use crmeb\services\FileService;
|
||||
use Phinx\Db\Adapter\AdapterFactory;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\helper\Str;
|
||||
use think\migration\db\Table;
|
||||
@ -582,8 +581,8 @@ class SystemCrudServices extends BaseServices
|
||||
$menuInfo = $meunService->save($dataMenu);
|
||||
}
|
||||
//删除掉添加的路由权限
|
||||
if ($crudInfo->routes_id) {
|
||||
$routeService->deleteRoutes($crudInfo->routes_id);
|
||||
if ($crudInfo->route_ids) {
|
||||
$routeService->deleteRoutes($crudInfo->route_ids);
|
||||
}
|
||||
//删除掉权限路由
|
||||
if ($crudInfo->menu_ids) {
|
||||
@ -689,7 +688,7 @@ class SystemCrudServices extends BaseServices
|
||||
'menu_ids' => json_encode($menuIds),//生成的菜单id
|
||||
'menu_id' => $menuInfo->id,//生成的菜单id
|
||||
'make_path' => json_encode($makePath),
|
||||
'routes_id' => json_encode($routeIds),
|
||||
'route_ids' => json_encode($routeIds),
|
||||
];
|
||||
|
||||
if ($crudInfo) {
|
||||
@ -700,8 +699,6 @@ class SystemCrudServices extends BaseServices
|
||||
$res = $this->dao->save($crudDate);
|
||||
}
|
||||
|
||||
// throw new ValidateException('测试中');
|
||||
|
||||
return $res;
|
||||
});
|
||||
|
||||
@ -781,6 +778,9 @@ class SystemCrudServices extends BaseServices
|
||||
$table = new Table($tableName, ['comment' => $tableComment], $this->getAdapter());
|
||||
//创建字段
|
||||
foreach ($tableField as $item) {
|
||||
if (isset($item['primaryKey']) && $item['primaryKey']) {
|
||||
continue;
|
||||
}
|
||||
$option = [];
|
||||
if (isset($item['limit'])) {
|
||||
$option['limit'] = (int)$item['limit'];
|
||||
@ -842,6 +842,7 @@ class SystemCrudServices extends BaseServices
|
||||
$dao = app()->make(Dao::class);
|
||||
$dao->setFilePathName($filePath['dao'] ?? '')->setbasePath($basePath)->handle($tableName, [
|
||||
'usePath' => $model->getUsePath(),
|
||||
'modelName' => $options['modelName'] ?? '',
|
||||
]);
|
||||
//生成service
|
||||
$service = app()->make(Service::class);
|
||||
|
||||
@ -97,8 +97,11 @@ class SystemRouteServices extends BaseServices
|
||||
foreach ($list as $key => $item) {
|
||||
if (!empty($item['children'])) {
|
||||
foreach ($item['children'] as $k => $v) {
|
||||
if (isset($v['cate_id']) && isset($v['method']) && $v['method'] === 'DELETE') {
|
||||
$v['method'] = 'DEL';
|
||||
if (isset($v['cate_id']) && isset($v['method'])) {
|
||||
if ($v['method'] === 'DELETE') {
|
||||
$v['method'] = 'DEL';
|
||||
}
|
||||
$v['pid'] = $v['cate_id'];
|
||||
$list[$key]['children'][$k] = $v;
|
||||
}
|
||||
}
|
||||
@ -108,6 +111,28 @@ class SystemRouteServices extends BaseServices
|
||||
return get_tree_children($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $importData
|
||||
* @return bool
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/4/26
|
||||
*/
|
||||
public function importData(array $importData)
|
||||
{
|
||||
foreach ($importData as $item) {
|
||||
$id = $this->dao->value(['method' => $item['method'], 'path' => $item['path']], 'id');
|
||||
if ($id) {
|
||||
$this->dao->update($id, [
|
||||
'request' => $item['request'],
|
||||
'response' => $item['response'],
|
||||
'request_type' => $item['request_type'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某个应用下的所有路由权限
|
||||
* @param string $app
|
||||
|
||||
@ -21,4 +21,56 @@ class SystemFileInfoServices extends BaseServices
|
||||
{
|
||||
$this->dao = $dao;
|
||||
}
|
||||
|
||||
public function syncfile()
|
||||
{
|
||||
$list = $this->flattenArray($this->scanDirectory());
|
||||
// $this->dao->saveAll($list);
|
||||
}
|
||||
|
||||
public function scanDirectory($dir = '')
|
||||
{
|
||||
if ($dir == '') $dir = root_path();
|
||||
$result = array();
|
||||
$files = scandir($dir);
|
||||
foreach ($files as $file) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
$path = $dir . '/' . $file;
|
||||
$fileInfo = array(
|
||||
'name' => $file,
|
||||
'update_time' => date('Y-m-d H:i:s', filemtime($path)),
|
||||
'create_time' => date('Y-m-d H:i:s', filectime($path)),
|
||||
'path' => str_replace(root_path(), '', $dir),
|
||||
'full_path' => str_replace(root_path(), '', $path),
|
||||
);
|
||||
if (is_dir($path)) {
|
||||
$fileInfo['type'] = 'dir';
|
||||
$fileInfo['contents'] = $this->scanDirectory($path);
|
||||
} else {
|
||||
$fileInfo['type'] = 'file';
|
||||
}
|
||||
$result[] = $fileInfo;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function flattenArray($arr)
|
||||
{
|
||||
$result = array();
|
||||
foreach ($arr as $item) {
|
||||
$result[] = array(
|
||||
'name' => $item['name'],
|
||||
'type' => $item['type'],
|
||||
'update_time' => $item['update_time'],
|
||||
'create_time' => $item['create_time'],
|
||||
'path' => $item['path'],
|
||||
'full_path' => $item['full_path'],
|
||||
);
|
||||
if (isset($item['contents'])) {
|
||||
$result = array_merge($result, $this->flattenArray($item['contents']));
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@
|
||||
namespace crmeb\command;
|
||||
|
||||
|
||||
use app\services\system\log\SystemFileInfoServices;
|
||||
use app\services\system\SystemRouteServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use think\console\Command;
|
||||
@ -18,10 +19,11 @@ class Util extends Command
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('util')
|
||||
->addArgument('type', Argument::REQUIRED, '类型replace/route')
|
||||
->addArgument('type', Argument::REQUIRED, '类型replace/route/file/apifox')
|
||||
->addOption('h', null, Option::VALUE_REQUIRED, '替换成当前域名')
|
||||
->addOption('u', null, Option::VALUE_REQUIRED, '替换的域名')
|
||||
->addOption('a', null, Option::VALUE_REQUIRED, '应用名')
|
||||
->addOption('f', null, Option::VALUE_REQUIRED, '导入文件路径,文件只能在项目根目录下或者根目录下的其他文件夹内')
|
||||
->setDescription('工具类');
|
||||
}
|
||||
|
||||
@ -48,6 +50,16 @@ class Util extends Command
|
||||
}
|
||||
app()->make(SystemRouteServices::class)->syncRoute($appName);
|
||||
break;
|
||||
case 'file':
|
||||
app()->make(SystemFileInfoServices::class)->syncfile();
|
||||
break;
|
||||
case 'apifox':
|
||||
$filePath = $input->getOption('f');
|
||||
if (!$filePath) {
|
||||
return $output->error('缺少导入文件地址');
|
||||
}
|
||||
$this->import($filePath);
|
||||
break;
|
||||
}
|
||||
|
||||
$output->info('执行成功');
|
||||
@ -87,4 +99,130 @@ class Util extends Command
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
* @param string $filePath
|
||||
* @return mixed
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/4/26
|
||||
*/
|
||||
protected function import(string $filePath)
|
||||
{
|
||||
$preg = '/\{+[a-zA-Z0-9]+\}/';
|
||||
|
||||
$res = file_get_contents(app()->getRootPath() . $filePath);
|
||||
|
||||
$data = json_decode($res, true)['apiCollection'][0]['items'];
|
||||
|
||||
$route = [];
|
||||
foreach ($data as $item) {
|
||||
foreach ($item['items'] as $value) {
|
||||
if (isset($value['api'])) {
|
||||
$path = str_replace('//', '/', str_replace('{}', '', $value['api']['path']));
|
||||
$paramePath = $this->getPathValue($value['api']['parameters']['path'] ?? []);
|
||||
if (strstr($path, ':') !== false) {
|
||||
$path = str_replace(':', '', $path);
|
||||
}
|
||||
if (preg_match_all($preg, $path, $matches)) {
|
||||
$paramePathMatche = [];
|
||||
if (isset($matches[0]) && $matches[0]) {
|
||||
foreach ($matches[0] as $v) {
|
||||
$paramePathMatche[] = str_replace(['{', '}'], ['<', '>'], $v);
|
||||
}
|
||||
}
|
||||
if ($paramePathMatche) {
|
||||
$paramePath = implode('/', $paramePathMatche);
|
||||
}
|
||||
}
|
||||
if ($path[0] === '/') {
|
||||
$path = substr($path, 1);
|
||||
}
|
||||
$route[] = [
|
||||
'method' => strtoupper($value['api']['method']),
|
||||
'path' => $path . $paramePath,
|
||||
'request_type' => $value['api']['requestBody']['type'],
|
||||
'request' => $this->getRequest($value['api']['requestBody']['parameters'] ?? []),
|
||||
'response' => $this->getResponse($value['api']['responses'][0]['jsonSchema']['properties'] ?? []),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return app()->make(SystemRouteServices::class)->importData($route);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求返回数据
|
||||
* @param array $options
|
||||
* @param string $parentId
|
||||
* @return array
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/4/26
|
||||
*/
|
||||
protected function getResponse(array $options, $parentId = '')
|
||||
{
|
||||
$response = [];
|
||||
foreach ($options as $key => $option) {
|
||||
$id = uniqid();
|
||||
$response[] = [
|
||||
'attribute' => $key,
|
||||
'type' => $option['type'],
|
||||
'trip' => '',
|
||||
'id' => $id,
|
||||
'parentId' => $parentId,
|
||||
];
|
||||
if (isset($option['properties'])) {
|
||||
$response = array_merge($response, $this->getResponse($option['properties'], $id));
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求数据
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/4/26
|
||||
*/
|
||||
protected function getRequest(array $options)
|
||||
{
|
||||
$request = [];
|
||||
foreach ($options as $option) {
|
||||
$request[] = [
|
||||
'attribute' => $option['name'],
|
||||
'type' => $option['type'] === 'text' ? 'string' : $option['type'],
|
||||
'must' => 0,
|
||||
'trip' => $option['description'],
|
||||
'id' => $option['id'],
|
||||
];
|
||||
}
|
||||
return $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理path路径
|
||||
* @param array $options
|
||||
* @return string
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/4/26
|
||||
*/
|
||||
protected function getPathValue(array $options)
|
||||
{
|
||||
$path = [];
|
||||
foreach ($options as $option) {
|
||||
if (strstr($option['name'], '?') !== false) {
|
||||
$option['name'] = str_replace('?', '', $option['name']) . '?';
|
||||
}
|
||||
$path[] = '<' . $option['name'] . '>';
|
||||
}
|
||||
|
||||
return implode('/', $path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,6 +238,9 @@ abstract class Make
|
||||
if (isset($this->value['use-php']) && !empty($options['usePath'])) {
|
||||
$this->value['use-php'] = "use " . str_replace('/', '\\', $options['usePath']) . ";\n";
|
||||
}
|
||||
if (isset($this->value['modelName']) && !$this->value['modelName'] && !empty($options['modelName'])) {
|
||||
$this->value['modelName'] = $options['modelName'];
|
||||
}
|
||||
|
||||
$contentStr = str_replace($this->var, $this->value, $content);
|
||||
$filePath = $this->getFilePathName($path, $this->value['nameCamel']);
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
crmeb/public/admin/system_static/css/app.dd63f4d8.css
Normal file
2
crmeb/public/admin/system_static/css/app.dd63f4d8.css
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
|
||||
[data-v-aa8a590c] .center{text-align:center;margin-right:0!important;margin-left:5px}.layout-columns-aside[data-v-085278ae]{width:70px;height:100%;background:var(--prev-bg-columnsMenuBar);-webkit-box-shadow:0 1px 4px rgba(0,21,41,.08);box-shadow:0 1px 4px rgba(0,21,41,.08);border-right:1px solid var(--prev-border-color-lighter)}.layout-columns-aside ul[data-v-085278ae]{position:relative}.layout-columns-aside ul li[data-v-085278ae]{color:var(--prev-bg-columnsMenuBarColor);width:100%;height:50px;text-align:center;display:-webkit-box;display:-ms-flexbox;display:flex;cursor:pointer;position:relative;z-index:1}.layout-columns-aside ul li .columns-vertical[data-v-085278ae]{margin:auto}.layout-columns-aside ul li .columns-vertical .columns-vertical-title[data-v-085278ae]{padding-top:1px}.layout-columns-aside ul li .columns-horizontal[data-v-085278ae]{display:-webkit-box;display:-ms-flexbox;display:flex;height:50px;width:100%;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;padding:0 5px}.layout-columns-aside ul li .columns-horizontal i[data-v-085278ae]{margin-right:3px}.layout-columns-aside ul li .columns-horizontal a[data-v-085278ae]{display:-webkit-box;display:-ms-flexbox;display:flex}.layout-columns-aside ul li .columns-horizontal a .columns-horizontal-title[data-v-085278ae]{padding-top:1px}.layout-columns-aside ul li a[data-v-085278ae]{text-decoration:none;color:var(--prev-bg-columnsMenuBarColor)}.layout-columns-aside ul .layout-columns-active[data-v-085278ae],.layout-columns-aside ul .layout-columns-active a[data-v-085278ae]{color:var(--prev-bg-columnsMenuActiveColor);-webkit-transition:.3s ease-in-out;transition:.3s ease-in-out}.layout-columns-aside ul .columns-card[data-v-085278ae],.layout-columns-aside ul .columns-round[data-v-085278ae]{background:var(--prev-color-primary);position:absolute;left:50%;top:2px;height:50px;width:65px;-webkit-transform:translateX(-50%);transform:translateX(-50%);z-index:0;-webkit-transition:.3s ease-in-out;transition:.3s ease-in-out;border-radius:5px}.layout-columns-aside ul .columns-card[data-v-085278ae]{top:0;height:50px;width:100%;border-radius:0}
|
||||
@ -0,0 +1 @@
|
||||
.message[data-v-41766f9d] .ivu-table-header thead tr th{padding:8px 16px}.message[data-v-41766f9d] .ivu-tabs-tab{border-radius:0!important}.table-box[data-v-41766f9d]{padding:20px}.is-table[data-v-41766f9d]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.btn[data-v-41766f9d]{padding:6px 12px;cursor:pointer;color:#2d8cf0;font-size:10px;border-radius:3px}.is-switch-close[data-v-41766f9d]{background-color:#504444}.is-switch[data-v-41766f9d]{background-color:#eb5252}.notice-list[data-v-41766f9d]{background-color:#308cf5;margin:0 15px}.table[data-v-41766f9d]{padding:0 18px}
|
||||
@ -0,0 +1 @@
|
||||
.form-width[data-v-cb985366]{width:500px}.item[data-v-cb985366]{display:-webkit-box;display:-ms-flexbox;display:flex;margin-bottom:10px}.item .row[data-v-cb985366]{width:140px;margin-right:10px}.form-width[data-v-3b04daa4]{width:500px}.item[data-v-3b04daa4]{display:-webkit-box;display:-ms-flexbox;display:flex;margin-bottom:10px}.item .row[data-v-3b04daa4]{width:140px;margin-right:10px}.table-options[data-v-3b04daa4]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.table-options .create[data-v-3b04daa4]{font-size:16px;margin-left:10px;cursor:pointer}.options-list .item[data-v-3b04daa4]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.options-list .item .add[data-v-3b04daa4]{font-size:24px;color:#2d8cf0}.form-width[data-v-4cd76107]{width:500px}.ivu-steps .ivu-steps-title[data-v-90ac6582]{line-height:26px}.code-wapper[data-v-90ac6582]{min-height:800px;padding-bottom:90px}.btn[data-v-90ac6582]{position:fixed;bottom:10px;height:80px;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;width:88.7%;background-color:hsla(0,0%,100%,.6);-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.tab-1[data-v-90ac6582]{padding-bottom:100px}[data-v-90ac6582] .el-input__inner{padding-left:7px}[data-v-90ac6582] .ivu-form-item{margin-bottom:17px}[data-v-90ac6582] .ivu-form-item-error-tip{padding-top:2px}[data-v-90ac6582] .tip{color:#bbb;line-height:16px;padding-top:5px}
|
||||
@ -0,0 +1 @@
|
||||
.trees-coadd[data-v-54f42439]{width:100%;height:500px;border-radius:4px;overflow:hidden}.scollhide[data-v-54f42439]{width:100%;height:100%;overflow:auto;margin-left:18px;padding:10px 0 10px 0;-webkit-box-sizing:border-box;box-sizing:border-box}.content[data-v-54f42439]{font-size:12px}.time[data-v-54f42439]{font-size:12px;color:#2d8cf0}.icons-item[data-v-54f42439]{float:left;margin:6px 6px 6px 0;width:53px;text-align:center;list-style:none;cursor:pointer;height:50px;color:#5c6b77;-webkit-transition:all .2s ease;transition:all .2s ease;position:relative;padding-top:10px}.icons-item .ivu-icon[data-v-54f42439]{font-size:16px}.search-rule[data-v-54f42439]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:10px;background-color:#f2f2f2}.rule[data-v-54f42439]{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;max-height:700px;overflow:scroll}.rule[data-v-54f42439]::-webkit-scrollbar{width:10px;height:10px;background-color:#f5f5f5}.rule[data-v-54f42439]::-webkit-scrollbar-track{border-radius:4px;background-color:#f5f5f5}.rule[data-v-54f42439]::-webkit-scrollbar-thumb{border-radius:4px;background-color:#555}.rule-list[data-v-54f42439]{background-color:#f8f5f5;width:32%;margin:5px;border-radius:3px;padding:10px;color:#333;cursor:pointer;-webkit-transition:all .1s;transition:all .1s}.rule-list[data-v-54f42439]:hover{background-color:#c5d1dd}.rule-list div[data-v-54f42439]{white-space:nowrap}.select-rule[data-v-54f42439]{background-color:#c5d1dd}.add[data-v-54f42439]{-webkit-box-align:center;-ms-flex-align:center;align-items:center}.add[data-v-54f42439],.df[data-v-54f42439]{display:-webkit-box;display:-ms-flexbox;display:flex}.df[data-v-54f42439]{-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.vxeTable>.vxe-table--header-wrapper[data-v-4a179718]{background:#fff!important}.vxeTable .icon[data-v-4a179718]{font-size:20px}.rule[data-v-4a179718]{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;overflow-y:scroll;height:-webkit-max-content;height:-moz-max-content;height:max-content;max-height:600px;-webkit-box-flex:1;-ms-flex:1;flex:1}.tree[data-v-4a179718]::-webkit-scrollbar{width:2px;background-color:#f5f5f5}.rule[data-v-4a179718]::-webkit-scrollbar{width:10px;height:10px;background-color:#f5f5f5}.rule[data-v-4a179718]::-webkit-scrollbar-track{border-radius:4px;background-color:#f5f5f5}.rule[data-v-4a179718]::-webkit-scrollbar-thumb{border-radius:4px;background-color:#ccc}.rule-list[data-v-4a179718]{background-color:#f2f2f2;width:48.5%;height:-webkit-max-content;height:-moz-max-content;height:max-content;margin:5px;border-radius:3px;padding:10px;color:#333;cursor:pointer;-webkit-transition:all .1s;transition:all .1s}.rule-list[data-v-4a179718]:hover{background-color:#badbfb}.rule-list div[data-v-4a179718]{white-space:nowrap}.select-rule[data-v-4a179718]{background-color:#badbfb}.route-list[data-v-4a179718]{display:-webkit-box;display:-ms-flexbox;display:flex;margin-top:10px}.route-list .tree[data-v-4a179718]{width:200px;overflow-y:scroll;max-height:600px}
|
||||
@ -0,0 +1 @@
|
||||
[data-v-aa8a590c] .center{text-align:center;margin-right:0!important;margin-left:5px}
|
||||
@ -0,0 +1 @@
|
||||
.showOn[data-v-26313647]{color:#2d8cf0;background:#f0faff;z-index:2}.tabBox_img[data-v-26313647]{width:36px;height:36px;border-radius:4px;cursor:pointer}.tabBox_img img[data-v-26313647]{width:100%;height:100%}.modelBox .ivu-table-header[data-v-26313647],.modelBox[data-v-26313647]{width:100%!important}.trees-coadd[data-v-26313647]{width:100%;height:385px}.trees-coadd .scollhide[data-v-26313647]{width:100%;height:100%;overflow-x:hidden;overflow-y:scroll}.scollhide[data-v-26313647]::-webkit-scrollbar{display:none}[data-v-26313647] .ivu-menu-vertical .ivu-menu-item-group-title,[data-v-26313647] .ivu-menu-vertical.ivu-menu-light:after{display:none}.left-wrapper[data-v-26313647]{height:904px;background:#fff;border-right:1px solid #f2f2f2}.menu-item[data-v-26313647]{z-index:50;position:relative;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;word-break:break-all}.menu-item .icon-box[data-v-26313647]{z-index:3;position:absolute;right:20px;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);display:none}.menu-item:hover .icon-box[data-v-26313647]{display:block}.menu-item .right-menu[data-v-26313647]{z-index:10;position:absolute;right:-106px;top:-11px;width:auto;min-width:121px}
|
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
|
||||
[data-v-aa8a590c] .center{text-align:center;margin-right:0!important;margin-left:5px}
|
||||
@ -0,0 +1 @@
|
||||
[data-v-aa652f5c] .diy-fullscreen{overflow:hidden}[data-v-aa652f5c] .diy-fullscreen .ivu-modal{top:0;left:0;right:0;bottom:0;height:100%;width:100%!important}[data-v-aa652f5c] .diy-fullscreen .ivu-modal .ivu-modal-content,[data-v-aa652f5c] .diy-fullscreen .ivu-modal .ivu-modal-content .ivu-modal-body{height:100%}[data-v-aa652f5c] .diy-fullscreen .ivu-modal .ivu-tabs .ivu-tabs-content-animated{height:92%;background-color:#2f2f2f!important}[data-v-aa652f5c] .diy-fullscreen .ivu-modal .ivu-tabs-content{height:100%}[data-v-aa652f5c] .diy-fullscreen .ivu-modal .ivu-tabs .ivu-tabs-tabpane{height:92%}.diy-header[data-v-aa652f5c]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.diy-header .diy-header-icon[data-v-aa652f5c]{margin-right:30px;cursor:pointer}.diy-header .diy-header-icon[data-v-aa652f5c]:hover{opacity:.8}[data-v-aa652f5c] .ivu-modal{top:70px}.ivu-modal-content .ivu-modal-body[data-v-aa652f5c]{min-height:632px;height:80vh;overflow:hidden}.ivu-tabs .ivu-tabs-content-animated[data-v-aa652f5c]{min-height:560px;height:73vh;margin-top:-1px}.ivu-tabs .ivu-tabs-tabpane[data-v-aa652f5c]{min-height:560px;margin-top:-1px}.ivu-tabs-nav .ivu-tabs-tab .ivu-icon[data-v-aa652f5c]{color:red}[data-v-aa652f5c] body .ivu-select-dropdown .ivu-dropdown-transfer{background:red!important}.file-left[data-v-aa652f5c] .ivu-select-dropdown.ivu-dropdown-transfer .ivu-dropdown-menu .ivu-dropdown-item:hover{background-color:#e5e5e5!important}[data-v-aa652f5c] .ivu-tabs.ivu-tabs-card>.ivu-tabs-bar .ivu-tabs-nav-container{background-color:#fff}.demo-drawer-footer[data-v-aa652f5c]{width:100%;position:absolute;bottom:0;left:0;border-top:1px solid #e8e8e8;padding:10px 16px;text-align:right;background:#fff}.file[data-v-aa652f5c]{position:relative}.file .save[data-v-aa652f5c]{position:absolute;right:140px;top:60px;z-index:99}.file-box[data-v-aa652f5c]{height:100%}
|
||||
File diff suppressed because one or more lines are too long
1
crmeb/public/admin/system_static/js/app.0d48ca32.js
Normal file
1
crmeb/public/admin/system_static/js/app.0d48ca32.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user