Commit bb8fa032 authored by alex yao's avatar alex yao

I18N

parent a07e844f
...@@ -109,8 +109,11 @@ public class RestHandlerExceptionResolver implements HandlerExceptionResolver, P ...@@ -109,8 +109,11 @@ public class RestHandlerExceptionResolver implements HandlerExceptionResolver, P
if (ex instanceof BusinessException) { if (ex instanceof BusinessException) {
map.put("message", "业务异常:[" + ex.getMessage() + "]"); map.put("message", "业务异常:[" + ex.getMessage() + "]");
} }
// if (ex instanceof IllegalArgumentException) {
// map.put("message", "参数异常:[" + ex.getMessage() + "]");
// }
if (ex instanceof IllegalArgumentException) { if (ex instanceof IllegalArgumentException) {
map.put("message", "参数异常:[" + ex.getMessage() + "]"); map.put("message", "Parameter exception:[" + ex.getMessage() + "]");
} }
if (ex instanceof I18nMessageException) { if (ex instanceof I18nMessageException) {
map.put("message", ex.getMessage()); map.put("message", ex.getMessage());
......
...@@ -18,7 +18,9 @@ import cn.com.poc.knowledge.service.BizKnowledgeDocumentService; ...@@ -18,7 +18,9 @@ import cn.com.poc.knowledge.service.BizKnowledgeDocumentService;
import cn.com.poc.knowledge.service.BizKnowledgeInfoService; import cn.com.poc.knowledge.service.BizKnowledgeInfoService;
import cn.com.poc.support.security.oauth.entity.UserBaseEntity; import cn.com.poc.support.security.oauth.entity.UserBaseEntity;
import cn.com.poc.thirdparty.resource.demand.ai.entity.knowledge.GetKnowledgeChunkInfoResult; import cn.com.poc.thirdparty.resource.demand.ai.entity.knowledge.GetKnowledgeChunkInfoResult;
import cn.com.yict.framemax.core.context.Context;
import cn.com.yict.framemax.core.i18n.I18nMessageException; import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.core.i18n.I18nUtils;
import cn.com.yict.framemax.data.model.PagingInfo; import cn.com.yict.framemax.data.model.PagingInfo;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
...@@ -29,6 +31,7 @@ import org.springframework.stereotype.Component; ...@@ -29,6 +31,7 @@ import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.swing.text.AbstractDocument;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -237,7 +240,7 @@ public class KnowledgeRestImpl implements KnowledgeRest { ...@@ -237,7 +240,7 @@ public class KnowledgeRestImpl implements KnowledgeRest {
@Override @Override
public BizKnowledgeInfoDto createKnowledge(BizKnowledgeInfoDto dto) throws Exception { public BizKnowledgeInfoDto createKnowledge(BizKnowledgeInfoDto dto) throws Exception {
Assert.notNull(dto.getKnowledgeName(), "知识库名称不能为空"); Assert.notNull(dto.getKnowledgeName(), I18nUtils.message("assert/knowledge.name.null"));
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException(); UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
BizKnowledgeInfoEntity bizKnowledgeInfoEntity = new BizKnowledgeInfoEntity(); BizKnowledgeInfoEntity bizKnowledgeInfoEntity = new BizKnowledgeInfoEntity();
bizKnowledgeInfoEntity.setKnowledgeName(dto.getKnowledgeName()); bizKnowledgeInfoEntity.setKnowledgeName(dto.getKnowledgeName());
...@@ -251,7 +254,7 @@ public class KnowledgeRestImpl implements KnowledgeRest { ...@@ -251,7 +254,7 @@ public class KnowledgeRestImpl implements KnowledgeRest {
@Override @Override
public BizKnowledgeInfoDto updateKnowledgeInfo(BizKnowledgeInfoDto dto) throws Exception { public BizKnowledgeInfoDto updateKnowledgeInfo(BizKnowledgeInfoDto dto) throws Exception {
Assert.notNull(dto.getId()); Assert.notNull(dto.getId());
Assert.notBlank(dto.getKnowledgeName(), "知识库名称不能为空"); Assert.notBlank(dto.getKnowledgeName(), I18nUtils.message("assert/knowledge.name.null"));
BizKnowledgeInfoEntity bizKnowledgeInfoEntity = new BizKnowledgeInfoEntity(); BizKnowledgeInfoEntity bizKnowledgeInfoEntity = new BizKnowledgeInfoEntity();
bizKnowledgeInfoEntity.setId(dto.getId()); bizKnowledgeInfoEntity.setId(dto.getId());
bizKnowledgeInfoEntity.setKnowledgeName(dto.getKnowledgeName()); bizKnowledgeInfoEntity.setKnowledgeName(dto.getKnowledgeName());
...@@ -264,7 +267,7 @@ public class KnowledgeRestImpl implements KnowledgeRest { ...@@ -264,7 +267,7 @@ public class KnowledgeRestImpl implements KnowledgeRest {
public void enableKnowledgeInfo(Integer knowledgeInfoId, String isOpen) throws Exception { public void enableKnowledgeInfo(Integer knowledgeInfoId, String isOpen) throws Exception {
Assert.notNull(knowledgeInfoId); Assert.notNull(knowledgeInfoId);
Assert.notBlank(isOpen); Assert.notBlank(isOpen);
Assert.isTrue(isOpen.equals(CommonConstant.IsDeleted.N) || isOpen.equals(CommonConstant.IsDeleted.Y), "isOpen must Y or N"); Assert.isTrue(isOpen.equals(CommonConstant.IsDeleted.N) || isOpen.equals(CommonConstant.IsDeleted.Y));
BizKnowledgeInfoEntity bizKnowledgeInfoEntity = new BizKnowledgeInfoEntity(); BizKnowledgeInfoEntity bizKnowledgeInfoEntity = new BizKnowledgeInfoEntity();
bizKnowledgeInfoEntity.setId(knowledgeInfoId); bizKnowledgeInfoEntity.setId(knowledgeInfoId);
bizKnowledgeInfoEntity.setIsOpen(isOpen); bizKnowledgeInfoEntity.setIsOpen(isOpen);
...@@ -297,7 +300,7 @@ public class KnowledgeRestImpl implements KnowledgeRest { ...@@ -297,7 +300,7 @@ public class KnowledgeRestImpl implements KnowledgeRest {
Assert.notNull(dto.getChunkContent()); Assert.notNull(dto.getChunkContent());
Assert.notNull(dto.getChunkRelationId()); Assert.notNull(dto.getChunkRelationId());
Assert.notNull(dto.getKdId()); Assert.notNull(dto.getKdId());
Assert.isTrue(dto.getChunkContent().length() <= 1200); Assert.isTrue(dto.getChunkContent().length() <= 1200, I18nUtils.message("assert/content.length.cannot.exceed", new Object[]{"1200"}));
knowledgeService.updateKnowledgeChunkDoc(dto.getKdId(), dto.getChunkRelationId(), dto.getChunkContent()); knowledgeService.updateKnowledgeChunkDoc(dto.getKdId(), dto.getChunkRelationId(), dto.getChunkContent());
} }
...@@ -306,7 +309,7 @@ public class KnowledgeRestImpl implements KnowledgeRest { ...@@ -306,7 +309,7 @@ public class KnowledgeRestImpl implements KnowledgeRest {
Assert.notNull(dto.getChunkContent()); Assert.notNull(dto.getChunkContent());
Assert.notNull(dto.getKdId()); Assert.notNull(dto.getKdId());
Assert.notNull(dto.getChunkSort()); Assert.notNull(dto.getChunkSort());
Assert.isTrue(dto.getChunkContent().length() <= 1200); Assert.isTrue(dto.getChunkContent().length() <= 1200, I18nUtils.message("assert/content.length.cannot.exceed", new Object[]{"1200"}));
knowledgeService.addKnowledgeChunk(dto.getKdId(), dto.getChunkContent(), dto.getChunkSort()); knowledgeService.addKnowledgeChunk(dto.getKdId(), dto.getChunkContent(), dto.getChunkSort());
} }
......
content.length.cannot.exceed=The content length cannot exceed,{0}
knowledge.name.null=\u77E5\u8BC6\u5E93\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
\ No newline at end of file
content.length.cannot.exceed=\u5185\u5BB9\u957F\u5EA6\u4E0D\u53EF\u8D85\u8FC7,{0}
knowledge.name.null=\u77E5\u8BC6\u5E93\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
\ No newline at end of file
content.length.cannot.exceed=\u5185\u5BB9\u9577\u5EA6\u4E0D\u53EF\u8D85\u904E,{0}
knowledge.name.null=\u77E5\u8B58\u5EAB\u540D\u4E0D\u80FD\u70BA\u7A7A
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment