城市查询列表

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

2
.idea/php.xml generated
View File

@@ -73,7 +73,7 @@
<path value="$PROJECT_DIR$/vendor/aliyuncs/oss-sdk-php" /> <path value="$PROJECT_DIR$/vendor/aliyuncs/oss-sdk-php" />
</include_path> </include_path>
</component> </component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.0"> <component name="PhpProjectSharedConfiguration" php_language_level="7.4">
<option name="suggestChangeDefaultLanguageLevel" value="false" /> <option name="suggestChangeDefaultLanguageLevel" value="false" />
</component> </component>
<component name="PhpStanOptionsConfiguration"> <component name="PhpStanOptionsConfiguration">

1
.idea/vcs.xml generated
View File

@@ -2,6 +2,5 @@
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/duolamaojiazhen" vcs="Git" />
</component> </component>
</project> </project>

View File

@@ -9,6 +9,11 @@ use think\Db;
class Ad extends ApiBase 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']; 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() public function lists()
{ {
$pid = $this->request->get('pid'); $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;
}
}

View File

@@ -16,7 +16,7 @@
} }
], ],
"require": { "require": {
"php": ">=7.0.0", "php": ">=7.4",
"topthink/framework": "5.1.*", "topthink/framework": "5.1.*",
"topthink/think-captcha": "2.0.*", "topthink/think-captcha": "2.0.*",
"overtrue/wechat": "~4.0", "overtrue/wechat": "~4.0",

View File

@@ -1,29 +1,49 @@
<?php <?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | 缓存设置
// +----------------------------------------------------------------------
use think\facade\Env; use think\facade\Env;
return [ return [
// 缓存配置为文件类型
'type' => 'complex',
// 默认缓存配置
'default' => [
// 驱动方式 // 驱动方式
'type' => Env::get('cache.type','File'), 'type' => 'File',
// 缓存保存目录 // 缓存保存目录
'path' => '', 'path' => '',
// 缓存前缀 // 缓存前缀
'prefix' => 'like_shop_', 'prefix' => 'like_shop_',
// 缓存有效期 0表示永久缓存 // 缓存有效期 0表示永久缓存
'expire' => 0, 'expire' => 0,
],
'port' =>Env::get('cache.port','6379'), // Redis缓存配置
'redis' => [
// 驱动方式
'type' => 'redis',
// Redis服务器地址
'host' => Env::get('cache.host','127.0.0.1'),
// Redis服务器端口
'port' => Env::get('cache.port','6379'),
// Redis连接密码留空表示无密码
'password' => Env::get('cache.pwd',''),
// Redis数据库索引0-15默认为0
'select' => Env::get('cache.select', 0),
// 连接超时时间0表示不限制
'timeout' => Env::get('cache.timeout', 0),
// 是否使用长连接true=长连接false=短连接)
'persistent' => Env::get('cache.persistent', true),
// 缓存前缀,用于区分不同应用或环境的缓存
'prefix' => 'like_shop_redis_',
// 缓存有效期0表示永久缓存
'expire' => Env::get('cache.expire', 0),
],
'host' => Env::get('cache.host','like-redis'), // File缓存配置
'file' => [
'type' => 'File',
'path' => '',
'prefix' => 'like_shop_file_',
'expire' => 0,
],
]; ];