<?php
// +----------------------------------------------------------------------
// | onezan-admin 快速开发的管理平台
// +----------------------------------------------------------------------
// | 官方网址：https://www.onezan.cn
// +----------------------------------------------------------------------
// | onezan团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: 543885307@qq.com
// +----------------------------------------------------------------------
declare(strict_types=1);

namespace {$nsCtrl};

use {$nsSvc};
use {$nsVal};
use {$nsDVal};
use app\adminapi\controller\BaseAdminController;
use think\Request;

class {$cls} extends BaseAdminController
{
    public function list(Request \$request)
    {
        \$params = \$request->get();
        \$this->validate(\$params, {$cls}Validator::class . '.list');

        return json(\$this->app->make({$cls}Service::class)->list(\$request));
    }


    public function detail(\$id, Request \$request)
    {
        \$this->validate(['id' => \$id], {$cls}Validator::class . '.detail');

        return json(\$this->app->make({$cls}Service::class)->detail((int)\$id, \$request));
    }


    public function save(Request \$request)
    {
        \$params = \$request->post();
        \$this->validate(\$params, {$cls}Validator::class . '.save');
        \$this->validateDomain(\$this->app->make({$cls}DomainValidator::class), \$params, 'save');

        return json(\$this->app->make({$cls}Service::class)->save(\$request));
    }


    public function delete(Request \$request)
    {
        \$params = \$request->post();
        \$this->validate(\$params, {$cls}Validator::class . '.delete');
        \$this->validateDomain(\$this->app->make({$cls}DomainValidator::class), \$params, 'delete');

        return json(\$this->app->make({$cls}Service::class)->delete(\$request));
    }
}


