优化项目目录结构
This commit is contained in:
@@ -9,13 +9,12 @@
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\model\AdPlace;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 广告管理
|
||||
* @description 广告管理
|
||||
*/
|
||||
class Ad extends Admin {
|
||||
class Ad extends Base {
|
||||
|
||||
/**
|
||||
* @title 广告位管理
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\Addons as AddonsM;
|
||||
use app\model\Hooks;
|
||||
|
||||
@@ -16,7 +15,7 @@ use app\model\Hooks;
|
||||
* @title 插件管理
|
||||
* @description 插件管理
|
||||
*/
|
||||
class Addons extends Admin {
|
||||
class Addons extends Base {
|
||||
|
||||
/**
|
||||
* @title 插件列表
|
||||
|
||||
@@ -8,13 +8,12 @@
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 字段管理
|
||||
* @description 字段管理
|
||||
*/
|
||||
class Attribute extends Admin {
|
||||
class Attribute extends Base {
|
||||
|
||||
//保存的Model句柄
|
||||
protected $model;
|
||||
|
||||
21
app/controller/Admin.php → app/controller/admin/Base.php
Executable file → Normal file
21
app/controller/Admin.php → app/controller/admin/Base.php
Executable file → Normal file
@@ -6,15 +6,14 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller;
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\model\Menu;
|
||||
use think\facade\View;
|
||||
use \app\model\Form;
|
||||
use \app\Base as BaseC;
|
||||
|
||||
/**
|
||||
* @title 后端公共模块
|
||||
*/
|
||||
class Admin extends Base {
|
||||
class Base extends BaseC {
|
||||
|
||||
// 使用内置PHP模板引擎渲染模板输出
|
||||
protected $tpl_config = [
|
||||
@@ -90,7 +89,7 @@ class Admin extends Base {
|
||||
final protected function checkRule($rule, $type = AuthRule::rule_url, $mode = 'url') {
|
||||
static $Auth = null;
|
||||
if (!$Auth) {
|
||||
$Auth = new \com\Auth();
|
||||
$Auth = new \sent\Auth();
|
||||
}
|
||||
if (!$Auth->check($rule, session('user_auth.uid'), $type, $mode)) {
|
||||
return false;
|
||||
@@ -125,8 +124,8 @@ class Admin extends Base {
|
||||
* @author 朱亚杰 <xcoolcc@gmail.com>
|
||||
*/
|
||||
final protected function accessControl() {
|
||||
$allow = \think\Config::get('allow_visit');
|
||||
$deny = \think\Config::get('deny_visit');
|
||||
$allow = \think\facade\Config::get('allow_visit');
|
||||
$deny = \think\facade\Config::get('deny_visit');
|
||||
$check = strtolower($this->request->controller() . '/' . $this->request->action());
|
||||
if (!empty($deny) && in_array_case($check, $deny)) {
|
||||
return false; //非超管禁止访问deny中的方法
|
||||
@@ -191,7 +190,7 @@ class Admin extends Base {
|
||||
}
|
||||
|
||||
protected function getContentMenu() {
|
||||
$model = \think\Loader::model('Model');
|
||||
$model = \think\facade\Loader::model('Model');
|
||||
$list = array();
|
||||
$map = array(
|
||||
'status' => array('gt', 0),
|
||||
@@ -202,10 +201,10 @@ class Admin extends Base {
|
||||
$models = AuthGroup::getAuthModels(session('user_auth.uid'));
|
||||
foreach ($list as $key => $value) {
|
||||
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['url'] = "admin/content/index?model_id=" . $value['id'];
|
||||
$value['url'] = "/admin/content/index?model_id=" . $value['id'];
|
||||
$value['title'] = $value['title'] . "管理";
|
||||
$value['icon'] = $value['icon'] ? $value['icon'] : 'file';
|
||||
$menu[] = $value;
|
||||
@@ -12,13 +12,12 @@ namespace app\controller\admin;
|
||||
use app\model\Category as CategoryM;
|
||||
use app\model\Attribute;
|
||||
use app\model\Model;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 栏目管理
|
||||
* @description 分类管理
|
||||
*/
|
||||
class Category extends Admin {
|
||||
class Category extends Base {
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\Channel as ChannelM;
|
||||
use sent\tree\Tree;
|
||||
|
||||
@@ -17,7 +16,7 @@ use sent\tree\Tree;
|
||||
* @title 频道管理
|
||||
* @description 频道管理
|
||||
*/
|
||||
class Channel extends Admin {
|
||||
class Channel extends Base {
|
||||
|
||||
/**
|
||||
* @title 频道列表
|
||||
|
||||
@@ -10,12 +10,11 @@
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\model\Client as ClientM;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 客户端管理
|
||||
*/
|
||||
class Client extends Admin {
|
||||
class Client extends Base {
|
||||
|
||||
/**
|
||||
* @title 客户端列表
|
||||
|
||||
@@ -8,14 +8,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\Config as ConfigM;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* @title 配置管理
|
||||
*/
|
||||
class Config extends Admin {
|
||||
class Config extends Base {
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
|
||||
@@ -8,12 +8,11 @@
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 内容管理
|
||||
*/
|
||||
class Content extends Admin {
|
||||
class Content extends Base {
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
|
||||
@@ -9,13 +9,12 @@
|
||||
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 数据库管理
|
||||
* @description 数据库管理
|
||||
*/
|
||||
class Database extends Admin {
|
||||
class Database extends Base {
|
||||
/**
|
||||
* 数据库备份/还原列表
|
||||
* @param String $type import-还原,export-备份
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\Form as FormM;
|
||||
use app\model\FormAttr;
|
||||
|
||||
@@ -16,7 +15,7 @@ use app\model\FormAttr;
|
||||
* @title 自定义表单
|
||||
* @description 自定义表单
|
||||
*/
|
||||
class Form extends Admin {
|
||||
class Form extends Base {
|
||||
|
||||
/**
|
||||
* @title 表单列表
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\AuthGroup;
|
||||
use app\model\AuthRule;
|
||||
|
||||
@@ -16,7 +15,7 @@ use app\model\AuthRule;
|
||||
* @title 用户组管理
|
||||
* @description 用户组管理
|
||||
*/
|
||||
class Group extends Admin {
|
||||
class Group extends Base {
|
||||
|
||||
/**
|
||||
* @title 用户组列表
|
||||
|
||||
@@ -8,14 +8,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\Member;
|
||||
use think\facade\Session;
|
||||
|
||||
/**
|
||||
* @title 后端公共模块
|
||||
*/
|
||||
class Index extends Admin {
|
||||
class Index extends Base {
|
||||
|
||||
/**
|
||||
* @title 后台首页
|
||||
|
||||
@@ -9,13 +9,12 @@
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\model\Link as LinkM;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 友情链接
|
||||
* @description 友情链接
|
||||
*/
|
||||
class Link extends Admin {
|
||||
class Link extends Base {
|
||||
|
||||
/**
|
||||
* @title 链接列表
|
||||
|
||||
@@ -9,14 +9,13 @@
|
||||
namespace app\controller\admin;
|
||||
|
||||
use sent\tree\Tree;
|
||||
use app\controller\Admin;
|
||||
use app\model\Menu as MenuM;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* @title 菜单管理
|
||||
*/
|
||||
class Menu extends Admin {
|
||||
class Menu extends Base {
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
|
||||
@@ -8,13 +8,12 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\Model as ModelM;
|
||||
|
||||
/**
|
||||
* @title 模型管理
|
||||
*/
|
||||
class Model extends Admin {
|
||||
class Model extends Base {
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
|
||||
@@ -8,14 +8,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\SeoRule;
|
||||
use app\model\Rewrite;
|
||||
|
||||
/**
|
||||
* @title SEO管理
|
||||
*/
|
||||
class Seo extends Admin {
|
||||
class Seo extends Base {
|
||||
|
||||
/**
|
||||
* @title SEO列表
|
||||
|
||||
@@ -8,9 +8,8 @@
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
|
||||
class Upload extends Admin {
|
||||
class Upload extends Base {
|
||||
|
||||
public function _empty() {
|
||||
$controller = controller('common/Upload');
|
||||
|
||||
@@ -9,12 +9,11 @@
|
||||
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\Member;
|
||||
/**
|
||||
* @title 用户管理
|
||||
*/
|
||||
class User extends Admin {
|
||||
class User extends Base {
|
||||
|
||||
/**
|
||||
* @title 用户列表
|
||||
|
||||
@@ -9,14 +9,13 @@
|
||||
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\Wechat as WechatM;
|
||||
|
||||
/**
|
||||
* @title 微信公众号
|
||||
* @description 微信公众号管理
|
||||
*/
|
||||
class Wechat extends Admin {
|
||||
class Wechat extends Base {
|
||||
|
||||
/**
|
||||
* @title 公众号列表
|
||||
|
||||
@@ -8,12 +8,10 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\api;
|
||||
|
||||
use app\controller\Api as ApiBase;
|
||||
|
||||
/**
|
||||
* @title 接口功能
|
||||
*/
|
||||
class Api extends ApiBase {
|
||||
class Api extends Base {
|
||||
|
||||
public $filter_method = ['__construct'];
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller;
|
||||
namespace app\controller\api;
|
||||
|
||||
class Api extends Base {
|
||||
class Base {
|
||||
|
||||
public $middleware = [
|
||||
'\app\http\middleware\Validate',
|
||||
@@ -8,13 +8,12 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\api;
|
||||
|
||||
use app\controller\Api;
|
||||
use app\model\Config as ConfigM;
|
||||
|
||||
/**
|
||||
* @title 基础功能
|
||||
*/
|
||||
class Config extends Api {
|
||||
class Config extends Base {
|
||||
|
||||
/**
|
||||
* @title 配置数据
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\api;
|
||||
|
||||
use app\controller\Api;
|
||||
use app\model\Department as DepartmentM;
|
||||
use app\model\Role;
|
||||
use sent\tree\Tree;
|
||||
@@ -16,7 +15,7 @@ use sent\tree\Tree;
|
||||
/**
|
||||
* @title 部门管理
|
||||
*/
|
||||
class Department extends Api {
|
||||
class Department extends Base {
|
||||
|
||||
/**
|
||||
* @title 部门列表
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\api;
|
||||
|
||||
use app\controller\Api;
|
||||
use app\model\Member;
|
||||
use app\model\MemberLog;
|
||||
use app\model\Role;
|
||||
@@ -18,7 +17,7 @@ use xin\helper\Str;
|
||||
/**
|
||||
* @title 用户管理
|
||||
*/
|
||||
class User extends Api {
|
||||
class User extends Base {
|
||||
|
||||
/**
|
||||
* @title 用户列表
|
||||
|
||||
15
app/controller/front/Base.php
Normal file
15
app/controller/front/Base.php
Normal 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 {
|
||||
|
||||
}
|
||||
@@ -6,12 +6,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller;
|
||||
namespace app\controller\front;
|
||||
|
||||
use \app\model\Form;
|
||||
|
||||
|
||||
class Front extends Base {
|
||||
|
||||
public function index() {
|
||||
return $this->fetch();
|
||||
}
|
||||
@@ -21,11 +21,11 @@ class Validate {
|
||||
//获取当前参数
|
||||
$params = $request->param();
|
||||
//获取访问控制器
|
||||
$controller = strtr($request->controller(), '.', '\\');
|
||||
$controller = explode(".", $request->controller());
|
||||
|
||||
//获取操作名,用于验证场景scene
|
||||
$scene = $request->action();
|
||||
$validate = "app\\http\\validate\\" . $controller;
|
||||
$scene = $controller[0] . ucfirst($request->action());
|
||||
$validate = "app\\http\\validate\\" . strtolower($controller[1]);
|
||||
//仅当验证器存在时 进行校验
|
||||
if (class_exists($validate) && $request->isPost()) {
|
||||
$v = new $validate;
|
||||
|
||||
@@ -58,14 +58,17 @@ class Model extends \think\Model{
|
||||
if (isset($data['attribute_sort']) && $data['attribute_sort']) {
|
||||
$attribute_sort = json_decode($data['attribute_sort'], true);
|
||||
|
||||
$attr = [];
|
||||
if (!empty($attribute_sort)) {
|
||||
foreach ($attribute_sort as $key => $value) {
|
||||
db('Attribute')->where('id', 'IN', $value)->setField('group_id', $key);
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user