Commit cbc9d777 authored by alex yao's avatar alex yao

feat:Agent应用配置保存 参数验证和转换

parent c507bd6d
......@@ -45,6 +45,9 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
public AgentApplicationInfoDto saveOrUpdate(AgentApplicationInfoDto dto) throws Exception {
Assert.notNull(dto);
Assert.notNull(dto.getBaseInfo());
Assert.notNull(dto.getCommConfig());
Assert.notNull(dto.getCommModelConfig());
Assert.notNull(dto.getKnowledgeConfig());
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
Long userId = userBaseEntity.getUserId();
dto.getBaseInfo().setMemberId(userId.intValue());
......@@ -58,6 +61,9 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
Assert.notNull(dto);
Assert.notNull(dto.getBaseInfo());
Assert.notNull(dto.getBaseInfo().getAgentId(), "id不能为空");
Assert.notNull(dto.getCommConfig());
Assert.notNull(dto.getCommModelConfig());
Assert.notNull(dto.getKnowledgeConfig());
BizAgentApplicationInfoEntity entity = AgentApplicationInfoConvert.dtoToEntity(dto);
return AgentApplicationInfoConvert.entityToDto(bizAgentApplicationInfoService.update(entity));
}
......@@ -83,6 +89,12 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
Assert.notNull(dto);
Assert.notNull(dto.getBaseInfo());
Assert.notNull(dto.getBaseInfo().getAgentId(), "id不能为空");
Assert.notNull(dto.getCommConfig());
Assert.notNull(dto.getCommModelConfig());
Assert.notNull(dto.getKnowledgeConfig());
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
Long userId = userBaseEntity.getUserId();
dto.getBaseInfo().setMemberId(userId.intValue());
dto.getBaseInfo().setAgentPublishStatus(AgentApplicationConstants.AGENT_PUBLISH_STATUS.PUBLISH);
if (null == bizAgentApplicationInfoService.update(AgentApplicationInfoConvert.dtoToEntity(dto))) {
throw new BusinessException("发布失败");
......
......@@ -16,6 +16,8 @@ public interface BizAgentApplicationInfoService extends BaseService {
BizAgentApplicationInfoEntity update(BizAgentApplicationInfoEntity entity) throws Exception;
BizAgentApplicationInfoEntity saveOrUpdate(BizAgentApplicationInfoEntity entity) throws Exception;
void deletedByAgentId(String agentId);
boolean publish(String agentId) throws Exception;
......
......@@ -12,8 +12,10 @@ import cn.com.poc.agent_application.entity.BizAgentApplicationInfoEntity;
import cn.com.poc.agent_application.convert.AgentApplicationInfoConvert;
import cn.com.poc.agent_application.repository.BizAgentApplicationInfoRepository;
import cn.com.yict.framemax.data.model.PagingInfo;
import cn.hutool.core.bean.BeanUtil;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.apache.commons.collections4.CollectionUtils;
......@@ -102,6 +104,18 @@ public class BizAgentApplicationInfoServiceImpl extends BaseServiceImpl
return AgentApplicationInfoConvert.modelToEntity(saveModel);
}
@Override
public BizAgentApplicationInfoEntity saveOrUpdate(BizAgentApplicationInfoEntity entity) throws Exception {
Assert.notNull(entity);
BizAgentApplicationInfoModel model = new BizAgentApplicationInfoModel();
BeanUtils.copyProperties(entity, model);
if (StringUtils.isBlank(entity.getAgentId())) {
model.setAgentId(UUIDTool.getUUID());
}
BizAgentApplicationInfoModel saveModel = this.repository.save(model);
return AgentApplicationInfoConvert.modelToEntity(saveModel);
}
@Override
public boolean publish(String agentId) throws Exception {
Assert.notNull(agentId);
......
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