package com.seer.teach.iot.api;

import com.seer.teach.common.entity.CityEntity;
import com.seer.teach.common.entity.ProvinceEntity;
import com.seer.teach.common.service.RegionAddressService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

/**
 * 设备定位数据
 * <p>
 * 设备定位数据
 * </p>
 *
 * @author Captain
 * @version 1.0
 * @since 2025-07-16 11:20
 */
@Slf4j
@RestController
@RequiredArgsConstructor
public class DeviceLocationInfoServiceApiImpl implements DeviceLocationInfoServiceApi {

    private final RegionAddressService regionAddressService;

    /**
     * 根据城市 ID 获取所属省份名称
     *
     * @param cityId 城市 ID
     * @return 所属省份的名称
     */
    @Override
    public String getProvinceByCityId(Integer cityId) {
        ProvinceEntity province = regionAddressService.getProvinceByCityId(cityId);
        return province.getProvince();
    }

    /**
     * 根据城市 ID 获取城市名称
     *
     * @param cityId 城市 ID
     * @return 城市名称
     */
    @Override
    public String getCityNameByCityId(Integer cityId) {
        CityEntity city = regionAddressService.getCityById(cityId);
        return city.getCity();
    }
}