Compare commits
3 Commits
v2.0
...
layui_vers
Author | SHA1 | Date | |
---|---|---|---|
![]() |
fd35d91f1c | ||
![]() |
f6e3ee1225 | ||
![]() |
7b782e916a |
@@ -1,24 +0,0 @@
|
||||
# 环境
|
||||
- 操作系统:
|
||||
- php 版本:
|
||||
- thinkphp 版本:
|
||||
- Mysql 版本:
|
||||
- web 服务器:
|
||||
|
||||
# 问题
|
||||
- 问题描述:
|
||||
- 问题截图:
|
||||
|
||||
# 结果
|
||||
- 实际结果:
|
||||
- 预期结果:
|
||||
|
||||
# 分析
|
||||
- 所做的尝试:
|
||||
-
|
||||
-
|
||||
|
||||
# 方案:
|
||||
- 解决方案:
|
||||
|
||||
> 请在问题解决后关闭 issue
|
25
.github/issue_template.md
vendored
25
.github/issue_template.md
vendored
@@ -1,25 +0,0 @@
|
||||
# 环境
|
||||
- 操作系统:
|
||||
- php 版本:
|
||||
- thinkphp 版本:
|
||||
- Mysql 版本:
|
||||
- web 服务器:
|
||||
|
||||
# 问题
|
||||
- 问题描述:
|
||||
|
||||
- 问题截图:
|
||||
|
||||
# 结果
|
||||
- 实际结果:
|
||||
- 预期结果:
|
||||
|
||||
# 分析
|
||||
- 所做的尝试:
|
||||
-
|
||||
-
|
||||
|
||||
# 方案:
|
||||
- 解决方案:
|
||||
|
||||
> 请在问题解决后关闭 issue
|
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,8 +1,6 @@
|
||||
/.idea
|
||||
/.vscode
|
||||
/vendor
|
||||
/package
|
||||
/database
|
||||
*.log
|
||||
.env
|
||||
composer.lock
|
||||
|
||||
.env
|
227
LICENSE.txt
227
LICENSE.txt
@@ -1,201 +1,32 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
|
||||
版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn)
|
||||
All rights reserved。
|
||||
ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
|
||||
|
||||
1. Definitions.
|
||||
Apache Licence是著名的非盈利开源组织Apache采用的协议。
|
||||
该协议和BSD类似,鼓励代码共享和尊重原作者的著作权,
|
||||
允许代码修改,再作为开源或商业软件发布。需要满足
|
||||
的条件:
|
||||
1. 需要给代码的用户一份Apache Licence ;
|
||||
2. 如果你修改了代码,需要在被修改的文件中说明;
|
||||
3. 在延伸的代码中(修改和有源代码衍生的代码中)需要
|
||||
带有原来代码中的协议,商标,专利声明和其他原来作者规
|
||||
定需要包含的说明;
|
||||
4. 如果再发布的产品中包含一个Notice文件,则在Notice文
|
||||
件中需要带有本协议内容。你可以在Notice中增加自己的
|
||||
许可,但不可以表现为对Apache Licence构成更改。
|
||||
具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
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
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
138
README.md
138
README.md
@@ -1,119 +1,47 @@
|
||||
<p align="center">
|
||||
<img src="https://cdn.learnku.com/uploads/images/202005/17/18206/zSuf7Ce5kM.png!large">
|
||||
</p>
|
||||
## CatchAdmin
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
<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 >
|
||||
|
||||
## 项目地址
|
||||
- [github 地址](https://github.com/yanwenwu/catch-admin)
|
||||
- [gitee 地址](https://gitee.com/jaguarjack/catchAdmin)
|
||||
- [前端 Vue 项目地址](https://github.com/yanwenwu/catch-admin-vue)
|
||||
- [文档地址](https://github.com/catch-admin/document)[个人精力实在有限,希望可以小伙伴们可以一起维护文档]
|
||||
## 预览
|
||||
<p align="center">
|
||||
<img src="https://cdn.learnku.com/uploads/images/202005/17/18206/0ECPy72zUZ.png!large">
|
||||
</p>
|
||||
<p align="center">
|
||||
<img src="https://cdn.learnku.com/uploads/images/202005/17/18206/ngzSU0A9SI.png!large">
|
||||
</p>
|
||||
|
||||
## 环境要求
|
||||
## 5.1 版本的请使用 tag1.0 版本
|
||||
## 新版后台在开发中 请不要使用
|
||||
### 环境要求
|
||||
- php7.1+ (需以下扩展)
|
||||
- [x] mbstring
|
||||
- [x] json
|
||||
- [x] openssl
|
||||
- [x] xml
|
||||
- [x] pdo
|
||||
- mbstring
|
||||
- json
|
||||
- openssl
|
||||
- xml
|
||||
- pdo
|
||||
- nginx
|
||||
- mysql
|
||||
|
||||
### 如何安装
|
||||
> 安装之前请确保已安装 Composer
|
||||
### install
|
||||
- curl -sS http://install.phpcomposer.com/installer | php
|
||||
- composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
|
||||
- composer update
|
||||
- php think catch:install
|
||||
|
||||
#### 下载项目
|
||||
- 通过 Git 下载(推荐)
|
||||
```shell
|
||||
git clone https://gitee.com/jaguarjack/catchAdmin && cd catchAdmin
|
||||
### Use
|
||||
- 配置虚拟域名 OR 在根目录下执行 php think run
|
||||
- yourUrl/login
|
||||
- 默认用户名 admin@gmail.com 密码 admin
|
||||
|
||||
curl -sS https://install.phpcomposer.com/installer | php
|
||||
|
||||
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
|
||||
|
||||
composer install
|
||||
### Problem
|
||||
> SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'updated_at'
|
||||
|
||||
> 设置 sql_mode;
|
||||
```
|
||||
- composer 安装
|
||||
```shell
|
||||
composer create-project jaguarjack/catchadmin:dev-master
|
||||
show variables like 'sql_mode' ;
|
||||
remove 'NO_ZERO_IN_DATE,NO_ZERO_DATE'
|
||||
```
|
||||
> SET GLOBAL sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
|
||||
|
||||
#### 安装
|
||||
下载完成之后通过命令来进行安装, 一键安装 🚀
|
||||
```shell
|
||||
php think catch:install
|
||||
```
|
||||
### Talking
|
||||
- 可以提 ISSUE,请按照 issue 模板提问
|
||||
- 欢迎进入 Q 群,可以及时反馈一些问题。
|
||||
- 
|
||||
|
||||
仅供学习
|
||||
|
||||
## 体验地址
|
||||
|
||||
[体验地址](http://vue.catchadmin.com)
|
||||
- 账号: admin@gmail.com
|
||||
- 密码: admin
|
||||
|
||||
[catchadmin 文档地址](http://doc.catchadmin.com)
|
||||
|
||||
### 系列文章
|
||||
如果是刚开始使用 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">
|
||||
|
||||
### 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)
|
||||
[体验地址](http://demo.catchadmin.com/login)
|
||||
- 账号: test@catch.com
|
||||
- 密码: 123456
|
@@ -3,8 +3,11 @@ declare (strict_types = 1);
|
||||
|
||||
namespace app;
|
||||
|
||||
use catcher\CatchAdmin;
|
||||
use think\App;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\View;
|
||||
use think\helper\Str;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
|
@@ -1,6 +1,11 @@
|
||||
<?php
|
||||
namespace app;
|
||||
|
||||
use catcher\CatchResponse;
|
||||
use catcher\exceptions\CatchException;
|
||||
use catcher\exceptions\FailedException;
|
||||
use catcher\exceptions\LoginFailedException;
|
||||
use catcher\exceptions\PermissionForbiddenException;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\exception\Handle;
|
||||
@@ -51,7 +56,10 @@ class ExceptionHandle extends Handle
|
||||
*/
|
||||
public function render($request, Throwable $e): Response
|
||||
{
|
||||
// if ($e instanceof CatchException){
|
||||
return CatchResponse::fail($e->getMessage(), $e->getCode());
|
||||
// }
|
||||
// 其他错误交给系统处理
|
||||
return parent::render($request, $e);
|
||||
//return parent::render($request, $e);
|
||||
}
|
||||
}
|
||||
|
@@ -3,51 +3,12 @@ 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;
|
||||
use catchAdmin\user\Auth;
|
||||
|
||||
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;
|
||||
public function user()
|
||||
{
|
||||
return Auth::user();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,5 @@ return [
|
||||
// 多语言加载
|
||||
// \think\middleware\LoadLangPack::class,
|
||||
// Session初始化
|
||||
// \think\middleware\SessionInit::class
|
||||
\think\middleware\AllowCrossDomain::class,
|
||||
\think\middleware\SessionInit::class
|
||||
];
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
return [
|
||||
\catcher\CatchAdminService::class,
|
||||
];
|
||||
\jaguarjack\think\module\ThinkModuleService::class,
|
||||
\catchAdmin\CatchAdminService::class,
|
||||
];
|
@@ -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,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,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 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,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,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,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);
|
||||
}
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"name": "权限管理",
|
||||
"alias": "permissions",
|
||||
"description": "权限管理模块",
|
||||
"version": "1.0.0",
|
||||
"keywords": [],
|
||||
"order": 2,
|
||||
"services": [
|
||||
"\\catchAdmin\\permissions\\PermissionService"
|
||||
],
|
||||
"aliases": {},
|
||||
"files": [],
|
||||
"requires": [],
|
||||
"enable": true
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
$router->group(function () use ($router){
|
||||
// 角色
|
||||
$router->resource('roles', '\catchAdmin\permissions\controller\Role');
|
||||
// 角色列表
|
||||
$router->get('/role/get/permissions', '\catchAdmin\permissions\controller\Role@getPermissions');
|
||||
// 权限
|
||||
$router->resource('permissions', '\catchAdmin\permissions\controller\Permission');
|
||||
$router->put('permissions/show/<id>', '\catchAdmin\permissions\controller\Permission@show');
|
||||
$router->get('controller/methods/<id>', '\catchAdmin\permissions\controller\Permission@getMethods');
|
||||
|
||||
// 部门
|
||||
$router->resource('departments', '\catchAdmin\permissions\controller\Department');
|
||||
// 岗位
|
||||
$router->resource('jobs', '\catchAdmin\permissions\controller\Job');
|
||||
|
||||
$router->get('jobs/all', '\catchAdmin\permissions\controller\Job@getAll');
|
||||
|
||||
// 用户
|
||||
$router->resource('users', '\catchAdmin\permissions\controller\User');
|
||||
// 切换状态
|
||||
$router->put('users/switch/status/<id>', '\catchAdmin\permissions\controller\User@switchStatus');
|
||||
$router->put('users/recover/<id>', '\catchAdmin\permissions\controller\User@recover');
|
||||
$router->get('users/get/roles', '\catchAdmin\permissions\controller\User@getRoles');
|
||||
$router->get('user/info', '\catchAdmin\permissions\controller\User@info');
|
||||
})->middleware('auth');
|
@@ -1,31 +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\system;
|
||||
|
||||
use catchAdmin\system\events\AttachmentEvent;
|
||||
use catcher\ModuleService;
|
||||
|
||||
class SystemService extends ModuleService
|
||||
{
|
||||
|
||||
public function loadRouteFrom()
|
||||
{
|
||||
// TODO: Implement loadRouteFrom() method.
|
||||
return __DIR__ . DIRECTORY_SEPARATOR . 'route.php';
|
||||
}
|
||||
|
||||
public function loadEvents()
|
||||
{
|
||||
return [
|
||||
'attachment' => [ AttachmentEvent::class ],
|
||||
];
|
||||
}
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\system\controller;
|
||||
|
||||
use catcher\base\CatchController;
|
||||
use catcher\CatchResponse;
|
||||
use catchAdmin\system\model\Attachments as AttachmentsModel;
|
||||
use catcher\Utils;
|
||||
use think\facade\Filesystem;
|
||||
|
||||
class Attachments extends CatchController
|
||||
{
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @time 2020年07月25日
|
||||
* @param AttachmentsModel $model
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function index(AttachmentsModel $model)
|
||||
{
|
||||
return CatchResponse::paginate($model->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @time 2020年07月25日
|
||||
* @param $id
|
||||
* @param AttachmentsModel $model
|
||||
* @throws \League\Flysystem\FileNotFoundException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function delete($id, AttachmentsModel $model)
|
||||
{
|
||||
$attachments = $model->whereIn('id', Utils::stringToArrayBy($id))->select();
|
||||
|
||||
if ($model->deleteBy($id)) {
|
||||
foreach ($attachments as $attachment) {
|
||||
Filesystem::delete($attachment->path);
|
||||
}
|
||||
}
|
||||
|
||||
return CatchResponse::success();
|
||||
}
|
||||
}
|
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\system\controller;
|
||||
|
||||
use app\Request;
|
||||
use catcher\base\CatchController;
|
||||
use catchAdmin\system\model\Config as ConfigModel;
|
||||
use catcher\CatchResponse;
|
||||
use think\response\Json;
|
||||
|
||||
class Config extends CatchController
|
||||
{
|
||||
protected $configModel;
|
||||
|
||||
public function __construct(ConfigModel $configModel)
|
||||
{
|
||||
$this->configModel = $configModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取父级别配置
|
||||
*
|
||||
* @time 2020年04月17日
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return Json
|
||||
*/
|
||||
public function parent()
|
||||
{
|
||||
return CatchResponse::success($this->configModel->getParentConfig());
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储配置
|
||||
*
|
||||
* @time 2020年04月17日
|
||||
* @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)
|
||||
{
|
||||
return CatchResponse::success([
|
||||
'id' => $this->configModel->storeBy($request->param()),
|
||||
'parents' => $this->configModel->getParentConfig(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置
|
||||
*
|
||||
* @time 2020年04月20日
|
||||
* @param $id
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return Json
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
return CatchResponse::success($this->configModel->getConfig($id));
|
||||
}
|
||||
}
|
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\system\controller;
|
||||
|
||||
use catcher\base\CatchRequest as Request;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\exceptions\FailedException;
|
||||
use catcher\library\BackUpDatabase;
|
||||
use think\Collection;
|
||||
use think\facade\Console;
|
||||
use think\facade\Db;
|
||||
use think\Paginator;
|
||||
|
||||
class DataDictionary extends CatchController
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月13日
|
||||
* @param Request $request
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function tables(Request $request): \think\response\Json
|
||||
{
|
||||
$tables = Db::query('show table status');
|
||||
|
||||
// 重组数据
|
||||
foreach ($tables as $key => &$table) {
|
||||
$table = array_change_key_case($table);
|
||||
$table['index_length'] = $table['index_length'] > 1024 ? intval($table['index_length']/1024) .'MB' : $table['index_length'].'KB';
|
||||
$table['data_length'] = $table['data_length'] > 1024 ? intval($table['data_length']/1024) .'MB' : $table['data_length'].'KB';
|
||||
$table['create_time'] = date('Y-m-d', strtotime($table['create_time']));
|
||||
}
|
||||
|
||||
// 搜素
|
||||
$tables = new Collection($tables);
|
||||
// 名称搜索
|
||||
if ($name = $request->get('tablename', null)) {
|
||||
$tables = $tables->where('name', 'like', $name)->values();
|
||||
}
|
||||
// 引擎搜索
|
||||
if ($engine = $request->get('engine', null)) {
|
||||
$tables = $tables->where('engine', $engine)->values();
|
||||
}
|
||||
|
||||
return CatchResponse::paginate(Paginator::make($tables->toArray(), $request->get('limit') ?? 10, $request->get('page') ?? 1, $tables->count(), false, []));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月13日
|
||||
* @param $table
|
||||
* @return \think\response\Json
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function view($table): \think\response\Json
|
||||
{
|
||||
return CatchResponse::success(array_values(Db::getFields($table)));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月13日
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function optimize(): \think\response\Json
|
||||
{
|
||||
$tables = \request()->post('data');
|
||||
|
||||
foreach ($tables as $table) {
|
||||
Db::query(sprintf('optimize table %s', $table));
|
||||
}
|
||||
|
||||
return CatchResponse::success([], '优化成功');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月13日
|
||||
* @throws FailedException
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function backup(BackUpDatabase $backUpDatabase): \think\response\Json
|
||||
{
|
||||
try {
|
||||
$backUpDatabase->done(trim(implode(',', \request()->post('data')), ','));
|
||||
}catch (\Exception $e) {
|
||||
throw new FailedException($e->getMessage());
|
||||
}
|
||||
|
||||
return CatchResponse::success([], '备份成功');
|
||||
}
|
||||
}
|
@@ -1,103 +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\system\controller;
|
||||
|
||||
use think\Request as Request;
|
||||
use catcher\CatchAuth;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\base\CatchController;
|
||||
use catchAdmin\system\model\Developers as DevelopersModel;
|
||||
|
||||
class Developer extends CatchController
|
||||
{
|
||||
protected $model;
|
||||
|
||||
public function __construct(DevelopersModel $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @time 2020/07/13 15:26
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return CatchResponse::paginate($this->model->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 开发者认证
|
||||
*
|
||||
* @time 2020年07月13日
|
||||
* @param Request $request
|
||||
* @param CatchAuth $auth
|
||||
* @return mixed
|
||||
*/
|
||||
public function authenticate(Request $request, CatchAuth $auth)
|
||||
{
|
||||
return CatchResponse::success($auth->guard('developer')->username('username')->attempt($request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @time 2020/07/13 15:26
|
||||
* @param Request Request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
return CatchResponse::success($this->model->storeBy($request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取
|
||||
*
|
||||
* @time 2020/07/13 15:26
|
||||
* @param $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
return CatchResponse::success($this->model->findBy($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @time 2020/07/13 15:26
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
return CatchResponse::success($this->model->updateBy($id, $request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @time 2020/07/13 15:26
|
||||
* @param $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
return CatchResponse::success($this->model->deleteBy($id));
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\system\controller;
|
||||
|
||||
use catcher\base\CatchController;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\generate\Generator;
|
||||
use think\Request;
|
||||
|
||||
class Generate extends CatchController
|
||||
{
|
||||
public function save(Request $request, Generator $generator)
|
||||
{
|
||||
return CatchResponse::success($generator->done($request->param()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览
|
||||
*
|
||||
* @time 2020年04月29日
|
||||
* @param Request $request
|
||||
* @param Generator $generator
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function preview(Request $request, Generator $generator)
|
||||
{
|
||||
return CatchResponse::success($generator->preview($request->param()));
|
||||
}
|
||||
}
|
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace catchAdmin\system\controller;
|
||||
|
||||
use catcher\base\CatchController;
|
||||
use catcher\CatchResponse;
|
||||
use think\facade\Db;
|
||||
use catchAdmin\system\model\LoginLog as Log;
|
||||
|
||||
class LoginLog extends CatchController
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @time 2020年04月28日
|
||||
* @param Log $log
|
||||
* @throws \think\db\exception\DbException
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function list(Log $log)
|
||||
{
|
||||
return CatchResponse::paginate($log->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空
|
||||
*
|
||||
* @time 2020年04月28日
|
||||
* @param Log $log
|
||||
* @throws \Exception
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function empty(Log $log)
|
||||
{
|
||||
return CatchResponse::success($log->where('id', '>', 0)->delete(), '清空成功');
|
||||
}
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace catchAdmin\system\controller;
|
||||
|
||||
use catcher\base\CatchController;
|
||||
use catcher\CatchResponse;
|
||||
use catchAdmin\system\model\OperateLog as Log;
|
||||
|
||||
class OperateLog extends CatchController
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @time 2020年04月28日
|
||||
* @param Log $log
|
||||
* @throws \think\db\exception\DbException
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function list(Log $log)
|
||||
{
|
||||
return CatchResponse::paginate($log->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2020年04月28日
|
||||
* @param Log $log
|
||||
* @throws \Exception
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function empty(Log $log)
|
||||
{
|
||||
return CatchResponse::success($log->where('id', '>', 0)->delete(), '清空成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Log $log
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function delete($id, Log $log)
|
||||
{
|
||||
return CatchResponse::success($log->deleteBy($id));
|
||||
}
|
||||
}
|
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\system\controller;
|
||||
|
||||
use catchAdmin\system\request\sensitiveWord\CreateRequest;
|
||||
use catchAdmin\system\request\sensitiveWord\UpdateRequest;
|
||||
use catcher\base\CatchController;
|
||||
use catchAdmin\system\model\SensitiveWord as Model;
|
||||
use catcher\base\CatchRequest;
|
||||
use catcher\CatchResponse;
|
||||
|
||||
class SensitiveWord extends CatchController
|
||||
{
|
||||
protected $sensitiveWord;
|
||||
|
||||
public function __construct(Model $model)
|
||||
{
|
||||
$this->sensitiveWord = $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @time 2020年06月17日
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return CatchResponse::paginate($this->sensitiveWord->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @time 2020年06月17日
|
||||
* @param CreateRequest $request
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function save(CreateRequest $request)
|
||||
{
|
||||
return CatchResponse::success($this->sensitiveWord->storeBy($request->param()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @time 2020年06月17日
|
||||
* @param $id
|
||||
* @param UpdateRequest $request
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function update($id, UpdateRequest $request)
|
||||
{
|
||||
return CatchResponse::success($this->sensitiveWord->updateBy($id, $request->param()));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @time 2020年06月17日
|
||||
* @param $id
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
return CatchResponse::success($this->sensitiveWord->deleteBy($id));
|
||||
}
|
||||
|
||||
}
|
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @filename Upload.php
|
||||
* @createdAt 2020/1/25
|
||||
* @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\system\controller;
|
||||
|
||||
use catchAdmin\system\model\Attachments;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\base\CatchRequest;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\CatchUpload;
|
||||
|
||||
class Upload extends CatchController
|
||||
{
|
||||
protected $attachment;
|
||||
|
||||
public function __construct(Attachments $attachment)
|
||||
{
|
||||
$this->attachment = $attachment;
|
||||
}
|
||||
|
||||
/**
|
||||
* image upload
|
||||
*
|
||||
* @time 2020年01月25日
|
||||
* @param CatchRequest $request
|
||||
* @param CatchUpload $upload
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function image(CatchRequest $request, CatchUpload $upload): \think\response\Json
|
||||
{
|
||||
$images = $request->file();
|
||||
|
||||
return CatchResponse::success($upload->checkImages($images)->multiUpload($images['image']));
|
||||
}
|
||||
|
||||
/**
|
||||
* file upload
|
||||
*
|
||||
* @time 2020年01月25日
|
||||
* @param CatchRequest $request
|
||||
* @param CatchUpload $upload
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function file(CatchRequest $request, CatchUpload $upload): \think\response\Json
|
||||
{
|
||||
$files = $request->file();
|
||||
|
||||
return CatchResponse::success($upload->checkFiles($files)->multiUpload($files['file']));
|
||||
}
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class Attachments 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('attachments',['engine'=>'Myisam', 'comment' => '附件管理', 'signed' => false]);
|
||||
$table->addColumn('path', 'string',['limit' => 50,'default'=>'','comment'=>'附件存储路径'])
|
||||
->addColumn('url', 'string',['default'=> '', 'limit' => 100, 'comment'=>'资源地址'])
|
||||
->addColumn('mime_type', 'string',['default'=> '', 'limit' => 100, 'comment'=>'资源mimeType'])
|
||||
->addColumn('file_ext', 'string',['default'=> '','limit' => 100, 'comment'=>'资源后缀'])
|
||||
->addColumn('file_size', 'integer',['default'=> 0, 'comment'=>'资源大小'])
|
||||
->addColumn('filename', 'string',['default'=>'', 'limit' => 255, 'comment'=>'资源名称'])
|
||||
->addColumn('driver', 'string',['default'=> 0, 'limit' => 20, 'comment' => 'local,oss,qcloud,qiniu'])
|
||||
->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'=>'删除时间', 'signed' => false ))
|
||||
->create();
|
||||
}
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class Config 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('config',['engine'=>'InnoDB', 'comment' => '配置管理', 'signed' => false]);
|
||||
$table->addColumn('name', 'string',['limit' => 50,'default'=>'','comment'=>'配置名称'])
|
||||
->addColumn('pid', 'integer', array('default'=> 0,'comment'=>'父级配置', 'signed' => false ))
|
||||
->addColumn('component', 'string', ['default'=> '', 'limit' => 100, 'comment'=>'tab 引入的组件名称'])
|
||||
->addColumn('key', 'string',['default'=> '', 'limit' => 100, 'comment'=>'配置键名'])
|
||||
->addColumn('value', 'string',['default'=> '', 'limit' => 255, 'comment'=>'配置键值'])
|
||||
->addColumn('status', 'integer',['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY,'default'=> 1,'comment'=>'1 启用 2 禁用'])
|
||||
->addColumn('creator_id', 'integer', array('default'=> 0,'comment'=>'创建人', 'signed' => false ))
|
||||
->addColumn('created_at', 'integer', ['default'=> 0,'comment'=>'创建时间', 'signed' => false])
|
||||
->addColumn('updated_at', 'integer', ['default'=> 0,'comment'=>'更新时间', 'signed' => false])
|
||||
->addColumn('deleted_at', 'integer', ['default'=> 0,'comment'=>'删除时间', 'signed' => false])
|
||||
->create();
|
||||
}
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class SensitiveWord 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('sensitive_word',['engine'=>'InnoDB', 'comment' => '敏感词库', 'signed' => false]);
|
||||
$table->addColumn('word', 'string',['limit' => 50,'default'=>'','comment'=>'词汇'])
|
||||
->addColumn('creator_id', 'integer', array('default'=>0, 'comment'=>'创建人ID', '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'=>'删除时间', 'signed' => false ))
|
||||
->create();
|
||||
}
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class Developers 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('developers', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '开发者' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
|
||||
$table->addColumn('username', 'string', ['limit' => 50,'null' => false,'default' => '','signed' => false,'comment' => '用户名',])
|
||||
->addColumn('password', 'string', ['limit' => 255,'null' => false,'default' => '','signed' => false,'comment' => '密码',])
|
||||
->addColumn('mobile', 'string', ['limit' => 30,'null' => false,'default' => '','signed' => false,'comment' => '手机号',])
|
||||
->addColumn('id_card', 'string', ['limit' => 50,'null' => false,'default' => '','signed' => false,'comment' => '身份证',])
|
||||
->addColumn('alipay_account', 'string', ['limit' => 100,'null' => false,'default' => '','signed' => false,'comment' => '支付宝账户',])
|
||||
->addColumn('status', 'boolean', ['null' => false,'default' => 1,'signed' => false,'comment' => '1 待认证 1 已认证',])
|
||||
->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建时间',])
|
||||
->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '更新时间',])
|
||||
->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '软删除',])
|
||||
->create();
|
||||
}
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class UpdateAttachmentsUrl 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('attachments')) {
|
||||
$table = $this->table('attachments');
|
||||
|
||||
$table->changeColumn('url', 'string', ['default'=> '', 'limit' => 255, 'comment'=>'资源地址'])
|
||||
->update();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Seeder;
|
||||
|
||||
class ConfigSeed 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 = [
|
||||
[
|
||||
'name' => '基础配置',
|
||||
'pid' => 0,
|
||||
'component' => 'basis',
|
||||
'key' => 'basis',
|
||||
],
|
||||
[
|
||||
'name' => '上传配置',
|
||||
'pid' => 0,
|
||||
'component' => 'upload',
|
||||
'key' => 'upload',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($data as $item) {
|
||||
\catchAdmin\system\model\Config::create($item);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,621 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Seeder;
|
||||
|
||||
class SystemPermissionSeed extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run Method.
|
||||
*
|
||||
* Write your database seeder using this method.
|
||||
*
|
||||
* More information on writing seeders is available here:
|
||||
* http://docs.phinx.org/en/latest/seeding.html
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
\catcher\Utils::importTreeData($this->getPermissions(), 'permissions', 'parent_id');
|
||||
}
|
||||
|
||||
protected function getPermissions()
|
||||
{
|
||||
return array(
|
||||
0 =>
|
||||
array(
|
||||
'id' => 37,
|
||||
'permission_name' => '系统管理',
|
||||
'parent_id' => 0,
|
||||
'level' => '',
|
||||
'route' => '/system',
|
||||
'icon' => 'bar-chart',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'system',
|
||||
'component' => 'pageView',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 2,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587462349,
|
||||
'updated_at' => 1593044431,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array(
|
||||
0 =>
|
||||
array(
|
||||
'id' => 38,
|
||||
'permission_name' => '数据字典',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/system/database',
|
||||
'icon' => 'hdd',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'dataDictionary@index',
|
||||
'component' => 'database',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 8,
|
||||
'created_at' => 1587463087,
|
||||
'updated_at' => 1593044431,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array(
|
||||
0 =>
|
||||
array(
|
||||
'id' => 39,
|
||||
'permission_name' => '查看',
|
||||
'parent_id' => 38,
|
||||
'level' => '37-38',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'dataDictionary@view',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587463113,
|
||||
'updated_at' => 1591343449,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array(
|
||||
'id' => 40,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 38,
|
||||
'level' => '37-38',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'dataDictionary@tables',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 10,
|
||||
'created_at' => 1587463173,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array(
|
||||
'id' => 41,
|
||||
'permission_name' => '优化',
|
||||
'parent_id' => 38,
|
||||
'level' => '37-38',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'dataDictionary@optimize',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587463201,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array(
|
||||
'id' => 42,
|
||||
'permission_name' => '备份',
|
||||
'parent_id' => 38,
|
||||
'level' => '37-38',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'optimize@backup',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587463217,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
1 =>
|
||||
array(
|
||||
'id' => 43,
|
||||
'permission_name' => '附件管理',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/attactments',
|
||||
'icon' => 'folder-open',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'attactments',
|
||||
'component' => 'attachment',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 10,
|
||||
'created_at' => 1587463302,
|
||||
'updated_at' => 1593044431,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array(
|
||||
0 =>
|
||||
array(
|
||||
'id' => 44,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 43,
|
||||
'level' => '37-43',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'attachments@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587463335,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array(
|
||||
'id' => 45,
|
||||
'permission_name' => '删除',
|
||||
'parent_id' => 43,
|
||||
'level' => '37-43',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'attachments@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587463355,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array(
|
||||
'id' => 46,
|
||||
'permission_name' => '上传图片',
|
||||
'parent_id' => 43,
|
||||
'level' => '37-43',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'upload@image',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587466919,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array(
|
||||
'id' => 47,
|
||||
'permission_name' => '上传文件',
|
||||
'parent_id' => 43,
|
||||
'level' => '37-43',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'upload@file',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587466939,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
2 =>
|
||||
array(
|
||||
'id' => 48,
|
||||
'permission_name' => '配置管理',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/system/config',
|
||||
'icon' => 'setting',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'config',
|
||||
'component' => 'config',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 9,
|
||||
'created_at' => 1587466991,
|
||||
'updated_at' => 1593044431,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array(
|
||||
0 =>
|
||||
array(
|
||||
'id' => 49,
|
||||
'permission_name' => '父级配置',
|
||||
'parent_id' => 48,
|
||||
'level' => '37-48',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'config@parent',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467036,
|
||||
'updated_at' => 1591345651,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array(
|
||||
'id' => 50,
|
||||
'permission_name' => '存储',
|
||||
'parent_id' => 48,
|
||||
'level' => '37-48',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'config@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467052,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array(
|
||||
'id' => 51,
|
||||
'permission_name' => '获取',
|
||||
'parent_id' => 48,
|
||||
'level' => '37-48',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'config@read',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467062,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
3 =>
|
||||
array(
|
||||
'id' => 52,
|
||||
'permission_name' => '登陆日志',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/system/log/login',
|
||||
'icon' => 'export',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'loginLog',
|
||||
'component' => 'loginLog',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 5,
|
||||
'created_at' => 1587467150,
|
||||
'updated_at' => 1593044431,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array(
|
||||
0 =>
|
||||
array(
|
||||
'id' => 53,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 52,
|
||||
'level' => '37-52',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'loginlog@list',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467206,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array(
|
||||
'id' => 54,
|
||||
'permission_name' => '清空',
|
||||
'parent_id' => 52,
|
||||
'level' => '37-52',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'loginlog@empty',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467221,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
4 =>
|
||||
array(
|
||||
'id' => 55,
|
||||
'permission_name' => '操作日志',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/system/log/operate',
|
||||
'icon' => 'profile',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'operateLog',
|
||||
'component' => 'operateLog',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467180,
|
||||
'updated_at' => 1593044431,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array(
|
||||
0 =>
|
||||
array(
|
||||
'id' => 56,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 55,
|
||||
'level' => '37-55',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'operatelog@list',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467246,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array(
|
||||
'id' => 57,
|
||||
'permission_name' => '清空',
|
||||
'parent_id' => 55,
|
||||
'level' => '37-55',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'operatelog@empty',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587467266,
|
||||
'updated_at' => 1587547118,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
5 =>
|
||||
array(
|
||||
'id' => 58,
|
||||
'permission_name' => '代码生成',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/generate',
|
||||
'icon' => 'scissor',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'generate',
|
||||
'component' => 'generate',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1587717452,
|
||||
'updated_at' => 1593044431,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array(
|
||||
0 =>
|
||||
array(
|
||||
'id' => 59,
|
||||
'permission_name' => '生成',
|
||||
'parent_id' => 58,
|
||||
'level' => '37-58',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'generate@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1588110923,
|
||||
'updated_at' => 1588110923,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array(
|
||||
'id' => 60,
|
||||
'permission_name' => '预览',
|
||||
'parent_id' => 58,
|
||||
'level' => '37-58',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'generate@preview',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1588110962,
|
||||
'updated_at' => 1588110962,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
6 =>
|
||||
array(
|
||||
'id' => 68,
|
||||
'permission_name' => '敏感词库',
|
||||
'parent_id' => 37,
|
||||
'level' => '37',
|
||||
'route' => '/sensitive/word',
|
||||
'icon' => 'sliders',
|
||||
'module' => 'system',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'sensitiveWord',
|
||||
'component' => 'sensitiveWord',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1592375865,
|
||||
'updated_at' => 1593044431,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\system\events;
|
||||
|
||||
|
||||
use catchAdmin\system\model\Attachments;
|
||||
|
||||
class AttachmentEvent
|
||||
{
|
||||
public function handle($params)
|
||||
{
|
||||
$file = $params['file'];
|
||||
|
||||
unset($params['file']);
|
||||
|
||||
Attachments::store($params, $file);
|
||||
}
|
||||
}
|
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\system\model;
|
||||
|
||||
use catcher\base\CatchModel;
|
||||
use think\file\UploadedFile;
|
||||
use think\Model;
|
||||
|
||||
class Attachments extends CatchModel
|
||||
{
|
||||
protected $name = 'attachments';
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'path', // 附件存储路径
|
||||
'url', // 资源地址
|
||||
'mime_type', // 资源mimeType
|
||||
'file_ext', // 资源后缀
|
||||
'file_size', // 资源大小
|
||||
'filename', // 资源名称
|
||||
'driver', // local,oss,qcloud,qiniu
|
||||
'created_at', // 创建时间
|
||||
'updated_at', // 更新时间
|
||||
'deleted_at', // 删除时间
|
||||
];
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return $this->order('id', 'desc')
|
||||
->catchSearch()
|
||||
->paginate();
|
||||
}
|
||||
|
||||
public function searchFileExtAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where('file_ext', $value);
|
||||
}
|
||||
|
||||
public function searchMimeTypesAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where('mime_type', $value);
|
||||
}
|
||||
|
||||
public function searchDriver($query, $value, $data)
|
||||
{
|
||||
return $query->where('driver', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @time 2020年06月01日
|
||||
* @param $data ['driver' => '', 'path' => '', 'url' => ],
|
||||
* @param UploadedFile $file
|
||||
* @return Attachments|Model
|
||||
*/
|
||||
public static function store($data, UploadedFile $file)
|
||||
{
|
||||
return parent::create([
|
||||
'file_size' => $file->getSize(),
|
||||
'mime_type' => $file->getMime(),
|
||||
'file_ext' => $file->getOriginalExtension(),
|
||||
'filename' => $file->getOriginalName(),
|
||||
'driver' => $data['driver'],
|
||||
'url' => $data['url'],
|
||||
'path' => $data['path']
|
||||
]);
|
||||
}
|
||||
}
|
@@ -1,210 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\system\model;
|
||||
|
||||
use catcher\base\CatchModel;
|
||||
use thans\jwt\exception\UserNotDefinedException;
|
||||
use think\Model;
|
||||
|
||||
class Config extends CatchModel
|
||||
{
|
||||
protected $name = 'config';
|
||||
|
||||
protected $pk = 'id';
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'name', // 配置名称
|
||||
'pid', // 父级配置
|
||||
'key', // 配置键名
|
||||
'value', // 配置键值
|
||||
'component', // 组件
|
||||
'status', // 1 启用 2 禁用
|
||||
'creator_id', // 创建人
|
||||
'created_at', // 创建时间
|
||||
'updated_at', // 更新时间
|
||||
'deleted_at', // 删除时间
|
||||
];
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2020年04月17日
|
||||
* @return \think\Collection
|
||||
*@throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
*/
|
||||
public function getParentConfig()
|
||||
{
|
||||
return $this->where('pid', 0)
|
||||
->field(['id', 'name', 'component'])->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储配置
|
||||
*
|
||||
* @time 2020年04月20日
|
||||
* @param array $data
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return bool
|
||||
*/
|
||||
public function storeBy(array $data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 子配置
|
||||
if ($data['pid'] ?? false) {
|
||||
$config = \json_decode($data['config'], true);
|
||||
$pid = $data['pid'];
|
||||
unset($data['pid']);
|
||||
/**[
|
||||
'key' => [
|
||||
'k' => 'v'
|
||||
],
|
||||
|
||||
'k' => 'v'
|
||||
]*/
|
||||
foreach ($config as $key => $value) {
|
||||
if (empty($value)) {
|
||||
continue;
|
||||
}
|
||||
// 如果二级配置存在
|
||||
$secondLevel = $this->isExistConfig($key, $pid);
|
||||
if ($secondLevel) {
|
||||
// value 是字符串
|
||||
if (!is_array($value)) {
|
||||
if ($value != $secondLevel->value) {
|
||||
$secondLevel->value = $value;
|
||||
$secondLevel->save();
|
||||
}
|
||||
} else {
|
||||
// 数组
|
||||
$thirdLevel = [];
|
||||
$this->subConfig($secondLevel->id, ['id', 'key', 'value'])
|
||||
->each(function ($item, $key) use (&$thirdLevel){
|
||||
$thirdLevel[$item['key']] = $item;
|
||||
});
|
||||
|
||||
if (!empty($value)) {
|
||||
$new = [];
|
||||
foreach ($value as $k => $v) {
|
||||
if (isset($thirdLevel[$k])) {
|
||||
if ($v != $thirdLevel[$k]->value) {
|
||||
$thirdLevel[$k]->value = $v;
|
||||
$thirdLevel[$k]->save();
|
||||
}
|
||||
} else {
|
||||
$new[] = [
|
||||
'pid' => $secondLevel->id,
|
||||
'key' => $k,
|
||||
'value' => $v,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($new)) {
|
||||
parent::insertAllBy($new);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!is_array($value)) {
|
||||
parent::createBy([
|
||||
'pid' => $pid,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
]);
|
||||
} else {
|
||||
$id = parent::createBy([
|
||||
'pid' => $pid,
|
||||
'key' => $key,
|
||||
]);
|
||||
if (!empty($value)) {
|
||||
$newConfig = [];
|
||||
foreach ($value as $k => $v) {
|
||||
$newConfig[] = [
|
||||
'key' => $k,
|
||||
'value' => $v,
|
||||
'pid' => $id,
|
||||
];
|
||||
}
|
||||
parent::insertAllBy($newConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return parent::storeBy($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置是否存在
|
||||
*
|
||||
* @time 2020年04月19日
|
||||
* @param $key
|
||||
* @param int $pid
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return array|Model|null
|
||||
*/
|
||||
public function isExistConfig($key, $pid = 0)
|
||||
{
|
||||
return $this->where('pid', $pid)
|
||||
->where('key', $key)
|
||||
->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子配置
|
||||
*
|
||||
* @time 2020年04月19日
|
||||
* @param int $pid
|
||||
* @param array $field
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return \think\Collection
|
||||
*/
|
||||
public function subConfig($pid = 0, array $field = ['*'])
|
||||
{
|
||||
return $this->where('pid', $pid)
|
||||
->field($field)
|
||||
->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置
|
||||
*
|
||||
* @time 2020年04月20日
|
||||
* @param int $pid
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function getConfig($pid = 0)
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$configs = $this->where('pid', $pid)
|
||||
->field('id,`key` as k,value,pid')
|
||||
->select();
|
||||
|
||||
foreach ($configs as $config) {
|
||||
if ($config->value !== '') {
|
||||
$data[$config->k] = $config->value;
|
||||
} else {
|
||||
$data[$config->k] = $this->getConfig($config->id);
|
||||
}
|
||||
}
|
||||
|
||||
return empty($data) ? '' : $data;
|
||||
}
|
||||
}
|
@@ -1,39 +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\system\model;
|
||||
|
||||
use catcher\base\CatchModel as Model;
|
||||
|
||||
class Developers extends Model
|
||||
{
|
||||
protected $name = 'developers';
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'username', // 用户名
|
||||
'password', // 密码
|
||||
'mobile', // 手机号
|
||||
'id_card', // 身份证
|
||||
'alipay_account', // 支付宝账户
|
||||
'status', // 1 待认证 1 已认证
|
||||
'created_at', // 创建时间
|
||||
'updated_at', // 更新时间
|
||||
'deleted_at', // 软删除
|
||||
];
|
||||
|
||||
|
||||
public function setPasswordAttr($value)
|
||||
{
|
||||
return password_hash($value, PASSWORD_DEFAULT);
|
||||
}
|
||||
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace catchAdmin\system\model;
|
||||
|
||||
use catcher\traits\db\BaseOptionsTrait;
|
||||
use catchAdmin\system\model\search\LoginLogSearch;
|
||||
|
||||
class LoginLog extends \think\Model
|
||||
{
|
||||
use BaseOptionsTrait, LoginLogSearch;
|
||||
|
||||
protected $name = 'login_log';
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'login_name', // 用户名
|
||||
'login_ip', // 登录地点ip
|
||||
'browser', // 浏览器
|
||||
'os', // 操作系统
|
||||
'login_at', // 登录时间
|
||||
'status', // 1 成功 2 失败
|
||||
];
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return $this->catchSearch()
|
||||
->order('id', 'desc')
|
||||
->paginate();
|
||||
}
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace catchAdmin\system\model;
|
||||
|
||||
use catchAdmin\permissions\model\Users;
|
||||
use catcher\traits\db\BaseOptionsTrait;
|
||||
use catchAdmin\system\model\search\OperateLogSearch;
|
||||
|
||||
class OperateLog extends \think\Model
|
||||
{
|
||||
use BaseOptionsTrait;
|
||||
use OperateLogSearch;
|
||||
|
||||
|
||||
protected $name = 'operate_log';
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'module', // 模块名称
|
||||
'operate', // 操作模块
|
||||
'route', // 路由
|
||||
'params', // 参数
|
||||
'ip', // ip
|
||||
'creator_id', // 创建人ID
|
||||
'method', // 请求方法
|
||||
'created_at', // 登录时间
|
||||
];
|
||||
|
||||
/**
|
||||
* get list
|
||||
*
|
||||
* @time 2020年04月28日
|
||||
* @param $params
|
||||
* @throws \think\db\exception\DbException
|
||||
* @return void
|
||||
*/
|
||||
public function getList()
|
||||
{
|
||||
return $this->field([$this->aliasField('*')])
|
||||
->catchJoin(Users::class, 'id', 'creator_id', ['username as creator'])
|
||||
->catchSearch()
|
||||
->order($this->aliasField('id'), 'desc')
|
||||
->paginate();
|
||||
}
|
||||
}
|
@@ -1,43 +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\system\model;
|
||||
|
||||
use catchAdmin\permissions\model\Users;
|
||||
use catcher\base\CatchModel;
|
||||
|
||||
class SensitiveWord extends CatchModel
|
||||
{
|
||||
protected $name = 'sensitive_word';
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'word', // 词汇
|
||||
'creator_id', // 创建人ID
|
||||
'created_at', // 创建时间
|
||||
'updated_at', // 更新时间
|
||||
'deleted_at', // 删除时间
|
||||
];
|
||||
|
||||
/**
|
||||
* 词汇查询
|
||||
*
|
||||
* @time 2020年06月17日
|
||||
* @param $query
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function searchWordAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('word', $value);
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace catchAdmin\system\model\search;
|
||||
|
||||
trait LoginLogSearch
|
||||
{
|
||||
public function searchLoginNameAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('login_name', $value);
|
||||
}
|
||||
|
||||
public function searchLoginIpAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('login_ip', $value);
|
||||
}
|
||||
|
||||
public function searchLoginAtAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereTime('login_at', 'between', $value);
|
||||
}
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace catchAdmin\system\model\search;
|
||||
|
||||
trait OperateLogSearch
|
||||
{
|
||||
public function searchModuleAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('module', $value);
|
||||
}
|
||||
|
||||
public function searchMethodAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('method', $value);
|
||||
}
|
||||
|
||||
public function searchCreatorAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where('username', $value);
|
||||
}
|
||||
|
||||
public function searchCreateAtAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereTime($this->aliasField('created_at'), 'between', $value);
|
||||
}
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"name": "系统管理",
|
||||
"alias": "system",
|
||||
"description": "系统管理模块",
|
||||
"version": "1.0.0",
|
||||
"keywords": [],
|
||||
"order": 2,
|
||||
"services": [
|
||||
"\\catchAdmin\\system\\SystemService"
|
||||
],
|
||||
"aliases": [],
|
||||
"files": [],
|
||||
"requires": [],
|
||||
"enable": true
|
||||
}
|
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\system\request\sensitiveWord;
|
||||
|
||||
use catchAdmin\system\model\SensitiveWord;
|
||||
use catcher\base\CatchRequest;
|
||||
|
||||
class CreateRequest extends CatchRequest
|
||||
{
|
||||
protected function rules(): array
|
||||
{
|
||||
// TODO: Implement rules() method.
|
||||
return [
|
||||
'word|词汇' => 'sensitive_word|unique:'.SensitiveWord::class.',word',
|
||||
];
|
||||
}
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\system\request\sensitiveWord;
|
||||
|
||||
use catchAdmin\system\model\SensitiveWord;
|
||||
use catcher\base\CatchRequest;
|
||||
|
||||
class UpdateRequest extends CatchRequest
|
||||
{
|
||||
protected function rules(): array
|
||||
{
|
||||
$id = request()->route()['id'];
|
||||
// TODO: Implement rules() method.
|
||||
return [
|
||||
'word|词汇' => 'sensitive_word|unique:'.SensitiveWord::class.',word,'.$id,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
$router->group(function () use ($router) {
|
||||
// 登录日志
|
||||
$router->get('log/login', '\catchAdmin\system\controller\LoginLog@list');
|
||||
$router->delete('loginLog/empty', '\catchAdmin\system\controller\LoginLog@empty');
|
||||
// 操作日志
|
||||
$router->get('log/operate', '\catchAdmin\system\controller\OperateLog@list');
|
||||
$router->delete('operateLog/empty', '\catchAdmin\system\controller\OperateLog@empty');
|
||||
$router->delete('operateLog/delete', '\catchAdmin\system\controller\OperateLog@delete');
|
||||
|
||||
// 数据字典
|
||||
$router->get('tables', '\catchAdmin\system\controller\DataDictionary@tables');
|
||||
$router->get('table/view/<table>', '\catchAdmin\system\controller\DataDictionary@view');
|
||||
$router->post('table/optimize', '\catchAdmin\system\controller\DataDictionary@optimize');
|
||||
$router->post('table/backup', '\catchAdmin\system\controller\DataDictionary@backup');
|
||||
|
||||
// 上传
|
||||
$router->post('upload/image', '\catchAdmin\system\controller\Upload@image');
|
||||
$router->post('upload/file', '\catchAdmin\system\controller\Upload@file');
|
||||
|
||||
// 附件
|
||||
$router->resource('attachments', '\catchAdmin\system\controller\Attachments');
|
||||
|
||||
// 配置
|
||||
$router->get('config/parent', '\catchAdmin\system\controller\Config@parent');
|
||||
$router->resource('config', '\catchAdmin\system\controller\Config');
|
||||
|
||||
// 代码生成
|
||||
$router->post('generate', '\catchAdmin\system\controller\Generate@save');
|
||||
$router->post('generate/preview', '\catchAdmin\system\controller\Generate@preview'); // 预览
|
||||
|
||||
// 敏感词
|
||||
$router->resource('sensitive/word', '\catchAdmin\system\controller\SensitiveWord');
|
||||
})->middleware('auth');
|
||||
|
||||
//developer路由
|
||||
$router->resource('developer', '\catchAdmin\system\controller\Developer')->middleware('auth');
|
||||
// 开发者认证
|
||||
$router->post('developer/authenticate', '\catchAdmin\system\controller\Developer@authenticate');
|
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\wechat;
|
||||
|
||||
use catchAdmin\wechat\command\SyncUsersCommand;
|
||||
use catcher\ModuleService;
|
||||
use think\Service;
|
||||
|
||||
class CatchWechatService extends ModuleService
|
||||
{
|
||||
/**
|
||||
* register
|
||||
*
|
||||
* @time 2020年06月24日
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
parent::register();
|
||||
}
|
||||
|
||||
/**
|
||||
* register command
|
||||
*
|
||||
* @time 2020年06月24日
|
||||
* @return array
|
||||
*/
|
||||
public function loadCommands()
|
||||
{
|
||||
return [__NAMESPACE__, __DIR__ . DIRECTORY_SEPARATOR . 'command'];
|
||||
}
|
||||
|
||||
/**
|
||||
* loaded router from
|
||||
*
|
||||
* @time 2020年06月24日
|
||||
* @return string
|
||||
*/
|
||||
public function loadRouteFrom()
|
||||
{
|
||||
// TODO: Implement loadRouteFrom() method.
|
||||
return __DIR__ . DIRECTORY_SEPARATOR . 'route.php';
|
||||
}
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @filename GetModuleTrait.php
|
||||
* @createdAt 2020/2/24
|
||||
* @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\wechat\command;
|
||||
|
||||
use catchAdmin\wechat\library\SyncWechatUsers;
|
||||
use catchAdmin\wechat\model\WechatUsers;
|
||||
use catcher\exceptions\FailedException;
|
||||
use catcher\facade\Trie;
|
||||
use catcher\library\ProgressBar;
|
||||
use catcher\library\WeChat;
|
||||
use catcher\Utils;
|
||||
use think\Collection;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
use think\Db;
|
||||
|
||||
class SyncUsersCommand extends Command
|
||||
{
|
||||
protected $officialAccount;
|
||||
|
||||
public function configure()
|
||||
{
|
||||
$this->setName('sync:users')
|
||||
->setDescription('sync wechat users');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2020年07月19日
|
||||
* @param Input $input
|
||||
* @param Output $output
|
||||
* @return int|void|null
|
||||
*/
|
||||
public function execute(Input $input, Output $output)
|
||||
{
|
||||
(new SyncWechatUsers())->start();
|
||||
}
|
||||
}
|
@@ -1,161 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @filename WechatCommand.php
|
||||
* @date 2020/6/6
|
||||
* @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\wechat\command;
|
||||
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
|
||||
class WechatCommand extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('publish:wechat')
|
||||
->setDescription('publish wechat config');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
file_put_contents(config_path() . 'wechat.php', $this->config());
|
||||
|
||||
$this->env();
|
||||
|
||||
$output->warning('wechat publish successfully');
|
||||
}
|
||||
|
||||
protected function config()
|
||||
{
|
||||
return <<<CONFIG
|
||||
<?php
|
||||
|
||||
return [
|
||||
/**
|
||||
* 公众号配置
|
||||
*
|
||||
*/
|
||||
'official_account' => [
|
||||
/**
|
||||
* 账号基本信息,请从微信公众平台/开放平台获取
|
||||
*/
|
||||
'app_id' => env('wechat.official_app_id'), // AppID
|
||||
'secret' => env('wechat.official_secret'), // AppSecret
|
||||
'token' => env('wechat.official_token'), // Token
|
||||
'aes_key' => env('wechat.official_aes_key'), // EncodingAESKey,兼容与安全模式下请一定要填写!!!
|
||||
|
||||
'response_type' => 'array',
|
||||
|
||||
/**
|
||||
* OAuth 配置
|
||||
*
|
||||
* scopes:公众平台(snsapi_userinfo / snsapi_base),开放平台:snsapi_login
|
||||
* callback:OAuth授权完成后的回调页地址
|
||||
*/
|
||||
'oauth' => [
|
||||
'scopes' => ['snsapi_userinfo'],
|
||||
'callback' => '/examples/oauth_callback.php',
|
||||
],
|
||||
],
|
||||
|
||||
/**
|
||||
* 小程序
|
||||
*/
|
||||
'mini_program' => [
|
||||
// 更多配置查看 https://www.easywechat.com/docs/master/mini-program/index
|
||||
],
|
||||
|
||||
/**
|
||||
* 开放平台
|
||||
*/
|
||||
'open_platform' => [
|
||||
// 更多配置查看 https://www.easywechat.com/docs/master/open-platform/index
|
||||
],
|
||||
|
||||
/**
|
||||
* 企业微信
|
||||
*/
|
||||
'work' => [
|
||||
// 更多配置查看 https://www.easywechat.com/docs/master/wework/index
|
||||
],
|
||||
|
||||
/**
|
||||
* 企业微信开放平台
|
||||
*/
|
||||
'open_work' => [
|
||||
// 配置 https://www.easywechat.com/docs/master/open-work/index
|
||||
],
|
||||
|
||||
/**
|
||||
* 小微商户
|
||||
*/
|
||||
'micro_merchant' => [
|
||||
// 配置 https://www.easywechat.com/docs/master/micro-merchant/index
|
||||
],
|
||||
|
||||
/**
|
||||
* wechat pay
|
||||
*/
|
||||
'payment' => [
|
||||
'app_id' => 'xxxx',
|
||||
'mch_id' => 'your-mch-id',
|
||||
'key' => 'key-for-signature', // API 密钥
|
||||
|
||||
// 如需使用敏感接口(如退款、发送红包等)需要配置 API 证书路径(登录商户平台下载 API 证书)
|
||||
'cert_path' => 'path/to/your/cert.pem', // XXX: 绝对路径!!!!
|
||||
'key_path' => 'path/to/your/key', // XXX: 绝对路径!!!!
|
||||
|
||||
'notify_url' => '默认的订单回调地址', // 你也可以在下单时单独设置来想覆盖它
|
||||
],
|
||||
|
||||
// 更多配置请查看 https://www.easywechat.com/docs
|
||||
];
|
||||
CONFIG;
|
||||
}
|
||||
|
||||
protected function env()
|
||||
{
|
||||
$filename = file_exists(root_path() . '.env') ? '.env' : '.example.env';
|
||||
|
||||
|
||||
$env = \parse_ini_file(root_path() . $filename, true);
|
||||
|
||||
$env['WECHAT'] = $this->envConfig();
|
||||
|
||||
$dotEnv = '';
|
||||
|
||||
foreach ($env as $key => $e) {
|
||||
if (is_string($e)) {
|
||||
$dotEnv .= sprintf('%s = %s', $key, $e === '1' ? 'true' : ($e === '' ? 'false' : $e)) . PHP_EOL;
|
||||
$dotEnv .= PHP_EOL;
|
||||
} else {
|
||||
$dotEnv .= sprintf('[%s]', $key) . PHP_EOL;
|
||||
foreach ($e as $k => $v) {
|
||||
$dotEnv .= sprintf('%s = %s', $k, $v === '1' ? 'true' : ($v === '' ? 'false' : $v)) . PHP_EOL;
|
||||
}
|
||||
|
||||
$dotEnv .= PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents(root_path() . '.env', $dotEnv);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function envConfig()
|
||||
{
|
||||
return [
|
||||
"official_app_id" => null,
|
||||
"official_secret" => null,
|
||||
"official_token" => null,
|
||||
"official_aes_key" => null,
|
||||
];
|
||||
}
|
||||
}
|
@@ -1,63 +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\wechat\controller;
|
||||
|
||||
use catchAdmin\wechat\repository\WechatGraphicRepository;
|
||||
use catchAdmin\wechat\repository\WechatUsersRepository;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\base\CatchRequest;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\library\WeChat;
|
||||
use catcher\Utils;
|
||||
use think\facade\Console;
|
||||
use think\Request;
|
||||
|
||||
class Graphic extends CatchController
|
||||
{
|
||||
protected $graphic;
|
||||
|
||||
public function __construct(WechatGraphicRepository $graphic)
|
||||
{
|
||||
$this->graphic = $graphic;
|
||||
}
|
||||
|
||||
/**
|
||||
* list
|
||||
*
|
||||
* @time 2020年06月27日
|
||||
* @param CatchRequest $request
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function index(CatchRequest $request)
|
||||
{
|
||||
return CatchResponse::paginate($this->graphic->getList($request->param()));
|
||||
}
|
||||
|
||||
public function read($id)
|
||||
{
|
||||
return CatchResponse::success($this->graphic->findBy($id));
|
||||
}
|
||||
|
||||
public function save(CatchRequest $request)
|
||||
{
|
||||
return CatchResponse::success($this->graphic->storeBy($request->param()));
|
||||
}
|
||||
|
||||
public function update($id, CatchRequest $request)
|
||||
{
|
||||
return CatchResponse::success($this->graphic->updateBy($id, $request->param()));
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
return CatchResponse::success($this->graphic->deleteBy($id));
|
||||
}
|
||||
}
|
@@ -1,48 +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\wechat\controller;
|
||||
|
||||
use catchAdmin\wechat\repository\WechatUsersRepository;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\base\CatchRequest;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\library\WeChat;
|
||||
use catcher\Utils;
|
||||
use think\facade\Console;
|
||||
use think\Request;
|
||||
|
||||
class Material extends CatchController
|
||||
{
|
||||
public function index(CatchRequest $request)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function read($id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function save(CatchRequest $request)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@@ -1,86 +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\wechat\controller;
|
||||
|
||||
use catchAdmin\wechat\repository\WechatMenusRepository;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\base\CatchRequest;
|
||||
use catcher\CatchResponse;
|
||||
|
||||
class Menus extends CatchController
|
||||
{
|
||||
protected $menus;
|
||||
|
||||
public function __construct(WechatMenusRepository $repository)
|
||||
{
|
||||
$this->menus = $repository;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return CatchResponse::success($this->menus->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @time 2020年06月26日
|
||||
* @param CatchRequest $request
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function save(CatchRequest $request)
|
||||
{
|
||||
return CatchResponse::success($this->menus->storeBy($request->param()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @time 2020年06月26日
|
||||
* @param $id
|
||||
* @param CatchRequest $request
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function update($id, CatchRequest $request)
|
||||
{
|
||||
return CatchResponse::success($this->menus->updateBy($id, $request->param()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @time 2020年06月26日
|
||||
* @param $id
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
return CatchResponse::success($this->menus->deleteBy($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步
|
||||
*
|
||||
* @time 2020年06月26日
|
||||
* @return \think\response\Json
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function sync()
|
||||
{
|
||||
return CatchResponse::success($this->menus->sync());
|
||||
}
|
||||
}
|
@@ -1,35 +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\wechat\controller;
|
||||
|
||||
use catchAdmin\wechat\library\messages\Factory;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\library\WeChat;
|
||||
use think\Request;
|
||||
|
||||
class Message extends CatchController
|
||||
{
|
||||
public function done(Request $request)
|
||||
{
|
||||
$app = WeChat::officialAccount();
|
||||
|
||||
if ($request->isPost()) {
|
||||
$app->server->push(function ($message) {
|
||||
file_put_contents('root.txt', var_export($message, true), FILE_APPEND);
|
||||
if ($res = Factory::make($message)->reply()) {
|
||||
return $res;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$app->server->serve()->send();exit;
|
||||
}
|
||||
}
|
@@ -1,74 +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\wechat\controller;
|
||||
|
||||
use catchAdmin\wechat\repository\WechatReplyRepository;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\base\CatchRequest;
|
||||
use catcher\CatchResponse;
|
||||
|
||||
class Reply extends CatchController
|
||||
{
|
||||
protected $reply;
|
||||
|
||||
public function __construct(WechatReplyRepository $reply)
|
||||
{
|
||||
$this->reply = $reply;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @time 2020年06月29日
|
||||
* @param CatchRequest $request
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function index(CatchRequest $request)
|
||||
{
|
||||
return CatchResponse::paginate($this->reply->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @time 2020年06月29日
|
||||
* @param CatchRequest $request
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function save(CatchRequest $request)
|
||||
{
|
||||
return CatchResponse::success($this->reply->storeBy($request->param()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @time 2020年06月29日
|
||||
* @param $id
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
return CatchResponse::success($this->reply->deleteBy($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用启用
|
||||
*
|
||||
* @time 2020年06月29日
|
||||
* @param $id
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function disOrEnable($id)
|
||||
{
|
||||
return CatchResponse::success($this->reply->disOrEnable($id));
|
||||
}
|
||||
}
|
@@ -1,102 +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\wechat\controller;
|
||||
|
||||
use think\Request;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\base\CatchController;
|
||||
use catchAdmin\wechat\repository\WechatTagsRepository;
|
||||
|
||||
class Tags extends CatchController
|
||||
{
|
||||
protected $repository;
|
||||
|
||||
public function __construct(WechatTagsRepository $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @time 2020/06/21 14:45
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
if ($request->has('all')) {
|
||||
return CatchResponse::success($this->repository->getList($request->param()));
|
||||
}
|
||||
|
||||
return CatchResponse::paginate($this->repository->getList($request->param()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @time 2020/06/21 14:45
|
||||
* @param Request Request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
return CatchResponse::success($this->repository->storeBy($request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取
|
||||
*
|
||||
* @time 2020/06/21 14:45
|
||||
* @param $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
return CatchResponse::success($this->repository->findBy($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @time 2020/06/21 14:45
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
return CatchResponse::success($this->repository->updateBy($id, $request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @time 2020/06/21 14:45
|
||||
* @param $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
return CatchResponse::success($this->repository->deleteBy($id));
|
||||
}
|
||||
|
||||
public function sync()
|
||||
{
|
||||
return CatchResponse::success($this->repository->sync());
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,59 +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\wechat\controller;
|
||||
|
||||
use catchAdmin\system\model\Attachments;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\base\CatchRequest;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\CatchUpload;
|
||||
|
||||
class Upload extends CatchController
|
||||
{
|
||||
protected $attachment;
|
||||
|
||||
public function __construct(Attachments $attachment)
|
||||
{
|
||||
$this->attachment = $attachment;
|
||||
}
|
||||
|
||||
/**
|
||||
* image upload
|
||||
*
|
||||
* @time 2020年01月25日
|
||||
* @param CatchRequest $request
|
||||
* @param CatchUpload $upload
|
||||
* @return \think\response\Json
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function image(CatchRequest $request, CatchUpload $upload): \think\response\Json
|
||||
{
|
||||
$images = $request->file();
|
||||
|
||||
return CatchResponse::success($upload->setDriver(CatchUpload::LOCAL)->checkImages($images)->multiUpload($images['image']));
|
||||
}
|
||||
|
||||
/**
|
||||
* file upload
|
||||
*
|
||||
* @time 2020年01月25日
|
||||
* @param CatchRequest $request
|
||||
* @param CatchUpload $upload
|
||||
* @return \think\response\Json
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function file(CatchRequest $request, CatchUpload $upload): \think\response\Json
|
||||
{
|
||||
$files = $request->file();
|
||||
|
||||
return CatchResponse::success($upload->setDriver(CatchUpload::LOCAL)->checkFiles($files)->multiUpload($files['file']));
|
||||
}
|
||||
}
|
@@ -1,101 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @filename WechatUsersRepository.php
|
||||
* @date 2020/6/7
|
||||
* @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\wechat\controller;
|
||||
|
||||
use catchAdmin\wechat\library\SyncWechatUsers;
|
||||
use catchAdmin\wechat\repository\WechatUsersRepository;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\library\WeChat;
|
||||
use catcher\Utils;
|
||||
use think\facade\Console;
|
||||
use think\Request;
|
||||
|
||||
class Users extends CatchController
|
||||
{
|
||||
protected $user;
|
||||
|
||||
public function __construct(WechatUsersRepository $users)
|
||||
{
|
||||
$this->user = $users;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @time 2020年06月19日
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return CatchResponse::paginate($this->user->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*
|
||||
* @time 2020年06月19日
|
||||
* @param $id
|
||||
* @param $remark
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function remark($id, $remark)
|
||||
{
|
||||
return CatchResponse::success($this->user->remark($id, $remark));
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉黑
|
||||
*
|
||||
* @time 2020年06月19日
|
||||
* @param $id
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function block($id)
|
||||
{
|
||||
return CatchResponse::success($this->user->block($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 贴标签
|
||||
*
|
||||
* @time 2020年06月26日
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function tag($id, Request $request)
|
||||
{
|
||||
return CatchResponse::success($this->user->tag($id, $request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户同步
|
||||
*
|
||||
* @time 2020年06月26日
|
||||
* @param SyncWechatUsers $users
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function sync(SyncWechatUsers $users)
|
||||
{
|
||||
return CatchResponse::success($users->start(), 'success');
|
||||
}
|
||||
|
||||
public function subscribe()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function unsubscribe()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class WechatUsers 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('wechat_users',array('engine'=>'Innodb', 'collation' => 'utf8mb4_general_ci', 'comment' => ' 微信用户表', 'signed' => false));
|
||||
$table->addColumn('nickname', 'string',array('limit' => 30,'default'=>'','comment'=>'用户名'))
|
||||
->addColumn('avatar', 'string',array('limit' => 255,'comment'=>'用户头像'))
|
||||
->addColumn('openid', 'string',array('limit' => 35, 'comment'=>'openid'))
|
||||
->addColumn('language', 'string',array('limit' => 20, 'comment'=>'语言'))
|
||||
->addColumn('country', 'string',array('limit' => 20, 'comment'=>'国家'))
|
||||
->addColumn('province', 'string',array('limit' => 20, 'comment'=>'省份'))
|
||||
->addColumn('city', 'string',array('limit' => 20, 'comment'=>'城市'))
|
||||
->addColumn('subscribe', 'boolean',array('limit' => 1,'default'=> 1,'comment'=>'用户状态 0 取消订阅 1 订阅'))
|
||||
->addColumn('block', 'boolean',array('limit' => 1,'default'=> 1,'comment'=>'拉黑状态 1 正常 2 拉黑'))
|
||||
->addColumn('subscribe_time', 'integer',array('default'=>0,'comment'=>'订阅时间', 'signed' => false))
|
||||
->addColumn('subscribe_scene', 'string', ['limit' => 50, 'comment' => '订阅场景 ADD_SCENE_SEARCH 公众号搜索,ADD_SCENE_ACCOUNT_MIGRATION 公众号迁移,ADD_SCENE_PROFILE_CARD 名片分享,ADD_SCENE_QR_CODE 扫描二维码,ADD_SCENE_PROFILE_LINK 图文页内名称点击,ADD_SCENE_PROFILE_ITEM 图文页右上角菜单,ADD_SCENE_PAID 支付后关注,ADD_SCENE_WECHAT_ADVERTISEMENT 微信广告,ADD_SCENE_OTHERS 其他'])
|
||||
->addColumn('unionid', 'string', ['limit' => 255, 'comment' => '用户平台唯一身份认证'])
|
||||
->addColumn('sex', 'boolean',array('limit' => 1,'default'=> 1,'comment'=>'用户状态 1 男 2 女 0 未知'))
|
||||
->addColumn('remark', 'string', ['limit' => 255, 'comment' => '备注'])
|
||||
->addColumn('groupid', 'integer', ['limit' => 0, 'comment' => '分组ID'])
|
||||
->addColumn('tagid_list', 'string',['limit' => 50, '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'=>'删除状态,0未删除 >0 已删除', 'signed' => false))
|
||||
->create();
|
||||
}
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class WechatUserHasTags 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('wechat_user_has_tags', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '用户标签关联表' ,'signed' => true ]);
|
||||
$table->addColumn('tag_id', 'integer', ['limit' => MysqlAdapter::INT_SMALL,'null' => true,'signed' => false,'comment' => '微信 tagId',])
|
||||
->addColumn('user_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '更新时间',])
|
||||
->create();
|
||||
}
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class WechatTags 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('wechat_tags', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '微信标签表' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
|
||||
$table->addColumn('tag_id', 'integer', ['limit' => MysqlAdapter::INT_SMALL,'null' => true,'signed' => false,'comment' => '微信 tagId',])
|
||||
->addColumn('name', 'string', ['limit' => 30,'null' => true,'comment' => '标签名称',])
|
||||
->addColumn('fans_amount', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '粉丝数量',])
|
||||
->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建时间',])
|
||||
->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '更新时间',])
|
||||
->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '软删除',])
|
||||
->addIndex(['tag_id'], ['unique' => true,'name' => 'unique_tag_id'])
|
||||
->create();
|
||||
}
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class WechatMaterial 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('wechat_material', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '微信素材' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
|
||||
$table->addColumn('tag_id', 'integer', ['limit' => MysqlAdapter::INT_SMALL,'null' => true,'signed' => false,'comment' => '微信 tagId',])
|
||||
->addColumn('name', 'string', ['limit' => 30,'null' => true,'comment' => '标签名称',])
|
||||
->addColumn('fans_amount', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '粉丝数量',])
|
||||
->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建时间',])
|
||||
->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '更新时间',])
|
||||
->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '软删除',])
|
||||
->addIndex(['tag_id'], ['unique' => true,'name' => 'unique_tag_id'])
|
||||
->create();
|
||||
}
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class WechatMenus 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('wechat_menus', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '微信菜单' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
|
||||
$table->addColumn('name', 'string', ['limit' => 30,'null' => true,'comment' => '菜单名称',])
|
||||
->addColumn('parent_id', 'integer', ['limit' => MysqlAdapter::INT_SMALL,'null' => false,'default' => 0,'signed' => true,'comment' => '父级ID',])
|
||||
->addColumn('type', 'string', ['null' => false, 'limit' => 100, 'comment' => '类型',])
|
||||
->addColumn('key', 'string', ['null' => false, 'limit' => 30, 'comment' => 'key',])
|
||||
->addColumn('url', 'string', ['default' => '', 'limit' => 255, 'comment' => 'view 类型 url 链接',])
|
||||
->addColumn('appid', 'string', ['default' => '', 'limit' => 100, 'comment' => '小程序 appid',])
|
||||
->addColumn('pagepath', 'string', ['default' => '', 'limit' => 255, 'comment' => '小程序页面',])
|
||||
->addColumn('media_id', 'string', ['default' => '', 'limit' => 100, 'comment' => '调用新增永久素材接口返回的合法media_id'])
|
||||
->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建时间',])
|
||||
->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '更新时间',])
|
||||
->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '软删除',])
|
||||
->create();
|
||||
}
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class WechatGraphic 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('wechat_graphic', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '微信图文管理' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
|
||||
$table->addColumn('title', 'string', ['limit' => 255, 'comment' => '标题',]) ->addColumn('author', 'string', ['default' => 'admin', 'limit' => 20,'signed' => true,'comment' => '作者'])
|
||||
->addColumn('parent_id', 'integer', ['default' => 0, 'limit' => MysqlAdapter::INT_REGULAR,'signed' => true,'comment' => '图文第一篇'])
|
||||
->addColumn('cover', 'string', ['limit' => 255,'signed' => true,'comment' => '封面'])
|
||||
->addColumn('content', 'text', ['comment' => '内容'])
|
||||
->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建人ID',])
|
||||
->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建时间',])
|
||||
->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '更新时间',])
|
||||
->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '软删除',])
|
||||
->create();
|
||||
}
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class WechatReply 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('wechat_reply', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '微信回复' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
|
||||
$table->addColumn('keyword', 'string', ['limit' => 255, 'default' => '', 'comment' => '关键字',])
|
||||
->addColumn('media_id', 'string', ['default' => '', 'limit' => 100,'signed' => true,'comment' => '微信资源ID'])
|
||||
->addColumn('media_url', 'string', ['default' => '', 'limit' => 255,'signed' => true,'comment' => '本地资源 URL'])
|
||||
->addColumn('image_url', 'string', ['default' => '', 'limit' => 255,'signed' => true,'comment' => '本地图片 URL'])
|
||||
->addColumn('title', 'string', ['limit' => '255', 'default' => '', 'comment' => '标题'])
|
||||
->addColumn('content', 'string', ['limit' => 1000, 'comment' => '内容', 'default' => '',])
|
||||
->addColumn('type', 'integer', ['limit' => MysqlAdapter::INT_TINY,'null' => false,'default' => 1,'signed' => true,'comment' => '1文字 2图文 3图片 4音乐 5视频 6语音 7转客服',])
|
||||
->addColumn('status', 'integer', ['limit' => MysqlAdapter::INT_TINY,'default' => 1,'signed' => true,'comment' => '1 正常 2 禁用',])
|
||||
->addColumn('rule_type', 'integer', ['limit' => MysqlAdapter::INT_TINY,'null' => false,'default' => 1,'signed' => true,'comment' => '1 关键字 2 关注 3 默认',])
|
||||
->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建人ID',])
|
||||
->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建时间',])
|
||||
->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '更新时间',])
|
||||
->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '软删除',])
|
||||
->create();
|
||||
}
|
||||
}
|
@@ -1,664 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Seeder;
|
||||
|
||||
class WechatPermissionSeed 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' => 66,
|
||||
'permission_name' => '微信管理',
|
||||
'parent_id' => 0,
|
||||
'level' => '',
|
||||
'route' => '/wechat',
|
||||
'icon' => 'wechat',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'wechat',
|
||||
'component' => 'routeView',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1591603025,
|
||||
'updated_at' => 1593044101,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 67,
|
||||
'permission_name' => '微信菜单',
|
||||
'parent_id' => 66,
|
||||
'level' => '66',
|
||||
'route' => '/wechat/menus',
|
||||
'icon' => 'table',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'menus',
|
||||
'component' => 'menus',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1591603088,
|
||||
'updated_at' => 1591603427,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 95,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 67,
|
||||
'level' => '66-67',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'menus@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304908,
|
||||
'updated_at' => 1593304908,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 96,
|
||||
'permission_name' => '保存',
|
||||
'parent_id' => 67,
|
||||
'level' => '66-67',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'menus@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304915,
|
||||
'updated_at' => 1593304915,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'id' => 97,
|
||||
'permission_name' => '更新',
|
||||
'parent_id' => 67,
|
||||
'level' => '66-67',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'menus@update',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304923,
|
||||
'updated_at' => 1593304923,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'id' => 98,
|
||||
'permission_name' => '删除',
|
||||
'parent_id' => 67,
|
||||
'level' => '66-67',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'menus@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304929,
|
||||
'updated_at' => 1593304929,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
4 =>
|
||||
array (
|
||||
'id' => 99,
|
||||
'permission_name' => '同步',
|
||||
'parent_id' => 67,
|
||||
'level' => '66-67',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'menus@sync',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304938,
|
||||
'updated_at' => 1593304938,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 75,
|
||||
'permission_name' => '用户管理',
|
||||
'parent_id' => 66,
|
||||
'level' => '66',
|
||||
'route' => '/wechat/users',
|
||||
'icon' => 'team',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'users',
|
||||
'component' => 'pageView',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1592624761,
|
||||
'updated_at' => 1592631716,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 76,
|
||||
'permission_name' => '微信用户',
|
||||
'parent_id' => 75,
|
||||
'level' => '66-75',
|
||||
'route' => '/wechat/users',
|
||||
'icon' => 'user',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'users',
|
||||
'component' => 'wechatUsers',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1592624799,
|
||||
'updated_at' => 1592624799,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 90,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 76,
|
||||
'level' => '66-75-76',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'users@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304869,
|
||||
'updated_at' => 1593304869,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 91,
|
||||
'permission_name' => '标记',
|
||||
'parent_id' => 76,
|
||||
'level' => '66-75-76',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'users@remark',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304876,
|
||||
'updated_at' => 1593304876,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'id' => 92,
|
||||
'permission_name' => '拉黑',
|
||||
'parent_id' => 76,
|
||||
'level' => '66-75-76',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'users@block',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304884,
|
||||
'updated_at' => 1593304884,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'id' => 93,
|
||||
'permission_name' => '打标签',
|
||||
'parent_id' => 76,
|
||||
'level' => '66-75-76',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'users@tag',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304892,
|
||||
'updated_at' => 1593304892,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
4 =>
|
||||
array (
|
||||
'id' => 94,
|
||||
'permission_name' => '同步',
|
||||
'parent_id' => 76,
|
||||
'level' => '66-75-76',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'users@sync',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304900,
|
||||
'updated_at' => 1593304900,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 77,
|
||||
'permission_name' => '微信标签',
|
||||
'parent_id' => 75,
|
||||
'level' => '66-75',
|
||||
'route' => '/wechat/tags',
|
||||
'icon' => 'tags',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'tags',
|
||||
'component' => 'wechatTags',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1592722634,
|
||||
'updated_at' => 1593304802,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 84,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 77,
|
||||
'level' => '66-75-77',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'wechatTags@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304575,
|
||||
'updated_at' => 1593304575,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 85,
|
||||
'permission_name' => '新增',
|
||||
'parent_id' => 77,
|
||||
'level' => '66-75-77',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'wechatTags@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304592,
|
||||
'updated_at' => 1593304592,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'id' => 86,
|
||||
'permission_name' => '获取',
|
||||
'parent_id' => 77,
|
||||
'level' => '66-75-77',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'tags@read',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304830,
|
||||
'updated_at' => 1593304830,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'id' => 87,
|
||||
'permission_name' => '更新',
|
||||
'parent_id' => 77,
|
||||
'level' => '66-75-77',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'tags@update',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304837,
|
||||
'updated_at' => 1593304837,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
4 =>
|
||||
array (
|
||||
'id' => 88,
|
||||
'permission_name' => '删除',
|
||||
'parent_id' => 77,
|
||||
'level' => '66-75-77',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'tags@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304846,
|
||||
'updated_at' => 1593304846,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
5 =>
|
||||
array (
|
||||
'id' => 89,
|
||||
'permission_name' => '同步',
|
||||
'parent_id' => 77,
|
||||
'level' => '66-75-77',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'tags@sync',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304859,
|
||||
'updated_at' => 1593304859,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'id' => 78,
|
||||
'permission_name' => '图文管理',
|
||||
'parent_id' => 66,
|
||||
'level' => '66',
|
||||
'route' => '/wechat/graphic',
|
||||
'icon' => 'gold',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'graphic',
|
||||
'component' => 'wechatGraphic',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 2,
|
||||
'keepalive' => 1,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593227704,
|
||||
'updated_at' => 1593227704,
|
||||
'deleted_at' => 0,
|
||||
'children' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'id' => 79,
|
||||
'permission_name' => '新增',
|
||||
'parent_id' => 78,
|
||||
'level' => '66-78',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'graphic@save',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304490,
|
||||
'updated_at' => 1593304490,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'id' => 80,
|
||||
'permission_name' => '获取',
|
||||
'parent_id' => 78,
|
||||
'level' => '66-78',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'graphic@read',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304510,
|
||||
'updated_at' => 1593304510,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'id' => 81,
|
||||
'permission_name' => '列表',
|
||||
'parent_id' => 78,
|
||||
'level' => '66-78',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'graphic@index',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 2,
|
||||
'created_at' => 1593304520,
|
||||
'updated_at' => 1593304520,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'id' => 82,
|
||||
'permission_name' => '更新',
|
||||
'parent_id' => 78,
|
||||
'level' => '66-78',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'graphic@update',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304530,
|
||||
'updated_at' => 1593304530,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
4 =>
|
||||
array (
|
||||
'id' => 83,
|
||||
'permission_name' => '删除',
|
||||
'parent_id' => 78,
|
||||
'level' => '66-78',
|
||||
'route' => '',
|
||||
'icon' => '',
|
||||
'module' => 'wechat',
|
||||
'creator_id' => 1,
|
||||
'method' => 'get',
|
||||
'permission_mark' => 'graphic@delete',
|
||||
'component' => '',
|
||||
'redirect' => '',
|
||||
'hide_children_in_menu' => 1,
|
||||
'keepalive' => 1,
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'sort' => 1,
|
||||
'created_at' => 1593304537,
|
||||
'updated_at' => 1593304537,
|
||||
'deleted_at' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,173 +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\wechat\library;
|
||||
|
||||
use catchAdmin\wechat\model\WechatUsers;
|
||||
use catcher\exceptions\FailedException;
|
||||
use catcher\library\ProgressBar;
|
||||
use catcher\library\WeChat;
|
||||
use catcher\Utils;
|
||||
use think\Db;
|
||||
|
||||
class SyncWechatUsers
|
||||
{
|
||||
protected $officialAccount;
|
||||
|
||||
public function start()
|
||||
{
|
||||
$this->officialAccount = WeChat::officialAccount();
|
||||
|
||||
$latest = WechatUsers::order('subscribe_time')->find();
|
||||
|
||||
if ($latest) {
|
||||
throw new FailedException('暂时无法增量同步');
|
||||
}
|
||||
|
||||
$this->sync($latest ? $latest->openid : null);
|
||||
|
||||
$this->syncTags();
|
||||
}
|
||||
|
||||
protected function syncTags()
|
||||
{
|
||||
$users = WechatUsers::cursor();
|
||||
|
||||
foreach ($users as $user) {
|
||||
if ($user->tag_list) {
|
||||
$tagIds = Utils::stringToArrayBy($user->tag_list);
|
||||
$relate = [];
|
||||
|
||||
foreach ($tagIds as $id) {
|
||||
$relate[] = [
|
||||
'user_id' => $user->id,
|
||||
'tag_id' => $id,
|
||||
];
|
||||
}
|
||||
|
||||
Db::name('wechat_user_has_tags')->insertAll($relate);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 同步
|
||||
*
|
||||
* @time 2020年06月20日
|
||||
* @param $nextOpenid
|
||||
* @return void
|
||||
*/
|
||||
protected function sync($nextOpenid)
|
||||
{
|
||||
$userOpenids = $this->getWechatUserOpenids($nextOpenid);
|
||||
|
||||
if ($userOpenids['next_openid']) {
|
||||
$this->getUsersBy($userOpenids['data']['openid']);
|
||||
$this->sync($userOpenids['next_openid']);
|
||||
} else {
|
||||
if ($userOpenids['count']) {
|
||||
$openids = $userOpenids['data']['openid'];
|
||||
$this->getUsersBy($openids);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户
|
||||
*
|
||||
* @time 2020年06月20日
|
||||
* @param $openids
|
||||
* @return void
|
||||
*/
|
||||
protected function getUsersBy($openids)
|
||||
{
|
||||
$chunks = array_chunk($openids, $this->getChunkSize($openids));
|
||||
|
||||
$total = count($chunks);
|
||||
|
||||
$bar = new ProgressBar($this->output, $total);
|
||||
|
||||
$bar->setHeader('[开始同步]');
|
||||
|
||||
$bar->start();
|
||||
foreach ($chunks as $chunk) {
|
||||
$users = $this->officialAccount->user->select($chunk);
|
||||
$this->syncToDatabase($users);
|
||||
$bar->advance();
|
||||
}
|
||||
$bar->finished();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 同步到数据库
|
||||
*
|
||||
* @time 2020年06月20日
|
||||
* @param $users
|
||||
* @return void
|
||||
*/
|
||||
protected function syncToDatabase($users)
|
||||
{
|
||||
$users = $users['user_info_list'];
|
||||
|
||||
foreach ($users as &$user) {
|
||||
$user['avatar'] = $user['headimgurl'];
|
||||
$user['unionid'] = $user['unionid'] ?? '';
|
||||
$user['created_at'] = time();
|
||||
$user['updated_at'] = time();
|
||||
if (!empty($user['tagid_list'])) {
|
||||
$user['tagid_list'] = trim(implode(',', $user['tagid_list']), ',');
|
||||
}
|
||||
unset($user['headimgurl']);
|
||||
unset($user['qr_scene'], $user['qr_scene_str']);
|
||||
}
|
||||
|
||||
WechatUsers::insertAll($users);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 chunk size
|
||||
*
|
||||
* @time 2020年06月20日
|
||||
* @param $openids
|
||||
* @return int
|
||||
*/
|
||||
protected function getChunkSize($openids)
|
||||
{
|
||||
$size = count($openids);
|
||||
|
||||
if ($size < 10) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ($size > 10 && $size < 100) {
|
||||
return 10;
|
||||
}
|
||||
|
||||
if ($size > 100 && $size < 1000) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
if ($size > 1000 && $size < 10000) {
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信 openids
|
||||
*
|
||||
* @time 2020年06月20日
|
||||
* @param $nextOpenId
|
||||
* @return mixed
|
||||
*/
|
||||
public function getWechatUserOpenids($nextOpenId)
|
||||
{
|
||||
return $this->officialAccount->user->list($nextOpenId);
|
||||
}
|
||||
}
|
@@ -1,46 +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\wechat\library\messages;
|
||||
|
||||
class Factory
|
||||
{
|
||||
/**
|
||||
* 对象生产
|
||||
*
|
||||
* @time 2020年06月26日
|
||||
* @param $message
|
||||
* @return mixed
|
||||
*/
|
||||
public static function make($message)
|
||||
{
|
||||
return self::parse($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析
|
||||
*
|
||||
* @time 2020年06月26日
|
||||
* @param $message
|
||||
* @return mixed
|
||||
*/
|
||||
protected static function parse($message)
|
||||
{
|
||||
// 事件类型
|
||||
if ($message['MsgType'] == 'event') {
|
||||
$event = __NAMESPACE__ . '\\events\\' . ucfirst($message['Event']);
|
||||
|
||||
return new $event($message);
|
||||
}
|
||||
|
||||
$messageClass = __NAMESPACE__ . '\\' . ucfirst($message['MsgType']);
|
||||
return new $messageClass($message);
|
||||
}
|
||||
}
|
@@ -1,19 +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\wechat\library\messages;
|
||||
|
||||
class Image extends Message
|
||||
{
|
||||
public function reply()
|
||||
{
|
||||
// TODO: Implement reply() method.
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user