diff --git a/app/admin/controller/Index.php b/app/admin/controller/Index.php index 5c2ae7b9..6be698cd 100755 --- a/app/admin/controller/Index.php +++ b/app/admin/controller/Index.php @@ -110,6 +110,7 @@ class Index extends AdminBase ,'zhuanye' ,'worktime' ,'tuixiu' + ,'guoqi' => \app\facade\Tools::mima_guoqi() ,'beizhu' ], 'POST'); @@ -274,8 +275,13 @@ class Index extends AdminBase $md5 = new APR1_MD5(); $password = $md5->hash('123456'); + $data = [ + 'password' => $password + ,'guoqi' => \app\facade\Tools::mima_guoqi() + ]; + // 查询用户信息 - $data = AD::where('id', $id)->update(['password' => $password]); + $data = AD::where('id', $id)->update($data); // 根据更新结果设置返回提示信息 $data ? $data = ['msg' => '密码已经重置为:
123456', 'val' => 1] : $data = ['msg' => '数据处理错误', 'val' => 0]; diff --git a/app/admin/model/Admin.php b/app/admin/model/Admin.php index cb1a07b4..6f6f3eb2 100755 --- a/app/admin/model/Admin.php +++ b/app/admin/model/Admin.php @@ -34,6 +34,7 @@ class Admin extends BaseModel ,'lasttime' => 'int' ,'thistime' => 'int' ,'status' => 'tinyint' + ,'guoqi' => 'int' ,'create_time' => 'int' ,'update_time' => 'int' ,'delete_time' => 'int' @@ -189,8 +190,9 @@ class Admin extends BaseModel // 整理表格数据 array_splice($arr, 0, 4); # 删除标题行 + // 获取帐号禁用时间 + $jinyong = \app\facade\Tools::mima_guoqi(); // 组合需要保存的数据 - $i = 0; $teacherlist = array(); $validate = new \app\admin\validate\Admin; $err = ['导入失败原因如下:']; @@ -224,6 +226,7 @@ class Admin extends BaseModel $teacherInfo[$i]['beizhu'] = $value[12]; $teacherInfo[$i]['lasttime'] = time(); $teacherInfo[$i]['thistime'] = time(); + $teacherInfo[$i]['guoqi'] = $jinyong; // 验证数据 $result = $validate->scene('admincreateall')->check($teacherInfo[$i]); $msg = $validate->getError(); diff --git a/app/student/controller/Index.php b/app/student/controller/Index.php index ff11e73a..b80229e5 100755 --- a/app/student/controller/Index.php +++ b/app/student/controller/Index.php @@ -187,6 +187,7 @@ class Index extends AdminBase ,'quanpin' ,'shoupin' ,'xuehao' + ,'guoqi' => \app\facade\Tools::mima_guoqi() ], 'POST'); // 验证表单数据 @@ -647,8 +648,13 @@ class Index extends AdminBase $md5 = new \WhiteHat101\Crypt\APR1_MD5; $password = $md5->hash('123456'); + $data = [ + 'password' => $password + ,'guoqi' => \app\facade\Tools::mima_guoqi() + ]; + // 查询用户信息 - $data = STU::where('id', $id)->update(['password' => $password]); + $data = STU::where('id', $id)->update($data); // 根据更新结果设置返回提示信息 $data ? $data = ['msg' => '密码已经重置为:
123456', 'val' => 1] : $data = ['msg' => '数据处理错误', 'val' => 0]; diff --git a/app/student/model/Student.php b/app/student/model/Student.php index 1ab7c02b..cb343925 100755 --- a/app/student/model/Student.php +++ b/app/student/model/Student.php @@ -27,10 +27,12 @@ class Student extends BaseModel ,'quanpin' => 'varchar' ,'shoupin' => 'varchar' ,'xuehao' => 'varchar' + ,'guoqi' => 'int' + ,'status' => 'tinyint' ,'create_time' => 'int' ,'update_time' => 'int' ,'delete_time' => 'int' - ,'status' => 'tinyint' + ]; @@ -521,6 +523,7 @@ class Student extends BaseModel ,'xuehao' => $value[$add_k][2] ,'quanpin' => trim(strtolower(str_replace(' ', '', $quanpin))) ,'shoupin' => trim(strtolower(str_replace(' ', '', $shoupin))) + ,'guoqi' => \app\facade\Tools::mima_guoqi() ]; $result = $validate->scene('create')->check($list[$add_k]); diff --git a/app/system/model/SystemBase.php b/app/system/model/SystemBase.php index 3207cc90..c8d20643 100755 --- a/app/system/model/SystemBase.php +++ b/app/system/model/SystemBase.php @@ -32,10 +32,11 @@ class SystemBase extends BaseModel // 查询系统信息 static function sysInfo() { - $info = self::order(['id' => 'desc']) + $info = self::where('id', 1) ->field('id, keywords, description, thinks, danwei, gradelist, classmax, classalias, xuenian, studefen, sys_title') - ->order(['id' => 'desc']) + ->cache(true) ->find(); + return $info; } diff --git a/app/tools/controller/Index.php b/app/tools/controller/Index.php index 96be88ec..87e821a0 100755 --- a/app/tools/controller/Index.php +++ b/app/tools/controller/Index.php @@ -331,4 +331,14 @@ class Index extends BaseController } return $data; } + + + public function mima_guoqi() { + // 计算帐号禁用时间 + $jyshijian = config('shangma.mimaguoqi'); + $now = date("Y-m-d", time()); + $jinyong = strtotime("$now+".$jyshijian." day"); + return $jinyong; + } + } diff --git a/database/migrations/20181010035225_system_base.php b/database/migrations/20181010035225_system_base.php index d287a657..ba0ddf94 100755 --- a/database/migrations/20181010035225_system_base.php +++ b/database/migrations/20181010035225_system_base.php @@ -47,6 +47,8 @@ class SystemBase extends Migrator ->addColumn('teacherrongyu','boolean',['limit'=>1,'default'=>0,'null'=>false,'comment'=>'教师查看个人荣誉']) ->addColumn('teacherketi','boolean',['limit'=>1,'default'=>0,'null'=>false,'comment'=>'教师查看个人课题']) ->addColumn('studefen','boolean',['limit'=>1,'default'=>0,'null'=>false,'comment'=>'是否允许学生查看分数']) + ->addColumn('teacher_guoqi','integer',['limit'=>11,'null'=>false,'default'=>1539158918,'comment'=>'教师帐号过期时间']) + ->addColumn('student_guoqi','integer',['limit'=>11,'null'=>false,'default'=>1539158918,'comment'=>'学生帐号过期时间']) ->addColumn('create_time','integer',['limit'=>11,'null'=>false,'default'=>1539158918,'comment'=>'创建时间']) ->addColumn('update_time','integer',['limit'=>11,'null'=>false,'default'=>1539158918,'comment'=>'更新时间']) ->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间']) diff --git a/database/migrations/20181012140355_member.php b/database/migrations/20181012140355_member.php index 0c275842..4c39e451 100755 --- a/database/migrations/20181012140355_member.php +++ b/database/migrations/20181012140355_member.php @@ -57,6 +57,7 @@ class Member extends Migrator ->addColumn('lasttime','integer',['limit'=>11,'default'=>'0','null'=>false,'comment'=>'最后登录时间']) ->addColumn('thistime','integer',['limit'=>11,'default'=>'0','null'=>false,'comment'=>'本次登录时间']) ->addColumn('status','boolean',['limit'=>1,'default'=>'1','null'=>false,'comment'=>'0=禁用,1=正常']) + ->addColumn('guoqi','integer',['limit'=>11,'null'=>false,'default'=>1539158918,'comment'=>'帐号过期时间']) ->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'=>'删除时间']) diff --git a/database/migrations/20181102003411_student.php b/database/migrations/20181102003411_student.php index 32e32fb7..d168d501 100755 --- a/database/migrations/20181102003411_student.php +++ b/database/migrations/20181102003411_student.php @@ -48,6 +48,7 @@ class Student extends Migrator ->addColumn('quanpin','string',['limit'=>30,'default'=>'a','null'=>false,'comment'=>'全拼']) ->addColumn('shoupin','string',['limit'=>5,'default'=>'a','null'=>false,'comment'=>'简拼']) ->addColumn('xuehao','string',['limit'=>25,'null'=>true,'comment'=>'自定义考号']) + ->addColumn('guoqi','integer',['limit'=>11,'null'=>false,'default'=>1539158918,'comment'=>'学生帐号过期时间']) ->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'=>'删除时间']) diff --git a/database/migrations/20220102124845_edit_admin_student.php b/database/migrations/20220102124845_edit_admin_student.php new file mode 100644 index 00000000..b7d6fa75 --- /dev/null +++ b/database/migrations/20220102124845_edit_admin_student.php @@ -0,0 +1,51 @@ +table('admin'); + $column = $table->hasColumn('guoqi'); + if (!$column) { + $table + ->addColumn('guoqi','integer',['limit'=>11,'null'=>false,'default'=>1539158918,'comment'=>'帐号过期时间']) + ->update(); + } + + // 学生帐号过期时间 + $table = $this->table('student'); + $column = $table->hasColumn('guoqi'); + if (!$column) { + $table + ->addColumn('guoqi','integer',['limit'=>11,'null'=>false,'default'=>1539158918,'comment'=>'帐号过期时间']) + ->update(); + } + + + } +} diff --git a/database/seeds/Admin.php b/database/seeds/Admin.php index fb7d4ee2..7d0f4b6d 100755 --- a/database/seeds/Admin.php +++ b/database/seeds/Admin.php @@ -14,6 +14,11 @@ class Admin extends Seeder */ public function run() { + // 计算帐号禁用时间 + $jyshijian = config('shangma.mimaguoqi'); + $now = date("Y-m-d", time()); + $jinyong = strtotime("$now+".$jyshijian." day"); + // 定义表的名称 $rows = [ [ @@ -33,6 +38,7 @@ class Admin extends Seeder "tuixiu" => 0, "lasttime" => time(), "thistime" => time(), + "guoqi" => $jinyong, "create_time" => time(), "update_time" => time() ], @@ -53,6 +59,7 @@ class Admin extends Seeder "tuixiu" => 0, "lasttime" => time(), "thistime" => time(), + "guoqi" => $jinyong, "create_time" => time(), "update_time" => time() ], diff --git a/database/seeds/Student.php b/database/seeds/Student.php index 019a8be7..faad6d58 100644 --- a/database/seeds/Student.php +++ b/database/seeds/Student.php @@ -23,6 +23,7 @@ class Student extends Seeder ,'shenfenzhenghao' => '210202201210018223' ,'banji_id' => 1 ,'shoupin' => 'yn' + ,'guoqi' => 33198038411 ,'create_time' => time() ,'update_time' => time() ] @@ -33,6 +34,7 @@ class Student extends Seeder ,'shenfenzhenghao' => '210202201210018214' ,'banji_id' => 1 ,'shoupin' => 'lbl' + ,'guoqi' => 33198038411 ,'create_time' => time() ,'update_time' => time() ] @@ -43,6 +45,7 @@ class Student extends Seeder ,'shenfenzhenghao' => '210202201210018255' ,'banji_id' => 1 ,'shoupin' => 'zyz' + ,'guoqi' => 33198038411 ,'create_time' => time() ,'update_time' => time() ] @@ -53,6 +56,7 @@ class Student extends Seeder ,'shenfenzhenghao' => '210202201210018236' ,'banji_id' => 1 ,'shoupin' => 'wxt' + ,'guoqi' => 33198038411 ,'create_time' => time() ,'update_time' => time() ] @@ -63,6 +67,7 @@ class Student extends Seeder ,'shenfenzhenghao' => '210202201210018227' ,'banji_id' => 1 ,'shoupin' => 'zyf' + ,'guoqi' => 33198038411 ,'create_time' => time() ,'update_time' => time() ] @@ -73,6 +78,7 @@ class Student extends Seeder ,'shenfenzhenghao' => '210202201210018218' ,'banji_id' => 1 ,'shoupin' => 'cly' + ,'guoqi' => 33198038411 ,'create_time' => time() ,'update_time' => time() ]