更新目录结构
This commit is contained in:
133
app/controller/admin/system/Dict.php
Normal file
133
app/controller/admin/system/Dict.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin\system;
|
||||
|
||||
use app\controller\Base;
|
||||
use app\services\system\DictionaryService;
|
||||
|
||||
/**
|
||||
* @title 字典功能
|
||||
*/
|
||||
class Dict extends Base{
|
||||
|
||||
/**
|
||||
* @title 字典分类数据
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function category(DictionaryService $dic){
|
||||
$list = $dic->getTree($this->request);
|
||||
$this->data['data'] = $list;
|
||||
return $this->data;
|
||||
}
|
||||
/**
|
||||
* @title 添加字典分类
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addcate(DictionaryService $dic){
|
||||
try {
|
||||
$data = $dic->addcate($this->request);
|
||||
$this->data['code'] = 1;
|
||||
$this->data['data'] = $data;
|
||||
} catch (\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
return $this->data;
|
||||
}
|
||||
/**
|
||||
* @title 修改字典分类
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function editcate(DictionaryService $dic){
|
||||
try {
|
||||
$data = $dic->editcate($this->request);
|
||||
$this->data['code'] = 1;
|
||||
$this->data['data'] = $data;
|
||||
} catch (\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
return $this->data;
|
||||
}
|
||||
public function delcate(DictionaryService $dic){
|
||||
$dic->deleteCategory($this->request);
|
||||
return $this->data;
|
||||
}
|
||||
/**
|
||||
* @title 字典列表
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function lists(DictionaryService $dic){
|
||||
$list = $dic->getDictionary($this->request);
|
||||
$this->data['data'] = $list;
|
||||
return $this->data;
|
||||
}
|
||||
/**
|
||||
* @title 添加字典
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add(DictionaryService $dic){
|
||||
try {
|
||||
$data = $dic->createDic($this->request);
|
||||
$this->data['code'] = 1;
|
||||
$this->data['data'] = $data;
|
||||
} catch (\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
return $this->data;
|
||||
}
|
||||
/**
|
||||
* @title 修改字典
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function edit(DictionaryService $dic){
|
||||
try {
|
||||
$data = $dic->updateDic($this->request);
|
||||
$this->data['code'] = 1;
|
||||
$this->data['data'] = $data;
|
||||
} catch (\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
return $this->data;
|
||||
}
|
||||
/**
|
||||
* @title 删除字典
|
||||
*
|
||||
* @param DictionaryService $dic
|
||||
* @return void
|
||||
*/
|
||||
public function delete(DictionaryService $dic){
|
||||
$dic->deleteDic($this->request);
|
||||
return $this->data;
|
||||
}
|
||||
/**
|
||||
* @title 字典明细
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function detail(DictionaryService $dic){
|
||||
$list = $dic->getDictionaryDetail($this->request);
|
||||
$this->data['data'] = $list;
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function all(DictionaryService $dic){
|
||||
$list = $dic->getDictionaryAll($this->request);
|
||||
$this->data['data'] = $list;
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
70
app/controller/admin/system/File.php
Normal file
70
app/controller/admin/system/File.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin\system;
|
||||
|
||||
use app\controller\Base;
|
||||
use app\validate\File as Files;
|
||||
use app\services\system\DictionaryService;
|
||||
|
||||
/**
|
||||
* @title 文件
|
||||
*/
|
||||
class File extends Base{
|
||||
|
||||
/**
|
||||
* @title 上传
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function upload(){
|
||||
$file = request()->file('file');
|
||||
$type = request()->param('type', 'images');
|
||||
|
||||
try {
|
||||
$this->data['data'] = $this->$type($file, $type);
|
||||
} catch (\think\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 用户头像上传
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function avatar($file, $type){
|
||||
try {
|
||||
validate(Files::class)->check(['avatar' => $file]);
|
||||
// 上传到本地服务器
|
||||
$savename = \think\facade\Filesystem::putFile( $type, $file);
|
||||
return ['src' => request()->static() . $savename, 'fileName' => ''];
|
||||
} catch (\think\exception\ValidateException $e) {
|
||||
throw new \think\Exception($e->getMessage(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 图片上传
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function images($file, $type){
|
||||
try {
|
||||
validate(Files::class)->check(['image' => $file]);
|
||||
// 上传到本地服务器
|
||||
$savename = \think\facade\Filesystem::putFile( $type, $file);
|
||||
return ['src' => request()->static() . $savename, 'fileName' => ''];
|
||||
} catch (\think\exception\ValidateException $e) {
|
||||
throw new \think\Exception($e->getMessage(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
45
app/controller/admin/system/Index.php
Normal file
45
app/controller/admin/system/Index.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin\system;
|
||||
|
||||
use app\controller\Base;
|
||||
use app\services\system\ConfigService;
|
||||
|
||||
class Index extends Base{
|
||||
|
||||
/**
|
||||
* @title 系统版本
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function version(){
|
||||
$system_info_mysql = \think\facade\Db::query("select version() as v;");
|
||||
$this->data['data'] = [
|
||||
['label' => '核心版本', 'values' => \think\facade\Env::get('version')],
|
||||
['label' => '服务器操作系统', 'values' => PHP_OS],
|
||||
['label' => '运行环境', 'values' => $_SERVER['SERVER_SOFTWARE']],
|
||||
['label' => 'MYSQL版本', 'values' => $system_info_mysql[0]['v']],
|
||||
['label' => '上传限制', 'values' => '10']
|
||||
];
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置列表
|
||||
*
|
||||
* @param ConfigService $service
|
||||
* @return void
|
||||
*/
|
||||
public function setting(ConfigService $service){
|
||||
$list = $service->getConfigField();
|
||||
|
||||
$this->data['data'] = $list;
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
42
app/controller/admin/system/Log.php
Normal file
42
app/controller/admin/system/Log.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin\system;
|
||||
|
||||
use app\controller\Base;
|
||||
use app\services\auth\UsersLogService;
|
||||
|
||||
/**
|
||||
* @title 用户日志管理
|
||||
*/
|
||||
class Log extends Base {
|
||||
|
||||
/**
|
||||
* @title 日志列表
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function index(){
|
||||
$list = app()->make(UsersLogService::class)->getUserLogList($this->request);
|
||||
|
||||
$this->data['data'] = $list;
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 我的日志
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function my(){
|
||||
$list = app()->make(UsersLogService::class)->getMyLogList($this->request);
|
||||
|
||||
$this->data['data'] = $list;
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
134
app/controller/admin/system/Menu.php
Normal file
134
app/controller/admin/system/Menu.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin\system;
|
||||
|
||||
use app\controller\Base;
|
||||
use app\services\auth\MenuService;
|
||||
use app\services\auth\AuthService;
|
||||
|
||||
class Menu extends Base{
|
||||
|
||||
/**
|
||||
* @title 权限列表
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param Departments $department
|
||||
* @return Array
|
||||
*/
|
||||
public function index() {
|
||||
$data = app()->make(MenuService::class)->getSystemMenu(false);
|
||||
$this->data['data'] = $data;
|
||||
return $this->data;
|
||||
}
|
||||
/**
|
||||
* @title 权限保存
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @return Array
|
||||
*/
|
||||
public function add() {
|
||||
$data = request()->post();
|
||||
$data['creator_id'] = request()->user['uid'];
|
||||
try {
|
||||
$result = app()->make(MenuService::class)->createData($data);
|
||||
$this->data['data'] = $result;
|
||||
$this->data['message'] = '添加成功!';
|
||||
} catch (\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
return $this->data;
|
||||
}
|
||||
/**
|
||||
* @title 权限更新
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return Array
|
||||
*/
|
||||
public function edit() {
|
||||
$data = request()->post();
|
||||
try {
|
||||
$result = app()->make(MenuService::class)->saveData($data);
|
||||
if($result){
|
||||
$this->data['data'] = app()->make(AuthService::class)->getAuthMenu();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
return $this->data;
|
||||
}
|
||||
/**
|
||||
* @title 权限删除
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param $id
|
||||
* @return Array
|
||||
*/
|
||||
public function delete() {
|
||||
$ids = request()->post('ids');
|
||||
try {
|
||||
$result = app()->make(MenuService::class)->deleteMenu($ids);
|
||||
$this->data['data'] = app()->make(MenuService::class)->getSystemMenu();
|
||||
} catch (\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
return $this->data;
|
||||
}
|
||||
/**
|
||||
* @title 菜单路由
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param $id
|
||||
* @return Array
|
||||
*/
|
||||
public function routes(Permissions $permission) {
|
||||
$map = [];
|
||||
$map[] = ['type', '=', 1];
|
||||
$map[] = ['hidden', '=', 1];
|
||||
$list = $permission->where($map)->field('router,name,icon,id,parent_id')->order('sort asc')->select()->toArray();
|
||||
$tree = (new Tree())->listToTree($list, 'id', 'parent_id', 'children');
|
||||
$this->data['data'] = [['router' => 'root', 'children' => $tree]];
|
||||
return $this->data;
|
||||
}
|
||||
/**
|
||||
* @title 权限数据
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param $id
|
||||
* @return Array
|
||||
*/
|
||||
public function permission(Permissions $permission) {
|
||||
$map = [];
|
||||
$map[] = ['hidden', '=', 1];
|
||||
$list = $permission->where($map)->field('router,name,icon,id,parent_id')->order('sort asc')->select()->toArray();
|
||||
$data = [];
|
||||
foreach($list as $item){
|
||||
if($item['type'] == 1){
|
||||
$data[$item['id']] = $item;
|
||||
}else{
|
||||
$data[$item['parent_id']]['module'] = $item;
|
||||
}
|
||||
}
|
||||
$this->data['data'] = $data;
|
||||
return $this->data;
|
||||
}
|
||||
/**
|
||||
* @title 我的菜单
|
||||
* @return Array
|
||||
*/
|
||||
public function my(AuthService $service){
|
||||
$this->data['code'] = 1;
|
||||
$this->data['data'] = ['menu' => $service->getAuthMenu($this->request), 'permissions' => $service->getAuthPermissions($this->request)];
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user