diff --git a/app/admin/controller/Admin.php b/app/admin/controller/Admin.php index 91ff79e..db935eb 100644 --- a/app/admin/controller/Admin.php +++ b/app/admin/controller/Admin.php @@ -9,12 +9,19 @@ use app\UploadFiles as AppUploadFiles; use think\facade\View; use think\helper\Str; +/** + * 管理员账号管理 + */ class Admin extends Common { + /** + * 当前登录的管理员编辑账户 + * + * @return void + */ public function edit() { - $model_admin = AppAdmin::find($this->adminInfo['id']); View::assign('admin',$model_admin); @@ -22,11 +29,21 @@ class Admin extends Common return View::fetch(); } + /** + * 当前登录的管理员修改密码 + * + * @return void + */ public function password() { return View::fetch(); } + /** + * 当前登陆的管理员保存修改密码 + * + * @return void + */ public function passwordUpdate() { @@ -54,6 +71,11 @@ class Admin extends Common } + /** + * 当前登陆的管理员更新账户 + * + * @return void + */ public function update() { $post_data = $this->request->post(); @@ -64,7 +86,6 @@ class Admin extends Common AppUploadFiles::use($post_data['avatar']); } - $model_admin->data($post_data); $model_admin->save(); @@ -72,14 +93,24 @@ class Admin extends Common return $this->success('保存成功','Admin/edit'); } + /** + * 管理员列表 + * + * @return void + */ public function index() { - $admin_list = AppAdmin::where('id','<>',1)->paginate(); + $admin_list = AppAdmin::where('id','<>',1)->order('id desc')->paginate(); View::assign('list',$admin_list); return View::fetch(); } + /** + * 添加管理员账号 + * + * @return void + */ public function create() { @@ -90,6 +121,12 @@ class Admin extends Common return View::fetch(); } + + /** + * 保存添加的管理员账号 + * + * @return void + */ public function save() { $post_data = $this->request->post(); @@ -104,8 +141,7 @@ class Admin extends Common $post_data['password'] = '123456'; } - if($admin_model->getData('avatar') != $post_data['avatar']){ - AppUploadFiles::delete($admin_model->getData('avatar')); + if(!empty($post_data['avatar'])){ AppUploadFiles::use($post_data['avatar']); } @@ -119,6 +155,12 @@ class Admin extends Common } + /** + * 编辑管理员账号 + * + * @param [type] $id + * @return void + */ public function editAccount($id) { $model_admin = AppAdmin::find($id); @@ -128,6 +170,11 @@ class Admin extends Common return View::fetch(); } + /** + * 更新管理员账号 + * + * @return void + */ public function updateAccount() { $post_data = $this->request->post(); @@ -152,6 +199,11 @@ class Admin extends Common } + /** + * 管理员操作日志 + * + * @return void + */ public function adminLog() { @@ -162,6 +214,12 @@ class Admin extends Common return View::fetch(); } + /** + * 删除管理员 + * + * @param [type] $id + * @return void + */ public function delete($id) { AppAdmin::destroy($id); diff --git a/app/admin/controller/File.php b/app/admin/controller/File.php index 6698ecc..5b6c907 100644 --- a/app/admin/controller/File.php +++ b/app/admin/controller/File.php @@ -21,7 +21,7 @@ class File extends Common $type = $this->request->param('type',1); $status = $this->request->param('status',''); - $model_list = UploadFiles::where('type',$type)->order('id desc'); + $model_list = UploadFiles::withTrashed()->where('type',$type)->order('id desc'); if($status != ''){ $model_list->where('status',$status); diff --git a/app/admin/middleware.php b/app/admin/middleware.php index a01674a..7c703c7 100644 --- a/app/admin/middleware.php +++ b/app/admin/middleware.php @@ -1,6 +1,7 @@ addColumn('avatar','string',['limit'=>40,'comment'=>'头像地址']); $table->addColumn('create_time','integer',['limit'=>10,'default'=>0,'comment'=>'添加时间']); $table->addColumn('delete_time','integer',['limit'=>10,'default'=>0,'comment'=>'删除时间']); + $table->addColumn('group_id','integer',['limit'=>10,'default'=>0,'comment'=>'管理员组']); $table->addIndex('account'); $table->addIndex('delete_time'); $table->create(); diff --git a/view/admin/admin/admin_log.html b/view/admin/admin/admin_log.html index ec1a4f7..e9d32d5 100644 --- a/view/admin/admin/admin_log.html +++ b/view/admin/admin/admin_log.html @@ -7,6 +7,11 @@