use of org.apache.shenyu.admin.model.entity.MetaDataDO in project incubator-shenyu by apache.
the class MetaDataServiceImpl method delete.
@Override
@Transactional(rollbackFor = Exception.class)
public int delete(final List<String> ids) {
int count = 0;
Set<String> idSet = Optional.ofNullable(ids).orElseGet(ArrayList::new).stream().filter(StringUtils::isNotEmpty).collect(Collectors.toSet());
if (CollectionUtils.isNotEmpty(idSet)) {
List<MetaDataDO> metaDataDoList = metaDataMapper.selectByIdSet(idSet);
List<MetaData> metaDataList = Optional.ofNullable(metaDataDoList).orElseGet(ArrayList::new).stream().map(MetaDataTransfer.INSTANCE::mapToData).collect(Collectors.toList());
count = metaDataMapper.deleteByIdSet(idSet);
eventPublisher.publishEvent(new DataChangedEvent(ConfigGroupEnum.META_DATA, DataEventTypeEnum.DELETE, metaDataList));
}
return count;
}
use of org.apache.shenyu.admin.model.entity.MetaDataDO in project incubator-shenyu by apache.
the class MetaDataServiceImpl method saveOrUpdateMetaData.
@Override
public void saveOrUpdateMetaData(final MetaDataDO exist, final MetaDataRegisterDTO metaDataDTO) {
DataEventTypeEnum eventType;
MetaDataDO metaDataDO = MetaDataTransfer.INSTANCE.mapRegisterDTOToEntity(metaDataDTO);
if (Objects.isNull(exist)) {
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
metaDataDO.setId(UUIDUtils.getInstance().generateShortUuid());
metaDataDO.setDateCreated(currentTime);
metaDataDO.setDateUpdated(currentTime);
metaDataMapper.insert(metaDataDO);
eventType = DataEventTypeEnum.CREATE;
} else {
metaDataDO.setId(exist.getId());
metaDataMapper.update(metaDataDO);
eventType = DataEventTypeEnum.UPDATE;
}
// publish MetaData's event
eventPublisher.publishEvent(new DataChangedEvent(ConfigGroupEnum.META_DATA, eventType, Collections.singletonList(MetaDataTransfer.INSTANCE.mapToData(metaDataDO))));
}
use of org.apache.shenyu.admin.model.entity.MetaDataDO in project incubator-shenyu by apache.
the class ShenyuClientRegisterSofaServiceImpl method registerMetadata.
@Override
protected void registerMetadata(final MetaDataRegisterDTO metaDataDTO) {
MetaDataService metaDataService = getMetaDataService();
MetaDataDO exist = metaDataService.findByServiceNameAndMethodName(metaDataDTO.getServiceName(), metaDataDTO.getMethodName());
metaDataService.saveOrUpdateMetaData(exist, metaDataDTO);
}
use of org.apache.shenyu.admin.model.entity.MetaDataDO in project incubator-shenyu by apache.
the class ShenyuClientRegisterSpringCloudServiceImpl method registerMetadata.
@Override
protected void registerMetadata(final MetaDataRegisterDTO metaDataDTO) {
MetaDataService metaDataService = getMetaDataService();
metaDataDTO.setPath(PathUtils.decoratorPath(metaDataDTO.getContextPath()));
MetaDataDO metaDataDO = metaDataService.findByPath(metaDataDTO.getPath());
metaDataService.saveOrUpdateMetaData(metaDataDO, metaDataDTO);
}
use of org.apache.shenyu.admin.model.entity.MetaDataDO in project incubator-shenyu by apache.
the class ShenyuClientRegisterTarsServiceImpl method registerMetadata.
@Override
protected void registerMetadata(final MetaDataRegisterDTO metaDataDTO) {
MetaDataService metaDataService = getMetaDataService();
MetaDataDO exist = metaDataService.findByServiceNameAndMethodName(metaDataDTO.getServiceName(), metaDataDTO.getMethodName());
metaDataService.saveOrUpdateMetaData(exist, metaDataDTO);
}
Aggregations