hyperf-view/app/System/Controller/Settings/SystemConfigGroupController...

80 lines
2.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\System\Controller\Settings;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\DeleteMapping;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\PostMapping;
use App\System\Request\SettingConfigGroupRequest;
use App\System\Service\SettingConfigGroupService;
use Builder\Annotation\Auth;
use Builder\Annotation\OperationLog;
use Builder\Annotation\Permission;
use Builder\BaseController;
/**
* 系统配置组控制器
* Class SystemConfigGroupController
* @package App\System\Controller\Settings
*/
#[Controller(prefix: "system/setting/configGroup"), Auth]
class SystemConfigGroupController extends BaseController
{
#[Inject]
protected SettingConfigGroupService $service;
/**
* 获取系统组配置
* @return \Psr\Http\Message\ResponseInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
#[GetMapping("index"), Permission("setting:config, setting:config:index")]
public function index(): \Psr\Http\Message\ResponseInterface
{
return $this->success($this->service->getList());
}
/**
* 保存配置组
* @param SettingConfigGroupRequest $request
* @return \Psr\Http\Message\ResponseInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
#[PostMapping("save"), Permission("setting:config:save"), OperationLog("保存配置组")]
public function save(SettingConfigGroupRequest $request): \Psr\Http\Message\ResponseInterface
{
return $this->service->save($request->validated()) ? $this->success() : $this->error();
}
/**
* 更新配置组
* @param SettingConfigGroupRequest $request
* @return \Psr\Http\Message\ResponseInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
#[PostMapping("update"), Permission("setting:config:update"), OperationLog("更新配置组")]
public function update(SettingConfigGroupRequest $request): \Psr\Http\Message\ResponseInterface
{
return $this->service->update((int) $this->request->input('id'), $request->validated()) ? $this->success() : $this->error();
}
/**
* 删除配置组
* @return \Psr\Http\Message\ResponseInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
#[DeleteMapping("delete"), Permission("setting:config:delete"), OperationLog("删除配置组")]
public function delete(): \Psr\Http\Message\ResponseInterface
{
return $this->service->deleteConfigGroup((int) $this->request->input('id')) ? $this->success() : $this->error();
}
}