[游戏管理]36字花字典-来自游戏配置扩展

This commit is contained in:
2026-04-15 17:46:30 +08:00
parent 569f9e7749
commit 518642ddb0
6 changed files with 272 additions and 2 deletions

View File

@@ -16,6 +16,19 @@ use Webman\Http\Request as WebmanRequest;
class ZiHuaDictionary extends Backend
{
protected bool $modelValidate = false;
protected array $noNeedPermission = ['index', 'save'];
private function hasNodePermission(WebmanRequest $request, string $action): bool
{
if (!$this->auth) {
return false;
}
$controllerPath = get_controller_path($request);
if (!$controllerPath) {
return false;
}
return $this->auth->check($controllerPath . '/' . $action);
}
protected function initController(WebmanRequest $request): ?Response
{
@@ -31,6 +44,9 @@ class ZiHuaDictionary extends Backend
if ($response !== null) {
return $response;
}
if (!$this->hasNodePermission($request, 'index')) {
return $this->error(__('You have no permission'), [], 401);
}
if ($request->method() !== 'GET') {
return $this->error(__('Parameter error'));
}
@@ -51,6 +67,9 @@ class ZiHuaDictionary extends Backend
if ($response !== null) {
return $response;
}
if (!$this->hasNodePermission($request, 'save')) {
return $this->error(__('You have no permission'), [], 401);
}
if ($request->method() !== 'POST') {
return $this->error(__('Parameter error'));
}