基础功能、图片上传
This commit is contained in:
@@ -72,4 +72,18 @@ class AdminController extends BaseController
|
||||
'获取成功'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单列表
|
||||
* @Method GET
|
||||
* @return JsonResponse
|
||||
* @throws Exception
|
||||
*/
|
||||
public function menu(): JsonResponse
|
||||
{
|
||||
return jok(
|
||||
$this->service->menu(),
|
||||
'获取成功'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ class LoginController extends BaseController
|
||||
public function login()
|
||||
{
|
||||
$this->insertField = [
|
||||
'phone', 'password', 'remember'
|
||||
'account', 'password'
|
||||
];
|
||||
$param = $this->checkRequiredFields(request()->post());
|
||||
|
||||
return jok(
|
||||
$this->service->login($param['phone'], $param['password']),
|
||||
$this->service->login($param['account'], $param['password']),
|
||||
'登录成功'
|
||||
);
|
||||
}
|
||||
@@ -54,4 +54,20 @@ class LoginController extends BaseController
|
||||
);
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
return jok(
|
||||
[],
|
||||
'退出成功'
|
||||
);
|
||||
}
|
||||
|
||||
public function codes()
|
||||
{
|
||||
return jok(
|
||||
[],
|
||||
'获取成功'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
35
app/Http/Controllers/Api/MenuController.php
Executable file
35
app/Http/Controllers/Api/MenuController.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\BaseApp\BaseController;
|
||||
use App\Service\MenuService;
|
||||
|
||||
class MenuController extends BaseController
|
||||
{
|
||||
//
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->insertField = [ 'pid', 'title', 'icon', 'path', 'affix_tab', 'keep_alive', 'hide_in_menu', 'sort' ];
|
||||
$this->updateField = [ 'id', 'pid', 'title', 'icon', 'path', 'affix_tab', 'redirect', 'keep_alive', 'hide_in_menu', 'badge_variants', 'sort' ];
|
||||
$this->notRequest = [ 'name', 'badge', 'iframe_src', 'redirect', 'query', 'badge_type', 'badge_variants', 'component' ];
|
||||
$this->service = MenuService::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单树形下拉列表
|
||||
* @Method GET
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
*/
|
||||
public function getTreeOption()
|
||||
{
|
||||
$isSelect = request()->get('is_select', false);
|
||||
return jok(
|
||||
$this->service->getTreeOption($isSelect)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
54
app/Http/Controllers/Api/RoleController.php
Executable file
54
app/Http/Controllers/Api/RoleController.php
Executable file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\BaseApp\BaseController;
|
||||
use App\Service\RoleService;
|
||||
use Exception;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
class RoleController extends BaseController
|
||||
{
|
||||
//
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->insertField = ['name', 'value', 'desc'];
|
||||
$this->updateField = ['id', 'name', 'value', 'desc'];
|
||||
$this->service = RoleService::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色菜单ID
|
||||
* @Method GET
|
||||
* @return JsonResponse
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getMenuIdsByRoleIds(): JsonResponse
|
||||
{
|
||||
$roleId = request()->get('role_id', null);
|
||||
return jok(
|
||||
$this->service->getMenuIdsByRoleIds($roleId)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存角色菜单
|
||||
* @Method POST
|
||||
* @return JsonResponse
|
||||
* @throws Exception
|
||||
*/
|
||||
public function saveRoleMenu(): JsonResponse
|
||||
{
|
||||
$this->insertField = ['role_id', 'menu_id'];
|
||||
$this->checkRequiredFields(request()->post());
|
||||
$roleId = request()->post('role_id');
|
||||
$menuIds = request()->post('menu_id', []);
|
||||
return jok(
|
||||
$this->service->saveRoleMenu($roleId, $menuIds)
|
||||
);
|
||||
}
|
||||
}
|
||||
47
app/Http/Controllers/Api/UploadController.php
Normal file
47
app/Http/Controllers/Api/UploadController.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\BaseApp\BaseController;
|
||||
use App\Service\common\UploadService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class UploadController extends BaseController
|
||||
{
|
||||
//
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->service = UploadService::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片上传
|
||||
* @Method POST
|
||||
* @return JsonResponse
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function image()
|
||||
{
|
||||
$file = request()->file('file');
|
||||
return jok(
|
||||
$this->service->uploadImage($file),
|
||||
'上传成功'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 视频上传
|
||||
* @Method POST
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function video()
|
||||
{
|
||||
$file = request()->file('file');
|
||||
return jok(
|
||||
$this->service->uploadVideo($file),
|
||||
'上传成功'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user