From e70b4b120b22074e46c2ecee4cc59651abf2dde9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=B4=E6=8E=8C?= Date: Fri, 12 Oct 2018 15:07:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E3=80=81Base=E3=80=81=E5=92=8C=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=8E=B7=E5=8F=96=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?index=E6=8E=A7=E5=88=B6=E5=99=A8=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/controller/Base.php | 9 -- application/common/model/Base.php | 12 ++- application/index/controller/Index.php | 30 +++++-- application/student/controller/Upload.php | 85 +++++++++++++++++++ application/system/controller/Index.php | 10 --- config/index/app.php | 4 +- .../migrations/20181010035225_system_base.php | 4 +- .../migrations/20181010075304_auth_group.php | 8 +- .../20181010075517_auth_group_access.php | 6 +- .../migrations/20181010075553_auth_rule.php | 12 +-- 10 files changed, 136 insertions(+), 44 deletions(-) create mode 100644 application/student/controller/Upload.php delete mode 100644 application/system/controller/Index.php diff --git a/application/common/controller/Base.php b/application/common/controller/Base.php index b95ba892..885f908e 100644 --- a/application/common/controller/Base.php +++ b/application/common/controller/Base.php @@ -6,19 +6,10 @@ namespace app\common\controller; use think\Controller; // 引用权限验证类 use think\auth\Auth; -// 引用软删除类 -use think\model\concern\SoftDelete; - class Base extends Controller { - // 开启全局自动时间戳 - protected $autoWriteTimestamp = true; - - // 开启软删除 - use SoftDelete; - protected $deleteTime = 'delete_time'; // 当前类初始化 protected function initialize() diff --git a/application/common/model/Base.php b/application/common/model/Base.php index 1bbab156..5a318df6 100644 --- a/application/common/model/Base.php +++ b/application/common/model/Base.php @@ -2,10 +2,18 @@ namespace app\common\model; +// 引用模型类 use think\Model; +// 引用软删除类 +use think\model\concern\SoftDelete; class Base extends Model { - //开启自动时间戳 - protected $autoWriteTimestamp = false; + + // 开启全局自动时间戳 + protected $autoWriteTimestamp = true; + + // 开启软删除 + use SoftDelete; + protected $deleteTime = 'delete_time'; } diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php index 75f29cf6..2dd6e368 100644 --- a/application/index/controller/Index.php +++ b/application/index/controller/Index.php @@ -13,6 +13,26 @@ class Index extends Base //关闭自动时间 protected $autoWriteTimestamp = false; + // 初始化 + protected function initialize() + { + //实例化数据模型 + $sysbasemod = new sysbasemod(); + + // 查询数据 + $list = $sysbasemod + ->where('id','>',0) + ->find(); + + if( $list == null ) + { + $sysbasemod->title = '学生成绩统计系统'; + $sysbasemod->save(); + } + + } + + // 主页 public function index() { @@ -23,18 +43,15 @@ class Index extends Base $list = $sysbasemod ->order(['id'=>'desc']) ->field('title,keywords,description') - ->limit(1) ->find(); // 获取版本号 - $list->version = config('version'); + $list->version = config('app.chengji.version'); // 模版赋值 $this->assign('list',$list); - // $url = url('welcome'); - // halt($url); - + // 渲染输出 return $this->fetch(); } @@ -48,11 +65,10 @@ class Index extends Base $list = $sysbasemod ->order(['id'=>'desc']) ->field('title,copyright,thinks') - ->limit(1) ->find(); // 获取版本号 - $list->version = config('version'); + $list->version = config('app.chengji.version'); // 模版赋值 $this->assign('list',$list); diff --git a/application/student/controller/Upload.php b/application/student/controller/Upload.php new file mode 100644 index 00000000..7760bd41 --- /dev/null +++ b/application/student/controller/Upload.php @@ -0,0 +1,85 @@ +*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }

:)

ThinkPHP V5.1
12载初心不改(2006-2018) - 你值得信赖的PHP框架

