update 优化 翻译组件 支持返回值泛型 支持多种类型数据翻译(例如: 根据主键翻译成对象)

This commit is contained in:
疯狂的狮子Li
2023-02-18 23:43:53 +08:00
parent dadf05c25c
commit edcd7c99ba
7 changed files with 13 additions and 13 deletions

View File

@ -24,15 +24,15 @@ import java.util.Map;
public class TranslationConfig {
@Autowired
private List<TranslationInterface> list;
private List<TranslationInterface<?>> list;
@Autowired
private ObjectMapper objectMapper;
@PostConstruct
public void init() {
Map<String, TranslationInterface> map = new HashMap<>(list.size());
for (TranslationInterface trans : list) {
Map<String, TranslationInterface<?>> map = new HashMap<>(list.size());
for (TranslationInterface<?> trans : list) {
if (trans.getClass().isAnnotationPresent(TranslationType.class)) {
TranslationType annotation = trans.getClass().getAnnotation(TranslationType.class);
map.put(annotation.type(), trans);