基础功能、图片上传
This commit is contained in:
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)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user