diff --git a/README.md b/README.md index 8dc90eb..6dcbb52 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ - 服务器信息(已完成) - 系统配置(已完成) - 管理员管理 -- 账户管理 +- 账户管理(已完成) - 用户管理 - 权限管理 - 文件管理 diff --git a/app/admin/controller/Admin.php b/app/admin/controller/Admin.php new file mode 100644 index 0000000..a8534e0 --- /dev/null +++ b/app/admin/controller/Admin.php @@ -0,0 +1,72 @@ +adminInfo['id']); + + View::assign('admin',$model_admin); + + return View::fetch(); + } + + public function password() + { + return View::fetch(); + } + + public function passwordUpdate() + { + + $post_data = $this->request->post(); + + if(empty($post_data['new_password'])){ + return $this->error('新密码不能为空'); + } + $model_admin = AppAdmin::find($this->adminInfo['id']); + + if(md5($post_data['original_password'].$model_admin->getData('salt')) != $model_admin->getData('password')){ + return $this->error('原密码错误'); + } + + if($post_data['new_password'] != $post_data['check_password']){ + return $this->error('新密码与确认密码不一致'); + } + + + $model_admin->password = md5($post_data['new_password'].$model_admin->getData('salt')); + + $model_admin->save(); + + return $this->success('修改成功'); + + } + + public function update() + { + $post_data = $this->request->post(); + $model_admin = AppAdmin::find($this->adminInfo['id']); + + if($model_admin->getData('avatar') != $post_data['avatar']){ + UploadFiles::destroy(['save_name'=>$model_admin->getData('avatar')]); + UploadFiles::update(['used_time'=>time()],['save_name'=>$post_data['avatar']]); + } + + + $model_admin->data($post_data); + + $model_admin->save(); + + return $this->success('保存成功','Admin/edit'); + } +} diff --git a/app/admin/controller/Common.php b/app/admin/controller/Common.php index eeb20b6..d88b893 100644 --- a/app/admin/controller/Common.php +++ b/app/admin/controller/Common.php @@ -5,6 +5,7 @@ use app\BaseController; use think\facade\Session; use app\model\Admin; use think\exception\HttpResponseException; +use think\facade\View; class Common extends BaseController{ @@ -30,5 +31,7 @@ class Common extends BaseController{ } } + View::assign('admin',$this->adminInfo); + } } \ No newline at end of file diff --git a/app/admin/controller/Login.php b/app/admin/controller/Login.php index 50799bd..7d55082 100644 --- a/app/admin/controller/Login.php +++ b/app/admin/controller/Login.php @@ -48,4 +48,11 @@ class Login extends Common return json_message(); } + + public function logout() + { + Session::clear(); + + $this->success('已经安全退出','Login/Index'); + } } diff --git a/app/common.php b/app/common.php index a19a7d8..cc9d351 100644 --- a/app/common.php +++ b/app/common.php @@ -33,15 +33,20 @@ function json_message($data = [],$code = 0,$msg = '') ]); } -function get_system_config($name,$default = '') +function get_system_config($name = '',$default = '') { + $list = Cache::get('system_config'); if(empty($list)){ $list = SystemConfig::column('value','name'); } + if($name === ''){ + return $list; + } + if(isset($list[$name])){ return $list[$name]; } diff --git a/app/model/Admin.php b/app/model/Admin.php index 3910a40..faadbac 100644 --- a/app/model/Admin.php +++ b/app/model/Admin.php @@ -10,4 +10,9 @@ use think\Model; class Admin extends Model { // + + public function getAvatarAttr($value) + { + return \get_source_link($value); + } } diff --git a/database/seeds/InitSystemConfig.php b/database/seeds/InitSystemConfig.php new file mode 100644 index 0000000..8eda86f --- /dev/null +++ b/database/seeds/InitSystemConfig.php @@ -0,0 +1,42 @@ +'奥宏后台管理小模板' + ]; + + $list = get_system_config(); + + foreach ($data as $key => $value) { + + if(isset($list[$key])){ + SystemConfig::where('name',$key)->update(['value'=>$value]); + }else{ + $model_sysconfig = new SystemConfig(); + $model_sysconfig->name = $key; + $model_sysconfig->value = $value; + $model_sysconfig->save(); + } + + $list[$key] = $value; + } + + Cache::set('system_config',$list); + } +} \ No newline at end of file diff --git a/view/admin/admin/edit.html b/view/admin/admin/edit.html new file mode 100644 index 0000000..bd0500b --- /dev/null +++ b/view/admin/admin/edit.html @@ -0,0 +1,100 @@ + + +
+ + + +