feat : user

This commit is contained in:
2025-03-03 16:21:38 +08:00
parent e92a1cd8c0
commit d6f9f348da
12 changed files with 361 additions and 12 deletions

View File

@@ -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]);
}
}