优化收到接口注册

This commit is contained in:
六如
2025-02-20 10:58:32 +08:00
parent 09eef2f049
commit 914adf6918

View File

@@ -39,8 +39,9 @@ public class ApiRegisterServiceImpl implements ApiRegisterService {
apiInfoDTO.setStatus(StatusEnum.ENABLE.getValue());
ApiInfo apiInfo = apiInfoMapper.getByNameVersion(apiInfoDTO.getApiName(), apiInfoDTO.getApiVersion());
boolean isSave = false;
if (apiInfo == null) {
isSave = true;
apiInfo = new ApiInfo();
} else {
check(apiInfo, registerDTO);
@@ -48,7 +49,11 @@ public class ApiRegisterServiceImpl implements ApiRegisterService {
CopyUtil.copyPropertiesIgnoreNull(apiInfoDTO, apiInfo);
apiInfo.setRegSource(REG_SOURCE_SYS);
// 保存到数据库
apiInfoMapper.saveOrUpdateIgnoreNull(apiInfo);
if (isSave) {
apiInfoMapper.saveIgnoreNull(apiInfo);
} else {
apiInfoMapper.updateIgnoreNull(apiInfo);
}
apiInfoDTO.setId(apiInfo.getId());
// 保存到缓存
apiManager.save(apiInfoDTO);