<?php
namespace app\api\controller;

use app\api\logic\RegionLogic;
use app\api\validate\RegionValidate;

/**
 * index
 * Class IndexController
 * @package app\api\controller
 */
class RegionController extends BaseApiController
{
    public array $notNeedLogin = ['index','get_address_location'];

    /**
     * 获取省市区
     * @return \think\response\Json
     */
    public function index()
    {
        $result = RegionLogic::getRegionList();
        return $this->data($result);
    }

    /**
     * 获取当前定位
     * @return \think\response\Json
     */
    public function get_address_location()
    {
        $params = (new RegionValidate())->goCheck('location');
        $result = RegionLogic::getLocation($params);
        if (false === $result) {
            return $this->fail(RegionLogic::getError());
        }
        return $this->data($result);

    }


}