feat : user
This commit is contained in:
@@ -10,10 +10,58 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Api\System;
|
||||
|
||||
class CityListService extends
|
||||
use App\Cache\Redis\Common\CityCache;
|
||||
use App\Constants\Common\CityCode;
|
||||
use App\Model\SystemCity;
|
||||
use App\Model\SystemCityConfig;
|
||||
use App\Service\Api\BaseService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
class CityListService extends BaseService
|
||||
{
|
||||
public function handle()
|
||||
|
||||
/**
|
||||
* @var SystemCity
|
||||
*/
|
||||
#[Inject]
|
||||
protected SystemCity $systemCityModel;
|
||||
|
||||
/**
|
||||
* @var SystemCityConfig
|
||||
*/
|
||||
#[Inject]
|
||||
protected SystemCityConfig $systemCityConfigModel;
|
||||
|
||||
/**
|
||||
* @var CityCache
|
||||
*/
|
||||
#[Inject]
|
||||
protected CityCache $cityCache;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function handle(): array
|
||||
{
|
||||
//todo Write logic
|
||||
$allInfo = array_column($this->cityCache->getCityList(),'title','id');
|
||||
|
||||
$list = $this->systemCityModel
|
||||
->where('is_del', CityCode::IS_NOT_DELETE)
|
||||
->select(['id','title','status','city_id','province_id'])
|
||||
->get();
|
||||
|
||||
if (empty($list)) return $this->return->success('success', ['list' => []]);
|
||||
|
||||
$list = $list->toArray();
|
||||
foreach ($list as &$v) {
|
||||
$v['city_name'] = $allInfo[$v['city_id']];
|
||||
$v['province_name'] = $allInfo[$v['province_id']];
|
||||
}
|
||||
|
||||
return $this->return->success('success', ['list' => $list]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user