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

import lombok.AllArgsConstructor;
import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.common.translation.annotation.TranslationType;
import org.dromara.common.translation.constant.TransConstant;
import org.dromara.common.translation.core.TranslationInterface;
import org.dromara.system.api.RemoteProjectService;

/**
 * 项目名称翻译实现
 *
 * @author lilemy
 * @date 2025-09-10 16:13
 */
@AllArgsConstructor
@TranslationType(type = TransConstant.PROJECT_ID_TO_NAME)
public class ProjectNameTranslationImpl implements TranslationInterface<String> {

    @DubboReference
    private RemoteProjectService remoteProjectService;

    /**
     * 翻译
     *
     * @param key   需要被翻译的键(不为空)
     * @param other 其他参数
     * @return 返回键对应的值
     */
    @Override
    public String translation(Object key, String other) {
        if (key instanceof Long id) {
            return remoteProjectService.selectProjectNameById(id);
        }
        return null;
    }
}
