Commit 028a598b authored by alex yao's avatar alex yao

i18n

parent 438781c8
......@@ -12,7 +12,7 @@ import cn.com.poc.agent_application.service.BizMemberAgentApplicationCollectServ
import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.common.utils.BlContext;
import cn.com.poc.support.security.oauth.entity.UserBaseEntity;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......@@ -39,17 +39,17 @@ public class AgentApplicationMallServiceImpl implements AgentApplicationMallServ
public void collectOrCancelAgentInMall(Integer id) throws Exception {
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
if (userBaseEntity == null) {
throw new BusinessException("用户未登录");
throw new I18nMessageException("exception/user.not.login");
}
BizAgentApplicationMallEntity mallEntity = bizAgentApplicationMallService.get(id);
if (mallEntity == null) {
throw new BusinessException("应用不存在");
throw new I18nMessageException("exception/application.does.not.exist");
}
BizAgentApplicationPublishEntity publishEntity = bizAgentApplicationPublishService.get(mallEntity.getAgentPublishId());
if (publishEntity == null) {
throw new BusinessException("应用未发布");
throw new I18nMessageException("exception/publication.failed");
}
// 先判断当前应用被收藏了吗
BizMemberAgentApplicationCollectEntity bizMemberAgentApplicationCollectEntity = new BizMemberAgentApplicationCollectEntity();
......
......@@ -18,7 +18,7 @@ import cn.com.poc.thirdparty.resource.demand.ai.function.LargeModelFunctionEnum;
import cn.com.poc.thirdparty.resource.demand.ai.function.long_memory.SetLongMemoryConstants;
import cn.com.poc.thirdparty.resource.demand.ai.function.value_memory.GetValueMemory;
import cn.com.poc.thirdparty.resource.demand.ai.function.value_memory.SetValueMemoryConstants;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.data.model.PagingInfo;
import cn.hutool.core.collection.ListUtil;
import com.alibaba.fastjson.JSONObject;
......@@ -67,10 +67,10 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
@Override
public AgentApplicationInfoDto saveVariableStructure(String agentId, List<Variable> variableStructure) {
Assert.notNull(agentId, "agentId不能为空");
Assert.notNull(agentId);
BizAgentApplicationInfoEntity bizAgentApplicationInfoEntity = bizAgentApplicationInfoService.saveVariableStructure(agentId, variableStructure);
if (bizAgentApplicationInfoEntity == null) {
throw new BusinessException("应用不存在");
throw new I18nMessageException("exception/application.does.not.exist");
}
return AgentApplicationInfoConvert.entityToDto(bizAgentApplicationInfoEntity);
}
......@@ -164,7 +164,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
public AgentApplicationInfoDto update(AgentApplicationInfoDto dto) throws Exception {
Assert.notNull(dto);
Assert.notNull(dto.getBaseInfo());
Assert.notNull(dto.getBaseInfo().getAgentId(), "id不能为空");
Assert.notNull(dto.getBaseInfo().getAgentId());
Assert.notNull(dto.getCommConfig());
Assert.notNull(dto.getCommModelConfig());
Assert.notNull(dto.getKnowledgeConfig());
......@@ -177,7 +177,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
Assert.notNull(agentId);
BizAgentApplicationInfoEntity entity = bizAgentApplicationInfoService.getByAgentId(agentId);
if (entity == null) {
throw new BusinessException("应用不存在");
throw new I18nMessageException("exception/application.does.not.exist");
}
return AgentApplicationInfoConvert.entityToDto(entity);
}
......@@ -219,7 +219,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
String agentId = dto.getAgentId();
BizAgentApplicationInfoEntity infoEntity = bizAgentApplicationInfoService.getByAgentId(agentId);
if (infoEntity == null) {
throw new BusinessException("应用不存在");
throw new I18nMessageException("exception/application.does.not.exist");
}
//获取知识库配置
List<Integer> kdIds = knowledgeService.getKdIdsByKnowledgeInfoIds(infoEntity.getKnowledgeIds());
......@@ -301,7 +301,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
bizAgentApplicationLargeModelListEntity.setModelNickName(query);
List<BizAgentApplicationLargeModelListEntity> entities = bizAgentApplicationLargeModelListService.findByExample(bizAgentApplicationLargeModelListEntity, null);
if (CollectionUtils.isEmpty(entities)) {
throw new BusinessException("模型不存在");
throw new I18nMessageException("模型不存在");
}
BizAgentApplicationLargeModelListEntity entity = entities.get(0);
BizAgentApplicationLargeModelListDto result = new BizAgentApplicationLargeModelListDto();
......@@ -338,7 +338,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
Assert.notNull(dto.getInput(), "输入不能为空");
CreateAgentTitleAndDescEntity entity = agentApplicationInfoService.createAgentTitleAndDesc(dto.getInput());
if (null == entity) {
throw new BusinessException("生成失败,请稍后重试");
throw new I18nMessageException("exception/generation.failed.please.try.again.later");
}
AgentApplicationGCDto result = new AgentApplicationGCDto();
result.setAgentTitle(entity.getAgentTitle());
......
package cn.com.poc.agent_application.rest.impl;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import cn.com.poc.agent_application.aggregate.AgentApplicationMallService;
import cn.com.poc.agent_application.convert.BizAgentApplicationCategoryConvert;
import cn.com.poc.agent_application.convert.BizAgentApplicationMallConvert;
import cn.com.poc.agent_application.dto.AgentApplicationMallQueryDto;
import cn.com.poc.agent_application.dto.BizAgentApplicationMallDto;
import cn.com.poc.agent_application.entity.BizAgentApplicationCategoryEntity;
import cn.com.poc.agent_application.entity.BizAgentApplicationMallEntity;
import cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity;
import cn.com.poc.agent_application.entity.BizMemberAgentApplicationCollectEntity;
import cn.com.poc.agent_application.query.MallAgentApplicationQueryCondition;
import cn.com.poc.agent_application.query.MallAgentApplicationQueryItem;
import cn.com.poc.agent_application.rest.BizAgentApplicationMallRest;
import cn.com.poc.agent_application.service.BizAgentApplicationCategoryService;
import cn.com.poc.agent_application.service.BizAgentApplicationMallService;
import cn.com.poc.agent_application.service.BizAgentApplicationPublishService;
import cn.com.poc.agent_application.service.BizMemberAgentApplicationCollectService;
import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.common.constant.XLangConstant;
import cn.com.poc.common.utils.StringUtils;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.springframework.stereotype.Component;
import cn.com.poc.agent_application.rest.BizAgentApplicationMallRest;
import cn.com.poc.agent_application.service.BizAgentApplicationMallService;
import cn.com.poc.agent_application.dto.BizAgentApplicationMallDto;
import cn.com.poc.agent_application.entity.BizAgentApplicationMallEntity;
import cn.com.yict.framemax.data.model.PagingInfo;
import cn.com.poc.agent_application.convert.BizAgentApplicationMallConvert;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
@Component
public class BizAgentApplicationMallRestImpl implements BizAgentApplicationMallRest {
......@@ -58,7 +56,7 @@ public class BizAgentApplicationMallRestImpl implements BizAgentApplicationMallR
Assert.notNull(dto.getIsCopy());
BizAgentApplicationPublishEntity publishEntity = bizAgentApplicationPublishService.get(dto.getAgentPublishId());
if (publishEntity == null) {
throw new BusinessException("应用未发布");
throw new I18nMessageException("exception/");
}
dto.setIsSale(CommonConstant.IsDeleted.Y);
// 判断当前应用之前是否上架了
......@@ -174,7 +172,7 @@ public class BizAgentApplicationMallRestImpl implements BizAgentApplicationMallR
result.add(entity.getCategoryTw());
break;
default:
throw new I18nMessageException("不支持的语言");
throw new I18nMessageException("not support lang");
}
}
return result;
......
......@@ -80,7 +80,7 @@ public class BizAgentApplicationDialoguesRecordServiceImpl extends BaseServiceIm
public BizAgentApplicationDialoguesRecordEntity update(BizAgentApplicationDialoguesRecordEntity entity) throws Exception {
Assert.notNull(entity);
Assert.notNull(entity.getId(), "update pk can not be null");
Assert.notNull(entity.getId());
BizAgentApplicationDialoguesRecordModel model = this.repository.get(entity.getId());
if (entity.getRole() != null) {
......
......@@ -70,7 +70,7 @@ public class BizAgentApplicationGcConfigServiceImpl extends BaseServiceImpl
public BizAgentApplicationGcConfigEntity update(BizAgentApplicationGcConfigEntity entity) throws Exception {
Assert.notNull(entity);
Assert.notNull(entity.getId(), "update pk can not be null");
Assert.notNull(entity.getId());
BizAgentApplicationGcConfigModel model = this.repository.get(entity.getId());
if (entity.getConfigCode() != null) {
......
......@@ -7,7 +7,7 @@ import cn.com.poc.agent_application.query.AgentApplicationInfoQueryItem;
import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.common.utils.JsonUtils;
import cn.com.poc.common.utils.UUIDTool;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.core.service.impl.BaseServiceImpl;
import cn.com.poc.agent_application.service.BizAgentApplicationInfoService;
import cn.com.poc.agent_application.model.BizAgentApplicationInfoModel;
......@@ -109,7 +109,7 @@ public class BizAgentApplicationInfoServiceImpl extends BaseServiceImpl
model.setIsDeleted(CommonConstant.IsDeleted.N);
List<BizAgentApplicationInfoModel> models = this.repository.findByExample(model);
if (CollectionUtils.isEmpty(models)) {
throw new BusinessException("数据不存在");
throw new I18nMessageException("exception/data.does.not.exist");
}
model = models.get(0);
paramVerificationAndConvert(entity, model);
......
......@@ -6,7 +6,7 @@ import cn.com.poc.agent_application.query.PublishAgentApplicationQueryItem;
import cn.com.poc.agent_application.service.BizAgentApplicationMallService;
import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.common.utils.JsonUtils;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.core.service.impl.BaseServiceImpl;
import cn.com.poc.agent_application.service.BizAgentApplicationPublishService;
import cn.com.poc.agent_application.model.BizAgentApplicationPublishModel;
......@@ -93,7 +93,7 @@ public class BizAgentApplicationPublishServiceImpl extends BaseServiceImpl
model.setIsDeleted(CommonConstant.IsDeleted.N);
List<BizAgentApplicationPublishModel> models = this.repository.findByExample(model);
if (CollectionUtils.isEmpty(models)) {
throw new BusinessException("数据不存在");
throw new I18nMessageException("exception/data.does.not.exist");
}
model = models.get(0);
paramVerificationAndConvert(entity, model);
......
package cn.com.poc.common.aspect;
import cn.com.poc.common.utils.JsonUtils;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.core.utils.JSON;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
......@@ -73,7 +73,7 @@ public class RestLoggingAspect {
try {
retVal = pjp.proceed();
} catch (BusinessException e) { // 业务层异常
} catch (I18nMessageException e) { // 业务层异常
logger.error("[Class:{}][Method:{}][Path:{}][BizException:{}-{}]", className, methodName, requestPath, e.getErrorCode(), e.getMessage());
throw e;
......
package cn.com.poc.common.aspect;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
......@@ -50,8 +50,8 @@ public class ServiceLoggingAspect {
private void logException(String methodName, Object object, Throwable e) throws Throwable {
//业务层异常
if (e instanceof BusinessException) {
BusinessException be = (BusinessException) e;
if (e instanceof I18nMessageException) {
I18nMessageException be = (I18nMessageException) e;
logger.info("[Class:{}][Method:{}][BizException:{}-{}]", object.getClass(), methodName, be.getErrorCode(), be.getMessage());
//系統异常
} else {
......
package cn.com.poc.common.handler;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.core.exception.ErrorCoded;
import cn.com.yict.framemax.core.spring.rest.RestServiceRegistration;
import cn.com.yict.framemax.core.utils.BeanUtils;
......@@ -111,6 +112,9 @@ public class RestHandlerExceptionResolver implements HandlerExceptionResolver, P
if (ex instanceof IllegalArgumentException) {
map.put("message", "参数异常:[" + ex.getMessage() + "]");
}
if (ex instanceof I18nMessageException) {
map.put("message", ex.getMessage());
}
/*
* if (ex instanceof NoneLoginException || ex instanceof
......@@ -122,7 +126,7 @@ public class RestHandlerExceptionResolver implements HandlerExceptionResolver, P
response.setStatus(statusCode);
HttpUtils.outJson(map, request, response);
if (ex instanceof BusinessException) {
if (ex instanceof I18nMessageException) {
log.error("业务异常:", ex);
return;
}
......
......@@ -36,7 +36,7 @@ public class AuthenticationInterceptor implements MvcHandlerInterceptor {
// String headerTimestamp = request.getHeader("timestamp");
// String headerSign = request.getHeader("x-request-sign");
// if (StringUtils.isBlank(headerSign) && StringUtils.isBlank(headerTimestamp)) {
// throw new BusinessException("Missing parameters in request header");
// throw new I18nMessageException("Missing parameters in request header");
// }
//
// //计算签名
......
package cn.com.poc.common.pool;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.concurrent.LinkedBlockingQueue;
......@@ -38,7 +38,7 @@ public class CommonThreadPoolExecutor {
try {
THREAD_POOL_EXECUTOR.execute(task);
} catch (Exception e) {
throw new BusinessException("当前任务过多,请稍后重试");
throw new I18nMessageException("exception/there.are.too.many.tasks.currently.please.try.again.later");
}
}
......
package cn.com.poc.common.pool;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.concurrent.LinkedBlockingQueue;
......@@ -38,7 +38,7 @@ public class SpeechToTextThreadPoolExecutor {
try {
THREAD_POOL_EXECUTOR.execute(task);
} catch (Exception e) {
throw new BusinessException("当前任务过多,请稍后重试");
throw new I18nMessageException("当前任务过多,请稍后重试");
}
}
......
package cn.com.poc.common.rest;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.core.rest.BaseRest;
import cn.com.yict.framemax.web.permission.Access;
import cn.com.yict.framemax.web.permission.Permission;
......@@ -14,7 +14,7 @@ public interface JudgeCodeRest extends BaseRest {
* @param account,code
* @throws Exception
*/
boolean judgeCode(@RequestParam String account, @RequestParam String code) throws BusinessException;
boolean judgeCode(@RequestParam String account, @RequestParam String code) throws Exception;
/**
* 校验验证码是否正确,正确的话就返回授权码,可以给别的业务操作
......@@ -22,5 +22,5 @@ public interface JudgeCodeRest extends BaseRest {
* @param account,code
* @throws Exception
*/
String judgeCodeReturnAuthCode(@RequestParam String account, @RequestParam String code) throws BusinessException;
String judgeCodeReturnAuthCode(@RequestParam String account, @RequestParam String code) throws Exception;
}
......@@ -17,7 +17,7 @@ public class BosRestImpl implements BosRest {
@Override
public String upload(MultipartFile file) throws IOException {
Assert.notNull(file, "文件不能为空");
Assert.notNull(file);
String contentType = file.getContentType();
String originalFilename = file.getOriginalFilename();
String prefix = originalFilename.substring(originalFilename.lastIndexOf(".")).replaceAll("\\.", "");
......
......@@ -3,7 +3,7 @@ package cn.com.poc.common.rest.impl;
import cn.com.poc.common.service.JudgeCodeService;
import cn.com.poc.common.utils.Assert;
import cn.com.poc.common.rest.JudgeCodeRest;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -15,16 +15,16 @@ public class JudgeCodeRestImpl implements JudgeCodeRest {
private JudgeCodeService judgeCodeService;
@Override
public boolean judgeCode(String account, String code) throws BusinessException {
Assert.notBlank(account, "用户登录,登录账号不能为空");
Assert.notBlank(code, "验证码不能为空");
public boolean judgeCode(String account, String code) throws Exception {
Assert.notBlank(account);
Assert.notBlank(code);
return judgeCodeService.judgeCode(account, code);
}
@Override
public String judgeCodeReturnAuthCode(String account, String code) throws BusinessException {
Assert.notBlank(account, "用户登录,登录账号不能为空");
Assert.notBlank(code, "验证码不能为空");
public String judgeCodeReturnAuthCode(String account, String code) throws Exception {
Assert.notBlank(account);
Assert.notBlank(code);
return judgeCodeService.judgeCodeReturnAuthCode(account, code);
}
}
......@@ -15,7 +15,7 @@ public class SendEmailRestImpl implements SendEmailRest {
@Override
public void sendEmailCode(String emailAddress) throws Exception {
Assert.notBlank(emailAddress, "用户登录,登录账号不能为空");
Assert.notBlank(emailAddress);
sendEmailService.sendEmailCode(emailAddress);
}
}
......@@ -21,7 +21,7 @@ public class SmsRestImpl implements SmsRest {
*/
@Override
public void smsDelivered(String phone) throws Exception {
Assert.notBlank(phone, "用户登录,登录账号不能为空");
Assert.notBlank(phone);
//校验手机号格式(其中包含大陆和港澳台的校验)
//正则表达式使用了多个正则模式,每个模式使用|分隔,表示多个模式中的任何一个匹配即可。这样,它可以用于校验多种手机号的格式
boolean matches = Pattern.matches(
......@@ -29,7 +29,7 @@ public class SmsRestImpl implements SmsRest {
"(?:0|852|\\+852)?\\d{8}|" + //MOBILE_HK
"(?:0|886|\\+886)?(?:|-)09\\d{8}|" + //MOBILE_TW
"(?:0|853|\\+853)?(?:|-)6\\d{7}", phone); //MOBILE_MO
Assert.isTrue(matches, "手机号格式错误!请重试!");
Assert.isTrue(matches);
smsService.smsDelivered(phone);
}
......
package cn.com.poc.common.service;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
public interface JudgeCodeService {
/**
......@@ -9,7 +9,7 @@ public interface JudgeCodeService {
* @param account,code
* @throws Exception
*/
boolean judgeCode(String account, String code) throws BusinessException;
boolean judgeCode(String account, String code) throws Exception;
/**
* 校验验证码是否正确,正确的话就返回授权码,可以给别的业务操作
......@@ -17,5 +17,5 @@ public interface JudgeCodeService {
* @param account,code
* @throws Exception
*/
String judgeCodeReturnAuthCode(String account, String code) throws BusinessException;
String judgeCodeReturnAuthCode(String account, String code) throws Exception;
}
......@@ -4,7 +4,7 @@ import cn.com.poc.common.service.BosConfigService;
import cn.com.poc.common.utils.Assert;
import cn.com.poc.common.utils.UUIDTool;
import cn.com.yict.framemax.core.config.Config;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.frame.service.FmxParamConfigService;
import com.baidubce.auth.BceCredentials;
import com.baidubce.auth.DefaultBceCredentials;
......
......@@ -4,7 +4,7 @@ import cn.com.poc.common.constant.RedisKeyConstant;
import cn.com.poc.common.service.JudgeCodeService;
import cn.com.poc.common.service.RedisService;
import cn.com.poc.common.utils.UUIDTool;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
......@@ -16,13 +16,13 @@ public class JudgeCodeServiceImpl implements JudgeCodeService {
@Resource
private RedisService redisService;
@Override
public boolean judgeCode(String account, String code) throws BusinessException {
public boolean judgeCode(String account, String code) throws Exception {
//验证次数
String accountKey = "JUDGE_CODE_COUNT:" + account;
//校验校验验证码:从redis获取发送的验证码
String mobileCode = (String) redisService.get(account);
if (StringUtils.isEmpty(mobileCode)) {
throw new BusinessException("验证码已过期,请重新获取");
throw new I18nMessageException("exception/verification.code.has.expired.please.obtain.it.again");
}
// 防止撞库攻击
......@@ -32,7 +32,7 @@ public class JudgeCodeServiceImpl implements JudgeCodeService {
//如果没有验证过
int verifyCount = Integer.parseInt(String.valueOf(redisService.get(accountKey)));
if (verifyCount > 5) {
throw new BusinessException("验证次数已达上限");
throw new I18nMessageException("exception/maximum.number.of.verifications.has.been.reached");
}
//验证次数自增
verifyCount++;
......@@ -49,7 +49,7 @@ public class JudgeCodeServiceImpl implements JudgeCodeService {
}
@Override
public String judgeCodeReturnAuthCode(String account, String code) throws BusinessException {
public String judgeCodeReturnAuthCode(String account, String code) throws Exception {
//验证验证码是否正确
if (!judgeCode(account, code)) {
return StringUtils.EMPTY;
......
......@@ -2,7 +2,7 @@ package cn.com.poc.common.service.impl;
import cn.com.poc.common.service.RedisService;
import cn.com.poc.common.utils.JsonUtils;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -39,7 +39,7 @@ public class RedisServiceImpl implements RedisService {
return true;
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -151,7 +151,7 @@ public class RedisServiceImpl implements RedisService {
return true;
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -174,7 +174,7 @@ public class RedisServiceImpl implements RedisService {
return true;
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -194,7 +194,7 @@ public class RedisServiceImpl implements RedisService {
return redisTemplate.opsForValue().increment(key, delta);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -214,7 +214,7 @@ public class RedisServiceImpl implements RedisService {
return redisTemplate.opsForValue().increment(key, -delta);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
/****************** String end ****************/
......@@ -259,7 +259,7 @@ public class RedisServiceImpl implements RedisService {
return true;
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -348,7 +348,7 @@ public class RedisServiceImpl implements RedisService {
return true;
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -367,7 +367,7 @@ public class RedisServiceImpl implements RedisService {
return true;
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -390,7 +390,7 @@ public class RedisServiceImpl implements RedisService {
return true;
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -406,7 +406,7 @@ public class RedisServiceImpl implements RedisService {
redisTemplate.opsForHash().delete(key, item);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -436,7 +436,7 @@ public class RedisServiceImpl implements RedisService {
return redisTemplate.opsForHash().increment(key, item, by);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -454,7 +454,7 @@ public class RedisServiceImpl implements RedisService {
return redisTemplate.opsForHash().increment(key, item, -by);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -511,7 +511,7 @@ public class RedisServiceImpl implements RedisService {
return redisTemplate.opsForSet().add(key, values);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -533,7 +533,7 @@ public class RedisServiceImpl implements RedisService {
return count;
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -569,7 +569,7 @@ public class RedisServiceImpl implements RedisService {
return count;
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -599,7 +599,7 @@ public class RedisServiceImpl implements RedisService {
return redisTemplate.opsForZSet().add(key, value, score);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -624,7 +624,7 @@ public class RedisServiceImpl implements RedisService {
return redisTemplate.opsForZSet().add(key, tuplesSet);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -642,7 +642,7 @@ public class RedisServiceImpl implements RedisService {
return redisTemplate.opsForZSet().remove(key, value);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -860,7 +860,7 @@ public class RedisServiceImpl implements RedisService {
return true;
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -882,7 +882,7 @@ public class RedisServiceImpl implements RedisService {
return true;
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -900,7 +900,7 @@ public class RedisServiceImpl implements RedisService {
return true;
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -922,7 +922,7 @@ public class RedisServiceImpl implements RedisService {
return true;
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -941,7 +941,7 @@ public class RedisServiceImpl implements RedisService {
return true;
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -960,7 +960,7 @@ public class RedisServiceImpl implements RedisService {
return remove;
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......
......@@ -5,7 +5,7 @@ import cn.com.poc.common.service.SendEmailService;
import cn.com.poc.common.utils.Assert;
import cn.com.poc.common.utils.DateUtils;
import cn.com.poc.common.utils.RandomCodeUtils;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.frame.entity.EmailSenderEntity;
import cn.com.yict.framemax.frame.service.EmailSenderService;
import cn.com.yict.framemax.frame.service.FmxParamConfigService;
......@@ -28,7 +28,7 @@ public class SendEmailServiceImpl implements SendEmailService {
@Override
public void sendEmailCode(String emailAddress) throws Exception {
Assert.notBlank(emailAddress, "用户登录,登录账号不能为空");
Assert.notBlank(emailAddress);
EmailSenderEntity entity = new EmailSenderEntity();
String code = RandomCodeUtils.generateNumber(6);
......@@ -48,7 +48,7 @@ public class SendEmailServiceImpl implements SendEmailService {
emailSenderService.sendMail(entity, null);
redisService.set(emailAddress, code, 900);
} catch (Exception e) {
throw new BusinessException("验证码发送失败!请重试");
throw new I18nMessageException("exception/verification.code.sending.failed.please.try.again");
}
}
}
......@@ -4,7 +4,7 @@ import cn.com.poc.common.dto.SmsDto;
import cn.com.poc.common.service.RedisService;
import cn.com.poc.common.service.SmsService;
import cn.com.poc.support.sms.channel.baidu.BaiDuThirdPlatformService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -34,7 +34,7 @@ public class SmsServiceImpl implements SmsService {
// 如果成功发送,则把验证码存入redis当中,并设置五分钟的过期时间
redisService.set(phone, code, 300);
} else {
throw new BusinessException("验证码发送失败!请重试");
throw new I18nMessageException("验证码发送失败!请重试");
}
}
......
package cn.com.poc.common.utils;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.hutool.core.io.FileUtil;
import org.apache.pdfbox.io.RandomAccessBufferedFileInputStream;
import org.apache.pdfbox.pdfparser.PDFParser;
......@@ -39,10 +39,10 @@ public class DocumentLoad {
case "txt":
return loadTxt(file);
default:
throw new BusinessException(type + " format is not yet supported");
throw new I18nMessageException(type + " format is not yet supported");
}
} catch (IOException e) {
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......
......@@ -14,7 +14,7 @@ public class GeneratingSnUtils {
private static Logger logger = LoggerFactory.getLogger(GeneratingSnUtils.class);
public static List<String> batchGenerationSn(BizSnRedisKeyEnum bizType, Integer qty) {
Assert.notNull(bizType, "生成业务类型不能为空!");
Assert.notNull(bizType);
qty = qty != null ? qty : 1;
......
......@@ -2,7 +2,7 @@ package cn.com.poc.common.utils;
import cn.com.poc.common.entity.oss.ImageUrl;
import cn.com.yict.framemax.core.config.Config;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.frame.service.FmxParamConfigService;
import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSSClient;
......@@ -54,7 +54,7 @@ public class OssUtils {
imageUrl = uploadFileToOss(content, uploadFolder, fileType);
if (imageUrl.getImageUrls().size() == 0) {
throw new BusinessException("Please select a file to upload");
throw new I18nMessageException("exception/upload.exception.please.check.the.file.before.uploading.again");
}
Optional.ofNullable(imageUrl).map(ImageUrl::getImageUrls).ifPresent(urls -> {
url.append(urls.get(0));
......@@ -67,7 +67,7 @@ public class OssUtils {
//
//
// } else {
// throw new BusinessException("调用上传阿里云图片异常!");
// throw new I18nMessageException("调用上传阿里云图片异常!");
// }
return url.toString();
......@@ -220,7 +220,7 @@ public class OssUtils {
e.printStackTrace();
}
if (content == null) {
throw new BusinessException("不能从该url中读取到数据");
throw new I18nMessageException("exception/cannot.read.data.from.this.url");
}
logger.info("size:" + content.length);
......
package cn.com.poc.common.utils;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -59,15 +59,15 @@ public class SignUtil {
//计算签名
logger.info("sign:{},appSecret:{},timestamp:{},api:{}", sign, appSecret, timestamp, api);
if (!sign(appSecret, timestamp, api).equals(sign)) {
throw new BusinessException("Failure to verify signature");
throw new I18nMessageException("exception/error.signature");
}
//匹对时间戳是否超过签名有效时间
long s = (System.currentTimeMillis() - Long.parseLong(timestamp)) / (1000 * 60);
if (s < -1L) {
throw new BusinessException("timestamp error");
throw new I18nMessageException("exception/signature.validity.time.exception");
}
if (s > 5L) {
throw new BusinessException("Expired sign");
throw new I18nMessageException("exception/signature.has.expired");
}
return true;
}
......
......@@ -29,7 +29,7 @@ import cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelResp
import cn.com.poc.thirdparty.resource.demand.ai.function.LargeModelFunctionEnum;
import cn.com.poc.thirdparty.resource.demand.ai.function.value_memory.GetValueMemory;
import cn.com.poc.thirdparty.service.LLMService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.data.model.PagingInfo;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.type.TypeReference;
......@@ -83,14 +83,14 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
if (userBaseEntity == null) {
throw new BusinessException("用户未登录");
throw new I18nMessageException("exception/user.not.login");
}
try {
BizAgentApplicationPublishEntity infoEntity = bizAgentApplicationPublishService.getByAgentId(agentId);
if (infoEntity == null) {
logger.warn("can not find agent application , agent_id:{}", agentId);
throw new BusinessException("未找到应用");
throw new I18nMessageException("exception/app.not.found");
}
if (StringUtils.isBlank(dialogsId)) {
......@@ -137,7 +137,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
outputRecord.setContent(output);
bizAgentApplicationDialoguesRecordService.save(outputRecord);
} catch (Exception e) {
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
}
}
......@@ -146,7 +146,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
public List<String> createContinueQuestions(String input) {
BizAgentApplicationGcConfigEntity configEntity = bizAgentApplicationGcConfigService.getByConfigCode(AgentApplicationGCConfigConstants.AGENT_CONTINUE_QUESTIONS);
if (null == configEntity) {
throw new BusinessException("创建[开场白]配置不存在");
throw new I18nMessageException("exception/create.[opening.statement].configuration.does.not.exist");
}
......@@ -226,7 +226,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
LargeModelDemandResult largeModelDemandResult = llmService.chat(largeModelResponse);
if (largeModelResponse == null || !"0".equals(largeModelDemandResult.getCode())) {
throw new BusinessException("生成推荐问题失败");
throw new I18nMessageException("exception/failed.to.generate.recommendation.question");
}
String res = largeModelDemandResult.getMessage();
int start = res.lastIndexOf("[");
......
......@@ -20,7 +20,7 @@ import cn.com.poc.expose.aggregate.AgentApplicationService;
import cn.com.poc.expose.dto.*;
import cn.com.poc.expose.rest.AgentApplicationRest;
import cn.com.poc.support.security.oauth.entity.UserBaseEntity;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.data.model.PagingInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Component;
......@@ -58,7 +58,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
public List<UserCollectDto> getCollectedApplications(PagingInfo pagingInfo) {
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
if (userBaseEntity == null) {
throw new BusinessException("用户未登录");
throw new I18nMessageException("exception/user.not.login");
}
Long memberId = userBaseEntity.getUserId();
List<MemberCollectQueryItem> collectedApplications = agentApplicationService.getCollectedApplications(memberId, pagingInfo);
......@@ -117,7 +117,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
Assert.notBlank(agentId, "应用ID不能为空");
BizAgentApplicationPublishEntity entity = bizAgentApplicationPublishService.getByAgentId(agentId);
if (entity == null) {
throw new BusinessException("应用不存在");
throw new I18nMessageException("exception/application.does.not.exist");
}
return BizAgentApplicationPublishConvert.entityToDto(entity);
}
......@@ -160,7 +160,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
public List<UserDialoguesDto> getUserDialogues() throws Exception {
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
if (userBaseEntity == null) {
throw new BusinessException("用户未登录");
throw new I18nMessageException("exception/user.not.login");
}
Long userId = userBaseEntity.getUserId();
List<UserDialoguesDto> result = new ArrayList<>();
......
......@@ -19,7 +19,7 @@ import cn.com.poc.support.security.oauth.entity.UserBaseEntity;
import cn.com.poc.thirdparty.resource.demand.ai.aggregate.DemandKnowledgeService;
import cn.com.poc.thirdparty.resource.demand.ai.entity.knowledge.GetKnowledgeChunkInfoResult;
import cn.com.poc.thirdparty.resource.demand.ai.entity.knowledge.SegmentationConfigRequest;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.data.model.PagingInfo;
import cn.hutool.core.bean.BeanUtil;
import com.fasterxml.jackson.core.type.TypeReference;
......@@ -81,18 +81,18 @@ public class KnowledgeServiceImpl implements KnowledgeService {
long fileSizeInBytes = file.length();
double fileSizeInMB = (double) fileSizeInBytes / (1024 * 1024);
if (fileSizeInMB > 10) {
throw new BusinessException("上传的文件不能超过10M,文件名:" + documentName);
throw new I18nMessageException("上传的文件不能超过10M,文件名:" + documentName);
}
String fileContent = DocumentLoad.documentToText(file).replaceAll(StringUtils.LF, StringUtils.EMPTY).replaceAll(StringUtils.CR, StringUtils.EMPTY);//文件内容
if (StringUtils.isBlank(fileContent)) {
throw new BusinessException("错误的文件,文件内容不能为空,文件名: " + documentName);
throw new I18nMessageException("错误的文件,文件内容不能为空,文件名: " + documentName);
}
//获取文件字符数
long charCount = fileContent.length();
//文件字符数不能超过100w
if (charCount > 100 * 10000) {
throw new BusinessException("文件内容字符数不能超过100w,文件名: " + documentName);
throw new I18nMessageException("文件内容字符数不能超过100w,文件名: " + documentName);
}
//文件上传
......@@ -129,7 +129,7 @@ public class KnowledgeServiceImpl implements KnowledgeService {
@Override
public Boolean delDocument(Integer knowledgeInfoId, Integer kdId) {
Assert.notNull(kdId, "kdId cannot be null");
Assert.notNull(kdId);
bizKnowledgeDocumentService.deleted(kdId);
bizMemberKnowledgeRelationService.deletedByKdId(kdId);
bizKnowledgeInfoService.removeDocument(knowledgeInfoId, kdId);
......@@ -142,7 +142,7 @@ public class KnowledgeServiceImpl implements KnowledgeService {
Assert.notBlank(rename);
BizKnowledgeDocumentEntity bizKnowledgeDocumentEntity = bizKnowledgeDocumentService.get(kdId);
if (bizKnowledgeDocumentEntity == null) {
throw new BusinessException("document not exist");
throw new I18nMessageException("exception/document.does.not.exist");
}
bizKnowledgeDocumentEntity.setDocumentName(rename);
bizKnowledgeDocumentService.update(kdId, bizKnowledgeDocumentEntity);
......@@ -153,7 +153,7 @@ public class KnowledgeServiceImpl implements KnowledgeService {
public String enableKnowledge(Integer kdId) throws Exception {
BizKnowledgeDocumentEntity bizKnowledgeDocumentEntity = bizKnowledgeDocumentService.get(kdId);
if (bizKnowledgeDocumentEntity == null) {
throw new BusinessException("document not exist");
throw new I18nMessageException("exception/document.does.not.exist");
}
String isEnable = bizKnowledgeDocumentEntity.getIsEnable();
......@@ -172,7 +172,7 @@ public class KnowledgeServiceImpl implements KnowledgeService {
Assert.isTrue(kdIds.size() <= 5, "Training cannot exceed five documents");
BizKnowledgeInfoEntity knowledgeInfoEntity = bizKnowledgeInfoService.get(knowledgeInfoId);
if (knowledgeInfoEntity == null) {
throw new BusinessException("Knowledge information does not exist");
throw new I18nMessageException("exception/knowledge.base.information.does.not.exist");
}
for (Integer kdId : kdIds) {
......@@ -181,7 +181,7 @@ public class KnowledgeServiceImpl implements KnowledgeService {
if (KnowledgeConstant.TrainStatus.COMPLETE.equals(currentStatus) ||
KnowledgeConstant.TrainStatus.LINE.equals(currentStatus) ||
KnowledgeConstant.TrainStatus.TRAINING.equals(currentStatus)) {
throw new BusinessException("No repetitive training");
throw new I18nMessageException("exception/repetitive.training.in.the.knowledge.base");
}
bizKnowledgeDocumentEntity.setTrainStatus(KnowledgeConstant.TrainStatus.LINE);
......@@ -256,7 +256,7 @@ public class KnowledgeServiceImpl implements KnowledgeService {
public void openKnowledgeChunk(Integer kdId, String chunkRelationId, String isOpen) {
BizKnowledgeDocumentEntity bizKnowledgeDocumentEntity = bizKnowledgeDocumentService.get(kdId);
if (bizKnowledgeDocumentEntity == null) {
throw new BusinessException("The knowledge does not exist");
throw new I18nMessageException("exception/knowledge.base.does.not.exist");
}
String knowledgeId = bizKnowledgeDocumentEntity.getKnowledgeId();
demandKnowledgeService.openKnowledgeChunk(knowledgeId, chunkRelationId, isOpen);
......@@ -266,7 +266,7 @@ public class KnowledgeServiceImpl implements KnowledgeService {
public void deleteKnowledgeChunk(Integer kdId, String chunkRelationId) {
BizKnowledgeDocumentEntity bizKnowledgeDocumentEntity = bizKnowledgeDocumentService.get(kdId);
if (bizKnowledgeDocumentEntity == null) {
throw new BusinessException("The knowledge does not exist");
throw new I18nMessageException("exception/knowledge.base.does.not.exist");
}
String knowledgeId = bizKnowledgeDocumentEntity.getKnowledgeId();
demandKnowledgeService.deleteKnowledgeChunk(knowledgeId, chunkRelationId);
......@@ -276,7 +276,7 @@ public class KnowledgeServiceImpl implements KnowledgeService {
public void updateKnowledgeChunkDoc(Integer kdId, String chunkRelationId, String content) {
BizKnowledgeDocumentEntity bizKnowledgeDocumentEntity = bizKnowledgeDocumentService.get(kdId);
if (bizKnowledgeDocumentEntity == null) {
throw new BusinessException("The knowledge does not exist");
throw new I18nMessageException("exception/knowledge.base.does.not.exist");
}
String knowledgeId = bizKnowledgeDocumentEntity.getKnowledgeId();
demandKnowledgeService.updateKnowledgeChunkDoc(knowledgeId, chunkRelationId, content);
......@@ -286,7 +286,7 @@ public class KnowledgeServiceImpl implements KnowledgeService {
public void addKnowledgeChunk(Integer kdId, String content, Integer chunkSort) {
BizKnowledgeDocumentEntity bizKnowledgeDocumentEntity = bizKnowledgeDocumentService.get(kdId);
if (bizKnowledgeDocumentEntity == null) {
throw new BusinessException("The knowledge does not exist");
throw new I18nMessageException("exception/knowledge.base.does.not.exist");
}
String knowledgeId = bizKnowledgeDocumentEntity.getKnowledgeId();
demandKnowledgeService.addKnowledgeChunk(knowledgeId, content, chunkSort);
......
......@@ -18,7 +18,7 @@ import cn.com.poc.knowledge.service.BizKnowledgeDocumentService;
import cn.com.poc.knowledge.service.BizKnowledgeInfoService;
import cn.com.poc.support.security.oauth.entity.UserBaseEntity;
import cn.com.poc.thirdparty.resource.demand.ai.entity.knowledge.GetKnowledgeChunkInfoResult;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.data.model.PagingInfo;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Assert;
......@@ -45,7 +45,7 @@ public class KnowledgeRestImpl implements KnowledgeRest {
@Override
public List<BizKnowledgeDocumentDto> uploadDocument(MultipartFile[] documentFiles) throws Exception {
Assert.notEmpty(documentFiles);
Assert.isTrue(documentFiles.length <= 5, "Uploaded files can be no larger than five");
Assert.isTrue(documentFiles.length <= 5);
List<BizKnowledgeDocumentEntity> entities = knowledgeService.uploadDocument(documentFiles);
List<BizKnowledgeDocumentDto> result = entities.stream().map(entity -> {
BizKnowledgeDocumentDto dto = new BizKnowledgeDocumentDto();
......@@ -103,7 +103,7 @@ public class KnowledgeRestImpl implements KnowledgeRest {
BizKnowledgeInfoEntity bizKnowledgeInfoEntity = bizKnowledgeInfoService.get(knowledgeInfoId);
if (bizKnowledgeInfoEntity == null) {
throw new BusinessException("知识库不存在");
throw new I18nMessageException("exception/knowledge.base.does.not.exist");
}
String kdIds = bizKnowledgeInfoEntity.getKdIds();
if (StringUtils.isBlank(kdIds)) {
......@@ -133,7 +133,7 @@ public class KnowledgeRestImpl implements KnowledgeRest {
Assert.notNull(knowledgeInfoId);
BizKnowledgeInfoEntity bizKnowledgeInfoEntity = bizKnowledgeInfoService.get(knowledgeInfoId);
if (bizKnowledgeInfoEntity == null) {
throw new BusinessException("知识库不存在");
throw new I18nMessageException("exception/knowledge.base.does.not.exist");
}
List<BizKnowledgeDocumentDto> res = new ArrayList<>();
String kdIds = bizKnowledgeInfoEntity.getKdIds();
......
......@@ -26,7 +26,7 @@ public class BizMemberKnowledgeRelationServiceImpl extends BaseServiceImpl
@Override
public BizMemberKnowledgeRelationEntity get(Integer id) throws Exception {
Assert.notNull(id, "id cant be null");
Assert.notNull(id);
BizMemberKnowledgeRelationModel model = this.repository.get(id);
return MemberKnowledgeRelationConvert.modelToEntity(model);
}
......
......@@ -18,7 +18,7 @@ import cn.com.poc.message.service.KnowledgeProducerService;
import cn.com.poc.message.topic.KnowledgeTopic;
import cn.com.poc.thirdparty.resource.demand.ai.aggregate.DemandKnowledgeService;
import cn.com.poc.thirdparty.resource.demand.ai.constants.KnowledgeTrainStatusConstant;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.tumbleweed.client.annotation.Consumer;
import com.alibaba.fastjson.TypeReference;
import org.slf4j.Logger;
......
......@@ -10,7 +10,7 @@ import cn.com.poc.support.dgTools.request.ProjectTokenRequest;
import cn.com.poc.support.dgTools.result.AbstractResult;
import cn.com.poc.support.dgTools.result.DgtoolsApiResult;
import cn.com.poc.support.dgTools.utils.AesEncodeUtil;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.data.model.PagingInfo;
import cn.com.yict.framemax.frame.service.FmxParamConfigService;
import com.alibaba.fastjson.JSON;
......@@ -85,12 +85,12 @@ public class DgtoolsAbstractHttpClient {
String privateKey = paramConfigMap.get(FmxParamConfigConstant.Dgtools.PRIVATE_KEY);
if (StringUtils.isEmpty(privateKey)) {
throw new BusinessException("营销中台配置项目私钥为空");
throw new I18nMessageException("exception/private.key.of.the.marketing.platform.configuration.project.is.empty");
}
String vi = paramConfigMap.get(FmxParamConfigConstant.Dgtools.VI);
if (StringUtils.isEmpty(vi)) {
throw new BusinessException("营销中台配置解密偏移量为空");
throw new I18nMessageException("exception/decryption.offset.of.the.marketing.platform.configuration.is.empty");
}
//生成请求实体
......@@ -124,12 +124,12 @@ public class DgtoolsAbstractHttpClient {
DgtoolsApiResult dgtoolsApiResult = LocalHttpClient.executeJsonResult(httpUriRequest, DgtoolsApiResult.class);
if (dgtoolsApiResult == null) {
throw new BusinessException("中台服务器无响应或响应超时!");
throw new I18nMessageException("exception/middle.server.is.unresponsive.or.has.timed.out");
}
if (!dgtoolsApiResult.isSuccess()) {
//调用服务超时 2000毫秒
throw new BusinessException(dgtoolsApiResult.getMessage());
throw new I18nMessageException(dgtoolsApiResult.getMessage());
}
if (dgtoolsApiResult.getPagingInfo() != null) {
pagingInfo.setTotalRows(dgtoolsApiResult.getPagingInfo().getTotalRows());
......@@ -154,12 +154,12 @@ public class DgtoolsAbstractHttpClient {
String privateKey = paramConfigMap.get(FmxParamConfigConstant.Dgtools.PRIVATE_KEY);
if (StringUtils.isEmpty(privateKey)) {
throw new BusinessException("营销中台配置项目私钥为空");
throw new I18nMessageException("exception/private.key.of.the.marketing.platform.configuration.project.is.empty");
}
String vi = paramConfigMap.get(FmxParamConfigConstant.Dgtools.VI);
if (StringUtils.isEmpty(vi)) {
throw new BusinessException("营销中台配置解密偏移量为空");
throw new I18nMessageException("exception/decryption.offset.of.the.marketing.platform.configuration.is.empty");
}
//生成请求实体
......
......@@ -8,7 +8,7 @@ import cn.com.poc.support.dgTools.constants.DgtoolsApiConstants;
import cn.com.poc.support.dgTools.request.ProjectTokenRequest;
import cn.com.poc.support.dgTools.result.ProjectTokenResult;
import cn.com.poc.support.dgTools.service.AuthorizationService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.frame.service.FmxParamConfigService;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.Header;
......@@ -40,11 +40,11 @@ public class AuthorizationServiceImpl implements AuthorizationService {
Map<String, String> paramConfigMap = getParamConfigMap();
String projectKey = paramConfigMap.get(FmxParamConfigConstant.Dgtools.PROJECT_KEY);
if (StringUtils.isEmpty(projectKey)) {
throw new BusinessException("营销中台配置项目key为空");
throw new I18nMessageException("exception/key.for.the.marketing.platform.configuration.project.is.empty");
}
String projectSecret = paramConfigMap.get(FmxParamConfigConstant.Dgtools.PROJECT_SECRET);
if (StringUtils.isEmpty(projectSecret)) {
throw new BusinessException("营销中台配置项目密钥为空");
throw new I18nMessageException("exception/secret.for.the.marketing.platform.configuration.project.is.empty");
}
ProjectTokenRequest request = new ProjectTokenRequest();
......@@ -71,7 +71,7 @@ public class AuthorizationServiceImpl implements AuthorizationService {
} else {
appToken = applicationAuthorization();
if (StringUtils.isEmpty(appToken)) {
throw new BusinessException("获取兴海appToken失败");
throw new I18nMessageException("exception/failed.to.obtain.xinghai.apptoken");
}
redisService.set(dgtoolsAppToken, appToken, 60 * 60 * 24 * 7 - 1000);
return appToken;
......
......@@ -3,7 +3,7 @@ package cn.com.poc.support.login;
import cn.com.poc.common.constant.Member3ptLoginChannel;
import cn.com.poc.support.login.channel.bl.IBTAuthService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
......@@ -21,7 +21,7 @@ public class ThirdPlatformAuthServiceBuilder implements ApplicationContextAware
return applicationContext.getBean(IBTAuthService.class);
}
throw new BusinessException("第三方授权渠道异常!");
throw new I18nMessageException("第三方授权渠道异常!");
}
@Override
......
......@@ -3,7 +3,7 @@ package cn.com.poc.support.login;
import cn.com.poc.common.constant.Member3ptLoginChannel;
import cn.com.poc.support.login.channel.bl.IBTLoginService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
......@@ -20,7 +20,7 @@ public class ThirdPlatformLoginServiceBuilder implements ApplicationContextAware
if (Member3ptLoginChannel.ibt.equals(channel)) {
return applicationContext.getBean(IBTLoginService.class);
}
throw new BusinessException("第三方登录渠道异常");
throw new I18nMessageException("exception/third.party.login.channel.abnormality");
}
@Override
......
......@@ -4,7 +4,7 @@ package cn.com.poc.support.login.channel;
import cn.com.poc.support.login.ThirdPlatformLoginService;
import cn.com.poc.support.login.domain.AuthInfo;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
......@@ -22,6 +22,6 @@ public class DefaultLoginService implements ThirdPlatformLoginService {
*/
@Override
public Object doLogin(AuthInfo authInfo) throws Exception {
throw new BusinessException("暂不支持默认登录渠道登录!");
throw new I18nMessageException("exception/default.login.channel.login.is.currently.not.supported");
}
}
\ No newline at end of file
......@@ -4,7 +4,7 @@
//import cn.com.blo.common.constant.Member3ptRegisterChannel;
//import cn.com.blo.support.register.channel.bl.BlMobileRegisterService;
//import cn.com.blo.support.register.channel.bl.BlWxMiniRegisterService;
//import cn.com.yict.framemax.core.exception.BusinessException;
//import cn.com.yict.framemax.core.i18n.I18nMessageException;
//import org.springframework.beans.BeansException;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.ApplicationContextAware;
......@@ -27,7 +27,7 @@
// return applicationContext.getBean(BlMobileRegisterService.class);
// }
//
// throw new BusinessException("注册渠道异常");
// throw new I18nMessageException("注册渠道异常");
// }
//
// @Override
......
......@@ -3,7 +3,7 @@
//
//import cn.com.blo.support.register.ThirdPlatformRegisterService;
//import cn.com.blo.user.dto.MemberInfoDto;
//import cn.com.yict.framemax.core.exception.BusinessException;
//import cn.com.yict.framemax.core.i18n.I18nMessageException;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Service;
......@@ -21,6 +21,6 @@
// */
// @Override
// public MemberInfoDto doRegister(MemberInfoDto memberInfoDto) throws Exception {
// throw new BusinessException("暂无默认注册渠道登录!");
// throw new I18nMessageException("暂无默认注册渠道登录!");
// }
//}
......@@ -20,7 +20,7 @@
//import cn.com.blo.user.service.BizMember3rdPartyRelationService;
//import cn.com.blo.user.service.BizMemberInfoService;
//import cn.com.gsst.marketing.tools.service.RedisService;
//import cn.com.yict.framemax.core.exception.BusinessException;
//import cn.com.yict.framemax.core.i18n.I18nMessageException;
//import org.apache.commons.lang3.StringUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
......@@ -75,7 +75,7 @@
// || StringUtils.isBlank(blThirdPartyConfig.getAppSecret())
// || StringUtils.isBlank(blThirdPartyConfig.getChannelIdWechat())
// || StringUtils.isBlank(blThirdPartyConfig.getSysId())) {
// throw new BusinessException("百联通开放平台配置异常!");
// throw new I18nMessageException("百联通开放平台配置异常!");
// }
//
// //调百联通手机号注册接口
......
......@@ -24,7 +24,7 @@
//import cn.com.blo.wx.entity.BizWxAppInfo;
//import cn.com.blo.wx.service.BizWxAppInfoService;
//import cn.com.gsst.marketing.tools.service.RedisService;
//import cn.com.yict.framemax.core.exception.BusinessException;
//import cn.com.yict.framemax.core.i18n.I18nMessageException;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.BeanUtils;
......@@ -74,7 +74,7 @@
//
// BizWxAppInfo wxAppInfo = bizWxAppInfoService.getBySceneCode(BloWxAppSceneCodeConstant.BLO_MINI);
// if (wxAppInfo == null) {
// throw new BusinessException("获取小程序信息异常!请检查配置是否正确!");
// throw new I18nMessageException("获取小程序信息异常!请检查配置是否正确!");
// }
//
// //查询配置
......@@ -84,7 +84,7 @@
// || StringUtils.isBlank(blThirdPartyConfig.getAppSecret())
// || StringUtils.isBlank(blThirdPartyConfig.getThirdPartyIdTypeMini())
// || StringUtils.isBlank(blThirdPartyConfig.getSysId())) {
// throw new BusinessException("百联通开放平台配置异常!");
// throw new I18nMessageException("百联通开放平台配置异常!");
// }
//
// //调百联小程序注册接口
......
package cn.com.poc.support.security.oauth;
import cn.com.poc.common.constant.FmxParamConfigConstant;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.frame.service.FmxParamConfigService;
import cn.com.yict.framemax.security.oauth.OauthTokenOperator;
import cn.com.yict.framemax.security.oauth.entity.OauthTokenEntity;
......@@ -27,10 +27,10 @@ public class MultiDomainOauthTokenOperatorImplementor extends OauthTokenOperator
@Override
public OauthTokenEntity genOauthToken(String user) {
if (fmxParamConfigService.getConfig(FmxParamConfigConstant.TOKEN_EXPIRED_HOURS) == null) {
throw new BusinessException("登录过期时间配置为空!");
throw new I18nMessageException("exception/login.expiration.time.configured.as.empty");
}
super.tokenExpiredHours = Long.valueOf(fmxParamConfigService.getConfig(FmxParamConfigConstant.TOKEN_EXPIRED_HOURS).getParamValue());
Assert.hasText(user, "user is required");
Assert.hasText(user);
TokenEntity oauthToken = super.newBaseOauthToken(user, null);
TokenEntity refreshToken = super.newBaseRefreshToken(user);
oauthToken.setToken1(refreshToken.getToken());
......
......@@ -8,7 +8,7 @@ import cn.com.poc.support.security.oauth.constants.OauthConstants;
import cn.com.poc.support.security.oauth.entity.OpenPlatformEntity;
import cn.com.poc.user.entity.MemberInfoEntity;
import cn.com.poc.user.service.BizMemberInfoService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.data.model.UserBaseModel;
import cn.com.yict.framemax.frame.entity.UserSessionEntity;
import cn.com.yict.framemax.frame.model.FmxRoleModel;
......@@ -79,7 +79,7 @@ public class MultiDomainOauthUserManagerImplementor extends OauthUserManagerImpl
securityToken = new SecurityAuthenticationToken(response, null, null);
}
} catch (Exception e) {
throw new BusinessException(((BusinessException) e).getErrorCode(), e.getMessage());
throw new I18nMessageException(e.getMessage());
}
return securityToken;
}
......
......@@ -3,7 +3,7 @@ package cn.com.poc.support.sms;
import cn.com.poc.support.sms.constant.SmsConstant;
import cn.com.poc.support.sms.channel.baidu.BaiDuThirdPlatformService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
......@@ -24,7 +24,7 @@ public class ThirdPlatformSmsServiceBuilder implements ApplicationContextAware {
return applicationContext.getBean(BaiDuThirdPlatformService.class);
}
throw new BusinessException("验证码渠道异常");
throw new I18nMessageException("exception/verification.code.channel.abnormality");
}
@Override
......
......@@ -3,7 +3,7 @@ package cn.com.poc.support.sms.channel;
import cn.com.poc.common.dto.SmsDto;
import cn.com.poc.support.sms.ThirdPlatformSmsService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
......@@ -24,6 +24,6 @@ public class DefaultSmsService implements ThirdPlatformSmsService {
*/
@Override
public boolean doSend(SmsDto smsDto) throws Exception {
throw new BusinessException("暂无默认验证码渠道登录!");
throw new I18nMessageException("exception/there.is.currently.no.default.verification.code.channel.login");
}
}
......@@ -5,7 +5,7 @@
//import cn.com.poc.support.sms.constant.SmsConstant;
//import cn.com.poc.common.dto.SmsDto;
//import cn.com.poc.support.sms.ThirdPlatformSmsService;
//import cn.com.yict.framemax.core.exception.BusinessException;
//import cn.com.yict.framemax.core.i18n.I18nMessageException;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Service;
......@@ -41,7 +41,7 @@
// || StringUtils.isBlank(blThirdPartyConfig.getAppKey())
// || StringUtils.isBlank(blThirdPartyConfig.getAppSecret())
// || StringUtils.isBlank(blThirdPartyConfig.getSysId())) {
// throw new BusinessException("百联通开放平台配置异常!");
// throw new I18nMessageException("百联通开放平台配置异常!");
// }
//
// //调百联通手机号注册接口
......@@ -71,7 +71,7 @@
// // OPERATING_FREQUENCY("5","操作过于频繁,请稍后再试!"),
// // VERIFY_CODE_FAIL("6","验证码错误")
// if (!SmsConstant.Status.BL.SEND_CODE_SUCCESS.getCode().equals(blMemberAuthResult.getStatus())) {
// throw new BusinessException(SmsConstant.Status.BL.getByStatus(blMemberAuthResult.getStatus()), blMemberAuthResult.getMsg());
// throw new I18nMessageException(SmsConstant.Status.BL.getByStatus(blMemberAuthResult.getStatus()), blMemberAuthResult.getMsg());
// }
//
// }
......
......@@ -5,7 +5,7 @@ import cn.com.poc.thirdparty.resource.baidu.api.BaiduTokenAPI;
import cn.com.poc.thirdparty.resource.baidu.entity.result.BaiduTokenResult;
import cn.com.poc.thirdparty.resource.baidu.service.BaiduTokenService;
import cn.com.yict.framemax.core.config.Config;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
......@@ -32,7 +32,7 @@ public class BaiduTokenServiceImpl implements BaiduTokenService {
if (null == redisService.get(BAIDU_AI_CUSTOM_TOKEN)) {
BaiduTokenResult token = baiduTokenApi.getToken(ACCESS_KEY_ID, SECRET_ACCESS_KEY);
if (StringUtils.isNoneBlank(token.getError())) {
throw new BusinessException("获取百度token失败");
throw new I18nMessageException("exception/failed.to.obtain.baidu.token");
}
redisService.set(BAIDU_AI_CUSTOM_TOKEN, token.getAccess_token(), token.getExpires_in());
}
......
......@@ -8,7 +8,7 @@ import cn.com.poc.thirdparty.resource.baidu.entity.response.BaiduTextTransRespon
import cn.com.poc.thirdparty.resource.baidu.entity.result.textTrans.BaiduTextTransResult;
import cn.com.poc.thirdparty.resource.baidu.service.BaiduTokenService;
import cn.com.poc.thirdparty.resource.baidu.service.BaiduTransService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
......@@ -34,7 +34,7 @@ public class BaiduTransServiceImpl implements BaiduTransService {
public String textTrans(String sourceText, String sourceLanguage, String targetLanguage) {
Assert.notBlank(sourceText);
Assert.notBlank(targetLanguage);
Assert.isTrue(BaiduTransTypeConstants.Utils.isExist(targetLanguage), "trans type is not exist");
Assert.isTrue(BaiduTransTypeConstants.Utils.isExist(targetLanguage));
sourceText = sourceText.replaceAll(StringUtils.LF, StringUtils.SPACE);
String token = baiduTokenService.getToken();
......@@ -45,7 +45,7 @@ public class BaiduTransServiceImpl implements BaiduTransService {
BaiduTextTransResult baiduTextTransResult = baiduTransApi.textTrans(token, response);
if (baiduTextTransResult.getError_code() != null) {
logger.warn("baidu translation error_code:{}, error_msg:{}", baiduTextTransResult.getError_code(), baiduTextTransResult.getError_msg());
throw new BusinessException("Translation failed. Please contact your system administrator");
throw new I18nMessageException("exception/training.exception.please.contact.the.administrator");
}
return baiduTextTransResult.getResult().getTrans_result().get(0).getDst();
}
......@@ -54,7 +54,7 @@ public class BaiduTransServiceImpl implements BaiduTransService {
public BaiduTextTransResult textTransDict(String sourceText, String sourceLanguage, String targetLanguage) {
Assert.notBlank(sourceText);
Assert.notBlank(targetLanguage);
Assert.isTrue(BaiduTransTypeConstants.Utils.isExist(sourceLanguage), "trans type is not exist");
Assert.isTrue(BaiduTransTypeConstants.Utils.isExist(sourceLanguage));
sourceText = sourceText.replaceAll(StringUtils.LF, StringUtils.SPACE);
String token = baiduTokenService.getToken();
......@@ -65,7 +65,7 @@ public class BaiduTransServiceImpl implements BaiduTransService {
BaiduTextTransResult baiduTextTransResult = baiduTransApi.textTrans(token, response);
if (baiduTextTransResult.getError_code() != null) {
logger.warn("baidu translation error_code:{}, error_msg:{}", baiduTextTransResult.getError_code(), baiduTextTransResult.getError_msg());
throw new BusinessException("Translation failed. Please contact your system administrator");
throw new I18nMessageException("exception/training.exception.please.contact.the.administrator");
}
return baiduTextTransResult;
}
......
......@@ -9,7 +9,7 @@ import cn.com.poc.thirdparty.resource.demand.ai.entity.generations.*;
import cn.com.poc.thirdparty.resource.demand.member.service.DemandAuthService;
import cn.com.poc.support.dgTools.DgtoolsAbstractHttpClient;
import cn.com.poc.support.dgTools.constants.DgtoolsApiConstants;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections.CollectionUtils;
......@@ -158,7 +158,7 @@ public class AICreateImageServiceImpl implements AICreateImageService {
if (baiduGetImageV2Result != null) {
if (FAILED.equals(baiduGetImageV2Result.getData().getTaskStatus())) {
logger.error("-----------调用百度AI作图高级错误:{}-------------", JSONObject.toJSONString(baiduGetImageV2Result));
throw new BusinessException("生成图片失败");
throw new I18nMessageException("exception/image.generation.failed");
}
GenerationsResult generationsResult = new GenerationsResult();
List<SubTaskResult> subTaskResultList = baiduGetImageV2Result.getData().getSubTaskResultList();
......@@ -200,21 +200,21 @@ public class AICreateImageServiceImpl implements AICreateImageService {
headers.add(new BasicHeader(DgtoolsApiConstants.HEADER_X_PLATFORM_AUTHORIZATION, demandAuthService.getToken()));
BaiduAISailsText2ImageResult imageResult = dgToolsAbstractHttpClient.doRequest(DgtoolsApiConstants.DgtoolsAI.AI_BAIDU_SAILS_TEXT_CREATE_IMAGE, request, headers);
if (imageResult == null) {
throw new BusinessException("中台无响应,请联系开发人员");
throw new I18nMessageException("exception/middle.platform.is.unresponsive");
}
if (StringUtils.isNotBlank(imageResult.getErrorMsg())) {
logger.error("调用中台百度千帆大模型错误,错误信息:{}", JSONObject.toJSONString(imageResult));
throw new BusinessException(imageResult.getErrorMsg());
throw new I18nMessageException(imageResult.getErrorMsg());
}
List<BaiduAISailsText2ImageDataItem> dataList = imageResult.getData();
if (CollectionUtils.isEmpty(dataList)) {
throw new BusinessException("中台无响应,请联系开发人员");
throw new I18nMessageException("exception/middle.platform.is.unresponsive");
}
//上传到oss
for (BaiduAISailsText2ImageDataItem imageData : dataList) {
if (StringUtils.isBlank(imageData.getImageBase64())) {
throw new BusinessException("中台无响应,请联系开发人员");
throw new I18nMessageException("exception/middle.platform.is.unresponsive");
}
String url = bosConfigService.uploadImageByBase64(imageData.getImageBase64());
imageData.setUrl(url);
......@@ -245,7 +245,7 @@ public class AICreateImageServiceImpl implements AICreateImageService {
//非流
String responseBodyStr = EntityUtils.toString(httpResponse.getEntity());
if (StringUtils.isBlank(responseBodyStr)) {
throw new BusinessException("无响应,请联系开发人员");
throw new I18nMessageException("exception/no.response.please.contact.the.developer");
}
JSONObject jsonObject = JSONObject.parseObject(responseBodyStr);
Integer code = (Integer) jsonObject.get("code");
......@@ -253,7 +253,7 @@ public class AICreateImageServiceImpl implements AICreateImageService {
String data = jsonObject.getString("data");
return JSON.parseObject(data, BaiduAISailsImage2TextResult.class);
} else {
throw new BusinessException(jsonObject.getString("message"));
throw new I18nMessageException(jsonObject.getString("message"));
}
}
//流式
......@@ -302,7 +302,7 @@ public class AICreateImageServiceImpl implements AICreateImageService {
}
returnResult.setResult(completeResponse.toString());
} catch (Exception e) {
throw new BusinessException(e.getMessage());
throw new I18nMessageException(e.getMessage());
} finally {
//关闭资源
if (writer != null) {
......
......@@ -6,7 +6,7 @@ import cn.com.poc.support.dgTools.result.AbstractResult;
import cn.com.poc.thirdparty.resource.demand.ai.aggregate.DemandKnowledgeService;
import cn.com.poc.thirdparty.resource.demand.ai.entity.knowledge.*;
import cn.com.poc.thirdparty.resource.demand.member.service.DemandAuthService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.data.model.PagingInfo;
import cn.hutool.core.lang.Assert;
import org.apache.commons.collections4.CollectionUtils;
......@@ -35,7 +35,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
request.setSegmentationConfig(segmentationConfig);
TrainKnowledgeResult trainKnowledgeResult = dgToolsAbstractHttpClient.doRequest(DgtoolsApiConstants.DgtoolsAI.TRAIN_KNOWLEDGE, request, getHeaders());
if (null == trainKnowledgeResult) {
throw new BusinessException("train knowledge error");
throw new I18nMessageException("exception/abnormal.knowledge.base.training");
}
return trainKnowledgeResult.getKnowledgeId();
}
......@@ -48,7 +48,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
request.setSegmentationConfig(segmentationConfig);
TrainKnowledgeResult trainKnowledgeResult = dgToolsAbstractHttpClient.doRequest(DgtoolsApiConstants.DgtoolsAI.TRAIN_KNOWLEDGE_EVENT, request, getHeaders());
if (null == trainKnowledgeResult) {
throw new BusinessException("train knowledge error");
throw new I18nMessageException("exception/abnormal.knowledge.base.training");
}
return trainKnowledgeResult.getKnowledgeId();
}
......@@ -60,7 +60,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
request.setKnowledgeId(knowledgeId);
TrainKnowledgeStatusResult trainKnowledgeStatusResult = dgToolsAbstractHttpClient.doRequest(DgtoolsApiConstants.DgtoolsAI.TRAIN_KNOWLEDGE_STATUS, request, getHeaders());
if (null == trainKnowledgeStatusResult) {
throw new BusinessException("get knowledge train status error");
throw new I18nMessageException("exception/abnormal.training.status.of.knowledge.base.acquisition");
}
return trainKnowledgeStatusResult.getTrainStatus();
}
......@@ -72,7 +72,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
request.setKnowledgeId(knowledgeId);
AbstractResult abstractResult = dgToolsAbstractHttpClient.doRequest(DgtoolsApiConstants.DgtoolsAI.DEL_KNOWLEDGE, request, getHeaders());
if (null == abstractResult) {
throw new BusinessException("del knowledge error");
throw new I18nMessageException("exception/delete.knowledge.base.exception");
}
}
......@@ -91,7 +91,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
searchKnowledgeRequest.setTopK(topK);
SearchKnowledgeResult searchKnowledgeResult = dgToolsAbstractHttpClient.doRequest(DgtoolsApiConstants.DgtoolsAI.SEARCH_KNOWLEDGE, searchKnowledgeRequest, getHeaders());
if (null == searchKnowledgeResult) {
throw new BusinessException("search knowledge is error");
throw new I18nMessageException("exception/query.knowledge.base.exception");
}
return searchKnowledgeResult.getDocuments();
}
......
......@@ -5,7 +5,7 @@ import cn.com.poc.common.service.RedisService;
import cn.com.poc.common.utils.BlContext;
import cn.com.poc.common.utils.DateUtils;
import cn.com.poc.thirdparty.resource.demand.ai.function.AbstractLargeModelFunction;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.hutool.json.JSONObject;
import com.google.gson.Gson;
import com.sun.org.apache.regexp.internal.RE;
......@@ -84,6 +84,6 @@ public class SetLongMemoryFunction extends AbstractLargeModelFunction {
@Override
public List<String> getVariableStructureLLMConfig(List<Variable> variableStructure) {
throw new BusinessException("暂不支持变量结构配置");
throw new I18nMessageException("exception/variable.structure.configuration.is.not.currently.supported");
}
}
......@@ -5,7 +5,7 @@ import cn.com.poc.common.service.RedisService;
import cn.com.poc.common.utils.BlContext;
import cn.com.poc.common.utils.JsonUtils;
import cn.com.poc.thirdparty.resource.demand.ai.function.AbstractLargeModelFunction;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.hutool.json.JSONObject;
import com.google.gson.Gson;
import org.springframework.stereotype.Service;
......@@ -47,7 +47,7 @@ public class SetValueMemoryFunction extends AbstractLargeModelFunction {
@Override
public List<String> getLLMConfig() {
throw new BusinessException("不支持此方法");
throw new I18nMessageException("exception/this.method.is.not.supported");
}
@Override
......
......@@ -5,7 +5,7 @@ import cn.com.poc.thirdparty.resource.demand.member.api.DemandAuthApi;
import cn.com.poc.thirdparty.resource.demand.member.entity.DemandAuthResponse;
import cn.com.poc.thirdparty.resource.demand.member.entity.DemandAuthResult;
import cn.com.poc.thirdparty.resource.demand.member.service.DemandAuthService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.frame.service.FmxParamConfigService;
import cn.hutool.core.lang.Assert;
import org.slf4j.Logger;
......@@ -50,7 +50,7 @@ public class DemandAuthServiceImpl implements DemandAuthService {
response.setProjectSecret(projectSecret);
DemandAuthResult demandAuthResult = demandAuthApi.getToken(response);
if (demandAuthResult == null || demandAuthResult.getToken() == null) {
throw new BusinessException("获取token失败");
throw new I18nMessageException("exception/failed.to.obtain.token");
}
//计算过期时长
long now = System.currentTimeMillis() / 1000L;
......
......@@ -9,7 +9,7 @@ import cn.com.poc.user.entity.Member3rdPartyRelationEntity;
import cn.com.poc.user.entity.MemberInfoEntity;
import cn.com.poc.user.service.BizMember3rdPartyRelationService;
import cn.com.poc.user.service.BizMemberInfoService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Component;
......@@ -40,12 +40,12 @@ public class MemberInfoServiceImpl extends BaseServiceImpl implements MemberInfo
String authCode = (String) redisService.get(RedisKeyConstant.Code.AUTH_CODE + memberPasswordRequestDto.getAccount());
if (!memberPasswordRequestDto.getAuthCode().equals(authCode)) {
throw new BusinessException("请重新验证用户身份");
throw new I18nMessageException("exception/re-verify.the.user.identity");
}
MemberInfoEntity memberInfoEntity = bizMemberInfoService.getMemberEntityByAccount(memberPasswordRequestDto.getAccount());
if (memberInfoEntity == null) {
throw new BusinessException("找不到该用户");
throw new I18nMessageException("exception/user.cannot.be.found");
}
Member3rdPartyRelationEntity member3rdPartyRelationEntity = bizMember3rdPartyRelationService.getPwRelationByMemberId(memberInfoEntity.getMemberId());
......
......@@ -6,7 +6,7 @@ import cn.com.poc.common.utils.StringUtils;
import cn.com.poc.user.dto.MemberLoginRequestDto;
import cn.com.poc.user.entity.MemberInfoEntity;
import cn.com.poc.user.service.BizMemberInfoService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.data.model.BaseModel;
import cn.com.yict.framemax.frame.service.FmxParamConfigService;
import org.springframework.stereotype.Component;
......@@ -24,11 +24,11 @@ public class EmailLoginChannel implements LoginChannelService {
@Override
public BaseModel doLogin(MemberLoginRequestDto memberLoginRequest) throws Exception {
Assert.notBlank(memberLoginRequest.getAccount(), "用户登录,登录账号不能为空");
Assert.notBlank(memberLoginRequest.getAuthCode(), "用户登录,验证码不能为空");
Assert.notBlank(memberLoginRequest.getAccount());
Assert.notBlank(memberLoginRequest.getAuthCode());
if (!judgeCodeService.judgeCode(memberLoginRequest.getAccount(), memberLoginRequest.getAuthCode())) {
throw new BusinessException("验证码有误,请重新输入");
throw new I18nMessageException("exception/verification.code.is.incorrect.please.re-enter");
}
MemberInfoEntity memberEntityByAccount = bizMemberInfoService.getMemberEntityByAccount(memberLoginRequest.getAccount());
......
......@@ -2,7 +2,7 @@ package cn.com.poc.user.builder;
import cn.com.poc.common.utils.Assert;
import cn.com.poc.user.constants.UserLoginConstants;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
......@@ -19,7 +19,7 @@ public class LoginChannelBuilder implements ApplicationContextAware {
private ApplicationContext applicationContext;
public LoginChannelService getService(String loginChannel) throws Exception {
Assert.notBlank(loginChannel, "登录渠道不能为空");
Assert.notBlank(loginChannel);
if (UserLoginConstants.LoginType.MEMBER_PLATFOMR_SMS.equals(loginChannel)) {
return applicationContext.getBean(SmsLoginChannel.class);
} else if (UserLoginConstants.LoginType.MEMBER_PLATFOMR_PW.equals(loginChannel)) {
......@@ -27,7 +27,7 @@ public class LoginChannelBuilder implements ApplicationContextAware {
} else if (UserLoginConstants.LoginType.MEMBER_PLATFOMR_EMAIL.equals(loginChannel)) {
return applicationContext.getBean(EmailLoginChannel.class);
}
throw new BusinessException("第三方授权渠道异常!");
throw new I18nMessageException("exception/third.party.authorization.channel.abnormal");
}
@Override
......
......@@ -6,7 +6,7 @@ import cn.com.poc.user.entity.Member3rdPartyRelationEntity;
import cn.com.poc.user.entity.MemberInfoEntity;
import cn.com.poc.user.service.BizMember3rdPartyRelationService;
import cn.com.poc.user.service.BizMemberInfoService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
......@@ -30,19 +30,19 @@ public class PwLoginChannel implements LoginChannelService {
@Override
public MemberInfoEntity doLogin(MemberLoginRequestDto memberLoginRequest) throws Exception {
Assert.notBlank(memberLoginRequest.getPassword(), "通过密码登录,密码不能为空。");
Assert.notBlank(memberLoginRequest.getPassword());
MemberInfoEntity memberEntityByAccount = bizMemberInfoService.getMemberEntityByAccount(memberLoginRequest.getAccount());
if (memberEntityByAccount == null) { //用户没有注册过 需要注册
throw new BusinessException("登录的用户不存在");
throw new I18nMessageException("exception/user.does.not.exist");
}
Integer memberId = memberEntityByAccount.getMemberId();
Member3rdPartyRelationEntity relationByMemberIdEntity = bizMember3rdPartyRelationService.getPwRelationByMemberId(memberId);
if (relationByMemberIdEntity == null || !memberLoginRequest.getPassword().equals(relationByMemberIdEntity.getRelationKey())) {
throw new BusinessException("密码错误,请重新输入");
throw new I18nMessageException("exception/password.error.please.re-enter");
}
return memberEntityByAccount;
}
......
......@@ -6,7 +6,7 @@ import cn.com.poc.common.utils.StringUtils;
import cn.com.poc.user.dto.MemberLoginRequestDto;
import cn.com.poc.user.entity.MemberInfoEntity;
import cn.com.poc.user.service.BizMemberInfoService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.frame.service.FmxParamConfigService;
import org.springframework.stereotype.Service;
......@@ -31,12 +31,12 @@ public class SmsLoginChannel implements LoginChannelService {
@Override
public MemberInfoEntity doLogin(MemberLoginRequestDto memberLoginRequest) throws Exception {
Assert.notBlank(memberLoginRequest.getAccount(), "用户登录,登录账号不能为空");
Assert.notBlank(memberLoginRequest.getAuthCode(), "用户登录,验证码不能为空");
Assert.notBlank(memberLoginRequest.getAccount());
Assert.notBlank(memberLoginRequest.getAuthCode());
//验证验证码
if (!judgeCodeService.judgeCode(memberLoginRequest.getAccount(), memberLoginRequest.getAuthCode())) {
throw new BusinessException("验证码有误,请重新输入");
throw new I18nMessageException("exception/verification.code.is.incorrect.please.re-enter");
}
MemberInfoEntity memberEntityByAccount = bizMemberInfoService.getMemberEntityByAccount(memberLoginRequest.getAccount());
......
......@@ -41,7 +41,7 @@ public class BizMemberInfoRestImpl implements BizMemberInfoRest {
@Override
public MemberLoginResponseDto doLogin(MemberLoginRequestDto memberLoginRequest) throws Exception {
Assert.notBlank(memberLoginRequest.getLoginChannel(), "登录的渠道不能为空");
Assert.notBlank(memberLoginRequest.getLoginChannel());
String loginChannel = memberLoginRequest.getLoginChannel();
MemberInfoEntity memberInfoEntity = (MemberInfoEntity) loginChannelBuilder.getService(loginChannel).doLogin(memberLoginRequest);
......@@ -68,9 +68,9 @@ public class BizMemberInfoRestImpl implements BizMemberInfoRest {
*/
@Override
public void configureMemberPassword(MemberPasswordRequestDto memberPasswordRequestDto) throws Exception {
Assert.notBlank(memberPasswordRequestDto.getAccount(), "调用会员密码配置,会员账号不能为空");
Assert.notBlank(memberPasswordRequestDto.getPassword(), "调用会员密码配置,密码不能为空");
Assert.notBlank(memberPasswordRequestDto.getAuthCode(), "调用会员密码配置,授权码不能为空");
Assert.notBlank(memberPasswordRequestDto.getAccount());
Assert.notBlank(memberPasswordRequestDto.getPassword());
Assert.notBlank(memberPasswordRequestDto.getAuthCode());
memberInfoService.configureMemberPassword(memberPasswordRequestDto);
}
......@@ -81,9 +81,9 @@ public class BizMemberInfoRestImpl implements BizMemberInfoRest {
*/
@Override
public void changeMemberPassword(MemberPasswordRequestDto memberPasswordRequestDto) throws Exception {
Assert.notBlank(memberPasswordRequestDto.getAccount(), "调用会员密码配置,会员账号不能为空");
Assert.notBlank(memberPasswordRequestDto.getPassword(), "调用会员密码配置,密码不能为空");
Assert.notBlank(memberPasswordRequestDto.getAuthCode(), "调用会员密码配置,授权码不能为空");
Assert.notBlank(memberPasswordRequestDto.getAccount());
Assert.notBlank(memberPasswordRequestDto.getPassword());
Assert.notBlank(memberPasswordRequestDto.getAuthCode());
memberInfoService.configureMemberPassword(memberPasswordRequestDto);
}
......@@ -94,9 +94,9 @@ public class BizMemberInfoRestImpl implements BizMemberInfoRest {
*/
@Override
public void forgetMemberPassword(MemberPasswordRequestDto memberPasswordRequestDto) throws Exception {
Assert.notBlank(memberPasswordRequestDto.getAccount(), "调用会员密码配置,会员账号不能为空");
Assert.notBlank(memberPasswordRequestDto.getPassword(), "调用会员密码配置,密码不能为空");
Assert.notBlank(memberPasswordRequestDto.getAuthCode(), "调用会员密码配置,授权码不能为空");
Assert.notBlank(memberPasswordRequestDto.getAccount());
Assert.notBlank(memberPasswordRequestDto.getPassword());
Assert.notBlank(memberPasswordRequestDto.getAuthCode());
memberInfoService.configureMemberPassword(memberPasswordRequestDto);
}
......
......@@ -8,7 +8,7 @@ import cn.com.poc.user.entity.Member3rdPartyRelationEntity;
import cn.com.poc.user.model.BizMember3rdPartyRelationModel;
import cn.com.poc.user.repository.BizMember3rdPartyRelationRepository;
import cn.com.poc.user.service.BizMember3rdPartyRelationService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.core.service.impl.BaseServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
......@@ -30,7 +30,7 @@ public class BizMember3rdPartyRelationServiceImpl extends BaseServiceImpl
if (member3rdPartyRelationEntity.getId() != null) {
BizMember3rdPartyRelationModel bizMember3rdPartyRelationModel = repository.get(member3rdPartyRelationEntity.getId());
if (bizMember3rdPartyRelationModel == null) {
throw new BusinessException("找不到用户的关联关系");
throw new I18nMessageException("exception/unable.find.user.association.relationship");
}
model = bizMember3rdPartyRelationModel;
model.setRelationKey(member3rdPartyRelationEntity.getRelationKey());
......@@ -49,7 +49,7 @@ public class BizMember3rdPartyRelationServiceImpl extends BaseServiceImpl
*/
@Override
public Member3rdPartyRelationEntity getPwRelationByMemberId(Integer memberId) throws Exception {
Assert.notNull(memberId, "通过会员id查询关联关系,会员id不能为空");
Assert.notNull(memberId);
BizMember3rdPartyRelationModel example = new BizMember3rdPartyRelationModel();
example.setMemberId(memberId);
example.setRelationPlatform(Member3rdPartyRelationConstants.RelationType.PW);
......
......@@ -6,7 +6,7 @@ import cn.com.poc.common.utils.StringUtils;
import cn.com.poc.common.utils.UUIDTool;
import cn.com.poc.user.convert.MemberInfoConvert;
import cn.com.poc.user.entity.MemberInfoEntity;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.core.service.impl.BaseServiceImpl;
import cn.com.poc.user.service.BizMemberInfoService;
import cn.com.poc.user.model.BizMemberInfoModel;
......@@ -40,7 +40,7 @@ public class BizMemberInfoServiceImpl extends BaseServiceImpl
@Override
public MemberInfoEntity getMemberEntityByAccount(String account) throws Exception {
Assert.notBlank(account, "账号不能为空");
Assert.notBlank(account);
BizMemberInfoModel example = new BizMemberInfoModel();
example.setIsDeleted(CommonConstant.IsDeleted.N);
example.setAccount(account);
......@@ -66,7 +66,7 @@ public class BizMemberInfoServiceImpl extends BaseServiceImpl
model.setEmail(memberInfoEntity.getEmail());
if (checkVaildAccountExist(memberInfoEntity.getAccount())) {
throw new BusinessException("该账号已经被注册,请更换一个");
throw new I18nMessageException("exception/account.has.already");
}
if (StringUtils.isBlank(memberInfoEntity.getAvatarUrl())) {
......
......@@ -2,7 +2,7 @@ package cn.com.yict.framemax.frame.aggregation.impl;
import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.common.utils.Assert;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.frame.aggregation.ParamLargerModelConfigService;
import cn.com.yict.framemax.frame.entity.LargeModelConfigEntity;
import cn.com.yict.framemax.frame.entity.TimBreEntity;
......@@ -45,14 +45,14 @@ public class ParamLargerModelConfigServiceImpl implements ParamLargerModelConfig
}
//3.如果没找到,则抛出异常
if(isFind == false){
throw new BusinessException("param_value模型不存在");
throw new I18nMessageException("param_value模型不存在");
}
//4.根据entity获取音色ID
Integer timbreId = largeModelConfigEntity.getTimbreId();
//根据音色ID获取音色code是否存在此音色(数据库里面音色列表中音色的唯一标识)
LargeModelConfigEntity timbre = largeModelConfigService.getByTimbreId(timbreId);
if(timbre == null){
throw new BusinessException("此音色不存在");
throw new I18nMessageException("此音色不存在");
}
//4.如果都存在,则保存entity
largeModelConfigEntity.setTimbreName(timbre.getTimbreName());
......@@ -60,7 +60,7 @@ public class ParamLargerModelConfigServiceImpl implements ParamLargerModelConfig
}
@Override
public LargeModelConfigEntity update(LargeModelConfigEntity largeModelConfigEntity) throws Exception {
Assert.notNull(largeModelConfigEntity.getId(), "largeModelConfigId is null");
Assert.notNull(largeModelConfigEntity.getId());
LargeModelConfigEntity largeModelConfig = largeModelConfigService.get(largeModelConfigEntity.getId());
if (largeModelConfig == null || CommonConstant.IsDeleted.Y.equals(largeModelConfig.getIsDeleted())) {
return null;
......@@ -78,14 +78,14 @@ public class ParamLargerModelConfigServiceImpl implements ParamLargerModelConfig
}
//3.如果没找到,则抛出异常
if(isFind == false){
throw new BusinessException("param_value模型不存在");
throw new I18nMessageException("param_value模型不存在");
}
//4.根据entity获取音色ID
Integer timbreId = largeModelConfigEntity.getTimbreId();
//根据音色ID获取音色code是否存在此音色(数据库里面音色列表中音色的唯一标识)
LargeModelConfigEntity timbre = largeModelConfigService.getByTimbreId(timbreId);
if(timbre == null){
throw new BusinessException("此音色不存在");
throw new I18nMessageException("此音色不存在");
}
//4.如果都存在,则更新entity
LargeModelConfigEntity result = largeModelConfigService.update(largeModelConfigEntity);
......
......@@ -23,11 +23,11 @@ public class LargeModelConfigRestImpl implements LargeModelConfigRest {
@Override
public LargeModelConfigEntity saveLargeModelConfig(LargeModelConfigEntity largeModelConfigEntity) throws Exception {
Assert.notNull(largeModelConfigEntity, "参数不能为空");
Assert.notNull(largeModelConfigEntity.getParamValue(), "参数不能为空");
Assert.notNull(largeModelConfigEntity.getTimbreId(), "参数不能为空");
Assert.notNull(largeModelConfigEntity.getPresencePenalty(), "参数不能为空");
Assert.notNull(largeModelConfigEntity.getTemperature(), "参数不能为空");
Assert.notNull(largeModelConfigEntity);
Assert.notNull(largeModelConfigEntity.getParamValue());
Assert.notNull(largeModelConfigEntity.getTimbreId());
Assert.notNull(largeModelConfigEntity.getPresencePenalty());
Assert.notNull(largeModelConfigEntity.getTemperature());
if(largeModelConfigEntity.getId() == null){
return paramLargerModelConfigService.save(largeModelConfigEntity);
}
......
......@@ -27,7 +27,7 @@ public class LargeModelConfigServiceImpl extends BaseServiceImpl
@Override
public LargeModelConfigEntity get(Integer id) throws Exception {
Assert.notNull(id, "largeModelConfigId is null");
Assert.notNull(id);
LargeModelConfigModel model = this.repository.get(id);
if (model == null || model.getIsDeleted().equals(CommonConstant.IsDeleted.Y)) {
return null;
......@@ -62,7 +62,7 @@ public class LargeModelConfigServiceImpl extends BaseServiceImpl
@Override
public void deleteById(Integer id) throws Exception {
Assert.notNull(id, "characterCommunicationId is null");
Assert.notNull(id);
//查找characterCommunication
LargeModelConfigModel largeModelConfigModel = this.repository.get(id);
if (null == largeModelConfigModel) {
......@@ -74,7 +74,7 @@ public class LargeModelConfigServiceImpl extends BaseServiceImpl
@Override
public LargeModelConfigEntity save(LargeModelConfigEntity entity) throws Exception {
Assert.notNull(entity, "Cannot save empty objects");
Assert.notNull(entity);
entity.setId(null);
LargeModelConfigModel largeModelConfigModel = LargeModelConfigConvert.entityToModel(entity);
LargeModelConfigModel model = this.repository.save(largeModelConfigModel);
......@@ -83,8 +83,8 @@ public class LargeModelConfigServiceImpl extends BaseServiceImpl
@Override
public LargeModelConfigEntity update(LargeModelConfigEntity entity) throws Exception {
Assert.notNull(entity, "entity is null");
Assert.notNull(entity.getId(), "entityId is null");
Assert.notNull(entity);
Assert.notNull(entity.getId());
LargeModelConfigModel largeModelConfigModel = this.repository.get(entity.getId());
if (largeModelConfigModel == null || CommonConstant.IsDeleted.Y.equals(largeModelConfigModel.getIsDeleted())) {
return null;
......
......@@ -44,7 +44,7 @@ public class MobileUpdateServiceImpl extends BaseServiceImpl implements MobileUp
*/
@Override
public FmxFileModel saveMobilePackage(FmxFileModel fileModel) throws Exception {
Assert.notNull(fileModel, "file is required");
Assert.notNull(fileModel);
if (StringUtils.isEmpty(fileModel.getBizId())) {
throw new I18nMessageException("framemaxPage/mobileUpdate.appNameEmptyMsg");
}
......@@ -88,7 +88,7 @@ public class MobileUpdateServiceImpl extends BaseServiceImpl implements MobileUp
*/
@Override
public List<FmxFileModel> mobilePackageList(FmxFileModel fileModel, PagingInfo pagingInfo) throws Exception {
Assert.notNull(fileModel, "query is required");
Assert.notNull(fileModel);
FmxFileModel modelExample = new FmxFileModel();
modelExample.setBizType(30);
......
publication.failed=Publication failed
create.[role.instruction].configuration.does.not.exist=Create [Role Instruction] configuration does not exist
create.[opening.statement].configuration.does.not.exist=Create [Opening statement] configuration does not exist
failed.to.create.[opening.statement]=Failed to create [opening statement]
the.configuration.for.creating.[avatar.prompt].does.not.exist.please.contact.the.administrator=The configuration for creating [avatar prompt] does not exist. Please contact the administrator
failed.to.create.[avatar].please.try.again.later=Failed to create [avatar], please try again later
create.[application.information].configuration.does.not.exist.please.contact.the.administrator=Create [Application Information] configuration does not exist, please contact the administrator
failed.to.create.[application.information].please.try.again.later=Failed to create [Application Information], please try again later
user.not.login=User not logged in
application.does.not.exist=The application does not exist
application.not.released=Application not released
generation.failed.please.try.again.later=Generation failed, please try again later
data.does.not.exist=Data does not exist
there.are.too.many.tasks.currently.please.try.again.later=There are too many tasks currently, please try again later
verification.code.has.expired.please.obtain.it.again=The verification code has expired, please obtain it again
maximum.number.of.verifications.has.been.reached=The maximum number of verifications has been reached
verification.code.sending.failed.please.try.again=Verification code sending failed! Please try again
upload.exception.please.check.the.file.before.uploading.again=Upload exception, please check the file before uploading again
abnormal.call.to.upload.alibaba.cloud.images=Abnormal call to upload Alibaba Cloud images!
cannot.read.data.from.this.url=Cannot read data from this URL
error.signature=Wrong signature
signature.validity.time.exception=Signature validity time exception
signature.has.expired=Signature has expired
app.not.found=App not found
failed.to.generate.recommendation.question=Failed to generate recommendation question
document.does.not.exist=The document does not exist
knowledge.base.information.does.not.exist=The knowledge base information does not exist
repetitive.training.in.the.knowledge.base=Repetitive training in the knowledge base
knowledge.base.does.not.exist=The knowledge base does not exist
private.key.of.the.marketing.platform.configuration.project.is.empty=The private key of the marketing platform configuration project is empty
decryption.offset.of.the.marketing.platform.configuration.is.empty=The decryption offset of the marketing platform configuration is empty
middle.server.is.unresponsive.or.has.timed.out=The middle server is unresponsive or has timed out!
key.for.the.marketing.platform.configuration.project.is.empty=The key for the marketing platform configuration project is empty
secret.for.the.marketing.platform.configuration.project.is.empty=The key for the marketing platform configuration project is empty
failed.to.obtain.xinghai.apptoken=Failed to obtain Xinghai appToken
default.login.channel.login.is.currently.not.supported=Default login channel login is currently not supported!
third.party.authorization.channel.abnormal=Third party authorization channel abnormal!
third.party.login.channel.abnormality=Third party login channel abnormality
abnormal.configuration.of.bai.liantong.open.platform=Abnormal configuration of Bai Liantong open platform!
abnormal.acquisition.of.mini.program.information.please.check.if.the.configuration.is.correct=Abnormal acquisition of mini program information! Please check if the configuration is correct!
currently.no.default.registration.channel.for.login=There is currently no default registration channel for login!
abnormal.registration.channel=Abnormal registration channel
login.expiration.time.configured.as.empty=Login expiration time configured as empty!
there.is.currently.no.default.verification.code.channel.login=There is currently no default verification code channel login!
verification.code.channel.abnormality=Verification code channel abnormality
failed.to.obtain.baidu.token=Failed to obtain Baidu token
training.exception.please.contact.the.administrator=Training exception, please contact the administrator
image.generation.failed=Image generation failed
middle.platform.is.unresponsive=The middle platform is unresponsive, please contact the developers
no.response.please.contact.the.developer=No response, please contact the developer
abnormal.knowledge.base.training=Abnormal knowledge base training
abnormal.training.status.of.knowledge.base.acquisition=Abnormal training status of knowledge base acquisition
delete.knowledge.base.exception=Delete knowledge base exception
query.knowledge.base.exception=Query knowledge base exception
variable.structure.configuration.is.not.currently.supported=Variable structure configuration is not currently supported
this.method.is.not.supported=This method is not supported
failed.to.obtain.token=Failed to obtain token
re-verify.the.user.identity=Please re verify the user's identity
user.cannot.be.found=The user cannot be found
verification.code.is.incorrect.please.re-enter=The verification code is incorrect, please re-enter
user.does.not.exist=The logged in user does not exist
password.error.please.re-enter=Password error, please re-enter
unable.find.user.association.relationship=Unable to find user's association relationship
account.has.already=This account has already been registered, please replace it
not.support.lang=not support this lang
call.failure=Call failure
\ No newline at end of file
publication.failed=发布失败
create.[role.instruction].configuration.does.not.exist=创建[角色指令]配置不存在
create.[opening.statement].configuration.does.not.exist=创建[开场白]配置不存在
failed.to.create.[opening.statement]=创建[开场白]失败
the.configuration.for.creating.[avatar.prompt].does.not.exist.please.contact.the.administrator=创建[头像提示语]配置不存在,请联系管理员
failed.to.create.[avatar].please.try.again.later=创建[头像]失败,请稍后再试
create.[application.information].configuration.does.not.exist.please.contact.the.administrator=创建[应用信息]配置不存在,请联系管理员
failed.to.create.[application.information].please.try.again.later=创建[应用信息]失败,请稍后再试
user.not.login=用户未登录
application.does.not.exist=应用不存在
application.not.released=应用未发布
generation.failed.please.try.again.later=生成失败,请稍后重试
data.does.not.exist=数据不存在
there.are.too.many.tasks.currently.please.try.again.later=当前任务过多,请稍后重试
verification.code.has.expired.please.obtain.it.again=验证码已过期,请重新获取
maximum.number.of.verifications.has.been.reached=验证次数已达上限
verification.code.sending.failed.please.try.again=验证码发送失败!请重试
upload.exception.please.check.the.file.before.uploading.again=上传异常,请检查文件后再上传
abnormal.call.to.upload.alibaba.cloud.images=调用上传阿里云图片异常!
cannot.read.data.from.this.url=不能从该url中读取到数据
error.signature=错误的签名
signature.validity.time.exception=签名有效时间异常
signature.has.expired=签名已过期
app.not.found=未找到应用
failed.to.generate.recommendation.question=生成推荐问题失败
document.does.not.exist=文档不存在
knowledge.base.information.does.not.exist=知识库信息不存在
repetitive.training.in.the.knowledge.base=知识库重复训练
knowledge.base.does.not.exist=知识库不存在
private.key.of.the.marketing.platform.configuration.project.is.empty=营销中台配置项目私钥为空
decryption.offset.of.the.marketing.platform.configuration.is.empty=营销中台配置解密偏移量为空
middle.server.is.unresponsive.or.has.timed.out=中台服务器无响应或响应超时!
key.for.the.marketing.platform.configuration.project.is.empty=营销中台配置项目key为空
secret.for.the.marketing.platform.configuration.project.is.empty=营销中台配置项目密钥为空
failed.to.obtain.xinghai.apptoken=获取兴海apptoken失败
default.login.channel.login.is.currently.not.supported=暂不支持默认登录渠道登录!
third.party.authorization.channel.abnormal=第三方授权渠道异常!
third.party.login.channel.abnormality=第三方登录渠道异常
abnormal.configuration.of.bai.liantong.open.platform=百联通开放平台配置异常!
abnormal.acquisition.of.mini.program.information.please.check.if.the.configuration.is.correct=获取小程序信息异常!请检查配置是否正确!
currently.no.default.registration.channel.for.login=暂无默认注册渠道登录!
abnormal.registration.channel=注册渠道异常
login.expiration.time.configured.as.empty=登录过期时间配置为空!
there.is.currently.no.default.verification.code.channel.login=暂无默认验证码渠道登录!
verification.code.channel.abnormality=验证码渠道异常
failed.to.obtain.baidu.token=获取百度token失败
training.exception.please.contact.the.administrator=翻译异常,请联系管理员
image.generation.failed=生成图片失败
middle.platform.is.unresponsive=中台无响应,请联系开发人员
no.response.please.contact.the.developer=无响应,请联系开发人员
abnormal.knowledge.base.training=知识库训练异常
abnormal.training.status.of.knowledge.base.acquisition=获取知识库训练状态异常
delete.knowledge.base.exception=删除知识库异常
query.knowledge.base.exception=查询知识库异常
variable.structure.configuration.is.not.currently.supported=暂不支持变量结构配置
this.method.is.not.supported=不支持此方法
failed.to.obtain.token=获取token失败
re-verify.the.user.identity=请重新验证用户身份
user.cannot.be.found=找不到该用户
verification.code.is.incorrect.please.re-enter=验证码有误,请重新输入
user.does.not.exist=登录的用户不存在
password.error.please.re-enter=密码错误,请重新输入
unable.find.user.association.relationship=找不到用户的关联关系
account.has.already=该账号已经被注册,请更换一个
not.support.lang=不支持该语音
call.failure=调用失败
\ No newline at end of file
publication.failed=發佈失敗
create.[role.instruction].configuration.does.not.exist=創建[角色指令]配置不存在
create.[opening.statement].configuration.does.not.exist=創建[開場白]配置不存在
failed.to.create.[opening.statement]=創建[開場白]失敗
the.configuration.for.creating.[avatar.prompt].does.not.exist.please.contact.the.administrator=創建[頭像提示語]配置不存在,請聯繫管理員
failed.to.create.[avatar].please.try.again.later=創建[頭像]失敗,請稍後再試
create.[application.information].configuration.does.not.exist.please.contact.the.administrator=創建[應用信息]配置不存在,請聯繫管理員
failed.to.create.[application.information].please.try.again.later=創建[應用信息]失敗,請稍後再試
user.not.login=用戶未登錄
application.does.not.exist=應用不存在
application.not.released=應用未發佈
generation.failed.please.try.again.later=生成失敗,請稍後重試
data.does.not.exist=數據不存在
there.are.too.many.tasks.currently.please.try.again.later=當前任務過多,請稍後重試
verification.code.has.expired.please.obtain.it.again=驗證碼已過期,請重新獲取
maximum.number.of.verifications.has.been.reached=驗證次數已達上限
verification.code.sending.failed.please.try.again=驗證碼發送失敗!請重試
upload.exception.please.check.the.file.before.uploading.again=上傳異常,請檢查文件後再上傳
abnormal.call.to.upload.alibaba.cloud.images=調用上傳阿里雲圖片異常!
cannot.read.data.from.this.url=不能從該url中讀取到數據
error.signature=錯誤的簽名
signature.validity.time.exception=簽名有效時間異常
signature.has.expired=簽名已過期
app.not.found=未找到應用
failed.to.generate.recommendation.question=生成推薦問題失敗
document.does.not.exist=文檔不存在
knowledge.base.information.does.not.exist=知識庫信息不存在
repetitive.training.in.the.knowledge.base=知識庫重複訓練
knowledge.base.does.not.exist=知識庫不存在
private.key.of.the.marketing.platform.configuration.project.is.empty=營銷中臺配置項目私鑰爲空
decryption.offset.of.the.marketing.platform.configuration.is.empty=營銷中臺配置解密偏移量爲空
middle.server.is.unresponsive.or.has.timed.out=中臺服務器無響應或響應超時!
key.for.the.marketing.platform.configuration.project.is.empty=營銷中臺配置項目key爲空
secret.for.the.marketing.platform.configuration.project.is.empty=營銷中臺配置項目密鑰爲空
failed.to.obtain.xinghai.apptoken=獲取興海apptoken失敗
default.login.channel.login.is.currently.not.supported=暫不支持默認登錄渠道登錄!
third.party.authorization.channel.abnormal=第三方授權渠道異常!
third.party.login.channel.abnormality=第三方登錄渠道異常
abnormal.configuration.of.bai.liantong.open.platform=百聯通開放平臺配置異常!
abnormal.acquisition.of.mini.program.information.please.check.if.the.configuration.is.correct=獲取小程序信息異常!請檢查配置是否正確!
currently.no.default.registration.channel.for.login=暫無默認註冊渠道登錄!
abnormal.registration.channel=註冊渠道異常
login.expiration.time.configured.as.empty=登錄過期時間配置爲空!
there.is.currently.no.default.verification.code.channel.login=暫無默認驗證碼渠道登錄!
verification.code.channel.abnormality=驗證碼渠道異常
failed.to.obtain.baidu.token=獲取百度token失敗
training.exception.please.contact.the.administrator=翻译異常,請聯繫管理員
image.generation.failed=生成圖片失敗
middle.platform.is.unresponsive=中臺無響應,請聯繫開發人員
no.response.please.contact.the.developer=無響應,請聯繫開發人員
abnormal.knowledge.base.training=知識庫訓練異常
abnormal.training.status.of.knowledge.base.acquisition=獲取知識庫訓練狀態異常
delete.knowledge.base.exception=刪除知識庫異常
query.knowledge.base.exception=查詢知識庫異常
variable.structure.configuration.is.not.currently.supported=暫不支持變量結構配置
this.method.is.not.supported=不支持此方法
failed.to.obtain.token=獲取token失敗
re-verify.the.user.identity=請重新驗證用戶身份
user.cannot.be.found=找不到該用戶
verification.code.is.incorrect.please.re-enter=驗證碼有誤,請重新輸入
user.does.not.exist=登錄的用戶不存在
password.error.please.re-enter=密碼錯誤,請重新輸入
unable.find.user.association.relationship=找不到用戶的關聯關係
account.has.already=該賬號已經被註冊,請更換一個
not.support.lang=不支持該語言
call.failure=調用失敗
\ No newline at end of file
package cn.com.poc.knowledge;
import cn.com.poc.common.utils.FileUtils;
import cn.com.poc.common.utils.JsonUtils;
import cn.com.poc.thirdparty.resource.demand.ai.aggregate.DemandKnowledgeService;
import cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Message;
import cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.MultiContent;
import cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelDemandResult;
import cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelResponse;
import cn.com.poc.thirdparty.service.LLMService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.spring.SingleContextInitializer;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import javax.annotation.Resource;
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(initializers = SingleContextInitializer.class)
@WebAppConfiguration
public class Demand {
final private String EVENT_STREAM_PREFIX = "data: ";
@Resource
private DemandKnowledgeService demandKnowledgeService;
@Resource
private LLMService llmService;
@Test
public void test() {
String str = FileUtils.formatFileSize(1024);
System.out.println(str);
// GetKnowledgeChunkInfoResult knowledgeChunkInfos = demandKnowledgeService.getKnowledgeChunkInfos(ListUtil.toList("KnowLedge-1050ef90-7232-487f-ac8b-501002c7b789", "KnowLedge-315f8992-9aa2-4f0b-a06f-9298b1de7504"), new PagingInfo());
// System.out.println(knowledgeChunkInfos);
}
@Test
public void llmTest() throws Exception {
List<Message> messageList = new ArrayList<>();
List<MultiContent> multiContents = new ArrayList<>();
MultiContent multiContent = new MultiContent();
multiContents.add(multiContent);
multiContent.setType("text");
multiContent.setText("Hello, how are you?");
Message userMessage = new Message();
userMessage.setRole("user");
userMessage.setContent(multiContents);
messageList.add(userMessage);
String largeModel = "qwen-max";
LargeModelResponse largeModelResponse = new LargeModelResponse();
largeModelResponse.setModel(largeModel);
largeModelResponse.setMessages(messageList.toArray(new Message[0]));
largeModelResponse.setTopP(0F);
largeModelResponse.setStream(true);
largeModelResponse.setUser("POE");
BufferedReader bufferedReader = llmService.chatChunk(largeModelResponse);
String res = "";
bufferedReader.mark(200);
while ((res = bufferedReader.readLine()) != null) {
if (StringUtils.isBlank(res)) {
continue;
}
LargeModelDemandResult result = JsonUtils.deSerialize(res.replaceFirst(EVENT_STREAM_PREFIX, StringUtils.EMPTY), LargeModelDemandResult.class);
if (!"0".equals(result.getCode())) {
BusinessException ex = new BusinessException("ʧ");
throw ex;
}
bufferedReader.reset();
break;
}
while ((res = bufferedReader.readLine()) != null) {
if (StringUtils.isBlank(res)) {
continue;
}
LargeModelDemandResult result = JsonUtils.deSerialize(res.replaceFirst(EVENT_STREAM_PREFIX, StringUtils.EMPTY), LargeModelDemandResult.class);
if (!"0".equals(result.getCode())) {
BusinessException ex = new BusinessException("ʧ");
throw ex;
}
System.out.println("result:" + result);
}
}
}
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