城市查询列表

轮播图
首页图标
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

@@ -9,6 +9,11 @@ use think\Db;
class Ad extends ApiBase
{
public $like_not_need_login = ['lists','channel','label','add_comost','add_comost','list_comost','follow_comost','comost_add','label_edit','comost_info','notice','position','position_list','vode_type','video_list','video_info','user_wages','user_wages_add','user_leave','fine','recruit','last_leave','last_fine','notice_list','leave','auth'];
/**
* @return void
* 广告图片展示
*/
public function lists()
{
$pid = $this->request->get('pid');

View File

@@ -0,0 +1,28 @@
<?php
namespace app\api\controller;
use app\api\server\CityService;
class City extends ApiBase
{
public $like_not_need_login = ['index'];
// 类型属性声明
protected CityService $cityService;
/**
* 构造函数 - 必须初始化类型属性
*/
public function __construct()
{
parent::__construct();
// 初始化服务
$this->cityService = new CityService();
}
public function index()
{
$array = $this->cityService->list();
return $this->_success($array);
}
}

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;
}
}