first commit
This commit is contained in:
commit
a1037a21b5
1
.example.env
Executable file
1
.example.env
Executable file
@ -0,0 +1 @@
|
||||
APP_DEBUG=true
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=likeadmin
DB_USERNAME=root
DB_PASSWORD=root
SESSION_DRIVER=file
REDIS_CONNECTION=default
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
REDIS_DB=24
YLY_PARTNER=25991
YLY_API_KEY=d955cc2296d69b4094c6465aad360dc6b19a8c77
YLY_REQUEST_URL=http://open.10ss.net:8888
UNIQUE_IDENTIFICATION = "11d3"
DEMO_ENV = ""
|
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/.idea
|
||||
/.vscode
|
||||
/vendor
|
||||
*.log
|
||||
.env
|
||||
/tests/tmp
|
||||
/tests/.phpunit.result.cache
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 walkor<walkor@workerman.net> and contributors (see https://github.com/walkor/webman/contributors)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
20
README.md
Normal file
20
README.md
Normal file
@ -0,0 +1,20 @@
|
||||
# webman
|
||||
|
||||
High performance HTTP Service Framework for PHP based on [Workerman](https://github.com/walkor/workerman).
|
||||
|
||||
# Manual (文档)
|
||||
|
||||
https://www.workerman.net/doc/webman
|
||||
|
||||
# Home page (主页)
|
||||
https://www.workerman.net/webman
|
||||
|
||||
|
||||
# Benchmarks (压测)
|
||||
|
||||
https://www.techempower.com/benchmarks/#section=test&runid=9716e3cd-9e53-433c-b6c5-d2c48c9593c1&hw=ph&test=db&l=zg24n3-1r&a=2
|
||||

|
||||
|
||||
## LICENSE
|
||||
|
||||
MIT
|
87
app/BaseController.php
Executable file
87
app/BaseController.php
Executable file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app;
|
||||
|
||||
use think\exception\ValidateException;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 控制器基础类
|
||||
*/
|
||||
abstract class BaseController
|
||||
{
|
||||
/**
|
||||
* Request实例
|
||||
* @var \support\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
|
||||
/**
|
||||
* 是否批量验证
|
||||
* @var bool
|
||||
*/
|
||||
protected $batchValidate = false;
|
||||
|
||||
/**
|
||||
* 控制器中间件
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [];
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
* @access public
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->request = request();
|
||||
|
||||
// 控制器初始化
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
// 初始化
|
||||
protected function initialize()
|
||||
{}
|
||||
|
||||
/**
|
||||
* 验证数据
|
||||
* @access protected
|
||||
* @param array $data 数据
|
||||
* @param string|array $validate 验证器名或者验证规则数组
|
||||
* @param array $message 提示信息
|
||||
* @param bool $batch 是否批量验证
|
||||
* @return array|string|true
|
||||
* @throws ValidateException
|
||||
*/
|
||||
protected function validate(array $data, $validate, array $message = [], bool $batch = false)
|
||||
{
|
||||
if (is_array($validate)) {
|
||||
$v = new Validate();
|
||||
$v->rule($validate);
|
||||
} else {
|
||||
if (strpos($validate, '.')) {
|
||||
// 支持场景
|
||||
[$validate, $scene] = explode('.', $validate);
|
||||
}
|
||||
$class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate);
|
||||
$v = new $class();
|
||||
if (!empty($scene)) {
|
||||
$v->scene($scene);
|
||||
}
|
||||
}
|
||||
|
||||
$v->message($message);
|
||||
|
||||
// 是否批量验证
|
||||
if ($batch || $this->batchValidate) {
|
||||
$v->batch(true);
|
||||
}
|
||||
|
||||
return $v->failException(true)->check($data);
|
||||
}
|
||||
|
||||
|
||||
}
|
11
app/Request.php
Normal file
11
app/Request.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app;
|
||||
|
||||
|
||||
class Request extends \support\Request
|
||||
{
|
||||
// 全局过滤规则
|
||||
protected $filter = ['trim'];
|
||||
}
|
24
app/admin/controller/BaseAdminController.php
Normal file
24
app/admin/controller/BaseAdminController.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
use app\common\controller\BaseLikeAdminController;
|
||||
use app\common\lists\BaseDataLists;
|
||||
|
||||
class BaseAdminController extends BaseLikeAdminController
|
||||
{
|
||||
public $notNeedLogin = [];
|
||||
|
||||
protected $adminId = 0;
|
||||
protected $adminInfo = [];
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
if (isset($this->request->adminInfo) && $this->request->adminInfo) {
|
||||
$this->adminInfo = $this->request->adminInfo;
|
||||
$this->adminId = $this->request->adminInfo['admin_id'];
|
||||
}
|
||||
}
|
||||
}
|
59
app/admin/controller/ConfigController.php
Executable file
59
app/admin/controller/ConfigController.php
Executable file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\logic\auth\AuthLogic;
|
||||
use app\admin\logic\ConfigLogic;
|
||||
|
||||
/**
|
||||
* 配置控制器
|
||||
* Class ConfigController
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class ConfigController extends BaseAdminController
|
||||
{
|
||||
public $notNeedLogin = ['getConfig', 'dict'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 基础配置
|
||||
* @author 乔峰
|
||||
* @date 2021/12/31 11:01
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$data = ConfigLogic::getConfig();
|
||||
return $this->data($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 根据类型获取字典数据
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2022/9/27 19:10
|
||||
*/
|
||||
public function dict()
|
||||
{
|
||||
$type = $this->request->get('type', '');
|
||||
$data = ConfigLogic::getDictByType($type);
|
||||
return $this->data($data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
38
app/admin/controller/DownloadController.php
Normal file
38
app/admin/controller/DownloadController.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
use app\common\cache\ExportCache;
|
||||
use app\common\service\JsonService;
|
||||
use think\facade\Cache;
|
||||
|
||||
class DownloadController extends BaseAdminController
|
||||
{
|
||||
public $notNeedLogin = ['export'];
|
||||
|
||||
/**
|
||||
* @notes 导出文件
|
||||
* @author 段誉
|
||||
* @date 2022/11/24 16:10
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
//获取文件缓存的key
|
||||
$fileKey = request()->get('file');
|
||||
|
||||
//通过文件缓存的key获取文件储存的路径
|
||||
$exportCache = new ExportCache();
|
||||
$fileInfo = $exportCache->getFile($fileKey);
|
||||
|
||||
if (empty($fileInfo)) {
|
||||
return JsonService::fail('下载文件不存在');
|
||||
}
|
||||
|
||||
//下载前删除缓存
|
||||
Cache::delete($fileKey);
|
||||
|
||||
return download($fileInfo['src'] . $fileInfo['name'], $fileInfo['name']);
|
||||
}
|
||||
}
|
113
app/admin/controller/FileController.php
Normal file
113
app/admin/controller/FileController.php
Normal file
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
use app\admin\lists\file\FileCateLists;
|
||||
use app\admin\lists\file\FileLists;
|
||||
use app\admin\logic\FileLogic;
|
||||
use app\admin\validate\FileValidate;
|
||||
|
||||
class FileController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 文件列表
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:30
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new FileLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 文件移动成功
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:30
|
||||
*/
|
||||
public function move()
|
||||
{
|
||||
$params = (new FileValidate())->post()->goCheck('move');
|
||||
FileLogic::move($params);
|
||||
return $this->success('移动成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 重命名文件
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:31
|
||||
*/
|
||||
public function rename()
|
||||
{
|
||||
$params = (new FileValidate())->post()->goCheck('rename');
|
||||
FileLogic::rename($params);
|
||||
return $this->success('重命名成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除文件
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:31
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new FileValidate())->post()->goCheck('delete');
|
||||
FileLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 分类列表
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:31
|
||||
*/
|
||||
public function listCate()
|
||||
{
|
||||
return $this->dataLists(new FileCateLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加文件分类
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:31
|
||||
*/
|
||||
public function addCate()
|
||||
{
|
||||
$params = (new FileValidate())->post()->goCheck('addCate');
|
||||
FileLogic::addCate($params);
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑文件分类
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:31
|
||||
*/
|
||||
public function editCate()
|
||||
{
|
||||
$params = (new FileValidate())->post()->goCheck('editCate');
|
||||
FileLogic::editCate($params);
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除文件分类
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:32
|
||||
*/
|
||||
public function delCate()
|
||||
{
|
||||
$params = (new FileValidate())->post()->goCheck('id');
|
||||
FileLogic::delCate($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
}
|
58
app/admin/controller/LoginController.php
Executable file
58
app/admin/controller/LoginController.php
Executable file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\logic\LoginLogic;
|
||||
use app\admin\validate\LoginValidate;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* 管理员登录控制器
|
||||
* Class LoginController
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class LoginController extends BaseAdminController
|
||||
{
|
||||
public $notNeedLogin = ['account'];
|
||||
|
||||
/**
|
||||
* @notes 账号登录
|
||||
* @date 2021/6/30 17:01
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 令狐冲
|
||||
*/
|
||||
public function account()
|
||||
{
|
||||
$params = (new LoginValidate())->post()->goCheck();
|
||||
return $this->data((new LoginLogic())->login($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 退出登录
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 令狐冲
|
||||
* @date 2021/7/8 00:36
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
//退出登录情况特殊,只有成功的情况,也不需要token验证
|
||||
(new LoginLogic())->logout($this->adminInfo);
|
||||
return $this->success();
|
||||
}
|
||||
}
|
44
app/admin/controller/UploadController.php
Normal file
44
app/admin/controller/UploadController.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
use app\common\service\UploadService;
|
||||
use Exception;
|
||||
use Tinywan\Storage\Storage;
|
||||
|
||||
class UploadController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 上传图片
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 16:27
|
||||
*/
|
||||
public function image()
|
||||
{
|
||||
try {
|
||||
$cid = $this->request->post('cid', 0);
|
||||
$result = UploadService::image($cid);
|
||||
return $this->success('上传成功', $result);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 上传视频
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 16:27
|
||||
*/
|
||||
public function video()
|
||||
{
|
||||
try {
|
||||
$cid = $this->request->post('cid', 0);
|
||||
$result = UploadService::video($cid);
|
||||
return $this->success('上传成功', $result);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
37
app/admin/controller/WorkbenchController.php
Executable file
37
app/admin/controller/WorkbenchController.php
Executable file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\logic\WorkbenchLogic;
|
||||
|
||||
/**
|
||||
* 工作台
|
||||
* Class WorkbenchCotroller
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class WorkbenchController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 工作台
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 17:01
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$result = WorkbenchLogic::index();
|
||||
return $this->data($result);
|
||||
}
|
||||
}
|
127
app/admin/controller/auth/AdminController.php
Executable file
127
app/admin/controller/auth/AdminController.php
Executable file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\auth;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\auth\AdminLists;
|
||||
use app\admin\validate\auth\AdminValidate;
|
||||
use app\admin\logic\auth\AdminLogic;
|
||||
use app\admin\validate\auth\editSelfValidate;
|
||||
|
||||
/**
|
||||
* 管理员控制器
|
||||
* Class AdminController
|
||||
* @package app\admin\controller\auth
|
||||
*/
|
||||
class AdminController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 查看管理员列表
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 9:55
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new AdminLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加管理员
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 10:21
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new AdminValidate())->post()->goCheck('add');
|
||||
$result = AdminLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(AdminLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑管理员
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 11:03
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new AdminValidate())->post()->goCheck('edit');
|
||||
$result = AdminLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(AdminLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除管理员
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 11:03
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new AdminValidate())->post()->goCheck('delete');
|
||||
$result = AdminLogic::delete($params);
|
||||
if (true === $result) {
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(AdminLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 查看管理员详情
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 11:07
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new AdminValidate())->goCheck('detail');
|
||||
$result = AdminLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取当前管理员信息
|
||||
* @author 乔峰
|
||||
* @date 2021/12/31 10:53
|
||||
*/
|
||||
public function mySelf()
|
||||
{
|
||||
$result = AdminLogic::detail(['id' => $this->adminId], 'auth');
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑超级管理员信息
|
||||
* @author 乔峰
|
||||
* @date 2022/4/8 17:54
|
||||
*/
|
||||
public function editSelf()
|
||||
{
|
||||
$params = (new editSelfValidate())->post()->goCheck('', ['admin_id' => $this->adminId]);
|
||||
$result = AdminLogic::editSelf($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
}
|
134
app/admin/controller/auth/MenuController.php
Executable file
134
app/admin/controller/auth/MenuController.php
Executable file
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\auth;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\auth\MenuLists;
|
||||
use app\admin\logic\auth\MenuLogic;
|
||||
use app\admin\validate\auth\MenuValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 系统菜单权限
|
||||
* Class MenuController
|
||||
* @package app\admin\controller\setting\system
|
||||
*/
|
||||
class MenuController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取菜单路由
|
||||
* @author 乔峰
|
||||
* @date 2022/6/29 17:41
|
||||
*/
|
||||
public function route()
|
||||
{
|
||||
$result = MenuLogic::getMenuByAdminId($this->adminId);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取菜单列表
|
||||
* @author 乔峰
|
||||
* @date 2022/6/29 17:23
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new MenuLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 菜单详情
|
||||
* @author 乔峰
|
||||
* @date 2022/6/30 10:07
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new MenuValidate())->goCheck('detail');
|
||||
return $this->data(MenuLogic::detail($params));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加菜单
|
||||
* @author 乔峰
|
||||
* @date 2022/6/30 10:07
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new MenuValidate())->post()->goCheck('add');
|
||||
MenuLogic::add($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑菜单
|
||||
* @author 乔峰
|
||||
* @date 2022/6/30 10:07
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new MenuValidate())->post()->goCheck('edit');
|
||||
MenuLogic::edit($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除菜单
|
||||
* @author 乔峰
|
||||
* @date 2022/6/30 10:07
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new MenuValidate())->post()->goCheck('delete');
|
||||
MenuLogic::delete($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 更新状态
|
||||
* @author 乔峰
|
||||
* @date 2022/7/6 17:04
|
||||
*/
|
||||
public function updateStatus()
|
||||
{
|
||||
$params = (new MenuValidate())->post()->goCheck('status');
|
||||
MenuLogic::updateStatus($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取菜单数据
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2022/10/13 11:03
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
$result = MenuLogic::getAllData();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
118
app/admin/controller/auth/RoleController.php
Executable file
118
app/admin/controller/auth/RoleController.php
Executable file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\auth;
|
||||
|
||||
use app\admin\{
|
||||
logic\auth\RoleLogic,
|
||||
lists\auth\RoleLists,
|
||||
validate\auth\RoleValidate,
|
||||
controller\BaseAdminController
|
||||
};
|
||||
|
||||
/**
|
||||
* 角色控制器
|
||||
* Class RoleController
|
||||
* @package app\admin\controller\auth
|
||||
*/
|
||||
class RoleController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 查看角色列表
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 11:49
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new RoleLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加权限
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 11:49
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new RoleValidate())->post()->goCheck('add');
|
||||
$res = RoleLogic::add($params);
|
||||
if (true === $res) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(RoleLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑角色
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 14:18
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new RoleValidate())->post()->goCheck('edit');
|
||||
$res = RoleLogic::edit($params);
|
||||
if (true === $res) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(RoleLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除角色
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 14:18
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new RoleValidate())->post()->goCheck('del');
|
||||
RoleLogic::delete($params['id']);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 查看角色详情
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 14:18
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new RoleValidate())->goCheck('detail');
|
||||
$detail = RoleLogic::detail($params['id']);
|
||||
return $this->data($detail);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取角色数据
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2022/10/13 10:39
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
$result = RoleLogic::getAllData();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
}
|
51
app/admin/controller/channel/AppSettingController.php
Executable file
51
app/admin/controller/channel/AppSettingController.php
Executable file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\channel;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\logic\channel\AppSettingLogic;
|
||||
|
||||
/**
|
||||
* APP设置控制器
|
||||
* Class AppSettingController
|
||||
* @package app\admin\controller\settings\app
|
||||
*/
|
||||
class AppSettingController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取App设置
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:24
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$result = AppSettingLogic::getConfig();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes App设置
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:25
|
||||
*/
|
||||
public function setConfig()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
AppSettingLogic::setConfig($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
}
|
50
app/admin/controller/channel/MnpSettingsController.php
Executable file
50
app/admin/controller/channel/MnpSettingsController.php
Executable file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\channel;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\logic\channel\MnpSettingsLogic;
|
||||
use app\admin\validate\channel\MnpSettingsValidate;
|
||||
|
||||
/**
|
||||
* 小程序设置
|
||||
* Class MnpSettingsController
|
||||
* @package app\admin\controller\channel
|
||||
*/
|
||||
class MnpSettingsController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 获取小程序配置
|
||||
* @author ljj
|
||||
* @date 2022/2/16 9:38 上午
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$result = (new MnpSettingsLogic())->getConfig();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置小程序配置
|
||||
* @author ljj
|
||||
* @date 2022/2/16 9:51 上午
|
||||
*/
|
||||
public function setConfig()
|
||||
{
|
||||
$params = (new MnpSettingsValidate())->post()->goCheck();
|
||||
(new MnpSettingsLogic())->setConfig($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
}
|
71
app/admin/controller/channel/OfficialAccountMenuController.php
Executable file
71
app/admin/controller/channel/OfficialAccountMenuController.php
Executable file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\channel;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\logic\channel\OfficialAccountMenuLogic;
|
||||
|
||||
/**
|
||||
* 微信公众号菜单控制器
|
||||
* Class OfficialAccountMenuController
|
||||
* @package app\admin\controller\channel
|
||||
*/
|
||||
class OfficialAccountMenuController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 保存菜单
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:41
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = OfficialAccountMenuLogic::save($params);
|
||||
if(false === $result) {
|
||||
return $this->fail(OfficialAccountMenuLogic::getError());
|
||||
}
|
||||
return $this->success('保存成功',[],1,1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 保存发布菜单
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:42
|
||||
*/
|
||||
public function saveAndPublish()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = OfficialAccountMenuLogic::saveAndPublish($params);
|
||||
if($result) {
|
||||
return $this->success('保存并发布成功',[],1,1);
|
||||
}
|
||||
return $this->fail(OfficialAccountMenuLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 查看菜单详情
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:42
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$result = OfficialAccountMenuLogic::detail();
|
||||
return $this->data($result);
|
||||
}
|
||||
}
|
138
app/admin/controller/channel/OfficialAccountReplyController.php
Executable file
138
app/admin/controller/channel/OfficialAccountReplyController.php
Executable file
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\channel;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\channel\OfficialAccountReplyLists;
|
||||
use app\admin\logic\channel\OfficialAccountReplyLogic;
|
||||
use app\admin\validate\channel\OfficialAccountReplyValidate;
|
||||
|
||||
/**
|
||||
* 微信公众号回复控制器
|
||||
* Class OfficialAccountReplyController
|
||||
* @package app\admin\controller\channel
|
||||
*/
|
||||
class OfficialAccountReplyController extends BaseAdminController
|
||||
{
|
||||
|
||||
public $notNeedLogin = ['index'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 查看回复列表(关注/关键词/默认)
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:58
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new OfficialAccountReplyLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加回复(关注/关键词/默认)
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:58
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new OfficialAccountReplyValidate())->post()->goCheck('add');
|
||||
$result = OfficialAccountReplyLogic::add($params);
|
||||
if ($result) {
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(OfficialAccountReplyLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 查看回复详情
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:58
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new OfficialAccountReplyValidate())->goCheck('detail');
|
||||
$result = OfficialAccountReplyLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑回复(关注/关键词/默认)
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:58
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new OfficialAccountReplyValidate())->post()->goCheck('edit');
|
||||
$result = OfficialAccountReplyLogic::edit($params);
|
||||
if ($result) {
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(OfficialAccountReplyLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除回复(关注/关键词/默认)
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:59
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new OfficialAccountReplyValidate())->post()->goCheck('delete');
|
||||
OfficialAccountReplyLogic::delete($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 更新排序
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:59
|
||||
*/
|
||||
public function sort()
|
||||
{
|
||||
$params = (new OfficialAccountReplyValidate())->post()->goCheck('sort');
|
||||
OfficialAccountReplyLogic::sort($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 更新状态
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:59
|
||||
*/
|
||||
public function status()
|
||||
{
|
||||
$params = (new OfficialAccountReplyValidate())->post()->goCheck('status');
|
||||
OfficialAccountReplyLogic::status($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 微信公众号回调
|
||||
* @throws \ReflectionException
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:59
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
OfficialAccountReplyLogic::index();
|
||||
}
|
||||
}
|
50
app/admin/controller/channel/OfficialAccountSettingController.php
Executable file
50
app/admin/controller/channel/OfficialAccountSettingController.php
Executable file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\channel;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\logic\channel\OfficialAccountSettingLogic;
|
||||
use app\admin\validate\channel\OfficialAccountSettingValidate;
|
||||
|
||||
/**
|
||||
* 公众号设置
|
||||
* Class OfficialAccountSettingController
|
||||
* @package app\admin\controller\channel
|
||||
*/
|
||||
class OfficialAccountSettingController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 获取公众号配置
|
||||
* @author ljj
|
||||
* @date 2022/2/16 10:09 上午
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$result = (new OfficialAccountSettingLogic())->getConfig();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置公众号配置
|
||||
* @author ljj
|
||||
* @date 2022/2/16 10:09 上午
|
||||
*/
|
||||
public function setConfig()
|
||||
{
|
||||
$params = (new OfficialAccountSettingValidate())->post()->goCheck();
|
||||
(new OfficialAccountSettingLogic())->setConfig($params);
|
||||
return $this->success('操作成功',[],1,1);
|
||||
}
|
||||
}
|
52
app/admin/controller/channel/OpenSettingController.php
Executable file
52
app/admin/controller/channel/OpenSettingController.php
Executable file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\channel;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\logic\channel\OpenSettingLogic;
|
||||
use app\admin\validate\channel\OpenSettingValidate;
|
||||
|
||||
/**
|
||||
* 微信开放平台
|
||||
* Class AppSettingController
|
||||
* @package app\admin\controller\settings\app
|
||||
*/
|
||||
class OpenSettingController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取微信开放平台设置
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 11:03
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$result = OpenSettingLogic::getConfig();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 微信开放平台设置
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 11:03
|
||||
*/
|
||||
public function setConfig()
|
||||
{
|
||||
$params = (new OpenSettingValidate())->post()->goCheck();
|
||||
OpenSettingLogic::setConfig($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
}
|
52
app/admin/controller/channel/WebPageSettingController.php
Executable file
52
app/admin/controller/channel/WebPageSettingController.php
Executable file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\channel;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\logic\channel\WebPageSettingLogic;
|
||||
use app\admin\validate\channel\WebPageSettingValidate;
|
||||
|
||||
/**
|
||||
* H5设置控制器
|
||||
* Class HFiveSettingController
|
||||
* @package app\admin\controller\settings\h5
|
||||
*/
|
||||
class WebPageSettingController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取H5设置
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:36
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$result = WebPageSettingLogic::getConfig();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes H5设置
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:36
|
||||
*/
|
||||
public function setConfig()
|
||||
{
|
||||
$params = (new WebPageSettingValidate())->post()->goCheck();
|
||||
WebPageSettingLogic::setConfig($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
}
|
128
app/admin/controller/crontab/CrontabController.php
Executable file
128
app/admin/controller/crontab/CrontabController.php
Executable file
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\crontab;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\crontab\CrontabLists;
|
||||
use app\admin\logic\crontab\CrontabLogic;
|
||||
use app\admin\validate\crontab\CrontabValidate;
|
||||
|
||||
/**
|
||||
* 定时任务控制器
|
||||
* Class CrontabController
|
||||
* @package app\admin\controller\crontab
|
||||
*/
|
||||
class CrontabController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 定时任务列表
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 14:27
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new CrontabLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加定时任务
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 14:27
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new CrontabValidate())->post()->goCheck('add');
|
||||
$result = CrontabLogic::add($params);
|
||||
if($result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(CrontabLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 查看定时任务详情
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 14:27
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new CrontabValidate())->goCheck('detail');
|
||||
$result = CrontabLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑定时任务
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 14:27
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new CrontabValidate())->post()->goCheck('edit');
|
||||
$result = CrontabLogic::edit($params);
|
||||
if($result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(CrontabLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除定时任务
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 14:27
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new CrontabValidate())->post()->goCheck('delete');
|
||||
$result = CrontabLogic::delete($params);
|
||||
if($result) {
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail('删除失败');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 操作定时任务
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 14:28
|
||||
*/
|
||||
public function operate()
|
||||
{
|
||||
$params = (new CrontabValidate())->post()->goCheck('operate');
|
||||
$result = CrontabLogic::operate($params);
|
||||
if($result) {
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(CrontabLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取规则执行时间
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 14:28
|
||||
*/
|
||||
public function expression()
|
||||
{
|
||||
$params = (new CrontabValidate())->goCheck('expression');
|
||||
$result = CrontabLogic::expression($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
}
|
127
app/admin/controller/dept/DeptController.php
Executable file
127
app/admin/controller/dept/DeptController.php
Executable file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\dept;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\logic\dept\DeptLogic;
|
||||
use app\admin\validate\dept\DeptValidate;
|
||||
|
||||
/**
|
||||
* 部门管理控制器
|
||||
* Class DeptController
|
||||
* @package app\admin\controller\dept
|
||||
*/
|
||||
class DeptController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 部门列表
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:07
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$result = DeptLogic::lists($params);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 上级部门
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/5/26 18:36
|
||||
*/
|
||||
public function leaderDept()
|
||||
{
|
||||
$result = DeptLogic::leaderDept();
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加部门
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:40
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new DeptValidate())->post()->goCheck('add');
|
||||
DeptLogic::add($params);
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑部门
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:41
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new DeptValidate())->post()->goCheck('edit');
|
||||
$result = DeptLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(DeptLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除部门
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:41
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new DeptValidate())->post()->goCheck('delete');
|
||||
DeptLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取部门详情
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:41
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new DeptValidate())->goCheck('detail');
|
||||
$result = DeptLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取部门数据
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/10/13 10:28
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
$result = DeptLogic::getAllData();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
112
app/admin/controller/dept/JobsController.php
Executable file
112
app/admin/controller/dept/JobsController.php
Executable file
@ -0,0 +1,112 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\dept;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\dept\JobsLists;
|
||||
use app\admin\logic\dept\JobsLogic;
|
||||
use app\admin\validate\dept\JobsValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 岗位管理控制器
|
||||
* Class JobsController
|
||||
* @package app\admin\controller\dept
|
||||
*/
|
||||
class JobsController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 岗位列表
|
||||
* @author 段誉
|
||||
* @date 2022/5/26 10:00
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new JobsLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加岗位
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:40
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new JobsValidate())->post()->goCheck('add');
|
||||
JobsLogic::add($params);
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑岗位
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:41
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new JobsValidate())->post()->goCheck('edit');
|
||||
$result = JobsLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(JobsLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除岗位
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:41
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new JobsValidate())->post()->goCheck('delete');
|
||||
JobsLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取岗位详情
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:41
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new JobsValidate())->goCheck('detail');
|
||||
$result = JobsLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取岗位数据
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/10/13 10:31
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
$result = JobsLogic::getAllData();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
67
app/admin/controller/notice/NoticeController.php
Executable file
67
app/admin/controller/notice/NoticeController.php
Executable file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\notice;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\notice\NoticeSettingLists;
|
||||
use app\admin\logic\notice\NoticeLogic;
|
||||
use app\admin\validate\notice\NoticeValidate;
|
||||
|
||||
/**
|
||||
* 通知控制器
|
||||
* Class NoticeController
|
||||
* @package app\admin\controller\notice
|
||||
*/
|
||||
class NoticeController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 查看通知设置列表
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 11:18
|
||||
*/
|
||||
public function settingLists()
|
||||
{
|
||||
return $this->dataLists(new NoticeSettingLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 查看通知设置详情
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 11:18
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new NoticeValidate())->goCheck('detail');
|
||||
$result = NoticeLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 通知设置
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 11:18
|
||||
*/
|
||||
public function set()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = NoticeLogic::set($params);
|
||||
if ($result) {
|
||||
return $this->success('设置成功');
|
||||
}
|
||||
return $this->fail(NoticeLogic::getError());
|
||||
}
|
||||
}
|
66
app/admin/controller/notice/SmsConfigController.php
Executable file
66
app/admin/controller/notice/SmsConfigController.php
Executable file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\notice;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\logic\notice\SmsConfigLogic;
|
||||
use app\admin\validate\notice\SmsConfigValidate;
|
||||
|
||||
/**
|
||||
* 短信配置控制器
|
||||
* Class SmsConfigController
|
||||
* @package app\admin\controller\notice
|
||||
*/
|
||||
class SmsConfigController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取短信配置
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 11:36
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$result = SmsConfigLogic::getConfig();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 短信配置
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 11:36
|
||||
*/
|
||||
public function setConfig()
|
||||
{
|
||||
$params = (new SmsConfigValidate())->post()->goCheck('setConfig');
|
||||
SmsConfigLogic::setConfig($params);
|
||||
return $this->success('操作成功',[],1,1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 查看短信配置详情
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 11:36
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new SmsConfigValidate())->goCheck('detail');
|
||||
$result = SmsConfigLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
}
|
49
app/admin/controller/setting/CustomerServiceController.php
Executable file
49
app/admin/controller/setting/CustomerServiceController.php
Executable file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\setting;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\logic\setting\CustomerServiceLogic;
|
||||
|
||||
/**
|
||||
* 客服设置
|
||||
* Class CustomerServiceController
|
||||
* @package app\admin\controller\setting
|
||||
*/
|
||||
class CustomerServiceController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 获取客服设置
|
||||
* @author ljj
|
||||
* @date 2022/2/15 12:05 下午
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$result = CustomerServiceLogic::getConfig();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置客服设置
|
||||
* @author ljj
|
||||
* @date 2022/2/15 12:11 下午
|
||||
*/
|
||||
public function setConfig()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
CustomerServiceLogic::setConfig($params);
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
}
|
54
app/admin/controller/setting/HotSearchController.php
Executable file
54
app/admin/controller/setting/HotSearchController.php
Executable file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\setting;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\logic\setting\HotSearchLogic;
|
||||
|
||||
/**
|
||||
* 热门搜索设置
|
||||
* Class HotSearchController
|
||||
* @package app\admin\controller\setting
|
||||
*/
|
||||
class HotSearchController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取热门搜索
|
||||
* @author 段誉
|
||||
* @date 2022/9/5 19:00
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$result = HotSearchLogic::getConfig();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置热门搜索
|
||||
* @author 段誉
|
||||
* @date 2022/9/5 19:00
|
||||
*/
|
||||
public function setConfig()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = HotSearchLogic::setConfig($params);
|
||||
if (false === $result) {
|
||||
return $this->fail(HotSearchLogic::getError() ?: '系统错误');
|
||||
}
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
}
|
63
app/admin/controller/setting/StorageController.php
Normal file
63
app/admin/controller/setting/StorageController.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\controller\setting;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\logic\setting\StorageLogic;
|
||||
use app\admin\validate\setting\StorageValidate;
|
||||
|
||||
class StorageController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 获取存储引擎列表
|
||||
* @author 段誉
|
||||
* @date 2022/4/20 16:13
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->success('获取成功', StorageLogic::lists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 存储配置信息
|
||||
* @author 段誉
|
||||
* @date 2022/4/20 16:19
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$param = (new StorageValidate())->get()->goCheck('detail');
|
||||
return $this->success('获取成功', StorageLogic::detail($param));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置存储参数
|
||||
* @author 段誉
|
||||
* @date 2022/4/20 16:19
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$params = (new StorageValidate())->post()->goCheck('setup');
|
||||
$result = StorageLogic::setup($params);
|
||||
if (true === $result) {
|
||||
return $this->success('配置成功', [], 1, 1);
|
||||
}
|
||||
return $this->success($result, [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 切换存储引擎
|
||||
* @author 段誉
|
||||
* @date 2022/4/20 16:19
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
$params = (new StorageValidate())->post()->goCheck('change');
|
||||
StorageLogic::change($params);
|
||||
return $this->success('切换成功', [], 1, 1);
|
||||
}
|
||||
}
|
51
app/admin/controller/setting/TransactionSettingsController.php
Executable file
51
app/admin/controller/setting/TransactionSettingsController.php
Executable file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\setting;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\logic\setting\TransactionSettingsLogic;
|
||||
use app\admin\validate\setting\TransactionSettingsValidate;
|
||||
|
||||
/**
|
||||
* 交易设置
|
||||
* Class TransactionSettingsController
|
||||
* @package app\admin\controller\setting
|
||||
*/
|
||||
class TransactionSettingsController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 获取交易设置
|
||||
* @author ljj
|
||||
* @date 2022/2/15 11:40 上午
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$result = TransactionSettingsLogic::getConfig();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置交易设置
|
||||
* @author ljj
|
||||
* @date 2022/2/15 11:50 上午
|
||||
*/
|
||||
public function setConfig()
|
||||
{
|
||||
$params = (new TransactionSettingsValidate())->post()->goCheck('setConfig');
|
||||
TransactionSettingsLogic::setConfig($params);
|
||||
return $this->success('操作成功',[],1,1);
|
||||
}
|
||||
}
|
94
app/admin/controller/setting/dict/DictDataController.php
Executable file
94
app/admin/controller/setting/dict/DictDataController.php
Executable file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\setting\dict;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\setting\dict\DictDataLists;
|
||||
use app\admin\logic\setting\dict\DictDataLogic;
|
||||
use app\admin\validate\dict\DictDataValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 字典数据
|
||||
* Class DictDataController
|
||||
* @package app\admin\controller\dictionary
|
||||
*/
|
||||
class DictDataController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取字典数据列表
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:35
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new DictDataLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加字典数据
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 17:13
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new DictDataValidate())->post()->goCheck('add');
|
||||
DictDataLogic::save($params);
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑字典数据
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 17:13
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new DictDataValidate())->post()->goCheck('edit');
|
||||
DictDataLogic::save($params);
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除字典数据
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 17:13
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new DictDataValidate())->post()->goCheck('id');
|
||||
DictDataLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取字典详情
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 17:14
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new DictDataValidate())->goCheck('id');
|
||||
$result = DictDataLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
110
app/admin/controller/setting/dict/DictTypeController.php
Executable file
110
app/admin/controller/setting/dict/DictTypeController.php
Executable file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\setting\dict;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\setting\dict\DictTypeLists;
|
||||
use app\admin\logic\setting\dict\DictTypeLogic;
|
||||
use app\admin\validate\dict\DictTypeValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
* Class DictTypeController
|
||||
* @package app\admin\controller\dict
|
||||
*/
|
||||
class DictTypeController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取字典类型列表
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 15:50
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new DictTypeLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加字典类型
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:24
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new DictTypeValidate())->post()->goCheck('add');
|
||||
DictTypeLogic::add($params);
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑字典类型
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:25
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new DictTypeValidate())->post()->goCheck('edit');
|
||||
DictTypeLogic::edit($params);
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除字典类型
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:25
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new DictTypeValidate())->post()->goCheck('delete');
|
||||
DictTypeLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取字典详情
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:25
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new DictTypeValidate())->goCheck('detail');
|
||||
$result = DictTypeLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取字典类型数据
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/10/13 10:46
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
$result = DictTypeLogic::getAllData();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
38
app/admin/controller/setting/system/CacheController.php
Executable file
38
app/admin/controller/setting/system/CacheController.php
Executable file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\setting\system;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\logic\setting\system\CacheLogic;
|
||||
|
||||
/**
|
||||
* 系统缓存
|
||||
* Class CacheController
|
||||
* @package app\admin\controller\settings\system
|
||||
*/
|
||||
class CacheController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 清除系统缓存
|
||||
* @author 段誉
|
||||
* @date 2022/4/8 16:34
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
CacheLogic::clear();
|
||||
return $this->success('清除成功', [], 1, 1);
|
||||
}
|
||||
}
|
37
app/admin/controller/setting/system/LogController.php
Executable file
37
app/admin/controller/setting/system/LogController.php
Executable file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\setting\system;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\setting\system\LogLists;
|
||||
|
||||
/**
|
||||
* 系统日志
|
||||
* Class LogController
|
||||
* @package app\admin\controller\setting\system
|
||||
*/
|
||||
class LogController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 查看系统日志列表
|
||||
* @author ljj
|
||||
* @date 2021/8/3 4:25 下午
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new LogLists());
|
||||
}
|
||||
}
|
41
app/admin/controller/setting/system/SystemController.php
Executable file
41
app/admin/controller/setting/system/SystemController.php
Executable file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\setting\system;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\logic\setting\system\SystemLogic;
|
||||
|
||||
|
||||
/**
|
||||
* 系统维护
|
||||
* Class SystemController
|
||||
* @package app\admin\controller\setting\system
|
||||
*/
|
||||
class SystemController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取系统环境信息
|
||||
* @author 段誉
|
||||
* @date 2021/12/28 18:36
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$result = SystemLogic::getInfo();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
80
app/admin/controller/setting/user/UserController.php
Executable file
80
app/admin/controller/setting/user/UserController.php
Executable file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\admin\controller\setting\user;
|
||||
|
||||
use app\admin\{
|
||||
controller\BaseAdminController,
|
||||
logic\setting\user\UserLogic,
|
||||
validate\setting\UserConfigValidate
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 设置-用户设置控制器
|
||||
* Class UserController
|
||||
* @package app\admin\controller\config
|
||||
*/
|
||||
class UserController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取用户设置
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:08
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$result = (new UserLogic())->getConfig();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置用户设置
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:08
|
||||
*/
|
||||
public function setConfig()
|
||||
{
|
||||
$params = (new UserConfigValidate())->post()->goCheck('user');
|
||||
(new UserLogic())->setConfig($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取注册配置
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:08
|
||||
*/
|
||||
public function getRegisterConfig()
|
||||
{
|
||||
$result = (new UserLogic())->getRegisterConfig();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置注册配置
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:08
|
||||
*/
|
||||
public function setRegisterConfig()
|
||||
{
|
||||
$params = (new UserConfigValidate())->post()->goCheck('register');
|
||||
(new UserLogic())->setRegisterConfig($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
}
|
106
app/admin/controller/setting/web/WebSettingController.php
Executable file
106
app/admin/controller/setting/web/WebSettingController.php
Executable file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\setting\web;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\logic\setting\web\WebSettingLogic;
|
||||
use app\admin\validate\setting\WebSettingValidate;
|
||||
|
||||
/**
|
||||
* 网站设置
|
||||
* Class WebSettingController
|
||||
* @package app\admin\controller\setting
|
||||
*/
|
||||
class WebSettingController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取网站信息
|
||||
* @author 段誉
|
||||
* @date 2021/12/28 15:44
|
||||
*/
|
||||
public function getWebsite()
|
||||
{
|
||||
$result = WebSettingLogic::getWebsiteInfo();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置网站信息
|
||||
* @author 段誉
|
||||
* @date 2021/12/28 15:45
|
||||
*/
|
||||
public function setWebsite()
|
||||
{
|
||||
$params = (new WebSettingValidate())->post()->goCheck('website');
|
||||
WebSettingLogic::setWebsiteInfo($params);
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取备案信息
|
||||
* @author 段誉
|
||||
* @date 2021/12/28 16:10
|
||||
*/
|
||||
public function getCopyright()
|
||||
{
|
||||
$result = WebSettingLogic::getCopyright();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置备案信息
|
||||
* @author 段誉
|
||||
* @date 2021/12/28 16:10
|
||||
*/
|
||||
public function setCopyright()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = WebSettingLogic::setCopyright($params);
|
||||
if (false === $result) {
|
||||
return $this->fail(WebSettingLogic::getError() ?: '操作失败');
|
||||
}
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置政策协议
|
||||
* @author ljj
|
||||
* @date 2022/2/15 11:00 上午
|
||||
*/
|
||||
public function setAgreement()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
WebSettingLogic::setAgreement($params);
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取政策协议
|
||||
* @author ljj
|
||||
* @date 2022/2/15 11:16 上午
|
||||
*/
|
||||
public function getAgreement()
|
||||
{
|
||||
$result = WebSettingLogic::getAgreement();
|
||||
return $this->data($result);
|
||||
}
|
||||
}
|
49
app/admin/controller/user/UserController.php
Normal file
49
app/admin/controller/user/UserController.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\controller\user;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\user\UserLists;
|
||||
use app\admin\logic\user\UserLogic;
|
||||
use app\admin\validate\user\UserValidate;
|
||||
|
||||
class UserController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 用户列表
|
||||
* @author 段誉
|
||||
* @date 2022//22 16:16
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new UserLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取用户详情
|
||||
* @author 段誉
|
||||
* @date 2022/9/22 16:34
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new UserValidate())->goCheck('detail');
|
||||
$detail = UserLogic::detail($params['id']);
|
||||
return $this->success('', $detail);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑用户信息
|
||||
* @author 段誉
|
||||
* @date 2022/9/22 16:34
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new UserValidate())->post()->goCheck('setInfo');
|
||||
UserLogic::setUserInfo($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
}
|
39
app/admin/lists/BaseAdminDataLists.php
Executable file
39
app/admin/lists/BaseAdminDataLists.php
Executable file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\admin\lists;
|
||||
|
||||
|
||||
use app\common\lists\BaseDataLists;
|
||||
|
||||
/**
|
||||
* 管理员模块数据列表基类
|
||||
* Class BaseAdminDataLists
|
||||
* @package app\admin\lists
|
||||
*/
|
||||
abstract class BaseAdminDataLists extends BaseDataLists
|
||||
{
|
||||
protected $adminInfo;
|
||||
protected $adminId;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->adminInfo = $this->request->adminInfo;
|
||||
$this->adminId = $this->request->adminId;
|
||||
}
|
||||
|
||||
|
||||
}
|
83
app/admin/lists/article/ArticleLists.php
Normal file
83
app/admin/lists/article/ArticleLists.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\lists\article;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\lists\ListsSortInterface;
|
||||
use app\common\model\article\Article;
|
||||
|
||||
class ArticleLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface
|
||||
{
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return array
|
||||
* @author heshihu
|
||||
* @date 2022/2/8 18:39
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'%like%' => ['title'],
|
||||
'=' => ['cid', 'is_show']
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置支持排序字段
|
||||
* @return array
|
||||
* @author heshihu
|
||||
* @date 2022/2/9 15:11
|
||||
*/
|
||||
public function setSortFields(): array
|
||||
{
|
||||
return ['create_time' => 'create_time', 'id' => 'id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置默认排序
|
||||
* @return array
|
||||
* @author heshihu
|
||||
* @date 2022/2/9 15:08
|
||||
*/
|
||||
public function setDefaultOrder(): array
|
||||
{
|
||||
return ['sort' => 'desc', 'id' => 'desc'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取管理列表
|
||||
* @return array
|
||||
* @author heshihu
|
||||
* @date 2022/2/21 17:11
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$ArticleLists = Article::where($this->searchWhere)
|
||||
->append(['cate_name', 'click'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order($this->sortOrder)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $ArticleLists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author heshihu
|
||||
* @date 2022/2/9 15:12
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Article::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
public function extend()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
206
app/admin/lists/auth/AdminLists.php
Executable file
206
app/admin/lists/auth/AdminLists.php
Executable file
@ -0,0 +1,206 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\lists\auth;
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\lists\ListsSortInterface;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\auth\AdminRole;
|
||||
use app\common\model\auth\SystemRole;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Jobs;
|
||||
|
||||
/**
|
||||
* 管理员列表
|
||||
* Class AdminLists
|
||||
* @package app\admin\lists\auth
|
||||
*/
|
||||
class AdminLists extends BaseAdminDataLists implements ListsExtendInterface, ListsSearchInterface, ListsSortInterface,ListsExcelInterface
|
||||
{
|
||||
/**
|
||||
* @notes 设置导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 10:08
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
return [
|
||||
'account' => '账号',
|
||||
'name' => '名称',
|
||||
'role_name' => '角色',
|
||||
'dept_name' => '部门',
|
||||
'create_time' => '创建时间',
|
||||
'login_time' => '最近登录时间',
|
||||
'login_ip' => '最近登录IP',
|
||||
'disable_desc' => '状态',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 10:08
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
return '管理员列表';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 10:07
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'%like%' => ['name', 'account'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置支持排序字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 10:07
|
||||
* @remark 格式: ['前端传过来的字段名' => '数据库中的字段名'];
|
||||
*/
|
||||
public function setSortFields(): array
|
||||
{
|
||||
return ['create_time' => 'create_time', 'id' => 'id'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置默认排序
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 10:06
|
||||
*/
|
||||
public function setDefaultOrder(): array
|
||||
{
|
||||
return ['id' => 'desc'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 查询条件
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/11/29 11:33
|
||||
*/
|
||||
public function queryWhere()
|
||||
{
|
||||
$where = [];
|
||||
if (isset($this->params['role_id']) && $this->params['role_id'] != '') {
|
||||
$adminIds = AdminRole::where('role_id', $this->params['role_id'])->column('admin_id');
|
||||
if (!empty($adminIds)) {
|
||||
$where[] = ['id', 'in', $adminIds];
|
||||
}
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取管理列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 10:05
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$field = [
|
||||
'id', 'name', 'account', 'create_time', 'disable', 'root',
|
||||
'login_time', 'login_ip', 'multipoint_login', 'avatar'
|
||||
];
|
||||
|
||||
$adminLists = Admin::field($field)
|
||||
->where($this->searchWhere)
|
||||
->where($this->queryWhere())
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order($this->sortOrder)
|
||||
->append(['role_id', 'dept_id', 'jobs_id', 'disable_desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 角色数组('角色id'=>'角色名称')
|
||||
$roleLists = SystemRole::column('name', 'id');
|
||||
// 部门列表
|
||||
$deptLists = Dept::column('name', 'id');
|
||||
// 岗位列表
|
||||
$jobsLists = Jobs::column('name', 'id');
|
||||
|
||||
//管理员列表增加角色名称
|
||||
foreach ($adminLists as $k => $v) {
|
||||
$roleName = '';
|
||||
if ($v['root'] == 1) {
|
||||
$roleName = '系统管理员';
|
||||
} else {
|
||||
foreach ($v['role_id'] as $roleId) {
|
||||
$roleName .= $roleLists[$roleId] ?? '';
|
||||
$roleName .= '/';
|
||||
}
|
||||
}
|
||||
|
||||
$deptName = '';
|
||||
foreach ($v['dept_id'] as $deptId) {
|
||||
$deptName .= $deptLists[$deptId] ?? '';
|
||||
$deptName .= '/';
|
||||
}
|
||||
|
||||
$jobsName = '';
|
||||
foreach ($v['jobs_id'] as $jobsId) {
|
||||
$jobsName .= $jobsLists[$jobsId] ?? '';
|
||||
$jobsName .= '/';
|
||||
}
|
||||
|
||||
$adminLists[$k]['role_name'] = trim($roleName, '/');
|
||||
$adminLists[$k]['dept_name'] = trim($deptName, '/');
|
||||
$adminLists[$k]['jobs_name'] = trim($jobsName, '/');
|
||||
}
|
||||
|
||||
return $adminLists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author 令狐冲
|
||||
* @date 2021/7/13 00:52
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Admin::where($this->searchWhere)
|
||||
->where($this->queryWhere())
|
||||
->count();
|
||||
}
|
||||
|
||||
public function extend()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
58
app/admin/lists/auth/MenuLists.php
Executable file
58
app/admin/lists/auth/MenuLists.php
Executable file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\lists\auth;
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\auth\SystemMenu;
|
||||
|
||||
|
||||
/**
|
||||
* 菜单列表
|
||||
* Class MenuLists
|
||||
* @package app\admin\lists\auth
|
||||
*/
|
||||
class MenuLists extends BaseAdminDataLists
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取菜单列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2022/6/29 16:41
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = SystemMenu::order(['sort' => 'desc', 'id' => 'asc'])
|
||||
->select()
|
||||
->toArray();
|
||||
return linear_to_tree($lists, 'children');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取菜单数量
|
||||
* @return int
|
||||
* @author 乔峰
|
||||
* @date 2022/6/29 16:41
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return SystemMenu::count();
|
||||
}
|
||||
|
||||
}
|
93
app/admin/lists/auth/RoleLists.php
Executable file
93
app/admin/lists/auth/RoleLists.php
Executable file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\lists\auth;
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\auth\AdminRole;
|
||||
use app\common\model\auth\SystemRole;
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
* Class RoleLists
|
||||
* @package app\admin\lists\auth
|
||||
*/
|
||||
class RoleLists extends BaseAdminDataLists
|
||||
{
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author Tab
|
||||
* @date 2021/9/22 18:52
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
return [
|
||||
'name' => '角色名称',
|
||||
'desc' => '备注',
|
||||
'create_time' => '创建时间'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出表名
|
||||
* @return string
|
||||
* @author Tab
|
||||
* @date 2021/9/22 18:52
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
return '角色表';
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 角色列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2021/8/25 18:00
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = SystemRole::with(['role_menu_index'])
|
||||
->field('id,name,desc,sort,create_time')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ($lists as $key => $role) {
|
||||
//使用角色的人数
|
||||
$lists[$key]['num'] = AdminRole::where('role_id', $role['id'])->count();
|
||||
$menuId = array_column($role['role_menu_index'], 'menu_id');
|
||||
$lists[$key]['menu_id'] = $menuId;
|
||||
unset($lists[$key]['role_menu_index']);
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 总记录数
|
||||
* @return int
|
||||
* @author Tab
|
||||
* @date 2021/7/13 11:26
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return SystemRole::count();
|
||||
}
|
||||
}
|
80
app/admin/lists/channel/OfficialAccountReplyLists.php
Executable file
80
app/admin/lists/channel/OfficialAccountReplyLists.php
Executable file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\lists\channel;
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\channel\OfficialAccountReply;
|
||||
|
||||
/**
|
||||
* 微信公众号回复列表
|
||||
* Class OfficialAccountLists
|
||||
* @package app\admin\lists
|
||||
*/
|
||||
class OfficialAccountReplyLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 设置搜索
|
||||
* @return \string[][]
|
||||
* @author 段誉
|
||||
* @date 2022/3/30 15:02
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['reply_type']
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 回复列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/3/30 15:02
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$field = 'id,name,keyword,matching_type,content,content_type,status,sort';
|
||||
$field .= ',matching_type as matching_type_desc,content_type as content_type_desc,status as status_desc';
|
||||
|
||||
$lists = OfficialAccountReply::field($field)
|
||||
->where($this->searchWhere)
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 回复记录数
|
||||
* @return int
|
||||
* @author 段誉
|
||||
* @date 2022/3/30 15:02
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$count = OfficialAccountReply::where($this->searchWhere)->count();
|
||||
|
||||
return $count;
|
||||
}
|
||||
}
|
61
app/admin/lists/crontab/CrontabLists.php
Executable file
61
app/admin/lists/crontab/CrontabLists.php
Executable file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\lists\crontab;
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\Crontab;
|
||||
|
||||
/**
|
||||
* 定时任务列表
|
||||
* Class CrontabLists
|
||||
* @package app\admin\lists\crontab
|
||||
*/
|
||||
class CrontabLists extends BaseAdminDataLists
|
||||
{
|
||||
/**
|
||||
* @notes 定时任务列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 14:30
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$field = 'id,name,type,type as type_desc,command,params,expression,
|
||||
status,status as status_desc,error,last_time,time,max_time';
|
||||
|
||||
$lists = Crontab::field($field)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order('id', 'desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 定时任务数量
|
||||
* @return int
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 14:38
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Crontab::count();
|
||||
}
|
||||
}
|
105
app/admin/lists/dept/JobsLists.php
Executable file
105
app/admin/lists/dept/JobsLists.php
Executable file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\lists\dept;
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\dept\Jobs;
|
||||
|
||||
/**
|
||||
* 岗位列表
|
||||
* Class JobsLists
|
||||
* @package app\admin\lists\dept
|
||||
*/
|
||||
class JobsLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author 段誉
|
||||
* @date 2022/5/26 9:46
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'%like%' => ['name'],
|
||||
'=' => ['code', 'status']
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取管理列表
|
||||
* @return array
|
||||
* @author heshihu
|
||||
* @date 2022/2/21 17:11
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = Jobs::where($this->searchWhere)
|
||||
->append(['status_desc'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author 段誉
|
||||
* @date 2022/5/26 9:48
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Jobs::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 段誉
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
return '岗位列表';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 段誉
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
return [
|
||||
'code' => '岗位编码',
|
||||
'name' => '岗位名称',
|
||||
'remark' => '备注',
|
||||
'status_desc' => '状态',
|
||||
'create_time' => '添加时间',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
57
app/admin/lists/file/FileCateLists.php
Normal file
57
app/admin/lists/file/FileCateLists.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\lists\file;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\file\FileCate;
|
||||
|
||||
class FileCateLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 文件分类搜素条件
|
||||
* @return \string[][]
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:24
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['type']
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取文件分类列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:24
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = (new FileCate())->field(['id,pid,type,name'])
|
||||
->where($this->searchWhere)
|
||||
->select()->toArray();
|
||||
|
||||
return linear_to_tree($lists, 'children');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取文件分类数量
|
||||
* @return int
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:24
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return (new FileCate())->where($this->searchWhere)->count();
|
||||
}
|
||||
}
|
70
app/admin/lists/file/FileLists.php
Normal file
70
app/admin/lists/file/FileLists.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\lists\file;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\enum\FileEnum;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\file\File;
|
||||
use app\common\service\FileService;
|
||||
|
||||
class FileLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
/**
|
||||
* @notes 文件搜索条件
|
||||
* @return \string[][]
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:27
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['type', 'cid'],
|
||||
'%like%' => ['name']
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取文件列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:27
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = (new File())->field(['id,cid,type,name,uri,create_time'])
|
||||
->order('id', 'desc')
|
||||
->where($this->searchWhere)
|
||||
->where('source', FileEnum::SOURCE_ADMIN)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['url'] = $item['uri'];
|
||||
$item['uri'] = FileService::getFileUrl($item['uri']);
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取文件数量
|
||||
* @return int
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:29
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return (new File())->where($this->searchWhere)
|
||||
->where('source', FileEnum::SOURCE_ADMIN)
|
||||
->count();
|
||||
}
|
||||
}
|
71
app/admin/lists/notice/NoticeSettingLists.php
Executable file
71
app/admin/lists/notice/NoticeSettingLists.php
Executable file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\lists\notice;
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\notice\NoticeSetting;
|
||||
|
||||
/**
|
||||
* 通知设置
|
||||
* Class NoticeSettingLists
|
||||
* @package app\admin\lists\notice
|
||||
*/
|
||||
class NoticeSettingLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @return \string[][]
|
||||
* @author ljj
|
||||
* @date 2022/2/17 2:21 下午
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['recipient', 'type']
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 通知设置列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/2/16 3:18 下午
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = (new NoticeSetting())->field('id,scene_name,sms_notice,type')
|
||||
->append(['sms_status_desc','type_desc'])
|
||||
->where($this->searchWhere)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 通知设置数量
|
||||
* @return int
|
||||
* @author ljj
|
||||
* @date 2022/2/16 3:18 下午
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return (new NoticeSetting())->where($this->searchWhere)->count();
|
||||
}
|
||||
}
|
76
app/admin/lists/setting/dict/DictDataLists.php
Executable file
76
app/admin/lists/setting/dict/DictDataLists.php
Executable file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\lists\setting\dict;
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\dict\DictData;
|
||||
|
||||
|
||||
/**
|
||||
* 字典数据列表
|
||||
* Class DictDataLists
|
||||
* @package app\admin\lists\dict
|
||||
*/
|
||||
class DictDataLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:29
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'%like%' => ['name', 'type_value'],
|
||||
'=' => ['status', 'type_id']
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:35
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return DictData::where($this->searchWhere)
|
||||
->append(['status_desc'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:35
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return DictData::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
76
app/admin/lists/setting/dict/DictTypeLists.php
Executable file
76
app/admin/lists/setting/dict/DictTypeLists.php
Executable file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\lists\setting\dict;
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\dict\DictType;
|
||||
|
||||
|
||||
/**
|
||||
* 字典类型列表
|
||||
* Class DictTypeLists
|
||||
* @package app\admin\lists\dictionary
|
||||
*/
|
||||
class DictTypeLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 15:53
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'%like%' => ['name', 'type'],
|
||||
'=' => ['status']
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 15:54
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return DictType::where($this->searchWhere)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->append(['status_desc'])
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 15:54
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return DictType::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
108
app/admin/lists/setting/system/LogLists.php
Executable file
108
app/admin/lists/setting/system/LogLists.php
Executable file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\lists\setting\system;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\OperationLog;
|
||||
|
||||
/**
|
||||
* 日志列表
|
||||
* Class LogLists
|
||||
* @package app\admin\lists\setting\system
|
||||
*/
|
||||
class LogLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
||||
{
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author ljj
|
||||
* @date 2021/8/3 4:21 下午
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'%like%' => ['admin_name','url','ip','type'],
|
||||
'between_time' => 'create_time',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 查看系统日志列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2021/8/3 4:21 下午
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = OperationLog::field('id,action,admin_name,admin_id,url,type,params,ip,create_time')
|
||||
->where($this->searchWhere)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order('id','desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 查看系统日志总数
|
||||
* @return int
|
||||
* @author ljj
|
||||
* @date 2021/8/3 4:23 下午
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return OperationLog::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置导出字段
|
||||
* @return string[]
|
||||
* @author ljj
|
||||
* @date 2021/8/3 4:48 下午
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
return [
|
||||
// '数据库字段名(支持别名) => 'Excel表字段名'
|
||||
'id' => '记录ID',
|
||||
'action' => '操作',
|
||||
'admin_name' => '管理员',
|
||||
'admin_id' => '管理员ID',
|
||||
'url' => '访问链接',
|
||||
'type' => '访问方式',
|
||||
'params' => '访问参数',
|
||||
'ip' => '来源IP',
|
||||
'create_time' => '日志时间',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置默认表名
|
||||
* @return string
|
||||
* @author ljj
|
||||
* @date 2021/8/3 4:48 下午
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
return '系统日志';
|
||||
}
|
||||
}
|
94
app/admin/lists/user/UserLists.php
Normal file
94
app/admin/lists/user/UserLists.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\lists\user;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\enum\user\UserTerminalEnum;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\model\user\User;
|
||||
|
||||
class UserLists extends BaseAdminDataLists implements ListsExcelInterface
|
||||
{
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/9/22 15:50
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
$allowSearch = ['keyword', 'channel', 'create_time_start', 'create_time_end'];
|
||||
return array_intersect(array_keys($this->params), $allowSearch);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取用户列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2022/9/22 15:50
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$field = "id,sn,nickname,sex,avatar,account,mobile,channel,create_time";
|
||||
$lists = User::withSearch($this->setSearch(), $this->params)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->field($field)
|
||||
->order('id desc')
|
||||
->select()->toArray();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['channel'] = UserTerminalEnum::getTermInalDesc($item['channel']);
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author 乔峰
|
||||
* @date 2022/9/22 15:51
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return User::withSearch($this->setSearch(), $this->params)->count();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
return '用户列表';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
return [
|
||||
'sn' => '用户编号',
|
||||
'nickname' => '用户昵称',
|
||||
'account' => '账号',
|
||||
'mobile' => '手机号码',
|
||||
'channel' => '注册来源',
|
||||
'create_time' => '注册时间',
|
||||
];
|
||||
}
|
||||
}
|
92
app/admin/logic/ConfigLogic.php
Executable file
92
app/admin/logic/ConfigLogic.php
Executable file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\service\{FileService, ConfigService};
|
||||
|
||||
/**
|
||||
* 配置类逻辑层
|
||||
* Class ConfigLogic
|
||||
* @package app\admin\logic
|
||||
*/
|
||||
class ConfigLogic
|
||||
{
|
||||
/**
|
||||
* @notes 获取配置
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2021/12/31 11:03
|
||||
*/
|
||||
public static function getConfig(): array
|
||||
{
|
||||
$config = [
|
||||
// 文件域名
|
||||
'oss_domain' => FileService::getFileUrl(),
|
||||
|
||||
// 网站名称
|
||||
'web_name' => ConfigService::get('website', 'name'),
|
||||
// 网站图标
|
||||
'web_favicon' => FileService::getFileUrl(ConfigService::get('website', 'web_favicon')),
|
||||
// 网站logo
|
||||
'web_logo' => FileService::getFileUrl(ConfigService::get('website', 'web_logo')),
|
||||
// 登录页
|
||||
'login_image' => FileService::getFileUrl(ConfigService::get('website', 'login_image')),
|
||||
|
||||
// 版权信息
|
||||
'copyright_config' => ConfigService::get('copyright', 'config', []),
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 根据类型获取字典类型
|
||||
* @param $type
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2022/9/27 19:09
|
||||
*/
|
||||
public static function getDictByType($type)
|
||||
{
|
||||
if (!is_string($type)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$type = explode(',', $type);
|
||||
$lists = DictData::whereIn('type_value', $type)->select()->toArray();
|
||||
|
||||
if (empty($lists)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
foreach ($type as $item) {
|
||||
foreach ($lists as $dict) {
|
||||
if ($dict['type_value'] == $item) {
|
||||
$result[$item][] = $dict;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
119
app/admin/logic/FileLogic.php
Executable file
119
app/admin/logic/FileLogic.php
Executable file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\file\File;
|
||||
use app\common\model\file\FileCate;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\storage\Driver as StorageDriver;
|
||||
|
||||
/**
|
||||
* 文件逻辑层
|
||||
* Class FileLogic
|
||||
* @package app\admin\logic
|
||||
*/
|
||||
class FileLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 移动文件
|
||||
* @param $params
|
||||
* @author 乔峰
|
||||
* @date 2021/7/28 15:29
|
||||
*/
|
||||
public static function move($params)
|
||||
{
|
||||
(new File())->whereIn('id', $params['ids'])
|
||||
->update([
|
||||
'cid' => $params['cid'],
|
||||
'update_time' => time()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 重命名文件
|
||||
* @param $params
|
||||
* @author 乔峰
|
||||
* @date 2021/7/29 17:16
|
||||
*/
|
||||
public static function rename($params)
|
||||
{
|
||||
(new File())->where('id', $params['id'])
|
||||
->update([
|
||||
'name' => $params['name'],
|
||||
'update_time' => time()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 批量删除文件
|
||||
* @param $params
|
||||
* @author 乔峰
|
||||
* @date 2021/7/28 15:41
|
||||
*/
|
||||
public static function delete($params)
|
||||
{
|
||||
$result = File::whereIn('id', $params['ids'])->select();
|
||||
$StorageDriver = new StorageDriver([
|
||||
'default' => ConfigService::get('storage', 'default', 'local'),
|
||||
'engine' => ConfigService::get('storage') ?? ['local'=>[]],
|
||||
]);
|
||||
foreach ($result as $item) {
|
||||
$StorageDriver->delete($item['uri']);
|
||||
}
|
||||
File::destroy($params['ids']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 添加文件分类
|
||||
* @param $params
|
||||
* @author 乔峰
|
||||
* @date 2021/7/28 11:32
|
||||
*/
|
||||
public static function addCate($params)
|
||||
{
|
||||
FileCate::create([
|
||||
'type' => $params['type'],
|
||||
'pid' => $params['pid'],
|
||||
'name' => $params['name']
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑文件分类
|
||||
* @param $params
|
||||
* @author 乔峰
|
||||
* @date 2021/7/28 14:03
|
||||
*/
|
||||
public static function editCate($params)
|
||||
{
|
||||
FileCate::update([
|
||||
'name' => $params['name'],
|
||||
'update_time' => time()
|
||||
], ['id' => $params['id']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除文件分类
|
||||
* @param $params
|
||||
* @author 乔峰
|
||||
* @date 2021/7/28 14:21
|
||||
*/
|
||||
public static function delCate($params)
|
||||
{
|
||||
FileCate::destroy($params['id']);
|
||||
}
|
||||
}
|
84
app/admin/logic/LoginLogic.php
Executable file
84
app/admin/logic/LoginLogic.php
Executable file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\admin\service\AdminTokenService;
|
||||
use app\common\service\FileService;
|
||||
use Webman\Config;
|
||||
|
||||
/**
|
||||
* 登录逻辑
|
||||
* Class LoginLogic
|
||||
* @package app\admin\logic
|
||||
*/
|
||||
class LoginLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 管理员账号登录
|
||||
* @param $params
|
||||
* @return false|mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 令狐冲
|
||||
* @date 2021/6/30 17:00
|
||||
*/
|
||||
public function login($params)
|
||||
{
|
||||
$time = time();
|
||||
$admin = Admin::where('account', '=', $params['account'])->find();
|
||||
|
||||
//用户表登录信息更新
|
||||
$admin->login_time = $time;
|
||||
$admin->login_ip = request()->getLocalIp();
|
||||
$admin->save();
|
||||
|
||||
//设置token
|
||||
$adminInfo = AdminTokenService::setToken($admin->id, $params['terminal'], $admin->multipoint_login);
|
||||
|
||||
//返回登录信息
|
||||
$avatar = $admin->avatar ? $admin->avatar : Config::get('project.default_image.admin_avatar');
|
||||
$avatar = FileService::getFileUrl($avatar);
|
||||
return [
|
||||
'name' => $adminInfo['name'],
|
||||
'avatar' => $avatar,
|
||||
'role_name' => $adminInfo['role_name'],
|
||||
'token' => $adminInfo['token'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 退出登录
|
||||
* @param $adminInfo
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 令狐冲
|
||||
* @date 2021/7/5 14:34
|
||||
*/
|
||||
public function logout($adminInfo)
|
||||
{
|
||||
//token不存在,不注销
|
||||
if (!isset($adminInfo['token'])) {
|
||||
return false;
|
||||
}
|
||||
//设置token过期
|
||||
return AdminTokenService::expireToken($adminInfo['token']);
|
||||
}
|
||||
}
|
208
app/admin/logic/WorkbenchLogic.php
Executable file
208
app/admin/logic/WorkbenchLogic.php
Executable file
@ -0,0 +1,208 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
|
||||
|
||||
/**
|
||||
* 工作台
|
||||
* Class WorkbenchLogic
|
||||
* @package app\admin\logic
|
||||
*/
|
||||
class WorkbenchLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 工作套
|
||||
* @param $adminInfo
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 15:58
|
||||
*/
|
||||
public static function index()
|
||||
{
|
||||
return [
|
||||
// 版本信息
|
||||
'version' => self::versionInfo(),
|
||||
// 今日数据
|
||||
'today' => self::today(),
|
||||
// 常用功能
|
||||
'menu' => self::menu(),
|
||||
// 近15日访客数
|
||||
'visitor' => self::visitor(),
|
||||
// 服务支持
|
||||
'support' => self::support()
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 常用功能
|
||||
* @return array[]
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 16:40
|
||||
*/
|
||||
public static function menu(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'name' => '管理员',
|
||||
'image' => FileService::getFileUrl(config('project.default_image.menu_admin')),
|
||||
'url' => '/permission/admin'
|
||||
],
|
||||
[
|
||||
'name' => '角色管理',
|
||||
'image' => FileService::getFileUrl(config('project.default_image.menu_role')),
|
||||
'url' => '/permission/role'
|
||||
],
|
||||
[
|
||||
'name' => '部门管理',
|
||||
'image' => FileService::getFileUrl(config('project.default_image.menu_dept')),
|
||||
'url' => '/organization/department'
|
||||
],
|
||||
[
|
||||
'name' => '字典管理',
|
||||
'image' => FileService::getFileUrl(config('project.default_image.menu_dict')),
|
||||
'url' => '/dev_tools/dict'
|
||||
],
|
||||
[
|
||||
'name' => '代码生成器',
|
||||
'image' => FileService::getFileUrl(config('project.default_image.menu_generator')),
|
||||
'url' => '/dev_tools/code'
|
||||
],
|
||||
[
|
||||
'name' => '素材中心',
|
||||
'image' => FileService::getFileUrl(config('project.default_image.menu_file')),
|
||||
'url' => '/material/index'
|
||||
],
|
||||
[
|
||||
'name' => '菜单权限',
|
||||
'image' => FileService::getFileUrl(config('project.default_image.menu_auth')),
|
||||
'url' => '/permission/menu'
|
||||
],
|
||||
[
|
||||
'name' => '网站信息',
|
||||
'image' => FileService::getFileUrl(config('project.default_image.menu_web')),
|
||||
'url' => '/setting/website/information'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 版本信息
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 16:08
|
||||
*/
|
||||
public static function versionInfo(): array
|
||||
{
|
||||
return [
|
||||
'version' => config('project.version'),
|
||||
'website' => config('project.website.url'),
|
||||
'name' => ConfigService::get('website', 'name'),
|
||||
'based' => 'vue3.x、ElementUI、MySQL',
|
||||
'channel' => [
|
||||
'website' => 'https://www.likeadmin.cn',
|
||||
'gitee' => 'https://gitee.com/likeadmin/likeadmin_php',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 今日数据
|
||||
* @return int[]
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 16:15
|
||||
*/
|
||||
public static function today(): array
|
||||
{
|
||||
return [
|
||||
'time' => date('Y-m-d H:i:s'),
|
||||
// 今日销售额
|
||||
'today_sales' => 100,
|
||||
// 总销售额
|
||||
'total_sales' => 1000,
|
||||
|
||||
// 今日访问量
|
||||
'today_visitor' => 10,
|
||||
// 总访问量
|
||||
'total_visitor' => 100,
|
||||
|
||||
// 今日新增用户量
|
||||
'today_new_user' => 30,
|
||||
// 总用户量
|
||||
'total_new_user' => 3000,
|
||||
|
||||
// 订单量 (笔)
|
||||
'order_num' => 12,
|
||||
// 总订单量
|
||||
'order_sum' => 255
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 访问数
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 16:57
|
||||
*/
|
||||
public static function visitor(): array
|
||||
{
|
||||
$num = [];
|
||||
$date = [];
|
||||
for ($i = 0; $i < 15; $i++) {
|
||||
$where_start = strtotime("- " . $i . "day");
|
||||
$date[] = date('Y/m/d', $where_start);
|
||||
$num[$i] = rand(0, 100);
|
||||
}
|
||||
|
||||
return [
|
||||
'date' => $date,
|
||||
'list' => [
|
||||
['name' => '访客数', 'data' => $num]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 服务支持
|
||||
* @return array[]
|
||||
* @author 乔峰
|
||||
* @date 2022/7/18 11:18
|
||||
*/
|
||||
public static function support()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'image' => FileService::getFileUrl(config('project.default_image.qq_group')),
|
||||
'title' => '官方公众号',
|
||||
'desc' => '关注官方公众号',
|
||||
],
|
||||
[
|
||||
'image' => FileService::getFileUrl(config('project.default_image.customer_service')),
|
||||
'title' => '添加企业客服微信',
|
||||
'desc' => '想了解更多请添加客服',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
}
|
127
app/admin/logic/article/ArticleCateLogic.php
Executable file
127
app/admin/logic/article/ArticleCateLogic.php
Executable file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\article;
|
||||
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\article\ArticleCate;
|
||||
|
||||
/**
|
||||
* 资讯分类管理逻辑
|
||||
* Class ArticleCateLogic
|
||||
* @package app\admin\logic\article
|
||||
*/
|
||||
class ArticleCateLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加资讯分类
|
||||
* @param array $params
|
||||
* @author heshihu
|
||||
* @date 2022/2/18 10:17
|
||||
*/
|
||||
public static function add(array $params)
|
||||
{
|
||||
ArticleCate::create([
|
||||
'name' => $params['name'],
|
||||
'is_show' => $params['is_show'],
|
||||
'sort' => $params['sort'] ?? 0
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑资讯分类
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author heshihu
|
||||
* @date 2022/2/21 17:50
|
||||
*/
|
||||
public static function edit(array $params) : bool
|
||||
{
|
||||
try {
|
||||
ArticleCate::update([
|
||||
'id' => $params['id'],
|
||||
'name' => $params['name'],
|
||||
'is_show' => $params['is_show'],
|
||||
'sort' => $params['sort'] ?? 0
|
||||
]);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除资讯分类
|
||||
* @param array $params
|
||||
* @author heshihu
|
||||
* @date 2022/2/21 17:52
|
||||
*/
|
||||
public static function delete(array $params)
|
||||
{
|
||||
ArticleCate::destroy($params['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 查看资讯分类详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author heshihu
|
||||
* @date 2022/2/21 17:54
|
||||
*/
|
||||
public static function detail($params) : array
|
||||
{
|
||||
return ArticleCate::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更改资讯分类状态
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author heshihu
|
||||
* @date 2022/2/21 18:04
|
||||
*/
|
||||
public static function updateStatus(array $params)
|
||||
{
|
||||
ArticleCate::update([
|
||||
'id' => $params['id'],
|
||||
'is_show' => $params['is_show']
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 文章分类数据
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2022/10/13 10:53
|
||||
*/
|
||||
public static function getAllData()
|
||||
{
|
||||
return ArticleCate::where(['is_show' => YesNoEnum::YES])
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
}
|
121
app/admin/logic/article/ArticleLogic.php
Executable file
121
app/admin/logic/article/ArticleLogic.php
Executable file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\article;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\article\Article;
|
||||
use app\common\service\FileService;
|
||||
|
||||
/**
|
||||
* 资讯管理逻辑
|
||||
* Class ArticleLogic
|
||||
* @package app\admin\logic\article
|
||||
*/
|
||||
class ArticleLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 添加资讯
|
||||
* @param array $params
|
||||
* @author heshihu
|
||||
* @date 2022/2/22 9:57
|
||||
*/
|
||||
public static function add(array $params)
|
||||
{
|
||||
Article::create([
|
||||
'title' => $params['title'],
|
||||
'desc' => $params['desc'] ?? '',
|
||||
'author' => $params['author'] ?? '', //作者
|
||||
'sort' => $params['sort'] ?? 0, // 排序
|
||||
'abstract' => $params['abstract'], // 文章摘要
|
||||
'click_virtual' => $params['click_virtual'] ?? 0,
|
||||
'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '',
|
||||
'cid' => $params['cid'],
|
||||
'is_show' => $params['is_show'],
|
||||
'content' => $params['content'] ?? '',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑资讯
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author heshihu
|
||||
* @date 2022/2/22 10:12
|
||||
*/
|
||||
public static function edit(array $params) : bool
|
||||
{
|
||||
try {
|
||||
Article::update([
|
||||
'id' => $params['id'],
|
||||
'title' => $params['title'],
|
||||
'desc' => $params['desc'] ?? '', // 简介
|
||||
'author' => $params['author'] ?? '', //作者
|
||||
'sort' => $params['sort'] ?? 0, // 排序
|
||||
'abstract' => $params['abstract'], // 文章摘要
|
||||
'click_virtual' => $params['click_virtual'] ?? 0,
|
||||
'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '',
|
||||
'cid' => $params['cid'],
|
||||
'is_show' => $params['is_show'],
|
||||
'content' => $params['content'] ?? '',
|
||||
]);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除资讯
|
||||
* @param array $params
|
||||
* @author heshihu
|
||||
* @date 2022/2/22 10:17
|
||||
*/
|
||||
public static function delete(array $params)
|
||||
{
|
||||
Article::destroy($params['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 查看资讯详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author heshihu
|
||||
* @date 2022/2/22 10:15
|
||||
*/
|
||||
public static function detail($params) : array
|
||||
{
|
||||
return Article::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更改资讯状态
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author heshihu
|
||||
* @date 2022/2/22 10:18
|
||||
*/
|
||||
public static function updateStatus(array $params)
|
||||
{
|
||||
Article::update([
|
||||
'id' => $params['id'],
|
||||
'is_show' => $params['is_show']
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
}
|
337
app/admin/logic/auth/AdminLogic.php
Executable file
337
app/admin/logic/auth/AdminLogic.php
Executable file
@ -0,0 +1,337 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\auth;
|
||||
|
||||
use app\common\cache\AdminAuthCache;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\auth\AdminDept;
|
||||
use app\common\model\auth\AdminJobs;
|
||||
use app\common\model\auth\AdminRole;
|
||||
use app\common\model\auth\AdminSession;
|
||||
use app\common\cache\AdminTokenCache;
|
||||
use app\common\service\FileService;
|
||||
use Webman\Config;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 管理员逻辑
|
||||
* Class AdminLogic
|
||||
* @package app\admin\logic\auth
|
||||
*/
|
||||
class AdminLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 添加管理员
|
||||
* @param array $params
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 10:23
|
||||
*/
|
||||
public static function add(array $params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$password = create_password($params['password'], $passwordSalt);
|
||||
$defaultAvatar = config('project.default_image.admin_avatar');
|
||||
$avatar = !empty($params['avatar']) ? FileService::setFileUrl($params['avatar']) : $defaultAvatar;
|
||||
|
||||
$admin = Admin::create([
|
||||
'name' => $params['name'],
|
||||
'account' => $params['account'],
|
||||
'avatar' => $avatar,
|
||||
'password' => $password,
|
||||
'create_time' => time(),
|
||||
'disable' => $params['disable'],
|
||||
'multipoint_login' => $params['multipoint_login'],
|
||||
]);
|
||||
|
||||
// 角色
|
||||
self::insertRole($admin['id'], $params['role_id'] ?? []);
|
||||
// 部门
|
||||
self::insertDept($admin['id'], $params['dept_id'] ?? []);
|
||||
// 岗位
|
||||
self::insertJobs($admin['id'], $params['jobs_id'] ?? []);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑管理员
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 10:43
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 基础信息
|
||||
$data = [
|
||||
'id' => $params['id'],
|
||||
'name' => $params['name'],
|
||||
'account' => $params['account'],
|
||||
'disable' => $params['disable'],
|
||||
'multipoint_login' => $params['multipoint_login']
|
||||
];
|
||||
|
||||
// 头像
|
||||
$data['avatar'] = !empty($params['avatar']) ? FileService::setFileUrl($params['avatar']) : '';
|
||||
|
||||
// 密码
|
||||
if (!empty($params['password'])) {
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$data['password'] = create_password($params['password'], $passwordSalt);
|
||||
}
|
||||
|
||||
// 禁用或更换角色后.设置token过期
|
||||
$roleId = AdminRole::where('admin_id', $params['id'])->column('role_id');
|
||||
$editRole = false;
|
||||
if (!empty(array_diff_assoc($roleId, $params['role_id']))) {
|
||||
$editRole = true;
|
||||
}
|
||||
|
||||
if ($params['disable'] == 1 || $editRole) {
|
||||
$tokenArr = AdminSession::where('admin_id', $params['id'])->select()->toArray();
|
||||
foreach ($tokenArr as $token) {
|
||||
self::expireToken($token['token']);
|
||||
}
|
||||
}
|
||||
|
||||
Admin::update($data);
|
||||
(new AdminAuthCache($params['id']))->clearAuthCache();
|
||||
|
||||
// 删除旧的关联信息
|
||||
AdminRole::delByUserId($params['id']);
|
||||
AdminDept::delByUserId($params['id']);
|
||||
AdminJobs::delByUserId($params['id']);
|
||||
// 角色
|
||||
self::insertRole($params['id'], $params['role_id']);
|
||||
// 部门
|
||||
self::insertDept($params['id'], $params['dept_id'] ?? []);
|
||||
// 岗位
|
||||
self::insertJobs($params['id'], $params['jobs_id'] ?? []);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除管理员
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 10:45
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$admin = Admin::findOrEmpty($params['id']);
|
||||
if ($admin->root == YesNoEnum::YES) {
|
||||
throw new \Exception("超级管理员不允许被删除");
|
||||
}
|
||||
Admin::destroy($params['id']);
|
||||
|
||||
//设置token过期
|
||||
$tokenArr = AdminSession::where('admin_id', $params['id'])->select()->toArray();
|
||||
foreach ($tokenArr as $token) {
|
||||
self::expireToken($token['token']);
|
||||
}
|
||||
(new AdminAuthCache($params['id']))->clearAuthCache();
|
||||
|
||||
// 删除旧的关联信息
|
||||
AdminRole::delByUserId($params['id']);
|
||||
AdminDept::delByUserId($params['id']);
|
||||
AdminJobs::delByUserId($params['id']);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 过期token
|
||||
* @param $token
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 10:46
|
||||
*/
|
||||
public static function expireToken($token): bool
|
||||
{
|
||||
$adminSession = AdminSession::where('token', '=', $token)
|
||||
->with('admin')
|
||||
->find();
|
||||
|
||||
if (empty($adminSession)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$adminSession->expire_time = $time;
|
||||
$adminSession->update_time = $time;
|
||||
$adminSession->save();
|
||||
|
||||
return (new AdminTokenCache())->deleteAdminInfo($token);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 查看管理员详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 11:07
|
||||
*/
|
||||
public static function detail($params, $action = 'detail'): array
|
||||
{
|
||||
$admin = Admin::field([
|
||||
'id', 'account', 'name', 'disable', 'root',
|
||||
'multipoint_login', 'avatar',
|
||||
])->findOrEmpty($params['id'])->toArray();
|
||||
|
||||
if ($action == 'detail') {
|
||||
return $admin;
|
||||
}
|
||||
|
||||
$result['user'] = $admin;
|
||||
// 当前管理员角色拥有的菜单
|
||||
$result['menu'] = MenuLogic::getMenuByAdminId($params['id']);
|
||||
// 当前管理员橘色拥有的按钮权限
|
||||
$result['permissions'] = AuthLogic::getBtnAuthByRoleId($admin);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑超级管理员
|
||||
* @param $params
|
||||
* @return Admin
|
||||
* @author 乔峰
|
||||
* @date 2022/4/8 17:54
|
||||
*/
|
||||
public static function editSelf($params)
|
||||
{
|
||||
$data = [
|
||||
'id' => $params['admin_id'],
|
||||
'name' => $params['name'],
|
||||
'avatar' => FileService::setFileUrl($params['avatar']),
|
||||
];
|
||||
|
||||
if (!empty($params['password'])) {
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$data['password'] = create_password($params['password'], $passwordSalt);
|
||||
}
|
||||
|
||||
return Admin::update($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 新增角色
|
||||
* @param $adminId
|
||||
* @param $roleIds
|
||||
* @throws \Exception
|
||||
* @author 乔峰
|
||||
* @date 2022/11/25 14:23
|
||||
*/
|
||||
public static function insertRole($adminId, $roleIds)
|
||||
{
|
||||
if (!empty($roleIds)) {
|
||||
// 角色
|
||||
$roleData = [];
|
||||
foreach ($roleIds as $roleId) {
|
||||
$roleData[] = [
|
||||
'admin_id' => $adminId,
|
||||
'role_id' => $roleId,
|
||||
];
|
||||
}
|
||||
(new AdminRole())->saveAll($roleData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 新增部门
|
||||
* @param $adminId
|
||||
* @param $deptIds
|
||||
* @throws \Exception
|
||||
* @author 乔峰
|
||||
* @date 2022/11/25 14:22
|
||||
*/
|
||||
public static function insertDept($adminId, $deptIds)
|
||||
{
|
||||
// 部门
|
||||
if (!empty($deptIds)) {
|
||||
$deptData = [];
|
||||
foreach ($deptIds as $deptId) {
|
||||
$deptData[] = [
|
||||
'admin_id' => $adminId,
|
||||
'dept_id' => $deptId
|
||||
];
|
||||
}
|
||||
(new AdminDept())->saveAll($deptData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 新增岗位
|
||||
* @param $adminId
|
||||
* @param $jobsIds
|
||||
* @throws \Exception
|
||||
* @author 乔峰
|
||||
* @date 2022/11/25 14:22
|
||||
*/
|
||||
public static function insertJobs($adminId, $jobsIds)
|
||||
{
|
||||
// 岗位
|
||||
if (!empty($jobsIds)) {
|
||||
$jobsData = [];
|
||||
foreach ($jobsIds as $jobsId) {
|
||||
$jobsData[] = [
|
||||
'admin_id' => $adminId,
|
||||
'jobs_id' => $jobsId
|
||||
];
|
||||
}
|
||||
(new AdminJobs())->saveAll($jobsData);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
105
app/admin/logic/auth/AuthLogic.php
Executable file
105
app/admin/logic/auth/AuthLogic.php
Executable file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\auth;
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\auth\AdminRole;
|
||||
use app\common\model\auth\SystemMenu;
|
||||
use app\common\model\auth\SystemRoleMenu;
|
||||
|
||||
|
||||
/**
|
||||
* 权限功能类
|
||||
* Class AuthLogic
|
||||
* @package app\admin\logic\auth
|
||||
*/
|
||||
class AuthLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取全部权限
|
||||
* @return mixed
|
||||
* @author 乔峰
|
||||
* @date 2022/7/1 11:55
|
||||
*/
|
||||
public static function getAllAuth()
|
||||
{
|
||||
return SystemMenu::distinct(true)
|
||||
->where([
|
||||
['is_disable', '=', 0],
|
||||
['perms', '<>', '']
|
||||
])
|
||||
->column('perms');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取当前管理员角色按钮权限
|
||||
* @param $roleId
|
||||
* @return mixed
|
||||
* @author 乔峰
|
||||
* @date 2022/7/1 16:10
|
||||
*/
|
||||
public static function getBtnAuthByRoleId($admin)
|
||||
{
|
||||
if ($admin['root']) {
|
||||
return ['*'];
|
||||
}
|
||||
|
||||
$menuId = SystemRoleMenu::whereIn('role_id', $admin['role_id'])
|
||||
->column('menu_id');
|
||||
|
||||
$where[] = ['is_disable', '=', 0];
|
||||
$where[] = ['perms', '<>', ''];
|
||||
|
||||
$roleAuth = SystemMenu::distinct(true)
|
||||
->where('id', 'in', $menuId)
|
||||
->where($where)
|
||||
->column('perms');
|
||||
|
||||
$allAuth = SystemMenu::distinct(true)
|
||||
->where($where)
|
||||
->column('perms');
|
||||
|
||||
$hasAllAuth = array_diff($allAuth, $roleAuth);
|
||||
if (empty($hasAllAuth)) {
|
||||
return ['*'];
|
||||
}
|
||||
|
||||
return $roleAuth;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取管理员角色关联的菜单id(菜单,权限)
|
||||
* @param int $adminId
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/7/1 15:56
|
||||
*/
|
||||
public static function getAuthByAdminId(int $adminId): array
|
||||
{
|
||||
$roleIds = AdminRole::where('admin_id', $adminId)->column('role_id');
|
||||
$menuId = SystemRoleMenu::whereIn('role_id', $roleIds)->column('menu_id');
|
||||
|
||||
return SystemMenu::distinct(true)
|
||||
->where([
|
||||
['is_disable', '=', 0],
|
||||
['perms', '<>', ''],
|
||||
['id', 'in', array_unique($menuId)],
|
||||
])
|
||||
->column('perms');
|
||||
}
|
||||
}
|
184
app/admin/logic/auth/MenuLogic.php
Executable file
184
app/admin/logic/auth/MenuLogic.php
Executable file
@ -0,0 +1,184 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\auth;
|
||||
|
||||
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\auth\SystemMenu;
|
||||
use app\common\model\auth\SystemRoleMenu;
|
||||
|
||||
|
||||
/**
|
||||
* 系统菜单
|
||||
* Class MenuLogic
|
||||
* @package app\admin\logic\auth
|
||||
*/
|
||||
class MenuLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取管理员对应的角色菜单
|
||||
* @param $adminId
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2022/7/1 10:50
|
||||
*/
|
||||
public static function getMenuByAdminId($adminId)
|
||||
{
|
||||
$admin = Admin::findOrEmpty($adminId);
|
||||
|
||||
$where = [];
|
||||
$where[] = ['type', 'in', ['M', 'C']];
|
||||
$where[] = ['is_disable', '=', 0];
|
||||
|
||||
if ($admin['root'] != 1) {
|
||||
$roleMenu = SystemRoleMenu::whereIn('role_id', $admin['role_id'])->column('menu_id');
|
||||
$where[] = ['id', 'in', $roleMenu];
|
||||
}
|
||||
|
||||
$menu = SystemMenu::where($where)
|
||||
->order(['sort' => 'desc', 'id' => 'asc'])
|
||||
->select();
|
||||
|
||||
return linear_to_tree($menu, 'children');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加菜单
|
||||
* @param array $params
|
||||
* @return SystemMenu|\think\Model
|
||||
* @author 乔峰
|
||||
* @date 2022/6/30 10:06
|
||||
*/
|
||||
public static function add(array $params)
|
||||
{
|
||||
return SystemMenu::create([
|
||||
'pid' => $params['pid'],
|
||||
'type' => $params['type'],
|
||||
'name' => $params['name'],
|
||||
'icon' => $params['icon'] ?? '',
|
||||
'sort' => $params['sort'],
|
||||
'perms' => $params['perms'] ?? '',
|
||||
'paths' => $params['paths'] ?? '',
|
||||
'component' => $params['component'] ?? '',
|
||||
'selected' => $params['selected'] ?? '',
|
||||
'params' => $params['params'] ?? '',
|
||||
'is_cache' => $params['is_cache'],
|
||||
'is_show' => $params['is_show'],
|
||||
'is_disable' => $params['is_disable'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑菜单
|
||||
* @param array $params
|
||||
* @return SystemMenu
|
||||
* @author 乔峰
|
||||
* @date 2022/6/30 10:07
|
||||
*/
|
||||
public static function edit(array $params)
|
||||
{
|
||||
return SystemMenu::update([
|
||||
'id' => $params['id'],
|
||||
'pid' => $params['pid'],
|
||||
'type' => $params['type'],
|
||||
'name' => $params['name'],
|
||||
'icon' => $params['icon'] ?? '',
|
||||
'sort' => $params['sort'],
|
||||
'perms' => $params['perms'] ?? '',
|
||||
'paths' => $params['paths'] ?? '',
|
||||
'component' => $params['component'] ?? '',
|
||||
'selected' => $params['selected'] ?? '',
|
||||
'params' => $params['params'] ?? '',
|
||||
'is_cache' => $params['is_cache'],
|
||||
'is_show' => $params['is_show'],
|
||||
'is_disable' => $params['is_disable'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/6/30 9:54
|
||||
*/
|
||||
public static function detail($params)
|
||||
{
|
||||
return SystemMenu::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除菜单
|
||||
* @param $params
|
||||
* @author 乔峰
|
||||
* @date 2022/6/30 9:47
|
||||
*/
|
||||
public static function delete($params)
|
||||
{
|
||||
// 删除菜单
|
||||
SystemMenu::destroy($params['id']);
|
||||
// 删除角色-菜单表中 与该菜单关联的记录
|
||||
SystemRoleMenu::where(['menu_id' => $params['id']])->delete();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 更新状态
|
||||
* @param array $params
|
||||
* @return SystemMenu
|
||||
* @author 乔峰
|
||||
* @date 2022/7/6 17:02
|
||||
*/
|
||||
public static function updateStatus(array $params)
|
||||
{
|
||||
return SystemMenu::update([
|
||||
'id' => $params['id'],
|
||||
'is_disable' => $params['is_disable']
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 全部数据
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2022/10/13 11:03
|
||||
*/
|
||||
public static function getAllData()
|
||||
{
|
||||
$data = SystemMenu::where(['is_disable' => YesNoEnum::NO])
|
||||
->field('id,pid,name')
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return linear_to_tree($data, 'children');
|
||||
}
|
||||
|
||||
}
|
170
app/admin/logic/auth/RoleLogic.php
Executable file
170
app/admin/logic/auth/RoleLogic.php
Executable file
@ -0,0 +1,170 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\auth;
|
||||
|
||||
use app\common\{
|
||||
cache\AdminAuthCache,
|
||||
model\auth\SystemRole,
|
||||
logic\BaseLogic,
|
||||
model\auth\SystemRoleMenu
|
||||
};
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 角色逻辑层
|
||||
* Class RoleLogic
|
||||
* @package app\admin\logic\auth
|
||||
*/
|
||||
class RoleLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 添加角色
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 11:50
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$menuId = !empty($params['menu_id']) ? $params['menu_id'] : [];
|
||||
|
||||
$role = SystemRole::create([
|
||||
'name' => $params['name'],
|
||||
'desc' => $params['desc'] ?? '',
|
||||
'sort' => $params['sort'] ?? 0,
|
||||
]);
|
||||
|
||||
$data = [];
|
||||
foreach ($menuId as $item) {
|
||||
if (empty($item)) {
|
||||
continue;
|
||||
}
|
||||
$data[] = [
|
||||
'role_id' => $role['id'],
|
||||
'menu_id' => $item,
|
||||
];
|
||||
}
|
||||
(new SystemRoleMenu)->insertAll($data);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑角色
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 14:16
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$menuId = !empty($params['menu_id']) ? $params['menu_id'] : [];
|
||||
|
||||
SystemRole::update([
|
||||
'id' => $params['id'],
|
||||
'name' => $params['name'],
|
||||
'desc' => $params['desc'] ?? '',
|
||||
'sort' => $params['sort'] ?? 0,
|
||||
]);
|
||||
|
||||
if (!empty($menuId)) {
|
||||
SystemRoleMenu::where(['role_id' => $params['id']])->delete();
|
||||
$data = [];
|
||||
foreach ($menuId as $item) {
|
||||
$data[] = [
|
||||
'role_id' => $params['id'],
|
||||
'menu_id' => $item,
|
||||
];
|
||||
}
|
||||
(new SystemRoleMenu)->insertAll($data);
|
||||
}
|
||||
|
||||
(new AdminAuthCache())->deleteTag();
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除角色
|
||||
* @param int $id
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 14:16
|
||||
*/
|
||||
public static function delete(int $id)
|
||||
{
|
||||
SystemRole::destroy(['id' => $id]);
|
||||
(new AdminAuthCache())->deleteTag();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 角色详情
|
||||
* @param int $id
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 14:17
|
||||
*/
|
||||
public static function detail(int $id): array
|
||||
{
|
||||
$detail = SystemRole::field('id,name,desc,sort')->find($id);
|
||||
$authList = $detail->roleMenuIndex()->select()->toArray();
|
||||
$menuId = array_column($authList, 'menu_id');
|
||||
$detail['menu_id'] = $menuId;
|
||||
return $detail->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 角色数据
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2022/10/13 10:39
|
||||
*/
|
||||
public static function getAllData()
|
||||
{
|
||||
return SystemRole::order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
}
|
56
app/admin/logic/channel/AppSettingLogic.php
Executable file
56
app/admin/logic/channel/AppSettingLogic.php
Executable file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\admin\logic\channel;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\ConfigService;
|
||||
|
||||
/**
|
||||
* App设置逻辑层
|
||||
* Class AppSettingLogic
|
||||
* @package app\admin\logic\settings\app
|
||||
*/
|
||||
class AppSettingLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取App设置
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 10:25
|
||||
*/
|
||||
public static function getConfig()
|
||||
{
|
||||
$config = [
|
||||
'ios_download_url' => ConfigService::get('app', 'ios_download_url', ''),
|
||||
'android_download_url' => ConfigService::get('app', 'android_download_url', ''),
|
||||
'download_title' => ConfigService::get('app', 'download_title', ''),
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes App设置
|
||||
* @param $params
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 10:26
|
||||
*/
|
||||
public static function setConfig($params)
|
||||
{
|
||||
ConfigService::set('app', 'ios_download_url', $params['ios_download_url'] ?? '');
|
||||
ConfigService::set('app', 'android_download_url', $params['android_download_url'] ?? '');
|
||||
ConfigService::set('app', 'download_title', $params['download_title'] ?? '');
|
||||
}
|
||||
}
|
72
app/admin/logic/channel/MnpSettingsLogic.php
Executable file
72
app/admin/logic/channel/MnpSettingsLogic.php
Executable file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\channel;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
|
||||
/**
|
||||
* 小程序设置逻辑
|
||||
* Class MnpSettingsLogic
|
||||
* @package app\admin\logic\channel
|
||||
*/
|
||||
class MnpSettingsLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 获取小程序配置
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/16 9:38 上午
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$domainName = $_SERVER['SERVER_NAME'];
|
||||
$qrCode = ConfigService::get('mnp_setting', 'qr_code', '');
|
||||
$qrCode = empty($qrCode) ? $qrCode : FileService::getFileUrl($qrCode);
|
||||
$config = [
|
||||
'name' => ConfigService::get('mnp_setting', 'name', ''),
|
||||
'original_id' => ConfigService::get('mnp_setting', 'original_id', ''),
|
||||
'qr_code' => $qrCode,
|
||||
'app_id' => ConfigService::get('mnp_setting', 'app_id', ''),
|
||||
'app_secret' => ConfigService::get('mnp_setting', 'app_secret', ''),
|
||||
'request_domain' => 'https://'.$domainName,
|
||||
'socket_domain' => 'wss://'.$domainName,
|
||||
'upload_file_domain' => 'https://'.$domainName,
|
||||
'download_file_domain' => 'https://'.$domainName,
|
||||
'udp_domain' => 'udp://'.$domainName,
|
||||
'business_domain' => $domainName,
|
||||
];
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置小程序配置
|
||||
* @param $params
|
||||
* @author ljj
|
||||
* @date 2022/2/16 9:51 上午
|
||||
*/
|
||||
public function setConfig($params)
|
||||
{
|
||||
$qrCode = isset($params['qr_code']) ? FileService::setFileUrl($params['qr_code']) : '';
|
||||
|
||||
ConfigService::set('mnp_setting','name', $params['name'] ?? '');
|
||||
ConfigService::set('mnp_setting','original_id',$params['original_id'] ?? '');
|
||||
ConfigService::set('mnp_setting','qr_code',$qrCode);
|
||||
ConfigService::set('mnp_setting','app_id',$params['app_id']);
|
||||
ConfigService::set('mnp_setting','app_secret',$params['app_secret']);
|
||||
}
|
||||
}
|
228
app/admin/logic/channel/OfficialAccountMenuLogic.php
Executable file
228
app/admin/logic/channel/OfficialAccountMenuLogic.php
Executable file
@ -0,0 +1,228 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\channel;
|
||||
|
||||
use app\common\enum\OfficialAccountEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\ConfigService;
|
||||
use EasyWeChat\Factory;
|
||||
|
||||
/**
|
||||
* 微信公众号菜单逻辑层
|
||||
* Class OfficialAccountMenuLogic
|
||||
* @package app\admin\logic\wechat
|
||||
*/
|
||||
class OfficialAccountMenuLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 保存
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 10:43
|
||||
*/
|
||||
public static function save($params)
|
||||
{
|
||||
try {
|
||||
self::checkMenu($params);
|
||||
ConfigService::set('oa_setting', 'menu', $params);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
OfficialAccountMenuLogic::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 一级菜单校验
|
||||
* @param $menu
|
||||
* @throws \Exception
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 10:55
|
||||
*/
|
||||
public static function checkMenu($menu)
|
||||
{
|
||||
if (empty($menu) || !is_array($menu)) {
|
||||
throw new \Exception('请设置正确格式菜单');
|
||||
}
|
||||
|
||||
if (count($menu) > 3) {
|
||||
throw new \Exception('一级菜单超出限制(最多3个)');
|
||||
}
|
||||
|
||||
foreach ($menu as $item) {
|
||||
if (!is_array($item)) {
|
||||
throw new \Exception('一级菜单项须为数组格式');
|
||||
}
|
||||
|
||||
if (empty($item['name'])) {
|
||||
throw new \Exception('请输入一级菜单名称');
|
||||
}
|
||||
|
||||
if (false == $item['has_menu']) {
|
||||
if (empty($item['type'])) {
|
||||
throw new \Exception('一级菜单未选择菜单类型');
|
||||
}
|
||||
if (!in_array($item['type'], OfficialAccountEnum::MENU_TYPE)) {
|
||||
throw new \Exception('一级菜单类型错误');
|
||||
}
|
||||
self::checkType($item);
|
||||
}
|
||||
|
||||
if (true == $item['has_menu'] && empty($item['sub_button'])) {
|
||||
throw new \Exception('请配置子菜单');
|
||||
}
|
||||
|
||||
self::checkType($item);
|
||||
|
||||
if (!empty($item['sub_button'])) {
|
||||
self::checkSubButton($item['sub_button']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 二级菜单校验
|
||||
* @param $subButtion
|
||||
* @throws \Exception
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 10:55
|
||||
*/
|
||||
public static function checkSubButton($subButtion)
|
||||
{
|
||||
if (!is_array($subButtion)) {
|
||||
throw new \Exception('二级菜单须为数组格式');
|
||||
}
|
||||
|
||||
if (count($subButtion) > 5) {
|
||||
throw new \Exception('二级菜单超出限制(最多5个)');
|
||||
}
|
||||
|
||||
foreach ($subButtion as $subItem) {
|
||||
if (!is_array($subItem)) {
|
||||
throw new \Exception('二级菜单项须为数组');
|
||||
}
|
||||
|
||||
if (empty($subItem['name'])) {
|
||||
throw new \Exception('请输入二级菜单名称');
|
||||
}
|
||||
|
||||
if (empty($subItem['type']) || !in_array($subItem['type'], OfficialAccountEnum::MENU_TYPE)) {
|
||||
throw new \Exception('二级未选择菜单类型或菜单类型错误');
|
||||
}
|
||||
|
||||
self::checkType($subItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 菜单类型校验
|
||||
* @param $item
|
||||
* @throws \Exception
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 10:55
|
||||
*/
|
||||
public static function checkType($item)
|
||||
{
|
||||
switch ($item['type']) {
|
||||
// 关键字
|
||||
case 'click':
|
||||
if (empty($item['key'])) {
|
||||
throw new \Exception('请输入关键字');
|
||||
}
|
||||
break;
|
||||
// 跳转网页链接
|
||||
case 'view':
|
||||
if (empty($item['url'])) {
|
||||
throw new \Exception('请输入网页链接');
|
||||
}
|
||||
break;
|
||||
// 小程序
|
||||
case 'miniprogram':
|
||||
if (empty($item['url'])) {
|
||||
throw new \Exception('请输入网页链接');
|
||||
}
|
||||
if (empty($item['appid'])) {
|
||||
throw new \Exception('请输入appid');
|
||||
}
|
||||
if (empty($item['pagepath'])) {
|
||||
throw new \Exception('请输入小程序路径');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 保存发布菜单
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 10:55
|
||||
*/
|
||||
public static function saveAndPublish($params)
|
||||
{
|
||||
try {
|
||||
self::checkMenu($params);
|
||||
|
||||
$officialAccountSetting = (new OfficialAccountSettingLogic())->getConfig();
|
||||
if (empty($officialAccountSetting['app_id']) || empty($officialAccountSetting['app_secret'])) {
|
||||
throw new \Exception('请先配置好微信公众号');
|
||||
}
|
||||
|
||||
$app = Factory::officialAccount([
|
||||
'app_id' => $officialAccountSetting['app_id'],
|
||||
'secret' => $officialAccountSetting['app_secret'],
|
||||
'response_type' => 'array',
|
||||
]);
|
||||
|
||||
$result = $app->menu->create($params);
|
||||
if ($result['errcode'] == 0) {
|
||||
ConfigService::set('oa_setting', 'menu', $params);
|
||||
return true;
|
||||
}
|
||||
|
||||
self::setError('保存发布菜单失败' . json_encode($result));
|
||||
return false;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 查看菜单详情
|
||||
* @return array|int|mixed|string|null
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 10:56
|
||||
*/
|
||||
public static function detail()
|
||||
{
|
||||
$data = ConfigService::get('oa_setting', 'menu', []);
|
||||
|
||||
if (!empty($data)) {
|
||||
foreach ($data as &$item) {
|
||||
$item['has_menu'] = !empty($item['has_menu']);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
217
app/admin/logic/channel/OfficialAccountReplyLogic.php
Executable file
217
app/admin/logic/channel/OfficialAccountReplyLogic.php
Executable file
@ -0,0 +1,217 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\channel;
|
||||
|
||||
use app\common\enum\OfficialAccountEnum;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\channel\OfficialAccountReply;
|
||||
use EasyWeChat\Factory;
|
||||
use EasyWeChat\Kernel\Messages\Text;
|
||||
|
||||
/**
|
||||
* 微信公众号回复逻辑层
|
||||
* Class OfficialAccountReplyLogic
|
||||
* @package app\admin\logic\channel
|
||||
*/
|
||||
class OfficialAccountReplyLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 添加回复(关注/关键词/默认)
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 10:57
|
||||
*/
|
||||
public static function add($params)
|
||||
{
|
||||
try {
|
||||
// 关键字回复排序值须大于0
|
||||
if ($params['reply_type'] == OfficialAccountEnum::REPLY_TYPE_KEYWORD && $params['sort'] <= 0) {
|
||||
throw new \Exception('排序值须大于0');
|
||||
}
|
||||
if ($params['reply_type'] != OfficialAccountEnum::REPLY_TYPE_KEYWORD && $params['status']) {
|
||||
// 非关键词回复只能有一条记录处于启用状态,所以将该回复类型下的已有记录置为禁用状态
|
||||
OfficialAccountReply::where(['reply_type' => $params['reply_type']])->update(['status' => YesNoEnum::NO]);
|
||||
}
|
||||
OfficialAccountReply::create($params);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 查看回复详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:00
|
||||
*/
|
||||
public static function detail($params)
|
||||
{
|
||||
$field = 'id,name,keyword,reply_type,matching_type,content_type,content,status,sort';
|
||||
$field .= ',reply_type as reply_type_desc, matching_type as matching_type_desc, content_type as content_type_desc, status as status_desc';
|
||||
return OfficialAccountReply::field($field)->findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑回复(关注/关键词/默认)
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:01
|
||||
*/
|
||||
public static function edit($params)
|
||||
{
|
||||
try {
|
||||
// 关键字回复排序值须大于0
|
||||
if ($params['reply_type'] == OfficialAccountEnum::REPLY_TYPE_KEYWORD && $params['sort'] <= 0) {
|
||||
throw new \Exception('排序值须大于0');
|
||||
}
|
||||
if ($params['reply_type'] != OfficialAccountEnum::REPLY_TYPE_KEYWORD && $params['status']) {
|
||||
// 非关键词回复只能有一条记录处于启用状态,所以将该回复类型下的已有记录置为禁用状态
|
||||
OfficialAccountReply::where(['reply_type' => $params['reply_type']])->update(['status' => YesNoEnum::NO]);
|
||||
}
|
||||
OfficialAccountReply::update($params);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除回复(关注/关键词/默认)
|
||||
* @param $params
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:01
|
||||
*/
|
||||
public static function delete($params)
|
||||
{
|
||||
OfficialAccountReply::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 更新排序
|
||||
* @param $params
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:01
|
||||
*/
|
||||
public static function sort($params)
|
||||
{
|
||||
$params['sort'] = $params['new_sort'];
|
||||
OfficialAccountReply::update($params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 更新状态
|
||||
* @param $params
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:01
|
||||
*/
|
||||
public static function status($params)
|
||||
{
|
||||
$reply = OfficialAccountReply::findOrEmpty($params['id']);
|
||||
$reply->status = !$reply->status;
|
||||
$reply->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 微信公众号回调
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\BadRequestException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \ReflectionException
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:01
|
||||
*/
|
||||
public static function index()
|
||||
{
|
||||
// 确认此次GET请求来自微信服务器,原样返回echostr参数内容,接入生效,成为开发者成功
|
||||
if (isset($_GET['echostr'])) {
|
||||
echo $_GET['echostr'];
|
||||
exit;
|
||||
}
|
||||
|
||||
$officialAccountSetting = (new OfficialAccountSettingLogic())->getConfig();
|
||||
$config = [
|
||||
'app_id' => $officialAccountSetting['app_id'],
|
||||
'secret' => $officialAccountSetting['app_secret'],
|
||||
'response_type' => 'array',
|
||||
];
|
||||
$app = Factory::officialAccount($config);
|
||||
|
||||
$app->server->push(function ($message) {
|
||||
switch ($message['MsgType']) { // 消息类型
|
||||
case OfficialAccountEnum::MSG_TYPE_EVENT: // 事件
|
||||
switch ($message['Event']) {
|
||||
case OfficialAccountEnum::EVENT_SUBSCRIBE: // 关注事件
|
||||
$reply_content = OfficialAccountReply::where(['reply_type' => OfficialAccountEnum::REPLY_TYPE_FOLLOW, 'status' => YesNoEnum::YES])
|
||||
->value('content');
|
||||
|
||||
if (empty($reply_content)) {
|
||||
// 未启用关注回复 或 关注回复内容为空
|
||||
$reply_content = OfficialAccountReply::where(['reply_type' => OfficialAccountEnum::REPLY_TYPE_DEFAULT, 'status' => YesNoEnum::YES])
|
||||
->value('content');
|
||||
}
|
||||
if ($reply_content) {
|
||||
$text = new Text($reply_content);
|
||||
return $text;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case OfficialAccountEnum::MSG_TYPE_TEXT: // 文本
|
||||
$reply_list = OfficialAccountReply::where(['reply_type' => OfficialAccountEnum::REPLY_TYPE_KEYWORD, 'status' => YesNoEnum::YES])
|
||||
->order('sort asc')
|
||||
->select();
|
||||
$reply_content = '';
|
||||
foreach ($reply_list as $reply) {
|
||||
switch ($reply['matching_type']) {
|
||||
case OfficialAccountEnum::MATCHING_TYPE_FULL:
|
||||
$reply['keyword'] === $message['Content'] && $reply_content = $reply['content'];
|
||||
break;
|
||||
case OfficialAccountEnum::MATCHING_TYPE_FUZZY:
|
||||
stripos($message['Content'], $reply['keyword']) !== false && $reply_content = $reply['content'];
|
||||
break;
|
||||
}
|
||||
if ($reply_content) {
|
||||
break; // 得到回复文本,中止循环
|
||||
}
|
||||
}
|
||||
//消息回复为空的话,找默认回复
|
||||
if (empty($reply_content)) {
|
||||
$reply_content = OfficialAccountReply::where(['reply_type' => OfficialAccountEnum::REPLY_TYPE_DEFAULT, 'status' => YesNoEnum::YES])
|
||||
->value('content');
|
||||
}
|
||||
if ($reply_content) {
|
||||
$text = new Text($reply_content);
|
||||
return $text;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
$response = $app->server->serve();
|
||||
$response->send();
|
||||
}
|
||||
}
|
76
app/admin/logic/channel/OfficialAccountSettingLogic.php
Executable file
76
app/admin/logic/channel/OfficialAccountSettingLogic.php
Executable file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\channel;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
|
||||
/**
|
||||
* 公众号设置逻辑
|
||||
* Class OfficialAccountSettingLogic
|
||||
* @package app\admin\logic\channel
|
||||
*/
|
||||
class OfficialAccountSettingLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 获取公众号配置
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/16 10:08 上午
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$domainName = $_SERVER['SERVER_NAME'];
|
||||
$qrCode = ConfigService::get('oa_setting', 'qr_code', '');
|
||||
$qrCode = empty($qrCode) ? $qrCode : FileService::getFileUrl($qrCode);
|
||||
$config = [
|
||||
'name' => ConfigService::get('oa_setting', 'name', ''),
|
||||
'original_id' => ConfigService::get('oa_setting', 'original_id', ''),
|
||||
'qr_code' => $qrCode,
|
||||
'app_id' => ConfigService::get('oa_setting', 'app_id', ''),
|
||||
'app_secret' => ConfigService::get('oa_setting', 'app_secret', ''),
|
||||
// url()方法返回Url实例,通过与空字符串连接触发该实例的__toString()方法以得到路由地址
|
||||
'url' => url('admin/wechat.official_account_reply/index', [],'',true).'',
|
||||
'token' => ConfigService::get('oa_setting', 'token'),
|
||||
'encoding_aes_key' => ConfigService::get('oa_setting', 'encoding_aes_key', ''),
|
||||
'encryption_type' => ConfigService::get('oa_setting', 'encryption_type'),
|
||||
'business_domain' => $domainName,
|
||||
'js_secure_domain' => $domainName,
|
||||
'web_auth_domain' => $domainName,
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置公众号配置
|
||||
* @param $params
|
||||
* @author ljj
|
||||
* @date 2022/2/16 10:08 上午
|
||||
*/
|
||||
public function setConfig($params)
|
||||
{
|
||||
$qrCode = isset($params['qr_code']) ? FileService::setFileUrl($params['qr_code']) : '';
|
||||
|
||||
ConfigService::set('oa_setting','name', $params['name'] ?? '');
|
||||
ConfigService::set('oa_setting','original_id', $params['original_id'] ?? '');
|
||||
ConfigService::set('oa_setting','qr_code', $qrCode);
|
||||
ConfigService::set('oa_setting','app_id',$params['app_id']);
|
||||
ConfigService::set('oa_setting','app_secret',$params['app_secret']);
|
||||
ConfigService::set('oa_setting','token',$params['token'] ?? '');
|
||||
ConfigService::set('oa_setting','encoding_aes_key',$params['encoding_aes_key'] ?? '');
|
||||
ConfigService::set('oa_setting','encryption_type',$params['encryption_type']);
|
||||
}
|
||||
}
|
55
app/admin/logic/channel/OpenSettingLogic.php
Executable file
55
app/admin/logic/channel/OpenSettingLogic.php
Executable file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\admin\logic\channel;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\ConfigService;
|
||||
|
||||
/**
|
||||
* 微信开放平台
|
||||
* Class AppSettingLogic
|
||||
* @package app\admin\logic\settings\app
|
||||
*/
|
||||
class OpenSettingLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取微信开放平台设置
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:03
|
||||
*/
|
||||
public static function getConfig()
|
||||
{
|
||||
$config = [
|
||||
'app_id' => ConfigService::get('open_platform', 'app_id', ''),
|
||||
'app_secret' => ConfigService::get('open_platform', 'app_secret', ''),
|
||||
];
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 微信开放平台设置
|
||||
* @param $params
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:03
|
||||
*/
|
||||
public static function setConfig($params)
|
||||
{
|
||||
ConfigService::set('open_platform', 'app_id', $params['app_id'] ?? '');
|
||||
ConfigService::set('open_platform', 'app_secret', $params['app_secret'] ?? '');
|
||||
}
|
||||
}
|
59
app/admin/logic/channel/WebPageSettingLogic.php
Executable file
59
app/admin/logic/channel/WebPageSettingLogic.php
Executable file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\admin\logic\channel;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\ConfigService;
|
||||
|
||||
/**
|
||||
* H5设置逻辑层
|
||||
* Class HFiveSettingLogic
|
||||
* @package app\admin\logic\settings\h5
|
||||
*/
|
||||
class WebPageSettingLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 获取H5设置
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 10:34
|
||||
*/
|
||||
public static function getConfig()
|
||||
{
|
||||
$config = [
|
||||
// 渠道状态 0-关闭 1-开启
|
||||
'status' => ConfigService::get('web_page', 'status', 1),
|
||||
// 关闭后渠道后访问页面 0-空页面 1-自定义链接
|
||||
'page_status' => ConfigService::get('web_page', 'page_status', 0),
|
||||
// 自定义链接
|
||||
'page_url' => ConfigService::get('web_page', 'page_url', ''),
|
||||
'url' => request()->domain() . '/mobile'
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes H5设置
|
||||
* @param $params
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 10:34
|
||||
*/
|
||||
public static function setConfig($params)
|
||||
{
|
||||
ConfigService::set('web_page', 'status', $params['status']);
|
||||
ConfigService::set('web_page', 'page_status', $params['page_status']);
|
||||
ConfigService::set('web_page', 'page_url', $params['page_url']);
|
||||
}
|
||||
}
|
169
app/admin/logic/crontab/CrontabLogic.php
Executable file
169
app/admin/logic/crontab/CrontabLogic.php
Executable file
@ -0,0 +1,169 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\admin\logic\crontab;
|
||||
|
||||
use app\common\enum\CrontabEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\Crontab;
|
||||
use Cron\CronExpression;
|
||||
|
||||
/**
|
||||
* 定时任务逻辑层
|
||||
* Class CrontabLogic
|
||||
* @package app\admin\logic\crontab
|
||||
*/
|
||||
class CrontabLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 添加定时任务
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 14:41
|
||||
*/
|
||||
public static function add($params)
|
||||
{
|
||||
try {
|
||||
$params['remark'] = $params['remark'] ?? '';
|
||||
$params['params'] = $params['params'] ?? '';
|
||||
$params['last_time'] = time();
|
||||
|
||||
Crontab::create($params);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 查看定时任务详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 14:41
|
||||
*/
|
||||
public static function detail($params)
|
||||
{
|
||||
$field = 'id,name,type,type as type_desc,command,params,status,status as status_desc,expression,remark';
|
||||
$crontab = Crontab::field($field)->findOrEmpty($params['id']);
|
||||
if ($crontab->isEmpty()) {
|
||||
return [];
|
||||
}
|
||||
return $crontab->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑定时任务
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 14:42
|
||||
*/
|
||||
public static function edit($params)
|
||||
{
|
||||
try {
|
||||
$params['remark'] = $params['remark'] ?? '';
|
||||
$params['params'] = $params['params'] ?? '';
|
||||
|
||||
Crontab::update($params);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除定时任务
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 14:42
|
||||
*/
|
||||
public static function delete($params)
|
||||
{
|
||||
try {
|
||||
Crontab::destroy($params['id']);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 操作定时任务
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 14:42
|
||||
*/
|
||||
public static function operate($params)
|
||||
{
|
||||
try {
|
||||
$crontab = Crontab::findOrEmpty($params['id']);
|
||||
if ($crontab->isEmpty()) {
|
||||
throw new \Exception('定时任务不存在');
|
||||
}
|
||||
switch ($params['operate']) {
|
||||
case 'start';
|
||||
$crontab->status = CrontabEnum::START;
|
||||
break;
|
||||
case 'stop':
|
||||
$crontab->status = CrontabEnum::STOP;
|
||||
break;
|
||||
}
|
||||
$crontab->save();
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取规则执行时间
|
||||
* @param $params
|
||||
* @return array|string
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 14:42
|
||||
*/
|
||||
public static function expression($params)
|
||||
{
|
||||
try {
|
||||
$cron = new CronExpression($params['expression']);
|
||||
$result = $cron->getMultipleRunDates(5);
|
||||
$result = json_decode(json_encode($result), true);
|
||||
$lists = [];
|
||||
foreach ($result as $k => $v) {
|
||||
$lists[$k]['time'] = $k + 1;
|
||||
$lists[$k]['date'] = str_replace('.000000', '', $v['date']);
|
||||
}
|
||||
$lists[] = ['time' => 'x', 'date' => '……'];
|
||||
return $lists;
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
56
app/admin/logic/decorate/DecorateDataLogic.php
Executable file
56
app/admin/logic/decorate/DecorateDataLogic.php
Executable file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\admin\logic\decorate;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\article\Article;
|
||||
|
||||
|
||||
/**
|
||||
* 装修页-数据
|
||||
* Class DecorateDataLogic
|
||||
* @package app\admin\logic\decorate
|
||||
*/
|
||||
class DecorateDataLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取文章列表
|
||||
* @param $limit
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2022/9/22 16:49
|
||||
*/
|
||||
public static function getArticleLists($limit)
|
||||
{
|
||||
$field = 'id,title,desc,abstract,image,author,content,
|
||||
click_virtual,click_actual,create_time';
|
||||
|
||||
return Article::where(['is_show' => 1])
|
||||
->field($field)
|
||||
->order(['id' => 'desc'])
|
||||
->limit($limit)
|
||||
->append(['click'])
|
||||
->hidden(['click_virtual', 'click_actual'])
|
||||
->select()->toArray();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
67
app/admin/logic/decorate/DecoratePageLogic.php
Executable file
67
app/admin/logic/decorate/DecoratePageLogic.php
Executable file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\admin\logic\decorate;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\decorate\DecoratePage;
|
||||
|
||||
|
||||
/**
|
||||
* 装修页面
|
||||
* Class DecoratePageLogic
|
||||
* @package app\admin\logic\theme
|
||||
*/
|
||||
class DecoratePageLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $id
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/9/14 18:41
|
||||
*/
|
||||
public static function getDetail($id)
|
||||
{
|
||||
return DecoratePage::findOrEmpty($id)->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 保存装修配置
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/9/15 9:37
|
||||
*/
|
||||
public static function save($params)
|
||||
{
|
||||
$pageData = DecoratePage::where(['id' => $params['id']])->findOrEmpty();
|
||||
if ($pageData->isEmpty()) {
|
||||
self::$error = '信息不存在';
|
||||
return false;
|
||||
}
|
||||
DecoratePage::update([
|
||||
'id' => $params['id'],
|
||||
'type' => $params['type'],
|
||||
'data' => $params['data'],
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
80
app/admin/logic/decorate/DecorateTabbarLogic.php
Executable file
80
app/admin/logic/decorate/DecorateTabbarLogic.php
Executable file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\admin\logic\decorate;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\decorate\DecorateTabbar;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
|
||||
|
||||
/**
|
||||
* 装修配置-底部导航
|
||||
* Class DecorateTabbarLogic
|
||||
* @package app\admin\logic\decorate
|
||||
*/
|
||||
class DecorateTabbarLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取底部导航详情
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2022/9/7 16:58
|
||||
*/
|
||||
public static function detail(): array
|
||||
{
|
||||
$list = DecorateTabbar::getTabbarLists();
|
||||
$style = ConfigService::get('tabbar', 'style', config('project.decorate.tabbar_style'));
|
||||
return ['style' => $style, 'list' => $list];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 底部导航保存
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
* @author 乔峰
|
||||
* @date 2022/9/7 17:19
|
||||
*/
|
||||
public static function save($params): bool
|
||||
{
|
||||
$model = new DecorateTabbar();
|
||||
// 删除旧配置数据
|
||||
$model->where('id', '>', 0)->delete();
|
||||
|
||||
// 保存数据
|
||||
$tabbars = $params['list'] ?? [];
|
||||
$data = [];
|
||||
foreach ($tabbars as $item) {
|
||||
$data[] = [
|
||||
'name' => $item['name'],
|
||||
'selected' => FileService::setFileUrl($item['selected']),
|
||||
'unselected' => FileService::setFileUrl($item['unselected']),
|
||||
'link' => $item['link'],
|
||||
];
|
||||
}
|
||||
$model->saveAll($data);
|
||||
|
||||
if (!empty($params['style'])) {
|
||||
ConfigService::set('tabbar', 'style', $params['style']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
202
app/admin/logic/dept/DeptLogic.php
Executable file
202
app/admin/logic/dept/DeptLogic.php
Executable file
@ -0,0 +1,202 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\dept;
|
||||
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\dept\Dept;
|
||||
|
||||
|
||||
/**
|
||||
* 部门管理逻辑
|
||||
* Class DeptLogic
|
||||
* @package app\admin\logic\dept
|
||||
*/
|
||||
class DeptLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 部门列表
|
||||
* @param $params
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2022/5/30 15:44
|
||||
*/
|
||||
public static function lists($params)
|
||||
{
|
||||
$where = [];
|
||||
if (!empty($params['name'])) {
|
||||
$where[] = ['name', 'like', '%' . $params['name'] . '%'];
|
||||
}
|
||||
if (isset($params['status']) && $params['status'] != '') {
|
||||
$where[] = ['status', '=', $params['status']];
|
||||
}
|
||||
$lists = Dept::where($where)
|
||||
->append(['status_desc'])
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$pid = 0;
|
||||
if (!empty($lists)) {
|
||||
$pid = min(array_column($lists, 'pid'));
|
||||
}
|
||||
return self::getTree($lists, $pid);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 列表树状结构
|
||||
* @param $array
|
||||
* @param int $pid
|
||||
* @param int $level
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/5/30 15:44
|
||||
*/
|
||||
public static function getTree($array, $pid = 0, $level = 0)
|
||||
{
|
||||
$list = [];
|
||||
foreach ($array as $key => $item) {
|
||||
if ($item['pid'] == $pid) {
|
||||
$item['level'] = $level;
|
||||
$item['children'] = self::getTree($array, $item['id'], $level + 1);
|
||||
$list[] = $item;
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 上级部门
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2022/5/26 18:36
|
||||
*/
|
||||
public static function leaderDept()
|
||||
{
|
||||
$lists = Dept::field(['id', 'name'])->where(['status' => 1])
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
return $lists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加部门
|
||||
* @param array $params
|
||||
* @author 乔峰
|
||||
* @date 2022/5/25 18:20
|
||||
*/
|
||||
public static function add(array $params)
|
||||
{
|
||||
Dept::create([
|
||||
'pid' => $params['pid'],
|
||||
'name' => $params['name'],
|
||||
'leader' => $params['leader'] ?? '',
|
||||
'mobile' => $params['mobile'] ?? '',
|
||||
'status' => $params['status'],
|
||||
'sort' => $params['sort'] ?? 0
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑部门
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/5/25 18:39
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
try {
|
||||
$pid = $params['pid'];
|
||||
$oldDeptData = Dept::findOrEmpty($params['id']);
|
||||
if ($oldDeptData['pid'] == 0) {
|
||||
$pid = 0;
|
||||
}
|
||||
|
||||
Dept::update([
|
||||
'id' => $params['id'],
|
||||
'pid' => $pid,
|
||||
'name' => $params['name'],
|
||||
'leader' => $params['leader'] ?? '',
|
||||
'mobile' => $params['mobile'] ?? '',
|
||||
'status' => $params['status'],
|
||||
'sort' => $params['sort'] ?? 0
|
||||
]);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除部门
|
||||
* @param array $params
|
||||
* @author 乔峰
|
||||
* @date 2022/5/25 18:40
|
||||
*/
|
||||
public static function delete(array $params)
|
||||
{
|
||||
Dept::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取部门详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/5/25 18:40
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return Dept::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 部门数据
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2022/10/13 10:19
|
||||
*/
|
||||
public static function getAllData()
|
||||
{
|
||||
$data = Dept::where(['status' => YesNoEnum::YES])
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$pid = min(array_column($data, 'pid'));
|
||||
return self::getTree($data, $pid);
|
||||
}
|
||||
|
||||
}
|
117
app/admin/logic/dept/JobsLogic.php
Executable file
117
app/admin/logic/dept/JobsLogic.php
Executable file
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\dept;
|
||||
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\dept\Jobs;
|
||||
|
||||
|
||||
/**
|
||||
* 岗位管理逻辑
|
||||
* Class JobsLogic
|
||||
* @package app\admin\logic\dept
|
||||
*/
|
||||
class JobsLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 新增岗位
|
||||
* @param array $params
|
||||
* @author 乔峰
|
||||
* @date 2022/5/26 9:58
|
||||
*/
|
||||
public static function add(array $params)
|
||||
{
|
||||
Jobs::create([
|
||||
'name' => $params['name'],
|
||||
'code' => $params['code'],
|
||||
'sort' => $params['sort'] ?? 0,
|
||||
'status' => $params['status'],
|
||||
'remark' => $params['remark'] ?? '',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑岗位
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/5/26 9:58
|
||||
*/
|
||||
public static function edit(array $params) : bool
|
||||
{
|
||||
try {
|
||||
Jobs::update([
|
||||
'id' => $params['id'],
|
||||
'name' => $params['name'],
|
||||
'code' => $params['code'],
|
||||
'sort' => $params['sort'] ?? 0,
|
||||
'status' => $params['status'],
|
||||
'remark' => $params['remark'] ?? '',
|
||||
]);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除岗位
|
||||
* @param array $params
|
||||
* @author 乔峰
|
||||
* @date 2022/5/26 9:59
|
||||
*/
|
||||
public static function delete(array $params)
|
||||
{
|
||||
Jobs::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取岗位详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/5/26 9:59
|
||||
*/
|
||||
public static function detail($params) : array
|
||||
{
|
||||
return Jobs::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 岗位数据
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2022/10/13 10:30
|
||||
*/
|
||||
public static function getAllData()
|
||||
{
|
||||
return Jobs::where(['status' => YesNoEnum::YES])
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
}
|
225
app/admin/logic/notice/NoticeLogic.php
Executable file
225
app/admin/logic/notice/NoticeLogic.php
Executable file
@ -0,0 +1,225 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\notice;
|
||||
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\notice\NoticeSetting;
|
||||
|
||||
/**
|
||||
* 通知逻辑层
|
||||
* Class NoticeLogic
|
||||
* @package app\admin\logic\notice
|
||||
*/
|
||||
class NoticeLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 查看通知设置详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:34
|
||||
*/
|
||||
public static function detail($params)
|
||||
{
|
||||
$field = 'id,type,scene_id,scene_name,scene_desc,system_notice,sms_notice,oa_notice,mnp_notice,support';
|
||||
$noticeSetting = NoticeSetting::field($field)->findOrEmpty($params['id'])->toArray();
|
||||
if (empty($noticeSetting)) {
|
||||
return [];
|
||||
}
|
||||
if (empty($noticeSetting['system_notice'])) {
|
||||
$noticeSetting['system_notice'] = [
|
||||
'title' => '',
|
||||
'content' => '',
|
||||
'status' => 0,
|
||||
];
|
||||
}
|
||||
$noticeSetting['system_notice']['tips'] = NoticeEnum::getOperationTips(NoticeEnum::SYSTEM, $noticeSetting['scene_id']);
|
||||
if (empty($noticeSetting['sms_notice'])) {
|
||||
$noticeSetting['sms_notice'] = [
|
||||
'template_id' => '',
|
||||
'content' => '',
|
||||
'status' => 0,
|
||||
];
|
||||
}
|
||||
$noticeSetting['sms_notice']['tips'] = NoticeEnum::getOperationTips(NoticeEnum::SMS, $noticeSetting['scene_id']);
|
||||
if (empty($noticeSetting['oa_notice'])) {
|
||||
$noticeSetting['oa_notice'] = [
|
||||
'template_id' => '',
|
||||
'template_sn' => '',
|
||||
'name' => '',
|
||||
'first' => '',
|
||||
'remark' => '',
|
||||
'tpl' => [],
|
||||
'status' => 0,
|
||||
];
|
||||
}
|
||||
$noticeSetting['oa_notice']['tips'] = NoticeEnum::getOperationTips(NoticeEnum::MNP, $noticeSetting['scene_id']);
|
||||
if (empty($noticeSetting['mnp_notice'])) {
|
||||
$noticeSetting['mnp_notice'] = [
|
||||
'template_id' => '',
|
||||
'template_sn' => '',
|
||||
'name' => '',
|
||||
'tpl' => [],
|
||||
'status' => 0,
|
||||
];
|
||||
}
|
||||
$noticeSetting['mnp_notice']['tips'] = NoticeEnum::getOperationTips(NoticeEnum::MNP, $noticeSetting['scene_id']);
|
||||
$noticeSetting['system_notice']['is_show'] = in_array(NoticeEnum::SYSTEM, explode(',', $noticeSetting['support']));
|
||||
$noticeSetting['sms_notice']['is_show'] = in_array(NoticeEnum::SMS, explode(',', $noticeSetting['support']));
|
||||
$noticeSetting['oa_notice']['is_show'] = in_array(NoticeEnum::OA, explode(',', $noticeSetting['support']));
|
||||
$noticeSetting['mnp_notice']['is_show'] = in_array(NoticeEnum::MNP, explode(',', $noticeSetting['support']));
|
||||
$noticeSetting['default'] = '';
|
||||
$noticeSetting['type'] = NoticeEnum::getTypeDesc($noticeSetting['type']);
|
||||
return $noticeSetting;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 通知设置
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:34
|
||||
*/
|
||||
public static function set($params)
|
||||
{
|
||||
try {
|
||||
// 校验参数
|
||||
self::checkSet($params);
|
||||
// 拼装更新数据
|
||||
$updateData = [];
|
||||
foreach ($params['template'] as $item) {
|
||||
$updateData[$item['type'] . '_notice'] = json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
// 更新通知设置
|
||||
NoticeSetting::where('id', $params['id'])->update($updateData);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验参数
|
||||
* @param $params
|
||||
* @throws \Exception
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:35
|
||||
*/
|
||||
public static function checkSet($params)
|
||||
{
|
||||
$noticeSetting = NoticeSetting::findOrEmpty($params['id'] ?? 0);
|
||||
|
||||
if ($noticeSetting->isEmpty()) {
|
||||
throw new \Exception('通知配置不存在');
|
||||
}
|
||||
|
||||
if (!isset($params['template']) || !is_array($params['template']) || count($params['template']) == 0) {
|
||||
throw new \Exception('模板配置不存在或格式错误');
|
||||
}
|
||||
|
||||
// 通知类型
|
||||
$noticeType = ['system', 'sms', 'oa', 'mnp'];
|
||||
|
||||
foreach ($params['template'] as $item) {
|
||||
if (!is_array($item)) {
|
||||
throw new \Exception('模板项格式错误');
|
||||
}
|
||||
|
||||
if (!isset($item['type']) || !in_array($item['type'], $noticeType)) {
|
||||
throw new \Exception('模板项缺少模板类型或模板类型有误');
|
||||
}
|
||||
|
||||
switch ($item['type']) {
|
||||
case "system";
|
||||
self::checkSystem($item);
|
||||
break;
|
||||
case "sms";
|
||||
self::checkSms($item);
|
||||
break;
|
||||
case "oa";
|
||||
self::checkOa($item);
|
||||
break;
|
||||
case "mnp";
|
||||
self::checkMnp($item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验系统通知参数
|
||||
* @param $item
|
||||
* @throws \Exception
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:35
|
||||
*/
|
||||
public static function checkSystem($item)
|
||||
{
|
||||
if (!isset($item['title']) || !isset($item['content']) || !isset($item['status'])) {
|
||||
throw new \Exception('系统通知必填参数:title、content、status');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验短信通知必填参数
|
||||
* @param $item
|
||||
* @throws \Exception
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:35
|
||||
*/
|
||||
public static function checkSms($item)
|
||||
{
|
||||
if (!isset($item['template_id']) || !isset($item['content']) || !isset($item['status'])) {
|
||||
throw new \Exception('短信通知必填参数:template_id、content、status');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验微信模板消息参数
|
||||
* @param $item
|
||||
* @throws \Exception
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:35
|
||||
*/
|
||||
public static function checkOa($item)
|
||||
{
|
||||
if (!isset($item['template_id']) || !isset($item['template_sn']) || !isset($item['name']) || !isset($item['first']) || !isset($item['remark']) || !isset($item['tpl']) || !isset($item['status'])) {
|
||||
throw new \Exception('微信模板消息必填参数:template_id、template_sn、name、first、remark、tpl、status');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验微信小程序提醒必填参数
|
||||
* @param $item
|
||||
* @throws \Exception
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:35
|
||||
*/
|
||||
public static function checkMnp($item)
|
||||
{
|
||||
if (!isset($item['template_id']) || !isset($item['template_sn']) || !isset($item['name']) || !isset($item['tpl']) || !isset($item['status'])) {
|
||||
throw new \Exception('微信模板消息必填参数:template_id、template_sn、name、tpl、status');
|
||||
}
|
||||
}
|
||||
}
|
127
app/admin/logic/notice/SmsConfigLogic.php
Executable file
127
app/admin/logic/notice/SmsConfigLogic.php
Executable file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\notice;
|
||||
|
||||
use app\common\enum\notice\SmsEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\ConfigService;
|
||||
|
||||
/**
|
||||
* 短信配置逻辑层
|
||||
* Class SmsConfigLogic
|
||||
* @package app\admin\logic\notice
|
||||
*/
|
||||
class SmsConfigLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 获取短信配置
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:37
|
||||
*/
|
||||
public static function getConfig()
|
||||
{
|
||||
$config = [
|
||||
ConfigService::get('sms', 'ali', ['type' => 'ali', 'name' => '阿里云短信', 'status' => 1]),
|
||||
ConfigService::get('sms', 'tencent', ['type' => 'tencent', 'name' => '腾讯云短信', 'status' => 0]),
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 短信配置
|
||||
* @param $params
|
||||
* @return bool|void
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:37
|
||||
*/
|
||||
public static function setConfig($params)
|
||||
{
|
||||
$type = $params['type'];
|
||||
$params['name'] = self::getNameDesc(strtoupper($type));
|
||||
ConfigService::set('sms', $type, $params);
|
||||
$default = ConfigService::get('sms', 'engine', false);
|
||||
if ($params['status'] == 1 && $default === false) {
|
||||
// 启用当前短信配置 并 设置当前短信配置为默认
|
||||
ConfigService::set('sms', 'engine', strtoupper($type));
|
||||
return true;
|
||||
}
|
||||
if ($params['status'] == 1 && $default != strtoupper($type)) {
|
||||
// 找到默认短信配置
|
||||
$defaultConfig = ConfigService::get('sms', strtolower($default));
|
||||
// 状态置为禁用 并 更新
|
||||
$defaultConfig['status'] = 0;
|
||||
ConfigService::set('sms', strtolower($default), $defaultConfig);
|
||||
// 设置当前短信配置为默认
|
||||
ConfigService::set('sms', 'engine', strtoupper($type));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 查看短信配置详情
|
||||
* @param $params
|
||||
* @return array|int|mixed|string|null
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:37
|
||||
*/
|
||||
public static function detail($params)
|
||||
{
|
||||
$default = [];
|
||||
switch ($params['type']) {
|
||||
case 'ali':
|
||||
$default = [
|
||||
'sign' => '',
|
||||
'app_key' => '',
|
||||
'secret_key' => '',
|
||||
'status' => 1,
|
||||
'name' => '阿里云短信',
|
||||
];
|
||||
break;
|
||||
case 'tencent':
|
||||
$default = [
|
||||
'sign' => '',
|
||||
'app_id' => '',
|
||||
'secret_key' => '',
|
||||
'status' => 0,
|
||||
'secret_id' => '',
|
||||
'name' => '腾讯云短信',
|
||||
];
|
||||
break;
|
||||
}
|
||||
$result = ConfigService::get('sms', $params['type'], $default);
|
||||
$result['status'] = intval($result['status'] ?? 0);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取短信平台名称
|
||||
* @param $value
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 11:37
|
||||
*/
|
||||
public static function getNameDesc($value)
|
||||
{
|
||||
$desc = [
|
||||
'ALI' => '阿里云短信',
|
||||
'TENCENT' => '腾讯云短信',
|
||||
];
|
||||
return $desc[$value] ?? '';
|
||||
}
|
||||
}
|
65
app/admin/logic/setting/CustomerServiceLogic.php
Executable file
65
app/admin/logic/setting/CustomerServiceLogic.php
Executable file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\setting;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
|
||||
/**
|
||||
* 客服设置逻辑
|
||||
* Class CustomerServiceLogic
|
||||
* @package app\admin\logic\setting
|
||||
*/
|
||||
class CustomerServiceLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 获取客服设置
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/15 12:05 下午
|
||||
*/
|
||||
public static function getConfig()
|
||||
{
|
||||
$qrCode = ConfigService::get('customer_service', 'qr_code');
|
||||
$qrCode = empty($qrCode) ? '' : FileService::getFileUrl($qrCode);
|
||||
$config = [
|
||||
'qr_code' => $qrCode,
|
||||
'wechat' => ConfigService::get('customer_service', 'wechat', ''),
|
||||
'phone' => ConfigService::get('customer_service', 'phone', ''),
|
||||
'service_time' => ConfigService::get('customer_service', 'service_time', ''),
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置客服设置
|
||||
* @param $params
|
||||
* @author ljj
|
||||
* @date 2022/2/15 12:11 下午
|
||||
*/
|
||||
public static function setConfig($params)
|
||||
{
|
||||
$allowField = ['qr_code','wechat','phone','service_time'];
|
||||
foreach($params as $key => $value) {
|
||||
if(in_array($key, $allowField)) {
|
||||
if ($key == 'qr_code') {
|
||||
$value = FileService::setFileUrl($value);
|
||||
}
|
||||
ConfigService::set('customer_service', $key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
75
app/admin/logic/setting/HotSearchLogic.php
Executable file
75
app/admin/logic/setting/HotSearchLogic.php
Executable file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\setting;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\HotSearch;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
|
||||
|
||||
/**
|
||||
* 热门搜素逻辑
|
||||
* Class HotSearchLogic
|
||||
* @package app\admin\logic\setting
|
||||
*/
|
||||
class HotSearchLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取配置
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/9/5 18:48
|
||||
*/
|
||||
public static function getConfig()
|
||||
{
|
||||
return [
|
||||
// 功能状态 0-关闭 1-开启
|
||||
'status' => ConfigService::get('hot_search', 'status', 0),
|
||||
// 热门搜索数据
|
||||
'data' => HotSearch::field(['name', 'sort'])->order(['sort' => 'desc', 'id' =>'desc'])->select()->toArray(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置热门搜搜
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/9/5 18:58
|
||||
*/
|
||||
public static function setConfig($params)
|
||||
{
|
||||
try {
|
||||
if (!empty($params['data'])) {
|
||||
$model = (new HotSearch());
|
||||
$model->where('id', '>', 0)->delete();
|
||||
$model->saveAll($params['data']);
|
||||
}
|
||||
|
||||
$status = empty($params['status']) ? 0 : $params['status'];
|
||||
ConfigService::set('hot_search', 'status', $status);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
203
app/admin/logic/setting/StorageLogic.php
Executable file
203
app/admin/logic/setting/StorageLogic.php
Executable file
@ -0,0 +1,203 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\setting;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\ConfigService;
|
||||
use think\facade\Cache;
|
||||
|
||||
|
||||
/**
|
||||
* 存储设置逻辑层
|
||||
* Class ShopStorageLogic
|
||||
* @package app\admin\logic\settings\shop
|
||||
*/
|
||||
class StorageLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 存储引擎列表
|
||||
* @return array[]
|
||||
* @author 乔峰
|
||||
* @date 2022/4/20 16:14
|
||||
*/
|
||||
public static function lists()
|
||||
{
|
||||
|
||||
$default = ConfigService::get('storage', 'default', 'local');
|
||||
|
||||
$data = [
|
||||
[
|
||||
'name' => '本地存储',
|
||||
'path' => '存储在本地服务器',
|
||||
'engine' => 'local',
|
||||
'status' => $default == 'local' ? 1 : 0
|
||||
],
|
||||
[
|
||||
'name' => '七牛云存储',
|
||||
'path' => '存储在七牛云,请前往七牛云开通存储服务',
|
||||
'engine' => 'qiniu',
|
||||
'status' => $default == 'qiniu' ? 1 : 0
|
||||
],
|
||||
[
|
||||
'name' => '阿里云OSS',
|
||||
'path' => '存储在阿里云,请前往阿里云开通存储服务',
|
||||
'engine' => 'aliyun',
|
||||
'status' => $default == 'aliyun' ? 1 : 0
|
||||
],
|
||||
[
|
||||
'name' => '腾讯云COS',
|
||||
'path' => '存储在腾讯云,请前往腾讯云开通存储服务',
|
||||
'engine' => 'qcloud',
|
||||
'status' => $default == 'qcloud' ? 1 : 0
|
||||
]
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 存储设置详情
|
||||
* @param $param
|
||||
* @return mixed
|
||||
* @author 乔峰
|
||||
* @date 2022/4/20 16:15
|
||||
*/
|
||||
public static function detail($param)
|
||||
{
|
||||
|
||||
$default = ConfigService::get('storage', 'default', '');
|
||||
|
||||
// 本地存储
|
||||
$local = ['status' => $default == 'local' ? 1 : 0];
|
||||
// 七牛云存储
|
||||
$qiniu = ConfigService::get('storage', 'qiniu', [
|
||||
'bucket' => '',
|
||||
'access_key' => '',
|
||||
'secret_key' => '',
|
||||
'domain' => '',
|
||||
'status' => $default == 'qiniu' ? 1 : 0
|
||||
]);
|
||||
|
||||
// 阿里云存储
|
||||
$aliyun = ConfigService::get('storage', 'aliyun', [
|
||||
'bucket' => '',
|
||||
'access_key' => '',
|
||||
'secret_key' => '',
|
||||
'domain' => '',
|
||||
'status' => $default == 'aliyun' ? 1 : 0
|
||||
]);
|
||||
|
||||
// 腾讯云存储
|
||||
$qcloud = ConfigService::get('storage', 'qcloud', [
|
||||
'bucket' => '',
|
||||
'region' => '',
|
||||
'access_key' => '',
|
||||
'secret_key' => '',
|
||||
'domain' => '',
|
||||
'status' => $default == 'qcloud' ? 1 : 0
|
||||
]);
|
||||
|
||||
$data = [
|
||||
'local' => $local,
|
||||
'qiniu' => $qiniu,
|
||||
'aliyun' => $aliyun,
|
||||
'qcloud' => $qcloud
|
||||
];
|
||||
$result = $data[$param['engine']];
|
||||
if ($param['engine'] == $default) {
|
||||
$result['status'] = 1;
|
||||
} else {
|
||||
$result['status'] = 0;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置存储参数
|
||||
* @param $params
|
||||
* @return bool|string
|
||||
* @author 乔峰
|
||||
* @date 2022/4/20 16:16
|
||||
*/
|
||||
public static function setup($params)
|
||||
{
|
||||
if ($params['status'] == 1) { //状态为开启
|
||||
ConfigService::set('storage', 'default', $params['engine']);
|
||||
} else {
|
||||
ConfigService::set('storage', 'default', 'local');
|
||||
}
|
||||
|
||||
switch ($params['engine']) {
|
||||
case 'local':
|
||||
ConfigService::set('storage', 'local', []);
|
||||
break;
|
||||
case 'qiniu':
|
||||
ConfigService::set('storage', 'qiniu', [
|
||||
'bucket' => $params['bucket'] ?? '',
|
||||
'access_key' => $params['access_key'] ?? '',
|
||||
'secret_key' => $params['secret_key'] ?? '',
|
||||
'domain' => $params['domain'] ?? ''
|
||||
]);
|
||||
break;
|
||||
case 'aliyun':
|
||||
ConfigService::set('storage', 'aliyun', [
|
||||
'bucket' => $params['bucket'] ?? '',
|
||||
'access_key' => $params['access_key'] ?? '',
|
||||
'secret_key' => $params['secret_key'] ?? '',
|
||||
'domain' => $params['domain'] ?? ''
|
||||
]);
|
||||
break;
|
||||
case 'qcloud':
|
||||
ConfigService::set('storage', 'qcloud', [
|
||||
'bucket' => $params['bucket'] ?? '',
|
||||
'region' => $params['region'] ?? '',
|
||||
'access_key' => $params['access_key'] ?? '',
|
||||
'secret_key' => $params['secret_key'] ?? '',
|
||||
'domain' => $params['domain'] ?? '',
|
||||
]);
|
||||
break;
|
||||
}
|
||||
|
||||
Cache::delete('STORAGE_DEFAULT');
|
||||
Cache::delete('STORAGE_ENGINE');
|
||||
if ($params['engine'] == 'local' && $params['status'] == 0) {
|
||||
return '默认开启本地存储';
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 切换状态
|
||||
* @param $params
|
||||
* @author 乔峰
|
||||
* @date 2022/4/20 16:17
|
||||
*/
|
||||
public static function change($params)
|
||||
{
|
||||
$default = ConfigService::get('storage', 'default', '');
|
||||
if ($default == $params['engine']) {
|
||||
ConfigService::set('storage', 'default', 'local');
|
||||
} else {
|
||||
ConfigService::set('storage', 'default', $params['engine']);
|
||||
}
|
||||
Cache::delete('STORAGE_DEFAULT');
|
||||
Cache::delete('STORAGE_ENGINE');
|
||||
}
|
||||
}
|
64
app/admin/logic/setting/TransactionSettingsLogic.php
Executable file
64
app/admin/logic/setting/TransactionSettingsLogic.php
Executable file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\setting;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\ConfigService;
|
||||
|
||||
/**
|
||||
* 交易设置逻辑
|
||||
* Class TransactionSettingsLogic
|
||||
* @package app\admin\logic\setting
|
||||
*/
|
||||
class TransactionSettingsLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 获取交易设置
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/15 11:40 上午
|
||||
*/
|
||||
public static function getConfig()
|
||||
{
|
||||
$config = [
|
||||
'cancel_unpaid_orders' => ConfigService::get('transaction', 'cancel_unpaid_orders', 1),
|
||||
'cancel_unpaid_orders_times' => ConfigService::get('transaction', 'cancel_unpaid_orders_times', 30),
|
||||
'verification_orders' => ConfigService::get('transaction', 'verification_orders', 1),
|
||||
'verification_orders_times' => ConfigService::get('transaction', 'verification_orders_times', 24),
|
||||
];
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置交易设置
|
||||
* @param $params
|
||||
* @author ljj
|
||||
* @date 2022/2/15 11:49 上午
|
||||
*/
|
||||
public static function setConfig($params)
|
||||
{
|
||||
ConfigService::set('transaction', 'cancel_unpaid_orders', $params['cancel_unpaid_orders']);
|
||||
ConfigService::set('transaction', 'verification_orders', $params['verification_orders']);
|
||||
|
||||
if (isset($params['cancel_unpaid_orders_times'])) {
|
||||
ConfigService::set('transaction', 'cancel_unpaid_orders_times', $params['cancel_unpaid_orders_times']);
|
||||
}
|
||||
|
||||
if (isset($params['verification_orders_times'])) {
|
||||
ConfigService::set('transaction', 'verification_orders_times', $params['verification_orders_times']);
|
||||
}
|
||||
}
|
||||
}
|
84
app/admin/logic/setting/dict/DictDataLogic.php
Executable file
84
app/admin/logic/setting/dict/DictDataLogic.php
Executable file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\setting\dict;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\dict\DictType;
|
||||
|
||||
|
||||
/**
|
||||
* 字典数据逻辑
|
||||
* Class DictDataLogic
|
||||
* @package app\admin\logic\DictData
|
||||
*/
|
||||
class DictDataLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 添加编辑
|
||||
* @param array $params
|
||||
* @return DictData|\think\Model
|
||||
* @author 乔峰
|
||||
* @date 2022/6/20 17:13
|
||||
*/
|
||||
public static function save(array $params)
|
||||
{
|
||||
$data = [
|
||||
'name' => $params['name'],
|
||||
'value' => $params['value'],
|
||||
'sort' => $params['sort'] ?? 0,
|
||||
'status' => $params['status'],
|
||||
'remark' => $params['remark'] ?? '',
|
||||
];
|
||||
|
||||
if (!empty($params['id'])) {
|
||||
return DictData::where(['id' => $params['id']])->update($data);
|
||||
} else {
|
||||
$dictType = DictType::findOrEmpty($params['type_id']);
|
||||
$data['type_id'] = $params['type_id'];
|
||||
$data['type_value'] = $dictType['type'];
|
||||
return DictData::create($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除字典数据
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/6/20 17:01
|
||||
*/
|
||||
public static function delete(array $params)
|
||||
{
|
||||
return DictData::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取字典数据详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/6/20 17:01
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return DictData::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
|
||||
}
|
111
app/admin/logic/setting/dict/DictTypeLogic.php
Executable file
111
app/admin/logic/setting/dict/DictTypeLogic.php
Executable file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\setting\dict;
|
||||
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\dict\DictType;
|
||||
|
||||
|
||||
/**
|
||||
* 字典类型逻辑
|
||||
* Class DictTypeLogic
|
||||
* @package app\admin\logic\dict
|
||||
*/
|
||||
class DictTypeLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 添加字典类型
|
||||
* @param array $params
|
||||
* @return DictType|\think\Model
|
||||
* @author 乔峰
|
||||
* @date 2022/6/20 16:08
|
||||
*/
|
||||
public static function add(array $params)
|
||||
{
|
||||
return DictType::create([
|
||||
'name' => $params['name'],
|
||||
'type' => $params['type'],
|
||||
'status' => $params['status'],
|
||||
'remark' => $params['remark'] ?? '',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑字典类型
|
||||
* @param array $params
|
||||
* @author 乔峰
|
||||
* @date 2022/6/20 16:10
|
||||
*/
|
||||
public static function edit(array $params)
|
||||
{
|
||||
DictType::update([
|
||||
'id' => $params['id'],
|
||||
'name' => $params['name'],
|
||||
'type' => $params['type'],
|
||||
'status' => $params['status'],
|
||||
'remark' => $params['remark'] ?? '',
|
||||
]);
|
||||
|
||||
DictData::where(['type_id' => $params['id']])
|
||||
->update(['type_value' => $params['type']]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除字典类型
|
||||
* @param array $params
|
||||
* @author 乔峰
|
||||
* @date 2022/6/20 16:23
|
||||
*/
|
||||
public static function delete(array $params)
|
||||
{
|
||||
DictType::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取字典详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/6/20 16:23
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return DictType::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 角色数据
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 乔峰
|
||||
* @date 2022/10/13 10:44
|
||||
*/
|
||||
public static function getAllData()
|
||||
{
|
||||
return DictType::where(['status' => YesNoEnum::YES])
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
}
|
37
app/admin/logic/setting/system/CacheLogic.php
Executable file
37
app/admin/logic/setting/system/CacheLogic.php
Executable file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\setting\system;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* 系统缓存逻辑
|
||||
* Class CacheLogic
|
||||
* @package app\admin\logic\setting\system
|
||||
*/
|
||||
class CacheLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 清楚系统缓存
|
||||
* @author 乔峰
|
||||
* @date 2022/4/8 16:29
|
||||
*/
|
||||
public static function clear()
|
||||
{
|
||||
Cache::clear();
|
||||
del_target_dir(app()->getRootPath().'runtime/file',true);
|
||||
}
|
||||
}
|
65
app/admin/logic/setting/system/SystemLogic.php
Executable file
65
app/admin/logic/setting/system/SystemLogic.php
Executable file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\setting\system;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
|
||||
/**
|
||||
* Class SystemLogic
|
||||
* @package app\admin\logic\setting\system
|
||||
*/
|
||||
class SystemLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 系统环境信息
|
||||
* @return \array[][]
|
||||
* @author 乔峰
|
||||
* @date 2021/12/28 18:35
|
||||
*/
|
||||
public static function getInfo() : array
|
||||
{
|
||||
$server = [
|
||||
['param' => '服务器操作系统', 'value' => PHP_OS],
|
||||
['param' => 'web服务器环境', 'value' => $_SERVER['SERVER_SOFTWARE']],
|
||||
['param' => 'PHP版本', 'value' => PHP_VERSION],
|
||||
];
|
||||
|
||||
$env = [
|
||||
[ 'option' => 'PHP版本',
|
||||
'require' => '8.0版本以上',
|
||||
'status' => (int)compare_php('8.0.0'),
|
||||
'remark' => ''
|
||||
]
|
||||
];
|
||||
|
||||
$auth = [
|
||||
[
|
||||
'dir' => '/runtime',
|
||||
'require' => 'runtime目录可写',
|
||||
'status' => (int)check_dir_write('runtime'),
|
||||
'remark' => ''
|
||||
],
|
||||
];
|
||||
|
||||
return [
|
||||
'server' => $server,
|
||||
'env' => $env,
|
||||
'auth' => $auth,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
108
app/admin/logic/setting/user/UserLogic.php
Executable file
108
app/admin/logic/setting/user/UserLogic.php
Executable file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\admin\logic\setting\user;
|
||||
|
||||
use app\common\service\{ConfigService, FileService};
|
||||
|
||||
/**
|
||||
* 设置-用户设置逻辑层
|
||||
* Class UserLogic
|
||||
* @package app\admin\logic\config
|
||||
*/
|
||||
class UserLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取用户设置
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 10:09
|
||||
*/
|
||||
public static function getConfig(): array
|
||||
{
|
||||
$defaultAvatar = FileService::getFileUrl(config('project.default_image.user_avatar'));
|
||||
$config = [
|
||||
//默认头像
|
||||
'default_avatar' => ConfigService::get('default_image', 'user_avatar', $defaultAvatar),
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置用户设置
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 10:09
|
||||
*/
|
||||
public function setConfig(array $params): bool
|
||||
{
|
||||
$avatar = FileService::setFileUrl($params['default_avatar']);
|
||||
ConfigService::set('default_image', 'user_avatar', $avatar);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取注册配置
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 10:10
|
||||
*/
|
||||
public function getRegisterConfig(): array
|
||||
{
|
||||
$config = [
|
||||
// 登录方式
|
||||
'login_way' => ConfigService::get('login', 'login_way', config('project.login.login_way')),
|
||||
// 注册强制绑定手机
|
||||
'coerce_mobile' => ConfigService::get('login', 'coerce_mobile', config('project.login.coerce_mobile')),
|
||||
// 政策协议
|
||||
'login_agreement' => ConfigService::get('login', 'login_agreement', config('project.login.login_agreement')),
|
||||
// 第三方登录 开关
|
||||
'third_auth' => ConfigService::get('login', 'third_auth', config('project.login.third_auth')),
|
||||
// 微信授权登录
|
||||
'wechat_auth' => ConfigService::get('login', 'wechat_auth', config('project.login.wechat_auth')),
|
||||
// qq授权登录
|
||||
'qq_auth' => ConfigService::get('login', 'qq_auth', config('project.login.qq_auth')),
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置登录注册
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/3/29 10:10
|
||||
*/
|
||||
public static function setRegisterConfig(array $params): bool
|
||||
{
|
||||
// 登录方式:1-账号密码登录;2-手机短信验证码登录
|
||||
ConfigService::set('login', 'login_way', $params['login_way']);
|
||||
// 注册强制绑定手机
|
||||
ConfigService::set('login', 'coerce_mobile', $params['coerce_mobile']);
|
||||
// 政策协议
|
||||
ConfigService::set('login', 'login_agreement', $params['login_agreement']);
|
||||
// 第三方授权登录
|
||||
ConfigService::set('login', 'third_auth', $params['third_auth']);
|
||||
// 微信授权登录
|
||||
ConfigService::set('login', 'wechat_auth', $params['wechat_auth']);
|
||||
// qq登录
|
||||
ConfigService::set('login', 'qq_auth', $params['qq_auth']);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
157
app/admin/logic/setting/web/WebSettingLogic.php
Executable file
157
app/admin/logic/setting/web/WebSettingLogic.php
Executable file
@ -0,0 +1,157 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\setting\web;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
|
||||
|
||||
/**
|
||||
* 网站设置
|
||||
* Class WebSettingLogic
|
||||
* @package app\admin\logic\setting
|
||||
*/
|
||||
class WebSettingLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取网站信息
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2021/12/28 15:43
|
||||
*/
|
||||
public static function getWebsiteInfo(): array
|
||||
{
|
||||
return [
|
||||
'name' => ConfigService::get('website', 'name'),
|
||||
'web_favicon' => FileService::getFileUrl(ConfigService::get('website', 'web_favicon')),
|
||||
'web_logo' => FileService::getFileUrl(ConfigService::get('website', 'web_logo')),
|
||||
'login_image' => FileService::getFileUrl(ConfigService::get('website', 'login_image')),
|
||||
'shop_name' => ConfigService::get('website', 'shop_name'),
|
||||
'shop_logo' => FileService::getFileUrl(ConfigService::get('website', 'shop_logo')),
|
||||
|
||||
'pc_logo' => FileService::getFileUrl(ConfigService::get('website', 'pc_logo')),
|
||||
'pc_title' => ConfigService::get('website', 'pc_title', ''),
|
||||
'pc_ico' => FileService::getFileUrl(ConfigService::get('website', 'pc_ico')),
|
||||
'pc_desc' => ConfigService::get('website', 'pc_desc', ''),
|
||||
'pc_keywords' => ConfigService::get('website', 'pc_keywords', ''),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置网站信息
|
||||
* @param array $params
|
||||
* @author 乔峰
|
||||
* @date 2021/12/28 15:43
|
||||
*/
|
||||
public static function setWebsiteInfo(array $params)
|
||||
{
|
||||
$favicon = FileService::setFileUrl($params['web_favicon']);
|
||||
$logo = FileService::setFileUrl($params['web_logo']);
|
||||
$login = FileService::setFileUrl($params['login_image']);
|
||||
$shopLogo = FileService::setFileUrl($params['shop_logo']);
|
||||
$pcLogo = FileService::setFileUrl($params['pc_logo']);
|
||||
$pcIco = FileService::setFileUrl($params['pc_ico'] ?? '');
|
||||
|
||||
ConfigService::set('website', 'name', $params['name']);
|
||||
ConfigService::set('website', 'web_favicon', $favicon);
|
||||
ConfigService::set('website', 'web_logo', $logo);
|
||||
ConfigService::set('website', 'login_image', $login);
|
||||
ConfigService::set('website', 'shop_name', $params['shop_name']);
|
||||
ConfigService::set('website', 'shop_logo', $shopLogo);
|
||||
ConfigService::set('website', 'pc_logo', $pcLogo);
|
||||
|
||||
ConfigService::set('website', 'pc_title', $params['pc_title']);
|
||||
ConfigService::set('website', 'pc_ico', $pcIco);
|
||||
ConfigService::set('website', 'pc_desc', $params['pc_desc'] ?? '');
|
||||
ConfigService::set('website', 'pc_keywords', $params['pc_keywords'] ?? '');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取版权备案
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2021/12/28 16:09
|
||||
*/
|
||||
public static function getCopyright() : array
|
||||
{
|
||||
return ConfigService::get('copyright', 'config', []);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置版权备案
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/8/8 16:33
|
||||
*/
|
||||
public static function setCopyright(array $params)
|
||||
{
|
||||
try {
|
||||
if (!is_array($params['config'])) {
|
||||
throw new \Exception('参数异常');
|
||||
}
|
||||
ConfigService::set('copyright', 'config', $params['config'] ?? []);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置政策协议
|
||||
* @param array $params
|
||||
* @author ljj
|
||||
* @date 2022/2/15 10:59 上午
|
||||
*/
|
||||
public static function setAgreement(array $params)
|
||||
{
|
||||
$serviceContent = clear_file_domain($params['service_content'] ?? '');
|
||||
$privacyContent = clear_file_domain($params['privacy_content'] ?? '');
|
||||
ConfigService::set('agreement', 'service_title', $params['service_title'] ?? '');
|
||||
ConfigService::set('agreement', 'service_content', $serviceContent);
|
||||
ConfigService::set('agreement', 'privacy_title', $params['privacy_title'] ?? '');
|
||||
ConfigService::set('agreement', 'privacy_content', $privacyContent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取政策协议
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/15 11:15 上午
|
||||
*/
|
||||
public static function getAgreement() : array
|
||||
{
|
||||
$config = [
|
||||
'service_title' => ConfigService::get('agreement', 'service_title'),
|
||||
'service_content' => ConfigService::get('agreement', 'service_content'),
|
||||
'privacy_title' => ConfigService::get('agreement', 'privacy_title'),
|
||||
'privacy_content' => ConfigService::get('agreement', 'privacy_content'),
|
||||
];
|
||||
|
||||
$config['service_content'] = get_file_domain($config['service_content']);
|
||||
$config['privacy_content'] = get_file_domain($config['privacy_content']);
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
505
app/admin/logic/tools/GeneratorLogic.php
Executable file
505
app/admin/logic/tools/GeneratorLogic.php
Executable file
@ -0,0 +1,505 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\logic\tools;
|
||||
|
||||
use app\common\enum\GeneratorEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\tools\GenerateColumn;
|
||||
use app\common\model\tools\GenerateTable;
|
||||
use app\common\service\generator\GenerateService;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 生成器逻辑
|
||||
* Class GeneratorLogic
|
||||
* @package app\admin\logic\tools
|
||||
*/
|
||||
class GeneratorLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 表详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/6/20 10:45
|
||||
*/
|
||||
public static function getTableDetail($params): array
|
||||
{
|
||||
$detail = GenerateTable::with('table_column')
|
||||
->findOrEmpty((int)$params['id'])
|
||||
->toArray();
|
||||
|
||||
$options = self::formatConfigByTableData($detail);
|
||||
$detail['menu'] = $options['menu'];
|
||||
$detail['delete'] = $options['delete'];
|
||||
$detail['tree'] = $options['tree'];
|
||||
$detail['relations'] = $options['relations'];
|
||||
return $detail;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 选择数据表
|
||||
* @param $params
|
||||
* @param $adminId
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/6/20 10:44
|
||||
*/
|
||||
public static function selectTable($params, $adminId)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
foreach ($params['table'] as $item) {
|
||||
// 添加主表基础信息
|
||||
$generateTable = self::initTable($item, $adminId);
|
||||
// 获取数据表字段信息
|
||||
$column = self::getTableColumn($item['name']);
|
||||
// 添加表字段信息
|
||||
self::initTableColumn($column, $generateTable['id']);
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑表信息
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/6/20 10:44
|
||||
*/
|
||||
public static function editTable($params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 格式化配置
|
||||
$options = self::formatConfigByTableData($params);
|
||||
// 更新主表-数据表信息
|
||||
GenerateTable::update([
|
||||
'id' => $params['id'],
|
||||
'table_name' => $params['table_name'],
|
||||
'table_comment' => $params['table_comment'],
|
||||
'template_type' => $params['template_type'],
|
||||
'author' => $params['author'] ?? '',
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'generate_type' => $params['generate_type'],
|
||||
'module_name' => $params['module_name'],
|
||||
'class_dir' => $params['class_dir'] ?? '',
|
||||
'class_comment' => $params['class_comment'] ?? '',
|
||||
'menu' => $options['menu'],
|
||||
'delete' => $options['delete'],
|
||||
'tree' => $options['tree'],
|
||||
'relations' => $options['relations'],
|
||||
]);
|
||||
|
||||
// 更新从表-数据表字段信息
|
||||
foreach ($params['table_column'] as $item) {
|
||||
GenerateColumn::update([
|
||||
'id' => $item['id'],
|
||||
'column_comment' => $item['column_comment'] ?? '',
|
||||
'is_required' => $item['is_required'] ?? 0,
|
||||
'is_insert' => $item['is_insert'] ?? 0,
|
||||
'is_update' => $item['is_update'] ?? 0,
|
||||
'is_lists' => $item['is_lists'] ?? 0,
|
||||
'is_query' => $item['is_query'] ?? 0,
|
||||
'query_type' => $item['query_type'],
|
||||
'view_type' => $item['view_type'],
|
||||
'dict_type' => $item['dict_type'] ?? '',
|
||||
]);
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除表相关信息
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/6/16 9:30
|
||||
*/
|
||||
public static function deleteTable($params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
GenerateTable::whereIn('id', $params['id'])->delete();
|
||||
GenerateColumn::whereIn('table_id', $params['id'])->delete();
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 同步表字段
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author 乔峰
|
||||
* @date 2022/6/23 16:28
|
||||
*/
|
||||
public static function syncColumn($params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
// table 信息
|
||||
$table = GenerateTable::findOrEmpty($params['id']);
|
||||
// 删除旧字段
|
||||
GenerateColumn::whereIn('table_id', $table['id'])->delete();
|
||||
// 获取当前数据表字段信息
|
||||
$column = self::getTableColumn($table['table_name']);
|
||||
// 创建新字段数据
|
||||
self::initTableColumn($column, $table['id']);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 生成代码
|
||||
* @param $params
|
||||
* @return false|int[]
|
||||
* @author 乔峰
|
||||
* @date 2022/6/24 9:43
|
||||
*/
|
||||
public static function generate($params)
|
||||
{
|
||||
try {
|
||||
// 获取数据表信息
|
||||
$tables = GenerateTable::with(['table_column'])
|
||||
->whereIn('id', $params['id'])
|
||||
->select()->toArray();
|
||||
|
||||
$generator = app()->make(GenerateService::class);
|
||||
$generator->delGenerateDirContent();
|
||||
$flag = array_unique(array_column($tables, 'table_name'));
|
||||
$flag = implode(',', $flag);
|
||||
$generator->setGenerateFlag(md5($flag . time()), false);
|
||||
|
||||
// 循环生成
|
||||
foreach ($tables as $table) {
|
||||
$generator->generate($table);
|
||||
}
|
||||
|
||||
$zipFile = '';
|
||||
// 生成压缩包
|
||||
if ($generator->getGenerateFlag()) {
|
||||
$generator->zipFile();
|
||||
$generator->delGenerateFlag();
|
||||
$zipFile = $generator->getDownloadUrl();
|
||||
}
|
||||
|
||||
return ['file' => $zipFile];
|
||||
|
||||
} catch (\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 预览
|
||||
* @param $params
|
||||
* @return false
|
||||
* @author 乔峰
|
||||
* @date 2022/6/23 16:27
|
||||
*/
|
||||
public static function preview($params)
|
||||
{
|
||||
try {
|
||||
// 获取数据表信息
|
||||
$table = GenerateTable::with(['table_column'])
|
||||
->whereIn('id', $params['id'])
|
||||
->findOrEmpty()->toArray();
|
||||
|
||||
return app()->make(GenerateService::class)->preview($table);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取表字段信息
|
||||
* @param $tableName
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/6/23 16:28
|
||||
*/
|
||||
public static function getTableColumn($tableName)
|
||||
{
|
||||
$tableName = get_no_prefix_table_name($tableName);
|
||||
return Db::name($tableName)->getFields();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 初始化代码生成数据表信息
|
||||
* @param $tableData
|
||||
* @param $adminId
|
||||
* @return GenerateTable|\think\Model
|
||||
* @author 乔峰
|
||||
* @date 2022/6/23 16:28
|
||||
*/
|
||||
public static function initTable($tableData, $adminId)
|
||||
{
|
||||
return GenerateTable::create([
|
||||
'table_name' => $tableData['name'],
|
||||
'table_comment' => $tableData['comment'],
|
||||
'template_type' => GeneratorEnum::TEMPLATE_TYPE_SINGLE,
|
||||
'generate_type' => GeneratorEnum::GENERATE_TYPE_ZIP,
|
||||
'module_name' => 'admin',
|
||||
'admin_id' => $adminId,
|
||||
// 菜单配置
|
||||
'menu' => [
|
||||
'pid' => 0, // 父级菜单id
|
||||
'type' => GeneratorEnum::GEN_SELF, // 构建方式 0-手动添加 1-自动构建
|
||||
'name' => $tableData['comment'], // 菜单名称
|
||||
],
|
||||
// 删除配置
|
||||
'delete' => [
|
||||
'type' => GeneratorEnum::DELETE_TRUE, // 删除类型
|
||||
'name' => GeneratorEnum::DELETE_NAME, // 默认删除字段名
|
||||
],
|
||||
// 关联配置
|
||||
'relations' => [],
|
||||
// 树形crud
|
||||
'tree' => []
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 初始化代码生成字段信息
|
||||
* @param $column
|
||||
* @param $tableId
|
||||
* @throws \Exception
|
||||
* @author 乔峰
|
||||
* @date 2022/6/23 16:28
|
||||
*/
|
||||
public static function initTableColumn($column, $tableId)
|
||||
{
|
||||
$defaultColumn = ['id', 'create_time', 'update_time', 'delete_time'];
|
||||
|
||||
$insertColumn = [];
|
||||
foreach ($column as $value) {
|
||||
$required = 0;
|
||||
if ($value['notnull'] && !$value['primary'] && !in_array($value['name'], $defaultColumn)) {
|
||||
$required = 1;
|
||||
}
|
||||
|
||||
$columnData = [
|
||||
'table_id' => $tableId,
|
||||
'column_name' => $value['name'],
|
||||
'column_comment' => $value['comment'],
|
||||
'column_type' => self::getDbFieldType($value['type']),
|
||||
'is_required' => $required,
|
||||
'is_pk' => $value['primary'] ? 1 : 0,
|
||||
];
|
||||
|
||||
if (!in_array($value['name'], $defaultColumn)) {
|
||||
$columnData['is_insert'] = 1;
|
||||
$columnData['is_update'] = 1;
|
||||
$columnData['is_lists'] = 1;
|
||||
$columnData['is_query'] = 1;
|
||||
}
|
||||
$insertColumn[] = $columnData;
|
||||
}
|
||||
|
||||
(new GenerateColumn())->saveAll($insertColumn);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 下载文件
|
||||
* @param $fileName
|
||||
* @return false|string
|
||||
* @author 乔峰
|
||||
* @date 2022/6/24 9:51
|
||||
*/
|
||||
public static function download(string $fileName)
|
||||
{
|
||||
$cacheFileName = cache('curd_file_name' . $fileName);
|
||||
if (empty($cacheFileName)) {
|
||||
self::$error = '请重新生成代码';
|
||||
return false;
|
||||
}
|
||||
|
||||
$path = root_path() . 'runtime/generate/' . $fileName;
|
||||
if (!file_exists($path)) {
|
||||
self::$error = '下载失败';
|
||||
return false;
|
||||
}
|
||||
|
||||
cache('curd_file_name' . $fileName, null);
|
||||
return $path;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数据表字段类型
|
||||
* @param string $type
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/6/15 10:11
|
||||
*/
|
||||
public static function getDbFieldType(string $type): string
|
||||
{
|
||||
if (0 === strpos($type, 'set') || 0 === strpos($type, 'enum')) {
|
||||
$result = 'string';
|
||||
} elseif (preg_match('/(double|float|decimal|real|numeric)/is', $type)) {
|
||||
$result = 'float';
|
||||
} elseif (preg_match('/(int|serial|bit)/is', $type)) {
|
||||
$result = 'int';
|
||||
} elseif (preg_match('/bool/is', $type)) {
|
||||
$result = 'bool';
|
||||
} elseif (0 === strpos($type, 'timestamp')) {
|
||||
$result = 'timestamp';
|
||||
} elseif (0 === strpos($type, 'datetime')) {
|
||||
$result = 'datetime';
|
||||
} elseif (0 === strpos($type, 'date')) {
|
||||
$result = 'date';
|
||||
} else {
|
||||
$result = 'string';
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes
|
||||
* @param $options
|
||||
* @param $tableComment
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/12/13 18:23
|
||||
*/
|
||||
public static function formatConfigByTableData($options)
|
||||
{
|
||||
// 菜单配置
|
||||
$menuConfig = $options['menu'] ?? [];
|
||||
// 删除配置
|
||||
$deleteConfig = $options['delete'] ?? [];
|
||||
// 关联配置
|
||||
$relationsConfig = $options['relations'] ?? [];
|
||||
// 树表crud配置
|
||||
$treeConfig = $options['tree'] ?? [];
|
||||
|
||||
$relations = [];
|
||||
foreach ($relationsConfig as $relation) {
|
||||
$relations[] = [
|
||||
'name' => $relation['name'] ?? '',
|
||||
'model' => $relation['model'] ?? '',
|
||||
'type' => $relation['type'] ?? GeneratorEnum::RELATION_HAS_ONE,
|
||||
'local_key' => $relation['local_key'] ?? 'id',
|
||||
'foreign_key' => $relation['foreign_key'] ?? 'id',
|
||||
];
|
||||
}
|
||||
|
||||
$options['menu'] = [
|
||||
'pid' => intval($menuConfig['pid'] ?? 0),
|
||||
'type' => intval($menuConfig['type'] ?? GeneratorEnum::GEN_SELF),
|
||||
'name' => !empty($menuConfig['name']) ? $menuConfig['name'] : $options['table_comment'],
|
||||
];
|
||||
$options['delete'] = [
|
||||
'type' => intval($deleteConfig['type'] ?? GeneratorEnum::DELETE_TRUE),
|
||||
'name' => !empty($deleteConfig['name']) ? $deleteConfig['name'] : GeneratorEnum::DELETE_NAME,
|
||||
];
|
||||
$options['relations'] = $relations;
|
||||
$options['tree'] = [
|
||||
'tree_id' => $treeConfig['tree_id'] ?? "",
|
||||
'tree_pid' =>$treeConfig['tree_pid'] ?? "",
|
||||
'tree_name' => $treeConfig['tree_name'] ?? '',
|
||||
];
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取所有模型
|
||||
* @param string $module
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/12/14 11:04
|
||||
*/
|
||||
public static function getAllModels($module = 'common')
|
||||
{
|
||||
if(empty($module)) {
|
||||
return [];
|
||||
}
|
||||
$modulePath = base_path() . $module . '/model/';
|
||||
if(!is_dir($modulePath)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$modulefiles = glob($modulePath . '*');
|
||||
$targetFiles = [];
|
||||
foreach ($modulefiles as $file) {
|
||||
$fileBaseName = basename($file, '.php');
|
||||
if (is_dir($file)) {
|
||||
$file = glob($file . '/*');
|
||||
foreach ($file as $item) {
|
||||
if (is_dir($item)) {
|
||||
continue;
|
||||
}
|
||||
$targetFiles[] = sprintf(
|
||||
"\\app\\" . $module . "\\model\\%s\\%s",
|
||||
$fileBaseName,
|
||||
basename($item, '.php')
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if ($fileBaseName == 'BaseModel') {
|
||||
continue;
|
||||
}
|
||||
$targetFiles[] = sprintf(
|
||||
"\\app\\" . $module . "\\model\\%s",
|
||||
basename($file, '.php')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $targetFiles;
|
||||
}
|
||||
|
||||
}
|
66
app/admin/logic/user/UserLogic.php
Executable file
66
app/admin/logic/user/UserLogic.php
Executable file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\admin\logic\user;
|
||||
|
||||
use app\common\enum\user\UserTerminalEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\user\User;
|
||||
|
||||
/**
|
||||
* 用户逻辑层
|
||||
* Class UserLogic
|
||||
* @package app\admin\logic\user
|
||||
*/
|
||||
class UserLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 用户详情
|
||||
* @param int $userId
|
||||
* @return array
|
||||
* @author 乔峰
|
||||
* @date 2022/9/22 16:32
|
||||
*/
|
||||
public static function detail(int $userId): array
|
||||
{
|
||||
$field = [
|
||||
'id', 'sn', 'account', 'nickname', 'avatar', 'real_name',
|
||||
'sex', 'mobile', 'create_time', 'login_time', 'channel'
|
||||
];
|
||||
|
||||
$user = User::where(['id' => $userId])->field($field)
|
||||
->findOrEmpty();
|
||||
|
||||
$user['channel'] = UserTerminalEnum::getTermInalDesc($user['channel']);
|
||||
$user->sex = $user->getData('sex');
|
||||
return $user->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 更新用户信息
|
||||
* @param array $params
|
||||
* @return User
|
||||
* @author 乔峰
|
||||
* @date 2022/9/22 16:38
|
||||
*/
|
||||
public static function setUserInfo(array $params)
|
||||
{
|
||||
return User::update([
|
||||
'id' => $params['id'],
|
||||
$params['field'] => $params['value']
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
63
app/admin/middleware/AuthMiddleware.php
Normal file
63
app/admin/middleware/AuthMiddleware.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\middleware;
|
||||
|
||||
|
||||
use app\common\cache\AdminAuthCache;
|
||||
use app\common\service\JsonService;
|
||||
use think\helper\Str;
|
||||
use Webman\Http\Request;
|
||||
use Webman\Http\Response;
|
||||
use Webman\MiddlewareInterface;
|
||||
|
||||
class AuthMiddleware implements MiddlewareInterface
|
||||
{
|
||||
public function process(Request $request, callable $handler): Response
|
||||
{
|
||||
//不登录访问,无需权限验证
|
||||
if ($request->controllerObject->isNotNeedLogin()) {
|
||||
return $handler($request);
|
||||
}
|
||||
|
||||
//系统默认超级管理员,无需权限验证
|
||||
if (1 === $request->adminInfo['root']) {
|
||||
return $handler($request);
|
||||
}
|
||||
|
||||
$adminAuthCache = new AdminAuthCache($request->adminInfo['admin_id']);
|
||||
|
||||
// 当前访问路径
|
||||
$accessUri = strtolower($request->controller . '/' . $request->action);
|
||||
// 全部路由
|
||||
$allUri = $this->formatUrl($adminAuthCache->getAllUri());
|
||||
|
||||
// 判断该当前访问的uri是否存在,不存在无需验证
|
||||
if (!in_array($accessUri, $allUri)) {
|
||||
return $handler($request);
|
||||
}
|
||||
|
||||
// 当前管理员拥有的路由权限
|
||||
$AdminUris = $adminAuthCache->getAdminUri() ?? [];
|
||||
$AdminUris = $this->formatUrl($AdminUris);
|
||||
|
||||
if (in_array($accessUri, $AdminUris)) {
|
||||
return $handler($request);
|
||||
}
|
||||
return JsonService::fail('权限不足,无法访问或操作');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 格式化URL
|
||||
* @param array $data
|
||||
* @return array|string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/7/7 15:39
|
||||
*/
|
||||
public function formatUrl(array $data)
|
||||
{
|
||||
return array_map(function ($item) {
|
||||
return strtolower(Str::camel($item));
|
||||
}, $data);
|
||||
}
|
||||
}
|
35
app/admin/middleware/InitMiddleware.php
Normal file
35
app/admin/middleware/InitMiddleware.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\middleware;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\common\exception\ControllerExtendException;
|
||||
use think\exception\ClassNotFoundException;
|
||||
use app\common\exception\HttpException;
|
||||
use Webman\Http\Request;
|
||||
use Webman\Http\Response;
|
||||
use Webman\MiddlewareInterface;
|
||||
|
||||
class InitMiddleware implements MiddlewareInterface
|
||||
{
|
||||
public function process(Request $request, callable $handler): Response
|
||||
{
|
||||
//获取控制器
|
||||
try {
|
||||
$controller = str_replace('.', '\\', $request->controller);
|
||||
$controllerClass = new $controller;
|
||||
if (($controllerClass instanceof BaseAdminController) === false) {
|
||||
throw new ControllerExtendException($controller, '404');
|
||||
}
|
||||
} catch (ClassNotFoundException $e) {
|
||||
throw new HttpException(404, 'controller not exists:' . $e->getClass());
|
||||
}
|
||||
|
||||
//创建控制器对象
|
||||
$request->controllerObject = new $controller;
|
||||
|
||||
return $handler($request);
|
||||
}
|
||||
}
|
64
app/admin/middleware/LoginMiddleware.php
Normal file
64
app/admin/middleware/LoginMiddleware.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\middleware;
|
||||
|
||||
|
||||
use app\admin\service\AdminTokenService;
|
||||
use app\common\cache\AdminTokenCache;
|
||||
use app\common\service\JsonService;
|
||||
use Webman\Config;
|
||||
use Webman\Http\Request;
|
||||
use Webman\Http\Response;
|
||||
use Webman\MiddlewareInterface;
|
||||
|
||||
class LoginMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 登录验证
|
||||
* @param $request
|
||||
* @param \Closure $next
|
||||
* @author 乔峰
|
||||
* @date 2021/7/1 17:33
|
||||
*/
|
||||
public function process(Request $request, callable $handler): Response
|
||||
{
|
||||
$token = $request->header('token');
|
||||
// $controller = str_replace('.', '\\', $request->controller);
|
||||
//判断接口是否免登录
|
||||
$isNotNeedLogin = $request->controllerObject->isNotNeedLogin();
|
||||
|
||||
//不直接判断$isNotNeedLogin结果,使不需要登录的接口通过,为了兼容某些接口可以登录或不登录访问
|
||||
if (empty($token) && !$isNotNeedLogin) {
|
||||
//没有token并且该地址需要登录才能访问
|
||||
return JsonService::fail('请求参数缺token', [], 0, 0);
|
||||
}
|
||||
|
||||
$adminInfo = (new AdminTokenCache())->getAdminInfo($token);
|
||||
if (empty($adminInfo) && !$isNotNeedLogin) {
|
||||
//token过期无效并且该地址需要登录才能访问
|
||||
return JsonService::fail('登录超时,请重新登录', [], -1);
|
||||
}
|
||||
|
||||
//token临近过期,自动续期
|
||||
if ($adminInfo) {
|
||||
//获取临近过期自动续期时长
|
||||
$beExpireDuration = Config::get('project.admin_token.be_expire_duration');
|
||||
//token续期
|
||||
if (time() > ($adminInfo['expire_time'] - $beExpireDuration)) {
|
||||
$result = AdminTokenService::overtimeToken($token);
|
||||
//续期失败(数据表被删除导致)
|
||||
if (empty($result)) {
|
||||
return JsonService::fail('登录过期', [], -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//给request赋值,用于控制器
|
||||
$request->adminInfo = $adminInfo;
|
||||
$request->adminId = $adminInfo['admin_id'] ?? 0;
|
||||
|
||||
return $handler($request);
|
||||
}
|
||||
}
|
116
app/admin/service/AdminTokenService.php
Normal file
116
app/admin/service/AdminTokenService.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\service;
|
||||
|
||||
|
||||
use app\common\cache\AdminTokenCache;
|
||||
use app\common\model\auth\AdminSession;
|
||||
use Webman\Config;
|
||||
|
||||
class AdminTokenService
|
||||
{
|
||||
/**
|
||||
* @notes 设置或更新管理员token
|
||||
* @param $adminId //管理员id
|
||||
* @param $terminal //多终端名称
|
||||
* @param $multipointLogin //是否支持多处登录
|
||||
* @return false|mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 令狐冲
|
||||
* @date 2021/7/2 20:25
|
||||
*/
|
||||
public static function setToken($adminId, $terminal, $multipointLogin = 1)
|
||||
{
|
||||
$time = time();
|
||||
$adminSession = AdminSession::where([['admin_id', '=', $adminId], ['terminal', '=', $terminal]])->find();
|
||||
|
||||
//获取token延长过期的时间
|
||||
$expireTime = $time + Config::get('project.admin_token.expire_duration');
|
||||
|
||||
$adminTokenCache = new AdminTokenCache();
|
||||
|
||||
//token处理
|
||||
if ($adminSession) {
|
||||
if ($adminSession->expire_time < $time || $multipointLogin === 0) {
|
||||
//清空缓存
|
||||
$adminTokenCache->deleteAdminInfo($adminSession->token);
|
||||
//如果token过期或账号设置不支持多处登录,更新token
|
||||
$adminSession->token = create_token($adminId);
|
||||
}
|
||||
$adminSession->expire_time = $expireTime;
|
||||
$adminSession->update_time = $time;
|
||||
|
||||
$adminSession->save();
|
||||
} else {
|
||||
//找不到在该终端的token记录,创建token记录
|
||||
$adminSession = AdminSession::create([
|
||||
'admin_id' => $adminId,
|
||||
'terminal' => $terminal,
|
||||
'token' => create_token($adminId),
|
||||
'expire_time' => $expireTime
|
||||
]);
|
||||
}
|
||||
|
||||
return $adminTokenCache->setAdminInfo($adminSession->token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 延长token过期时间
|
||||
* @param $token
|
||||
* @return array|false|mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 令狐冲
|
||||
* @date 2021/7/5 14:25
|
||||
*/
|
||||
public static function overtimeToken($token)
|
||||
{
|
||||
$time = time();
|
||||
$adminSession = AdminSession::where('token', '=', $token)->findOrEmpty();
|
||||
if ($adminSession->isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
//延长token过期时间
|
||||
$adminSession->expire_time = $time + Config::get('project.admin_token.expire_duration');
|
||||
$adminSession->update_time = $time;
|
||||
$adminSession->save();
|
||||
return (new AdminTokenCache())->setAdminInfo($adminSession->token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置token为过期
|
||||
* @param $token
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 令狐冲
|
||||
* @date 2021/7/5 14:31
|
||||
*/
|
||||
public static function expireToken($token)
|
||||
{
|
||||
$adminSession = AdminSession::where('token', '=', $token)
|
||||
->with('admin')
|
||||
->findOrEmpty();
|
||||
|
||||
if ($adminSession->isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//当支持多处登录的时候,服务端不注销
|
||||
if ($adminSession->admin->multipoint_login === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$adminSession->expire_time = $time;
|
||||
$adminSession->update_time = $time;
|
||||
$adminSession->save();
|
||||
|
||||
return (new AdminTokenCache())->deleteAdminInfo($token);
|
||||
}
|
||||
}
|
101
app/admin/validate/FileValidate.php
Normal file
101
app/admin/validate/FileValidate.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class FileValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|number',
|
||||
'cid' => 'require|number',
|
||||
'ids' => 'require|array',
|
||||
'type' => 'require|in:10,20,30',
|
||||
'pid' => 'require|number',
|
||||
'name' => 'require|max:20'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '缺少id参数',
|
||||
'cid.require' => '缺少cid参数',
|
||||
'ids.require' => '缺少ids参数',
|
||||
'type.require' => '缺少type参数',
|
||||
'pid.require' => '缺少pid参数',
|
||||
'name.require' => '请填写分组名称',
|
||||
'name.max' => '分组名称长度须为20字符内',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes id验证场景
|
||||
* @return \app\admin\validate\FileValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:32
|
||||
*/
|
||||
public function sceneId()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 重命名文件场景
|
||||
* @return FileValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:32
|
||||
*/
|
||||
public function sceneRename()
|
||||
{
|
||||
return $this->only(['id', 'name']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 新增分类场景
|
||||
* @return FileValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:33
|
||||
*/
|
||||
public function sceneAddCate()
|
||||
{
|
||||
return $this->only(['type', 'pid', 'name']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑分类场景
|
||||
* @return FileValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:33
|
||||
*/
|
||||
public function sceneEditCate()
|
||||
{
|
||||
return $this->only(['id', 'name']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 移动场景
|
||||
* @return FileValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:33
|
||||
*/
|
||||
public function sceneMove()
|
||||
{
|
||||
return $this->only(['ids', 'cid']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return FileValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:35
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['ids']);
|
||||
}
|
||||
}
|
86
app/admin/validate/LoginValidate.php
Normal file
86
app/admin/validate/LoginValidate.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
|
||||
use app\common\cache\AdminAccountSafeCache;
|
||||
use app\common\enum\AdminTerminalEnum;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\validate\BaseValidate;
|
||||
use Webman\Config;
|
||||
|
||||
class LoginValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'terminal' => 'require|in:' . AdminTerminalEnum::PC . ',' . AdminTerminalEnum::MOBILE,
|
||||
'account' => 'require',
|
||||
'password' => 'require|password',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'account.require' => '请输入账号',
|
||||
'password.require' => '请输入密码'
|
||||
];
|
||||
|
||||
/**
|
||||
* @notes @notes 密码验证
|
||||
* @param $password
|
||||
* @param $other
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 令狐冲
|
||||
* @date 2021/7/2 14:00
|
||||
*/
|
||||
public function password($password, $other, $data)
|
||||
{
|
||||
// 登录限制
|
||||
$config = [
|
||||
'login_restrictions' => ConfigService::get('admin_login', 'login_restrictions'),
|
||||
'password_error_times' => ConfigService::get('admin_login', 'password_error_times'),
|
||||
'limit_login_time' => ConfigService::get('admin_login', 'limit_login_time'),
|
||||
];
|
||||
|
||||
$adminAccountSafeCache = new AdminAccountSafeCache();
|
||||
if ($config['login_restrictions'] == 1) {
|
||||
$adminAccountSafeCache->count = $config['password_error_times'];
|
||||
$adminAccountSafeCache->minute = $config['limit_login_time'];
|
||||
}
|
||||
|
||||
//后台账号安全机制,连续输错后锁定,防止账号密码暴力破解
|
||||
if ($config['login_restrictions'] == 1 && !$adminAccountSafeCache->isSafe()) {
|
||||
return '密码连续' . $adminAccountSafeCache->count . '次输入错误,请' . $adminAccountSafeCache->minute . '分钟后重试';
|
||||
}
|
||||
|
||||
$adminInfo = Admin::where('account', '=', $data['account'])
|
||||
->field(['password,disable'])
|
||||
->findOrEmpty();
|
||||
|
||||
if ($adminInfo->isEmpty()) {
|
||||
return '账号不存在';
|
||||
}
|
||||
|
||||
if ($adminInfo['disable'] === 1) {
|
||||
return '账号已禁用';
|
||||
}
|
||||
|
||||
if (empty($adminInfo['password'])) {
|
||||
$adminAccountSafeCache->record();
|
||||
return '账号不存在';
|
||||
}
|
||||
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
|
||||
if ($adminInfo['password'] !== create_password($password, $passwordSalt)) {
|
||||
$adminAccountSafeCache->record();
|
||||
return '密码错误';
|
||||
}
|
||||
|
||||
$adminAccountSafeCache->relieve();
|
||||
return true;
|
||||
}
|
||||
}
|
168
app/admin/validate/auth/AdminValidate.php
Executable file
168
app/admin/validate/auth/AdminValidate.php
Executable file
@ -0,0 +1,168 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\validate\auth;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\auth\Admin;
|
||||
|
||||
/**
|
||||
* 管理员验证
|
||||
* Class AdminValidate
|
||||
* @package app\admin\validate\auth
|
||||
*/
|
||||
class AdminValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkAdmin',
|
||||
'account' => 'require|length:1,32|unique:'.Admin::class,
|
||||
'name' => 'require|length:1,16|unique:'.Admin::class,
|
||||
'password' => 'require|length:6,32|edit',
|
||||
'password_confirm' => 'requireWith:password|confirm',
|
||||
'role_id' => 'require',
|
||||
'disable' => 'require|in:0,1|checkAbleDisable',
|
||||
'multipoint_login' => 'require|in:0,1',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '管理员id不能为空',
|
||||
'account.require' => '账号不能为空',
|
||||
'account.length' => '账号长度须在1-32位字符',
|
||||
'account.unique' => '账号已存在',
|
||||
'password.require' => '密码不能为空',
|
||||
'password.length' => '密码长度须在6-32位字符',
|
||||
'password_confirm.requireWith' => '确认密码不能为空',
|
||||
'password_confirm.confirm' => '两次输入的密码不一致',
|
||||
'name.require' => '名称不能为空',
|
||||
'name.length' => '名称须在1-16位字符',
|
||||
'name.unique' => '名称已存在',
|
||||
'role_id.require' => '请选择角色',
|
||||
'disable.require' => '请选择状态',
|
||||
'disable.in' => '状态值错误',
|
||||
'multipoint_login.require' => '请选择是否支持多处登录',
|
||||
'multipoint_login.in' => '多处登录状态值为误',
|
||||
];
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return AdminValidate
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 15:46
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove(['password', 'edit'])
|
||||
->remove('id', 'require|checkAdmin')
|
||||
->remove('disable', 'checkAbleDisable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return AdminValidate
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 15:46
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return AdminValidate
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 15:47
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->remove('password', 'require|length')
|
||||
->append('id', 'require|checkAdmin');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return AdminValidate
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 15:47
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑情况下,检查是否填密码
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 10:19
|
||||
*/
|
||||
public function edit($value, $rule, $data)
|
||||
{
|
||||
if (empty($data['password']) && empty($data['password_confirm'])) {
|
||||
return true;
|
||||
}
|
||||
$len = strlen($value);
|
||||
if ($len < 6 || $len > 32) {
|
||||
return '密码长度须在6-32位字符';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 检查指定管理员是否存在
|
||||
* @param $value
|
||||
* @return bool|string
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 10:19
|
||||
*/
|
||||
public function checkAdmin($value)
|
||||
{
|
||||
$admin = Admin::findOrEmpty($value);
|
||||
if ($admin->isEmpty()) {
|
||||
return '管理员不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 禁用校验
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 乔峰
|
||||
* @date 2022/8/11 9:59
|
||||
*/
|
||||
public function checkAbleDisable($value, $rule, $data)
|
||||
{
|
||||
$admin = Admin::findOrEmpty($data['id']);
|
||||
if ($admin->isEmpty()) {
|
||||
return '管理员不存在';
|
||||
}
|
||||
|
||||
if ($value && $admin['root']) {
|
||||
return '超级管理员不允许被禁用';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
195
app/admin/validate/auth/MenuValidate.php
Executable file
195
app/admin/validate/auth/MenuValidate.php
Executable file
@ -0,0 +1,195 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\validate\auth;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\auth\{SystemRole,SystemMenu};
|
||||
|
||||
|
||||
/**
|
||||
* 系统菜单
|
||||
* Class SystemMenuValidate
|
||||
* @package app\admin\validate\auth
|
||||
*/
|
||||
class MenuValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'pid' => 'require|checkPid',
|
||||
'type' => 'require|in:M,C,A',
|
||||
'name' => 'require|length:1,30|checkUniqueName',
|
||||
'icon' => 'max:100',
|
||||
'sort' => 'require|egt:0',
|
||||
'perms' => 'max:100',
|
||||
'paths' => 'max:200',
|
||||
'component' => 'max:200',
|
||||
'selected' => 'max:200',
|
||||
'params' => 'max:200',
|
||||
'is_cache' => 'require|in:0,1',
|
||||
'is_show' => 'require|in:0,1',
|
||||
'is_disable' => 'require|in:0,1',
|
||||
];
|
||||
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'pid.require' => '请选择上级菜单',
|
||||
'type.require' => '请选择菜单类型',
|
||||
'type.in' => '菜单类型参数值错误',
|
||||
'name.require' => '请填写菜单名称',
|
||||
'name.length' => '菜单名称长度需为1~30个字符',
|
||||
'icon.max' => '图标名称不能超过100个字符',
|
||||
'sort.require' => '请填写排序',
|
||||
'sort.egt' => '排序值需大于或等于0',
|
||||
'perms.max' => '权限字符不能超过100个字符',
|
||||
'paths.max' => '路由地址不能超过200个字符',
|
||||
'component.max' => '组件路径不能超过200个字符',
|
||||
'selected.max' => '选中菜单路径不能超过200个字符',
|
||||
'params.max' => '路由参数不能超过200个字符',
|
||||
'is_cache.require' => '请选择缓存状态',
|
||||
'is_cache.in' => '缓存状态参数值错误',
|
||||
'is_show.require' => '请选择显示状态',
|
||||
'is_show.in' => '显示状态参数值错误',
|
||||
'is_disable.require' => '请选择菜单状态',
|
||||
'is_disable.in' => '菜单状态参数值错误',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return MenuValidate
|
||||
* @author 乔峰
|
||||
* @date 2022/6/29 18:26
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return MenuValidate
|
||||
* @author 乔峰
|
||||
* @date 2022/6/29 18:27
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return MenuValidate
|
||||
* @author 乔峰
|
||||
* @date 2022/6/29 18:27
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id', 'checkAbleDelete');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 更新状态场景
|
||||
* @return MenuValidate
|
||||
* @author 乔峰
|
||||
* @date 2022/7/6 17:04
|
||||
*/
|
||||
public function sceneStatus()
|
||||
{
|
||||
return $this->only(['id', 'is_disable']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验菜单名称是否已存在
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 乔峰
|
||||
* @date 2022/6/29 18:24
|
||||
*/
|
||||
protected function checkUniqueName($value, $rule, $data)
|
||||
{
|
||||
if ($data['type'] != 'M') {
|
||||
return true;
|
||||
}
|
||||
$where[] = ['type', '=', $data['type']];
|
||||
$where[] = ['name', '=', $data['name']];
|
||||
|
||||
if (!empty($data['id'])) {
|
||||
$where[] = ['id', '<>', $data['id']];
|
||||
}
|
||||
|
||||
$check = SystemMenu::where($where)->findOrEmpty();
|
||||
|
||||
if (!$check->isEmpty()) {
|
||||
return '菜单名称已存在';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 是否有子级菜单
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 乔峰
|
||||
* @date 2022/6/30 9:40
|
||||
*/
|
||||
protected function checkAbleDelete($value, $rule, $data)
|
||||
{
|
||||
$hasChild = SystemMenu::where(['pid' => $value])->findOrEmpty();
|
||||
if (!$hasChild->isEmpty()) {
|
||||
//return '存在子菜单,不允许删除';
|
||||
}
|
||||
|
||||
// 已绑定角色菜单不可以删除
|
||||
$isBindRole = SystemRole::hasWhere('roleMenuIndex', ['menu_id' => $value])->findOrEmpty();
|
||||
if (!$isBindRole->isEmpty()) {
|
||||
//return '已分配菜单不可删除';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验上级
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 乔峰
|
||||
* @date 2022/6/30 9:51
|
||||
*/
|
||||
protected function checkPid($value, $rule, $data)
|
||||
{
|
||||
if (!empty($data['id']) && $data['id'] == $value) {
|
||||
return '上级菜单不能选择自己';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user