package org.dromara.common.translation.core.impl;

import org.dromara.common.core.service.AreaService;
import org.dromara.common.translation.annotation.TranslationType;
import org.dromara.common.translation.constant.TransConstant;
import org.dromara.common.translation.core.TranslationInterface;
import lombok.AllArgsConstructor;

/**
 * 区域翻译实现
 *
 * @author Lion Li
 */
@AllArgsConstructor
@TranslationType(type = TransConstant.AREA_ID_TO_NAME)
public class AreaNameTranslationImpl implements TranslationInterface<String> {

    private final AreaService areaService;

    @Override
    public String translation(Object key, String other) {
        if (key instanceof String ids) {
            return areaService.selectAreaNameByIds(ids);
        } else if (key instanceof Long id) {
            return areaService.selectAreaNameByIds(id.toString());
        }
        return null;
    }
}
