城市查询列表

轮播图
首页图标
This commit is contained in:
2025-12-22 21:26:10 +08:00
parent 7cb0becde5
commit f6d50d8d98
7 changed files with 106 additions and 26 deletions

View File

@@ -0,0 +1,28 @@
<?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;
}
}