Merge branch 'prod/20260407' into test
This commit is contained in:
commit
d5c2c18af7
|
|
@ -1,10 +1,31 @@
|
|||
package com.nflg.mobilebroken.admin.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.nflg.mobilebroken.common.constant.Constant;
|
||||
import com.nflg.mobilebroken.common.util.MultilingualUtil;
|
||||
import com.nflg.mobilebroken.starter.service.impl.AliYunTranslate;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Validated
|
||||
@RestController
|
||||
public class ControllerBase {
|
||||
|
||||
@Resource
|
||||
private AliYunTranslate aliYunTranslate;
|
||||
|
||||
protected String translate(String text) {
|
||||
if (StrUtil.isNotBlank(text)) {
|
||||
String languageCode = MultilingualUtil.getLanguage();
|
||||
if (!StrUtil.equals(languageCode, Constant.DEFAULT_LANGUAGE_CODE)) {
|
||||
String aliyunCode = Constant.LANGUAGE_ALIYUN_MAP.get(languageCode);
|
||||
if (StrUtil.isNotBlank(aliyunCode)) {
|
||||
return aliYunTranslate.translateWord(text, aliyunCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,15 +5,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.nflg.mobilebroken.admin.annotation.ApiMark;
|
||||
import com.nflg.mobilebroken.common.constant.Constant;
|
||||
import com.nflg.mobilebroken.common.constant.MessageSubType;
|
||||
import com.nflg.mobilebroken.common.constant.MessageType;
|
||||
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||
import com.nflg.mobilebroken.common.pojo.PageData;
|
||||
import com.nflg.mobilebroken.common.pojo.request.AdminMessageSearchRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.request.MessageConfigRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.AdminMessageVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.AdminNotReadMessageCountVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.MessageConfigVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.TicketNotReadMessageCountVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.*;
|
||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||
import com.nflg.mobilebroken.common.util.MultilingualUtil;
|
||||
import com.nflg.mobilebroken.common.util.PageUtil;
|
||||
import com.nflg.mobilebroken.repository.entity.*;
|
||||
import com.nflg.mobilebroken.repository.service.*;
|
||||
|
|
@ -64,6 +63,9 @@ public class MessageController extends ControllerBase {
|
|||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Resource
|
||||
private IDictionaryItemTranslateService dictionaryItemTranslateService;
|
||||
|
||||
/**
|
||||
* 搜索消息
|
||||
* @param request 请求参数
|
||||
|
|
@ -73,6 +75,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());
|
||||
return ApiResult.success(PageUtil.convert(datas, d -> {
|
||||
if (Objects.equals(d.getSource(), 0)) {
|
||||
Ticket ticket = ticketService.getById(d.getSourceId());
|
||||
|
|
@ -115,6 +118,18 @@ 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())
|
||||
);
|
||||
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())
|
||||
);
|
||||
return d;
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class TestController extends ControllerBase {
|
|||
* @return 翻译结果
|
||||
*/
|
||||
@PostMapping("translate")
|
||||
public ApiResult<String> translate(@RequestBody String text) {
|
||||
public ApiResult<String> translateText(@RequestBody String text) {
|
||||
return ApiResult.success(translate.translateWord(text, "auto", "ja", "html"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,32 @@
|
|||
package com.nflg.mobilebroken.cfs.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.nflg.mobilebroken.common.constant.Constant;
|
||||
import com.nflg.mobilebroken.common.util.MultilingualUtil;
|
||||
import com.nflg.mobilebroken.starter.service.impl.AliYunTranslate;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.Console;
|
||||
|
||||
@Validated
|
||||
@RestController
|
||||
public class ControllerBase {
|
||||
|
||||
@Resource
|
||||
private AliYunTranslate aliYunTranslate;
|
||||
|
||||
protected String translate(String text) {
|
||||
if (StrUtil.isNotBlank(text)) {
|
||||
String languageCode = MultilingualUtil.getLanguage();
|
||||
if (!StrUtil.equals(languageCode, Constant.DEFAULT_LANGUAGE_CODE)) {
|
||||
String aliyunCode = Constant.LANGUAGE_ALIYUN_MAP.get(languageCode);
|
||||
if (StrUtil.isNotBlank(aliyunCode)) {
|
||||
return aliYunTranslate.translateWord(text, aliyunCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +1,21 @@
|
|||
package com.nflg.mobilebroken.cfs.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.nflg.mobilebroken.common.constant.Constant;
|
||||
import com.nflg.mobilebroken.common.constant.MessageSubType;
|
||||
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||
import com.nflg.mobilebroken.common.pojo.PageData;
|
||||
import com.nflg.mobilebroken.common.pojo.request.AppMessageSearchRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.request.MessageConfigRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.AppMessageVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.AppNotReadMessageCountVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.MessageConfigVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.TicketNotReadMessageCountVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.*;
|
||||
import com.nflg.mobilebroken.common.util.AppUserUtil;
|
||||
import com.nflg.mobilebroken.common.util.MultilingualUtil;
|
||||
import com.nflg.mobilebroken.repository.entity.AppMessage;
|
||||
import com.nflg.mobilebroken.repository.service.IAppMessageService;
|
||||
import com.nflg.mobilebroken.repository.service.IDictionaryItemService;
|
||||
import com.nflg.mobilebroken.repository.service.IDictionaryItemTranslateService;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
|
|
@ -45,6 +48,9 @@ public class MessageController extends ControllerBase {
|
|||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Resource
|
||||
private IDictionaryItemTranslateService dictionaryItemTranslateService;
|
||||
|
||||
/**
|
||||
* 搜索消息
|
||||
* @param request 请求参数
|
||||
|
|
@ -52,7 +58,19 @@ public class MessageController extends ControllerBase {
|
|||
*/
|
||||
@PostMapping("searchMessages")
|
||||
public ApiResult<PageData<AppMessageVO>> searchMessages(@RequestBody AppMessageSearchRequest request) {
|
||||
return ApiResult.success(appMessageService.search(AppUserUtil.getUserId(), AppUserUtil.getFrom(), request));
|
||||
IPage<AppMessageVO> page = appMessageService.search(AppUserUtil.getUserId(), AppUserUtil.getFrom(), request);
|
||||
if (CollectionUtil.isNotEmpty(page.getRecords())) {
|
||||
List<DictionaryItemTranslateVO> translates = dictionaryItemTranslateService.getAllByDictionaryCode("Prompt", MultilingualUtil.getLanguage());
|
||||
page.getRecords().forEach(r -> {
|
||||
r.setContent(translates.stream()
|
||||
.filter(t -> StrUtil.equals(t.getDictionaryItemName(), MessageSubType.findByValue(r.getSubType()).getDescription()))
|
||||
.findFirst()
|
||||
.map(DictionaryItemTranslateVO::getValue)
|
||||
.orElse(MessageSubType.findByValue(r.getSubType()).getDescription())
|
||||
);
|
||||
});
|
||||
}
|
||||
return ApiResult.success(page);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ public class AdminMessageVO {
|
|||
//任务事项描述
|
||||
private String subTypeDesc;
|
||||
|
||||
public String getSubTypeDesc() {
|
||||
return MessageSubType.findByValue(subType).getDescription();
|
||||
}
|
||||
// public String getSubTypeDesc() {
|
||||
// return MessageSubType.findByValue(subType).getDescription();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 任务类别
|
||||
|
|
@ -49,9 +49,9 @@ public class AdminMessageVO {
|
|||
//任务类别描述
|
||||
private String typeDesc;
|
||||
|
||||
public String getTypeDesc() {
|
||||
return MessageType.findByValue(type).getDescription();
|
||||
}
|
||||
// public String getTypeDesc() {
|
||||
// return MessageType.findByValue(type).getDescription();
|
||||
// }
|
||||
|
||||
//提交人
|
||||
private String sourceCreateUserName;
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ public class AppMessageVO {
|
|||
//任务事项描述
|
||||
private String content;
|
||||
|
||||
public String getContent() {
|
||||
return MessageSubType.findByValue(subType).getDescription();
|
||||
}
|
||||
// public String getContent() {
|
||||
// return MessageSubType.findByValue(subType).getDescription();
|
||||
// }
|
||||
|
||||
//消息时间
|
||||
private LocalDateTime createTime;
|
||||
|
|
|
|||
Loading…
Reference in New Issue