56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* This service file is part of item.
|
|
*
|
|
* @author ctexthuang
|
|
* @contact ctexthuang@qq.com
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Service\System;
|
|
|
|
use App\Cache\Redis\Common\CityCache;
|
|
use App\Constants\Common\CityCode;
|
|
use App\Service\Admin\BaseService;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use Psr\Container\ContainerExceptionInterface;
|
|
use Psr\Container\NotFoundExceptionInterface;
|
|
use RedisException;
|
|
|
|
class SystemService extends BaseService
|
|
{
|
|
/**
|
|
* @var CityCache
|
|
*/
|
|
#[Inject]
|
|
protected CityCache $cityCache;
|
|
|
|
public function handle()
|
|
{
|
|
return $this->return->success();
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
* @throws RedisException
|
|
*/
|
|
public function address_list(): array
|
|
{
|
|
$deep = (int)$this->request->input('deep');
|
|
$pid = $this->request->input('pid',0);
|
|
|
|
$deepList = $this->cityCache->getCityList($deep);
|
|
|
|
if (in_array($deep,[CityCode::DEEP_CITY,CityCode::DEEP_PROVINCE]) && $pid != 0) {
|
|
$column = 'pid';
|
|
$filteredData = array_values(array_filter($deepList, function($value) use ($column, $pid) {
|
|
return $value[$column] == $pid;
|
|
}));
|
|
}
|
|
|
|
return $this->return->success('success', ['list' => $filteredData ?? $deepList]);
|
|
}
|
|
} |