更新功能
This commit is contained in:
@@ -8,17 +8,73 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Services\Auth\UsersService;
|
||||
use App\Services\Auth\DepartmentService;
|
||||
use App\Http\Controllers\Base;
|
||||
use App\Support\Tree;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class Department extends Base{
|
||||
|
||||
/**
|
||||
* @title 部门数据
|
||||
*/
|
||||
public function index(){
|
||||
/**
|
||||
* @title 部门数据
|
||||
*/
|
||||
public function index(DepartmentService $service){
|
||||
$data = $service->getDepartmentList(request());
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
$sortData = Arr::keyBy($data, 'partent_id');
|
||||
|
||||
$this->data['data'] = (new Tree())->listToTree($data->toArray(), 'id', 'parent_id', 'children');
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 添加部门
|
||||
*
|
||||
* @param DepartmentService $service
|
||||
* @return void
|
||||
*/
|
||||
public function add(DepartmentService $service){
|
||||
try {
|
||||
$service->createDepartment(request());
|
||||
$this->data['message'] = '添加成功!';
|
||||
} catch (\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 修改部门
|
||||
*
|
||||
* @param DepartmentService $service
|
||||
* @return void
|
||||
*/
|
||||
public function edit(DepartmentService $service){
|
||||
try {
|
||||
$service->updateDepartment(request());
|
||||
$this->data['message'] = '修改成功!';
|
||||
} catch (\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 删除部门
|
||||
*
|
||||
* @param DepartmentService $service
|
||||
* @return void
|
||||
*/
|
||||
public function delete(DepartmentService $service){
|
||||
try {
|
||||
$service->deleteDepartment(request());
|
||||
$this->data['message'] = '删除成功!';
|
||||
} catch (\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
|
||||
27
backend/app/Http/Controllers/Auth/Log.php
Normal file
27
backend/app/Http/Controllers/Auth/Log.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?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\Http\Controllers\Base;
|
||||
use App\Services\Auth\UsersLogService;
|
||||
|
||||
class Log extends Base{
|
||||
|
||||
/**
|
||||
* @title 日志列表
|
||||
*
|
||||
* @param UsersLogService $service
|
||||
* @return void
|
||||
*/
|
||||
public function index(UsersLogService $service){
|
||||
$this->data['data'] = $service->getUserLogList(request());
|
||||
$this->data['code'] = 1;
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -5,5 +5,5 @@ use Illuminate\Routing\Controller;
|
||||
|
||||
class Base extends Controller{
|
||||
|
||||
public $data = ['code' => 0, 'data' => '', 'message' => ''];
|
||||
public $data = ['code' => 1, 'data' => '', 'message' => ''];
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class Index extends Base{
|
||||
}
|
||||
|
||||
public function log(UsersLogService $service){
|
||||
$this->data['data'] = $service->getUserLogList(request());
|
||||
$this->data['data'] = $service->getUserLogList(request());
|
||||
$this->data['code'] = 1;
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?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\System;
|
||||
|
||||
use App\Http\Controllers\Base;
|
||||
|
||||
class Setting extends Base{
|
||||
|
||||
/**
|
||||
* @title 设置配置表单
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function index(){
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user