优化项目目录结构

This commit is contained in:
2020-03-28 12:10:40 +08:00
parent f239647c7c
commit 671f66a0f0
33 changed files with 60 additions and 66 deletions

View File

@@ -9,13 +9,12 @@
namespace app\controller\admin; namespace app\controller\admin;
use app\model\AdPlace; use app\model\AdPlace;
use app\controller\Admin;
/** /**
* @title 广告管理 * @title 广告管理
* @description 广告管理 * @description 广告管理
*/ */
class Ad extends Admin { class Ad extends Base {
/** /**
* @title 广告位管理 * @title 广告位管理

View File

@@ -8,7 +8,6 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin;
use app\model\Addons as AddonsM; use app\model\Addons as AddonsM;
use app\model\Hooks; use app\model\Hooks;
@@ -16,7 +15,7 @@ use app\model\Hooks;
* @title 插件管理 * @title 插件管理
* @description 插件管理 * @description 插件管理
*/ */
class Addons extends Admin { class Addons extends Base {
/** /**
* @title 插件列表 * @title 插件列表

View File

@@ -8,13 +8,12 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin;
/** /**
* @title 字段管理 * @title 字段管理
* @description 字段管理 * @description 字段管理
*/ */
class Attribute extends Admin { class Attribute extends Base {
//保存的Model句柄 //保存的Model句柄
protected $model; protected $model;

View File

@@ -6,15 +6,14 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller; namespace app\controller\admin;
use app\model\Menu; use app\model\Menu;
use think\facade\View; use think\facade\View;
use \app\model\Form;
use \app\Base as BaseC;
/** class Base extends BaseC {
* @title 后端公共模块
*/
class Admin extends Base {
// 使用内置PHP模板引擎渲染模板输出 // 使用内置PHP模板引擎渲染模板输出
protected $tpl_config = [ protected $tpl_config = [
@@ -90,7 +89,7 @@ class Admin extends Base {
final protected function checkRule($rule, $type = AuthRule::rule_url, $mode = 'url') { final protected function checkRule($rule, $type = AuthRule::rule_url, $mode = 'url') {
static $Auth = null; static $Auth = null;
if (!$Auth) { if (!$Auth) {
$Auth = new \com\Auth(); $Auth = new \sent\Auth();
} }
if (!$Auth->check($rule, session('user_auth.uid'), $type, $mode)) { if (!$Auth->check($rule, session('user_auth.uid'), $type, $mode)) {
return false; return false;
@@ -125,8 +124,8 @@ class Admin extends Base {
* @author 朱亚杰 <xcoolcc@gmail.com> * @author 朱亚杰 <xcoolcc@gmail.com>
*/ */
final protected function accessControl() { final protected function accessControl() {
$allow = \think\Config::get('allow_visit'); $allow = \think\facade\Config::get('allow_visit');
$deny = \think\Config::get('deny_visit'); $deny = \think\facade\Config::get('deny_visit');
$check = strtolower($this->request->controller() . '/' . $this->request->action()); $check = strtolower($this->request->controller() . '/' . $this->request->action());
if (!empty($deny) && in_array_case($check, $deny)) { if (!empty($deny) && in_array_case($check, $deny)) {
return false; //非超管禁止访问deny中的方法 return false; //非超管禁止访问deny中的方法
@@ -191,7 +190,7 @@ class Admin extends Base {
} }
protected function getContentMenu() { protected function getContentMenu() {
$model = \think\Loader::model('Model'); $model = \think\facade\Loader::model('Model');
$list = array(); $list = array();
$map = array( $map = array(
'status' => array('gt', 0), 'status' => array('gt', 0),
@@ -202,10 +201,10 @@ class Admin extends Base {
$models = AuthGroup::getAuthModels(session('user_auth.uid')); $models = AuthGroup::getAuthModels(session('user_auth.uid'));
foreach ($list as $key => $value) { foreach ($list as $key => $value) {
if (IS_ROOT || in_array($value['id'], $models)) { if (IS_ROOT || in_array($value['id'], $models)) {
if ('admin/content/index' == $this->request->path() && input('model_id') == $value['id']) { if ('/admin/content/index' == $this->request->path() && input('model_id') == $value['id']) {
$value['style'] = "active"; $value['style'] = "active";
} }
$value['url'] = "admin/content/index?model_id=" . $value['id']; $value['url'] = "/admin/content/index?model_id=" . $value['id'];
$value['title'] = $value['title'] . "管理"; $value['title'] = $value['title'] . "管理";
$value['icon'] = $value['icon'] ? $value['icon'] : 'file'; $value['icon'] = $value['icon'] ? $value['icon'] : 'file';
$menu[] = $value; $menu[] = $value;

View File

@@ -12,13 +12,12 @@ namespace app\controller\admin;
use app\model\Category as CategoryM; use app\model\Category as CategoryM;
use app\model\Attribute; use app\model\Attribute;
use app\model\Model; use app\model\Model;
use app\controller\Admin;
/** /**
* @title 栏目管理 * @title 栏目管理
* @description 分类管理 * @description 分类管理
*/ */
class Category extends Admin { class Category extends Base {
public function _initialize() { public function _initialize() {
parent::_initialize(); parent::_initialize();

View File

@@ -9,7 +9,6 @@
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin;
use app\model\Channel as ChannelM; use app\model\Channel as ChannelM;
use sent\tree\Tree; use sent\tree\Tree;
@@ -17,7 +16,7 @@ use sent\tree\Tree;
* @title 频道管理 * @title 频道管理
* @description 频道管理 * @description 频道管理
*/ */
class Channel extends Admin { class Channel extends Base {
/** /**
* @title 频道列表 * @title 频道列表

View File

@@ -10,12 +10,11 @@
namespace app\controller\admin; namespace app\controller\admin;
use app\model\Client as ClientM; use app\model\Client as ClientM;
use app\controller\Admin;
/** /**
* @title 客户端管理 * @title 客户端管理
*/ */
class Client extends Admin { class Client extends Base {
/** /**
* @title 客户端列表 * @title 客户端列表

View File

@@ -8,14 +8,13 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin;
use app\model\Config as ConfigM; use app\model\Config as ConfigM;
use think\facade\Cache; use think\facade\Cache;
/** /**
* @title 配置管理 * @title 配置管理
*/ */
class Config extends Admin { class Config extends Base {
public function _initialize() { public function _initialize() {
parent::_initialize(); parent::_initialize();

View File

@@ -8,12 +8,11 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin;
/** /**
* @title 内容管理 * @title 内容管理
*/ */
class Content extends Admin { class Content extends Base {
public function _initialize() { public function _initialize() {
parent::_initialize(); parent::_initialize();

View File

@@ -9,13 +9,12 @@
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin;
/** /**
* @title 数据库管理 * @title 数据库管理
* @description 数据库管理 * @description 数据库管理
*/ */
class Database extends Admin { class Database extends Base {
/** /**
* 数据库备份/还原列表 * 数据库备份/还原列表
* @param String $type import-还原export-备份 * @param String $type import-还原export-备份

View File

@@ -8,7 +8,6 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin;
use app\model\Form as FormM; use app\model\Form as FormM;
use app\model\FormAttr; use app\model\FormAttr;
@@ -16,7 +15,7 @@ use app\model\FormAttr;
* @title 自定义表单 * @title 自定义表单
* @description 自定义表单 * @description 自定义表单
*/ */
class Form extends Admin { class Form extends Base {
/** /**
* @title 表单列表 * @title 表单列表

View File

@@ -8,7 +8,6 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin;
use app\model\AuthGroup; use app\model\AuthGroup;
use app\model\AuthRule; use app\model\AuthRule;
@@ -16,7 +15,7 @@ use app\model\AuthRule;
* @title 用户组管理 * @title 用户组管理
* @description 用户组管理 * @description 用户组管理
*/ */
class Group extends Admin { class Group extends Base {
/** /**
* @title 用户组列表 * @title 用户组列表

View File

@@ -8,14 +8,13 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin;
use app\model\Member; use app\model\Member;
use think\facade\Session; use think\facade\Session;
/** /**
* @title 后端公共模块 * @title 后端公共模块
*/ */
class Index extends Admin { class Index extends Base {
/** /**
* @title 后台首页 * @title 后台首页

View File

@@ -9,13 +9,12 @@
namespace app\controller\admin; namespace app\controller\admin;
use app\model\Link as LinkM; use app\model\Link as LinkM;
use app\controller\Admin;
/** /**
* @title 友情链接 * @title 友情链接
* @description 友情链接 * @description 友情链接
*/ */
class Link extends Admin { class Link extends Base {
/** /**
* @title 链接列表 * @title 链接列表

View File

@@ -9,14 +9,13 @@
namespace app\controller\admin; namespace app\controller\admin;
use sent\tree\Tree; use sent\tree\Tree;
use app\controller\Admin;
use app\model\Menu as MenuM; use app\model\Menu as MenuM;
use think\facade\Cache; use think\facade\Cache;
/** /**
* @title 菜单管理 * @title 菜单管理
*/ */
class Menu extends Admin { class Menu extends Base {
public function _initialize() { public function _initialize() {
parent::_initialize(); parent::_initialize();

View File

@@ -8,13 +8,12 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin;
use app\model\Model as ModelM; use app\model\Model as ModelM;
/** /**
* @title 模型管理 * @title 模型管理
*/ */
class Model extends Admin { class Model extends Base {
public function _initialize() { public function _initialize() {
parent::_initialize(); parent::_initialize();

View File

@@ -8,14 +8,13 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin;
use app\model\SeoRule; use app\model\SeoRule;
use app\model\Rewrite; use app\model\Rewrite;
/** /**
* @title SEO管理 * @title SEO管理
*/ */
class Seo extends Admin { class Seo extends Base {
/** /**
* @title SEO列表 * @title SEO列表

View File

@@ -8,9 +8,8 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin;
class Upload extends Admin { class Upload extends Base {
public function _empty() { public function _empty() {
$controller = controller('common/Upload'); $controller = controller('common/Upload');

View File

@@ -9,12 +9,11 @@
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin;
use app\model\Member; use app\model\Member;
/** /**
* @title 用户管理 * @title 用户管理
*/ */
class User extends Admin { class User extends Base {
/** /**
* @title 用户列表 * @title 用户列表

View File

@@ -9,14 +9,13 @@
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin;
use app\model\Wechat as WechatM; use app\model\Wechat as WechatM;
/** /**
* @title 微信公众号 * @title 微信公众号
* @description 微信公众号管理 * @description 微信公众号管理
*/ */
class Wechat extends Admin { class Wechat extends Base {
/** /**
* @title 公众号列表 * @title 公众号列表

View File

@@ -8,12 +8,10 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\api; namespace app\controller\api;
use app\controller\Api as ApiBase;
/** /**
* @title 接口功能 * @title 接口功能
*/ */
class Api extends ApiBase { class Api extends Base {
public $filter_method = ['__construct']; public $filter_method = ['__construct'];

View File

@@ -6,9 +6,9 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller; namespace app\controller\api;
class Api extends Base { class Base {
public $middleware = [ public $middleware = [
'\app\http\middleware\Validate', '\app\http\middleware\Validate',

View File

@@ -8,13 +8,12 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\api; namespace app\controller\api;
use app\controller\Api;
use app\model\Config as ConfigM; use app\model\Config as ConfigM;
/** /**
* @title 基础功能 * @title 基础功能
*/ */
class Config extends Api { class Config extends Base {
/** /**
* @title 配置数据 * @title 配置数据

View File

@@ -8,7 +8,6 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\api; namespace app\controller\api;
use app\controller\Api;
use app\model\Department as DepartmentM; use app\model\Department as DepartmentM;
use app\model\Role; use app\model\Role;
use sent\tree\Tree; use sent\tree\Tree;
@@ -16,7 +15,7 @@ use sent\tree\Tree;
/** /**
* @title 部门管理 * @title 部门管理
*/ */
class Department extends Api { class Department extends Base {
/** /**
* @title 部门列表 * @title 部门列表

View File

@@ -8,7 +8,6 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\api; namespace app\controller\api;
use app\controller\Api;
use app\model\Member; use app\model\Member;
use app\model\MemberLog; use app\model\MemberLog;
use app\model\Role; use app\model\Role;
@@ -18,7 +17,7 @@ use xin\helper\Str;
/** /**
* @title 用户管理 * @title 用户管理
*/ */
class User extends Api { class User extends Base {
/** /**
* @title 用户列表 * @title 用户列表

View File

@@ -0,0 +1,15 @@
<?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;
use \app\Base as BaseC;
class Base extends BaseC {
}

View File

@@ -6,12 +6,13 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller; namespace app\controller\front;
use \app\model\Form; use \app\model\Form;
class Front extends Base { class Front extends Base {
public function index() { public function index() {
return $this->fetch(); return $this->fetch();
} }

View File

@@ -21,11 +21,11 @@ class Validate {
//获取当前参数 //获取当前参数
$params = $request->param(); $params = $request->param();
//获取访问控制器 //获取访问控制器
$controller = strtr($request->controller(), '.', '\\'); $controller = explode(".", $request->controller());
//获取操作名,用于验证场景scene //获取操作名,用于验证场景scene
$scene = $request->action(); $scene = $controller[0] . ucfirst($request->action());
$validate = "app\\http\\validate\\" . $controller; $validate = "app\\http\\validate\\" . strtolower($controller[1]);
//仅当验证器存在时 进行校验 //仅当验证器存在时 进行校验
if (class_exists($validate) && $request->isPost()) { if (class_exists($validate) && $request->isPost()) {
$v = new $validate; $v = new $validate;

View File

@@ -58,14 +58,17 @@ class Model extends \think\Model{
if (isset($data['attribute_sort']) && $data['attribute_sort']) { if (isset($data['attribute_sort']) && $data['attribute_sort']) {
$attribute_sort = json_decode($data['attribute_sort'], true); $attribute_sort = json_decode($data['attribute_sort'], true);
$attr = [];
if (!empty($attribute_sort)) { if (!empty($attribute_sort)) {
foreach ($attribute_sort as $key => $value) { foreach ($attribute_sort as $key => $value) {
db('Attribute')->where('id', 'IN', $value)->setField('group_id', $key);
foreach ($value as $k => $v) { foreach ($value as $k => $v) {
db('Attribute')->where('id', $v)->setField('sort', $k); $attr[] = ['id' => $v, 'group_id' => $key, 'sort' => $k];
} }
} }
} }
if (!empty($attr)) {
(new Attribute())->saveAll($attr);
}
} }
return true; return true;
} }