<?php

namespace app\api\server;

use think\Db;
use think\facade\Cache;
use think\facade\Config;

class CityService
{
    public function list()
    {
        $cacheKey = 'city_cache_keys';
        if (Cache::store('redis')->has($cacheKey)) {
            return Cache::store('redis')->get($cacheKey);
        }
        //查询市级名称
        $data = Db::name('dev_region')
            ->order('id', 'asc')
            ->field('id,parent_id,name')
            ->where('level',1)
            ->select();
        if ($data) {
            Cache::store('redis')->set($cacheKey, $data);
        }
        return $data;
    }
}