<?php

namespace app\controller\admin\system;

use app\BaseController;
use app\entity\SysConfig;
use app\service\CurdService;
use think\response\Json;

class ConfigController extends BaseController
{
    public function list(): Json
    {
        $model = SysConfig::with([])
            ->withSearch(['group'], [
                'group'=> $this->request->get('group/s','')
            ]);

        $paginate = CurdService::getPaginate($this->request, $model);

        return $this->writeSuccess('success', $paginate);
    }

    public function data(string $name)
    {
        $config = SysConfig::where('name', $name)->findOrEmpty();

        return $this->writeSuccess('success', $config->toArray());
    }
}