'; - } -} diff --git a/config/index/app.php b/config/index/app.php index b6cdce37..f7413ded 100644 --- a/config/index/app.php +++ b/config/index/app.php @@ -2,5 +2,7 @@ //配置文件 return [ // 应用名称 - 'version' => '1.0', + 'chengji' => [ + 'version' => '1.0', + ], ]; \ No newline at end of file diff --git a/database/migrations/20181010035225_system_base.php b/database/migrations/20181010035225_system_base.php index db5f76f9..c1397e78 100644 --- a/database/migrations/20181010035225_system_base.php +++ b/database/migrations/20181010035225_system_base.php @@ -36,11 +36,11 @@ class SystemBase extends Migrator ->addColumn('create_time','integer',['limit'=>11,'default'=>'1539158918','null'=>false,'comment'=>'创建时间']) ->addColumn('update_time','integer',['limit'=>11,'default'=>'1539158918','null'=>false,'comment'=>'更新时间']) ->addColumn('title','string',['limit'=>50,'default'=>'学生成绩统计系统','null'=>false,'comment'=>'网站名称']) - ->addColumn('keywords','string',['limit'=>100,'default'=>'成绩统计,成绩管理','null'=>true,'comment'=>'关键词']) + ->addColumn('keywords','string',['limit'=>100,'default'=>'成绩统计,成绩管理','null'=>false,'comment'=>'关键词']) ->addColumn('description','string',['limit'=>100,'default'=>'这是我们自己开发的系统','null'=>false,'comment'=>'网站说明']) ->addColumn('copyright','string',['limit'=>15,'default'=>'2018-'.date('Y').'-'.date('y'),'null'=>false,'comment'=>'版权']) ->addColumn('thinks','string',['limit'=>200,'default'=>'H-ui前端框架、ThinkPhp框架','null'=>false,'comment'=>'网站感谢']) - // ->addIndex(array('username'), array('unique' => true)) + ->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间']) ->create(); } } diff --git a/database/migrations/20181010075304_auth_group.php b/database/migrations/20181010075304_auth_group.php index 0d70cb5e..6328fcef 100644 --- a/database/migrations/20181010075304_auth_group.php +++ b/database/migrations/20181010075304_auth_group.php @@ -33,10 +33,10 @@ class AuthGroup extends Migrator // 添加当前表字段 $table - ->addColumn('title','string',['limit'=>100,'default'=>'','null'=>true,'comment'=>'用户组中文名称']) - ->addColumn('rules','string',['limit'=>300,'default'=>'','null'=>true,'comment'=>'用户组拥有的规则id']) - ->addColumn('status','boolean',['default'=>true,'null'=>true,'comment'=>'用户组状态']) - ->addColumn('delete_time','integer',['limit'=>11,'null'=>false,'comment'=>'删除时间']) + ->addColumn('title','string',['limit'=>100,'default'=>'','null'=>false,'comment'=>'用户组中文名称']) + ->addColumn('rules','string',['limit'=>300,'default'=>'','null'=>false,'comment'=>'用户组拥有的规则id']) + ->addColumn('status','boolean',['default'=>true,'null'=>false,'comment'=>'用户组状态']) + ->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间']) ->create(); } } diff --git a/database/migrations/20181010075517_auth_group_access.php b/database/migrations/20181010075517_auth_group_access.php index 913e9264..d0022844 100644 --- a/database/migrations/20181010075517_auth_group_access.php +++ b/database/migrations/20181010075517_auth_group_access.php @@ -33,9 +33,9 @@ class AuthGroupAccess extends Migrator // 添加当前表字段 $table - ->addColumn('uid','integer',['limit'=>11,'default'=>'','null'=>true,'comment'=>'用户id']) - ->addColumn('group_id','integer',['limit'=>11,'default'=>'','null'=>true,'comment'=>'用户组id']) - ->addColumn('delete_time','integer',['limit'=>11,'null'=>false,'comment'=>'删除时间']) + ->addColumn('uid','integer',['limit'=>11,'null'=>false,'comment'=>'用户id']) + ->addColumn('group_id','integer',['limit'=>11,'null'=>false,'comment'=>'用户组id']) + ->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间']) ->create(); } } diff --git a/database/migrations/20181010075553_auth_rule.php b/database/migrations/20181010075553_auth_rule.php index c8368486..eef53c40 100644 --- a/database/migrations/20181010075553_auth_rule.php +++ b/database/migrations/20181010075553_auth_rule.php @@ -33,12 +33,12 @@ class AuthRule extends Migrator // 添加当前表字段 $table - ->addColumn('name','string',['limit'=>80,'default'=>'','null'=>true,'comment'=>'规则唯一标识']) - ->addColumn('title','string',['limit'=>80,'default'=>'','null'=>true,'comment'=>'规则中文名']) - ->addColumn('type','boolean',['default'=>false,'null'=>false,'comment'=>'是否是菜单']) - ->addColumn('status','boolean',['default'=>true,'null'=>true,'comment'=>'规则状态']) - ->addColumn('condition','string',['limit'=>100,'default'=>'','null'=>false,'comment'=>'规则表达式']) - ->addColumn('delete_time','integer',['limit'=>11,'default'=>'','null'=>false,'comment'=>'删除时间']) + ->addColumn('name','string',['limit'=>80,'default'=>'','null'=>false,'comment'=>'规则唯一标识']) + ->addColumn('title','string',['limit'=>80,'default'=>'','null'=>false,'comment'=>'规则中文名']) + ->addColumn('type','boolean',['default'=>false,'null'=>true,'comment'=>'是否是菜单']) + ->addColumn('status','boolean',['default'=>true,'null'=>false,'comment'=>'规则状态']) + ->addColumn('condition','string',['limit'=>100,'default'=>'','null'=>true,'comment'=>'规则表达式']) + ->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间']) ->addIndex(array('name'), array('unique' => true)) ->create(); }