diff --git a/CHANGES.md b/CHANGES.md index 80a3bb1f667..468ef1408d7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,5 +8,6 @@ Apollo 2.0.1 * [Upgrade spring boot to fix search user issue](https://github.com/apolloconfig/apollo/pull/4366) * [Fix search user duplication issue](https://github.com/apolloconfig/apollo/pull/4371) * [Fix the npe issue for old version of gray release rules](https://github.com/apolloconfig/apollo/pull/4382) +* [Fix the delete AppNamespace failed issue](https://github.com/apolloconfig/apollo/pull/4388) ------------------ All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/12?closed=1) diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java index 46e783a6a9d..596229d76fc 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java @@ -43,10 +43,10 @@ public interface AppNamespaceRepository extends PagingAndSortingRepository findFirst500ByIdGreaterThanOrderByIdAsc(long id); @Modifying - @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE AppId=?1") + @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE AppId=?1 and IsDeleted = 0") int batchDeleteByAppId(String appId, String operator); @Modifying - @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?3 WHERE AppId=?1 and Name = ?2") + @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?3 WHERE AppId=?1 and Name = ?2 and IsDeleted = 0") int delete(String appId, String namespaceName, String operator); } diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java index dab026c945d..9d5a90bea18 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java @@ -35,7 +35,7 @@ List findByAppIdAndClusterNameAndNamespaceNameAndDataChangeLastModifiedT String appId, String clusterName, String namespaceName, Date dataChangeLastModifiedTime, Pageable pageable); @Modifying - @Query("update Commit set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3") + @Query("update Commit set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3 and IsDeleted = 0") int batchDelete(String appId, String clusterName, String namespaceName, String operator); List findByAppIdAndClusterNameAndNamespaceNameAndChangeSetsLikeOrderByIdDesc(String appId, String clusterName, String namespaceName,String changeSets, Pageable page); diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java index d9d61769f4c..136bc269007 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java @@ -42,7 +42,7 @@ public interface ItemRepository extends PagingAndSortingRepository { Item findFirst1ByNamespaceIdOrderByLineNumDesc(Long namespaceId); @Modifying - @Query("update Item set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 where namespaceId = ?1") + @Query("update Item set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 where namespaceId = ?1 and IsDeleted = 0") int deleteByNamespaceId(long namespaceId, String operator); } diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java index 6ca111c8a97..b0d27810274 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java @@ -33,7 +33,7 @@ public interface NamespaceRepository extends PagingAndSortingRepository findByAppIdAndNamespaceNameOrderByIdAsc(String appId, String namespaceName); diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java index 1671fa194ef..342dc505c8a 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java @@ -39,7 +39,7 @@ Page findByAppIdAndClusterNameAndNamespaceNameOrderByIdDesc(Stri Page findByReleaseIdAndOperationInOrderByIdDesc(long releaseId, Set operations, Pageable pageable); @Modifying - @Query("update ReleaseHistory set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3") + @Query("update ReleaseHistory set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3 and IsDeleted = 0") int batchDelete(String appId, String clusterName, String namespaceName, String operator); } diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java index ce0afe3ac7f..dfa87b59a8f 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java @@ -48,7 +48,7 @@ Release findFirstByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderBy List findByIdIn(Set releaseIds); @Modifying - @Query("update Release set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3") + @Query("update Release set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3 and IsDeleted = 0") int batchDelete(String appId, String clusterName, String namespaceName, String operator); // For release history conversion program, need to delete after conversion it done diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java index 7f48c3d16d5..0e9d0b3a31e 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java @@ -43,6 +43,6 @@ public interface ConsumerRoleRepository extends PagingAndSortingRepository roleIds, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java index 8bc7bb0b3ec..0c385915fca 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java @@ -35,10 +35,10 @@ public interface AppNamespaceRepository extends PagingAndSortingRepository findByAppId(String appId); @Modifying - @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy=?2 WHERE AppId=?1") + @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy=?2 WHERE AppId=?1 and IsDeleted = 0") int batchDeleteByAppId(String appId, String operator); @Modifying - @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?3 WHERE AppId=?1 and Name = ?2") + @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?3 WHERE AppId=?1 and Name = ?2 and IsDeleted = 0") int delete(String appId, String namespaceName, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppRepository.java index 175395e1914..b88bcb3b3bd 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppRepository.java @@ -41,6 +41,6 @@ public interface AppRepository extends PagingAndSortingRepository { Page findByAppIdContainingOrNameContaining(String appId, String name, Pageable pageable); @Modifying - @Query("UPDATE App SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE AppId=?1") + @Query("UPDATE App SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE AppId=?1 and IsDeleted = 0") int deleteApp(String appId, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java index 2198caef21b..37bc92b2f16 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java @@ -36,6 +36,6 @@ public interface FavoriteRepository extends PagingAndSortingRepository findByPermissionTypeInAndTargetId(Collection permission List findPermissionIdsByAppIdAndNamespace(String appId, String namespaceName); @Modifying - @Query("UPDATE Permission SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE Id in ?1") + @Query("UPDATE Permission SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE Id in ?1 and IsDeleted = 0") Integer batchDelete(List permissionIds, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java index 2b1f0391b14..a23dc3f31ef 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java @@ -36,6 +36,6 @@ public interface RolePermissionRepository extends PagingAndSortingRepository findByRoleIdIn(Collection roleId); @Modifying - @Query("UPDATE RolePermission SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE PermissionId in ?1") + @Query("UPDATE RolePermission SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE PermissionId in ?1 and IsDeleted = 0") Integer batchDeleteByPermissionIds(List permissionIds, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java index c7241fd5c85..008cab1559f 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java @@ -43,6 +43,6 @@ public interface RoleRepository extends PagingAndSortingRepository { List findRoleIdsByAppIdAndNamespace(String appId, String namespaceName); @Modifying - @Query("UPDATE Role SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE Id in ?1") + @Query("UPDATE Role SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE Id in ?1 and IsDeleted = 0") Integer batchDelete(List roleIds, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java index 0796cf045b4..c79893e8979 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java @@ -45,7 +45,7 @@ public interface UserRoleRepository extends PagingAndSortingRepository findByUserIdInAndRoleId(Collection userId, long roleId); @Modifying - @Query("UPDATE UserRole SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE RoleId in ?1") + @Query("UPDATE UserRole SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE RoleId in ?1 and IsDeleted = 0") Integer batchDeleteByRoleIds(List roleIds, String operator); }