Commit d53b2f5e authored by alex yao's avatar alex yao

feat: 应用下架

parent f6930f20
......@@ -22,6 +22,14 @@ public interface AgentApplicationInfoService {
Integer[] knowledgeIds, Integer communicationTurn, Float topP,
List<Message> messages, List<Tool> tools, HttpServletResponse httpServletResponse) throws Exception;
/**
* 应用下架
*
* @param agentId
* @return
*/
boolean unPublish(String agentId) throws Exception;
/**
* 角色指令AI生成
......
......@@ -323,6 +323,12 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
return JsonUtils.deSerialize(res.substring(start, end + 1), CreateAgentTitleAndDescEntity.class);
}
@Override
public boolean unPublish(String agentId) throws Exception {
bizAgentApplicationPublishService.deleteByAgentId(agentId);
bizAgentApplicationInfoService.unPublish(agentId);
return true;
}
/**
* 构建应用信息提示词
......
......@@ -2,24 +2,16 @@ package cn.com.poc.agent_application.constant;
public interface AgentApplicationConstants {
interface USE_AGENT_STATUS {
String PREVIEW = "preview";
String PUBLISH = "publish";
}
interface TOOLS {
int FUNCTION_NUMBER = 4;
}
interface AGENT_PUBLISH_STATUS {
String DRAFT = "draft"; // 草稿
String PUBLISH = "publish"; // 发布
String UN_PUBLISH = "unPublish"; // 已下架
static boolean isPublishStatus(String status) {
return PUBLISH.equals(status) || DRAFT.equals(status);
return PUBLISH.equals(status) || DRAFT.equals(status) || UN_PUBLISH.equals(status);
}
}
......
......@@ -27,4 +27,6 @@ public interface BizAgentApplicationInfoService extends BaseService {
boolean publish(String agentId) throws Exception;
boolean unPublish(String agentId);
}
\ No newline at end of file
......@@ -129,7 +129,7 @@ public class BizAgentApplicationInfoServiceImpl extends BaseServiceImpl
}
@Override
public boolean publish(String agentId) throws Exception {
public boolean publish(String agentId) {
Assert.notNull(agentId);
BizAgentApplicationInfoModel model = new BizAgentApplicationInfoModel();
model.setAgentId(agentId);
......@@ -138,11 +138,28 @@ public class BizAgentApplicationInfoServiceImpl extends BaseServiceImpl
if (CollectionUtils.isEmpty(models)) {
return false;
}
model = models.get(0);
model.setAgentPublishStatus(AgentApplicationConstants.AGENT_PUBLISH_STATUS.PUBLISH);
this.repository.save(model);
return true;
}
@Override
public boolean unPublish(String agentId) {
Assert.notNull(agentId);
BizAgentApplicationInfoModel model = new BizAgentApplicationInfoModel();
model.setAgentId(agentId);
model.setIsDeleted(CommonConstant.IsDeleted.N);
List<BizAgentApplicationInfoModel> models = this.repository.findByExample(model);
if (CollectionUtils.isEmpty(models)) {
return false;
}
model = models.get(0);
model.setAgentPublishStatus(AgentApplicationConstants.AGENT_PUBLISH_STATUS.UN_PUBLISH);
this.repository.save(model);
return true;
}
/**
* 参数验证和转换 Entity To Model
*
......
......@@ -43,6 +43,11 @@ public interface AgentApplicationRest extends BaseRest {
@Permission(value = Access.Anonymous)
BizAgentApplicationPublishDto getInfo(@RequestParam String agentId) throws Exception;
/**
* 下架已发布应用
*/
void unPublish(@RequestParam String agentId) throws Exception;
/**
* 追问
*/
......
package cn.com.poc.expose.rest.impl;
import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService;
import cn.com.poc.agent_application.convert.AgentApplicationInfoConvert;
import cn.com.poc.agent_application.convert.BizAgentApplicationDialoguesRecordConvert;
import cn.com.poc.agent_application.convert.BizAgentApplicationPublishConvert;
......@@ -46,6 +47,9 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
@Resource
private AgentApplicationService agentApplicationService;
@Resource
private AgentApplicationInfoService agentApplicationInfoService;
@Resource
private BizAgentApplicationPublishService bizAgentApplicationPublishService;
......@@ -98,6 +102,12 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
return BizAgentApplicationPublishConvert.entityToDto(entity);
}
@Override
public void unPublish(String agentId) throws Exception {
Assert.notBlank(agentId, "应用ID不能为空");
agentApplicationInfoService.unPublish(agentId);
}
@Override
public List<String> createContinueQuestions(AgentApplicationCreateContinueQuesDto dto) throws Exception {
cn.com.poc.common.utils.Assert.notNull(dto.getInput(), "input不能为空");
......@@ -139,7 +149,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
}
@Override
public void batchCloseDialogues(List<String> dialogueIds) {
public void batchCloseDialogues(List<String> dialogueIds) {
bizAgentApplicationDialoguesRecordService.batchDeleteByDialogueId(dialogueIds);
}
......
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