Skip to content

Commit

Permalink
fix the delete appnamespace failed issue
Browse files Browse the repository at this point in the history
  • Loading branch information
nobodyiam committed May 29, 2022
1 parent 1cdbd14 commit 7d50d88
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public interface AppNamespaceRepository extends PagingAndSortingRepository<AppNa
List<AppNamespace> 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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ List<Commit> 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<Commit> findByAppIdAndClusterNameAndNamespaceNameAndChangeSetsLikeOrderByIdDesc(String appId, String clusterName, String namespaceName,String changeSets, Pageable page);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public interface ItemRepository extends PagingAndSortingRepository<Item, Long> {
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);

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface NamespaceRepository extends PagingAndSortingRepository<Namespac
Namespace findByAppIdAndClusterNameAndNamespaceName(String appId, String clusterName, String namespaceName);

@Modifying
@Query("update Namespace set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?3 where appId=?1 and clusterName=?2")
@Query("update Namespace set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?3 where appId=?1 and clusterName=?2 and IsDeleted = 0")
int batchDelete(String appId, String clusterName, String operator);

List<Namespace> findByAppIdAndNamespaceNameOrderByIdAsc(String appId, String namespaceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Page<ReleaseHistory> findByAppIdAndClusterNameAndNamespaceNameOrderByIdDesc(Stri
Page<ReleaseHistory> findByReleaseIdAndOperationInOrderByIdDesc(long releaseId, Set<Integer> 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);

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Release findFirstByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderBy
List<Release> findByIdIn(Set<Long> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ public interface ConsumerRoleRepository extends PagingAndSortingRepository<Consu
ConsumerRole findByConsumerIdAndRoleId(long consumerId, long roleId);

@Modifying
@Query("UPDATE ConsumerRole SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE RoleId in ?1")
@Query("UPDATE ConsumerRole SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE RoleId in ?1 and IsDeleted = 0")
Integer batchDeleteByRoleIds(List<Long> roleIds, String operator);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public interface AppNamespaceRepository extends PagingAndSortingRepository<AppNa
List<AppNamespace> 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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public interface AppRepository extends PagingAndSortingRepository<App, Long> {
Page<App> 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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public interface FavoriteRepository extends PagingAndSortingRepository<Favorite,
Favorite findByUserIdAndAppId(String userId, String appId);

@Modifying
@Query("UPDATE Favorite SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE AppId=?1")
@Query("UPDATE Favorite 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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ List<Permission> findByPermissionTypeInAndTargetId(Collection<String> permission
List<Long> 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<Long> permissionIds, String operator);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public interface RolePermissionRepository extends PagingAndSortingRepository<Rol
List<RolePermission> findByRoleIdIn(Collection<Long> 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<Long> permissionIds, String operator);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ public interface RoleRepository extends PagingAndSortingRepository<Role, Long> {
List<Long> 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<Long> roleIds, String operator);
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public interface UserRoleRepository extends PagingAndSortingRepository<UserRole,
List<UserRole> findByUserIdInAndRoleId(Collection<String> 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<Long> roleIds, String operator);

}

0 comments on commit 7d50d88

Please sign in to comment.