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