package net.rzdata.common.translation.core.impl;

import lombok.AllArgsConstructor;
import net.rzdata.common.core.service.UserService;
import net.rzdata.common.translation.core.TranslationInterface;
import net.rzdata.common.translation.annotation.TranslationType;
import net.rzdata.common.translation.constant.TransConstant;

/**
 * 用户名称翻译实现
 *
 * @author may
 */
@AllArgsConstructor
@TranslationType(type = TransConstant.USER_ID_TO_NICKNAME)
public class NicknameTranslationImpl implements TranslationInterface<String> {

    private final UserService userService;

    @Override
    public String translation(Object key, String other) {
        if (key instanceof Long id) {
            return userService.selectNicknameById(id);
        }
        return null;
    }
}
