修改数据迁移、Base、和版本参数获取,增加index控制器初始化
This commit is contained in:
1 parent
7ab5bbdd8b
commit
e70b4b120b
10 files changed
+136
-44
No files matched your search
@@ -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()
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Loaded 3 of 10 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user