From 8a16560d0713d83f7ac107dd8da59af1ca1162ba Mon Sep 17 00:00:00 2001 From: cxdbz Date: Fri, 12 Oct 2018 22:49:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E7=94=A8=E6=88=B7=E8=A1=A8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=BF=81=E7=A7=BB=E3=80=81=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=A9=BA=E6=8E=A7=E5=88=B6=E5=99=A8=E5=92=8C=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E7=9A=84=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/controller/Base.php | 2 +- application/common/controller/index | 0 application/error/controller/Index.php | 2 +- application/error/view/index/index.html | 35 +++++++++++++ application/http/middleware/YanZheng.php | 15 +++--- application/index/controller/Error.php | 21 ++++++++ application/index/controller/Index.php | 2 - application/student/controller/Error.php | 14 ++++++ application/system/controller/Error.php | 14 ++++++ config/auth/app.php | 13 ----- config/index/app.php | 9 ++++ database/migrations/20181012140355_member.php | 50 +++++++++++++++++++ route/error.php | 14 ++++++ vendor/5ini99/think-auth/src/Auth.php | 16 +++--- 14 files changed, 173 insertions(+), 34 deletions(-) create mode 100644 application/common/controller/index create mode 100644 application/error/view/index/index.html create mode 100644 application/index/controller/Error.php create mode 100644 application/student/controller/Error.php create mode 100644 application/system/controller/Error.php delete mode 100644 config/auth/app.php create mode 100644 database/migrations/20181012140355_member.php create mode 100644 route/error.php diff --git a/application/common/controller/Base.php b/application/common/controller/Base.php index de56e575..da496bb3 100644 --- a/application/common/controller/Base.php +++ b/application/common/controller/Base.php @@ -16,7 +16,7 @@ class Base extends Controller public function _empty() { - $this->redirect('error/index/index'); + $this->redirect(url('/notfound')); } } diff --git a/application/common/controller/index b/application/common/controller/index new file mode 100644 index 00000000..e69de29b diff --git a/application/error/controller/Index.php b/application/error/controller/Index.php index 5dcb93d8..e3128a32 100644 --- a/application/error/controller/Index.php +++ b/application/error/controller/Index.php @@ -15,7 +15,7 @@ class Index extends Controller public function index() { // - dump('空方法转到这里'); + return $this->fetch(); } diff --git a/application/error/view/index/index.html b/application/error/view/index/index.html new file mode 100644 index 00000000..f5b504a8 --- /dev/null +++ b/application/error/view/index/index.html @@ -0,0 +1,35 @@ + + + + + + + + + +{css href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/static/h-ui/css/H-ui.min.css" /} +{css href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/static/h-ui.admin/css/H-ui.admin.css" /} +{css href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/Hui-iconfont/1.0.8/iconfont.css" /} + +404页面 + + +
+

+ 404 +

+

不好意思,您访问的页面不存在~

+

您可以: + < 返回上一页 + | + 去首页 > +

+
+ + \ No newline at end of file diff --git a/application/http/middleware/YanZheng.php b/application/http/middleware/YanZheng.php index ad9a7808..a8352088 100644 --- a/application/http/middleware/YanZheng.php +++ b/application/http/middleware/YanZheng.php @@ -12,16 +12,13 @@ class YanZheng extends Controller // 实例化权限验证类 $auth = new Auth(); - // 检测权限 - // if($auth->check('show_button',1)){// 第一个参数是规则名称,第二个参数是用户UID - // //有显示操作按钮的权限 - // }else{ - // //没有显示操作按钮的权限 - // } - - $request->hello = 'ThinkPHP'; - $a = $request->action(); + if($auth->check('show_button',1)){// 第一个参数是规则名称,第二个参数是用户UID + dump('验证通过'); + }else{ + dump('验证不通过'); + } + return $next($request); } diff --git a/application/index/controller/Error.php b/application/index/controller/Error.php new file mode 100644 index 00000000..857c48f5 --- /dev/null +++ b/application/index/controller/Error.php @@ -0,0 +1,21 @@ +redirect(url('/notfound')); + } + +} diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php index 93a05834..7b251293 100644 --- a/application/index/controller/Index.php +++ b/application/index/controller/Index.php @@ -6,7 +6,6 @@ use app\common\controller\Base; // 引用与此控制器同名的数据模型 use app\system\model\SystemBase as sysbasemod; -use think\auth\Auth; class Index extends Base { @@ -27,7 +26,6 @@ class Index extends Base $sysbasemod->title = '学生成绩统计系统'; $sysbasemod->save(); } - dump('index初始化'); } diff --git a/application/student/controller/Error.php b/application/student/controller/Error.php new file mode 100644 index 00000000..74eb2b0a --- /dev/null +++ b/application/student/controller/Error.php @@ -0,0 +1,14 @@ +redirect(url('/notfound')); + } +} diff --git a/application/system/controller/Error.php b/application/system/controller/Error.php new file mode 100644 index 00000000..d62455c6 --- /dev/null +++ b/application/system/controller/Error.php @@ -0,0 +1,14 @@ +redirect(url('/notfound')); + } +} diff --git a/config/auth/app.php b/config/auth/app.php deleted file mode 100644 index b58470cf..00000000 --- a/config/auth/app.php +++ /dev/null @@ -1,13 +0,0 @@ - [ - 'auth_on' => 1, // 权限开关 - 'auth_type' => 1, // 认证方式,1为实时认证;2为登录认证。 - 'auth_group' => 'auth_group', // 用户组数据不带前缀表名 - 'auth_group_access' => 'auth_group_access', // 用户-用户组关系不带前缀表 - 'auth_rule' => 'auth_rule', // 权限规则不带前缀表 - 'auth_user' => 'member', // 用户信息不带前缀表 - ], -]; \ No newline at end of file diff --git a/config/index/app.php b/config/index/app.php index f7413ded..eb6a7e2b 100644 --- a/config/index/app.php +++ b/config/index/app.php @@ -5,4 +5,13 @@ return [ 'chengji' => [ 'version' => '1.0', ], + // Auth权限验证公共配置 + 'auth' => [ + 'auth_on' => 1, // 权限开关 + 'auth_type' => 1, // 认证方式,1为实时认证;2为登录认证。 + 'auth_group' => 'auth_group', // 用户组数据不带前缀表名 + 'auth_group_access' => 'auth_group_access', // 用户-用户组关系不带前缀表 + 'auth_rule' => 'auth_rule', // 权限规则不带前缀表 + 'auth_user' => 'member', // 用户信息不带前缀表 + ], ]; \ No newline at end of file diff --git a/database/migrations/20181012140355_member.php b/database/migrations/20181012140355_member.php new file mode 100644 index 00000000..bd7c259f --- /dev/null +++ b/database/migrations/20181012140355_member.php @@ -0,0 +1,50 @@ +table('member'); + + // 添加当前表字段 + $table + ->addColumn('xingming','string',['limit'=>15,'null'=>false,'comment'=>'用户姓名']) + ->addColumn('xingbie','boolean',['limit'=>1,'default'=>'2','null'=>false,'comment'=>'0=女,1=男,2=未知']) + ->addColumn('shengri','integer',['limit'=>11,'null'=>true,'comment'=>'出生日期']) + ->addColumn('username','string',['limit'=>18,'null'=>false,'comment'=>'用户帐号']) + ->addColumn('password','string',['limit'=>128,'null'=>false,'comment'=>'登录密码']) + ->addColumn('denglucishu','integer',['limit'=>5,'default'=>0,'null'=>false,'comment'=>'登录次数']) + ->addColumn('ip','string',['limit'=>55,'default'=>'127.0.0.1','null'=>false,'comment'=>'登录IP']) + ->addColumn('lasttime','integer',['limit'=>11,'null'=>false,'comment'=>'最后登录时间']) + ->addColumn('status','boolean',['limit'=>1,'default'=>'1','null'=>false,'comment'=>'0=禁用,1=正常']) + ->addColumn('create_time','integer',['limit'=>11,'default'=>'1539158918','null'=>false,'comment'=>'创建时间']) + ->addColumn('update_time','integer',['limit'=>11,'default'=>'1539158918','null'=>false,'comment'=>'更新时间']) + ->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间']) + ->create(); + } +} diff --git a/route/error.php b/route/error.php new file mode 100644 index 00000000..8823b061 --- /dev/null +++ b/route/error.php @@ -0,0 +1,14 @@ + +// +---------------------------------------------------------------------- + +// 错误页面 +// 找不到操作提示 +Route::rule('notfound','error/index/index'); diff --git a/vendor/5ini99/think-auth/src/Auth.php b/vendor/5ini99/think-auth/src/Auth.php index ab31e083..5377b6db 100644 --- a/vendor/5ini99/think-auth/src/Auth.php +++ b/vendor/5ini99/think-auth/src/Auth.php @@ -11,9 +11,9 @@ namespace think\auth; use think\Db; -use think\Config; -use think\Session; -use think\Request; +use think\facade\Config; +use think\facade\Session; +use think\facade\Request; use think\Loader; /** @@ -101,11 +101,11 @@ class Auth public function __construct() { //可设置配置项 auth, 此配置项为数组。 - // if ($auth = Config::get('auth')) { - // $this->config = array_merge($this->config, $auth); - // } - // // 初始化request - // $this->request = Request::instance(); + if ($auth = Config::get('auth')) { + $this->config = array_merge($this->config, $auth); + } + // 初始化request + $this->request = Request::instance(); } /**