更新功能
This commit is contained in:
83
backend/app/Http/Controllers/Auth/Role.php
Normal file
83
backend/app/Http/Controllers/Auth/Role.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Services\Auth\RoleService;
|
||||
use App\Http\Controllers\Base;
|
||||
|
||||
class Role extends Base{
|
||||
|
||||
/**
|
||||
* @title 角色数据
|
||||
*/
|
||||
public function index(RoleService $service){
|
||||
$tree = $service->getRolesList(request(), true);
|
||||
|
||||
$this->data['code'] = 1;
|
||||
$this->data['data'] = $tree;
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 角色修改
|
||||
* @time 2019年12月11日
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return Array
|
||||
*/
|
||||
public function edit(RoleService $service) {
|
||||
try {
|
||||
$service->updateRole(request());
|
||||
$this->data['code'] = 1;
|
||||
} catch (\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 角色授权
|
||||
* @time 2019年12月11日
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return Array
|
||||
*/
|
||||
public function auth(RoleService $service) {
|
||||
$role_id = request()->input('role_id', '');
|
||||
$auth = request()->input('auth', '');
|
||||
try {
|
||||
$service->updateRolePermission($role_id, $auth);
|
||||
$service->updateRoleAuth(request());
|
||||
$this->data['code'] = 1;
|
||||
} catch (\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 删除角色
|
||||
*
|
||||
* @time 2019年12月11日
|
||||
* @param $id
|
||||
* @return Json
|
||||
*/
|
||||
public function delete(RoleService $service){
|
||||
try {
|
||||
$service->deleteRole(request());
|
||||
$this->data['code'] = 1;
|
||||
} catch (\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user