first commit

This commit is contained in:
编码猿
2024-09-27 01:32:49 +08:00
commit 28ebe05a64
7399 changed files with 1174529 additions and 0 deletions

View File

@@ -0,0 +1 @@
44e9deb2-eea3-4463-8100-5169958e89b1

View File

@@ -0,0 +1,58 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/10/1
* Time: 1:10
*/
namespace app\admin\controller\api;
use app\admin\controller\AdminController;
use think\facade\Cache;
/**
* 后台公共接口
* Class Common
* @package app\api\controller\admin
*/
class Common extends AdminController {
/**
* 获取菜单接口
*/
public function getMenu() {
$SysInfo = Cache::get('SysInfo');
if (!isset($SysInfo['AdminModuleName'])) {
return __error('后台绑定模块名数据有误,请刷新缓存或修改数据库配置!');
}
$this->redirect(url("{$SysInfo['AdminModuleName']}.php\api.menu\getMenu"));
}
/**
* 打开图片上传窗口
* @return \think\response\Json
*/
public function uploadIamge($type = 'one') {
$SysInfo = Cache::get('SysInfo');
if (!isset($SysInfo['AdminModuleName'])) {
return __error('后台绑定模块名数据有误,请刷新缓存或修改数据库配置!');
}
$this->redirect(url("{$SysInfo['AdminModuleName']}.php\\tool.upload\image") . "?type=" . $type);
}
/**
* 后台刷新缓存接口
* @return \think\response\Json
*/
public function clearCache() {
if (app('cache')->clear()) {
return __success('缓存刷新成功!');
} else {
return __error('缓存刷新失败!');
}
}
}

View File

@@ -0,0 +1,62 @@
<?php
/*
* 菜单控制接口
* */
namespace app\admin\controller\api;
use app\admin\controller\AdminController;
use think\facade\Cache;
class Menu extends AdminController
{
/**
* 根据权限规则生成菜单栏数据
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getMenu()
{
if (!empty(Cache::tag('menu')->get(session('user.id') . '_AdminMenu'))) {
return json(Cache::get(session('user.id') . '_AdminMenu'));
} else {
$menu_list = \app\admin\model\Menu::getMenuApi();
Cache::tag('menu')->set(session('user.id') . '_AdminMenu', $menu_list, 86400);
return json($menu_list);
}
}
/**
* 获取顶部菜单栏
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getNav()
{
if (!empty(Cache::tag('menu')->get(session('user.id') . '_AdminMenu'))) {
$menu_list = Cache::get(session('user.id') . '_AdminMenu');
} else {
$menu_list = \app\admin\model\Menu::getMenuApi();
Cache::tag('menu')->set(session('user.id') . '_AdminMenu', $menu_list, 86400);
}
$memu_id_list = [];
foreach ($menu_list as $key => $val) {
$menu_id = explode("66ysx_", $key);
isset($menu_id[1]) && $memu_id_list[] = $menu_id[1];
}
$nav = model('menu')->whereIn('id', $memu_id_list)->field('id, title, icon')
->order([
'sort' => 'asc',
'create_at' => 'asc',
])->select();
foreach ($nav as $key => $val) {
(strpos($nav[$key]['icon'], 'fa-') !== false) ? $nav[$key]['icon_type'] = true : $nav[$key]['icon_type'] = false;
}
return $nav;
}
}

View File

@@ -0,0 +1,66 @@
<?php
/*
* 系统节点接口
* */
namespace app\admin\controller\api;
use app\admin\controller\AdminController;
class Node extends AdminController {
/**
* 获取对应角色的节点数据
* @param $id
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getNodeTree($id) {
$list = [];
$module = model('node')->where(['type' => 1, 'is_auth' => 1])->order(['node' => 'asc'])->select();
foreach ($module as $k => $val) {
$list[$k] = [
'title' => $this->__biuldGetNodeTree($val['node'], $val['title']),
'value' => $val['id'],
'data' => [],
];
$is_checked = model('auth_node')->where(['auth' => $id, 'node' => $val['id']])->find();
!empty($is_checked) && $list[$k]['checked'] = true;
$data_1 = model('node')->where([['type', '=', 2], ['is_auth', '=', 1], ['node', 'LIKE', "{$val['node']}/%"]])->select();
foreach ($data_1 as $k_1 => $val_1) {
$list[$k]['data'][$k_1] = [
'title' => $this->__biuldGetNodeTree($val_1['node'], $val_1['title']),
'value' => $val_1['id'],
'data' => [],
];
$is_checked_1 = model('auth_node')->where(['auth' => $id, 'node' => $val_1['id']])->find();
!empty($is_checked_1) && $list[$k]['data'][$k_1]['checked'] = true;
$data_2 = model('node')->where([['type', '=', 3], ['is_auth', '=', 1], ['node', 'LIKE', "{$val_1['node']}/%"]])->select();
foreach ($data_2 as $k_2 => $val_2) {
$list[$k]['data'][$k_1]['data'][$k_2] = [
'title' => $this->__biuldGetNodeTree($val_2['node'], $val_2['title']),
'value' => $val_2['id'],
'data' => [],
];
$is_checked_2 = model('auth_node')->where(['auth' => $id, 'node' => $val_2['id']])->find();
!empty($is_checked_2) && $list[$k]['data'][$k_1]['data'][$k_2]['checked'] = true;
}
}
}
return json($list);
}
/**
* 组合数据
* @param $node
* @param $title
* @return string
*/
protected function __biuldGetNodeTree($node, $title) {
if (empty($title)) return $node;
else return $title . '【' . $node . '】';
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* 后台上传通用接口
* Class Upload
* @package app\admin\controller\api
*/
namespace app\admin\controller\api;
use app\admin\controller\AdminController;
use app\admin\service\QiniuService;
use think\Db;
class Upload extends AdminController {
/**
* 编辑器多图片上传
* @return \think\response\Json
*/
public function image() {
$files = request()->file();
if (is_array($files)) {
foreach ($files as $vo) {
$info = $vo->move('../public/static/uploads');
if ($info) {
$url[] = '/static/uploads/' . date('Ymd') . '/' . $info->getFilename();
} else {
return json(['code' => 1, 'msg' => $vo->getError()]);
}
}
} else {
$info = $files->move('../public/static/uploads');
if ($info) {
$url[] = '/static/uploads/' . date('Ymd') . '/' . $info->getFilename();
} else {
return json(['code' => 1, 'msg' => $files->getError()]);
}
}
//判断是否使用七牛云上传
$file_type = Db::name('SystemConfig')->where(['name' => 'FileType', 'group' => 'file'])->value('value');
if ($file_type == 2) {
foreach ($url as &$vo) {
$vo = QiniuService::upload($vo);
}
}
return json(['code' => 0, 'msg' => '上传成功!', 'url' => $url]);
}
}

View File

@@ -0,0 +1,17 @@
<?php
/**
* 欢迎页接口
* Class Welcome
* @package app\admin\controller\api
*/
namespace app\admin\controller\api;
use app\admin\controller\AdminController;
class Welcome extends AdminController {
}