【优化】添加多语言支持
This commit is contained in:
parent
11c33d3674
commit
ea9de2c135
|
|
@ -67,7 +67,7 @@ public class MessageController extends ControllerBase {
|
|||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Resource
|
||||
private IDictionaryItemTranslateService dictionaryItemTranslateService;
|
||||
private IDictionaryItemService dictionaryItemService;
|
||||
|
||||
/**
|
||||
* 搜索消息
|
||||
|
|
@ -78,7 +78,7 @@ public class MessageController extends ControllerBase {
|
|||
@ApiMark(moduleName = "消息管理", apiName = "搜索消息")
|
||||
public ApiResult<PageData<AdminMessageVO>> searchMessages(@Valid @RequestBody AdminMessageSearchRequest request) {
|
||||
IPage<AdminMessageVO> datas = adminMessageService.search(AdminUserUtil.getUserId(), request);
|
||||
List<DictionaryItemTranslateVO> translates = dictionaryItemTranslateService.getAllByDictionaryCode("Prompt", MultilingualUtil.getLanguage());
|
||||
List<DictionaryItem> translates = dictionaryItemService.getListByDictionaryCode("Prompt", MultilingualUtil.getLanguage());
|
||||
return ApiResult.success(PageUtil.convert(datas, d -> {
|
||||
if (Objects.equals(d.getSource(), 0)) {
|
||||
Ticket ticket = ticketService.getById(d.getSourceId());
|
||||
|
|
@ -121,18 +121,24 @@ public class MessageController extends ControllerBase {
|
|||
}
|
||||
}
|
||||
}
|
||||
d.setTypeDesc(translates.stream()
|
||||
.filter(t -> StrUtil.equals(t.getDictionaryItemName(), MessageType.findByValue(d.getType()).getDescription()))
|
||||
.findFirst()
|
||||
.map(DictionaryItemTranslateVO::getValue)
|
||||
.orElse(MessageType.findByValue(d.getType()).getDescription())
|
||||
);
|
||||
MessageType mt = MessageType.findByValue(d.getType());
|
||||
if(Objects.nonNull(mt)) {
|
||||
d.setTypeDesc(translates.stream()
|
||||
.filter(t -> StrUtil.equals(t.getName(), mt.getDescription()))
|
||||
.findFirst()
|
||||
.map(DictionaryItem::getValue)
|
||||
.orElse(mt.getDescription())
|
||||
);
|
||||
}
|
||||
MessageSubType mst = MessageSubType.findByValue(d.getSubType());
|
||||
if(Objects.nonNull(mst)) {
|
||||
d.setSubTypeDesc(translates.stream()
|
||||
.filter(t -> StrUtil.equals(t.getDictionaryItemName(), MessageSubType.findByValue(d.getSubType()).getDescription()))
|
||||
.findFirst()
|
||||
.map(DictionaryItemTranslateVO::getValue)
|
||||
.orElse(MessageSubType.findByValue(d.getSubType()).getDescription())
|
||||
);
|
||||
.filter(t -> StrUtil.equals(t.getName(), mst.getDescription()))
|
||||
.findFirst()
|
||||
.map(DictionaryItem::getValue)
|
||||
.orElse(mst.getDescription())
|
||||
);
|
||||
}
|
||||
return d;
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue