Compare commits
45 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
90990f8782 | ||
![]() |
40276babfb | ||
![]() |
818ffb2ce6 | ||
![]() |
763a05fa80 | ||
![]() |
8c153cce60 | ||
![]() |
93b6f1e2f1 | ||
![]() |
61b9a07d99 | ||
![]() |
d75c455bdc | ||
![]() |
04e2b1ffe5 | ||
![]() |
14b5b3ce3a | ||
![]() |
a4e84ffa75 | ||
![]() |
bd7f62b9ed | ||
![]() |
3a2689db18 | ||
![]() |
3fb55deaaf | ||
![]() |
b07defb0e9 | ||
![]() |
377b72ae19 | ||
![]() |
dd023caf36 | ||
![]() |
163d1c4bee | ||
![]() |
2c2b7f8723 | ||
![]() |
d533aeaa9e | ||
![]() |
a6cebc3750 | ||
![]() |
214ca68b44 | ||
![]() |
e712f824f5 | ||
![]() |
f301f149fb | ||
![]() |
96751d6974 | ||
![]() |
da9aa45036 | ||
![]() |
9ec1285cb9 | ||
![]() |
3947ba7386 | ||
![]() |
d0a9a41c68 | ||
![]() |
7fbee46c73 | ||
![]() |
c8a7d0291c | ||
![]() |
d0044ee019 | ||
![]() |
3466c8ec1f | ||
![]() |
b3be31750a | ||
![]() |
ca7a3df823 | ||
![]() |
9a5e7010b1 | ||
![]() |
2e67214032 | ||
![]() |
c5fb6f9409 | ||
![]() |
8f73948223 | ||
![]() |
2941eeac1e | ||
![]() |
e0007d4150 | ||
![]() |
0e3656c7cc | ||
![]() |
44ed0b9788 | ||
![]() |
1d660ba648 | ||
![]() |
202f7f1dea |
57
README.md
57
README.md
@@ -4,7 +4,10 @@
|
||||
|
||||
|
||||
<p align="center"><code>CatchAdmin</code>是一款基于<a href="http://www.thinkphp.cn/" target="_blank">thinkphp framework</a>和
|
||||
<a href="https://pro.loacg.com/docs/getting-started">ant degisn pro vue</a>二次开发而成的后台管理系统,采用了目前趋势的前后端分离开发模式,后端仅需要提供简洁的 API 数据结构,前端负责呈现数据。目前前端采用数据驱动,大大提高了开发效率。这不仅仅是一个项目,更是后端更新技术栈的一次实践</p>
|
||||
<a href="https://github.com/PanJiaChen/vue-element-admin/">element admin</a>二次开发而成后台管理系统。因为 thinkphp 的简单高效,文档齐全。在看了很多 thinkphp 生态中的后台管理系统,发现没有一款合适的前后端分离系统。遂开发了 CatchAdmin。
|
||||
完全利用了 thinkphp6 的新版本特性 ServiceProvider,将管理系统模块之间的耦合降到了最低限度。每个模块之间都有独立的 controller,路由,模型,数据表`。在开发上尽可能将模块之间的影响降到最低,降低了开发上的难度。基于 CatchAdmin 可以开发 cms,CRM,OA 等
|
||||
等系统。也封装了很多实用的工具,提升开发体验。
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="http://doc.catchadmin.com/">文档</a> |
|
||||
@@ -28,18 +31,56 @@
|
||||
<img src="https://svg.hamm.cn/badge.svg?key=License&value=Apache-2.0"/>
|
||||
</p >
|
||||
|
||||
## 功能
|
||||
- [x] `用户管理` 后台用户管理
|
||||
- [x] `部门管理` 配置公司的部门结构,支持树形结构
|
||||
- [x] `岗位管理` 配置后台用户的职务
|
||||
- [x] `菜单管理` 配置系统菜单,按钮等等
|
||||
- [x] `角色管理` 配置用户担当的角色,分配权限
|
||||
- [x] `数据字典` 管理后台表结构
|
||||
- [x] `操作日志` 后台用户操作记录
|
||||
- [x] `登录日志` 后台系统用户的登录记录
|
||||
- [x] `代码生成` 生成 API 端的 CURD 操作
|
||||
- [x] `敏感词` 支持敏感词配置
|
||||
- [x] `附件管理` 可管理上传的文件
|
||||
- [ ] `微信管理`
|
||||
|
||||
## 项目地址
|
||||
- [github 地址](https://github.com/yanwenwu/catch-admin)
|
||||
- [gitee 地址](https://gitee.com/jaguarjack/catchAdmin)
|
||||
- [前端 Vue 项目地址](https://github.com/yanwenwu/catch-admin-vue)
|
||||
- [文档地址](https://github.com/catch-admin/document)[个人精力实在有限,希望可以小伙伴们可以一起维护文档]
|
||||
## 预览
|
||||
<p align="center">
|
||||
<img src="https://cdn.learnku.com/uploads/images/202005/17/18206/0ECPy72zUZ.png!large">
|
||||
</p>
|
||||
<p align="center">
|
||||
<img src="https://cdn.learnku.com/uploads/images/202005/17/18206/ngzSU0A9SI.png!large">
|
||||
</p>
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="https://s1.ax1x.com/2020/09/07/wucNXq.md.png"></td>
|
||||
<td><img src="https://s1.ax1x.com/2020/09/07/wucm6I.md.png"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://s1.ax1x.com/2020/09/07/wucZpd.md.png"></td>
|
||||
<td><img src="https://s1.ax1x.com/2020/09/07/wuce1A.md.png"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://s1.ax1x.com/2020/09/07/wucnXt.md.png"></td>
|
||||
<td><img src="https://s1.ax1x.com/2020/09/07/wucKnP.md.png"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://s1.ax1x.com/2020/09/07/wuc3tg.md.png"></td>
|
||||
<td><img src="https://s1.ax1x.com/2020/09/07/wucM0f.md.png"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://s1.ax1x.com/2020/09/07/wucQ78.md.png"></td>
|
||||
<td><img src="https://s1.ax1x.com/2020/09/07/wuc1AS.md.png"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://s1.ax1x.com/2020/09/07/wuc8hQ.md.png"></td>
|
||||
<td><img src="https://s1.ax1x.com/2020/09/07/wucY1s.md.png"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://s1.ax1x.com/2020/09/07/wucJpj.md.png"></td>
|
||||
<td><img src="https://s1.ax1x.com/2020/09/07/wuctcn.md.png"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## 环境要求
|
||||
- php7.1+ (需以下扩展)
|
||||
@@ -110,7 +151,7 @@ composer create-project jaguarjack/catchadmin:dev-master
|
||||
> 排名部分先后
|
||||
|
||||
- [top-think/think](https://github.com/top-think/think)
|
||||
- [ant-design-pro-vue](https://github.com/sendya/ant-design-pro-vue)
|
||||
- [element-admin](https://panjiachen.gitee.io/vue-element-admin-site/zh/)
|
||||
- [thans/tp-jwt-auth](https://packagist.org/packages/thans/tp-jwt-auth)
|
||||
- [workerman/workerman](https://github.com/walkor/Workerman)
|
||||
- [jaguarjack/think-filesystem-cloud](https://github.com/yanwenwu/think-filesystem-cloud)
|
||||
|
@@ -33,7 +33,7 @@ class Request extends \think\Request
|
||||
$user = $this->auth->guard($guard ? : config('catch.auth.default.guard'))->user();
|
||||
|
||||
if ($user->status == Users::DISABLE) {
|
||||
throw new LoginFailedException('该用户已被禁用');
|
||||
throw new LoginFailedException('该用户已被禁用', Code::USER_FORBIDDEN);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
if ($e instanceof TokenExpiredException) {
|
||||
@@ -45,7 +45,7 @@ class Request extends \think\Request
|
||||
if ($e instanceof TokenInvalidException) {
|
||||
throw new FailedException('token 不合法', Code::LOST_LOGIN);
|
||||
}
|
||||
throw new FailedException('认证失败: '. $e->getMessage(), Code::LOST_LOGIN);
|
||||
throw new FailedException('认证失败: '. $e->getMessage(), $e->getCode());
|
||||
}
|
||||
|
||||
return $user;
|
||||
|
BIN
catch/.DS_Store
vendored
Normal file
BIN
catch/.DS_Store
vendored
Normal file
Binary file not shown.
13
catch/cms/CmsService.php
Normal file
13
catch/cms/CmsService.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace catchAdmin\cms;
|
||||
|
||||
use catcher\ModuleService;
|
||||
|
||||
class CmsService extends ModuleService
|
||||
{
|
||||
public function loadRouteFrom()
|
||||
{
|
||||
// TODO: Implement loadRouteFrom() method.
|
||||
return __DIR__ . DIRECTORY_SEPARATOR . 'route.php';
|
||||
}
|
||||
}
|
30
catch/cms/model/Hello.php
Normal file
30
catch/cms/model/Hello.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CatchAdmin [Just Like ~ ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace catchAdmin\cms\model;
|
||||
|
||||
use catcher\base\CatchModel as Model;
|
||||
|
||||
class Hello extends Model
|
||||
{
|
||||
protected $name = 'hello';
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'good', //
|
||||
'creator_id', // 创建人ID
|
||||
'created_at', // 创建时间
|
||||
'updated_at', // 更新时间
|
||||
'deleted_at', // 软删除
|
||||
];
|
||||
|
||||
|
||||
}
|
15
catch/cms/module.json
Normal file
15
catch/cms/module.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "内容管理",
|
||||
"alias": "cms",
|
||||
"description": "cms,博客,企业站点,内容管理",
|
||||
"version": "1.0.0",
|
||||
"keywords": [],
|
||||
"order": 0,
|
||||
"services": [
|
||||
"\\catchAdmin\\cms\\CmsService"
|
||||
],
|
||||
"aliases": {},
|
||||
"files": [],
|
||||
"requires": [],
|
||||
"enable": true
|
||||
}
|
14
catch/cms/route.php
Normal file
14
catch/cms/route.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
// you should user `$router`
|
||||
$router->group(function () use ($router){
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
//hello路由
|
||||
$router->resource('hello', '\catchAdmin\cms\controller\Hello')->middleware('auth');
|
||||
|
||||
//hello路由
|
||||
$router->resource('hello', '\catchAdmin\cms\controller\Hello')->middleware('auth');
|
@@ -11,15 +11,13 @@ class LoginLogEvent
|
||||
{
|
||||
$agent = request()->header('user-agent');
|
||||
|
||||
$username = Users::where('email', $params['email'])->value('username');
|
||||
|
||||
app(LoginLog::class)->storeBy([
|
||||
'login_name' => $username ? : $params['email'],
|
||||
'login_name' => $params['login_name'],
|
||||
'login_ip' => request()->ip(),
|
||||
'browser' => $this->getBrowser($agent),
|
||||
'os' => $this->getOs($agent),
|
||||
'login_at' => time(),
|
||||
'status' => $params['success'] ? 1 : 2,
|
||||
'status' => $params['success'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -6,6 +6,7 @@ use catchAdmin\permissions\model\Users;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\CatchAuth;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\Code;
|
||||
use catcher\exceptions\LoginFailedException;
|
||||
use thans\jwt\facade\JWTAuth;
|
||||
|
||||
@@ -21,29 +22,15 @@ class Index extends CatchController
|
||||
*/
|
||||
public function login(LoginRequest $request, CatchAuth $auth)
|
||||
{
|
||||
$params = $request->param();
|
||||
|
||||
$token = $auth->attempt($params);
|
||||
|
||||
$user = $auth->user();
|
||||
|
||||
if ($user->status == Users::DISABLE) {
|
||||
throw new LoginFailedException('该用户已被禁用');
|
||||
try {
|
||||
$params = $request->param();
|
||||
$token = $auth->attempt($params);
|
||||
return CatchResponse::success([
|
||||
'token' => $token,
|
||||
], '登录成功');
|
||||
} catch (\Exception $exception) {
|
||||
return CatchResponse::fail('登录失败', $exception->getCode());
|
||||
}
|
||||
|
||||
// 记录用户登录
|
||||
$user->last_login_ip = request()->ip();
|
||||
$user->last_login_time = time();
|
||||
$user->save();
|
||||
|
||||
// 登录事件
|
||||
$params['success'] = $token;
|
||||
|
||||
event('loginLog', $params);
|
||||
|
||||
return $token ? CatchResponse::success([
|
||||
'token' => $token,
|
||||
], '登录成功') : CatchResponse::success('', '登录失败');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -5,6 +5,7 @@ use catcher\base\CatchController;
|
||||
use catchAdmin\permissions\model\Department as DepartmentModel;
|
||||
use catcher\base\CatchRequest;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\exceptions\FailedException;
|
||||
use catcher\Tree;
|
||||
|
||||
class Department extends CatchController
|
||||
@@ -63,6 +64,10 @@ class Department extends CatchController
|
||||
*/
|
||||
public function delete($id): \think\response\Json
|
||||
{
|
||||
if ($this->department->where('parent_id', $id)->find()) {
|
||||
throw new FailedException('存在子部门,无法删除');
|
||||
}
|
||||
|
||||
return CatchResponse::success($this->department->deleteBy($id));
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ use catcher\exceptions\FailedException;
|
||||
use catcher\library\ParseClass;
|
||||
use catcher\Tree;
|
||||
use catchAdmin\permissions\model\Permissions;
|
||||
use think\helper\Str;
|
||||
use think\response\Json;
|
||||
|
||||
class Permission extends CatchController
|
||||
@@ -66,9 +67,22 @@ class Permission extends CatchController
|
||||
|
||||
// 如果是子分类 自动写入父类模块
|
||||
$parentId = $params['parent_id'] ?? 0;
|
||||
if ($parentId) {
|
||||
$parent = $this->permissions->findBy($parentId);
|
||||
$params['module'] = $parent->module;
|
||||
// 按钮类型寻找上级
|
||||
if ($params['type'] == Permissions::BTN_TYPE && $parentId) {
|
||||
$permissionMark = $params['permission_mark'];
|
||||
// 查找父级
|
||||
$parentPermission = $this->permissions->findBy($parentId);
|
||||
// 如果父级是顶级 parent_id = 0
|
||||
if ($parentPermission->parent_id) {
|
||||
if (Str::contains($parentPermission->permission_mark, '@')) {
|
||||
list($controller, $action) = explode('@', $parentPermission->permission_mark);
|
||||
$permissionMark = $controller . '@' . $permissionMark;
|
||||
} else {
|
||||
$permissionMark = $parentPermission->permission_mark .'@'. $permissionMark;
|
||||
}
|
||||
}
|
||||
$params['permission_mark'] = $permissionMark;
|
||||
$params['module'] = $parentPermission->module;
|
||||
}
|
||||
|
||||
return CatchResponse::success($this->permissions->storeBy($params));
|
||||
@@ -85,6 +99,33 @@ class Permission extends CatchController
|
||||
{
|
||||
$permission = $this->permissions->findBy($id);
|
||||
|
||||
$params = $request->param();
|
||||
// 按钮类型
|
||||
if ($params['type'] == Permissions::BTN_TYPE && $permission->parent_id) {
|
||||
$parentPermission = $this->permissions->findBy($permission->parent_id);
|
||||
|
||||
$permissionMark = $params['permission_mark'];
|
||||
if ($parentPermission->parent_id) {
|
||||
if (Str::contains($parentPermission->permission_mark, '@')) {
|
||||
list($controller, $action) = explode('@', $parentPermission->permission_mark);
|
||||
$permissionMark = $controller . '@' . $permissionMark;
|
||||
} else {
|
||||
$permissionMark = $parentPermission->permission_mark .'@'. $permissionMark;
|
||||
}
|
||||
}
|
||||
|
||||
$params['permission_mark'] = $permissionMark;
|
||||
|
||||
|
||||
$this->permissions->where('id',$id)->update(array_merge($params, [
|
||||
'parent_id' => $permission->parent_id,
|
||||
'level' => $permission->level,
|
||||
'updated_at' => time()
|
||||
]));
|
||||
|
||||
return CatchResponse::success();
|
||||
}
|
||||
|
||||
$params = array_merge($request->param(), [
|
||||
'parent_id' => $permission->parent_id,
|
||||
'level' => $permission->level
|
||||
@@ -134,17 +175,9 @@ class Permission extends CatchController
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$permission = $this->permissions->findBy($id);
|
||||
$this->permissions->show($id);
|
||||
|
||||
$permission->status = $permission->status == Permissions::ENABLE ? Permissions::DISABLE : Permissions::ENABLE;
|
||||
|
||||
if ($permission->save()) {
|
||||
$this->permissions->where('parent_id', $id)->update([
|
||||
'status' => $permission->status,
|
||||
]);
|
||||
}
|
||||
|
||||
return CatchResponse::success($permission->save());
|
||||
return CatchResponse::success();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,14 +193,15 @@ class Permission extends CatchController
|
||||
public function getMethods($id, ParseClass $parseClass)
|
||||
{
|
||||
$permission = Permissions::where('id', $id)->find();
|
||||
|
||||
$module = $permission->module;
|
||||
|
||||
$controller = explode('@', $permission->permission_mark)[0];
|
||||
|
||||
$methods = $parseClass->setModule('catch')->setRule($module, $controller)->onlySelfMethods();
|
||||
|
||||
return CatchResponse::success($methods);
|
||||
try {
|
||||
$methods = $parseClass->setModule('catch')->setRule($module, $controller)->onlySelfMethods();
|
||||
return CatchResponse::success($methods);
|
||||
}catch (\Exception $e) {
|
||||
return CatchResponse::success([]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,7 @@
|
||||
namespace catchAdmin\permissions\controller;
|
||||
|
||||
use catchAdmin\permissions\model\Permissions;
|
||||
use catchAdmin\permissions\model\Roles;
|
||||
use catcher\base\CatchRequest as Request;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\CatchResponse;
|
||||
@@ -38,14 +39,19 @@ class Role extends CatchController
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
$this->role->storeBy($request->param());
|
||||
$params = $request->param();
|
||||
|
||||
$permissions = $request->param('permissions');
|
||||
if (Roles::where('identify', $params['identify'])->find()) {
|
||||
throw new FailedException('角色标识 [' . $params['identify'] . ']已存在');
|
||||
}
|
||||
|
||||
$this->role->storeBy($params);
|
||||
$permissions = $params['permissions'];
|
||||
if (!empty($permissions)) {
|
||||
$this->role->attachPermissions(array_unique($permissions));
|
||||
}
|
||||
if (!empty($request->param('departments'))) {
|
||||
$this->role->attachDepartments($request->param('departments'));
|
||||
if (!empty($params['permissions'])) {
|
||||
$this->role->attachDepartments($params['permissions']);
|
||||
}
|
||||
// 添加角色
|
||||
return CatchResponse::success();
|
||||
@@ -69,6 +75,10 @@ class Role extends CatchController
|
||||
*/
|
||||
public function update($id, Request $request): Json
|
||||
{
|
||||
if (Roles::where('identify', $request->param('identify'))->where('id', '<>', $id)->find()) {
|
||||
throw new FailedException('角色标识 [' . $request->param('identify') . ']已存在');
|
||||
}
|
||||
|
||||
$this->role->updateBy($id, $request->param());
|
||||
$role = $this->role->findBy($id);
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\controller;
|
||||
|
||||
use catchAdmin\permissions\excel\UserExport;
|
||||
use catcher\base\CatchRequest as Request;
|
||||
use catchAdmin\permissions\model\Permissions;
|
||||
use catchAdmin\permissions\model\Roles;
|
||||
@@ -11,6 +12,7 @@ use catcher\base\CatchController;
|
||||
use catcher\CatchAuth;
|
||||
use catcher\CatchCacheKeys;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\library\excel\Excel;
|
||||
use catcher\Tree;
|
||||
use catcher\Utils;
|
||||
use think\facade\Cache;
|
||||
@@ -49,7 +51,7 @@ class User extends CatchController
|
||||
{
|
||||
$user = $auth->user();
|
||||
|
||||
$roles = $user->getRoles();
|
||||
$roles = $user->getRoles()->column('identify');
|
||||
|
||||
$permissionIds = $user->getPermissionsBy($user->id);
|
||||
// 缓存用户权限
|
||||
@@ -86,7 +88,9 @@ class User extends CatchController
|
||||
|
||||
$this->user->attachRoles($request->param('roles'));
|
||||
|
||||
$this->user->attachJobs($request->param('jobs'));
|
||||
if ($request->param('jobs')) {
|
||||
$this->user->attachJobs($request->param('jobs'));
|
||||
}
|
||||
|
||||
return CatchResponse::success('', '添加成功');
|
||||
}
|
||||
@@ -225,4 +229,18 @@ class User extends CatchController
|
||||
'hasRoles' => $roleIds,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*
|
||||
* @time 2020年09月08日
|
||||
* @param Excel $excel
|
||||
* @param UserExport $userExport
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function export(Excel $excel, UserExport $userExport)
|
||||
{
|
||||
return CatchResponse::success($excel->save($userExport, Utils::publicPath('export/users')));
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class UpdateRoles extends Migrator
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
if ($this->hasTable('roles')) {
|
||||
$table = $this->table('roles');
|
||||
|
||||
$table->addColumn('identify', 'string', [
|
||||
'limit' => 20,
|
||||
'default' => 1,
|
||||
'comment' => '角色的标识,用英文表示,用于后台路由权限',
|
||||
'after' => 'role_name'])
|
||||
->update();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class UpdatePermissions extends Migrator
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
if ($this->hasTable('permissions')) {
|
||||
$table = $this->table('permissions');
|
||||
|
||||
$table->removeColumn('method')
|
||||
->removeColumn('hide_children_in_menu')
|
||||
->renameColumn('status', 'hidden')
|
||||
->update();
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
|
||||
use think\migration\Seeder;
|
||||
|
||||
class PermissionSeed extends Seeder
|
||||
class PermissionsMenusSeed extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run Method.
|
||||
@@ -27,20 +27,18 @@ class PermissionSeed extends Seeder
|
||||
'parent_id' => 0,
|
||||
'level' => '',
|
||||
'route' => '/permissions',
|
||||
'icon' => 'appstore',
|
||||
'icon' => 'el-icon-cpu',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'permission@index',
|
||||
'component' => 'pageView',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'permission_mark' => 'permission',
|
||||
'component' => 'layout',
|
||||
'redirect' => '/permissions/users',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 100,
|
||||
'created_at' => 1587461455,
|
||||
'updated_at' => 1593044101,
|
||||
'updated_at' => 1599362429,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
@@ -51,20 +49,18 @@ class PermissionSeed extends Seeder
|
||||
'parent_id' => 1,
|
||||
'level' => '1',
|
||||
'route' => '/permissions/users',
|
||||
'icon' => 'user',
|
||||
'icon' => 'el-icon-user',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@index',
|
||||
'permission_mark' => 'user',
|
||||
'component' => 'users',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 10,
|
||||
'created_at' => 1587461597,
|
||||
'updated_at' => 1592371975,
|
||||
'updated_at' => 1599362429,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
@@ -78,17 +74,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461647,
|
||||
'updated_at' => 1591316160,
|
||||
'updated_at' => 1599030266,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
@@ -101,17 +95,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@create',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461696,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599030266,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
@@ -124,17 +116,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461721,
|
||||
'updated_at' => 1591345475,
|
||||
'updated_at' => 1599030266,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
@@ -147,17 +137,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@edit',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461742,
|
||||
'updated_at' => 1591345504,
|
||||
'updated_at' => 1599030266,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
4 =>
|
||||
@@ -170,17 +158,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@update',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461762,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599030266,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
5 =>
|
||||
@@ -193,17 +179,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461841,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599030266,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
6 =>
|
||||
@@ -216,17 +200,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@switchStatus',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461876,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599030266,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
7 =>
|
||||
@@ -239,17 +221,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@recover',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461901,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599030266,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
@@ -261,20 +241,18 @@ class PermissionSeed extends Seeder
|
||||
'parent_id' => 1,
|
||||
'level' => '1',
|
||||
'route' => '/permissions/roles',
|
||||
'icon' => 'usergroup-add',
|
||||
'icon' => 'el-icon-s-custom',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'role@index',
|
||||
'permission_mark' => 'role',
|
||||
'component' => 'roles',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 9,
|
||||
'created_at' => 1587461939,
|
||||
'updated_at' => 1592371974,
|
||||
'updated_at' => 1599362438,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
@@ -288,17 +266,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'role@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461984,
|
||||
'updated_at' => 1591341461,
|
||||
'updated_at' => 1599362438,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
@@ -311,17 +287,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'role@create',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462007,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599362438,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
@@ -334,17 +308,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'role@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462021,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599362438,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
@@ -357,17 +329,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'role@edit',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462040,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599362438,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
4 =>
|
||||
@@ -380,17 +350,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'role@update',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462058,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599362438,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
5 =>
|
||||
@@ -403,17 +371,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'role@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462070,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599362438,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
6 =>
|
||||
@@ -426,17 +392,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'role@getPermissions',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462094,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599362438,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
@@ -448,20 +412,18 @@ class PermissionSeed extends Seeder
|
||||
'parent_id' => 1,
|
||||
'level' => '1',
|
||||
'route' => '/permissions/rules',
|
||||
'icon' => 'build',
|
||||
'icon' => 'el-icon-collection-tag',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'permission@index',
|
||||
'permission_mark' => 'permission',
|
||||
'component' => 'rules',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 8,
|
||||
'created_at' => 1587462147,
|
||||
'updated_at' => 1592371979,
|
||||
'updated_at' => 1599362475,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
@@ -475,17 +437,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'permission@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462205,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599362475,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
@@ -498,17 +458,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'permission@create',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462232,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599362475,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
@@ -521,40 +479,36 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'permission@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462250,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599362475,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'id' => 23,
|
||||
'permission_name' => '查看',
|
||||
'permission_name' => '禁用/启用',
|
||||
'parent_id' => 19,
|
||||
'level' => '1-19',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'permission@edit',
|
||||
'permission_mark' => 'permission@show',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462273,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599362475,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
4 =>
|
||||
@@ -567,17 +521,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'permission@update',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462284,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599362475,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
5 =>
|
||||
@@ -590,17 +542,36 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'permission@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462296,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599362475,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
6 =>
|
||||
array (
|
||||
'id' => 106,
|
||||
'permission_name' => '权限方法',
|
||||
'parent_id' => 19,
|
||||
'level' => '1-19',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'permission@getMethods',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1599221913,
|
||||
'updated_at' => 1599362475,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
@@ -612,20 +583,18 @@ class PermissionSeed extends Seeder
|
||||
'parent_id' => 1,
|
||||
'level' => '1',
|
||||
'route' => '/permissions/departments',
|
||||
'icon' => 'desktop',
|
||||
'icon' => 'el-icon-monitor',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'departments',
|
||||
'component' => 'departments',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 7,
|
||||
'created_at' => 1587462488,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599362429,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
@@ -639,17 +608,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'department@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462529,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599030565,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
@@ -662,17 +629,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'department@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462548,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599030565,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
@@ -685,17 +650,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'department@update',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462579,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599030565,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
@@ -708,17 +671,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'department@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462592,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599030565,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
@@ -730,20 +691,18 @@ class PermissionSeed extends Seeder
|
||||
'parent_id' => 1,
|
||||
'level' => '1',
|
||||
'route' => '/permissions/jobs',
|
||||
'icon' => 'skin',
|
||||
'icon' => 'el-icon-setting',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'job',
|
||||
'component' => 'jobs',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462707,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1599362429,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
@@ -757,17 +716,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'job@index',
|
||||
'permission_mark' => 'job@indexs',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462757,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1598959522,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
@@ -780,17 +737,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'job@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462774,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1598959522,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
@@ -803,17 +758,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'job@update',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462785,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1598959522,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
@@ -826,17 +779,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'job@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462794,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1598959522,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
4 =>
|
||||
@@ -849,17 +800,15 @@ class PermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'job@getAll',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462818,
|
||||
'updated_at' => 1587547118,
|
||||
'updated_at' => 1598959522,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
@@ -24,7 +24,9 @@ class RolesSeed extends Seeder
|
||||
{
|
||||
\catchAdmin\permissions\model\Roles::create([
|
||||
'role_name' => '超级管理员',
|
||||
'identify' => 'admin',
|
||||
'description' => 'super user',
|
||||
'data_range' => 1,
|
||||
'creator_id' => 1,
|
||||
]);
|
||||
|
||||
|
78
catch/permissions/excel/UserExport.php
Normal file
78
catch/permissions/excel/UserExport.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CatchAdmin [Just Like ~ ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace catchAdmin\permissions\excel;
|
||||
|
||||
use catchAdmin\permissions\model\Users;
|
||||
use catcher\library\excel\ExcelContract;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
|
||||
class UserExport implements ExcelContract
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置头部
|
||||
*
|
||||
* @time 2020年09月08日
|
||||
* @return string[]
|
||||
*/
|
||||
public function headers(): array
|
||||
{
|
||||
// TODO: Implement headers() method.
|
||||
return [
|
||||
'id', '用户名', '邮箱', '状态', '创建日期'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理数据
|
||||
*
|
||||
* @time 2020年09月08日
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return \think\Collection
|
||||
*/
|
||||
public function sheets()
|
||||
{
|
||||
// TODO: Implement sheets() method.
|
||||
$users = Users::field(['id', 'username', 'email', 'status', 'created_at'])->select();
|
||||
|
||||
foreach ($users as &$user) {
|
||||
$user->status = $user->status == Users::ENABLE ? '启用' : '停用';
|
||||
}
|
||||
|
||||
return $users;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置开始行
|
||||
*
|
||||
* @time 2020年09月08日
|
||||
* @return int
|
||||
*/
|
||||
public function setRow()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置标题
|
||||
*
|
||||
* @time 2020年09月08日
|
||||
* @return array
|
||||
*/
|
||||
public function setTitle()
|
||||
{
|
||||
return [
|
||||
'A1:G1', '导出用户', Alignment::HORIZONTAL_CENTER
|
||||
];
|
||||
}
|
||||
}
|
@@ -57,6 +57,11 @@ trait DataRangScopeTrait
|
||||
$userIds[] = $user->id;
|
||||
break;
|
||||
case Roles::DEPARTMENT_DOWN_DATA:
|
||||
// 查一下下级部门
|
||||
$departmentIds = Department::where('parent_id', $user->department_id)->column('id');
|
||||
$departmentIds[] = $user->department_id;
|
||||
$userIds = array_merge([$user->id], $this->getUserIdsByDepartmentId($departmentIds));
|
||||
break;
|
||||
case Roles::DEPARTMENT_DATA:
|
||||
$userIds = array_merge($userIds, $this->getUserIdsByDepartmentId([$user->department_id]));
|
||||
break;
|
||||
|
@@ -35,9 +35,7 @@ class Department extends CatchModel
|
||||
*/
|
||||
public function getList(): array
|
||||
{
|
||||
return $this->withoutField(['department_name'])
|
||||
->addFields(['department_name as title'])
|
||||
->catchSearch()
|
||||
return $this->catchSearch()
|
||||
->catchOrder()
|
||||
->select()->toArray();
|
||||
}
|
||||
|
@@ -19,12 +19,10 @@ class Permissions extends CatchModel
|
||||
'component', // 组件
|
||||
'redirect',
|
||||
'keepalive',
|
||||
'hide_children_in_menu',
|
||||
'creator_id',
|
||||
'status',
|
||||
'hidden',
|
||||
'module', // 模块
|
||||
'route', // 路由
|
||||
'method', // 请求方法
|
||||
'permission_mark', // 权限标识
|
||||
'type', // 1 菜单 2 按钮
|
||||
'sort', // 排序字段
|
||||
@@ -71,7 +69,7 @@ class Permissions extends CatchModel
|
||||
return parent::whereIn('id', $permissionIds)
|
||||
->field(['permission_name as title', 'id', 'parent_id',
|
||||
'route', 'icon', 'component', 'redirect', 'module',
|
||||
'keepalive as keepAlive', 'hide_children_in_menu', 'type', 'permission_mark', 'status'
|
||||
'keepalive as keepAlive', 'type', 'permission_mark', 'hidden'
|
||||
])
|
||||
->catchOrder()
|
||||
->select();
|
||||
@@ -101,4 +99,44 @@ class Permissions extends CatchModel
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$permission = $this->findBy($id);
|
||||
|
||||
// 不能使用改属性判断,模型有该属性,使用数组方式
|
||||
// $permission->hidden
|
||||
$hidden = $permission['hidden'] == Permissions::ENABLE ? Permissions::DISABLE : Permissions::ENABLE;
|
||||
|
||||
$nextLevelIds = $this->getNextLevel([$id]);
|
||||
|
||||
$nextLevelIds[] = $id;
|
||||
|
||||
return $this->whereIn('id', $nextLevelIds)->update([
|
||||
'hidden' => $hidden,
|
||||
'updated_at' => time(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 level ids
|
||||
*
|
||||
* @time 2020年09月06日
|
||||
* @param array $id
|
||||
* @param array $ids
|
||||
* @return array
|
||||
*/
|
||||
protected function getNextLevel(array $id, &$ids = [])
|
||||
{
|
||||
$_ids = $this->whereIn('parent_id', $id)
|
||||
->where('type', self::MENU_TYPE)
|
||||
->column('id');
|
||||
|
||||
if (count($_ids)) {
|
||||
$ids = array_merge($_ids, $this->getNextLevel($_ids, $ids));
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ class Roles extends CatchModel
|
||||
protected $field = [
|
||||
'id', //
|
||||
'role_name', // 角色名
|
||||
'identify', // 身份标识
|
||||
'parent_id', // 父级ID
|
||||
'creator_id', // 创建者
|
||||
'data_range', // 数据范围
|
||||
|
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model\search;
|
||||
|
||||
use catchAdmin\permissions\model\Department;
|
||||
|
||||
trait UserSearch
|
||||
{
|
||||
public function searchUsernameAttr($query, $value, $data)
|
||||
@@ -20,6 +22,8 @@ trait UserSearch
|
||||
|
||||
public function searchDepartmentIdAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where($this->aliasField('department_id'), $value);
|
||||
$departmentIds = Department::where('parent_id', $value)->column('id');
|
||||
$departmentIds[] = $value;
|
||||
return $query->whereIn($this->aliasField('department_id'), $departmentIds);
|
||||
}
|
||||
}
|
||||
|
@@ -23,4 +23,5 @@ $router->group(function () use ($router){
|
||||
$router->put('users/recover/<id>', '\catchAdmin\permissions\controller\User@recover');
|
||||
$router->get('users/get/roles', '\catchAdmin\permissions\controller\User@getRoles');
|
||||
$router->get('user/info', '\catchAdmin\permissions\controller\User@info');
|
||||
$router->get('user/export', '\catchAdmin\permissions\controller\User@export');
|
||||
})->middleware('auth');
|
@@ -5,7 +5,7 @@ use catcher\base\CatchController;
|
||||
use catcher\CatchResponse;
|
||||
use catchAdmin\system\model\Attachments as AttachmentsModel;
|
||||
use catcher\Utils;
|
||||
use think\facade\Filesystem;
|
||||
use catcher\facade\FileSystem;
|
||||
|
||||
class Attachments extends CatchController
|
||||
{
|
||||
@@ -39,7 +39,15 @@ class Attachments extends CatchController
|
||||
|
||||
if ($model->deleteBy($id)) {
|
||||
foreach ($attachments as $attachment) {
|
||||
Filesystem::delete($attachment->path);
|
||||
if ($attachment->driver == 'local') {
|
||||
$localPath = config('filesystem.disks.local.root') . DIRECTORY_SEPARATOR;
|
||||
$path = $localPath . str_replace('\\','\/', $attachment->path);
|
||||
if (!FileSystem::exists($path)) {
|
||||
Filesystem::delete($path);
|
||||
}
|
||||
} else {
|
||||
Filesystem::delete($attachment->path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -42,7 +42,10 @@ class DataDictionary extends CatchController
|
||||
$tables = $tables->where('engine', $engine)->values();
|
||||
}
|
||||
|
||||
return CatchResponse::paginate(Paginator::make($tables->toArray(), $request->get('limit') ?? 10, $request->get('page') ?? 1, $tables->count(), false, []));
|
||||
$page = $request->get('page', 1);
|
||||
$limit = $request->get('limit', 10);
|
||||
|
||||
return CatchResponse::paginate(Paginator::make(array_slice($tables->toArray(), ($page - 1) * $limit, $limit), $limit, $page, $tables->count(), false, []));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -35,7 +35,7 @@ class Developers extends Migrator
|
||||
->addColumn('mobile', 'string', ['limit' => 30,'null' => false,'default' => '','signed' => false,'comment' => '手机号',])
|
||||
->addColumn('id_card', 'string', ['limit' => 50,'null' => false,'default' => '','signed' => false,'comment' => '身份证',])
|
||||
->addColumn('alipay_account', 'string', ['limit' => 100,'null' => false,'default' => '','signed' => false,'comment' => '支付宝账户',])
|
||||
->addColumn('status', 'boolean', ['null' => false,'default' => 1,'signed' => false,'comment' => '1 待认证 1 已认证',])
|
||||
->addColumn('status', 'boolean', ['null' => false,'default' => 1,'signed' => false,'comment' => '1 待认证 2 已认证',])
|
||||
->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建时间',])
|
||||
->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '更新时间',])
|
||||
->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '软删除',])
|
||||
|
@@ -18,8 +18,8 @@ class ConfigSeed extends Seeder
|
||||
[
|
||||
'name' => '基础配置',
|
||||
'pid' => 0,
|
||||
'component' => 'basis',
|
||||
'key' => 'basis',
|
||||
'component' => 'basic',
|
||||
'key' => 'basic',
|
||||
],
|
||||
[
|
||||
'name' => '上传配置',
|
||||
|
679
catch/system/database/seeds/SystemMenusSeed.php
Normal file
679
catch/system/database/seeds/SystemMenusSeed.php
Normal file
@@ -0,0 +1,679 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Seeder;
|
||||
|
||||
class SystemMenusSeed extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run Method.
|
||||
*
|
||||
* Write your database seeder using this method.
|
||||
*
|
||||
* More information on writing seeders is available here:
|
||||
* http://docs.phinx.org/en/latest/seeding.html
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
\catcher\Utils::importTreeData($this->getPermissions(), 'permissions', 'parent_id');
|
||||
}
|
||||
|
||||
protected function getPermissions()
|
||||
{
|
||||
return array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 37,
|
||||
'permission_name' => '系统管理',
|
||||
'parent_id' => 0,
|
||||
'level' => '',
|
||||
'route' => '/system',
|
||||
'icon' => 'el-icon-s-tools',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'system',
|
||||
'component' => 'layout',
|
||||
'redirect' => 'attactments',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 2,
|
||||
'type' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462349,
|
||||
'updated_at' => 1599288737,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 38,
|
||||
'permission_name' => '数据字典',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/system/database',
|
||||
'icon' => 'el-icon-copy-document',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'dataDictionary',
|
||||
'component' => 'database',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'sort' => 8,
|
||||
'created_at' => 1587463087,
|
||||
'updated_at' => 1599362678,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 39,
|
||||
'permission_name' => '查看',
|
||||
'parent_id' => 38,
|
||||
'level' => '37-38',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'dataDictionary@view',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587463113,
|
||||
'updated_at' => 1599362691,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 40,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 38,
|
||||
'level' => '37-38',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'dataDictionary@tables',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 10,
|
||||
'created_at' => 1587463173,
|
||||
'updated_at' => 1599362678,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'id' => 41,
|
||||
'permission_name' => '优化',
|
||||
'parent_id' => 38,
|
||||
'level' => '37-38',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'dataDictionary@optimize',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587463201,
|
||||
'updated_at' => 1599362678,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'id' => 42,
|
||||
'permission_name' => '备份',
|
||||
'parent_id' => 38,
|
||||
'level' => '37-38',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'optimize@backup',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587463217,
|
||||
'updated_at' => 1599362678,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 43,
|
||||
'permission_name' => '附件管理',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/system/attactments',
|
||||
'icon' => 'el-icon-folder-opened',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'attactments',
|
||||
'component' => 'attachment',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'sort' => 10,
|
||||
'created_at' => 1587463302,
|
||||
'updated_at' => 1599288737,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 44,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 43,
|
||||
'level' => '37-43',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'attachments@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587463335,
|
||||
'updated_at' => 1599217559,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 45,
|
||||
'permission_name' => '删除',
|
||||
'parent_id' => 43,
|
||||
'level' => '37-43',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'attachments@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587463355,
|
||||
'updated_at' => 1599217559,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'id' => 46,
|
||||
'permission_name' => '上传图片',
|
||||
'parent_id' => 43,
|
||||
'level' => '37-43',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'upload@image',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587466919,
|
||||
'updated_at' => 1599217559,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'id' => 47,
|
||||
'permission_name' => '上传文件',
|
||||
'parent_id' => 43,
|
||||
'level' => '37-43',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'upload@file',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587466939,
|
||||
'updated_at' => 1599217559,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'id' => 48,
|
||||
'permission_name' => '配置管理',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/system/config',
|
||||
'icon' => 'el-icon-setting',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'config',
|
||||
'component' => 'config',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'sort' => 9,
|
||||
'created_at' => 1587466991,
|
||||
'updated_at' => 1599288737,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 49,
|
||||
'permission_name' => '父级配置',
|
||||
'parent_id' => 48,
|
||||
'level' => '37-48',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'config@parent',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467036,
|
||||
'updated_at' => 1591345651,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 50,
|
||||
'permission_name' => '存储',
|
||||
'parent_id' => 48,
|
||||
'level' => '37-48',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'config@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467052,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'id' => 51,
|
||||
'permission_name' => '获取',
|
||||
'parent_id' => 48,
|
||||
'level' => '37-48',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'config@read',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467062,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'id' => 52,
|
||||
'permission_name' => '登陆日志',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/system/log/operate',
|
||||
'icon' => 'el-icon-coin',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'loginLog',
|
||||
'component' => 'loginLog',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'sort' => 5,
|
||||
'created_at' => 1587467150,
|
||||
'updated_at' => 1599288737,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 53,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 52,
|
||||
'level' => '37-52',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'loginlog@list',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467206,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 54,
|
||||
'permission_name' => '清空',
|
||||
'parent_id' => 52,
|
||||
'level' => '37-52',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'loginlog@empty',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467221,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
4 =>
|
||||
array (
|
||||
'id' => 55,
|
||||
'permission_name' => '操作日志',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/system/log/login',
|
||||
'icon' => 'el-icon-house',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'operateLog',
|
||||
'component' => 'operateLog',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467180,
|
||||
'updated_at' => 1599288737,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 56,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 55,
|
||||
'level' => '37-55',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'operatelog@list',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467246,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 57,
|
||||
'permission_name' => '清空',
|
||||
'parent_id' => 55,
|
||||
'level' => '37-55',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'operatelog@empty',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467266,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
5 =>
|
||||
array (
|
||||
'id' => 58,
|
||||
'permission_name' => '代码生成',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/system/generate',
|
||||
'icon' => 'el-icon-scissors',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'generate',
|
||||
'component' => 'generate',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587717452,
|
||||
'updated_at' => 1599288737,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 59,
|
||||
'permission_name' => '生成',
|
||||
'parent_id' => 58,
|
||||
'level' => '37-58',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'generate@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1588110923,
|
||||
'updated_at' => 1599217574,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 60,
|
||||
'permission_name' => '预览',
|
||||
'parent_id' => 58,
|
||||
'level' => '37-58',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'generate@preview',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1588110962,
|
||||
'updated_at' => 1599217574,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
6 =>
|
||||
array (
|
||||
'id' => 68,
|
||||
'permission_name' => '敏感词库',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/sensitive/word',
|
||||
'icon' => 'el-icon-folder-delete',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'sensitiveWord',
|
||||
'component' => 'sensitiveWord',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1592375865,
|
||||
'updated_at' => 1599288737,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 69,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 68,
|
||||
'level' => '37-68',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'sensitiveWord@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1592382167,
|
||||
'updated_at' => 1593589434,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 70,
|
||||
'permission_name' => '新增',
|
||||
'parent_id' => 68,
|
||||
'level' => '37-68',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'sensitiveWord@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1592382179,
|
||||
'updated_at' => 1593589434,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'id' => 71,
|
||||
'permission_name' => '更新',
|
||||
'parent_id' => 68,
|
||||
'level' => '37-68',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'sensitiveWord@update',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1592382192,
|
||||
'updated_at' => 1593589434,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'id' => 72,
|
||||
'permission_name' => '删除',
|
||||
'parent_id' => 68,
|
||||
'level' => '37-68',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'sensitiveWord@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1592382202,
|
||||
'updated_at' => 1593589434,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
7 =>
|
||||
array (
|
||||
'id' => 101,
|
||||
'permission_name' => '开发者',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/system/develop',
|
||||
'icon' => 'el-icon-rank',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'develop',
|
||||
'component' => 'develop',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1594626307,
|
||||
'updated_at' => 1599288737,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,621 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Seeder;
|
||||
|
||||
class SystemPermissionSeed extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run Method.
|
||||
*
|
||||
* Write your database seeder using this method.
|
||||
*
|
||||
* More information on writing seeders is available here:
|
||||
* http://docs.phinx.org/en/latest/seeding.html
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
\catcher\Utils::importTreeData($this->getPermissions(), 'permissions', 'parent_id');
|
||||
}
|
||||
|
||||
protected function getPermissions()
|
||||
{
|
||||
return array(
|
||||
0 =>
|
||||
array(
|
||||
'id' => 37,
|
||||
'permission_name' => '系统管理',
|
||||
'parent_id' => 0,
|
||||
'level' => '',
|
||||
'route' => '/system',
|
||||
'icon' => 'bar-chart',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'system',
|
||||
'component' => 'pageView',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 2,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462349,
|
||||
'updated_at' => 1593044431,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array(
|
||||
0 =>
|
||||
array(
|
||||
'id' => 38,
|
||||
'permission_name' => '数据字典',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/system/database',
|
||||
'icon' => 'hdd',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'dataDictionary@index',
|
||||
'component' => 'database',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 8,
|
||||
'created_at' => 1587463087,
|
||||
'updated_at' => 1593044431,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array(
|
||||
0 =>
|
||||
array(
|
||||
'id' => 39,
|
||||
'permission_name' => '查看',
|
||||
'parent_id' => 38,
|
||||
'level' => '37-38',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'dataDictionary@view',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587463113,
|
||||
'updated_at' => 1591343449,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array(
|
||||
'id' => 40,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 38,
|
||||
'level' => '37-38',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'dataDictionary@tables',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 10,
|
||||
'created_at' => 1587463173,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array(
|
||||
'id' => 41,
|
||||
'permission_name' => '优化',
|
||||
'parent_id' => 38,
|
||||
'level' => '37-38',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'dataDictionary@optimize',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587463201,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array(
|
||||
'id' => 42,
|
||||
'permission_name' => '备份',
|
||||
'parent_id' => 38,
|
||||
'level' => '37-38',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'optimize@backup',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587463217,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
1 =>
|
||||
array(
|
||||
'id' => 43,
|
||||
'permission_name' => '附件管理',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/attactments',
|
||||
'icon' => 'folder-open',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'attactments',
|
||||
'component' => 'attachment',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 10,
|
||||
'created_at' => 1587463302,
|
||||
'updated_at' => 1593044431,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array(
|
||||
0 =>
|
||||
array(
|
||||
'id' => 44,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 43,
|
||||
'level' => '37-43',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'attachments@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587463335,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array(
|
||||
'id' => 45,
|
||||
'permission_name' => '删除',
|
||||
'parent_id' => 43,
|
||||
'level' => '37-43',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'attachments@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587463355,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array(
|
||||
'id' => 46,
|
||||
'permission_name' => '上传图片',
|
||||
'parent_id' => 43,
|
||||
'level' => '37-43',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'upload@image',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587466919,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array(
|
||||
'id' => 47,
|
||||
'permission_name' => '上传文件',
|
||||
'parent_id' => 43,
|
||||
'level' => '37-43',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'upload@file',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587466939,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
2 =>
|
||||
array(
|
||||
'id' => 48,
|
||||
'permission_name' => '配置管理',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/system/config',
|
||||
'icon' => 'setting',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'config',
|
||||
'component' => 'config',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 9,
|
||||
'created_at' => 1587466991,
|
||||
'updated_at' => 1593044431,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array(
|
||||
0 =>
|
||||
array(
|
||||
'id' => 49,
|
||||
'permission_name' => '父级配置',
|
||||
'parent_id' => 48,
|
||||
'level' => '37-48',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'config@parent',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467036,
|
||||
'updated_at' => 1591345651,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array(
|
||||
'id' => 50,
|
||||
'permission_name' => '存储',
|
||||
'parent_id' => 48,
|
||||
'level' => '37-48',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'config@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467052,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array(
|
||||
'id' => 51,
|
||||
'permission_name' => '获取',
|
||||
'parent_id' => 48,
|
||||
'level' => '37-48',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'config@read',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467062,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
3 =>
|
||||
array(
|
||||
'id' => 52,
|
||||
'permission_name' => '登陆日志',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/system/log/login',
|
||||
'icon' => 'export',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'loginLog',
|
||||
'component' => 'loginLog',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 5,
|
||||
'created_at' => 1587467150,
|
||||
'updated_at' => 1593044431,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array(
|
||||
0 =>
|
||||
array(
|
||||
'id' => 53,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 52,
|
||||
'level' => '37-52',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'loginlog@list',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467206,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array(
|
||||
'id' => 54,
|
||||
'permission_name' => '清空',
|
||||
'parent_id' => 52,
|
||||
'level' => '37-52',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'loginlog@empty',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467221,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
4 =>
|
||||
array(
|
||||
'id' => 55,
|
||||
'permission_name' => '操作日志',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/system/log/operate',
|
||||
'icon' => 'profile',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'operateLog',
|
||||
'component' => 'operateLog',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467180,
|
||||
'updated_at' => 1593044431,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array(
|
||||
0 =>
|
||||
array(
|
||||
'id' => 56,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 55,
|
||||
'level' => '37-55',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'operatelog@list',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467246,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array(
|
||||
'id' => 57,
|
||||
'permission_name' => '清空',
|
||||
'parent_id' => 55,
|
||||
'level' => '37-55',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'operatelog@empty',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467266,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
5 =>
|
||||
array(
|
||||
'id' => 58,
|
||||
'permission_name' => '代码生成',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/generate',
|
||||
'icon' => 'scissor',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'generate',
|
||||
'component' => 'generate',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587717452,
|
||||
'updated_at' => 1593044431,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array(
|
||||
0 =>
|
||||
array(
|
||||
'id' => 59,
|
||||
'permission_name' => '生成',
|
||||
'parent_id' => 58,
|
||||
'level' => '37-58',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'generate@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1588110923,
|
||||
'updated_at' => 1588110923,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array(
|
||||
'id' => 60,
|
||||
'permission_name' => '预览',
|
||||
'parent_id' => 58,
|
||||
'level' => '37-58',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'generate@preview',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1588110962,
|
||||
'updated_at' => 1588110962,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
6 =>
|
||||
array(
|
||||
'id' => 68,
|
||||
'permission_name' => '敏感词库',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/sensitive/word',
|
||||
'icon' => 'sliders',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'sensitiveWord',
|
||||
'component' => 'sensitiveWord',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1592375865,
|
||||
'updated_at' => 1593044431,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,12 +1,15 @@
|
||||
<?php
|
||||
namespace catchAdmin\system\model;
|
||||
|
||||
use catchAdmin\system\model\search\AttachmentsSearch;
|
||||
use catcher\base\CatchModel;
|
||||
use think\file\UploadedFile;
|
||||
use think\Model;
|
||||
|
||||
class Attachments extends CatchModel
|
||||
{
|
||||
use AttachmentsSearch;
|
||||
|
||||
protected $name = 'attachments';
|
||||
|
||||
protected $field = [
|
||||
@@ -27,24 +30,10 @@ class Attachments extends CatchModel
|
||||
{
|
||||
return $this->order('id', 'desc')
|
||||
->catchSearch()
|
||||
->catchOrder()
|
||||
->paginate();
|
||||
}
|
||||
|
||||
public function searchFileExtAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where('file_ext', $value);
|
||||
}
|
||||
|
||||
public function searchMimeTypesAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where('mime_type', $value);
|
||||
}
|
||||
|
||||
public function searchDriver($query, $value, $data)
|
||||
{
|
||||
return $query->where('driver', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
@@ -2,6 +2,7 @@
|
||||
namespace catchAdmin\system\model;
|
||||
|
||||
use catcher\base\CatchModel;
|
||||
use catcher\exceptions\FailedException;
|
||||
use thans\jwt\exception\UserNotDefinedException;
|
||||
use think\Model;
|
||||
|
||||
@@ -55,92 +56,45 @@ class Config extends CatchModel
|
||||
return true;
|
||||
}
|
||||
|
||||
// 子配置
|
||||
if ($data['pid'] ?? false) {
|
||||
$config = \json_decode($data['config'], true);
|
||||
$pid = $data['pid'];
|
||||
unset($data['pid']);
|
||||
/**[
|
||||
'key' => [
|
||||
'k' => 'v'
|
||||
],
|
||||
$parent = $data['parent'] ?? false;
|
||||
if (!$parent) {
|
||||
throw new FailedException('父配置丢失');
|
||||
}
|
||||
unset($data['parent']);
|
||||
|
||||
'k' => 'v'
|
||||
]*/
|
||||
foreach ($config as $key => $value) {
|
||||
if (empty($value)) {
|
||||
continue;
|
||||
}
|
||||
// 如果二级配置存在
|
||||
$secondLevel = $this->isExistConfig($key, $pid);
|
||||
if ($secondLevel) {
|
||||
// value 是字符串
|
||||
if (!is_array($value)) {
|
||||
if ($value != $secondLevel->value) {
|
||||
$secondLevel->value = $value;
|
||||
$secondLevel->save();
|
||||
}
|
||||
} else {
|
||||
// 数组
|
||||
$thirdLevel = [];
|
||||
$this->subConfig($secondLevel->id, ['id', 'key', 'value'])
|
||||
->each(function ($item, $key) use (&$thirdLevel){
|
||||
$thirdLevel[$item['key']] = $item;
|
||||
});
|
||||
|
||||
if (!empty($value)) {
|
||||
$new = [];
|
||||
foreach ($value as $k => $v) {
|
||||
if (isset($thirdLevel[$k])) {
|
||||
if ($v != $thirdLevel[$k]->value) {
|
||||
$thirdLevel[$k]->value = $v;
|
||||
$thirdLevel[$k]->save();
|
||||
}
|
||||
} else {
|
||||
$new[] = [
|
||||
'pid' => $secondLevel->id,
|
||||
'key' => $k,
|
||||
'value' => $v,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($new)) {
|
||||
parent::insertAllBy($new);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!is_array($value)) {
|
||||
parent::createBy([
|
||||
'pid' => $pid,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
]);
|
||||
} else {
|
||||
$id = parent::createBy([
|
||||
'pid' => $pid,
|
||||
'key' => $key,
|
||||
]);
|
||||
if (!empty($value)) {
|
||||
$newConfig = [];
|
||||
foreach ($value as $k => $v) {
|
||||
$newConfig[] = [
|
||||
'key' => $k,
|
||||
'value' => $v,
|
||||
'pid' => $id,
|
||||
];
|
||||
}
|
||||
parent::insertAllBy($newConfig);
|
||||
}
|
||||
}
|
||||
$parentConfig = $this->where('key', $parent)->find();
|
||||
$config = [];
|
||||
foreach ($data as $key => $item) {
|
||||
foreach ($item as $k => $value) {
|
||||
if ($value) {
|
||||
$config[$key . '.' .$k] = [
|
||||
'pid' => $parentConfig['id'],
|
||||
'key' => $key . '.' . $k,
|
||||
'value' => $value,
|
||||
'created_at' => time(),
|
||||
'updated_at' => time(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return parent::storeBy($data);
|
||||
$this->where('pid', $parentConfig->id)
|
||||
->select()
|
||||
->each(function ($item) use (&$config){
|
||||
if (isset($config[$item['key']])) {
|
||||
if ($config[$item['key']]['value'] != $item->value) {
|
||||
$item['value'] = $config[$item['key']]['value'];
|
||||
$item->save();
|
||||
}
|
||||
unset($config[$item['key']]);
|
||||
}
|
||||
});
|
||||
|
||||
if (count($config)) {
|
||||
return $this->insertAll($config);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,28 +137,26 @@ class Config extends CatchModel
|
||||
* 获取配置
|
||||
*
|
||||
* @time 2020年04月20日
|
||||
* @param int $pid
|
||||
* @param string $component
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function getConfig($pid = 0)
|
||||
public function getConfig(string $component)
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$configs = $this->where('pid', $pid)
|
||||
$configs = $this->where('pid', $this->where('component', $component)->value('id'))
|
||||
->field('id,`key` as k,value,pid')
|
||||
->select();
|
||||
|
||||
foreach ($configs as $config) {
|
||||
if ($config->value !== '') {
|
||||
$data[$config->k] = $config->value;
|
||||
} else {
|
||||
$data[$config->k] = $this->getConfig($config->id);
|
||||
if (strpos($config['k'], '.') !== false) {
|
||||
list($object, $key) = explode('.', $config['k']);
|
||||
$data[$object][$key] = $config['value'];
|
||||
}
|
||||
}
|
||||
|
||||
return empty($data) ? '' : $data;
|
||||
return $data;
|
||||
}
|
||||
}
|
@@ -11,10 +11,13 @@
|
||||
|
||||
namespace catchAdmin\system\model;
|
||||
|
||||
use catchAdmin\system\model\search\DeveloperSearch;
|
||||
use catcher\base\CatchModel as Model;
|
||||
|
||||
class Developers extends Model
|
||||
{
|
||||
use DeveloperSearch;
|
||||
|
||||
protected $name = 'developers';
|
||||
|
||||
protected $field = [
|
||||
|
29
catch/system/model/search/AttachmentsSearch.php
Normal file
29
catch/system/model/search/AttachmentsSearch.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CatchAdmin [Just Like ~ ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace catchAdmin\system\model\search;
|
||||
|
||||
trait AttachmentsSearch
|
||||
{
|
||||
public function searchFileExtAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where('file_ext', $value);
|
||||
}
|
||||
|
||||
public function searchMimeTypesAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where('mime_type', $value);
|
||||
}
|
||||
|
||||
public function searchDriverAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where('driver', $value);
|
||||
}
|
||||
}
|
29
catch/system/model/search/DeveloperSearch.php
Normal file
29
catch/system/model/search/DeveloperSearch.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CatchAdmin [Just Like ~ ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace catchAdmin\system\model\search;
|
||||
|
||||
trait DeveloperSearch
|
||||
{
|
||||
public function searchUsernameAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('username', $value);
|
||||
}
|
||||
|
||||
public function searchMobileAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('mobile', $value);
|
||||
}
|
||||
|
||||
public function searchStatusAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where('driver', $value);
|
||||
}
|
||||
}
|
@@ -10,7 +10,7 @@ class CreateRequest extends CatchRequest
|
||||
{
|
||||
// TODO: Implement rules() method.
|
||||
return [
|
||||
'word|词汇' => 'sensitive_word|unique:'.SensitiveWord::class.',word',
|
||||
'word|词汇' => 'unique:'.SensitiveWord::class.',word',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@ $router->group(function () use ($router) {
|
||||
$router->delete('loginLog/empty', '\catchAdmin\system\controller\LoginLog@empty');
|
||||
// 操作日志
|
||||
$router->get('log/operate', '\catchAdmin\system\controller\OperateLog@list');
|
||||
$router->delete('operateLog/empty', '\catchAdmin\system\controller\OperateLog@empty');
|
||||
$router->delete('operateLog/delete', '\catchAdmin\system\controller\OperateLog@delete');
|
||||
// $router->delete('empty/log/operate', '\catchAdmin\system\controller\OperateLog@empty');
|
||||
$router->delete('log/operate/<id>', '\catchAdmin\system\controller\OperateLog@delete');
|
||||
|
||||
// 数据字典
|
||||
$router->get('tables', '\catchAdmin\system\controller\DataDictionary@tables');
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
use think\migration\Seeder;
|
||||
|
||||
class WechatPermissionSeed extends Seeder
|
||||
class WechatMenusSeed extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run Method.
|
||||
@@ -30,17 +30,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => 'wechat',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'wechat',
|
||||
'component' => 'routeView',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'component' => 'layout',
|
||||
'redirect' => '/wechat/menus',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1591603025,
|
||||
'updated_at' => 1593044101,
|
||||
'updated_at' => 1599371183,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
@@ -54,17 +52,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => 'table',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'menus',
|
||||
'component' => 'menus',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'sort' => 18,
|
||||
'created_at' => 1591603088,
|
||||
'updated_at' => 1591603427,
|
||||
'updated_at' => 1599371183,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
@@ -78,17 +74,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'menus@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304908,
|
||||
'updated_at' => 1593304908,
|
||||
'updated_at' => 1599371167,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
@@ -101,17 +95,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'menus@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304915,
|
||||
'updated_at' => 1593304915,
|
||||
'updated_at' => 1599371167,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
@@ -124,17 +116,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'menus@update',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304923,
|
||||
'updated_at' => 1593304923,
|
||||
'updated_at' => 1599371167,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
@@ -147,17 +137,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'menus@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304929,
|
||||
'updated_at' => 1593304929,
|
||||
'updated_at' => 1599371167,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
4 =>
|
||||
@@ -170,17 +158,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'menus@sync',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304938,
|
||||
'updated_at' => 1593304938,
|
||||
'updated_at' => 1599371167,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
@@ -192,20 +178,18 @@ class WechatPermissionSeed extends Seeder
|
||||
'parent_id' => 66,
|
||||
'level' => '66',
|
||||
'route' => '/wechat/users',
|
||||
'icon' => 'team',
|
||||
'icon' => 'el-icon-s-custom',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'users',
|
||||
'component' => 'pageView',
|
||||
'component' => 'routerView',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1592624761,
|
||||
'updated_at' => 1592631716,
|
||||
'updated_at' => 1599371697,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
@@ -215,21 +199,19 @@ class WechatPermissionSeed extends Seeder
|
||||
'permission_name' => '微信用户',
|
||||
'parent_id' => 75,
|
||||
'level' => '66-75',
|
||||
'route' => '/wechat/users',
|
||||
'route' => '/wechat/users/user',
|
||||
'icon' => 'user',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'users',
|
||||
'component' => 'wechatUsers',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1592624799,
|
||||
'updated_at' => 1592624799,
|
||||
'updated_at' => 1599376002,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
@@ -243,17 +225,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'users@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304869,
|
||||
'updated_at' => 1593304869,
|
||||
'updated_at' => 1599376002,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
@@ -266,17 +246,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'users@remark',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304876,
|
||||
'updated_at' => 1593304876,
|
||||
'updated_at' => 1599376002,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
@@ -289,17 +267,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'users@block',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304884,
|
||||
'updated_at' => 1593304884,
|
||||
'updated_at' => 1599376002,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
@@ -312,17 +288,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'users@tag',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304892,
|
||||
'updated_at' => 1593304892,
|
||||
'updated_at' => 1599376002,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
4 =>
|
||||
@@ -335,17 +309,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'users@sync',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304900,
|
||||
'updated_at' => 1593304900,
|
||||
'updated_at' => 1599376002,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
@@ -356,21 +328,19 @@ class WechatPermissionSeed extends Seeder
|
||||
'permission_name' => '微信标签',
|
||||
'parent_id' => 75,
|
||||
'level' => '66-75',
|
||||
'route' => '/wechat/tags',
|
||||
'icon' => 'tags',
|
||||
'route' => '/wechat/users/tag',
|
||||
'icon' => 'el-icon-paperclip',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'tags',
|
||||
'component' => 'wechatTags',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1592722634,
|
||||
'updated_at' => 1593304802,
|
||||
'updated_at' => 1599376011,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
@@ -384,17 +354,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'wechatTags@index',
|
||||
'permission_mark' => 'tags@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304575,
|
||||
'updated_at' => 1593304575,
|
||||
'updated_at' => 1599376011,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
@@ -407,17 +375,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'wechatTags@save',
|
||||
'permission_mark' => 'tags@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304592,
|
||||
'updated_at' => 1593304592,
|
||||
'updated_at' => 1599376011,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
@@ -430,17 +396,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'tags@read',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304830,
|
||||
'updated_at' => 1593304830,
|
||||
'updated_at' => 1599376011,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
@@ -453,17 +417,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'tags@update',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304837,
|
||||
'updated_at' => 1593304837,
|
||||
'updated_at' => 1599376011,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
4 =>
|
||||
@@ -476,17 +438,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'tags@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304846,
|
||||
'updated_at' => 1593304846,
|
||||
'updated_at' => 1599376011,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
5 =>
|
||||
@@ -499,17 +459,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'tags@sync',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304859,
|
||||
'updated_at' => 1593304859,
|
||||
'updated_at' => 1599376011,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
@@ -523,20 +481,18 @@ class WechatPermissionSeed extends Seeder
|
||||
'parent_id' => 66,
|
||||
'level' => '66',
|
||||
'route' => '/wechat/graphic',
|
||||
'icon' => 'gold',
|
||||
'icon' => 'el-icon-document-add',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'graphic',
|
||||
'component' => 'wechatGraphic',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593227704,
|
||||
'updated_at' => 1593227704,
|
||||
'updated_at' => 1599371183,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
@@ -550,17 +506,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'graphic@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304490,
|
||||
'updated_at' => 1593304490,
|
||||
'updated_at' => 1595978929,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
@@ -573,17 +527,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'graphic@read',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304510,
|
||||
'updated_at' => 1593304510,
|
||||
'updated_at' => 1595978929,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
@@ -596,17 +548,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'graphic@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 2,
|
||||
'created_at' => 1593304520,
|
||||
'updated_at' => 1593304520,
|
||||
'updated_at' => 1595978929,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
@@ -619,17 +569,15 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'graphic@update',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304530,
|
||||
'updated_at' => 1593304530,
|
||||
'updated_at' => 1595978929,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
4 =>
|
||||
@@ -642,17 +590,123 @@ class WechatPermissionSeed extends Seeder
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'graphic@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304537,
|
||||
'updated_at' => 1593304537,
|
||||
'updated_at' => 1595978929,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'id' => 100,
|
||||
'permission_name' => '微信回复',
|
||||
'parent_id' => 66,
|
||||
'level' => '66',
|
||||
'route' => '/wechat/reply',
|
||||
'icon' => 'el-icon-chat-line-round',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'reply',
|
||||
'component' => 'wechatReply',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593323887,
|
||||
'updated_at' => 1599371183,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 111,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 100,
|
||||
'level' => '66-100',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'reply@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1599292333,
|
||||
'updated_at' => 1599292373,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 112,
|
||||
'permission_name' => '新增',
|
||||
'parent_id' => 100,
|
||||
'level' => '66-100',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'reply@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1599292344,
|
||||
'updated_at' => 1599292344,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'id' => 113,
|
||||
'permission_name' => '删除',
|
||||
'parent_id' => 100,
|
||||
'level' => '66-100',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'reply@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1599292351,
|
||||
'updated_at' => 1599292351,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'id' => 114,
|
||||
'permission_name' => '禁用/启用',
|
||||
'parent_id' => 100,
|
||||
'level' => '66-100',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'permission_mark' => 'reply@disOrEnable',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hidden' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'sort' => 1,
|
||||
'created_at' => 1599292363,
|
||||
'updated_at' => 1599292363,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
@@ -14,5 +14,5 @@
|
||||
"aliases": "wechat",
|
||||
"files": [],
|
||||
"requires": [],
|
||||
"enable": true
|
||||
"enable": false
|
||||
}
|
@@ -101,7 +101,8 @@ class WechatUsersRepository extends CatchRepository
|
||||
*/
|
||||
public function tag($id, $data)
|
||||
{
|
||||
$tagIds = WechatTags::whereIn('name', Utils::stringToArrayBy($data['tag']))->column('tag_id');
|
||||
$tagIds = Utils::stringToArrayBy($data['tag']);
|
||||
// WechatTags::whereIn('name', Utils::stringToArrayBy($data['tag']))->column('tag_id');
|
||||
|
||||
$user = $this->findBy($id);
|
||||
|
||||
@@ -134,6 +135,10 @@ class WechatUsersRepository extends CatchRepository
|
||||
$user->hasTags()->saveAll($attachIds);
|
||||
}
|
||||
|
||||
WechatUsers::where('id', $id)->update([
|
||||
'tagid_list' => $data['tag'],
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -31,7 +31,8 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"topthink/think-trace":"^1.0",
|
||||
"symfony/var-dumper": "^5.1"
|
||||
"symfony/var-dumper": "^5.1",
|
||||
"swoole/ide-helper": "^4.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@@ -10,7 +10,7 @@ return [
|
||||
'local' => [
|
||||
'type' => 'local',
|
||||
'root' => app()->getRootPath() . 'public'.DIRECTORY_SEPARATOR.'images',
|
||||
'domain' => env('API_URL'),
|
||||
'domain' => env('app.domain'),
|
||||
],
|
||||
'public' => [
|
||||
// 磁盘类型
|
||||
|
@@ -1,10 +1,12 @@
|
||||
<?php
|
||||
namespace catcher;
|
||||
|
||||
use catchAdmin\permissions\model\Users;
|
||||
use catcher\exceptions\FailedException;
|
||||
use catcher\exceptions\LoginFailedException;
|
||||
use thans\jwt\facade\JWTAuth;
|
||||
use think\facade\Session;
|
||||
use think\helper\Str;
|
||||
|
||||
class CatchAuth
|
||||
{
|
||||
@@ -49,24 +51,72 @@ class CatchAuth
|
||||
*/
|
||||
public function attempt($condition)
|
||||
{
|
||||
$user = $this->authenticate($condition);
|
||||
try {
|
||||
$user = $this->authenticate($condition);
|
||||
|
||||
if (!$user) {
|
||||
throw new LoginFailedException();
|
||||
if (!$user) {
|
||||
throw new LoginFailedException();
|
||||
}
|
||||
if ($user->status == Users::DISABLE) {
|
||||
throw new LoginFailedException('该用户已被禁用|' . $user->username, Code::USER_FORBIDDEN);
|
||||
}
|
||||
|
||||
if (!password_verify($condition['password'], $user->password)) {
|
||||
throw new LoginFailedException('登录失败|' . $user->username);
|
||||
}
|
||||
|
||||
$token = $this->{$this->getDriver()}($user);
|
||||
$this->afterLoginSuccess($user);
|
||||
// 登录事件
|
||||
$this->loginEvent($user->username);
|
||||
return $token;
|
||||
} catch (\Exception $exception) {
|
||||
$message = $exception->getMessage();
|
||||
if (strpos($message, '|') !== false) {
|
||||
$username = explode('|', $message)[1];
|
||||
} else {
|
||||
$username = $condition['email'];
|
||||
}
|
||||
$this->loginEvent($username, false);
|
||||
throw new LoginFailedException('登录失败', $exception->getCode());
|
||||
}
|
||||
|
||||
if (!password_verify($condition['password'], $user->password)) {
|
||||
throw new LoginFailedException();
|
||||
}
|
||||
|
||||
return $this->{$this->getDriver()}($user);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2020年01月07日
|
||||
* @return mixed
|
||||
*/
|
||||
/**
|
||||
* 用户登录成功后
|
||||
*
|
||||
* @time 2020年09月09日
|
||||
* @param $user
|
||||
* @return void
|
||||
*/
|
||||
protected function afterLoginSuccess($user)
|
||||
{
|
||||
$user->last_login_ip = request()->ip();
|
||||
$user->last_login_time = time();
|
||||
$user->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录事件
|
||||
*
|
||||
* @time 2020年09月09日
|
||||
* @param $name
|
||||
* @param bool $success
|
||||
* @return void
|
||||
*/
|
||||
protected function loginEvent($name, $success = true)
|
||||
{
|
||||
$params['login_name'] = $name;
|
||||
$params['success'] = $success ? 1 : 2;
|
||||
event('loginLog', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* user
|
||||
*
|
||||
* @time 2020年09月09日
|
||||
* @return mixed
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
$user = $this->user[$this->guard] ?? null;
|
||||
|
@@ -118,8 +118,8 @@ class CatchQuery extends Query
|
||||
|
||||
foreach ($params as $field => $value) {
|
||||
$method = 'search' . Str::studly($field) . 'Attr';
|
||||
if (method_exists($this->model, $method)) {
|
||||
$this->model->$method($this, $value ?? null, $params);
|
||||
if ($value && method_exists($this->model, $method)) {
|
||||
$this->model->$method($this, $value, $params);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -45,15 +45,20 @@ class CatchUpload
|
||||
*/
|
||||
protected $path = '';
|
||||
|
||||
/**
|
||||
* upload files
|
||||
*
|
||||
* @param UploadedFile $file
|
||||
* @return string
|
||||
* @author JaguarJack
|
||||
* @email njphper@gmail.com
|
||||
* @time 2020/1/25
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->initDriver();
|
||||
}
|
||||
|
||||
/**
|
||||
* upload files
|
||||
*
|
||||
* @param UploadedFile $file
|
||||
* @return string
|
||||
* @author JaguarJack
|
||||
* @email njphper@gmail.com
|
||||
* @time 2020/1/25
|
||||
*/
|
||||
public function upload(UploadedFile $file): string
|
||||
{
|
||||
$this->initUploadConfig();
|
||||
@@ -77,10 +82,20 @@ class CatchUpload
|
||||
throw new FailedException('Upload Failed, Try Again!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地路径
|
||||
*
|
||||
* @time 2020年09月07日
|
||||
* @param $path
|
||||
* @return string
|
||||
*/
|
||||
protected function getLocalPath($path)
|
||||
{
|
||||
if ($this->getDriver() === self::LOCAL) {
|
||||
return str_replace(root_path('public'), '', \config('filesystem.disks.local.root')) . DIRECTORY_SEPARATOR .$path;
|
||||
|
||||
$path = str_replace(root_path('public'), '', \config('filesystem.disks.local.root')) . DIRECTORY_SEPARATOR .$path;
|
||||
|
||||
return str_replace('\\', '/', $path);
|
||||
}
|
||||
|
||||
return $path;
|
||||
@@ -174,12 +189,12 @@ class CatchUpload
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2020年01月25日
|
||||
* @param UploadedFile $file
|
||||
* @return array
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @time 2020年01月25日
|
||||
* @param UploadedFile $file
|
||||
* @return array
|
||||
*/
|
||||
protected function data(UploadedFile $file)
|
||||
{
|
||||
return [
|
||||
@@ -247,9 +262,19 @@ class CatchUpload
|
||||
$disk = app()->config->get('filesystem.disks');
|
||||
|
||||
$uploadConfigs = $configModel->getConfig($upload->id);
|
||||
|
||||
// 重组
|
||||
$_config = [];
|
||||
if (!empty($uploadConfigs)) {
|
||||
foreach ($uploadConfigs as $key => $value) {
|
||||
list($object, $key) = explode('.', $key);
|
||||
$_config[$object][$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_config)) {
|
||||
// 读取上传可配置数据
|
||||
foreach ($uploadConfigs as $key => &$config) {
|
||||
foreach ($_config as $key => &$config) {
|
||||
// $disk[$key]['type'] = $key;
|
||||
// 腾讯云配置处理
|
||||
if (strtolower($key) == 'qcloud') {
|
||||
@@ -258,21 +283,21 @@ class CatchUpload
|
||||
'secretKey' => $config['secret_key'] ?? '',
|
||||
'secretId' => $config['secret_id'] ?? '',
|
||||
];
|
||||
$readFromCdn = $config['read_from_cdn'] ?? false;
|
||||
$config['read_from_cdn'] = $readFromCdn ? true : false;
|
||||
$readFromCdn = $config['read_from_cdn'] ?? 0;
|
||||
$config['read_from_cdn'] = intval($readFromCdn) == 1;
|
||||
}
|
||||
// OSS 配置
|
||||
if (strtolower($key) == 'oss') {
|
||||
$isCname = $config['is_cname'] ?? false;
|
||||
$config['is_cname'] = $isCname ? true : false;
|
||||
$isCname = $config['is_cname'] ?? 0;
|
||||
$config['is_cname'] = intval($isCname) == 1;
|
||||
}
|
||||
}
|
||||
|
||||
// 合并数组
|
||||
array_walk($disk, function (&$item, $key) use ($uploadConfigs) {
|
||||
array_walk($disk, function (&$item, $key) use ($_config) {
|
||||
if (!in_array($key, ['public', 'local'])) {
|
||||
if ($uploadConfigs[$key] ?? false) {
|
||||
foreach ($uploadConfigs[$key] as $k => $value) {
|
||||
if ($_config[$key] ?? false) {
|
||||
foreach ($_config[$key] as $k => $value) {
|
||||
$item[$k] = $value;
|
||||
}
|
||||
}
|
||||
@@ -286,6 +311,21 @@ class CatchUpload
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*
|
||||
* @time 2020年09月07日
|
||||
* @return $this
|
||||
*/
|
||||
protected function initDriver()
|
||||
{
|
||||
if ($driver = Utils::config('site.upload')) {
|
||||
$this->driver = $driver;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取云存储的域名
|
||||
*
|
||||
|
@@ -11,6 +11,7 @@ class Code
|
||||
public const FAILED = 10005; // 操作失败
|
||||
public const LOGIN_EXPIRED = 10006; // 登录失效
|
||||
public const LOGIN_BLACKLIST = 10007; // 黑名单
|
||||
public const USER_FORBIDDEN = 10008; // 账户被禁
|
||||
|
||||
public const WECHAT_RESPONSE_ERROR = 40000;
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace catcher;
|
||||
|
||||
use catchAdmin\system\model\Config;
|
||||
use think\facade\Db;
|
||||
use think\helper\Str;
|
||||
|
||||
@@ -129,4 +130,28 @@ class Utils
|
||||
{
|
||||
return request()->user()->id == config('catch.permissions.super_admin_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置
|
||||
*
|
||||
* @time 2020年09月07日
|
||||
* @param $key
|
||||
* @return mixed
|
||||
*/
|
||||
public static function config($key)
|
||||
{
|
||||
return Config::where('key', $key)->value('value');
|
||||
}
|
||||
|
||||
/**
|
||||
* public path
|
||||
*
|
||||
* @param string $path
|
||||
* @time 2020年09月08日
|
||||
* @return string
|
||||
*/
|
||||
public static function publicPath($path = '')
|
||||
{
|
||||
return root_path($path ? 'public/'. $path : 'public');
|
||||
}
|
||||
}
|
||||
|
@@ -86,7 +86,7 @@ class CatchRequest extends Request
|
||||
// 设置默认参数
|
||||
if ($this->needCreatorId) {
|
||||
$this->param['creator_id'] = $this->user()->id;
|
||||
$this->post['creator'] = $this->user()->id;
|
||||
$this->post['creator_id'] = $this->user()->id;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@@ -30,7 +30,8 @@ class ExportDataCommand extends Command
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$table = Utils::tablePrefix() . $input->getArgument('table');
|
||||
//$table = // Utils::tablePrefix() .
|
||||
$table = $input->getArgument('table');
|
||||
$parent = $input->getOption('pid');
|
||||
$module = $input->getOption('module');
|
||||
|
||||
@@ -39,8 +40,12 @@ class ExportDataCommand extends Command
|
||||
->where('module', $module)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
|
||||
} else {
|
||||
$data = Db::name($table)->where('deleted_at', 0)->select()->toArray();
|
||||
$data = Db::name($table)->where('deleted_at', 0)
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
if ($parent) {
|
||||
@@ -60,7 +65,11 @@ class ExportDataCommand extends Command
|
||||
{
|
||||
$stub = file_get_contents(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'permissionSeed.stub');
|
||||
|
||||
file_put_contents(CatchAdmin::moduleSeedsDirectory($module) . 'permissionSeed.php', str_replace('{DATA}', $data, $stub));
|
||||
$class = ucfirst($module) . 'MenusSeed';
|
||||
|
||||
$stub = str_replace('{CLASS}', $class, $stub);
|
||||
|
||||
file_put_contents(CatchAdmin::moduleSeedsDirectory($module) . $class .'.php', str_replace('{DATA}', $data, $stub));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,7 @@ namespace catcher\command\install;
|
||||
|
||||
use catchAdmin\permissions\model\Permissions;
|
||||
use catcher\CatchAdmin;
|
||||
use catcher\library\InstallLocalModule;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Argument;
|
||||
@@ -34,10 +35,7 @@ class DisableModuleCommand extends Command
|
||||
if (empty(CatchAdmin::getModuleInfo(CatchAdmin::directory() .$module))) {
|
||||
$output->error("module [$module] not exist");
|
||||
} else {
|
||||
CatchAdmin::disableModule($module);
|
||||
Permissions::destroy(function ($query) use ($module){
|
||||
$query->where('module', trim($module));
|
||||
});
|
||||
(new InstallLocalModule($module))->disableModule();
|
||||
$output->info("module [$module] disabled");
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ namespace catcher\command\install;
|
||||
|
||||
use catchAdmin\permissions\model\Permissions;
|
||||
use catcher\CatchAdmin;
|
||||
use catcher\library\InstallLocalModule;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Argument;
|
||||
@@ -33,8 +34,7 @@ class EnableModuleCommand extends Command
|
||||
if (empty(CatchAdmin::getModuleInfo(CatchAdmin::directory() .$module))) {
|
||||
$output->error("module [$module] not exist");
|
||||
} else {
|
||||
CatchAdmin::enableModule($module);
|
||||
app(Permissions::class)->restore(['module' => trim($module)]);
|
||||
(new InstallLocalModule($module))->enableModule();
|
||||
$output->info("module [$module] enabled");
|
||||
}
|
||||
}
|
||||
|
68
extend/catcher/command/install/InstallLocalModuleCommand.php
Normal file
68
extend/catcher/command/install/InstallLocalModuleCommand.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CatchAdmin [Just Like ~ ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace catcher\command\install;
|
||||
|
||||
|
||||
use catcher\library\InstallLocalModule;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Argument;
|
||||
use think\console\input\Option;
|
||||
use think\console\Output;
|
||||
|
||||
class InstallLocalModuleCommand extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('local:install')
|
||||
->addArgument('module', Argument::REQUIRED, 'module name')
|
||||
->setDescription('install catch local module');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$installedModule = $input->getArgument('module');
|
||||
|
||||
$install = new InstallLocalModule($installedModule);
|
||||
|
||||
if (!$install->localModuleExist()) {
|
||||
while (true) {
|
||||
$modules = $install->getLocalModulesInfo(false);
|
||||
if (!count($modules)) {
|
||||
$output->error('Input module not found and All local modules had been enabled');exit;
|
||||
}
|
||||
$choose = '';
|
||||
$i = 1;
|
||||
foreach ($modules as $k => $module) {
|
||||
$choose .= ($i++) . ':' . ($module['name']) . ($module['enable'] ? '(开启)' : '(未开启)') . PHP_EOL;
|
||||
}
|
||||
$answer = $output->ask($input, $choose);
|
||||
if (isset($modules[$answer-1])) {
|
||||
$installedModule = $modules[$answer - 1]['name'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$install = new InstallLocalModule($installedModule);
|
||||
|
||||
if (!$install->isModuleEnabled()) {
|
||||
$output->error($installedModule . ' has been enabled!');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$install->done()) {
|
||||
$output->error(sprintf('module [%s] has been installed, You can use [php think enable:module $module] to start it.', $installedModule));
|
||||
}
|
||||
|
||||
$output->info(sprintf('module [%s] installed successfully', $installedModule));
|
||||
}
|
||||
}
|
@@ -2,6 +2,7 @@
|
||||
namespace catcher\command\install;
|
||||
|
||||
use catcher\CatchAdmin;
|
||||
use catcher\library\InstallLocalModule;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Option;
|
||||
@@ -13,6 +14,8 @@ class InstallProjectCommand extends Command
|
||||
|
||||
protected $databaseLink = [];
|
||||
|
||||
protected $defaultModule = ['permissions', 'system'];
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('catch:install')
|
||||
@@ -111,6 +114,12 @@ class InstallProjectCommand extends Command
|
||||
return false;
|
||||
}
|
||||
|
||||
// 设置 app domain
|
||||
$appDomain = strtolower($this->output->ask($this->input, '👉 first, you should set app domain: '));
|
||||
if (strpos('http://', $appDomain) === false || strpos('https://', $appDomain) === false) {
|
||||
$appDomain = 'http://' . $appDomain;
|
||||
}
|
||||
|
||||
$answer = strtolower($this->output->ask($this->input, '🤔️ Did You Need to Set Database information? (Y/N): '));
|
||||
|
||||
if ($answer === 'y' || $answer === 'yes') {
|
||||
@@ -142,7 +151,7 @@ class InstallProjectCommand extends Command
|
||||
|
||||
$this->databaseLink = [$host, $database, $username, $password, $port, $charset, $prefix];
|
||||
|
||||
$this->generateEnvFile($host, $database, $username, $password, $port, $charset, $prefix);
|
||||
$this->generateEnvFile($host, $database, $username, $password, $port, $charset, $prefix, $appDomain);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,27 +200,28 @@ class InstallProjectCommand extends Command
|
||||
*/
|
||||
protected function migrateAndSeeds(): void
|
||||
{
|
||||
foreach (CatchAdmin::getModulesDirectory() as $directory) {
|
||||
$moduleInfo = CatchAdmin::getModuleInfo($directory);
|
||||
if (!empty($moduleInfo) && is_dir(CatchAdmin::moduleMigrationsDirectory($moduleInfo['alias']))) {
|
||||
$output = Console::call('catch-migrate:run', [$moduleInfo['alias']]);
|
||||
$this->output->info(sprintf('module [%s] migrations %s', $moduleInfo['alias'], $output->fetch()));
|
||||
|
||||
$seedOut = Console::call('catch-seed:run', [$moduleInfo['alias']]);
|
||||
$this->output->info(sprintf('module [%s] seeds %s', $moduleInfo['alias'], $seedOut->fetch()));
|
||||
}
|
||||
foreach ($this->defaultModule as $m) {
|
||||
$module = new InstallLocalModule($m);
|
||||
$module->installModuleTables();
|
||||
$module->installModuleSeeds();
|
||||
$this->output->info('🎉 module [' . $m . '] installed successfully');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚数据
|
||||
*
|
||||
* @time 2020年09月07日
|
||||
* @return void
|
||||
*/
|
||||
protected function migrateRollback()
|
||||
{
|
||||
foreach (CatchAdmin::getModulesDirectory() as $directory) {
|
||||
$moduleInfo = CatchAdmin::getModuleInfo($directory);
|
||||
if (!empty($moduleInfo) && is_dir(CatchAdmin::moduleMigrationsDirectory($moduleInfo['alias']))) {
|
||||
$rollbackOut = Console::call('catch-migrate:rollback', [$moduleInfo['alias'], '-f']);
|
||||
// $this->output->info(sprintf('module [%s] [%s] rollback %s', $moduleInfo['alias'], basename($migration), $rollbackOut->fetch()));
|
||||
foreach ($this->defaultModule as $m) {
|
||||
$module = new InstallLocalModule($m);
|
||||
$module->rollbackModuleTable();
|
||||
$this->output->info('🎉' . $m . ' tables rollback successfully');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,13 +261,15 @@ class InstallProjectCommand extends Command
|
||||
* @param $port
|
||||
* @param $charset
|
||||
* @param $prefix
|
||||
* @param $appDomain
|
||||
* @return void
|
||||
*/
|
||||
protected function generateEnvFile($host, $database, $username, $password, $port, $charset, $prefix): void
|
||||
protected function generateEnvFile($host, $database, $username, $password, $port, $charset, $prefix, $appDomain): void
|
||||
{
|
||||
try {
|
||||
$env = \parse_ini_file(root_path() . '.example.env', true);
|
||||
|
||||
$env['APP']['DOMAIN'] = $appDomain;
|
||||
$env['DATABASE']['HOSTNAME'] = $host;
|
||||
$env['DATABASE']['DATABASE'] = $database;
|
||||
$env['DATABASE']['USERNAME'] = $username;
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
use think\migration\Seeder;
|
||||
|
||||
class PermissionSeed extends Seeder
|
||||
class {CLASS} extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run Method.
|
||||
|
@@ -55,7 +55,7 @@ class Generator
|
||||
// 只有最后成功才写入 route
|
||||
(new Route())->controller($controller['controller'])
|
||||
->restful($controller['restful'])
|
||||
->methods((new Controller())->parseOtherMethods($controller['other_function']))
|
||||
// ->methods((new Controller())->parseOtherMethods($controller['other_function']))
|
||||
->done();
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
@@ -76,10 +76,10 @@ class Generator
|
||||
*/
|
||||
public function preview($params)
|
||||
{
|
||||
$params = \json_decode($params['data'], true);
|
||||
|
||||
$type = $params['type'];
|
||||
|
||||
$params = \json_decode($params['data'], true);
|
||||
|
||||
[$controller, $model] = $this->parseParams($params);
|
||||
|
||||
switch ($type) {
|
||||
@@ -113,7 +113,7 @@ class Generator
|
||||
'model' => $params['controller']['model'] ?? '',
|
||||
'controller' => $params['controller']['controller'] ?? '',
|
||||
'restful' => $params['controller']['restful'],
|
||||
'other_function' => $params['controller']['other_function'],
|
||||
// 'other_function' => $params['controller']['other_function'],
|
||||
];
|
||||
|
||||
$table = $params['controller']['table'] ?? '';
|
||||
@@ -124,8 +124,8 @@ class Generator
|
||||
$model = [
|
||||
'table' => $table,
|
||||
'model' => $params['controller']['model'] ?? '',
|
||||
'sql' => $params['model']['data'],
|
||||
'extra' => $params['model']['extra'],
|
||||
'sql' => $params['table_fields'],
|
||||
'extra' => $params['table_extra'],
|
||||
];
|
||||
|
||||
|
||||
|
@@ -92,13 +92,14 @@ class Controller extends Factory
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
if (!empty($params['other_function'])) {
|
||||
$others = $this->parseOtherMethods($params['other_function']);
|
||||
$this->methods = array_merge($this->methods, $others);
|
||||
foreach ($others as $other) {
|
||||
$content .= $template->otherFunction($other[0], $other[1]);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
177
extend/catcher/library/InstallLocalModule.php
Normal file
177
extend/catcher/library/InstallLocalModule.php
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CatchAdmin [Just Like ~ ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace catcher\library;
|
||||
|
||||
|
||||
use catchAdmin\permissions\model\Permissions;
|
||||
use catcher\CatchAdmin;
|
||||
use think\facade\Console;
|
||||
|
||||
class InstallLocalModule
|
||||
{
|
||||
protected $module;
|
||||
|
||||
public function __construct($module)
|
||||
{
|
||||
$this->module = $module;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找
|
||||
*
|
||||
* @time 2020年09月10日
|
||||
* @return bool
|
||||
*/
|
||||
public function done()
|
||||
{
|
||||
if ($this->findModuleInPermissions()) {
|
||||
return false;
|
||||
} else {
|
||||
$this->installModuleTables();
|
||||
$this->installModuleSeeds();
|
||||
$this->enableModule();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地模块是否存在
|
||||
*
|
||||
* @time 2020年09月10日
|
||||
* @return bool
|
||||
*/
|
||||
public function localModuleExist()
|
||||
{
|
||||
return in_array($this->module, array_column(CatchAdmin::getModulesInfo(true), 'value'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 模块是否开启
|
||||
*
|
||||
* @time 2020年09月10日
|
||||
* @return false|mixed
|
||||
*/
|
||||
public function isModuleEnabled()
|
||||
{
|
||||
return in_array($this->module, array_column($this->getLocalModulesInfo(false), 'name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本地模块信息
|
||||
*
|
||||
* @param bool $enabled
|
||||
* @time 2020年09月10日
|
||||
* @return array
|
||||
*/
|
||||
public function getLocalModulesInfo($enabled = true)
|
||||
{
|
||||
$modules = CatchAdmin::getModulesInfo(true);
|
||||
|
||||
$info = [];
|
||||
foreach ($modules as $module) {
|
||||
$moduleInfo = CatchAdmin::getModuleInfo(CatchAdmin::directory() . $module['value']);
|
||||
// 获取全部
|
||||
if ($enabled) {
|
||||
$info[] = [
|
||||
'name' => $module['value'],
|
||||
'title' => $module['title'],
|
||||
'enable' => $moduleInfo['enable'],
|
||||
];
|
||||
} else {
|
||||
// 获取未开启的
|
||||
if (!$moduleInfo['enable']) {
|
||||
$info[] = [
|
||||
'name' => $module['value'],
|
||||
'title' => $module['title'],
|
||||
'enable' => $moduleInfo['enable'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找模块
|
||||
*
|
||||
* @time 2020年09月10日
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return bool
|
||||
*/
|
||||
protected function findModuleInPermissions()
|
||||
{
|
||||
return Permissions::where('module', $this->module)->find() ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用模块
|
||||
*
|
||||
* @time 2020年09月10日
|
||||
* @return void
|
||||
*/
|
||||
public function enableModule()
|
||||
{
|
||||
CatchAdmin::enableModule($this->module);
|
||||
app(Permissions::class)->restore(['module' => trim($this->module)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用模块
|
||||
*
|
||||
* @time 2020年09月10日
|
||||
* @return void
|
||||
*/
|
||||
public function disableModule()
|
||||
{
|
||||
CatchAdmin::disableModule($this->module);
|
||||
|
||||
Permissions::destroy(function ($query) {
|
||||
$query->where('module', trim($this->module));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建模块表
|
||||
*
|
||||
* @time 2020年09月10日
|
||||
* @return void
|
||||
*/
|
||||
public function installModuleTables()
|
||||
{
|
||||
Console::call('catch-migrate:run', [$this->module]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化模块数据
|
||||
*
|
||||
* @time 2020年09月10日
|
||||
* @return void
|
||||
*/
|
||||
public function installModuleSeeds()
|
||||
{
|
||||
Console::call('catch-seed:run', [$this->module]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚模块表
|
||||
*
|
||||
* @time 2020年09月10日
|
||||
* @return void
|
||||
*/
|
||||
public function rollbackModuleTable()
|
||||
{
|
||||
Console::call('catch-migrate:rollback', [$this->module, '-f']);
|
||||
}
|
||||
}
|
@@ -2,6 +2,8 @@
|
||||
namespace catcher\library;
|
||||
|
||||
|
||||
use think\exception\ClassNotFoundException;
|
||||
|
||||
class ParseClass
|
||||
{
|
||||
protected $namespace;
|
||||
@@ -74,18 +76,23 @@ class ParseClass
|
||||
return $methods;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取 CLASS
|
||||
* 获取class
|
||||
*
|
||||
* @return \ReflectionClass
|
||||
* @time 2020年09月06日
|
||||
* @throws \ReflectionException
|
||||
* @return \ReflectionClass
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
$class = $this->namespace . $this->module . '\\controller\\'. ucfirst($this->controller);
|
||||
|
||||
return new \ReflectionClass($this->namespace . $this->module . '\\controller\\'.
|
||||
if (class_exists($class)) {
|
||||
return new \ReflectionClass($class);
|
||||
}
|
||||
|
||||
ucfirst($this->controller));
|
||||
throw new ClassNotFoundException($this->controller . ' not found');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -3,10 +3,12 @@ namespace catcher\library\excel;
|
||||
|
||||
use catcher\CatchUpload;
|
||||
use catcher\exceptions\FailedException;
|
||||
use catcher\Utils;
|
||||
use PhpOffice\PhpSpreadsheet\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use think\file\UploadedFile;
|
||||
use think\helper\Str;
|
||||
|
||||
class Excel
|
||||
{
|
||||
@@ -21,35 +23,54 @@ class Excel
|
||||
|
||||
protected $spreadsheet = null;
|
||||
|
||||
protected $extension = 'xlsx';
|
||||
|
||||
/**
|
||||
* save
|
||||
*
|
||||
* @time 2020年05月25日
|
||||
* @param ExcelContract $excel
|
||||
* @param $path
|
||||
* @param null $disk
|
||||
* @return bool
|
||||
* @param string $disk
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save(ExcelContract $excel, $path, $disk = null)
|
||||
public function save(ExcelContract $excel, $path, $disk = 'local')
|
||||
{
|
||||
$this->excel = $excel;
|
||||
|
||||
$this->init();
|
||||
|
||||
Factory::make(pathinfo($path, PATHINFO_EXTENSION))
|
||||
->setSpreadsheet($this->spreadsheet)
|
||||
->save($path);
|
||||
!is_dir($path) && mkdir($path, 0777, true);
|
||||
|
||||
if (!file_exists($path)) {
|
||||
throw new FailedException($path . ' generate failed');
|
||||
$file = $path . date('YmdHis').Str::random(6) . '.' .$this->extension;
|
||||
Factory::make($this->extension)
|
||||
->setSpreadsheet($this->spreadsheet)
|
||||
->save($file);
|
||||
|
||||
if (!file_exists($file)) {
|
||||
throw new FailedException($file . ' generate failed');
|
||||
}
|
||||
|
||||
if ($disk) {
|
||||
$path = $this->upload($disk, $path);
|
||||
}
|
||||
if ($disk) {
|
||||
$file = $this->upload($disk, $file);
|
||||
}
|
||||
|
||||
return $path;
|
||||
return ['url' => $file];
|
||||
}
|
||||
|
||||
/**
|
||||
* set extension
|
||||
*
|
||||
* @time 2020年09月08日
|
||||
* @param $extension
|
||||
* @return $this
|
||||
*/
|
||||
public function setExtension($extension)
|
||||
{
|
||||
$this->extension = $extension;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,11 +240,27 @@ class Excel
|
||||
*/
|
||||
protected function upload($disk, $path)
|
||||
{
|
||||
if ($disk == 'local') {
|
||||
return $this->local($path);
|
||||
}
|
||||
$upload = new CatchUpload;
|
||||
|
||||
return ($disk ? $upload->setDriver($disk) : $upload)->upload($this->uploadedFile($path));
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回本地下载地址
|
||||
*
|
||||
* @param $path
|
||||
* @time 2020年09月08日
|
||||
* @return mixed
|
||||
*/
|
||||
protected function local($path)
|
||||
{
|
||||
return \config('filesystem.disks.local')['domain'] . '/' .
|
||||
|
||||
str_replace('\\', '/', str_replace(Utils::publicPath(), '', $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* get uploaded file
|
||||
|
36
extend/catcher/middlewares/JsonResponseMiddleware.php
Normal file
36
extend/catcher/middlewares/JsonResponseMiddleware.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CatchAdmin [Just Like ~ ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | CatchAdmin [Just Like ~ ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace catcher\middlewares;
|
||||
|
||||
use think\Middleware;
|
||||
use think\Request;
|
||||
|
||||
class JsonResponseMiddleware extends Middleware
|
||||
{
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$server = $request->server();
|
||||
$server['HTTP_ACCEPT'] = 'application/json';
|
||||
$request->withServer($server);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user