xm
2024-06-14 722af26bc6fec32bb289b1df51a9016a4935610f
提交 | 用户 | 时间
722af2 1 package com.dl.common.translation.impl;
X 2
3 import com.dl.common.annotation.TranslationType;
4 import com.dl.common.constant.TransConstant;
5 import com.dl.common.core.service.DictService;
6 import com.dl.common.translation.TranslationInterface;
7 import com.dl.common.utils.StringUtils;
8 import lombok.AllArgsConstructor;
9 import org.springframework.stereotype.Component;
10
11 /**
12  * 字典翻译实现
13  *
14  * @author Lion Li
15  */
16 @Component
17 @AllArgsConstructor
18 @TranslationType(type = TransConstant.DICT_TYPE_TO_LABEL)
19 public class DictTypeTranslationImpl implements TranslationInterface<String> {
20
21     private final DictService dictService;
22
23     @Override
24     public String translation(Object key, String other) {
25         if (key instanceof String && StringUtils.isNotBlank(other)) {
26             return dictService.getDictLabel(other, key.toString());
27         }
28         return null;
29     }
30 }