Compare commits
No commits in common. "v1" and "server" have entirely different histories.
18
.editorconfig
Normal file
18
.editorconfig
Normal file
@ -0,0 +1,18 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[docker-compose.yml]
|
||||
indent_size = 4
|
67
.env.example
Normal file
67
.env.example
Normal file
@ -0,0 +1,67 @@
|
||||
APP_NAME=CatchAdmin后台管理系统
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=laravel
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
DB_PREFIX=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailhog
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_HOST=
|
||||
PUSHER_PORT=443
|
||||
PUSHER_SCHEME=https
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
VITE_PUSHER_HOST="${PUSHER_HOST}"
|
||||
VITE_PUSHER_PORT="${PUSHER_PORT}"
|
||||
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
|
||||
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
VITE_BASE_URL=${APP_URL}/api/
|
||||
VITE_APP_NAME=${APP_NAME}
|
||||
|
||||
ALIOSS_BUCKET=
|
||||
ALIOSS_ACCESS_ID=
|
||||
ALIOSS_ACCESS_SECRET=
|
||||
ALIOSS_ENDPOINT=
|
||||
ALIOSS_UPLOAD_DIR=
|
@ -1 +0,0 @@
|
||||
APP_DEBUG = false
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE]
TYPE = mysql
HOSTNAME = 127.0.0.1
DATABASE = test
USERNAME = username
PASSWORD = password
HOSTPORT = 3306
CHARSET = utf8
DEBUG = true
[LANG]
default_lang = zh-cn
|
11
.gitattributes
vendored
Normal file
11
.gitattributes
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
* text=auto
|
||||
|
||||
*.blade.php diff=html
|
||||
*.css diff=css
|
||||
*.html diff=html
|
||||
*.md diff=markdown
|
||||
*.php diff=php
|
||||
|
||||
/.github export-ignore
|
||||
CHANGELOG.md export-ignore
|
||||
.styleci.yml export-ignore
|
@ -1,7 +1,7 @@
|
||||
# 环境
|
||||
- 操作系统:
|
||||
- php 版本:
|
||||
- thinkphp 版本:
|
||||
- Laravel 版本:
|
||||
- Mysql 版本:
|
||||
- web 服务器:
|
||||
|
||||
@ -21,4 +21,4 @@
|
||||
# 方案:
|
||||
- 解决方案:
|
||||
|
||||
> 请在问题解决后关闭 issue
|
||||
> 请在问题解决后关闭 issue
|
||||
|
4
.github/issue_template.md
vendored
4
.github/issue_template.md
vendored
@ -1,7 +1,7 @@
|
||||
# 环境
|
||||
- 操作系统:
|
||||
- php 版本:
|
||||
- thinkphp 版本:
|
||||
- Laravel 版本:
|
||||
- Mysql 版本:
|
||||
- web 服务器:
|
||||
|
||||
@ -22,4 +22,4 @@
|
||||
# 方案:
|
||||
- 解决方案:
|
||||
|
||||
> 请在问题解决后关闭 issue
|
||||
> 请在问题解决后关闭 issue
|
||||
|
23
.gitignore
vendored
23
.gitignore
vendored
@ -1,8 +1,19 @@
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/vendor
|
||||
/fixer
|
||||
/catch
|
||||
.env
|
||||
nohup.out
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpunit.result.cache
|
||||
.php-cs-fixer.cache
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
composer.lock
|
||||
/.fleet
|
||||
/.idea
|
||||
/.vscode
|
||||
/vendor
|
||||
/package
|
||||
*.log
|
||||
.env
|
||||
composer.lock
|
||||
|
||||
/web
|
||||
|
101
.php-cs-fixer.dist.php
Normal file
101
.php-cs-fixer.dist.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.DIRECTORY_SEPARATOR.'fixer'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
|
||||
|
||||
use PhpCsFixer\Finder;
|
||||
use PhpCsFixer\Config;
|
||||
|
||||
$finder = Finder::create()
|
||||
// 排除目录
|
||||
//->exclude('packages')
|
||||
//// ->notPath('./packages/test.php')
|
||||
// in 配置需要规则的目录
|
||||
->in([
|
||||
__DIR__.DIRECTORY_SEPARATOR.'app',
|
||||
|
||||
__DIR__.DIRECTORY_SEPARATOR.'catch',
|
||||
|
||||
__DIR__.DIRECTORY_SEPARATOR.'modules',
|
||||
])
|
||||
// 排除 . 开头的文件
|
||||
->ignoreDotFiles(true)
|
||||
// vcs 文件
|
||||
->ignoreVCS(true);
|
||||
|
||||
$config = new Config();
|
||||
|
||||
return $config->setRules([
|
||||
'@PSR1' => true, // psr1
|
||||
|
||||
'@PSR2' => true, // psr2 规范
|
||||
|
||||
'@PSR12' => true, // psr12 规范
|
||||
|
||||
'binary_operator_spaces' => true, // 二元操作符号空格 $a=1 => $a = 1;
|
||||
|
||||
'array_syntax' => [
|
||||
'syntax' => 'short', // array('1') => ['1']
|
||||
],
|
||||
|
||||
'no_trailing_comma_in_singleline_array' => true, // -$a = array('sample', ); => $a = array('sample');
|
||||
|
||||
'trim_array_spaces' => true, // array( 'a', 'b' ); => array('a', 'b')
|
||||
|
||||
'single_trait_insert_per_statement' => false,
|
||||
|
||||
'standardize_not_equals' => true, // "!=" => "<>"
|
||||
|
||||
'magic_constant_casing' => true, // __dir__ => __DIR__
|
||||
|
||||
'native_function_casing' => true, // STRLEN($str); => strlen($str);
|
||||
|
||||
'cast_spaces' => true, // (int)$b => (int) $b
|
||||
|
||||
'simplified_if_return' => true, // if ($foo) { return true; } return false; => return (bool) ($foo) ;
|
||||
|
||||
'no_unused_imports' => true, // use \DateTime; -use \Exception; => use \DateTime;
|
||||
|
||||
'not_operator_with_successor_space' => true, // if (!$bar) => if (! $bar)
|
||||
|
||||
/**
|
||||
* // function example($b) {
|
||||
if ($b) {
|
||||
return;
|
||||
}
|
||||
- return;
|
||||
*/
|
||||
'no_useless_return' => true,
|
||||
|
||||
/**
|
||||
* function a() {
|
||||
- $a = 1;
|
||||
- return $a;
|
||||
+ return 1;
|
||||
*/
|
||||
'return_assignment' => true,
|
||||
|
||||
/**
|
||||
-<?php return null;
|
||||
+<?php return;
|
||||
*/
|
||||
'simplified_null_return' => true,
|
||||
|
||||
/**
|
||||
* $foo = [
|
||||
- 'bar' => [
|
||||
- 'baz' => true,
|
||||
- ],
|
||||
+ 'bar' => [
|
||||
+ 'baz' => true,
|
||||
+ ],
|
||||
*/
|
||||
'array_indentation' => true,
|
||||
|
||||
/**
|
||||
* -$sample = $b [ 'a' ] [ 'b' ];
|
||||
+$sample = $b['a']['b'];
|
||||
*/
|
||||
'no_spaces_around_offset' => true,
|
||||
|
||||
'concat_space' => true, // $a.$b => $a . $b
|
||||
])->setFinder($finder);
|
42
.travis.yml
42
.travis.yml
@ -1,42 +0,0 @@
|
||||
sudo: false
|
||||
|
||||
language: php
|
||||
|
||||
branches:
|
||||
only:
|
||||
- stable
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache
|
||||
|
||||
before_install:
|
||||
- composer self-update
|
||||
|
||||
install:
|
||||
- composer install --no-dev --no-interaction --ignore-platform-reqs
|
||||
- zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Core.zip .
|
||||
- composer require --update-no-dev --no-interaction "topthink/think-image:^1.0"
|
||||
- composer require --update-no-dev --no-interaction "topthink/think-migration:^1.0"
|
||||
- composer require --update-no-dev --no-interaction "topthink/think-captcha:^1.0"
|
||||
- composer require --update-no-dev --no-interaction "topthink/think-mongo:^1.0"
|
||||
- composer require --update-no-dev --no-interaction "topthink/think-worker:^1.0"
|
||||
- composer require --update-no-dev --no-interaction "topthink/think-helper:^1.0"
|
||||
- composer require --update-no-dev --no-interaction "topthink/think-queue:^1.0"
|
||||
- composer require --update-no-dev --no-interaction "topthink/think-angular:^1.0"
|
||||
- composer require --dev --update-no-dev --no-interaction "topthink/think-testing:^1.0"
|
||||
- zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Full.zip .
|
||||
|
||||
script:
|
||||
- php think unit
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
secure: TSF6bnl2JYN72UQOORAJYL+CqIryP2gHVKt6grfveQ7d9rleAEoxlq6PWxbvTI4jZ5nrPpUcBUpWIJHNgVcs+bzLFtyh5THaLqm39uCgBbrW7M8rI26L8sBh/6nsdtGgdeQrO/cLu31QoTzbwuz1WfAVoCdCkOSZeXyT/CclH99qV6RYyQYqaD2wpRjrhA5O4fSsEkiPVuk0GaOogFlrQHx+C+lHnf6pa1KxEoN1A0UxxVfGX6K4y5g4WQDO5zT4bLeubkWOXK0G51XSvACDOZVIyLdjApaOFTwamPcD3S1tfvuxRWWvsCD5ljFvb2kSmx5BIBNwN80MzuBmrGIC27XLGOxyMerwKxB6DskNUO9PflKHDPI61DRq0FTy1fv70SFMSiAtUv9aJRT41NQh9iJJ0vC8dl+xcxrWIjU1GG6+l/ZcRqVx9V1VuGQsLKndGhja7SQ+X1slHl76fRq223sMOql7MFCd0vvvxVQ2V39CcFKao/LB1aPH3VhODDEyxwx6aXoTznvC/QPepgWsHOWQzKj9ftsgDbsNiyFlXL4cu8DWUty6rQy8zT2b4O8b1xjcwSUCsy+auEjBamzQkMJFNlZAIUrukL/NbUhQU37TAbwsFyz7X0E/u/VMle/nBCNAzgkMwAUjiHM6FqrKKBRWFbPrSIixjfjkCnrMEPw=
|
||||
file:
|
||||
- ThinkPHP_Core.zip
|
||||
- ThinkPHP_Full.zip
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
51
.workflow/branch-pipeline.yml
Normal file
51
.workflow/branch-pipeline.yml
Normal file
@ -0,0 +1,51 @@
|
||||
version: '1.0'
|
||||
name: branch-pipeline
|
||||
displayName: BranchPipeline
|
||||
stages:
|
||||
- stage:
|
||||
name: compile
|
||||
displayName: 编译
|
||||
steps:
|
||||
- step: build@php
|
||||
name: build_php
|
||||
displayName: PHP 构建
|
||||
# 支持5.0、7.0、7.1、7.2、7.3、7.4、8.0、8.1八个版本
|
||||
phpVersion: 8.0
|
||||
# 构建命令
|
||||
commands:
|
||||
- php --version
|
||||
# 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,7天后自动清除
|
||||
artifacts:
|
||||
# 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址
|
||||
- name: BUILD_ARTIFACT
|
||||
# 构建产物获取路径,是指代码编译完毕之后构建物的所在路径
|
||||
path:
|
||||
- ./
|
||||
- step: publish@general_artifacts
|
||||
name: publish_general_artifacts
|
||||
displayName: 上传制品
|
||||
# 上游构建任务定义的产物名,默认BUILD_ARTIFACT
|
||||
dependArtifact: BUILD_ARTIFACT
|
||||
# 上传到制品库时的制品命名,默认output
|
||||
artifactName: output
|
||||
dependsOn: build_php
|
||||
- stage:
|
||||
name: release
|
||||
displayName: 发布
|
||||
steps:
|
||||
- step: publish@release_artifacts
|
||||
name: publish_release_artifacts
|
||||
displayName: '发布'
|
||||
# 上游上传制品任务的产出
|
||||
dependArtifact: output
|
||||
# 发布制品版本号
|
||||
version: '1.0.0.0'
|
||||
# 是否开启版本号自增,默认开启
|
||||
autoIncrement: true
|
||||
triggers:
|
||||
push:
|
||||
branches:
|
||||
exclude:
|
||||
- master
|
||||
include:
|
||||
- .*
|
49
.workflow/master-pipeline.yml
Normal file
49
.workflow/master-pipeline.yml
Normal file
@ -0,0 +1,49 @@
|
||||
version: '1.0'
|
||||
name: master-pipeline
|
||||
displayName: MasterPipeline
|
||||
stages:
|
||||
- stage:
|
||||
name: compile
|
||||
displayName: 编译
|
||||
steps:
|
||||
- step: build@php
|
||||
name: build_php
|
||||
displayName: PHP 构建
|
||||
# 支持5.0、7.0、7.1、7.2、7.3、7.4、8.0、8.1八个版本
|
||||
phpVersion: 8.0
|
||||
# 构建命令
|
||||
commands:
|
||||
- php --version
|
||||
# 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,7天后自动清除
|
||||
artifacts:
|
||||
# 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址
|
||||
- name: BUILD_ARTIFACT
|
||||
# 构建产物获取路径,是指代码编译完毕之后构建物的所在路径
|
||||
path:
|
||||
- ./
|
||||
- step: publish@general_artifacts
|
||||
name: publish_general_artifacts
|
||||
displayName: 上传制品
|
||||
# 上游构建任务定义的产物名,默认BUILD_ARTIFACT
|
||||
dependArtifact: BUILD_ARTIFACT
|
||||
# 上传到制品库时的制品命名,默认output
|
||||
artifactName: output
|
||||
dependsOn: build_php
|
||||
- stage:
|
||||
name: release
|
||||
displayName: 发布
|
||||
steps:
|
||||
- step: publish@release_artifacts
|
||||
name: publish_release_artifacts
|
||||
displayName: '发布'
|
||||
# 上游上传制品任务的产出
|
||||
dependArtifact: output
|
||||
# 发布制品版本号
|
||||
version: '1.0.0.0'
|
||||
# 是否开启版本号自增,默认开启
|
||||
autoIncrement: true
|
||||
triggers:
|
||||
push:
|
||||
branches:
|
||||
include:
|
||||
- master
|
36
.workflow/pr-pipeline.yml
Normal file
36
.workflow/pr-pipeline.yml
Normal file
@ -0,0 +1,36 @@
|
||||
version: '1.0'
|
||||
name: pr-pipeline
|
||||
displayName: PRPipeline
|
||||
stages:
|
||||
- stage:
|
||||
name: compile
|
||||
displayName: 编译
|
||||
steps:
|
||||
- step: build@php
|
||||
name: build_php
|
||||
displayName: PHP 构建
|
||||
# 支持5.0、7.0、7.1、7.2、7.3、7.4、8.0、8.1八个版本
|
||||
phpVersion: 8.0
|
||||
# 构建命令
|
||||
commands:
|
||||
- php --version
|
||||
# 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,7天后自动清除
|
||||
artifacts:
|
||||
# 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址
|
||||
- name: BUILD_ARTIFACT
|
||||
# 构建产物获取路径,是指代码编译完毕之后构建物的所在路径
|
||||
path:
|
||||
- ./
|
||||
- step: publish@general_artifacts
|
||||
name: publish_general_artifacts
|
||||
displayName: 上传制品
|
||||
# 上游构建任务定义的产物名,默认BUILD_ARTIFACT
|
||||
dependArtifact: BUILD_ARTIFACT
|
||||
# 上传到制品库时的制品命名,默认output
|
||||
artifactName: output
|
||||
dependsOn: build_php
|
||||
triggers:
|
||||
pr:
|
||||
branches:
|
||||
include:
|
||||
- master
|
@ -186,8 +186,6 @@
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
64
README-en.md
Normal file
64
README-en.md
Normal file
@ -0,0 +1,64 @@
|
||||
## Introduce
|
||||
`CatchAdmin` is a background management system based on secondary development of [Laravel](https://laravel.com) and [Element Plus](https://element-plus.org). The `Laravel` community also has many excellent background management systems, such as `Nova`, an official product, which is of course charged, and `Filament` based on `Livewire` is free, and `Laravel Admin` has to be said. `CatchAdmin` still adopts the traditional front-end and back-end separation strategy, and the `Laravel` framework is only exported as `Api`. Coupling between management system modules is minimized. Each module has independent controllers, routes, models, and data tables. In terms of development, the influence between modules is minimized as much as possible, which reduces the difficulty of development. Based on `CatchAdmin`, systems such as `CMS`, `CRM`, `OA`, etc. can be developed. It also encapsulates many practical tools to enhance the development experience.
|
||||
|
||||
[Chinese](./README.md)|[English](./README-en.md)
|
||||
|
||||
## Function
|
||||
- [x] User management Background
|
||||
- [x] Department Management Configure the company's department structure, support tree structure
|
||||
- [x] Position Management Configure the position of background users
|
||||
- [x] Menu Management Configure system menus, buttons, etc.
|
||||
- [x] Role management Configure user roles and assign permissions
|
||||
- [x] Operation log Background user operation records
|
||||
- [x] Login log The login record of background system users
|
||||
- [x] Code Generation Generate CURD operations on the API side
|
||||
- [x] Schema management Generate table structure
|
||||
- [x] module management system
|
||||
|
||||
## Project Address
|
||||
- [github catch admin](https://github.com/jaguarjack/catch-admin)
|
||||
-
|
||||
## Document Address
|
||||
- [Document Address](https://catchadmin.com/docs/3.0/intro)
|
||||
|
||||
## Preview
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
## Demo Address
|
||||
[demo address](https://v3.catchadmin.com)
|
||||
- Account: `catch@admin.com`
|
||||
- Password: `catchadmin`
|
||||
|
||||
## Sponsorship
|
||||
If the project helps you, or saves you development time at work. If you can, you can support the `Catchadmin` project, thank you very much 🙏
|
||||
<img src="https://i.imgtg.com/2023/02/16/dAV0a.jpg" width = "200" alt="support"/>
|
||||
|
||||
## Specification
|
||||
###PHP
|
||||
Use fixer for code checking, please refer to the specifications of the `.php-cs-fixer.dist.php` file in the root directory for details, and the following two steps are required
|
||||
```shell
|
||||
mkdir path
|
||||
```
|
||||
```shell
|
||||
composer require --working-dir=path friendsofphp/php-cs-fixer
|
||||
```
|
||||
After the installation is complete, you can use
|
||||
```shell
|
||||
composer cs
|
||||
```
|
||||
Format the code, this command will directly modify the file to complete the correction, if you only need to check whether the format is correct, then use
|
||||
```shell
|
||||
composer cs-diff
|
||||
```
|
||||
|
||||
## Thanks 🙏
|
||||
> Ranked in no particular order
|
||||
|
||||
- [Laravel](https://laravel.com)
|
||||
- [Vue](https://cn.vuejs.org/)
|
||||
- [ElementPlus](https://element-plus.org)
|
||||
- [Docusaurus](https://docusaurus.com)
|
||||
- [JetBrains](https://www.jetbrains.com/)
|
186
README.md
186
README.md
@ -1,119 +1,97 @@
|
||||
<p align="center">
|
||||
<img src="https://cdn.learnku.com/uploads/images/202005/17/18206/zSuf7Ce5kM.png!large">
|
||||
</p>
|
||||
## 介绍
|
||||
### 这是 catchadmin 完全分离的版本
|
||||
`CatchAdmin`是一款基于[Laravel](https://laravel.com)和[Element Plus](https://element-plus.org)二次开发而成后台管理系统。`Laravel` 社区也有许多非常优秀的后台管理系统,例如 `Nova`, 官方出品,当然是收费的,免费的有基于 `Livewire` 的 `Filament`,还有不得不说的 `Laravel Admin`。`CatchAdmin` 还是采用传统的前后端分离策略,`Laravel` 框架仅仅作为 `Api` 输出。将管理系统模块之间的耦合降到了最低限度。每个模块之间都有独立的控制器,路由,模型,数据表。在开发上尽可能将模块之间的影响降到最低,降低了开发上的难度。基于 `CatchAdmin `可以开发 `CMS`,`CRM`,`OA` 等 等系统。也封装了很多实用的工具,提升开发体验。
|
||||
|
||||
## 前端项目
|
||||
[catchadmin-vue](https://gitee.com/catchadmin/catch-admin-vue)
|
||||
|
||||
## Laravel 入门教程
|
||||
[Laravel 免费入门教程](https://laravel-study.catchadmin.com)
|
||||
|
||||
[中文](./README.md)|[英文](./README-en.md)
|
||||
## 其他版本
|
||||
- [tp8 新版本](https://gitee.com/catchamin/catchadmin-tp)
|
||||
- [webman 高性能版本](https://gitee.com/catchamin/catchadmin-webman)
|
||||
|
||||
## 新功能
|
||||
- [动态表单](https://catchadmin.com/docs/3.0/front/catch-form)
|
||||
- [动态表格](https://catchadmin.com/docs/3.0/front/catch-table)
|
||||
|
||||
## 专业版
|
||||
[专业版本官方地址](https://license.catchadmin.com)
|
||||
|
||||
首先感谢一直以来对 `CatchAdmin` 开源项目的支持和使用。作为一名开源工作者,我一直致力于开发出功能强大且易于使用的后台管理系统,以帮助您简化业务流程和提升工作效率。然而,由于某些原因,我不得不做出一些调整。为了能够继续开发和维护这个项目,我将推出一款付费的后台管理系统,以确保我能够持续为您提供高质量的服务和支持。
|
||||
|
||||
专业版本不会在开源版本做一些破坏性变更,所以当您从开源版本切换到专业版本,不会有任何开发心智负担。但是使用专业版本会有新的组件来配合您的工作。
|
||||
|
||||
我深信,付费后台管理系统将为您带来更多的价值和便利,帮助您提升工作效率
|
||||
|
||||
## 功能
|
||||
- [x] 用户管理 后台用户管理
|
||||
- [x] 部门管理 配置公司的部门结构,支持树形结构
|
||||
- [x] 岗位管理 配置后台用户的职务
|
||||
- [x] 菜单管理 配置系统菜单,按钮等等
|
||||
- [x] 角色管理 配置用户担当的角色,分配权限
|
||||
- [x] 操作日志 后台用户操作记录
|
||||
- [x] 登录日志 后台系统用户的登录记录
|
||||
- [x] 代码生成 生成 API 端的 CURD 操作
|
||||
- [x] Schema 管理 生成表结构
|
||||
- [x] 模块管理 系统模块管理
|
||||
|
||||
|
||||
<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>
|
||||
## 讨论
|
||||
- 可以提 `ISSUE`,请按照 `issue` 模板提问
|
||||
- 加入 Q 群 `302266230` 暗号 `catchadmin`。
|
||||
- 加微信入群,新建🆕
|
||||
|
||||
<p align="center">
|
||||
<a href="http://doc.catchadmin.com/">文档</a> |
|
||||
<a href="http://vue.catchadmin.com">演示地址</a> |
|
||||
<a href="http://apidoc.catchadmin.com">接口文档</a> |
|
||||
<a href="https://gitee.com/jaguarjack/catchAdmin">项目源码</a> |
|
||||
<a href="https://www.kancloud.cn/akasishikelu/thinkphp6">看云分析</a>
|
||||
<a href="#extensions">扩展</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://gitee.com/jaguarjack/catchAdmin" target="_blank">
|
||||
<img src="https://svg.hamm.cn/gitee.svg?type=star&user=jaguarjack&project=catchAdmin"/>
|
||||
</a >
|
||||
<a href="https://gitee.com/jaguarjack/catchAdmin" target="_blank">
|
||||
<img src="https://svg.hamm.cn/gitee.svg?type=fork&user=jaguarjack&project=catchAdmin"/>
|
||||
</a >
|
||||
<img src="https://svg.hamm.cn/badge.svg?key=Base&value=ThinkPHP6"/>
|
||||
<img src="https://svg.hamm.cn/badge.svg?key=Data&value=MySQL5.5"/>
|
||||
<img src="https://svg.hamm.cn/badge.svg?key=Runtime&value=PHP7.1"/>
|
||||
<img src="https://svg.hamm.cn/badge.svg?key=License&value=Apache-2.0"/>
|
||||
</p >
|
||||
<img src="wechat.png" width="200"/>
|
||||
|
||||
## 项目地址
|
||||
- [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)[个人精力实在有限,希望可以小伙伴们可以一起维护文档]
|
||||
- [github catchadmin](https://github.com/jaguarjack/catch-admin)
|
||||
## 文档地址
|
||||
- [文档地址](https://catchadmin.com/docs/3.0/intro)
|
||||
## 预览
|
||||
<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>
|
||||
|
||||
## 环境要求
|
||||
- php7.1+ (需以下扩展)
|
||||
- [x] mbstring
|
||||
- [x] json
|
||||
- [x] openssl
|
||||
- [x] xml
|
||||
- [x] pdo
|
||||
- nginx
|
||||
- mysql
|
||||
|
||||
### 如何安装
|
||||
> 安装之前请确保已安装 Composer
|
||||
|
||||
#### 下载项目
|
||||
- 通过 Git 下载(推荐)
|
||||
```shell
|
||||
git clone https://gitee.com/jaguarjack/catchAdmin && cd catchAdmin
|
||||
|
||||
curl -sS https://install.phpcomposer.com/installer | php
|
||||
|
||||
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
|
||||
|
||||
composer install
|
||||
|
||||
```
|
||||
- composer 安装
|
||||
```shell
|
||||
composer create-project jaguarjack/catchadmin:dev-master
|
||||
```
|
||||
|
||||
#### 安装
|
||||
下载完成之后通过命令来进行安装, 一键安装 🚀
|
||||
```shell
|
||||
php think catch:install
|
||||
```
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
## 体验地址
|
||||
[demo 地址](https://v3.catchadmin.com)
|
||||
- 账户: `catch@admin.com`
|
||||
- 密码: `catchadmin`
|
||||
|
||||
[体验地址](http://vue.catchadmin.com)
|
||||
- 账号: admin@gmail.com
|
||||
- 密码: admin
|
||||
## 视频教程(😂记得一键三连哦)
|
||||
- [catchadmin 安装](https://www.bilibili.com/video/BV1eY411v71J/)
|
||||
- [catchadmin 开发之模块创建](https://www.bilibili.com/video/BV1jP41127aW/)
|
||||
- [catchadmin 之快速开发](https://www.bilibili.com/video/BV1Qh4y1J7eB/)
|
||||
|
||||
[catchadmin 文档地址](http://doc.catchadmin.com)
|
||||
## 规范
|
||||
### PHP
|
||||
使用 fixer 进行代码检查, 具体请查看根目录下 `.php-cs-fixer.dist.php` 文件的规范,还需要进行以下两步骤
|
||||
```shell
|
||||
mkdir path
|
||||
```
|
||||
```shell
|
||||
composer require --working-dir=path friendsofphp/php-cs-fixer
|
||||
```
|
||||
安装完成之后可以使用
|
||||
```shell
|
||||
composer cs
|
||||
```
|
||||
进行代码格式化,这个命令会直接修改文件完成修正,如果只需要查看格式是否正确,那么使用
|
||||
```shell
|
||||
composer cs-diff
|
||||
```
|
||||
|
||||
### 系列文章
|
||||
如果是刚开始使用 thinkphp6, 以下文章可能会对你有些许帮助,文章基于 RC3 版本。整体架构是不变的。
|
||||
- [Tp6 启动分析](https://www.kancloud.cn/akasishikelu/thinkphp6/1129385)
|
||||
- [Tp6 Request 解析](https://www.kancloud.cn/akasishikelu/thinkphp6/1134496)
|
||||
- [TP6 应用初始化](https://www.kancloud.cn/akasishikelu/thinkphp6/1130427)
|
||||
- [Tp6 中间件分析](https://www.kancloud.cn/akasishikelu/thinkphp6/1136616)
|
||||
- [Tp6 请求流程](https://www.kancloud.cn/akasishikelu/thinkphp6/1136608)
|
||||
## 感谢🙏
|
||||
> 排名不分先后
|
||||
|
||||
### Donate
|
||||
如果你觉得项目对你有帮助,可以请作者喝杯咖啡☕️!鼓励下
|
||||
<img src="https://cdn.learnku.com/uploads/images/202008/11/18206/e6qAAM8Bod.jpg!large">
|
||||
- [Laravel](https://laravel.com)
|
||||
- [Vue](https://cn.vuejs.org/)
|
||||
- [ElementPlus](https://element-plus.org)
|
||||
- [VitePress](https://vitepress.dev/zh/)
|
||||
- [JetBrains](https://www.jetbrains.com/)
|
||||
|
||||
### Talking
|
||||
- [论坛讨论](http://bbs.catchadmin.com)
|
||||
- 可以提 `ISSUE`,请按照 `issue` 模板提问
|
||||
- 加入 Q 群 `302266230` 讨论以及反馈一些问题。
|
||||
- 加群需要付费,所以请使用能支持群费的客户端。(不喜勿喷,过滤一部分不看文档和 TP 框架文档并且衣来伸手饭来张口的用户)
|
||||
- 不建议你付费入群,认真阅读文档可以解决所有问题
|
||||
- 更愿意以 `ISSUE` 的方式提问
|
||||
- 付费入群,群里的各位也是没有义务回答各种各样的基础问题。请 GOOGLE。
|
||||
|
||||
### Thanks
|
||||
> 排名部分先后
|
||||
|
||||
- [top-think/think](https://github.com/top-think/think)
|
||||
- [ant-design-pro-vue](https://github.com/sendya/ant-design-pro-vue)
|
||||
- [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)
|
||||
- [overtrue/wechat](https://github.com/overtrue/wechat)
|
||||
- [jaguarjack/migration-generator](https://github.com/yanwenwu/migration-generator)
|
||||
- [phpoffice/phpspreadsheet](https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
|
@ -1 +0,0 @@
|
||||
deny from all
|
@ -1,93 +0,0 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app;
|
||||
|
||||
use think\App;
|
||||
use think\exception\ValidateException;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 控制器基础类
|
||||
*/
|
||||
abstract class BaseController
|
||||
{
|
||||
/**
|
||||
* Request实例
|
||||
* @var \think\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* 应用实例
|
||||
* @var \think\App
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* 是否批量验证
|
||||
* @var bool
|
||||
*/
|
||||
protected $batchValidate = false;
|
||||
|
||||
/**
|
||||
* 控制器中间件
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [];
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
* @access public
|
||||
* @param App $app 应用对象
|
||||
*/
|
||||
public function __construct(App $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->request = $this->app->request;
|
||||
|
||||
// 控制器初始化
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
// 初始化
|
||||
protected function initialize()
|
||||
{}
|
||||
|
||||
/**
|
||||
* 验证数据
|
||||
* @access protected
|
||||
* @param array $data 数据
|
||||
* @param string|array $validate 验证器名或者验证规则数组
|
||||
* @param array $message 提示信息
|
||||
* @param bool $batch 是否批量验证
|
||||
* @return array|string|true
|
||||
* @throws ValidateException
|
||||
*/
|
||||
protected function validate(array $data, $validate, array $message = [], bool $batch = false)
|
||||
{
|
||||
if (is_array($validate)) {
|
||||
$v = new Validate();
|
||||
$v->rule($validate);
|
||||
} else {
|
||||
if (strpos($validate, '.')) {
|
||||
// 支持场景
|
||||
list($validate, $scene) = explode('.', $validate);
|
||||
}
|
||||
$class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate);
|
||||
$v = new $class();
|
||||
if (!empty($scene)) {
|
||||
$v->scene($scene);
|
||||
}
|
||||
}
|
||||
|
||||
$v->message($message);
|
||||
|
||||
// 是否批量验证
|
||||
if ($batch || $this->batchValidate) {
|
||||
$v->batch(true);
|
||||
}
|
||||
|
||||
return $v->failException(true)->check($data);
|
||||
}
|
||||
}
|
32
app/Console/Kernel.php
Normal file
32
app/Console/Kernel.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command('inspire')->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
33
app/Events/Create.php
Normal file
33
app/Events/Create.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Create
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new PrivateChannel('channel-name');
|
||||
}
|
||||
}
|
33
app/Events/Test.php
Normal file
33
app/Events/Test.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Test
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new PrivateChannel('channel-name');
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
<?php
|
||||
namespace app;
|
||||
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\exception\Handle;
|
||||
use think\exception\HttpException;
|
||||
use think\exception\HttpResponseException;
|
||||
use think\exception\ValidateException;
|
||||
use think\Response;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* 应用异常处理类
|
||||
*/
|
||||
class ExceptionHandle extends Handle
|
||||
{
|
||||
/**
|
||||
* 不需要记录信息(日志)的异常类列表
|
||||
* @var array
|
||||
*/
|
||||
protected $ignoreReport = [
|
||||
HttpException::class,
|
||||
HttpResponseException::class,
|
||||
ModelNotFoundException::class,
|
||||
DataNotFoundException::class,
|
||||
ValidateException::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* 记录异常信息(包括日志或者其它方式记录)
|
||||
*
|
||||
* @access public
|
||||
* @param Throwable $exception
|
||||
* @return void
|
||||
*/
|
||||
public function report(Throwable $exception): void
|
||||
{
|
||||
// 使用内置的方式记录异常日志
|
||||
parent::report($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @access public
|
||||
* @param \think\Request $request
|
||||
* @param Throwable $e
|
||||
* @return Response
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function render($request, Throwable $e): Response
|
||||
{
|
||||
// 其他错误交给系统处理
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
}
|
85
app/Exceptions/Handler.php
Normal file
85
app/Exceptions/Handler.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Catch\Enums\Code;
|
||||
use Catch\Exceptions\CatchException;
|
||||
use Catch\Exceptions\FailedException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of exception types with their corresponding custom log levels.
|
||||
*
|
||||
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
|
||||
*/
|
||||
protected $levels = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array<int, class-string<\Throwable>>
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed to the session on validation exceptions.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->reportable(function (Throwable $e) {
|
||||
//
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* render
|
||||
*
|
||||
* @param $request
|
||||
* @param Throwable $e
|
||||
* @return JsonResponse|Response
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function render($request, Throwable $e): JsonResponse|Response
|
||||
{
|
||||
$message = $e->getMessage();
|
||||
|
||||
if (method_exists($e, 'getStatusCode')) {
|
||||
if ($e->getStatusCode() == Response::HTTP_NOT_FOUND) {
|
||||
$message = '路由未找到或未注册';
|
||||
}
|
||||
}
|
||||
|
||||
$e = new FailedException($message ?: 'Server Error', $e instanceof CatchException ? $e->getCode() : Code::FAILED);
|
||||
|
||||
$response = parent::render($request, $e);
|
||||
|
||||
$response->header('Access-Control-Allow-Origin', '*');
|
||||
$response->header('Access-Control-Allow-Methods', '*');
|
||||
$response->header('Access-Control-Allow-Headers', '*');
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
13
app/Http/Controllers/Controller.php
Normal file
13
app/Http/Controllers/Controller.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
67
app/Http/Kernel.php
Normal file
67
app/Http/Kernel.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array<int, class-string|string>
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array<string, array<int, class-string|string>>
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
'throttle:api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
];
|
||||
}
|
21
app/Http/Middleware/Authenticate.php
Normal file
21
app/Http/Middleware/Authenticate.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string|null
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return route('login');
|
||||
}
|
||||
}
|
||||
}
|
17
app/Http/Middleware/EncryptCookies.php
Normal file
17
app/Http/Middleware/EncryptCookies.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
32
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
32
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @param string|null ...$guards
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, ...$guards)
|
||||
{
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
19
app/Http/Middleware/TrimStrings.php
Normal file
19
app/Http/Middleware/TrimStrings.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
20
app/Http/Middleware/TrustHosts.php
Normal file
20
app/Http/Middleware/TrustHosts.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts()
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
28
app/Http/Middleware/TrustProxies.php
Normal file
28
app/Http/Middleware/TrustProxies.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers =
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
22
app/Http/Middleware/ValidateSignature.php
Normal file
22
app/Http/Middleware/ValidateSignature.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
|
||||
|
||||
class ValidateSignature extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the query string parameters that should be ignored.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
// 'fbclid',
|
||||
// 'utm_campaign',
|
||||
// 'utm_content',
|
||||
// 'utm_medium',
|
||||
// 'utm_source',
|
||||
// 'utm_term',
|
||||
];
|
||||
}
|
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
30
app/Listeners/Command.php
Normal file
30
app/Listeners/Command.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use Illuminate\Console\Events\CommandFinished;
|
||||
|
||||
class Command
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param CommandFinished $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(CommandFinished $event)
|
||||
{
|
||||
//
|
||||
// dd($event->command);
|
||||
}
|
||||
}
|
28
app/Listeners/RouteMatched.php
Normal file
28
app/Listeners/RouteMatched.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
class RouteMatched
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param object $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(\Illuminate\Routing\Events\RouteMatched $event)
|
||||
{
|
||||
//
|
||||
// dd($event->route);
|
||||
}
|
||||
}
|
27
app/Listeners/test.php
Normal file
27
app/Listeners/test.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
class test
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param object $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
11
app/Models/Modules/Users/Models/CatchController.php
Normal file
11
app/Models/Modules/Users/Models/CatchController.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Modules\Users\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CatchController extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
45
app/Models/User.php
Normal file
45
app/Models/User.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
protected $table = 'users';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
}
|
28
app/Providers/AppServiceProvider.php
Normal file
28
app/Providers/AppServiceProvider.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
30
app/Providers/AuthServiceProvider.php
Normal file
30
app/Providers/AuthServiceProvider.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
// use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The model to policy mappings for the application.
|
||||
*
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
protected $policies = [
|
||||
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
21
app/Providers/BroadcastServiceProvider.php
Normal file
21
app/Providers/BroadcastServiceProvider.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
53
app/Providers/EventServiceProvider.php
Normal file
53
app/Providers/EventServiceProvider.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Listeners\Command;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Console\Events\CommandFinished;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Routing\Events\RouteMatched;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event to listener mappings for the application.
|
||||
*
|
||||
* @var array<class-string, array<int, class-string>>
|
||||
*/
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
|
||||
RouteMatched::class => [
|
||||
\App\Listeners\RouteMatched::class
|
||||
],
|
||||
|
||||
CommandFinished::class => [
|
||||
Command::class
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if events and listeners should be automatically discovered.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldDiscoverEvents()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
62
app/Providers/RouteServiceProvider.php
Normal file
62
app/Providers/RouteServiceProvider.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Catch\CatchAdmin;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\CompiledRouteCollection;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* Typically, users are redirected here after authentication.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/home';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, and other route configuration.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->configureRateLimiting();
|
||||
|
||||
$this->routes(function () {
|
||||
Route::middleware('api')
|
||||
->prefix('api')
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
|
||||
$this->booted(function(){
|
||||
$this->app->booted(function (){
|
||||
if (file_exists('loadCachedAdminRoutes')) {
|
||||
loadCachedAdminRoutes();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the rate limiters for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configureRateLimiting()
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
namespace app;
|
||||
|
||||
// 应用请求对象类
|
||||
|
||||
use catchAdmin\permissions\model\Users;
|
||||
use catcher\CatchAuth;
|
||||
use catcher\Code;
|
||||
use catcher\exceptions\FailedException;
|
||||
use catcher\exceptions\LoginFailedException;
|
||||
use thans\jwt\exception\TokenBlacklistException;
|
||||
use thans\jwt\exception\TokenExpiredException;
|
||||
use thans\jwt\exception\TokenInvalidException;
|
||||
|
||||
class Request extends \think\Request
|
||||
{
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* login user
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param null $guard
|
||||
* @return mixed
|
||||
*/
|
||||
public function user($guard = null)
|
||||
{
|
||||
if (!$this->auth) {
|
||||
$this->auth = new CatchAuth;
|
||||
}
|
||||
|
||||
try {
|
||||
$user = $this->auth->guard($guard ? : config('catch.auth.default.guard'))->user();
|
||||
|
||||
if ($user->status == Users::DISABLE) {
|
||||
throw new LoginFailedException('该用户已被禁用');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
if ($e instanceof TokenExpiredException) {
|
||||
throw new FailedException('token 过期', Code::LOGIN_EXPIRED);
|
||||
}
|
||||
if ($e instanceof TokenBlacklistException) {
|
||||
throw new FailedException('token 被加入黑名单', Code::LOGIN_BLACKLIST);
|
||||
}
|
||||
if ($e instanceof TokenInvalidException) {
|
||||
throw new FailedException('token 不合法', Code::LOST_LOGIN);
|
||||
}
|
||||
throw new FailedException('认证失败: '. $e->getMessage(), Code::LOST_LOGIN);
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
<?php
|
||||
// 应用公共文件
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
// 事件定义文件
|
||||
|
||||
return [
|
||||
'bind' => [],
|
||||
|
||||
'listen' => [
|
||||
'AppInit' => [],
|
||||
'HttpRun' => [],
|
||||
'HttpEnd' => [],
|
||||
'LogLevel' => [],
|
||||
'LogWrite' => [],
|
||||
'RouteLoaded' => [],
|
||||
],
|
||||
|
||||
'subscribe' => [
|
||||
],
|
||||
];
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
// 全局中间件定义文件
|
||||
return [
|
||||
// 全局请求缓存
|
||||
// \think\middleware\CheckRequestCache::class,
|
||||
// 多语言加载
|
||||
// \think\middleware\LoadLangPack::class,
|
||||
// Session初始化
|
||||
// \think\middleware\SessionInit::class
|
||||
\think\middleware\AllowCrossDomain::class,
|
||||
];
|
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
use app\ExceptionHandle;
|
||||
use app\Request;
|
||||
|
||||
// 容器Provider定义文件
|
||||
return [
|
||||
'think\Request' => Request::class,
|
||||
'think\exception\Handle' => ExceptionHandle::class,
|
||||
];
|
@ -1,4 +0,0 @@
|
||||
<?php
|
||||
return [
|
||||
\catcher\CatchAdminService::class,
|
||||
];
|
53
artisan
Normal file
53
artisan
Normal file
@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Auto Loader
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Composer provides a convenient, automatically generated class loader
|
||||
| for our application. We just need to utilize it! We'll require it
|
||||
| into the script here so that we do not have to worry about the
|
||||
| loading of any of our classes manually. It's great to relax.
|
||||
|
|
||||
*/
|
||||
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Run The Artisan Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When we run the console application, the current CLI command will be
|
||||
| executed in this console and the response sent back to a terminal
|
||||
| or another output device for the developers. Here goes nothing!
|
||||
|
|
||||
*/
|
||||
|
||||
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||
|
||||
$status = $kernel->handle(
|
||||
$input = new Symfony\Component\Console\Input\ArgvInput,
|
||||
new Symfony\Component\Console\Output\ConsoleOutput
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Shutdown The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Once Artisan has finished running, we will fire off the shutdown events
|
||||
| so that any final work may be done by the application before we shut
|
||||
| down the process. This is the last thing to happen to the request.
|
||||
|
|
||||
*/
|
||||
|
||||
$kernel->terminate($input, $status);
|
||||
|
||||
exit($status);
|
55
bootstrap/app.php
Normal file
55
bootstrap/app.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Create The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The first thing we will do is create a new Laravel application instance
|
||||
| which serves as the "glue" for all the components of Laravel, and is
|
||||
| the IoC container for the system binding all of the various parts.
|
||||
|
|
||||
*/
|
||||
|
||||
$app = new Illuminate\Foundation\Application(
|
||||
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Bind Important Interfaces
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, we need to bind some important interfaces into the container so
|
||||
| we will be able to resolve them when needed. The kernels serve the
|
||||
| incoming requests to this application from both the web and CLI.
|
||||
|
|
||||
*/
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Http\Kernel::class,
|
||||
App\Http\Kernel::class
|
||||
);
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Console\Kernel::class,
|
||||
App\Console\Kernel::class
|
||||
);
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Debug\ExceptionHandler::class,
|
||||
App\Exceptions\Handler::class
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Return The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This script returns the application instance. The instance is given to
|
||||
| the calling script so we can separate the building of the instances
|
||||
| from the actual running of the application and sending responses.
|
||||
|
|
||||
*/
|
||||
|
||||
return $app;
|
49
bootstrap/cache/packages.php
vendored
Executable file
49
bootstrap/cache/packages.php
vendored
Executable file
@ -0,0 +1,49 @@
|
||||
<?php return array (
|
||||
'laravel/tinker' =>
|
||||
array (
|
||||
'providers' =>
|
||||
array (
|
||||
0 => 'Laravel\\Tinker\\TinkerServiceProvider',
|
||||
),
|
||||
),
|
||||
'nesbot/carbon' =>
|
||||
array (
|
||||
'providers' =>
|
||||
array (
|
||||
0 => 'Carbon\\Laravel\\ServiceProvider',
|
||||
),
|
||||
),
|
||||
'nunomaduro/collision' =>
|
||||
array (
|
||||
'providers' =>
|
||||
array (
|
||||
0 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
|
||||
),
|
||||
),
|
||||
'nunomaduro/termwind' =>
|
||||
array (
|
||||
'providers' =>
|
||||
array (
|
||||
0 => 'Termwind\\Laravel\\TermwindServiceProvider',
|
||||
),
|
||||
),
|
||||
'pestphp/pest' =>
|
||||
array (
|
||||
'providers' =>
|
||||
array (
|
||||
0 => 'Pest\\Laravel\\PestServiceProvider',
|
||||
),
|
||||
),
|
||||
'tymon/jwt-auth' =>
|
||||
array (
|
||||
'aliases' =>
|
||||
array (
|
||||
'JWTAuth' => 'Tymon\\JWTAuth\\Facades\\JWTAuth',
|
||||
'JWTFactory' => 'Tymon\\JWTAuth\\Facades\\JWTFactory',
|
||||
),
|
||||
'providers' =>
|
||||
array (
|
||||
0 => 'Tymon\\JWTAuth\\Providers\\LaravelServiceProvider',
|
||||
),
|
||||
),
|
||||
);
|
237
bootstrap/cache/services.php
vendored
Executable file
237
bootstrap/cache/services.php
vendored
Executable file
@ -0,0 +1,237 @@
|
||||
<?php return array (
|
||||
'providers' =>
|
||||
array (
|
||||
0 => 'Illuminate\\Auth\\AuthServiceProvider',
|
||||
1 => 'Illuminate\\Broadcasting\\BroadcastServiceProvider',
|
||||
2 => 'Illuminate\\Bus\\BusServiceProvider',
|
||||
3 => 'Illuminate\\Cache\\CacheServiceProvider',
|
||||
4 => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
5 => 'Illuminate\\Cookie\\CookieServiceProvider',
|
||||
6 => 'Illuminate\\Database\\DatabaseServiceProvider',
|
||||
7 => 'Illuminate\\Encryption\\EncryptionServiceProvider',
|
||||
8 => 'Illuminate\\Filesystem\\FilesystemServiceProvider',
|
||||
9 => 'Illuminate\\Foundation\\Providers\\FoundationServiceProvider',
|
||||
10 => 'Illuminate\\Hashing\\HashServiceProvider',
|
||||
11 => 'Illuminate\\Mail\\MailServiceProvider',
|
||||
12 => 'Illuminate\\Notifications\\NotificationServiceProvider',
|
||||
13 => 'Illuminate\\Pagination\\PaginationServiceProvider',
|
||||
14 => 'Illuminate\\Pipeline\\PipelineServiceProvider',
|
||||
15 => 'Illuminate\\Queue\\QueueServiceProvider',
|
||||
16 => 'Illuminate\\Redis\\RedisServiceProvider',
|
||||
17 => 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider',
|
||||
18 => 'Illuminate\\Session\\SessionServiceProvider',
|
||||
19 => 'Illuminate\\Translation\\TranslationServiceProvider',
|
||||
20 => 'Illuminate\\Validation\\ValidationServiceProvider',
|
||||
21 => 'Illuminate\\View\\ViewServiceProvider',
|
||||
22 => 'Laravel\\Tinker\\TinkerServiceProvider',
|
||||
23 => 'Carbon\\Laravel\\ServiceProvider',
|
||||
24 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
|
||||
25 => 'Termwind\\Laravel\\TermwindServiceProvider',
|
||||
26 => 'Pest\\Laravel\\PestServiceProvider',
|
||||
27 => 'Tymon\\JWTAuth\\Providers\\LaravelServiceProvider',
|
||||
28 => 'Catch\\Providers\\CatchAdminServiceProvider',
|
||||
29 => 'App\\Providers\\AppServiceProvider',
|
||||
30 => 'App\\Providers\\AuthServiceProvider',
|
||||
31 => 'App\\Providers\\EventServiceProvider',
|
||||
32 => 'App\\Providers\\RouteServiceProvider',
|
||||
),
|
||||
'eager' =>
|
||||
array (
|
||||
0 => 'Illuminate\\Auth\\AuthServiceProvider',
|
||||
1 => 'Illuminate\\Cookie\\CookieServiceProvider',
|
||||
2 => 'Illuminate\\Database\\DatabaseServiceProvider',
|
||||
3 => 'Illuminate\\Encryption\\EncryptionServiceProvider',
|
||||
4 => 'Illuminate\\Filesystem\\FilesystemServiceProvider',
|
||||
5 => 'Illuminate\\Foundation\\Providers\\FoundationServiceProvider',
|
||||
6 => 'Illuminate\\Notifications\\NotificationServiceProvider',
|
||||
7 => 'Illuminate\\Pagination\\PaginationServiceProvider',
|
||||
8 => 'Illuminate\\Session\\SessionServiceProvider',
|
||||
9 => 'Illuminate\\View\\ViewServiceProvider',
|
||||
10 => 'Carbon\\Laravel\\ServiceProvider',
|
||||
11 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
|
||||
12 => 'Termwind\\Laravel\\TermwindServiceProvider',
|
||||
13 => 'Pest\\Laravel\\PestServiceProvider',
|
||||
14 => 'Tymon\\JWTAuth\\Providers\\LaravelServiceProvider',
|
||||
15 => 'Catch\\Providers\\CatchAdminServiceProvider',
|
||||
16 => 'App\\Providers\\AppServiceProvider',
|
||||
17 => 'App\\Providers\\AuthServiceProvider',
|
||||
18 => 'App\\Providers\\EventServiceProvider',
|
||||
19 => 'App\\Providers\\RouteServiceProvider',
|
||||
),
|
||||
'deferred' =>
|
||||
array (
|
||||
'Illuminate\\Broadcasting\\BroadcastManager' => 'Illuminate\\Broadcasting\\BroadcastServiceProvider',
|
||||
'Illuminate\\Contracts\\Broadcasting\\Factory' => 'Illuminate\\Broadcasting\\BroadcastServiceProvider',
|
||||
'Illuminate\\Contracts\\Broadcasting\\Broadcaster' => 'Illuminate\\Broadcasting\\BroadcastServiceProvider',
|
||||
'Illuminate\\Bus\\Dispatcher' => 'Illuminate\\Bus\\BusServiceProvider',
|
||||
'Illuminate\\Contracts\\Bus\\Dispatcher' => 'Illuminate\\Bus\\BusServiceProvider',
|
||||
'Illuminate\\Contracts\\Bus\\QueueingDispatcher' => 'Illuminate\\Bus\\BusServiceProvider',
|
||||
'Illuminate\\Bus\\BatchRepository' => 'Illuminate\\Bus\\BusServiceProvider',
|
||||
'Illuminate\\Bus\\DatabaseBatchRepository' => 'Illuminate\\Bus\\BusServiceProvider',
|
||||
'cache' => 'Illuminate\\Cache\\CacheServiceProvider',
|
||||
'cache.store' => 'Illuminate\\Cache\\CacheServiceProvider',
|
||||
'cache.psr6' => 'Illuminate\\Cache\\CacheServiceProvider',
|
||||
'memcached.connector' => 'Illuminate\\Cache\\CacheServiceProvider',
|
||||
'Illuminate\\Cache\\RateLimiter' => 'Illuminate\\Cache\\CacheServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\AboutCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Cache\\Console\\ClearCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Cache\\Console\\ForgetCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\ClearCompiledCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Auth\\Console\\ClearResetsCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\ConfigCacheCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\ConfigClearCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\DbCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\MonitorCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\PruneCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\ShowCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\TableCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\WipeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\DownCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\EnvironmentCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\EnvironmentDecryptCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\EnvironmentEncryptCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\EventCacheCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\EventClearCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\EventListCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\KeyGenerateCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\OptimizeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\OptimizeClearCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\PackageDiscoverCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Queue\\Console\\ClearCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Queue\\Console\\ListFailedCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Queue\\Console\\FlushFailedCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Queue\\Console\\ForgetFailedCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Queue\\Console\\ListenCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Queue\\Console\\MonitorCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Queue\\Console\\PruneBatchesCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Queue\\Console\\PruneFailedJobsCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Queue\\Console\\RestartCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Queue\\Console\\RetryCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Queue\\Console\\RetryBatchCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Queue\\Console\\WorkCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\RouteCacheCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\RouteClearCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\RouteListCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\DumpCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\Seeds\\SeedCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Console\\Scheduling\\ScheduleFinishCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Console\\Scheduling\\ScheduleListCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Console\\Scheduling\\ScheduleRunCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Console\\Scheduling\\ScheduleClearCacheCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Console\\Scheduling\\ScheduleTestCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Console\\Scheduling\\ScheduleWorkCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\ShowModelCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\StorageLinkCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\UpCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\ViewCacheCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\ViewClearCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Cache\\Console\\CacheTableCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\CastMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\ChannelMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\ComponentMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\ConsoleMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Routing\\Console\\ControllerMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\DocsCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\EventGenerateCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\EventMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\ExceptionMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\Factories\\FactoryMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\JobMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\ListenerMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\MailMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Routing\\Console\\MiddlewareMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\ModelMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\NotificationMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Notifications\\Console\\NotificationTableCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\ObserverMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\PolicyMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\ProviderMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Queue\\Console\\FailedTableCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Queue\\Console\\TableCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Queue\\Console\\BatchesTableCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\RequestMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\ResourceMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\RuleMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\ScopeMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\Seeds\\SeederMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Session\\Console\\SessionTableCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\ServeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\StubPublishCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\TestMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Foundation\\Console\\VendorPublishCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'migrator' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'migration.repository' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'migration.creator' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\Migrations\\MigrateCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\Migrations\\FreshCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\Migrations\\InstallCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\Migrations\\RefreshCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\Migrations\\ResetCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\Migrations\\RollbackCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\Migrations\\StatusCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'Illuminate\\Database\\Console\\Migrations\\MigrateMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'composer' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
|
||||
'hash' => 'Illuminate\\Hashing\\HashServiceProvider',
|
||||
'hash.driver' => 'Illuminate\\Hashing\\HashServiceProvider',
|
||||
'mail.manager' => 'Illuminate\\Mail\\MailServiceProvider',
|
||||
'mailer' => 'Illuminate\\Mail\\MailServiceProvider',
|
||||
'Illuminate\\Mail\\Markdown' => 'Illuminate\\Mail\\MailServiceProvider',
|
||||
'Illuminate\\Contracts\\Pipeline\\Hub' => 'Illuminate\\Pipeline\\PipelineServiceProvider',
|
||||
'queue' => 'Illuminate\\Queue\\QueueServiceProvider',
|
||||
'queue.connection' => 'Illuminate\\Queue\\QueueServiceProvider',
|
||||
'queue.failer' => 'Illuminate\\Queue\\QueueServiceProvider',
|
||||
'queue.listener' => 'Illuminate\\Queue\\QueueServiceProvider',
|
||||
'queue.worker' => 'Illuminate\\Queue\\QueueServiceProvider',
|
||||
'redis' => 'Illuminate\\Redis\\RedisServiceProvider',
|
||||
'redis.connection' => 'Illuminate\\Redis\\RedisServiceProvider',
|
||||
'auth.password' => 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider',
|
||||
'auth.password.broker' => 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider',
|
||||
'translator' => 'Illuminate\\Translation\\TranslationServiceProvider',
|
||||
'translation.loader' => 'Illuminate\\Translation\\TranslationServiceProvider',
|
||||
'validator' => 'Illuminate\\Validation\\ValidationServiceProvider',
|
||||
'validation.presence' => 'Illuminate\\Validation\\ValidationServiceProvider',
|
||||
'command.tinker' => 'Laravel\\Tinker\\TinkerServiceProvider',
|
||||
),
|
||||
'when' =>
|
||||
array (
|
||||
'Illuminate\\Broadcasting\\BroadcastServiceProvider' =>
|
||||
array (
|
||||
),
|
||||
'Illuminate\\Bus\\BusServiceProvider' =>
|
||||
array (
|
||||
),
|
||||
'Illuminate\\Cache\\CacheServiceProvider' =>
|
||||
array (
|
||||
),
|
||||
'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider' =>
|
||||
array (
|
||||
),
|
||||
'Illuminate\\Hashing\\HashServiceProvider' =>
|
||||
array (
|
||||
),
|
||||
'Illuminate\\Mail\\MailServiceProvider' =>
|
||||
array (
|
||||
),
|
||||
'Illuminate\\Pipeline\\PipelineServiceProvider' =>
|
||||
array (
|
||||
),
|
||||
'Illuminate\\Queue\\QueueServiceProvider' =>
|
||||
array (
|
||||
),
|
||||
'Illuminate\\Redis\\RedisServiceProvider' =>
|
||||
array (
|
||||
),
|
||||
'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider' =>
|
||||
array (
|
||||
),
|
||||
'Illuminate\\Translation\\TranslationServiceProvider' =>
|
||||
array (
|
||||
),
|
||||
'Illuminate\\Validation\\ValidationServiceProvider' =>
|
||||
array (
|
||||
),
|
||||
'Laravel\\Tinker\\TinkerServiceProvider' =>
|
||||
array (
|
||||
),
|
||||
),
|
||||
);
|
@ -1,82 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\login;
|
||||
|
||||
use catchAdmin\permissions\model\Users;
|
||||
use catchAdmin\system\model\LoginLog;
|
||||
use think\facade\Db;
|
||||
|
||||
class LoginLogEvent
|
||||
{
|
||||
public function handle($params)
|
||||
{
|
||||
$agent = request()->header('user-agent');
|
||||
|
||||
$username = Users::where('email', $params['email'])->value('username');
|
||||
|
||||
app(LoginLog::class)->storeBy([
|
||||
'login_name' => $username ? : $params['email'],
|
||||
'login_ip' => request()->ip(),
|
||||
'browser' => $this->getBrowser($agent),
|
||||
'os' => $this->getOs($agent),
|
||||
'login_at' => time(),
|
||||
'status' => $params['success'] ? 1 : 2,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月12日
|
||||
* @param $agent
|
||||
* @return string
|
||||
*/
|
||||
private function getOs($agent): string
|
||||
{
|
||||
if (false !== stripos($agent, 'win') && preg_match('/nt 6.1/i', $agent)) {
|
||||
return 'Windows 7';
|
||||
}
|
||||
if (false !== stripos($agent, 'win') && preg_match('/nt 6.2/i', $agent)) {
|
||||
return 'Windows 8';
|
||||
}
|
||||
if(false !== stripos($agent, 'win') && preg_match('/nt 10.0/i', $agent)) {
|
||||
return 'Windows 10';#添加win10判断
|
||||
}
|
||||
if (false !== stripos($agent, 'win') && preg_match('/nt 5.1/i', $agent)) {
|
||||
return 'Windows XP';
|
||||
}
|
||||
if (false !== stripos($agent, 'linux')) {
|
||||
return 'Linux';
|
||||
}
|
||||
if (false !== stripos($agent, 'mac')) {
|
||||
return 'mac';
|
||||
}
|
||||
|
||||
return '未知';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月12日
|
||||
* @param $agent
|
||||
* @return string
|
||||
*/
|
||||
private function getBrowser($agent): string
|
||||
{
|
||||
if (false !== stripos($agent, "MSIE")) {
|
||||
return 'MSIE';
|
||||
}
|
||||
if (false !== stripos($agent, "Firefox")) {
|
||||
return 'Firefox';
|
||||
}
|
||||
if (false !== stripos($agent, "Chrome")) {
|
||||
return 'Chrome';
|
||||
}
|
||||
if (false !== stripos($agent, "Safari")) {
|
||||
return 'Safari';
|
||||
}
|
||||
if (false !== stripos($agent, "Opera")) {
|
||||
return 'Opera';
|
||||
}
|
||||
|
||||
return '未知';
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?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\login;
|
||||
|
||||
use catcher\ModuleService;
|
||||
use think\Service;
|
||||
|
||||
class LoginService extends ModuleService
|
||||
{
|
||||
public function loadRouteFrom()
|
||||
{
|
||||
// TODO: Implement loadRouteFrom() method.
|
||||
return __DIR__ . DIRECTORY_SEPARATOR . 'route.php';
|
||||
}
|
||||
|
||||
public function loadEvents()
|
||||
{
|
||||
return [
|
||||
'loginLog' => [ LoginLogEvent::class ],
|
||||
];
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\login\controller;
|
||||
|
||||
use catchAdmin\login\request\LoginRequest;
|
||||
use catchAdmin\permissions\model\Users;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\CatchAuth;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\exceptions\LoginFailedException;
|
||||
use thans\jwt\facade\JWTAuth;
|
||||
|
||||
class Index extends CatchController
|
||||
{
|
||||
/**
|
||||
* 登陆
|
||||
*
|
||||
* @time 2019年11月28日
|
||||
* @param LoginRequest $request
|
||||
* @param CatchAuth $auth
|
||||
* @return bool|string
|
||||
*/
|
||||
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('该用户已被禁用');
|
||||
}
|
||||
|
||||
// 记录用户登录
|
||||
$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('', '登录失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 登出
|
||||
*
|
||||
* @time 2019年11月28日
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function logout(): \think\response\Json
|
||||
{
|
||||
return CatchResponse::success();
|
||||
}
|
||||
|
||||
/**
|
||||
* refresh token
|
||||
*
|
||||
* @author JaguarJack
|
||||
* @email njphper@gmail.com
|
||||
* @time 2020/5/18
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function refreshToken()
|
||||
{
|
||||
return CatchResponse::success([
|
||||
'token' => JWTAuth::refresh()
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
{
|
||||
"name": "登陆",
|
||||
"alias": "login",
|
||||
"description": "login 模块",
|
||||
"version": "1.0.0",
|
||||
"keywords": [],
|
||||
"order": 1,
|
||||
"services": [
|
||||
"\\catchAdmin\\login\\LoginService"
|
||||
],
|
||||
"aliases": {},
|
||||
"files": [],
|
||||
"requires": [],
|
||||
"enable": true
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\login\request;
|
||||
|
||||
use catcher\base\CatchRequest;
|
||||
|
||||
class LoginRequest extends CatchRequest
|
||||
{
|
||||
protected $needCreatorId = false;
|
||||
|
||||
protected function rules(): array
|
||||
{
|
||||
// TODO: Implement rules() method.
|
||||
return [
|
||||
'email|用户名' => 'email',
|
||||
'password|密码' => 'require',
|
||||
// 'captcha|验证码' => 'require|captcha'
|
||||
];
|
||||
}
|
||||
|
||||
protected function message(): array
|
||||
{
|
||||
// TODO: Implement message() method.
|
||||
return [];
|
||||
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
$router->group(function () use ($router){
|
||||
# 登入
|
||||
$router->post('login', '\catchAdmin\login\controller\Index@login');
|
||||
$router->post('logout', '\catchAdmin\login\controller\Index@logout');
|
||||
$router->post('refresh/token', '\catchAdmin\login\controller\Index@refreshToken');
|
||||
});
|
||||
|
||||
|
@ -1,54 +0,0 @@
|
||||
<?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;
|
||||
|
||||
use catchAdmin\permissions\event\OperateLogEvent;
|
||||
use catchAdmin\permissions\middleware\AuthTokenMiddleware;
|
||||
use catchAdmin\permissions\middleware\PermissionsMiddleware;
|
||||
use catchAdmin\permissions\middleware\RecordOperateMiddleware;
|
||||
use catcher\ModuleService;
|
||||
|
||||
class PermissionService extends ModuleService
|
||||
{
|
||||
public function register()
|
||||
{
|
||||
parent::register(); // TODO: Change the autogenerated stub
|
||||
|
||||
$this->registerMiddleWares();
|
||||
}
|
||||
|
||||
public function loadEvents()
|
||||
{
|
||||
return [
|
||||
'operateLog' => [ OperateLogEvent::class ],
|
||||
];
|
||||
}
|
||||
|
||||
public function loadRouteFrom()
|
||||
{
|
||||
// TODO: Implement loadRouteFrom() method.
|
||||
return __DIR__ . DIRECTORY_SEPARATOR . 'route.php';
|
||||
}
|
||||
|
||||
|
||||
protected function registerMiddleWares()
|
||||
{
|
||||
$middleware = $this->app->config->get('middleware');
|
||||
|
||||
$middleware['alias']['auth'] = [
|
||||
AuthTokenMiddleware::class,
|
||||
PermissionsMiddleware::class,
|
||||
RecordOperateMiddleware::class
|
||||
];
|
||||
|
||||
$this->app->config->set($middleware, 'middleware');
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\controller;
|
||||
|
||||
use catcher\base\CatchController;
|
||||
use catchAdmin\permissions\model\Department as DepartmentModel;
|
||||
use catcher\base\CatchRequest;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\Tree;
|
||||
|
||||
class Department extends CatchController
|
||||
{
|
||||
protected $department;
|
||||
|
||||
public function __construct(DepartmentModel $department)
|
||||
{
|
||||
$this->department = $department;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param CatchRequest $request
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function index(): \think\response\Json
|
||||
{
|
||||
return CatchResponse::success(Tree::done($this->department->getList()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param CatchRequest $request
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function save(CatchRequest $request): \think\response\Json
|
||||
{
|
||||
return CatchResponse::success($this->department->storeBy($request->param()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param $id
|
||||
* @param CatchRequest $request
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function update($id, CatchRequest $request): \think\response\Json
|
||||
{
|
||||
return CatchResponse::success($this->department->updateBy($id, $request->param()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param $id
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function delete($id): \think\response\Json
|
||||
{
|
||||
return CatchResponse::success($this->department->deleteBy($id));
|
||||
}
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\controller;
|
||||
|
||||
use catchAdmin\permissions\model\Job as JobModel;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\base\CatchRequest;
|
||||
use catcher\CatchResponse;
|
||||
|
||||
class Job extends CatchController
|
||||
{
|
||||
protected $job;
|
||||
|
||||
public function __construct(JobModel $job)
|
||||
{
|
||||
$this->job = $job;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param CatchRequest $request
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function index(): \think\response\Json
|
||||
{
|
||||
return CatchResponse::paginate($this->job->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param CatchRequest $request
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function save(CatchRequest $request): \think\response\Json
|
||||
{
|
||||
return CatchResponse::success($this->job->storeBy($request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param $id
|
||||
* @param CatchRequest $request
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function update($id, CatchRequest $request): \think\response\Json
|
||||
{
|
||||
return CatchResponse::success($this->job->updateBy($id, $request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param $id
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function delete($id): \think\response\Json
|
||||
{
|
||||
return CatchResponse::success($this->job->deleteBy($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有
|
||||
*
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
return CatchResponse::success($this->job->field(['id', 'job_name'])->select());
|
||||
}
|
||||
}
|
@ -1,174 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\controller;
|
||||
|
||||
|
||||
use catcher\base\CatchRequest as Request;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\exceptions\FailedException;
|
||||
use catcher\library\ParseClass;
|
||||
use catcher\Tree;
|
||||
use catchAdmin\permissions\model\Permissions;
|
||||
use think\response\Json;
|
||||
|
||||
class Permission extends CatchController
|
||||
{
|
||||
protected $permissions;
|
||||
|
||||
public function __construct(Permissions $permissions)
|
||||
{
|
||||
$this->permissions = $permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月11日
|
||||
* @param Request $request
|
||||
* @return Json
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
*/
|
||||
public function index(Request $request): Json
|
||||
{
|
||||
// 获取菜单类型
|
||||
$menuList = $this->permissions->getList(true);
|
||||
|
||||
// 获取按钮类型并且重新排列
|
||||
$buttonList = [];
|
||||
$this->permissions
|
||||
->whereIn('parent_id', array_unique($menuList->column('id')))
|
||||
->where('type', Permissions::BTN_TYPE)
|
||||
->select()->each(function ($item) use (&$buttonList){
|
||||
$buttonList[$item['parent_id']][] = $item->toArray();
|
||||
});
|
||||
|
||||
// 子节点的 key
|
||||
$children = $request->param('actionList') ?? 'children';
|
||||
// 返回树结构
|
||||
return CatchResponse::success(Tree::done($menuList->each(function (&$item) use ($buttonList, $children){
|
||||
$item[$children] = $buttonList[$item['id']] ?? [];
|
||||
})->toArray()));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月11日
|
||||
* @param Request $request
|
||||
* @return Json
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
*/
|
||||
public function save(Request $request): Json
|
||||
{
|
||||
$params = $request->param();
|
||||
|
||||
// 如果是子分类 自动写入父类模块
|
||||
$parentId = $params['parent_id'] ?? 0;
|
||||
if ($parentId) {
|
||||
$parent = $this->permissions->findBy($parentId);
|
||||
$params['module'] = $parent->module;
|
||||
}
|
||||
|
||||
return CatchResponse::success($this->permissions->storeBy($params));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月11日
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return Json
|
||||
*/
|
||||
public function update($id, Request $request): Json
|
||||
{
|
||||
$permission = $this->permissions->findBy($id);
|
||||
|
||||
$params = array_merge($request->param(), [
|
||||
'parent_id' => $permission->parent_id,
|
||||
'level' => $permission->level
|
||||
]);
|
||||
|
||||
if ($permission->updateBy($id, $params)) {
|
||||
if ($params['module'] ?? false) {
|
||||
$this->permissions->updateBy($permission->id, [
|
||||
'module' => $params['module'],
|
||||
], 'parent_id');
|
||||
}
|
||||
return CatchResponse::success();
|
||||
}
|
||||
|
||||
throw new FailedException('更新失败');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月11日
|
||||
* @param $id
|
||||
* @throws FailedException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return Json
|
||||
*/
|
||||
public function delete($id): Json
|
||||
{
|
||||
if ($this->permissions->where('parent_id', $id)->find()) {
|
||||
throw new FailedException('存在子菜单,无法删除');
|
||||
}
|
||||
|
||||
$this->permissions->findBy($id)->roles()->detach();
|
||||
|
||||
return CatchResponse::success($this->permissions->deleteBy($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示/隐藏
|
||||
*
|
||||
* @author JaguarJack
|
||||
* @email njphper@gmail.com
|
||||
* @time 2020/5/19
|
||||
* @param $id
|
||||
* @return Json
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$permission = $this->permissions->findBy($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());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2020年06月05日
|
||||
* @param $id
|
||||
* @param ParseClass $parseClass
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return Json
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,182 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\controller;
|
||||
|
||||
use catchAdmin\permissions\model\Permissions;
|
||||
use catcher\base\CatchRequest as Request;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\exceptions\FailedException;
|
||||
use catcher\Tree;
|
||||
use think\response\Json;
|
||||
|
||||
class Role extends CatchController
|
||||
{
|
||||
protected $role;
|
||||
|
||||
public function __construct(\catchAdmin\permissions\model\Roles $role)
|
||||
{
|
||||
$this->role = $role;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月09日
|
||||
* @param Request $request
|
||||
* @return string
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return CatchResponse::success(Tree::done($this->role->getList()));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月11日
|
||||
* @param Request $request
|
||||
* @return Json
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
$this->role->storeBy($request->param());
|
||||
|
||||
$permissions = $request->param('permissions');
|
||||
if (!empty($permissions)) {
|
||||
$this->role->attachPermissions(array_unique($permissions));
|
||||
}
|
||||
if (!empty($request->param('departments'))) {
|
||||
$this->role->attachDepartments($request->param('departments'));
|
||||
}
|
||||
// 添加角色
|
||||
return CatchResponse::success();
|
||||
}
|
||||
|
||||
public function read($id)
|
||||
{
|
||||
$role = $this->role->findBy($id);
|
||||
$role->permissions = $role->getPermissions();
|
||||
$role->departments = $role->getDepartments();
|
||||
return CatchResponse::success($role);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月11日
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return Json
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function update($id, Request $request): Json
|
||||
{
|
||||
$this->role->updateBy($id, $request->param());
|
||||
$role = $this->role->findBy($id);
|
||||
|
||||
$hasPermissionIds = $role->getPermissions()->column('id');
|
||||
|
||||
$permissionIds = $request->param('permissions');
|
||||
|
||||
// 已存在权限 IDS
|
||||
$existedPermissionIds = [];
|
||||
foreach ($hasPermissionIds as $hasPermissionId) {
|
||||
if (in_array($hasPermissionId, $permissionIds)) {
|
||||
$existedPermissionIds[] = $hasPermissionId;
|
||||
}
|
||||
}
|
||||
|
||||
$attachIds = array_diff($permissionIds, $existedPermissionIds);
|
||||
$detachIds = array_diff($hasPermissionIds, $existedPermissionIds);
|
||||
|
||||
if (!empty($detachIds)) {
|
||||
$role->detachPermissions($detachIds);
|
||||
}
|
||||
if (!empty($attachIds)) {
|
||||
$role->attachPermissions(array_unique($attachIds));
|
||||
}
|
||||
|
||||
// 更新department
|
||||
$hasDepartmentIds = $role->getDepartments()->column('id');
|
||||
$departmentIds = $request->param('departments',[]);
|
||||
|
||||
// 已存在部门 IDS
|
||||
$existedDepartmentIds = [];
|
||||
foreach ($hasDepartmentIds as $hasDepartmentId) {
|
||||
if (in_array($hasDepartmentId, $departmentIds)) {
|
||||
$existedDepartmentIds[] = $hasDepartmentId;
|
||||
}
|
||||
}
|
||||
|
||||
$attachDepartmentIds = array_diff($departmentIds, $existedDepartmentIds);
|
||||
$detachDepartmentIds = array_diff($hasDepartmentIds, $existedDepartmentIds);
|
||||
|
||||
if (!empty($detachDepartmentIds)) {
|
||||
$role->detachDepartments($detachDepartmentIds);
|
||||
}
|
||||
if (!empty($attachDepartmentIds)) {
|
||||
$role->attachDepartments(array_unique($attachDepartmentIds));
|
||||
}
|
||||
|
||||
return CatchResponse::success();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月11日
|
||||
* @param $id
|
||||
* @throws FailedException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return Json
|
||||
*/
|
||||
public function delete($id): Json
|
||||
{
|
||||
if ($this->role->where('parent_id', $id)->find()) {
|
||||
throw new FailedException('存在子角色,无法删除');
|
||||
}
|
||||
$role = $this->role->findBy($id);
|
||||
// 删除权限
|
||||
$role->detachPermissions();
|
||||
// 删除部门关联
|
||||
$role->detachDepartments();
|
||||
// 删除用户关联
|
||||
$role->users()->detach();
|
||||
// 删除
|
||||
$this->role->deleteBy($id);
|
||||
|
||||
return CatchResponse::success();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月11日
|
||||
* @param Request $request
|
||||
* @param \catchAdmin\permissions\model\Permissions $permission
|
||||
* @return Json
|
||||
*/
|
||||
public function getPermissions(Request $request, \catchAdmin\permissions\model\Permissions $permission): Json
|
||||
{
|
||||
$parentRoleHasPermissionIds = [];
|
||||
if ($request->param('parent_id')) {
|
||||
$permissions = $this->role->findBy($request->param('parent_id'))->getPermissions();
|
||||
foreach ($permissions as $_permission) {
|
||||
$parentRoleHasPermissionIds[] = $_permission->pivot->permission_id;
|
||||
}
|
||||
}
|
||||
|
||||
$permissions = Tree::done(Permissions::whereIn('id', $parentRoleHasPermissionIds)->select()->toArray());
|
||||
|
||||
$permissionIds = [];
|
||||
if ($request->param('role_id')) {
|
||||
$roleHasPermissions = $this->role->findBy($request->param('role_id'))->getPermissions();
|
||||
foreach ($roleHasPermissions as $_permission) {
|
||||
$permissionIds[] = $_permission->pivot->permission_id;
|
||||
}
|
||||
}
|
||||
|
||||
return CatchResponse::success([
|
||||
'permissions' => $permissions,
|
||||
'hasPermissions' => $permissionIds,
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,228 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\controller;
|
||||
|
||||
use catcher\base\CatchRequest as Request;
|
||||
use catchAdmin\permissions\model\Permissions;
|
||||
use catchAdmin\permissions\model\Roles;
|
||||
use catchAdmin\permissions\model\Users;
|
||||
use catchAdmin\permissions\request\CreateRequest;
|
||||
use catchAdmin\permissions\request\UpdateRequest;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\CatchAuth;
|
||||
use catcher\CatchCacheKeys;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\Tree;
|
||||
use catcher\Utils;
|
||||
use think\facade\Cache;
|
||||
|
||||
class User extends CatchController
|
||||
{
|
||||
protected $user;
|
||||
|
||||
public function __construct(Users $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2020年04月24日
|
||||
* @throws \think\db\exception\DbException
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return CatchResponse::paginate($this->user->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @time 2020年01月07日
|
||||
* @param CatchAuth $auth
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function info(CatchAuth $auth)
|
||||
{
|
||||
$user = $auth->user();
|
||||
|
||||
$roles = $user->getRoles();
|
||||
|
||||
$permissionIds = $user->getPermissionsBy($user->id);
|
||||
// 缓存用户权限
|
||||
Cache::set(CatchCacheKeys::USER_PERMISSIONS . $user->id, $permissionIds);
|
||||
|
||||
$user->permissions = Permissions::getCurrentUserPermissions($permissionIds);
|
||||
|
||||
$user->roles = $roles;
|
||||
|
||||
// 用户数据权限
|
||||
// $user->data_range = Roles::getDepartmentUserIdsBy($roles);
|
||||
|
||||
return CatchResponse::success($user);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月06日
|
||||
* @throws \Exception
|
||||
* @return string
|
||||
*/
|
||||
public function create()
|
||||
{}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param CreateRequest $request
|
||||
* @time 2019年12月06日
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function save(CreateRequest $request)
|
||||
{
|
||||
$this->user->storeBy($request->param());
|
||||
|
||||
$this->user->attachRoles($request->param('roles'));
|
||||
|
||||
$this->user->attachJobs($request->param('jobs'));
|
||||
|
||||
return CatchResponse::success('', '添加成功');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月04日
|
||||
* @param $id
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
$user = $this->user->findBy($id);
|
||||
$user->roles = $user->getRoles();
|
||||
$user->jobs = $user->getJobs();
|
||||
return CatchResponse::success($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function edit($id){}
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月04日
|
||||
* @param $id
|
||||
* @param UpdateRequest $request
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function update($id, UpdateRequest $request)
|
||||
{
|
||||
$this->user->updateBy($id, $request->param());
|
||||
|
||||
$user = $this->user->findBy($id);
|
||||
|
||||
$user->detachRoles();
|
||||
$user->detachJobs();
|
||||
|
||||
if (!empty($request->param('roles'))) {
|
||||
$user->attachRoles($request->param('roles'));
|
||||
}
|
||||
if (!empty($request->param('jobs'))) {
|
||||
$user->attachJobs($request->param('jobs'));
|
||||
}
|
||||
return CatchResponse::success();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月04日
|
||||
* @param $id
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
$ids = Utils::stringToArrayBy($id);
|
||||
|
||||
foreach ($ids as $_id) {
|
||||
$user = $this->user->findBy($_id);
|
||||
// 删除角色
|
||||
$user->detachRoles();
|
||||
// 删除岗位
|
||||
$user->detachJobs();
|
||||
|
||||
$this->user->deleteBy($_id);
|
||||
}
|
||||
|
||||
return CatchResponse::success();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月07日
|
||||
* @param $id
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function switchStatus($id): \think\response\Json
|
||||
{
|
||||
$ids = Utils::stringToArrayBy($id);
|
||||
|
||||
foreach ($ids as $_id) {
|
||||
|
||||
$user = $this->user->findBy($_id);
|
||||
|
||||
$this->user->updateBy($_id, [
|
||||
'status' => $user->status == Users::ENABLE ? Users::DISABLE : Users::ENABLE,
|
||||
]);
|
||||
}
|
||||
|
||||
return CatchResponse::success([], '操作成功');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月07日
|
||||
* @param $id
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
*/
|
||||
public function recover($id): \think\response\Json
|
||||
{
|
||||
$trashedUser = $this->user->findBy($id, ['*'], true);
|
||||
|
||||
if ($this->user->where('email', $trashedUser->email)->find()) {
|
||||
return CatchResponse::fail(sprintf('该恢复用户的邮箱 [%s] 已被占用', $trashedUser->email));
|
||||
}
|
||||
|
||||
return CatchResponse::success($this->user->recover($id));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月11日
|
||||
* @param Request $request
|
||||
* @param Roles $roles
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function getRoles(Request $request, Roles $roles): \think\response\Json
|
||||
{
|
||||
$roles = Tree::done($roles->getList());
|
||||
|
||||
$roleIds = [];
|
||||
if ($request->param('uid')) {
|
||||
$userHasRoles = $this->user->findBy($request->param('uid'))->getRoles();
|
||||
foreach ($userHasRoles as $role) {
|
||||
$roleIds[] = $role->pivot->role_id;
|
||||
}
|
||||
}
|
||||
|
||||
return CatchResponse::success([
|
||||
'roles' => $roles,
|
||||
'hasRoles' => $roleIds,
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class Users 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()
|
||||
{
|
||||
$table = $this->table('users',array('engine'=>'Innodb', 'comment' => '用户表', 'signed' => false));
|
||||
$table->addColumn('username', 'string',array('limit' => 15,'default'=>'','comment'=>'用户名'))
|
||||
->addColumn('password', 'string',array('limit' => 255,'comment'=>'用户密码'))
|
||||
->addColumn('email', 'string',array('limit' => 100, 'comment'=>'邮箱 登录'))
|
||||
->addColumn('creator_id', 'integer',['default' => 0, 'comment'=>'创建人ID'])
|
||||
->addColumn('department_id', 'integer',['default' => 0, 'comment'=>'部门ID'])
|
||||
->addColumn('status', 'boolean',array('limit' => 1,'default'=> 1,'comment'=>'用户状态 1 正常 2 禁用'))
|
||||
->addColumn('last_login_ip', 'string',array('limit' => 50,'default'=>0,'comment'=>'最后登录IP'))
|
||||
->addColumn('last_login_time', 'integer',array('default'=>0,'comment'=>'最后登录时间', 'signed' => false))
|
||||
->addColumn('created_at', 'integer', array('default'=>0,'comment'=>'创建时间', 'signed' => false ))
|
||||
->addColumn('updated_at', 'integer', array('default'=>0,'comment'=>'更新时间', 'signed' => false))
|
||||
->addColumn('deleted_at', 'integer', array('default'=>0,'comment'=>'删除状态,0未删除 >0 已删除', 'signed' => false))
|
||||
->create();
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class Roles 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()
|
||||
{
|
||||
$table = $this->table('roles',['engine'=>'Innodb', 'comment' => '角色表', 'signed' => false]);
|
||||
$table->addColumn('role_name', 'string',['limit' => 15,'default'=>'','comment'=>'角色名'])
|
||||
->addColumn('parent_id', 'integer',['default'=>0,'comment'=>'父级ID', 'signed' => false])
|
||||
->addColumn('description', 'string',['default'=> '','comment'=>'角色备注'])
|
||||
->addColumn('data_range', 'integer',['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY,'default'=> 0,'comment'=>'1 全部数据 2 自定义数据 3 仅本人数据 4 部门数据 5 部门及以下数据'])
|
||||
->addColumn('creator_id', 'integer',['default' => 0, 'comment'=>'创建人ID'])
|
||||
->addColumn('created_at', 'integer', array('default'=>0,'comment'=>'创建时间', 'signed' => false ))
|
||||
->addColumn('updated_at', 'integer', array('default'=>0,'comment'=>'更新时间', 'signed' => false))
|
||||
->addColumn('deleted_at', 'integer', array('default'=>0,'comment'=>'删除状态,0未删除 >0 已删除', 'signed' => false))
|
||||
->create();
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class Permissions 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()
|
||||
{
|
||||
$table = $this->table('permissions',['engine'=>'Innodb', 'comment' => '菜单表', 'signed' => false]);
|
||||
$table->addColumn('permission_name', 'string',['limit' => 15,'default'=>'','comment'=>'菜单名称'])
|
||||
->addColumn('parent_id', 'integer',['default'=>0,'comment'=>'父级ID', 'signed' => false])
|
||||
->addColumn('route', 'string', ['default' => '', 'comment' => '路由', 'limit' => 50])
|
||||
->addColumn('icon', 'string', ['default' => '', 'comment' => '菜单图标', 'limit' => 50])
|
||||
->addColumn('module', 'string', ['default' => '', 'comment' => '模块', 'limit' => 20])
|
||||
->addColumn('creator_id', 'integer',['default' => 0, 'comment'=>'创建人ID'])
|
||||
->addColumn('method', 'string', ['default' => 'get', 'comment' => '路由请求方法', 'limit' => 15])
|
||||
->addColumn('permission_mark', 'string', ['null' => false, 'comment' => '权限标识', 'limit' => 50])
|
||||
->addColumn('type', 'integer',['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY,'default'=> 1,'comment'=>'1 菜单 2 按钮'])
|
||||
->addColumn('sort', 'integer',['default'=> 0,'comment'=>'排序字段'])
|
||||
->addColumn('created_at', 'integer', array('default'=>0,'comment'=>'创建时间', 'signed' => false ))
|
||||
->addColumn('updated_at', 'integer', array('default'=>0,'comment'=>'更新时间', 'signed' => false))
|
||||
->addColumn('deleted_at', 'integer', array('default'=>0,'comment'=>'删除状态,null 未删除 timestamp 已删除', 'signed' => false))
|
||||
->create();
|
||||
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class UserHasRoles 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()
|
||||
{
|
||||
$table = $this->table('user_has_roles',['engine'=>'Innodb', 'comment' => '用户角色表', 'signed' => false]);
|
||||
$table->addColumn('uid', 'integer',['comment'=>'用户ID', 'signed' => false])
|
||||
->addColumn('role_id', 'integer', ['comment'=>'角色ID', 'signed' => false])
|
||||
->create();
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class RoleHasPermissions 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()
|
||||
{
|
||||
$table = $this->table('role_has_permissions',['engine'=>'Innodb', 'comment' => '角色权限表', 'signed' => false]);
|
||||
$table->addColumn('role_id', 'integer',['comment'=>'角色ID', 'signed' => false])
|
||||
->addColumn('permission_id', 'integer', ['comment'=>'权限ID', 'signed' => false])
|
||||
->create();
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class Department 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()
|
||||
{
|
||||
$table = $this->table('departments',['engine'=>'Innodb', 'comment' => '部门表', 'signed' => false]);
|
||||
$table->addColumn('department_name', 'string',['limit' => 15,'default'=>'','comment'=>'部门名称'])
|
||||
->addColumn('parent_id', 'integer',['default'=>0,'comment'=>'父级ID', 'signed' => false])
|
||||
->addColumn('principal', 'string', ['default' => '', 'comment' => '负责人', 'limit' => 20])
|
||||
->addColumn('mobile', 'string', ['default' => '', 'comment' => '联系电话', 'limit' => 20])
|
||||
->addColumn('email', 'string', ['default' => '', 'comment' => '联系又想', 'limit' => 100])
|
||||
->addColumn('creator_id', 'integer',['default' => 0, 'comment'=>'创建人ID'])
|
||||
->addColumn('status', 'integer',['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY,'default'=> 1,'comment'=>'1 正常 2 停用'])
|
||||
->addColumn('sort', 'integer',['default'=> 0,'comment'=>'排序字段'])
|
||||
->addColumn('created_at', 'integer', array('default'=>0,'comment'=>'创建时间', 'signed' => false ))
|
||||
->addColumn('updated_at', 'integer', array('default'=>0,'comment'=>'更新时间', 'signed' => false))
|
||||
->addColumn('deleted_at', 'integer', array('default'=>0,'comment'=>'删除状态,null 未删除 timestamp 已删除', 'signed' => false))
|
||||
->create();
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class Job 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()
|
||||
{
|
||||
$table = $this->table('jobs',['engine'=>'Innodb', 'comment' => '岗位表', 'signed' => false]);
|
||||
$table->addColumn('job_name', 'string',['limit' => 15,'default'=>'','comment'=>'岗位名称'])
|
||||
->addColumn('coding', 'string', ['default' => '', 'comment' => '编码', 'limit' => 50])
|
||||
->addColumn('creator_id', 'integer',['default' => 0, 'comment'=>'创建人ID'])
|
||||
->addColumn('status', 'integer',['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY,'default'=> 1,'comment'=>'1 正常 2 停用'])
|
||||
->addColumn('sort', 'integer',['default'=> 0,'comment'=>'排序字段'])
|
||||
->addColumn('description', 'string', ['default' => '', 'comment' => '描述', 'limit' => 255])
|
||||
->addColumn('created_at', 'integer', array('default'=>0,'comment'=>'创建时间', 'signed' => false ))
|
||||
->addColumn('updated_at', 'integer', array('default'=>0,'comment'=>'更新时间', 'signed' => false))
|
||||
->addColumn('deleted_at', 'integer', array('default'=>0,'comment'=>'删除状态,null 未删除 timestamp 已删除', 'signed' => false))
|
||||
->create();
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class UserRelateJob 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()
|
||||
{
|
||||
$table = $this->table('user_has_jobs',['engine'=>'Innodb', 'comment' => '用户角色表', 'signed' => false]);
|
||||
$table->addColumn('uid', 'integer',['comment'=>'用户ID', 'signed' => false])
|
||||
->addColumn('job_id', 'integer', ['comment'=>'岗位ID', 'signed' => false])
|
||||
->create();
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class RoleHasDepartments 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()
|
||||
{
|
||||
$table = $this->table('role_has_departments',['engine'=>'Innodb', 'comment' => '角色部门表', 'signed' => false]);
|
||||
$table->addColumn('role_id', 'integer',['comment'=>'角色ID', 'signed' => false])
|
||||
->addColumn('department_id', 'integer', ['comment'=>'部门ID', 'signed' => false])
|
||||
->create();
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class ChangePermissions 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->addColumn('component', 'string', ['default' => '', 'comment' => '组件名称', 'limit' => '255', 'after' => 'permission_mark'])
|
||||
->addColumn('redirect', 'string', ['default' => '', 'comment' => '跳转地址', 'limit' => '255', 'after' => 'component'])
|
||||
->addColumn('hide_children_in_menu', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 1, 'comment' => '1 显示 2隐藏', 'after' => 'redirect'])
|
||||
->addColumn('keepalive', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 1, 'comment' => '1 缓存 2 不存在 ', 'after' => 'hide_children_in_menu'])
|
||||
->update();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class PermissionsAddColumn 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->addColumn('level', 'string', ['default' => '', 'comment' => '层级', 'limit' => '50', 'after' => 'parent_id'])
|
||||
->update();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class AddPermissionStatusColumn 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->addColumn('status', 'integer', [
|
||||
'limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY,
|
||||
'default' => 1,
|
||||
'comment' => '1 显示 2 隐藏',
|
||||
'after' => 'type'])
|
||||
->update();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Seeder;
|
||||
|
||||
class DepartmentsSeed 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()
|
||||
{
|
||||
$data = [
|
||||
[
|
||||
'id' => 1,
|
||||
'department_name' => '总部',
|
||||
'parent_id' => 0,
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'department_name' => '北京总部',
|
||||
'parent_id' => 1,
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'department_name' => '南京总部',
|
||||
'parent_id' => 1,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($data as $item) {
|
||||
\catchAdmin\permissions\model\Department::create($item);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,871 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Seeder;
|
||||
|
||||
class PermissionSeed 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' => 1,
|
||||
'permission_name' => '权限管理',
|
||||
'parent_id' => 0,
|
||||
'level' => '',
|
||||
'route' => '/permissions',
|
||||
'icon' => 'appstore',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'permission@index',
|
||||
'component' => 'pageView',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 100,
|
||||
'created_at' => 1587461455,
|
||||
'updated_at' => 1593044101,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 2,
|
||||
'permission_name' => '用户管理',
|
||||
'parent_id' => 1,
|
||||
'level' => '1',
|
||||
'route' => '/permissions/users',
|
||||
'icon' => 'user',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@index',
|
||||
'component' => 'users',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 10,
|
||||
'created_at' => 1587461597,
|
||||
'updated_at' => 1592371975,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 3,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 2,
|
||||
'level' => '1-2',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461647,
|
||||
'updated_at' => 1591316160,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 4,
|
||||
'permission_name' => '创建',
|
||||
'parent_id' => 2,
|
||||
'level' => '1-2',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@create',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461696,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'id' => 5,
|
||||
'permission_name' => '保存',
|
||||
'parent_id' => 2,
|
||||
'level' => '1-2',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461721,
|
||||
'updated_at' => 1591345475,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'id' => 6,
|
||||
'permission_name' => '查看',
|
||||
'parent_id' => 2,
|
||||
'level' => '1-2',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@edit',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461742,
|
||||
'updated_at' => 1591345504,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
4 =>
|
||||
array (
|
||||
'id' => 7,
|
||||
'permission_name' => '更新',
|
||||
'parent_id' => 2,
|
||||
'level' => '1-2',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@update',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461762,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
5 =>
|
||||
array (
|
||||
'id' => 8,
|
||||
'permission_name' => '删除',
|
||||
'parent_id' => 2,
|
||||
'level' => '1-2',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461841,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
6 =>
|
||||
array (
|
||||
'id' => 9,
|
||||
'permission_name' => '禁用',
|
||||
'parent_id' => 2,
|
||||
'level' => '1-2',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@switchStatus',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461876,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
7 =>
|
||||
array (
|
||||
'id' => 10,
|
||||
'permission_name' => '恢复',
|
||||
'parent_id' => 2,
|
||||
'level' => '1-2',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'user@recover',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461901,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 11,
|
||||
'permission_name' => '角色管理',
|
||||
'parent_id' => 1,
|
||||
'level' => '1',
|
||||
'route' => '/permissions/roles',
|
||||
'icon' => 'usergroup-add',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'role@index',
|
||||
'component' => 'roles',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 9,
|
||||
'created_at' => 1587461939,
|
||||
'updated_at' => 1592371974,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 12,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 11,
|
||||
'level' => '1-11',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'role@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587461984,
|
||||
'updated_at' => 1591341461,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 13,
|
||||
'permission_name' => '创建',
|
||||
'parent_id' => 11,
|
||||
'level' => '1-11',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'role@create',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462007,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'id' => 14,
|
||||
'permission_name' => '保存',
|
||||
'parent_id' => 11,
|
||||
'level' => '1-11',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'role@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462021,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'id' => 15,
|
||||
'permission_name' => '查看',
|
||||
'parent_id' => 11,
|
||||
'level' => '1-11',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'role@edit',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462040,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
4 =>
|
||||
array (
|
||||
'id' => 16,
|
||||
'permission_name' => '更新',
|
||||
'parent_id' => 11,
|
||||
'level' => '1-11',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'role@update',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462058,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
5 =>
|
||||
array (
|
||||
'id' => 17,
|
||||
'permission_name' => '删除',
|
||||
'parent_id' => 11,
|
||||
'level' => '1-11',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'role@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462070,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
6 =>
|
||||
array (
|
||||
'id' => 18,
|
||||
'permission_name' => '权限获取',
|
||||
'parent_id' => 11,
|
||||
'level' => '1-11',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'role@getPermissions',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462094,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'id' => 19,
|
||||
'permission_name' => '菜单管理',
|
||||
'parent_id' => 1,
|
||||
'level' => '1',
|
||||
'route' => '/permissions/rules',
|
||||
'icon' => 'build',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'permission@index',
|
||||
'component' => 'rules',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 8,
|
||||
'created_at' => 1587462147,
|
||||
'updated_at' => 1592371979,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 20,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 19,
|
||||
'level' => '1-19',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'permission@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462205,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 21,
|
||||
'permission_name' => '创建',
|
||||
'parent_id' => 19,
|
||||
'level' => '1-19',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'permission@create',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462232,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'id' => 22,
|
||||
'permission_name' => '保存',
|
||||
'parent_id' => 19,
|
||||
'level' => '1-19',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'permission@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462250,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'id' => 23,
|
||||
'permission_name' => '查看',
|
||||
'parent_id' => 19,
|
||||
'level' => '1-19',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'permission@edit',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462273,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
4 =>
|
||||
array (
|
||||
'id' => 24,
|
||||
'permission_name' => '更新',
|
||||
'parent_id' => 19,
|
||||
'level' => '1-19',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'permission@update',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462284,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
5 =>
|
||||
array (
|
||||
'id' => 25,
|
||||
'permission_name' => '删除',
|
||||
'parent_id' => 19,
|
||||
'level' => '1-19',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'permission@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462296,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'id' => 26,
|
||||
'permission_name' => '部门管理',
|
||||
'parent_id' => 1,
|
||||
'level' => '1',
|
||||
'route' => '/permissions/departments',
|
||||
'icon' => 'desktop',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'departments',
|
||||
'component' => 'departments',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 7,
|
||||
'created_at' => 1587462488,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 27,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 26,
|
||||
'level' => '1-26',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'department@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462529,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 28,
|
||||
'permission_name' => '保存',
|
||||
'parent_id' => 26,
|
||||
'level' => '1-26',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'department@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462548,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'id' => 29,
|
||||
'permission_name' => '更新',
|
||||
'parent_id' => 26,
|
||||
'level' => '1-26',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'department@update',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462579,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'id' => 30,
|
||||
'permission_name' => '删除',
|
||||
'parent_id' => 26,
|
||||
'level' => '1-26',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'department@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462592,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
4 =>
|
||||
array (
|
||||
'id' => 31,
|
||||
'permission_name' => '岗位管理',
|
||||
'parent_id' => 1,
|
||||
'level' => '1',
|
||||
'route' => '/permissions/jobs',
|
||||
'icon' => 'skin',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'job',
|
||||
'component' => 'jobs',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462707,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 32,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 31,
|
||||
'level' => '1-31',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'job@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462757,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 33,
|
||||
'permission_name' => '保存',
|
||||
'parent_id' => 31,
|
||||
'level' => '1-31',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'job@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462774,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'id' => 34,
|
||||
'permission_name' => '更新',
|
||||
'parent_id' => 31,
|
||||
'level' => '1-31',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'job@update',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462785,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'id' => 35,
|
||||
'permission_name' => '删除',
|
||||
'parent_id' => 31,
|
||||
'level' => '1-31',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'job@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462794,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
4 =>
|
||||
array (
|
||||
'id' => 36,
|
||||
'permission_name' => '获取全部',
|
||||
'parent_id' => 31,
|
||||
'level' => '1-31',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'permissions',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'job@getAll',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462818,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?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 ]
|
||||
// +----------------------------------------------------------------------
|
||||
use think\migration\Seeder;
|
||||
|
||||
class RolesSeed 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()
|
||||
{
|
||||
\catchAdmin\permissions\model\Roles::create([
|
||||
'role_name' => '超级管理员',
|
||||
'description' => 'super user',
|
||||
'creator_id' => 1,
|
||||
]);
|
||||
|
||||
\think\facade\Db::name( 'user_has_roles')->insert([
|
||||
'role_id' => 1,
|
||||
'uid' => 1,
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Seeder;
|
||||
|
||||
class UsersSeed 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()
|
||||
{
|
||||
return \catchAdmin\permissions\model\Users::create([
|
||||
'username' => 'admin',
|
||||
'password' => 'admin',
|
||||
'email' => 'admin@gmail.com',
|
||||
'creator_id' => 1,
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace catchAdmin\permissions\event;
|
||||
|
||||
use catchAdmin\permissions\model\Permissions;
|
||||
use catchAdmin\system\model\OperateLog;
|
||||
use catcher\CatchAdmin;
|
||||
use think\facade\Db;
|
||||
|
||||
class OperateLogEvent
|
||||
{
|
||||
public function handle($params)
|
||||
{
|
||||
$permission = $params['permission'];
|
||||
|
||||
$parentPermission = Permissions::where('id', $permission->parent_id)->value('permission_name');
|
||||
|
||||
$requestParams = request()->param();
|
||||
|
||||
// 如果参数过长则不记录
|
||||
if (!empty($requestParams)) {
|
||||
if (strlen(\json_encode($requestParams)) > 1000) {
|
||||
$requestParams = [];
|
||||
}
|
||||
}
|
||||
|
||||
app(OperateLog::class)->storeBy([
|
||||
'creator_id' => $params['creator_id'],
|
||||
'module' => $parentPermission ? : '',
|
||||
'method' => request()->method(),
|
||||
'operate' => $permission->permission_name,
|
||||
'route' => $permission->permission_mark,
|
||||
'params' => !empty($requestParams) ? json_encode($requestParams, JSON_UNESCAPED_UNICODE) : '',
|
||||
'created_at' => time(),
|
||||
'ip' => request()->ip(),
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\middleware;
|
||||
|
||||
use catcher\Code;
|
||||
use catcher\exceptions\FailedException;
|
||||
use thans\jwt\exception\TokenBlacklistException;
|
||||
use thans\jwt\exception\TokenExpiredException;
|
||||
use thans\jwt\exception\TokenInvalidException;
|
||||
use thans\jwt\facade\JWTAuth;
|
||||
use think\Middleware;
|
||||
|
||||
class AuthTokenMiddleware extends Middleware
|
||||
{
|
||||
public function handle($request, \Closure $next)
|
||||
{
|
||||
try {
|
||||
JWTAuth::auth();
|
||||
} catch (\Exception $e) {
|
||||
if ($e instanceof TokenExpiredException) {
|
||||
throw new FailedException('token 过期', Code::LOGIN_EXPIRED);
|
||||
}
|
||||
if ($e instanceof TokenBlacklistException) {
|
||||
throw new FailedException('token 被加入黑名单', Code::LOGIN_BLACKLIST);
|
||||
}
|
||||
if ($e instanceof TokenInvalidException) {
|
||||
throw new FailedException('token 不合法', Code::LOST_LOGIN);
|
||||
}
|
||||
|
||||
throw new FailedException('登录用户不合法', Code::LOST_LOGIN);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\middleware;
|
||||
|
||||
use app\Request;
|
||||
use catchAdmin\permissions\model\Permissions;
|
||||
use catcher\CatchCacheKeys;
|
||||
use catcher\Code;
|
||||
use catcher\exceptions\PermissionForbiddenException;
|
||||
use think\facade\Cache;
|
||||
use catcher\Utils;
|
||||
|
||||
class PermissionsMiddleware
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月12日
|
||||
* @param Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws PermissionForbiddenException
|
||||
*/
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$rule = $request->rule()->getName();
|
||||
|
||||
if (!$rule) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
// 模块忽略
|
||||
[$module, $controller, $action] = Utils::parseRule($rule);
|
||||
// toad
|
||||
if (in_array($module, $this->ignoreModule())) {
|
||||
return $next($request);
|
||||
}
|
||||
// 用户未登录
|
||||
$user = $request->user();
|
||||
if (!$user) {
|
||||
throw new PermissionForbiddenException('Login is invalid', Code::LOST_LOGIN);
|
||||
}
|
||||
// 超级管理员
|
||||
if ($request->user()->id === config('catch.permissions.super_admin_id')) {
|
||||
return $next($request);
|
||||
}
|
||||
// Get 请求
|
||||
if ($request->isGet() && config('catch.permissions.is_allow_get')) {
|
||||
return $next($request);
|
||||
}
|
||||
// 判断权限
|
||||
$permission = property_exists($request, 'permission') ? $request->permission :
|
||||
$this->getPermission($module, $controller, $action);
|
||||
|
||||
if (!$permission || !in_array($permission->id, Cache::get(CatchCacheKeys::USER_PERMISSIONS . $user->id))) {
|
||||
throw new PermissionForbiddenException();
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月14日
|
||||
* @param $module
|
||||
* @param $controllerName
|
||||
* @param $action
|
||||
* @param $request
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return array|bool|\think\Model|null
|
||||
*/
|
||||
protected function getPermission($module, $controllerName, $action)
|
||||
{
|
||||
$permissionMark = sprintf('%s@%s', $controllerName, $action);
|
||||
|
||||
return Permissions::where('module', $module)->where('permission_mark', $permissionMark)->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 忽略模块
|
||||
*
|
||||
* @time 2020年04月16日
|
||||
* @return array
|
||||
*/
|
||||
protected function ignoreModule()
|
||||
{
|
||||
return ['login'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作日志
|
||||
*
|
||||
* @time 2020年04月16日
|
||||
* @param $creatorId
|
||||
* @param $permission
|
||||
* @return void
|
||||
*/
|
||||
protected function operateEvent($creatorId, $permission)
|
||||
{
|
||||
// 操作日志
|
||||
$permission && event('operateLog', [
|
||||
'creator_id' => $creatorId,
|
||||
'permission' => $permission,
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\middleware;
|
||||
|
||||
use app\Request;
|
||||
use catchAdmin\permissions\model\Permissions;
|
||||
use catcher\CatchCacheKeys;
|
||||
use catcher\Code;
|
||||
use catcher\exceptions\PermissionForbiddenException;
|
||||
use think\facade\Cache;
|
||||
use catcher\Utils;
|
||||
|
||||
class RecordOperateMiddleware
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月12日
|
||||
* @param Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws PermissionForbiddenException
|
||||
*/
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$rule = $request->rule()->getName();
|
||||
|
||||
// 模块忽略
|
||||
[$module, $controller, $action] = Utils::parseRule($rule);
|
||||
|
||||
$permission = $this->getPermission($module, $controller, $action);
|
||||
|
||||
$this->operateEvent($request->user()->id, $permission);
|
||||
|
||||
// 将权限带入
|
||||
$request->permission = $permission;
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月14日
|
||||
* @param $module
|
||||
* @param $controllerName
|
||||
* @param $action
|
||||
* @param $request
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return array|bool|\think\Model|null
|
||||
*/
|
||||
protected function getPermission($module, $controllerName, $action)
|
||||
{
|
||||
$permissionMark = sprintf('%s@%s', $controllerName, $action);
|
||||
|
||||
return Permissions::where('module', $module)->where('permission_mark', $permissionMark)->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作日志
|
||||
*
|
||||
* @time 2020年04月16日
|
||||
* @param $creatorId
|
||||
* @param $permission
|
||||
* @return void
|
||||
*/
|
||||
protected function operateEvent($creatorId, $permission)
|
||||
{
|
||||
// 操作日志
|
||||
$permission && event('operateLog', [
|
||||
'creator_id' => $creatorId,
|
||||
'permission' => $permission,
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
use catcher\Utils;
|
||||
|
||||
trait DataRangScopeTrait
|
||||
{
|
||||
/**
|
||||
* 数据范围查询
|
||||
*
|
||||
* @param $roles
|
||||
* @return mixed
|
||||
* @author JaguarJack <njphper@gmail.com>
|
||||
* @date 2020/6/6
|
||||
*/
|
||||
protected function dataRange($roles)
|
||||
{
|
||||
if (Utils::isSuperAdmin()) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$userIds = $this->getDepartmentUserIdsBy($roles);
|
||||
|
||||
if (empty($userIds)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this->whereIn($this->aliasField('creator_id'), $userIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门IDs
|
||||
*
|
||||
* @param $roles
|
||||
* @return array
|
||||
* @author JaguarJack <njphper@gmail.com>
|
||||
* @date 2020/6/6
|
||||
*/
|
||||
public function getDepartmentUserIdsBy($roles)
|
||||
{
|
||||
$userIds = [];
|
||||
|
||||
$isAll = false;
|
||||
|
||||
$user = request()->user();
|
||||
|
||||
foreach ($roles as $role) {
|
||||
switch ($role->data_range) {
|
||||
case Roles::ALL_DATA:
|
||||
$isAll = true;
|
||||
break;
|
||||
case Roles::SELF_CHOOSE:
|
||||
$departmentIds = array_merge(array_column($role->getDepartments()->toArray(), 'id'));
|
||||
$userIds = array_merge($userIds, $this->getUserIdsByDepartmentId($departmentIds));
|
||||
break;
|
||||
case Roles::SELF_DATA:
|
||||
$userIds[] = $user->id;
|
||||
break;
|
||||
case Roles::DEPARTMENT_DOWN_DATA:
|
||||
case Roles::DEPARTMENT_DATA:
|
||||
$userIds = array_merge($userIds, $this->getUserIdsByDepartmentId([$user->department_id]));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// 如果有全部数据 直接跳出
|
||||
if ($isAll) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $userIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取UserID
|
||||
*
|
||||
* @time 2020年07月04日
|
||||
* @param $id
|
||||
* @return array
|
||||
*/
|
||||
protected function getUserIdsByDepartmentId(array $id)
|
||||
{
|
||||
return Users::whereIn('department_id', $id)->column('id');
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
use catchAdmin\permissions\model\search\DepartmentSearch;
|
||||
use catcher\base\CatchModel;
|
||||
|
||||
class Department extends CatchModel
|
||||
{
|
||||
use DepartmentSearch;
|
||||
|
||||
protected $name = 'departments';
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'department_name', // 部门名称
|
||||
'parent_id', // 父级ID
|
||||
'principal', // 负责人
|
||||
'mobile', // 联系电话
|
||||
'email', // 联系又想
|
||||
'creator_id', // 创建人ID
|
||||
'status', // 1 正常 2 停用
|
||||
'sort', // 排序字段
|
||||
'created_at', // 创建时间
|
||||
'updated_at', // 更新时间
|
||||
'deleted_at', // 删除状态,null 未删除 timestamp 已删除
|
||||
];
|
||||
|
||||
/**
|
||||
* 列表数据
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param $params
|
||||
* @return array
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function getList(): array
|
||||
{
|
||||
return $this->withoutField(['department_name'])
|
||||
->addFields(['department_name as title'])
|
||||
->catchSearch()
|
||||
->catchOrder()
|
||||
->select()->toArray();
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
trait HasDepartmentsTrait
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @return mixed
|
||||
*/
|
||||
public function departments()
|
||||
{
|
||||
return $this->belongsToMany(Department::class, 'role_has_departments', 'department_id', 'role_id');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDepartments()
|
||||
{
|
||||
return $this->departments()->select();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $departments
|
||||
* @return mixed
|
||||
*/
|
||||
public function attachDepartments(array $departments)
|
||||
{
|
||||
if (empty($departments)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
sort($departments);
|
||||
|
||||
return $this->departments()->attach($departments);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $departments
|
||||
* @return mixed
|
||||
*/
|
||||
public function detachDepartments(array $departments = [])
|
||||
{
|
||||
if (empty($departments)) {
|
||||
return $this->departments()->detach();
|
||||
}
|
||||
|
||||
return $this->departments()->detach($departments);
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
trait HasJobsTrait
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @return mixed
|
||||
*/
|
||||
public function jobs()
|
||||
{
|
||||
return $this->belongsToMany(Job::class, 'user_has_jobs', 'job_id', 'uid');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $fields
|
||||
* @return mixed
|
||||
*/
|
||||
public function getJobs()
|
||||
{
|
||||
return $this->jobs()->select();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $jobs
|
||||
* @return mixed
|
||||
*/
|
||||
public function attachJobs(array $jobs)
|
||||
{
|
||||
if (empty($jobs)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
sort($jobs);
|
||||
|
||||
return $this->jobs()->attach($jobs);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $jobs
|
||||
* @return mixed
|
||||
*/
|
||||
public function detachJobs(array $jobs = [])
|
||||
{
|
||||
if (empty($jobs)) {
|
||||
return $this->jobs()->detach();
|
||||
}
|
||||
|
||||
return $this->jobs()->detach($jobs);
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @filename HasPermissionsTrait.php
|
||||
* @createdAt 2020/1/14
|
||||
* @project https://github.com/yanwenwu/catch-admin
|
||||
* @document http://doc.catchadmin.com
|
||||
* @author JaguarJack <njphper@gmail.com>
|
||||
* @copyright By CatchAdmin
|
||||
* @license https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt
|
||||
*/
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
trait HasPermissionsTrait
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月09日
|
||||
* @return \think\model\relation\BelongsToMany
|
||||
*/
|
||||
public function permissions(): \think\model\relation\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Permissions::class, 'role_has_permissions', 'permission_id', 'role_id');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $condition
|
||||
* @param array $field
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPermissions($condition = [], $field = [])
|
||||
{
|
||||
return $this->permissions()
|
||||
->when(!empty($field), function ($query) use ($field){
|
||||
$query->field($field);
|
||||
})
|
||||
->when(!empty($condition), function ($query) use ($condition){
|
||||
$query->where($condition);
|
||||
})
|
||||
->select();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $permissions
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function attachPermissions(array $permissions)
|
||||
{
|
||||
if (empty($permissions)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
sort($permissions);
|
||||
|
||||
return $this->permissions()->attach($permissions);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $permissions
|
||||
* @return mixed
|
||||
*/
|
||||
public function detachPermissions(array $permissions = [])
|
||||
{
|
||||
if (empty($permissions)) {
|
||||
return $this->permissions()->detach();
|
||||
}
|
||||
|
||||
return $this->permissions()->detach($permissions);
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
trait HasRolesTrait
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @return mixed
|
||||
*/
|
||||
public function roles()
|
||||
{
|
||||
return $this->belongsToMany(Roles::class, 'user_has_roles', 'role_id', 'uid');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $fields
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRoles()
|
||||
{
|
||||
return $this->roles()->select();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $roles
|
||||
* @return mixed
|
||||
*/
|
||||
public function attachRoles(array $roles)
|
||||
{
|
||||
if (empty($roles)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
sort($roles);
|
||||
|
||||
return $this->roles()->attach($roles);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $roles
|
||||
* @return mixed
|
||||
*/
|
||||
public function detachRoles(array $roles = [])
|
||||
{
|
||||
if (empty($roles)) {
|
||||
return $this->roles()->detach();
|
||||
}
|
||||
|
||||
return $this->roles()->detach($roles);
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
use catchAdmin\permissions\model\search\JobsSearch;
|
||||
use catcher\base\CatchModel;
|
||||
|
||||
class Job extends CatchModel
|
||||
{
|
||||
use JobsSearch;
|
||||
|
||||
protected $name = 'jobs';
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'job_name', // 岗位名称
|
||||
'coding', // 编码
|
||||
'creator_id', // 创建人ID
|
||||
'status', // 1 正常 2 停用
|
||||
'sort', // 排序字段
|
||||
'description', // 描述
|
||||
'created_at', // 创建时间
|
||||
'updated_at', // 更新时间
|
||||
'deleted_at', // 删除状态,null 未删除 timestamp 已删除
|
||||
];
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param $params
|
||||
* @throws \think\db\exception\DbException
|
||||
* @return \think\Paginator
|
||||
*/
|
||||
public function getList()
|
||||
{
|
||||
return $this->catchSearch()
|
||||
->paginate();
|
||||
}
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
use catchAdmin\permissions\model\search\PermissionsSearch;
|
||||
use catcher\base\CatchModel;
|
||||
use think\Model;
|
||||
|
||||
class Permissions extends CatchModel
|
||||
{
|
||||
use PermissionsSearch;
|
||||
|
||||
protected $name = 'permissions';
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'permission_name', // 菜单名称
|
||||
'parent_id', // 父级ID
|
||||
'icon',
|
||||
'component', // 组件
|
||||
'redirect',
|
||||
'keepalive',
|
||||
'hide_children_in_menu',
|
||||
'creator_id',
|
||||
'status',
|
||||
'module', // 模块
|
||||
'route', // 路由
|
||||
'method', // 请求方法
|
||||
'permission_mark', // 权限标识
|
||||
'type', // 1 菜单 2 按钮
|
||||
'sort', // 排序字段
|
||||
'created_at', // 创建时间
|
||||
'updated_at', // 更新时间
|
||||
'deleted_at', // 删除状态,null 未删除 timestamp 已删除
|
||||
];
|
||||
|
||||
public const MENU_TYPE = 1;
|
||||
public const BTN_TYPE = 2;
|
||||
|
||||
public const GET = 'get';
|
||||
public const POST = 'post';
|
||||
public const PUT = 'put';
|
||||
public const DELETE = 'delete';
|
||||
|
||||
public function getList($isMenu = false)
|
||||
{
|
||||
return $this->catchSearch()
|
||||
->catchOrder()
|
||||
->when($isMenu, function ($query){
|
||||
$query->where('type', self::MENU_TYPE);
|
||||
})
|
||||
->select();
|
||||
}
|
||||
|
||||
public function roles(): \think\model\relation\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Roles::class, 'role_has_permissions', 'role_id', 'permission_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户权限
|
||||
*
|
||||
* @time 2020年01月14日
|
||||
* @param array $permissionIds
|
||||
* @return \think\Collection
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
*/
|
||||
public static function getCurrentUserPermissions(array $permissionIds): \think\Collection
|
||||
{
|
||||
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'
|
||||
])
|
||||
->catchOrder()
|
||||
->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入后回调 更新 level
|
||||
*
|
||||
* @time 2020年04月22日
|
||||
* @param Model $model
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return array|bool|Model|void|null
|
||||
*/
|
||||
public static function onAfterInsert(Model $model)
|
||||
{
|
||||
$model = self::where('id', $model->id)->find();
|
||||
|
||||
if ($model && $model->parent_id) {
|
||||
$parent = self::where('id', $model->parent_id)->find();
|
||||
$level = $parent->level ? $parent->level . '-' . $parent->id : $parent->id;
|
||||
return $model->where('id', $model->id)->update([
|
||||
'level' => $level
|
||||
]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
use catchAdmin\permissions\model\search\RolesSearch;
|
||||
use catcher\base\CatchModel;
|
||||
|
||||
class Roles extends CatchModel
|
||||
{
|
||||
use HasDepartmentsTrait;
|
||||
use HasPermissionsTrait;
|
||||
use RolesSearch;
|
||||
|
||||
protected $name = 'roles';
|
||||
|
||||
public const ALL_DATA = 1; // 全部数据
|
||||
public const SELF_CHOOSE = 2; // 自定义数据
|
||||
public const SELF_DATA = 3; // 本人数据
|
||||
public const DEPARTMENT_DATA = 4; // 部门数据
|
||||
public const DEPARTMENT_DOWN_DATA = 5; // 部门及以下数据
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'role_name', // 角色名
|
||||
'parent_id', // 父级ID
|
||||
'creator_id', // 创建者
|
||||
'data_range', // 数据范围
|
||||
'description', // 角色备注
|
||||
'created_at', // 创建时间
|
||||
'updated_at', // 更新时间
|
||||
'deleted_at', // 删除状态,0未删除 >0 已删除
|
||||
|
||||
];
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return $this->catchSearch()
|
||||
->order('id', 'desc')
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @return \think\model\relation\BelongsToMany
|
||||
*/
|
||||
public function users(): \think\model\relation\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Users::class, 'user_has_roles', 'uid', 'role_id');
|
||||
}
|
||||
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
use catchAdmin\permissions\model\search\UserSearch;
|
||||
use catcher\base\CatchModel;
|
||||
use catcher\exceptions\FailedException;
|
||||
use catcher\Utils;
|
||||
|
||||
class Users extends CatchModel
|
||||
{
|
||||
use HasRolesTrait;
|
||||
use HasJobsTrait;
|
||||
use UserSearch;
|
||||
|
||||
protected $name = 'users';
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'username', // 用户名
|
||||
'password', // 用户密码
|
||||
'email', // 邮箱 登录
|
||||
'creator_id', // 创建者ID
|
||||
'department_id', // 部门ID
|
||||
'status', // 用户状态 1 正常 2 禁用
|
||||
'last_login_ip', // 最后登录IP
|
||||
'last_login_time', // 最后登录时间
|
||||
'created_at', // 创建时间
|
||||
'updated_at', // 更新时间
|
||||
'deleted_at', // 删除状态,0未删除 >0 已删除
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* set password
|
||||
*
|
||||
* @time 2019年12月07日
|
||||
* @param $value
|
||||
* @return false|string
|
||||
*/
|
||||
public function setPasswordAttr($value)
|
||||
{
|
||||
return password_hash($value, PASSWORD_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @throws \think\db\exception\DbException
|
||||
* @return \think\Paginator
|
||||
*/
|
||||
public function getList(): \think\Paginator
|
||||
{
|
||||
return $this->withoutField(['updated_at'], true)
|
||||
->catchSearch()
|
||||
->catchLeftJoin(Department::class, 'id', 'department_id', ['department_name'])
|
||||
->order($this->aliasField('id'), 'desc')
|
||||
->paginate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限
|
||||
*
|
||||
* @time 2019年12月12日
|
||||
* @param $uid
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return array
|
||||
*/
|
||||
public function getPermissionsBy($uid = 0): array
|
||||
{
|
||||
// 获取超级管理配置 超级管理员全部权限
|
||||
if ($uid == config('catch.permissions.super_admin_id')) {
|
||||
return Permissions::select()->column('id');
|
||||
}
|
||||
|
||||
$roles = $uid ? $this->findBy($uid)->getRoles() : $this->getRoles();
|
||||
|
||||
$permissionIds = [];
|
||||
foreach ($roles as $role) {
|
||||
$permissionIds = array_merge($permissionIds, $role->getPermissions()->column('id'));
|
||||
}
|
||||
|
||||
return array_unique($permissionIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台根据权限标识判断用户是否拥有某个权限
|
||||
* @param string $permission_mark
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*
|
||||
* 用法 request()->user()->can('permission@create');
|
||||
*/
|
||||
public function can($permission_mark)
|
||||
{
|
||||
// 超级管理员直接返回true
|
||||
if (Utils::isSuperAdmin()){
|
||||
return true;
|
||||
}
|
||||
// 查询当前用户的权限
|
||||
return in_array(
|
||||
Permissions::where('permission_mark',$permission_mark)->value('id') ? : 0,
|
||||
$this->getPermissionsBy()
|
||||
);
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model\search;
|
||||
|
||||
trait DepartmentSearch
|
||||
{
|
||||
public function searchDepartmentNameAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('department_name', $value);
|
||||
}
|
||||
|
||||
public function searchStatusAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where('status', $value);
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model\search;
|
||||
|
||||
trait JobsSearch
|
||||
{
|
||||
public function searchJobNameAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('job_name', $value);
|
||||
}
|
||||
|
||||
public function searchCodingAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('coding', $value);
|
||||
}
|
||||
|
||||
public function searchStatusAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where('status', $value);
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model\search;
|
||||
|
||||
use catchAdmin\permissions\model\Roles;
|
||||
|
||||
trait PermissionsSearch
|
||||
{
|
||||
public function searchPermissionNameAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('permission_name', $value);
|
||||
}
|
||||
|
||||
public function searchIdAttr($query, $value, $data)
|
||||
{
|
||||
$query->where('parent_id', $value)->whereOr('id', $value);
|
||||
}
|
||||
|
||||
public function searchRoleIdAttr($query, $value, $data)
|
||||
{
|
||||
$permissionIds = [];
|
||||
$permissions = Roles::where('id', $value)->find()->getPermissions();
|
||||
|
||||
foreach ($permissions as $_permission) {
|
||||
$permissionIds[] = $_permission->pivot->permission_id;
|
||||
}
|
||||
|
||||
if(!empty($permissionIds)) {
|
||||
$query->whereIn('id', $permissionIds);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model\search;
|
||||
|
||||
trait RolesSearch
|
||||
{
|
||||
public function searchRoleNameAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('role_name', $value);
|
||||
}
|
||||
|
||||
public function searchIdAttr($query, $value, $data)
|
||||
{
|
||||
$query->where('parent_id', $value)->whereOr('id', $value);
|
||||
}
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model\search;
|
||||
|
||||
trait UserSearch
|
||||
{
|
||||
public function searchUsernameAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('username', $value);
|
||||
}
|
||||
|
||||
public function searchEmailAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('email', $value);
|
||||
}
|
||||
|
||||
public function searchStatusAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where($this->aliasField('status'), $value);
|
||||
}
|
||||
|
||||
public function searchDepartmentIdAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where($this->aliasField('department_id'), $value);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user