Commit 05de9276 authored by alex yao's avatar alex yao

style: service命名优化

parent 9a52e406
package cn.com.poc.agent_application.aggregate;
import cn.com.poc.agent_application.domain.FunctionResult;
import cn.com.poc.agent_application.entity.AgentResultEntity;
import cn.com.poc.agent_application.entity.BizAgentApplicationInfoEntity;
import cn.com.poc.agent_application.entity.CreateAgentTitleAndDescEntity;
import cn.com.poc.agent_application.entity.KnowledgeSuperclassProblemConfig;
import cn.com.poc.agent_application.entity.call_agent.CallAgentApplicationKnowledgeConfig;
import cn.com.poc.agent_application.entity.call_agent.CallAgentApplicationModelConfig;
import cn.com.poc.thirdparty.resource.demand.ai.constants.KnowledgeSearchTypeEnum;
import cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Message;
import cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Tool;
......@@ -15,7 +12,7 @@ import cn.com.poc.thirdparty.resource.demand.ai.entity.function.FunctionCallResu
import javax.servlet.http.HttpServletResponse;
import java.util.List;
public interface AgentApplicationInfoService {
public interface AgentApplicationService {
/**
* 创建/更新应用
......@@ -39,32 +36,6 @@ public interface AgentApplicationInfoService {
*/
boolean deletedAgentApplication(String agentId) throws Exception;
/**
* Agent应用对话
*
* @param agentId 应用ID
* @param identifier 对话唯一标识
* @param largeModel 模型
* @param agentSystem 应用角色指令
* @param knowledgeIds 知识库ID
* @param communicationTurn 对话轮数
* @param topP 模型参数topP
* @param temperature 模型参数temperature
* @param messages 对话消息
* @param tools 插件配置
* @param fileUrls 文件URLs
* @param imageUrls 图片URLs
* @param stream 是否流式传输
* @param score 知识库参数score
* @param topK 知识库参数topK
* @param knowledgeSearchType 知识库参数知识搜索类型
*/
@Deprecated
AgentResultEntity callAgentApplication(String agentId, String identifier, String largeModel, String agentSystem,
Integer[] knowledgeIds, Integer communicationTurn, Float topP, Float temperature,
List<Message> messages, List<Tool> tools, List<String> fileUrls, boolean stream, List<String> imageUrls,
Double score, Integer topK, KnowledgeSearchTypeEnum knowledgeSearchType, HttpServletResponse httpServletResponse) throws Exception;
/**
* Agent应用对话
*
......
package cn.com.poc.agent_application.aggregate.impl;
import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService;
import cn.com.poc.agent_application.aggregate.AgentApplicationService;
import cn.com.poc.agent_application.constant.AgentApplicationConstants;
import cn.com.poc.agent_application.constant.AgentApplicationDialoguesRecordConstants;
import cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants;
......@@ -65,13 +65,13 @@ import java.util.stream.Collectors;
import static cn.com.poc.common.constant.XLangConstant.*;
@Component
public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoService {
public class AgentApplicationServiceImpl implements AgentApplicationService {
final private String TEXT_EVENT_STREAM_CHARSET_UTF_8 = "text/event-stream;charset=UTF-8";
final private String EVENT_STREAM_PREFIX = "data: ";
final private Logger logger = LoggerFactory.getLogger(AgentApplicationInfoService.class);
final private Logger logger = LoggerFactory.getLogger(AgentApplicationService.class);
@Resource
private BizKnowledgeDocumentService bizKnowledgeDocumentService;
......@@ -173,66 +173,57 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
return true;
}
@Override
public AgentResultEntity callAgentApplication(String agentId, String dialogueId, String largeModel,
String agentSystem, Integer[] kdIds, Integer communicationTurn, Float topP, Float temperature,
List<Message> messages, List<Tool> tools, List<String> fileUrls, boolean stream, List<String> imageUrls,
Double score, Integer topK, KnowledgeSearchTypeEnum knowledgeSearchType, HttpServletResponse httpServletResponse) throws Exception {
logger.info("Call Agent Application, agentId:{}, dialogueId:{},largeModel:{},agentSystem:{},kdIds:{},communicationTurn:{},topP:{},temperature:{},messages:{}, tools:{}"
, agentId, dialogueId, largeModel, agentSystem, kdIds, communicationTurn, topP, temperature, messages, tools);
String model = modelConvert(largeModel);
Tool[] toolArray = tools.toArray(new Tool[0]);
FunctionResult functionResult = functionCall(dialogueId, messages, toolArray, agentId, fileUrls, imageUrls);
List<KnowledgeContentResult> knowledgeResult = knowledge(kdIds, messages, topK, score, knowledgeSearchType);
String promptTemplate = buildDialogsPrompt(functionResult, agentSystem, toolArray, dialogueId, agentId, knowledgeResult);
Message[] messageArray = buildMessages(messages, communicationTurn, promptTemplate);
return llmExecutorAndOutput(topP, stream, model, messageArray, functionResult, knowledgeResult, httpServletResponse);
}
@Override
public AgentResultEntity callAgentApplication(String agentId, String dialogueId, String largeModel, String agentSystem, Integer[] kdIds,
Integer communicationTurn, Float topP, Float temperature, List<Message> messages, List<Tool> tools, FunctionCallResult functionCallResult, List<String> fileUrls, boolean stream, List<String> imageUrls,
Double score, Integer topK, KnowledgeSearchTypeEnum knowledgeSearchType, KnowledgeSuperclassProblemConfig superclassProblemConfig, HttpServletResponse httpServletResponse) throws Exception {
String model = modelConvert(largeModel);
Tool[] toolArray = tools.toArray(new Tool[0]);
List<KnowledgeContentResult> knowledgeResult = knowledge(kdIds, messages, topK, score, knowledgeSearchType);
if (superclassProblem(superclassProblemConfig, kdIds, knowledgeResult)) {
String mess = superclassProblemConfig.getKnowledgeCustomResponse()[0];
logger.info("触发知识库超纲回答,mess{}", mess);
if (stream) {
PrintWriter writer = httpServletResponse.getWriter();
LargeModelDemandResult result = new LargeModelDemandResult();
result.setCode("0");
result.setMessage(mess);
result.setFinish_reason("finish");
writer.write(EVENT_STREAM_PREFIX + JsonUtils.serialize(result) + "\n\n");
writer.write(EVENT_STREAM_PREFIX + "[DONE]" + "\n\n");
writer.flush();
writer.close();
}
AgentResultEntity agentResultEntity = new AgentResultEntity();
agentResultEntity.setMessage(mess);
return agentResultEntity;
}
Tool[] toolArray = tools.toArray(new Tool[0]);
return sendProblemMess(stream, superclassProblemConfig, httpServletResponse);
} else {
FunctionResult functionResult = functionCall(dialogueId, functionCallResult, agentId);
FunctionResult functionResult = functionCall(dialogueId, functionCallResult, agentId);
String promptTemplate = buildDialogsPrompt(functionResult, agentSystem, toolArray, dialogueId, agentId, knowledgeResult);
String promptTemplate = buildDialogsPrompt(functionResult, agentSystem, toolArray, dialogueId, agentId, knowledgeResult);
Message[] messageArray = buildMessages(messages, communicationTurn, promptTemplate);
Message[] messageArray = buildMessages(messages, communicationTurn, promptTemplate);
return llmExecutorAndOutput(topP, stream, model, messageArray, functionResult, knowledgeResult, httpServletResponse);
return llmExecutorAndOutput(topP, stream, model, messageArray, functionResult, knowledgeResult, httpServletResponse);
}
}
/**
* 发送知识库超纲回答
*
* @param stream
* @param superclassProblemConfig
* @param httpServletResponse
* @return
* @throws IOException
*/
private AgentResultEntity sendProblemMess(boolean stream, KnowledgeSuperclassProblemConfig superclassProblemConfig, HttpServletResponse httpServletResponse) throws IOException {
String mess = superclassProblemConfig.getKnowledgeCustomResponse()[0];
logger.info("触发知识库超纲回答,mess{}", mess);
if (stream) {
SSEUtil sseUtil = new SSEUtil(httpServletResponse);
LargeModelDemandResult result = new LargeModelDemandResult();
result.setCode("0");
result.setMessage(mess);
result.setFinish_reason("finish");
sseUtil.send(JsonUtils.serialize(result));
sseUtil.send("[DONE]");
sseUtil.complete();
}
AgentResultEntity agentResultEntity = new AgentResultEntity();
agentResultEntity.setMessage(mess);
return agentResultEntity;
}
......@@ -563,15 +554,11 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
private AgentResultEntity llmExecutorAndOutput(Float topP, boolean stream, String model, Message[] messageArray, FunctionResult functionResult, List<KnowledgeContentResult> knowledgeResult, HttpServletResponse httpServletResponse) throws Exception {
if (stream) {
SSEUtil sseUtil = new SSEUtil(httpServletResponse);
// httpServletResponse.setContentType(TEXT_EVENT_STREAM_CHARSET_UTF_8);
// PrintWriter writer = httpServletResponse.getWriter();
if (CollectionUtils.isNotEmpty(knowledgeResult)) {
LargeModelDemandResult result = new LargeModelDemandResult();
result.setCode("0");
result.setKnowledgeContentResult(knowledgeResult);
sseUtil.send(JsonUtils.serialize(result));
// writer.write(EVENT_STREAM_PREFIX + JsonUtils.serialize(result) + "\n\n");
// writer.flush();
}
if (ObjectUtil.isNotNull(functionResult) && StringUtils.isNotBlank(functionResult.getFunctionName())) {
LargeModelDemandResult result = new LargeModelDemandResult();
......@@ -579,8 +566,6 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
ToolFunction toolFunction = functionResultConvertToolFunction(functionResult);
result.setFunction(toolFunction);
sseUtil.send(JsonUtils.serialize(result));
// writer.write(EVENT_STREAM_PREFIX + JsonUtils.serialize(result) + "\n\n");
// writer.flush();
}
BufferedReader bufferedReader = invokeLLMStream(model, messageArray, topP);
return textOutputStream(sseUtil, bufferedReader);
......
package cn.com.poc.agent_application.rest.impl;
import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService;
import cn.com.poc.agent_application.aggregate.AgentApplicationService;
import cn.com.poc.agent_application.convert.AgentApplicationInfoConvert;
import cn.com.poc.agent_application.domain.LargeModelInfo;
import cn.com.poc.agent_application.dto.*;
......@@ -57,7 +57,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
private BizAgentApplicationInfoService bizAgentApplicationInfoService;
@Resource
private AgentApplicationInfoService agentApplicationInfoService;
private AgentApplicationService agentApplicationService;
@Resource
private BizAgentApplicationPublishService bizAgentApplicationPublishService;
......@@ -184,7 +184,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
throw new I18nMessageException("exception/create.num.limit");
}
}
return AgentApplicationInfoConvert.entityToDto(agentApplicationInfoService.saveOrUpdate(entity));
return AgentApplicationInfoConvert.entityToDto(agentApplicationService.saveOrUpdate(entity));
}
......@@ -212,7 +212,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
@Override
public void delete(String agentId) throws Exception {
Assert.notNull(agentId);
agentApplicationInfoService.deletedAgentApplication(agentId);
agentApplicationService.deletedAgentApplication(agentId);
}
@Override
......@@ -225,7 +225,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
Assert.notNull(dto.getCommModelConfig());
Assert.notNull(dto.getKnowledgeConfig());
BizAgentApplicationInfoEntity bizAgentApplicationInfoEntity = AgentApplicationInfoConvert.dtoToEntity(dto);
agentApplicationInfoService.updateAndPublish(bizAgentApplicationInfoEntity);
agentApplicationService.updateAndPublish(bizAgentApplicationInfoEntity);
return true;
}
......@@ -276,7 +276,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
agentUseModifyEventInfo.setIsPublish(CommonConstant.IsDeleted.N);
reduceSn = memberEquityService.reducePoint(userBaseEntity.getUserId(), pointDeductionNum, ModifyEventEnum.use, agentUseModifyEventInfo);
//调用应用服务
agentApplicationInfoService.callAgentApplication(agentId, dialogueId, model,
agentApplicationService.callAgentApplication(agentId, dialogueId, model,
agentSystem, kdIds.toArray(new Integer[0]), communicationTurn, topP,
temperature, dto.getMessages(), tools, checkPluginUseEntity.getFunctionCallResult(), dto.getFileUrls(), true, imageUrls,
infoEntity.getKnowledgeSimilarity(), infoEntity.getKnowledgeNResult(), KnowledgeSearchTypeEnum.valueOf(infoEntity.getKnowledgeSearchType()),
......@@ -411,29 +411,29 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
@Override
public void createAgentSystem(AgentApplicationGCDto dto, HttpServletResponse response) throws Exception {
Assert.notNull(dto.getInput());
agentApplicationInfoService.createAgentSystem(dto.getInput(), response);
agentApplicationService.createAgentSystem(dto.getInput(), response);
}
@Override
public List<String> createFeaturedQuestions(AgentApplicationGCDto dto) {
return agentApplicationInfoService.createFeaturedQuestions(dto.getAgentTitle(), dto.getAgentDesc());
return agentApplicationService.createFeaturedQuestions(dto.getAgentTitle(), dto.getAgentDesc());
}
@Override
public String createPreamble(AgentApplicationGCDto dto) {
return agentApplicationInfoService.createPreamble(dto.getAgentTitle(), dto.getAgentDesc(), dto.getAgentSystem());
return agentApplicationService.createPreamble(dto.getAgentTitle(), dto.getAgentDesc(), dto.getAgentSystem());
}
@Override
public String createAgentApplicationAvatar(AgentApplicationGCDto dto) throws Exception {
Assert.isTrue(StringUtils.isNotBlank(dto.getAgentDesc()) || StringUtils.isNotBlank(dto.getAgentTitle()));
return agentApplicationInfoService.createAgentIcon(dto.getAgentTitle(), dto.getAgentDesc());
return agentApplicationService.createAgentIcon(dto.getAgentTitle(), dto.getAgentDesc());
}
@Override
public AgentApplicationGCDto createAgentTitleAndDesc(AgentApplicationGCDto dto) {
Assert.notNull(dto.getInput());
CreateAgentTitleAndDescEntity entity = agentApplicationInfoService.createAgentTitleAndDesc(dto.getInput());
CreateAgentTitleAndDescEntity entity = agentApplicationService.createAgentTitleAndDesc(dto.getInput());
if (null == entity) {
throw new I18nMessageException("exception/generation.failed.please.try.again.later");
}
......@@ -447,7 +447,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
@RedisLimit(key = "collect:agent_person", currentUser = true, count = 1, timeout = 1, exceptionInfo = "exception/too.many.requests")
public void collectOrCancelAgentInPerson(String agentId) throws Exception {
Assert.notNull(agentId);
agentApplicationInfoService.collectOrCancelAgentInPerson(agentId);
agentApplicationService.collectOrCancelAgentInPerson(agentId);
}
@Override
......
package cn.com.poc.agent_application.scheduler;
import cn.com.poc.expose.aggregate.AgentApplicationService;
import cn.com.poc.expose.aggregate.AgentApplicationExposeService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
......@@ -11,7 +11,7 @@ import javax.annotation.Resource;
public class RecommendQuestionScheduler {
@Resource
private AgentApplicationService agentApplicationService;
private AgentApplicationExposeService agentApplicationExposeService;
/**
* 每日凌晨
......@@ -20,6 +20,6 @@ public class RecommendQuestionScheduler {
*/
@Scheduled(cron = "0 0 0 * * ?")
public void knowledgeInfoStatusUpdateScheduler() throws Exception {
agentApplicationService.createRecommendQuestion();
agentApplicationExposeService.createRecommendQuestion();
}
}
......@@ -2,14 +2,12 @@ package cn.com.poc.expose.aggregate;
import cn.com.poc.agent_application.entity.BizAgentApplicationApiProfileEntity;
import cn.com.poc.agent_application.query.MemberCollectQueryItem;
import cn.com.poc.expose.dto.AgentApplicationApiProfileDto;
import cn.com.yict.framemax.data.model.PagingInfo;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
public interface AgentApplicationService {
public interface AgentApplicationExposeService {
/**
* 调用 已发布Agent应用
......
package cn.com.poc.expose.aggregate.impl;
import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService;
import cn.com.poc.agent_application.aggregate.AgentApplicationService;
import cn.com.poc.agent_application.constant.AgentApplicationDialoguesRecordConstants;
import cn.com.poc.agent_application.entity.*;
import cn.com.poc.agent_application.service.*;
......@@ -55,7 +55,7 @@ public class AgentApplicationApiServiceImpl implements AgentApplicationApiServic
private BizAgentApplicationPublishService bizAgentApplicationPublishService;
@Resource
private AgentApplicationInfoService agentApplicationInfoService;
private AgentApplicationService agentApplicationService;
@Resource
private KnowledgeService knowledgeService;
......@@ -168,7 +168,7 @@ public class AgentApplicationApiServiceImpl implements AgentApplicationApiServic
//对话
try {
AgentResultEntity agentResultEntity = agentApplicationInfoService.callAgentApplication(agentId, conversationId, infoEntity.getLargeModel(),
AgentResultEntity agentResultEntity = agentApplicationService.callAgentApplication(agentId, conversationId, infoEntity.getLargeModel(),
infoEntity.getAgentSystem(), kdIdList.toArray(new Integer[0]), infoEntity.getCommunicationTurn(),
infoEntity.getTopP(), infoEntity.getTemperature(), messages, tools, checkPluginUseEntity.getFunctionCallResult(), fileUrls, stream, imageUrls,
infoEntity.getKnowledgeSimilarity(), infoEntity.getKnowledgeNResult(), KnowledgeSearchTypeEnum.valueOf(infoEntity.getKnowledgeSearchType()),
......
package cn.com.poc.expose.aggregate.impl;
import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService;
import cn.com.poc.agent_application.aggregate.AgentApplicationService;
import cn.com.poc.agent_application.constant.AgentApplicationDialoguesRecordConstants;
import cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants;
import cn.com.poc.agent_application.entity.*;
......@@ -19,7 +19,7 @@ import cn.com.poc.equity.aggregate.MemberEquityService;
import cn.com.poc.equity.aggregate.PointDeductionRulesService;
import cn.com.poc.equity.constants.ModifyEventEnum;
import cn.com.poc.equity.domain.modifyEquityInfo.AgentUseModifyEventInfo;
import cn.com.poc.expose.aggregate.AgentApplicationService;
import cn.com.poc.expose.aggregate.AgentApplicationExposeService;
import cn.com.poc.knowledge.aggregate.KnowledgeService;
import cn.com.poc.support.security.oauth.entity.UserBaseEntity;
import cn.com.poc.thirdparty.resource.demand.ai.constants.KnowledgeSearchTypeEnum;
......@@ -51,9 +51,9 @@ import java.util.Set;
import java.util.stream.Collectors;
@Service
public class AgentApplicationServiceImpl implements AgentApplicationService {
public class AgentApplicationExposeServiceImpl implements AgentApplicationExposeService {
final private Logger logger = LoggerFactory.getLogger(AgentApplicationService.class);
final private Logger logger = LoggerFactory.getLogger(AgentApplicationExposeService.class);
/**
* 推荐问Key
......@@ -84,7 +84,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
private BizAgentApplicationDialoguesRecordService bizAgentApplicationDialoguesRecordService;
@Resource
private AgentApplicationInfoService agentApplicationInfoService;
private AgentApplicationService agentApplicationService;
@Resource
private BizAgentApplicationGcConfigService bizAgentApplicationGcConfigService;
......@@ -185,7 +185,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
}
}
//对话
AgentResultEntity agentResultEntity = agentApplicationInfoService.callAgentApplication(agentId, dialogsId, infoEntity.getLargeModel(),
AgentResultEntity agentResultEntity = agentApplicationService.callAgentApplication(agentId, dialogsId, infoEntity.getLargeModel(),
infoEntity.getAgentSystem(), kdIdList.toArray(new Integer[0]), infoEntity.getCommunicationTurn(),
infoEntity.getTopP(), infoEntity.getTemperature(), messages, tools, checkPluginUseEntity.getFunctionCallResult(), fileUrls, true, imageUrls,
infoEntity.getKnowledgeSimilarity(), infoEntity.getKnowledgeNResult(), KnowledgeSearchTypeEnum.valueOf(infoEntity.getKnowledgeSearchType()),
......@@ -258,7 +258,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
String redisKey = AGENT_APPLICATION_RECOMMEND_QUESTIONS + xlang;
if (!redisService.hasKey(redisKey)) {
synchronized (AgentApplicationInfoService.class) {
synchronized (AgentApplicationService.class) {
if (!redisService.hasKey(redisKey)) {
createRecommendQuestion();
}
......
package cn.com.poc.expose.rest.impl;
import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService;
import cn.com.poc.agent_application.aggregate.AgentApplicationService;
import cn.com.poc.agent_application.convert.AgentApplicationInfoConvert;
import cn.com.poc.agent_application.convert.BizAgentApplicationPublishConvert;
import cn.com.poc.agent_application.dto.AgentApplicationCreateContinueQuesDto;
......@@ -19,7 +19,7 @@ import cn.com.poc.common.utils.StringUtils;
import cn.com.poc.common.utils.UUIDTool;
import cn.com.poc.equity.aggregate.PointDeductionRulesService;
import cn.com.poc.equity.entity.BizPointDeductionRulesEntity;
import cn.com.poc.expose.aggregate.AgentApplicationService;
import cn.com.poc.expose.aggregate.AgentApplicationExposeService;
import cn.com.poc.expose.dto.*;
import cn.com.poc.expose.rest.AgentApplicationRest;
import cn.com.poc.message.entity.AgentApplicationClickEventMessage;
......@@ -50,10 +50,10 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
private Logger logger = LoggerFactory.getLogger(AgentApplicationRest.class);
@Resource
private AgentApplicationService agentApplicationService;
private AgentApplicationExposeService agentApplicationExposeService;
@Resource
private AgentApplicationInfoService agentApplicationInfoService;
private AgentApplicationService agentApplicationService;
@Resource
private BizAgentApplicationPublishService bizAgentApplicationPublishService;
......@@ -70,7 +70,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
@Override
public List<String> getRecommendQuestions(HttpServletRequest httpServletRequest) throws Exception {
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
return agentApplicationService.getRecommendQuestions(httpServletRequest.getHeader("x-lang"), userBaseEntity.getUserId());
return agentApplicationExposeService.getRecommendQuestions(httpServletRequest.getHeader("x-lang"), userBaseEntity.getUserId());
}
@Override
......@@ -80,7 +80,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
throw new I18nMessageException("exception/user.not.login");
}
Long memberId = userBaseEntity.getUserId();
List<MemberCollectQueryItem> collectedApplications = agentApplicationService.getCollectedApplications(memberId, pagingInfo);
List<MemberCollectQueryItem> collectedApplications = agentApplicationExposeService.getCollectedApplications(memberId, pagingInfo);
List<UserCollectDto> result = new ArrayList<>();
if (CollectionUtils.isNotEmpty(collectedApplications)) {
for (MemberCollectQueryItem item : collectedApplications) {
......@@ -112,7 +112,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
Assert.notNull(dto.getAgentId());
Assert.notNull(dto.getDialogsId());
try {
agentApplicationService.callAgentApplication(dto.getAgentId(), dto.getDialogsId(), dto.getInput(), dto.getFileUrls(), dto.getChannel(), dto.getImageUrl(), httpServletResponse);
agentApplicationExposeService.callAgentApplication(dto.getAgentId(), dto.getDialogsId(), dto.getInput(), dto.getFileUrls(), dto.getChannel(), dto.getImageUrl(), httpServletResponse);
} catch (Exception e) {
httpServletResponse.setContentType("text/event-stream");
PrintWriter writer = httpServletResponse.getWriter();
......@@ -181,13 +181,13 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
@Override
public void unPublish(String agentId) throws Exception {
Assert.notBlank(agentId);
agentApplicationInfoService.unPublish(agentId);
agentApplicationService.unPublish(agentId);
}
@Override
public List<String> createContinueQuestions(AgentApplicationCreateContinueQuesDto dto) throws Exception {
Assert.notNull(dto.getInput());
return agentApplicationService.createContinueQuestions(dto.getInput());
return agentApplicationExposeService.createContinueQuestions(dto.getInput());
}
@Override
......@@ -257,7 +257,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
public String autoPlayByAgentId(String agentId) {
Assert.notBlank(agentId);
UserBaseEntity currentUser = BlContext.getCurrentUser();
return agentApplicationService.autoPlayByAgentId(currentUser.getUserId(), agentId);
return agentApplicationExposeService.autoPlayByAgentId(currentUser.getUserId(), agentId);
}
@Override
......@@ -266,13 +266,13 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
Assert.notBlank(autoPlay);
Assert.isTrue(CommonConstant.YOrN.N.equals(autoPlay) || CommonConstant.YOrN.Y.equals(autoPlay));
UserBaseEntity currentUser = BlContext.getCurrentUser();
return agentApplicationService.enableAutoPlay(currentUser.getUserId(), agentId, autoPlay);
return agentApplicationExposeService.enableAutoPlay(currentUser.getUserId(), agentId, autoPlay);
}
@Override
public AgentApplicationApiProfileDto getApiProfile() {
UserBaseEntity userBaseEntity = BlContext.getCurrentUser();
BizAgentApplicationApiProfileEntity apiProfileEntity = agentApplicationService.getApiProfile(userBaseEntity.getUserId());
BizAgentApplicationApiProfileEntity apiProfileEntity = agentApplicationExposeService.getApiProfile(userBaseEntity.getUserId());
AgentApplicationApiProfileDto result = new AgentApplicationApiProfileDto();
result.setApiKey(apiProfileEntity.getApiKey());
result.setApiSecret(apiProfileEntity.getApiSecret());
......@@ -282,7 +282,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
@Override
public AgentApplicationApiProfileDto resetApiProfile() throws Exception {
UserBaseEntity userBaseEntity = BlContext.getCurrentUser();
BizAgentApplicationApiProfileEntity apiProfileEntity = agentApplicationService.resetApiProfile(userBaseEntity.getUserId());
BizAgentApplicationApiProfileEntity apiProfileEntity = agentApplicationExposeService.resetApiProfile(userBaseEntity.getUserId());
AgentApplicationApiProfileDto result = new AgentApplicationApiProfileDto();
result.setApiKey(apiProfileEntity.getApiKey());
result.setApiSecret(apiProfileEntity.getApiSecret());
......
package cn.com.poc.expose.rest.impl;
import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService;
import cn.com.poc.agent_application.aggregate.AgentApplicationService;
import cn.com.poc.common.utils.BlContext;
import cn.com.poc.common.utils.ListUtils;
import cn.com.poc.data_analyze.constants.DataAnalyzeChannelEnum;
import cn.com.poc.data_analyze.entity.*;
import cn.com.poc.expose.aggregate.AgentDataAnalyzeService;
import cn.com.poc.expose.dto.agent_data_analyze.*;
import cn.com.poc.expose.rest.AgentDataAnalyzeRest;
import cn.com.poc.support.security.oauth.entity.UserBaseEntity;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.hutool.core.collection.ListUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Component;
......@@ -31,7 +28,7 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest {
private AgentDataAnalyzeService agentDataAnalyzeService;
@Resource
private AgentApplicationInfoService agentApplicationInfoService;
private AgentApplicationService agentApplicationService;
@Override
public List<AgentDataAnalyzeGeneralDto> getGeneralUsageData(String agentId, List<String> channel) {
......@@ -128,7 +125,7 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest {
if (userBaseEntity == null) {
throw new I18nMessageException("exception/user.does.not.exist");
}
if (!agentApplicationInfoService.hasPublishAgentPermission(agentId, userBaseEntity.getUserId())) {
if (!agentApplicationService.hasPublishAgentPermission(agentId, userBaseEntity.getUserId())) {
throw new I18nMessageException("exception/no.permission");
}
}
......
......@@ -3,7 +3,7 @@ package cn.com.poc.agent_application;
import cn.com.poc.agent_application.entity.BizAgentApplicationApiProfileEntity;
import cn.com.poc.agent_application.service.BizAgentApplicationApiProfileService;
import cn.com.poc.common.utils.JsonUtils;
import cn.com.poc.expose.aggregate.AgentApplicationService;
import cn.com.poc.expose.aggregate.AgentApplicationExposeService;
import cn.com.poc.expose.dto.AgentApplicationApiProfileDto;
import cn.com.yict.framemax.core.spring.SingleContextInitializer;
import org.junit.Test;
......@@ -34,12 +34,12 @@ public class AgentApplicationApiProfileTest {
}
@Resource
private AgentApplicationService agentApplicationService;
private AgentApplicationExposeService agentApplicationExposeService;
@Test
public void test_getApiProfile() {
String agentId = "d37d4a9b2fe0421ea991127c247fbbf3";
BizAgentApplicationApiProfileEntity apiProfileEntity = agentApplicationService.getApiProfile(197L);
BizAgentApplicationApiProfileEntity apiProfileEntity = agentApplicationExposeService.getApiProfile(197L);
AgentApplicationApiProfileDto result = new AgentApplicationApiProfileDto();
result.setApiKey(apiProfileEntity.getApiKey());
result.setApiSecret(apiProfileEntity.getApiSecret());
......
......@@ -4,14 +4,12 @@ import cn.com.poc.agent_application.query.MemberCollectQueryCondition;
import cn.com.poc.agent_application.query.MemberCollectQueryItem;
import cn.com.poc.agent_application.service.BizMemberAgentApplicationCollectService;
import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.expose.aggregate.impl.AgentApplicationServiceImpl;
import cn.com.poc.expose.aggregate.impl.AgentApplicationExposeServiceImpl;
import cn.com.yict.framemax.core.spring.SingleContextInitializer;
import cn.com.yict.framemax.data.model.PagingInfo;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
......@@ -27,11 +25,11 @@ import static org.mockito.Mockito.when;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(initializers = SingleContextInitializer.class)
@WebAppConfiguration
public class AgentApplicationServiceTest {
public class AgentApplicationExposeServiceTest {
private BizMemberAgentApplicationCollectService bizMemberAgentApplicationCollectService;
@Resource
private AgentApplicationServiceImpl agentApplicationService;
private AgentApplicationExposeServiceImpl agentApplicationService;
private Long memberId;
private PagingInfo pagingInfo;
......
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