Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apollo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
apollo
Commits
2d9ece83
Commit
2d9ece83
authored
Jul 22, 2018
by
nobodyiam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor a little bit
parent
e25fe0ce
Changes
40
Hide whitespace changes
Inline
Side-by-side
Showing
40 changed files
with
644 additions
and
766 deletions
+644
-766
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/AppController.java
...amework/apollo/adminservice/controller/AppController.java
+1
-19
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java
...amework/apollo/biz/repository/AppNamespaceRepository.java
+1
-3
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppRepository.java
.../ctrip/framework/apollo/biz/repository/AppRepository.java
+0
-7
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ClusterRepository.java
...ip/framework/apollo/biz/repository/ClusterRepository.java
+0
-8
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java
...rip/framework/apollo/biz/repository/CommitRepository.java
+0
-5
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/GrayReleaseRuleRepository.java
...work/apollo/biz/repository/GrayReleaseRuleRepository.java
+2
-4
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java
.../framework/apollo/biz/repository/NamespaceRepository.java
+0
-5
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java
...ework/apollo/biz/repository/ReleaseHistoryRepository.java
+0
-5
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java
...ip/framework/apollo/biz/repository/ReleaseRepository.java
+0
-6
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AdminService.java
.../com/ctrip/framework/apollo/biz/service/AdminService.java
+11
-45
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppNamespaceService.java
...rip/framework/apollo/biz/service/AppNamespaceService.java
+2
-4
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppService.java
...va/com/ctrip/framework/apollo/biz/service/AppService.java
+0
-7
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ClusterService.java
...om/ctrip/framework/apollo/biz/service/ClusterService.java
+0
-7
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/CommitService.java
...com/ctrip/framework/apollo/biz/service/CommitService.java
+0
-6
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/GrayReleaseRuleService.java
.../framework/apollo/biz/service/GrayReleaseRuleService.java
+2
-4
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java
.../ctrip/framework/apollo/biz/service/NamespaceService.java
+13
-26
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseHistoryService.java
...p/framework/apollo/biz/service/ReleaseHistoryService.java
+0
-7
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java
...om/ctrip/framework/apollo/biz/service/ReleaseService.java
+0
-6
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepositoryTest.java
...ork/apollo/biz/repository/AppNamespaceRepositoryTest.java
+0
-7
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AppRepositoryTest.java
...ip/framework/apollo/biz/repository/AppRepositoryTest.java
+0
-25
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AdminServiceTest.java
.../ctrip/framework/apollo/biz/service/AdminServiceTest.java
+75
-75
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java
...ork/apollo/openapi/repository/ConsumerRoleRepository.java
+6
-0
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
...om/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
+409
-394
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java
...rip/framework/apollo/portal/controller/AppController.java
+2
-4
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppDeletionEvent.java
...ip/framework/apollo/portal/listener/AppDeletionEvent.java
+0
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppInfoChangedListener.java
...mework/apollo/portal/listener/AppInfoChangedListener.java
+1
-3
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java
...work/apollo/portal/repository/AppNamespaceRepository.java
+1
-3
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java
...ramework/apollo/portal/repository/FavoriteRepository.java
+1
-3
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/PermissionRepository.java
...mework/apollo/portal/repository/PermissionRepository.java
+6
-7
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java
...rk/apollo/portal/repository/RolePermissionRepository.java
+5
-0
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java
...ip/framework/apollo/portal/repository/RoleRepository.java
+10
-7
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java
...ramework/apollo/portal/repository/UserRoleRepository.java
+6
-0
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppNamespaceService.java
.../framework/apollo/portal/service/AppNamespaceService.java
+2
-4
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppService.java
...com/ctrip/framework/apollo/portal/service/AppService.java
+10
-4
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/FavoriteService.java
...trip/framework/apollo/portal/service/FavoriteService.java
+2
-4
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultRolePermissionService.java
.../portal/spi/defaultimpl/DefaultRolePermissionService.java
+28
-3
scripts/docker-quick-start/sql/apolloconfigdb.sql
scripts/docker-quick-start/sql/apolloconfigdb.sql
+11
-11
scripts/docker-quick-start/sql/apolloportaldb.sql
scripts/docker-quick-start/sql/apolloportaldb.sql
+25
-25
scripts/sql/apolloconfigdb.sql
scripts/sql/apolloconfigdb.sql
+5
-5
scripts/sql/apolloportaldb.sql
scripts/sql/apolloportaldb.sql
+7
-7
No files found.
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/AppController.java
View file @
2d9ece83
...
@@ -6,7 +6,6 @@ import com.ctrip.framework.apollo.common.dto.AppDTO;
...
@@ -6,7 +6,6 @@ import com.ctrip.framework.apollo.common.dto.AppDTO;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.InputValidator
;
import
com.ctrip.framework.apollo.common.utils.InputValidator
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
...
@@ -55,7 +54,7 @@ public class AppController {
...
@@ -55,7 +54,7 @@ public class AppController {
if
(
entity
==
null
)
{
if
(
entity
==
null
)
{
throw
new
NotFoundException
(
"app not found for appId "
+
appId
);
throw
new
NotFoundException
(
"app not found for appId "
+
appId
);
}
}
a
ppService
.
delete
(
entity
.
getId
()
,
operator
);
a
dminService
.
deleteApp
(
entity
,
operator
);
}
}
@RequestMapping
(
value
=
"/apps/{appId:.+}"
,
method
=
RequestMethod
.
PUT
)
@RequestMapping
(
value
=
"/apps/{appId:.+}"
,
method
=
RequestMethod
.
PUT
)
...
@@ -92,21 +91,4 @@ public class AppController {
...
@@ -92,21 +91,4 @@ public class AppController {
public
boolean
isAppIdUnique
(
@PathVariable
(
"appId"
)
String
appId
)
{
public
boolean
isAppIdUnique
(
@PathVariable
(
"appId"
)
String
appId
)
{
return
appService
.
isAppIdUnique
(
appId
);
return
appService
.
isAppIdUnique
(
appId
);
}
}
@RequestMapping
(
value
=
"/apps"
,
method
=
RequestMethod
.
DELETE
)
public
void
deleteApp
(
@RequestParam
(
"appId"
)
String
appId
,
@RequestParam
(
"operator"
)
String
operator
)
{
App
app
=
appService
.
findOne
(
appId
);
if
(
Objects
.
isNull
(
app
))
{
throw
new
NotFoundException
(
"app not found for appId "
+
appId
);
}
try
{
adminService
.
deleteApp
(
appId
,
operator
);
}
catch
(
Exception
e
)
{
String
exc
=
String
.
format
(
"user:%s deleting app:%s,failure:%s"
,
operator
,
app
,
e
.
getMessage
());
throw
new
ServiceException
(
exc
);
}
}
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java
View file @
2d9ece83
...
@@ -28,7 +28,5 @@ public interface AppNamespaceRepository extends PagingAndSortingRepository<AppNa
...
@@ -28,7 +28,5 @@ public interface AppNamespaceRepository extends PagingAndSortingRepository<AppNa
@Modifying
@Modifying
@Query
(
"UPDATE AppNamespace SET IsDeleted=1,DataChange_LastModifiedBy = ?2 WHERE AppId=?1"
)
@Query
(
"UPDATE AppNamespace SET IsDeleted=1,DataChange_LastModifiedBy = ?2 WHERE AppId=?1"
)
int
batchDeleteByDeleteApp
(
String
appId
,
String
operator
);
int
batchDeleteByAppId
(
String
appId
,
String
operator
);
int
countByAppId
(
String
appId
);
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppRepository.java
View file @
2d9ece83
...
@@ -2,7 +2,6 @@ package com.ctrip.framework.apollo.biz.repository;
...
@@ -2,7 +2,6 @@ package com.ctrip.framework.apollo.biz.repository;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.data.repository.query.Param
;
...
@@ -15,10 +14,4 @@ public interface AppRepository extends PagingAndSortingRepository<App, Long> {
...
@@ -15,10 +14,4 @@ public interface AppRepository extends PagingAndSortingRepository<App, Long> {
List
<
App
>
findByName
(
@Param
(
"name"
)
String
name
);
List
<
App
>
findByName
(
@Param
(
"name"
)
String
name
);
App
findByAppId
(
String
appId
);
App
findByAppId
(
String
appId
);
@Modifying
@Query
(
"UPDATE App SET IsDeleted=1,DataChange_LastModifiedBy = ?2 WHERE AppId=?1"
)
int
deleteApp
(
String
appId
,
String
operator
);
int
countByAppId
(
String
appId
);
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ClusterRepository.java
View file @
2d9ece83
...
@@ -3,8 +3,6 @@ package com.ctrip.framework.apollo.biz.repository;
...
@@ -3,8 +3,6 @@ package com.ctrip.framework.apollo.biz.repository;
import
com.ctrip.framework.apollo.biz.entity.Cluster
;
import
com.ctrip.framework.apollo.biz.entity.Cluster
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
java.util.List
;
import
java.util.List
;
...
@@ -18,10 +16,4 @@ public interface ClusterRepository extends PagingAndSortingRepository<Cluster, L
...
@@ -18,10 +16,4 @@ public interface ClusterRepository extends PagingAndSortingRepository<Cluster, L
Cluster
findByAppIdAndName
(
String
appId
,
String
name
);
Cluster
findByAppIdAndName
(
String
appId
,
String
name
);
List
<
Cluster
>
findByParentClusterId
(
Long
parentClusterId
);
List
<
Cluster
>
findByParentClusterId
(
Long
parentClusterId
);
@Modifying
@Query
(
"UPDATE Cluster SET IsDeleted=1,DataChange_LastModifiedBy = ?2 WHERE AppId=?1"
)
int
batchDeleteByDeleteApp
(
String
appId
,
String
operator
);
int
countByAppId
(
String
appId
);
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java
View file @
2d9ece83
...
@@ -18,9 +18,4 @@ public interface CommitRepository extends PagingAndSortingRepository<Commit, Lon
...
@@ -18,9 +18,4 @@ public interface CommitRepository extends PagingAndSortingRepository<Commit, Lon
@Query
(
"update Commit set isdeleted=1,DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3"
)
@Query
(
"update Commit set isdeleted=1,DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3"
)
int
batchDelete
(
String
appId
,
String
clusterName
,
String
namespaceName
,
String
operator
);
int
batchDelete
(
String
appId
,
String
clusterName
,
String
namespaceName
,
String
operator
);
@Modifying
@Query
(
"UPDATE Commit SET IsDeleted=1,DataChange_LastModifiedBy = ?2 WHERE AppId=?1"
)
int
batchDeleteByDeleteApp
(
String
appId
,
String
operator
);
int
countByAppId
(
String
appId
);
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/GrayReleaseRuleRepository.java
View file @
2d9ece83
...
@@ -20,8 +20,6 @@ public interface GrayReleaseRuleRepository extends PagingAndSortingRepository<Gr
...
@@ -20,8 +20,6 @@ public interface GrayReleaseRuleRepository extends PagingAndSortingRepository<Gr
List
<
GrayReleaseRule
>
findFirst500ByIdGreaterThanOrderByIdAsc
(
Long
id
);
List
<
GrayReleaseRule
>
findFirst500ByIdGreaterThanOrderByIdAsc
(
Long
id
);
@Modifying
@Modifying
@Query
(
"UPDATE GrayReleaseRule SET IsDeleted=1,DataChange_LastModifiedBy = ?2 WHERE AppId=?1"
)
@Query
(
"UPDATE GrayReleaseRule SET IsDeleted=1, DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3"
)
int
batchDeleteByDeleteApp
(
String
appId
,
String
operator
);
int
batchDelete
(
String
appId
,
String
clusterName
,
String
namespaceName
,
String
operator
);
int
countByAppId
(
String
appId
);
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java
View file @
2d9ece83
...
@@ -25,9 +25,4 @@ public interface NamespaceRepository extends PagingAndSortingRepository<Namespac
...
@@ -25,9 +25,4 @@ public interface NamespaceRepository extends PagingAndSortingRepository<Namespac
int
countByNamespaceNameAndAppIdNot
(
String
namespaceName
,
String
appId
);
int
countByNamespaceNameAndAppIdNot
(
String
namespaceName
,
String
appId
);
@Modifying
@Query
(
"UPDATE Namespace SET IsDeleted=1,DataChange_LastModifiedBy = ?2 WHERE AppId=?1"
)
int
batchDeleteByDeleteApp
(
String
appId
,
String
operator
);
int
countByAppId
(
String
appId
);
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java
View file @
2d9ece83
...
@@ -23,9 +23,4 @@ public interface ReleaseHistoryRepository extends PagingAndSortingRepository<Rel
...
@@ -23,9 +23,4 @@ public interface ReleaseHistoryRepository extends PagingAndSortingRepository<Rel
@Query
(
"update ReleaseHistory set isdeleted=1,DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3"
)
@Query
(
"update ReleaseHistory set isdeleted=1,DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3"
)
int
batchDelete
(
String
appId
,
String
clusterName
,
String
namespaceName
,
String
operator
);
int
batchDelete
(
String
appId
,
String
clusterName
,
String
namespaceName
,
String
operator
);
@Modifying
@Query
(
"UPDATE ReleaseHistory SET IsDeleted=1,DataChange_LastModifiedBy = ?2 WHERE AppId=?1"
)
int
batchDeleteByDeleteApp
(
String
appId
,
String
operator
);
int
countByAppId
(
String
appId
);
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java
View file @
2d9ece83
...
@@ -35,10 +35,4 @@ public interface ReleaseRepository extends PagingAndSortingRepository<Release, L
...
@@ -35,10 +35,4 @@ public interface ReleaseRepository extends PagingAndSortingRepository<Release, L
// For release history conversion program, need to delete after conversion it done
// For release history conversion program, need to delete after conversion it done
List
<
Release
>
findByAppIdAndClusterNameAndNamespaceNameOrderByIdAsc
(
String
appId
,
String
clusterName
,
String
namespaceName
);
List
<
Release
>
findByAppIdAndClusterNameAndNamespaceNameOrderByIdAsc
(
String
appId
,
String
clusterName
,
String
namespaceName
);
@Modifying
@Query
(
"UPDATE Release SET IsDeleted=1,DataChange_LastModifiedBy = ?2 WHERE AppId=?1"
)
int
batchDeleteByDeleteApp
(
String
oldAppId
,
String
operator
);
int
countByAppId
(
String
appId
);
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AdminService.java
View file @
2d9ece83
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
service
;
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
service
;
import
com.ctrip.framework.apollo.biz.entity.Cluster
;
import
com.ctrip.framework.apollo.biz.entity.Cluster
;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.google.common.collect.Sets
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -14,7 +13,6 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -14,7 +13,6 @@ import org.springframework.transaction.annotation.Transactional;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Objects
;
import
java.util.Set
;
@Service
@Service
public
class
AdminService
{
public
class
AdminService
{
...
@@ -27,18 +25,8 @@ public class AdminService {
...
@@ -27,18 +25,8 @@ public class AdminService {
private
ClusterService
clusterService
;
private
ClusterService
clusterService
;
@Autowired
@Autowired
private
NamespaceService
namespaceService
;
private
NamespaceService
namespaceService
;
@Autowired
private
ReleaseHistoryService
releaseHistoryService
;
@Autowired
private
ReleaseService
releaseService
;
@Autowired
private
GrayReleaseRuleService
grayReleaseRuleService
;
@Autowired
private
CommitService
commitService
;
@Autowired
private
ItemService
itemService
;
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
AdminService
.
class
);
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
AdminService
.
class
);
@Transactional
@Transactional
public
App
createNewApp
(
App
app
)
{
public
App
createNewApp
(
App
app
)
{
...
@@ -57,46 +45,24 @@ public class AdminService {
...
@@ -57,46 +45,24 @@ public class AdminService {
}
}
@Transactional
@Transactional
public
void
deleteApp
(
String
appId
,
String
operator
)
{
public
void
deleteApp
(
App
app
,
String
operator
)
{
String
appId
=
app
.
getAppId
();
logger
.
info
(
"{} is deleting App:{}"
,
operator
,
appId
);
logger
.
info
(
"{} is deleting App:{}"
,
operator
,
appId
);
List
<
Cluster
>
managedClusters
=
clusterService
.
findClusters
(
appId
);
List
<
Cluster
>
managedClusters
=
clusterService
.
findClusters
(
appId
);
Set
<
Namespace
>
managedNamespaces
=
Sets
.
newLinkedHashSet
();
// 1. delete clusters
if
(
Objects
.
nonNull
(
managedClusters
))
{
if
(
Objects
.
nonNull
(
managedClusters
))
{
for
(
Cluster
cluster
:
managedClusters
)
{
for
(
Cluster
cluster
:
managedClusters
)
{
managedNamespaces
.
addAll
(
namespaceService
.
findNamespaces
(
appId
,
cluster
.
getName
())
);
clusterService
.
delete
(
cluster
.
getId
(),
operator
);
}
}
}
}
//1.delete release history.
// 2. delete appNamespace
releaseHistoryService
.
batchDeleteByDeleteApp
(
appId
,
operator
);
appNamespaceService
.
batchDelete
(
appId
,
operator
);
//2.delete release.
releaseService
.
deleteApp
(
appId
,
operator
);
//3.delete config items.
for
(
Namespace
namespace
:
managedNamespaces
)
{
itemService
.
batchDelete
(
namespace
.
getId
(),
operator
);
}
//4.delete Namespaces
namespaceService
.
deleteApp
(
managedNamespaces
,
operator
);
//5.delete GrayReleaseRule
grayReleaseRuleService
.
deleteApp
(
appId
,
operator
);
//6.delete history.
commitService
.
deleteApp
(
appId
,
operator
);
//7.delete cluster
clusterService
.
deleteApp
(
appId
,
operator
);
//8.delete appNamespace
appNamespaceService
.
deleteApp
(
appId
,
operator
);
//
9.
delete app
//
3.
delete app
appService
.
delete
App
(
appId
,
operator
);
appService
.
delete
(
app
.
getId
()
,
operator
);
}
}
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppNamespaceService.java
View file @
2d9ece83
...
@@ -139,9 +139,7 @@ public class AppNamespaceService {
...
@@ -139,9 +139,7 @@ public class AppNamespaceService {
}
}
@Transactional
@Transactional
public
void
deleteApp
(
String
appId
,
String
operator
)
{
public
void
batchDelete
(
String
appId
,
String
operator
)
{
if
(
appNamespaceRepository
.
countByAppId
(
appId
)
>
0
)
{
appNamespaceRepository
.
batchDeleteByAppId
(
appId
,
operator
);
appNamespaceRepository
.
batchDeleteByDeleteApp
(
appId
,
operator
);
}
}
}
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppService.java
View file @
2d9ece83
...
@@ -92,11 +92,4 @@ public class AppService {
...
@@ -92,11 +92,4 @@ public class AppService {
managedApp
.
getDataChangeLastModifiedBy
());
managedApp
.
getDataChangeLastModifiedBy
());
}
}
@Transactional
public
void
deleteApp
(
String
appId
,
String
operator
)
{
if
(
appRepository
.
countByAppId
(
appId
)
>
0
)
{
appRepository
.
deleteApp
(
appId
,
operator
);
}
}
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ClusterService.java
View file @
2d9ece83
...
@@ -137,13 +137,6 @@ public class ClusterService {
...
@@ -137,13 +137,6 @@ public class ClusterService {
return
clusterRepository
.
findByParentClusterId
(
parentCluster
.
getId
());
return
clusterRepository
.
findByParentClusterId
(
parentCluster
.
getId
());
}
}
@Transactional
public
void
deleteApp
(
String
appId
,
String
operator
)
{
if
(
clusterRepository
.
countByAppId
(
appId
)
>
0
)
{
clusterRepository
.
batchDeleteByDeleteApp
(
appId
,
operator
);
}
}
public
List
<
Cluster
>
findClusters
(
String
appId
)
{
public
List
<
Cluster
>
findClusters
(
String
appId
)
{
return
clusterRepository
.
findByAppId
(
appId
);
return
clusterRepository
.
findByAppId
(
appId
);
}
}
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/CommitService.java
View file @
2d9ece83
...
@@ -31,10 +31,4 @@ public class CommitService {
...
@@ -31,10 +31,4 @@ public class CommitService {
return
commitRepository
.
batchDelete
(
appId
,
clusterName
,
namespaceName
,
operator
);
return
commitRepository
.
batchDelete
(
appId
,
clusterName
,
namespaceName
,
operator
);
}
}
@Transactional
public
void
deleteApp
(
String
appId
,
String
operator
)
{
if
(
commitRepository
.
countByAppId
(
appId
)
>
0
)
{
commitRepository
.
batchDeleteByDeleteApp
(
appId
,
operator
);
}
}
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/GrayReleaseRuleService.java
View file @
2d9ece83
...
@@ -12,9 +12,7 @@ public class GrayReleaseRuleService {
...
@@ -12,9 +12,7 @@ public class GrayReleaseRuleService {
private
GrayReleaseRuleRepository
grayReleaseRuleRepository
;
private
GrayReleaseRuleRepository
grayReleaseRuleRepository
;
@Transactional
@Transactional
public
void
deleteApp
(
String
appId
,
String
operator
)
{
public
void
batchDelete
(
String
appId
,
String
clusterName
,
String
namespaceName
,
String
operator
)
{
if
(
grayReleaseRuleRepository
.
countByAppId
(
appId
)
>
0
)
{
grayReleaseRuleRepository
.
batchDelete
(
appId
,
clusterName
,
namespaceName
,
operator
);
grayReleaseRuleRepository
.
batchDeleteByDeleteApp
(
appId
,
operator
);
}
}
}
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java
View file @
2d9ece83
...
@@ -59,6 +59,8 @@ public class NamespaceService {
...
@@ -59,6 +59,8 @@ public class NamespaceService {
@Autowired
@Autowired
private
ReleaseHistoryService
releaseHistoryService
;
private
ReleaseHistoryService
releaseHistoryService
;
@Autowired
@Autowired
private
GrayReleaseRuleService
grayReleaseRuleService
;
@Autowired
private
NamespaceLockService
namespaceLockService
;
private
NamespaceLockService
namespaceLockService
;
@Autowired
@Autowired
private
InstanceService
instanceService
;
private
InstanceService
instanceService
;
...
@@ -263,17 +265,18 @@ public class NamespaceService {
...
@@ -263,17 +265,18 @@ public class NamespaceService {
itemService
.
batchDelete
(
namespace
.
getId
(),
operator
);
itemService
.
batchDelete
(
namespace
.
getId
(),
operator
);
commitService
.
batchDelete
(
appId
,
clusterName
,
namespace
.
getNamespaceName
(),
operator
);
commitService
.
batchDelete
(
appId
,
clusterName
,
namespace
.
getNamespaceName
(),
operator
);
if
(!
isChildNamespace
(
namespace
))
{
releaseService
.
batchDelete
(
appId
,
clusterName
,
namespace
.
getNamespaceName
(),
operator
);
releaseService
.
batchDelete
(
appId
,
clusterName
,
namespace
.
getNamespaceName
(),
operator
);
grayReleaseRuleService
.
batchDelete
(
appId
,
clusterName
,
namespace
.
getNamespaceName
(),
operator
);
}
//delete child namespace
if
(!
isChildNamespace
(
namespace
))
{
Namespace
childNamespace
=
findChildNamespace
(
namespace
);
//delete child namespace
if
(
childNamespace
!=
null
)
{
Namespace
childNamespace
=
findChildNamespace
(
namespace
);
namespaceBranchService
.
deleteBranch
(
appId
,
clusterName
,
namespaceName
,
if
(
childNamespace
!=
null
)
{
childNamespace
.
getClusterName
(),
NamespaceBranchStatus
.
DELETED
,
operator
);
namespaceBranchService
.
deleteBranch
(
appId
,
clusterName
,
namespaceName
,
//delete child namespace's releases. Notice: delete child namespace will not delete child namespace's releases
childNamespace
.
getClusterName
(),
NamespaceBranchStatus
.
DELETED
,
operator
);
releaseService
.
batchDelete
(
appId
,
childNamespace
.
getClusterName
(),
namespaceName
,
operator
);
//delete child namespace's releases. Notice: delete child namespace will not delete child namespace's releases
releaseService
.
batchDelete
(
appId
,
childNamespace
.
getClusterName
(),
namespaceName
,
operator
);
}
}
}
releaseHistoryService
.
batchDelete
(
appId
,
clusterName
,
namespaceName
,
operator
);
releaseHistoryService
.
batchDelete
(
appId
,
clusterName
,
namespaceName
,
operator
);
...
@@ -394,20 +397,4 @@ public class NamespaceService {
...
@@ -394,20 +397,4 @@ public class NamespaceService {
return
false
;
return
false
;
}
}
@Transactional
public
void
deleteApp
(
Set
<
Namespace
>
namespaces
,
String
operator
)
{
if
(
Objects
.
nonNull
(
namespaces
))
{
String
appId
=
namespaces
.
iterator
().
next
().
getAppId
();
namespaceRepository
.
batchDeleteByDeleteApp
(
appId
,
operator
);
//Publish release message
for
(
Namespace
namespace
:
namespaces
)
{
messageSender
.
sendMessage
(
ReleaseMessageKeyGenerator
.
generate
(
appId
,
namespace
.
getClusterName
(),
namespace
.
getNamespaceName
()),
Topics
.
APOLLO_RELEASE_TOPIC
);
}
}
}
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseHistoryService.java
View file @
2d9ece83
...
@@ -76,11 +76,4 @@ public class ReleaseHistoryService {
...
@@ -76,11 +76,4 @@ public class ReleaseHistoryService {
public
int
batchDelete
(
String
appId
,
String
clusterName
,
String
namespaceName
,
String
operator
)
{
public
int
batchDelete
(
String
appId
,
String
clusterName
,
String
namespaceName
,
String
operator
)
{
return
releaseHistoryRepository
.
batchDelete
(
appId
,
clusterName
,
namespaceName
,
operator
);
return
releaseHistoryRepository
.
batchDelete
(
appId
,
clusterName
,
namespaceName
,
operator
);
}
}
@Transactional
public
void
batchDeleteByDeleteApp
(
String
appId
,
String
operator
)
{
if
(
releaseHistoryRepository
.
countByAppId
(
appId
)
>
0
)
{
releaseHistoryRepository
.
batchDeleteByDeleteApp
(
appId
,
operator
);
}
}
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java
View file @
2d9ece83
...
@@ -467,10 +467,4 @@ public class ReleaseService {
...
@@ -467,10 +467,4 @@ public class ReleaseService {
return
releaseRepository
.
batchDelete
(
appId
,
clusterName
,
namespaceName
,
operator
);
return
releaseRepository
.
batchDelete
(
appId
,
clusterName
,
namespaceName
,
operator
);
}
}
@Transactional
public
void
deleteApp
(
String
appId
,
String
operator
)
{
if
(
releaseRepository
.
countByAppId
(
appId
)
>
0
)
{
releaseRepository
.
batchDeleteByDeleteApp
(
appId
,
operator
);
}
}
}
}
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepositoryTest.java
View file @
2d9ece83
...
@@ -27,11 +27,4 @@ public class AppNamespaceRepositoryTest extends AbstractIntegrationTest{
...
@@ -27,11 +27,4 @@ public class AppNamespaceRepositoryTest extends AbstractIntegrationTest{
assertNull
(
appNamespace
);
assertNull
(
appNamespace
);
}
}
@Test
public
void
testDeleteAppNamespaceWhenDeleteApp
()
throws
Exception
{
String
appId
=
"100003171"
;
int
count
=
repository
.
countByAppId
(
appId
);
assertEquals
(
count
,
repository
.
batchDeleteByDeleteApp
(
appId
,
null
));
}
}
}
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AppRepositoryTest.java
View file @
2d9ece83
...
@@ -56,29 +56,4 @@ public class AppRepositoryTest extends AbstractIntegrationTest{
...
@@ -56,29 +56,4 @@ public class AppRepositoryTest extends AbstractIntegrationTest{
Assert
.
assertEquals
(
0
,
appRepository
.
count
());
Assert
.
assertEquals
(
0
,
appRepository
.
count
());
}
}
@Test
public
void
testDelete
()
{
String
appId
=
"someAppId"
;
String
appName
=
"someAppName"
;
String
ownerName
=
"someOwnerName"
;
String
ownerEmail
=
"someOwnerName@ctrip.com"
;
String
operator
=
"someOwnerName"
;
App
app
=
new
App
();
app
.
setAppId
(
appId
);
app
.
setName
(
appName
);
app
.
setOwnerName
(
ownerName
);
app
.
setOwnerEmail
(
ownerEmail
);
Assert
.
assertEquals
(
0
,
appRepository
.
count
());
appRepository
.
save
(
app
);
Assert
.
assertEquals
(
1
,
appRepository
.
count
());
Assert
.
assertEquals
(
1
,
appRepository
.
deleteApp
(
app
.
getAppId
(),
operator
));
Assert
.
assertEquals
(
0
,
appRepository
.
count
());
}
}
}
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AdminServiceTest.java
View file @
2d9ece83
...
@@ -8,109 +8,109 @@ import com.ctrip.framework.apollo.biz.repository.AppRepository;
...
@@ -8,109 +8,109 @@ import com.ctrip.framework.apollo.biz.repository.AppRepository;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
java.util.Date
;
import
java.util.List
;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.Date
;
import
java.util.List
;
public
class
AdminServiceTest
extends
AbstractIntegrationTest
{
public
class
AdminServiceTest
extends
AbstractIntegrationTest
{
@Autowired
@Autowired
private
AdminService
adminService
;
private
AdminService
adminService
;
@Autowired
@Autowired
private
AuditService
auditService
;
private
AuditService
auditService
;
@Autowired
@Autowired
private
AppRepository
appRepository
;
private
AppRepository
appRepository
;
@Autowired
@Autowired
private
ClusterService
clusterService
;
private
ClusterService
clusterService
;
@Autowired
@Autowired
private
NamespaceService
namespaceService
;
private
NamespaceService
namespaceService
;
@Autowired
@Autowired
private
AppNamespaceService
appNamespaceService
;
private
AppNamespaceService
appNamespaceService
;
@Test
@Test
public
void
testCreateNewApp
()
{
public
void
testCreateNewApp
()
{
String
appId
=
"someAppId"
;
String
appId
=
"someAppId"
;
App
app
=
new
App
();
App
app
=
new
App
();
app
.
setAppId
(
appId
);
app
.
setAppId
(
appId
);
app
.
setName
(
"someAppName"
);
app
.
setName
(
"someAppName"
);
String
owner
=
"someOwnerName"
;
String
owner
=
"someOwnerName"
;
app
.
setOwnerName
(
owner
);
app
.
setOwnerName
(
owner
);
app
.
setOwnerEmail
(
"someOwnerName@ctrip.com"
);
app
.
setOwnerEmail
(
"someOwnerName@ctrip.com"
);
app
.
setDataChangeCreatedBy
(
owner
);
app
.
setDataChangeCreatedBy
(
owner
);
app
.
setDataChangeLastModifiedBy
(
owner
);
app
.
setDataChangeLastModifiedBy
(
owner
);
app
.
setDataChangeCreatedTime
(
new
Date
());
app
.
setDataChangeCreatedTime
(
new
Date
());
app
=
adminService
.
createNewApp
(
app
);
app
=
adminService
.
createNewApp
(
app
);
Assert
.
assertEquals
(
appId
,
app
.
getAppId
());
Assert
.
assertEquals
(
appId
,
app
.
getAppId
());
List
<
Cluster
>
clusters
=
clusterService
.
findParentClusters
(
app
.
getAppId
());
List
<
Cluster
>
clusters
=
clusterService
.
findParentClusters
(
app
.
getAppId
());
Assert
.
assertEquals
(
1
,
clusters
.
size
());
Assert
.
assertEquals
(
1
,
clusters
.
size
());
Assert
.
assertEquals
(
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
clusters
.
get
(
0
).
getName
());
Assert
.
assertEquals
(
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
clusters
.
get
(
0
).
getName
());
List
<
Namespace
>
namespaces
=
namespaceService
.
findNamespaces
(
appId
,
clusters
.
get
(
0
).
getName
());
List
<
Namespace
>
namespaces
=
namespaceService
.
findNamespaces
(
appId
,
clusters
.
get
(
0
).
getName
());
Assert
.
assertEquals
(
1
,
namespaces
.
size
());
Assert
.
assertEquals
(
1
,
namespaces
.
size
());
Assert
.
assertEquals
(
ConfigConsts
.
NAMESPACE_APPLICATION
,
namespaces
.
get
(
0
).
getNamespaceName
());
Assert
.
assertEquals
(
ConfigConsts
.
NAMESPACE_APPLICATION
,
namespaces
.
get
(
0
).
getNamespaceName
());
List
<
Audit
>
audits
=
auditService
.
findByOwner
(
owner
);
List
<
Audit
>
audits
=
auditService
.
findByOwner
(
owner
);
Assert
.
assertEquals
(
4
,
audits
.
size
());
Assert
.
assertEquals
(
4
,
audits
.
size
());
}
}
@Test
(
expected
=
ServiceException
.
class
)
@Test
(
expected
=
ServiceException
.
class
)
public
void
testCreateDuplicateApp
()
{
public
void
testCreateDuplicateApp
()
{
String
appId
=
"someAppId"
;
String
appId
=
"someAppId"
;
App
app
=
new
App
();
App
app
=
new
App
();
app
.
setAppId
(
appId
);
app
.
setAppId
(
appId
);
app
.
setName
(
"someAppName"
);
app
.
setName
(
"someAppName"
);
String
owner
=
"someOwnerName"
;
String
owner
=
"someOwnerName"
;
app
.
setOwnerName
(
owner
);
app
.
setOwnerName
(
owner
);
app
.
setOwnerEmail
(
"someOwnerName@ctrip.com"
);
app
.
setOwnerEmail
(
"someOwnerName@ctrip.com"
);
app
.
setDataChangeCreatedBy
(
owner
);
app
.
setDataChangeCreatedBy
(
owner
);
app
.
setDataChangeLastModifiedBy
(
owner
);
app
.
setDataChangeLastModifiedBy
(
owner
);
app
.
setDataChangeCreatedTime
(
new
Date
());
app
.
setDataChangeCreatedTime
(
new
Date
());
appRepository
.
save
(
app
);
appRepository
.
save
(
app
);
adminService
.
createNewApp
(
app
);
adminService
.
createNewApp
(
app
);
}
}
@Test
@Test
public
void
testDeleteApp
()
{
public
void
testDeleteApp
()
{
String
appId
=
"someAppId"
;
String
appId
=
"someAppId"
;
App
app
=
new
App
();
App
app
=
new
App
();
app
.
setAppId
(
appId
);
app
.
setAppId
(
appId
);
app
.
setName
(
"someAppName"
);
app
.
setName
(
"someAppName"
);
String
owner
=
"someOwnerName"
;
String
owner
=
"someOwnerName"
;
app
.
setOwnerName
(
owner
);
app
.
setOwnerName
(
owner
);
app
.
setOwnerEmail
(
"someOwnerName@ctrip.com"
);
app
.
setOwnerEmail
(
"someOwnerName@ctrip.com"
);
app
.
setDataChangeCreatedBy
(
owner
);
app
.
setDataChangeCreatedBy
(
owner
);
app
.
setDataChangeLastModifiedBy
(
owner
);
app
.
setDataChangeLastModifiedBy
(
owner
);
app
.
setDataChangeCreatedTime
(
new
Date
());
app
.
setDataChangeCreatedTime
(
new
Date
());
app
=
adminService
.
createNewApp
(
app
);
app
=
adminService
.
createNewApp
(
app
);
Assert
.
assertEquals
(
appId
,
app
.
getAppId
());
Assert
.
assertEquals
(
appId
,
app
.
getAppId
());
Assert
.
assertEquals
(
1
,
appNamespaceService
.
findByAppId
(
appId
).
size
());
Assert
.
assertEquals
(
1
,
appNamespaceService
.
findByAppId
(
appId
).
size
());
Assert
.
assertEquals
(
1
,
clusterService
.
findClusters
(
appId
).
size
());
Assert
.
assertEquals
(
1
,
clusterService
.
findClusters
(
appId
).
size
());
Assert
.
assertEquals
(
1
,
namespaceService
.
findNamespaces
(
appId
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
).
size
());
Assert
.
assertEquals
(
1
,
namespaceService
.
findNamespaces
(
appId
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
).
size
());
adminService
.
deleteApp
(
appId
,
owner
);
adminService
.
deleteApp
(
app
,
owner
);
Assert
.
assertEquals
(
0
,
appNamespaceService
.
findByAppId
(
appId
).
size
());
Assert
.
assertEquals
(
0
,
appNamespaceService
.
findByAppId
(
appId
).
size
());
Assert
.
assertEquals
(
0
,
clusterService
.
findClusters
(
appId
).
size
());
Assert
.
assertEquals
(
0
,
clusterService
.
findClusters
(
appId
).
size
());
Assert
.
assertEquals
(
0
,
namespaceService
.
findByAppIdAndNamespaceName
(
appId
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
).
size
());
Assert
}
.
assertEquals
(
0
,
namespaceService
.
findByAppIdAndNamespaceName
(
appId
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
).
size
());
}
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java
View file @
2d9ece83
...
@@ -2,6 +2,8 @@ package com.ctrip.framework.apollo.openapi.repository;
...
@@ -2,6 +2,8 @@ package com.ctrip.framework.apollo.openapi.repository;
import
com.ctrip.framework.apollo.openapi.entity.ConsumerRole
;
import
com.ctrip.framework.apollo.openapi.entity.ConsumerRole
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
java.util.List
;
import
java.util.List
;
...
@@ -23,4 +25,8 @@ public interface ConsumerRoleRepository extends PagingAndSortingRepository<Consu
...
@@ -23,4 +25,8 @@ public interface ConsumerRoleRepository extends PagingAndSortingRepository<Consu
List
<
ConsumerRole
>
findByRoleId
(
long
roleId
);
List
<
ConsumerRole
>
findByRoleId
(
long
roleId
);
ConsumerRole
findByConsumerIdAndRoleId
(
long
consumerId
,
long
roleId
);
ConsumerRole
findByConsumerIdAndRoleId
(
long
consumerId
,
long
roleId
);
@Modifying
@Query
(
"UPDATE ConsumerRole SET IsDeleted=1, DataChange_LastModifiedBy = ?2 WHERE RoleId in ?1"
)
Integer
batchDeleteByRoleIds
(
List
<
Long
>
roleIds
,
String
operator
);
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
View file @
2d9ece83
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
api
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
api
;
import
com.ctrip.framework.apollo.common.dto.*
;
import
com.ctrip.framework.apollo.common.dto.AppDTO
;
import
com.ctrip.framework.apollo.common.dto.AppNamespaceDTO
;
import
com.ctrip.framework.apollo.common.dto.ClusterDTO
;
import
com.ctrip.framework.apollo.common.dto.CommitDTO
;
import
com.ctrip.framework.apollo.common.dto.GrayReleaseRuleDTO
;
import
com.ctrip.framework.apollo.common.dto.InstanceDTO
;
import
com.ctrip.framework.apollo.common.dto.ItemChangeSets
;
import
com.ctrip.framework.apollo.common.dto.ItemDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceLockDTO
;
import
com.ctrip.framework.apollo.common.dto.PageDTO
;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.common.dto.ReleaseHistoryDTO
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.google.common.base.Joiner
;
import
com.google.common.base.Joiner
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.springframework.boot.actuate.health.Health
;
import
org.springframework.boot.actuate.health.Health
;
import
org.springframework.core.ParameterizedTypeReference
;
import
org.springframework.core.ParameterizedTypeReference
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpEntity
;
...
@@ -15,417 +32,415 @@ import org.springframework.util.CollectionUtils;
...
@@ -15,417 +32,415 @@ import org.springframework.util.CollectionUtils;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
java.util.*
;
@Service
@Service
public
class
AdminServiceAPI
{
public
class
AdminServiceAPI
{
@Service
@Service
public
static
class
HealthAPI
extends
API
{
public
static
class
HealthAPI
extends
API
{
public
Health
health
(
Env
env
)
{
return
restTemplate
.
get
(
env
,
"/health"
,
Health
.
class
);
}
}
@Service
public
static
class
AppAPI
extends
API
{
public
AppDTO
loadApp
(
Env
env
,
String
appId
)
{
return
restTemplate
.
get
(
env
,
"apps/{appId}"
,
AppDTO
.
class
,
appId
);
}
public
AppDTO
createApp
(
Env
env
,
AppDTO
app
)
{
return
restTemplate
.
post
(
env
,
"apps"
,
app
,
AppDTO
.
class
);
}
public
void
updateApp
(
Env
env
,
AppDTO
app
)
{
restTemplate
.
put
(
env
,
"apps/{appId}"
,
app
,
app
.
getAppId
());
}
public
void
deleteApp
(
Env
env
,
String
appId
,
String
operator
)
{
restTemplate
.
delete
(
env
,
"/apps/{appId}?operator={operator}"
,
appId
,
operator
);
}
}
@Service
public
static
class
NamespaceAPI
extends
API
{
private
ParameterizedTypeReference
<
Map
<
String
,
Boolean
>>
typeReference
=
new
ParameterizedTypeReference
<
Map
<
String
,
Boolean
>>()
{
};
public
Health
health
(
Env
env
)
{
public
List
<
NamespaceDTO
>
findNamespaceByCluster
(
String
appId
,
Env
env
,
String
clusterName
)
{
return
restTemplate
.
get
(
env
,
"/health"
,
Health
.
class
);
NamespaceDTO
[]
namespaceDTOs
=
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces"
,
}
NamespaceDTO
[].
class
,
appId
,
clusterName
);
return
Arrays
.
asList
(
namespaceDTOs
);
}
}
@Service
public
NamespaceDTO
loadNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
public
static
class
AppAPI
extends
API
{
String
namespaceName
)
{
return
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}"
,
NamespaceDTO
.
class
,
appId
,
clusterName
,
namespaceName
);
}
public
NamespaceDTO
findPublicNamespaceForAssociatedNamespace
(
Env
env
,
String
appId
,
String
clusterName
,
String
namespaceName
)
{
return
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/associated-public-namespace"
,
NamespaceDTO
.
class
,
appId
,
clusterName
,
namespaceName
);
}
public
NamespaceDTO
createNamespace
(
Env
env
,
NamespaceDTO
namespace
)
{
return
restTemplate
.
post
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces"
,
namespace
,
NamespaceDTO
.
class
,
namespace
.
getAppId
(),
namespace
.
getClusterName
());
}
public
AppNamespaceDTO
createAppNamespace
(
Env
env
,
AppNamespaceDTO
appNamespace
)
{
return
restTemplate
.
post
(
env
,
"apps/{appId}/appnamespaces"
,
appNamespace
,
AppNamespaceDTO
.
class
,
appNamespace
.
getAppId
());
}
public
AppDTO
loadApp
(
Env
env
,
String
appId
)
{
public
void
deleteNamespace
(
Env
env
,
String
appId
,
String
clusterName
,
String
namespaceName
,
String
operator
)
{
return
restTemplate
.
get
(
env
,
"apps/{appId}"
,
AppDTO
.
class
,
appId
);
restTemplate
}
.
delete
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}?operator={operator}"
,
appId
,
clusterName
,
namespaceName
,
operator
);
}
public
Map
<
String
,
Boolean
>
getNamespacePublishInfo
(
Env
env
,
String
appId
)
{
return
restTemplate
.
get
(
env
,
"apps/{appId}/namespaces/publish_info"
,
typeReference
,
appId
).
getBody
();
}
public
List
<
NamespaceDTO
>
getPublicAppNamespaceAllNamespaces
(
Env
env
,
String
publicNamespaceName
,
int
page
,
int
size
)
{
NamespaceDTO
[]
namespaceDTOs
=
restTemplate
.
get
(
env
,
"/appnamespaces/{publicNamespaceName}/namespaces?page={page}&size={size}"
,
NamespaceDTO
[].
class
,
publicNamespaceName
,
page
,
size
);
return
Arrays
.
asList
(
namespaceDTOs
);
}
public
int
countPublicAppNamespaceAssociatedNamespaces
(
Env
env
,
String
publicNamesapceName
)
{
Integer
count
=
restTemplate
.
get
(
env
,
"/appnamespaces/{publicNamespaceName}/associated-namespaces/count"
,
Integer
.
class
,
publicNamesapceName
);
return
count
==
null
?
0
:
count
;
}
}
@Service
public
static
class
ItemAPI
extends
API
{
public
List
<
ItemDTO
>
findItems
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
ItemDTO
[]
itemDTOs
=
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items"
,
ItemDTO
[].
class
,
appId
,
clusterName
,
namespaceName
);
return
Arrays
.
asList
(
itemDTOs
);
}
public
ItemDTO
loadItem
(
Env
env
,
String
appId
,
String
clusterName
,
String
namespaceName
,
String
key
)
{
return
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key}"
,
ItemDTO
.
class
,
appId
,
clusterName
,
namespaceName
,
key
);
}
public
void
updateItemsByChangeSet
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
ItemChangeSets
changeSets
)
{
restTemplate
.
post
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/itemset"
,
changeSets
,
Void
.
class
,
appId
,
clusterName
,
namespace
);
}
public
void
updateItem
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
long
itemId
,
ItemDTO
item
)
{
restTemplate
.
put
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{itemId}"
,
item
,
appId
,
clusterName
,
namespace
,
itemId
);
}
public
ItemDTO
createItem
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
ItemDTO
item
)
{
return
restTemplate
.
post
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items"
,
item
,
ItemDTO
.
class
,
appId
,
clusterName
,
namespace
);
}
public
void
deleteItem
(
Env
env
,
long
itemId
,
String
operator
)
{
restTemplate
.
delete
(
env
,
"items/{itemId}?operator={operator}"
,
itemId
,
operator
);
}
}
@Service
public
static
class
ClusterAPI
extends
API
{
public
List
<
ClusterDTO
>
findClustersByApp
(
String
appId
,
Env
env
)
{
ClusterDTO
[]
clusterDTOs
=
restTemplate
.
get
(
env
,
"apps/{appId}/clusters"
,
ClusterDTO
[].
class
,
appId
);
return
Arrays
.
asList
(
clusterDTOs
);
}
public
ClusterDTO
loadCluster
(
String
appId
,
Env
env
,
String
clusterName
)
{
return
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}"
,
ClusterDTO
.
class
,
appId
,
clusterName
);
}
public
boolean
isClusterUnique
(
String
appId
,
Env
env
,
String
clusterName
)
{
return
restTemplate
.
get
(
env
,
"apps/{appId}/cluster/{clusterName}/unique"
,
Boolean
.
class
,
appId
,
clusterName
);
}
public
ClusterDTO
create
(
Env
env
,
ClusterDTO
cluster
)
{
return
restTemplate
.
post
(
env
,
"apps/{appId}/clusters"
,
cluster
,
ClusterDTO
.
class
,
cluster
.
getAppId
());
}
public
void
delete
(
Env
env
,
String
appId
,
String
clusterName
,
String
operator
)
{
restTemplate
.
delete
(
env
,
"apps/{appId}/clusters/{clusterName}?operator={operator}"
,
appId
,
clusterName
,
operator
);
}
}
public
AppDTO
createApp
(
Env
env
,
AppDTO
app
)
{
@Service
return
restTemplate
.
post
(
env
,
"apps"
,
app
,
AppDTO
.
class
);
public
static
class
ReleaseAPI
extends
API
{
}
public
void
updateApp
(
Env
env
,
AppDTO
app
)
{
private
static
final
Joiner
JOINER
=
Joiner
.
on
(
","
);
restTemplate
.
put
(
env
,
"apps/{appId}"
,
app
,
app
.
getAppId
());
}
public
void
deleteApp
(
Env
env
,
String
appId
,
String
operator
)
{
public
ReleaseDTO
loadRelease
(
Env
env
,
long
releaseId
)
{
restTemplate
.
delete
(
env
,
"/apps?appId={appId}&operator={operator}"
,
appId
,
operator
);
return
restTemplate
.
get
(
env
,
"releases/{releaseId}"
,
ReleaseDTO
.
class
,
releaseId
);
}
}
}
public
List
<
ReleaseDTO
>
findReleaseByIds
(
Env
env
,
Set
<
Long
>
releaseIds
)
{
if
(
CollectionUtils
.
isEmpty
(
releaseIds
))
{
return
Collections
.
emptyList
();
}
@Service
ReleaseDTO
[]
public
static
class
NamespaceAPI
extends
API
{
releases
=
restTemplate
.
get
(
env
,
"/releases?releaseIds={releaseIds}"
,
ReleaseDTO
[].
class
,
JOINER
.
join
(
releaseIds
));
return
Arrays
.
asList
(
releases
);
private
ParameterizedTypeReference
<
Map
<
String
,
Boolean
>>
}
typeReference
=
new
ParameterizedTypeReference
<
Map
<
String
,
Boolean
>>()
{
public
List
<
ReleaseDTO
>
findAllReleases
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
int
page
,
int
size
)
{
ReleaseDTO
[]
releaseDTOs
=
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/all?page={page}&size={size}"
,
ReleaseDTO
[].
class
,
appId
,
clusterName
,
namespaceName
,
page
,
size
);
return
Arrays
.
asList
(
releaseDTOs
);
}
public
List
<
ReleaseDTO
>
findActiveReleases
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
int
page
,
int
size
)
{
ReleaseDTO
[]
releaseDTOs
=
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/active?page={page}&size={size}"
,
ReleaseDTO
[].
class
,
appId
,
clusterName
,
namespaceName
,
page
,
size
);
return
Arrays
.
asList
(
releaseDTOs
);
}
public
ReleaseDTO
loadLatestRelease
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
)
{
ReleaseDTO
releaseDTO
=
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/latest"
,
ReleaseDTO
.
class
,
appId
,
clusterName
,
namespace
);
return
releaseDTO
;
}
public
ReleaseDTO
createRelease
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
String
releaseName
,
String
releaseComment
,
String
operator
,
boolean
isEmergencyPublish
)
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
parseMediaType
(
MediaType
.
APPLICATION_FORM_URLENCODED_VALUE
+
";charset=UTF-8"
));
MultiValueMap
<
String
,
String
>
parameters
=
new
LinkedMultiValueMap
<>();
parameters
.
add
(
"name"
,
releaseName
);
parameters
.
add
(
"comment"
,
releaseComment
);
parameters
.
add
(
"operator"
,
operator
);
parameters
.
add
(
"isEmergencyPublish"
,
String
.
valueOf
(
isEmergencyPublish
));
HttpEntity
<
MultiValueMap
<
String
,
String
>>
entity
=
new
HttpEntity
<>(
parameters
,
headers
);
ReleaseDTO
response
=
restTemplate
.
post
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases"
,
entity
,
ReleaseDTO
.
class
,
appId
,
clusterName
,
namespace
);
return
response
;
}
public
ReleaseDTO
updateAndPublish
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
String
releaseName
,
String
releaseComment
,
String
branchName
,
boolean
isEmergencyPublish
,
boolean
deleteBranch
,
ItemChangeSets
changeSets
)
{
return
restTemplate
.
post
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/updateAndPublish?"
+
"releaseName={releaseName}&releaseComment={releaseComment}&branchName={branchName}"
+
"&deleteBranch={deleteBranch}&isEmergencyPublish={isEmergencyPublish}"
,
changeSets
,
ReleaseDTO
.
class
,
appId
,
clusterName
,
namespace
,
releaseName
,
releaseComment
,
branchName
,
deleteBranch
,
isEmergencyPublish
);
}
public
void
rollback
(
Env
env
,
long
releaseId
,
String
operator
)
{
restTemplate
.
put
(
env
,
"releases/{releaseId}/rollback?operator={operator}"
,
null
,
releaseId
,
operator
);
}
}
@Service
public
static
class
CommitAPI
extends
API
{
public
List
<
CommitDTO
>
find
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
int
page
,
int
size
)
{
CommitDTO
[]
commitDTOs
=
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/commit?page={page}&size={size}"
,
CommitDTO
[].
class
,
appId
,
clusterName
,
namespaceName
,
page
,
size
);
return
Arrays
.
asList
(
commitDTOs
);
}
}
@Service
public
static
class
NamespaceLockAPI
extends
API
{
public
NamespaceLockDTO
getNamespaceLockOwner
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
return
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock"
,
NamespaceLockDTO
.
class
,
appId
,
clusterName
,
namespaceName
);
}
}
@Service
public
static
class
InstanceAPI
extends
API
{
private
Joiner
joiner
=
Joiner
.
on
(
","
);
private
ParameterizedTypeReference
<
PageDTO
<
InstanceDTO
>>
pageInstanceDtoType
=
new
ParameterizedTypeReference
<
PageDTO
<
InstanceDTO
>>()
{
};
public
PageDTO
<
InstanceDTO
>
getByRelease
(
Env
env
,
long
releaseId
,
int
page
,
int
size
)
{
ResponseEntity
<
PageDTO
<
InstanceDTO
>>
entity
=
restTemplate
.
get
(
env
,
"/instances/by-release?releaseId={releaseId}&page={page}&size={size}"
,
pageInstanceDtoType
,
releaseId
,
page
,
size
);
return
entity
.
getBody
();
}
public
List
<
InstanceDTO
>
getByReleasesNotIn
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
Set
<
Long
>
releaseIds
)
{
InstanceDTO
[]
instanceDTOs
=
restTemplate
.
get
(
env
,
"/instances/by-namespace-and-releases-not-in?appId={appId}&clusterName={clusterName}&namespaceName={namespaceName}&releaseIds={releaseIds}"
,
InstanceDTO
[].
class
,
appId
,
clusterName
,
namespaceName
,
joiner
.
join
(
releaseIds
));
return
Arrays
.
asList
(
instanceDTOs
);
}
public
PageDTO
<
InstanceDTO
>
getByNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
String
instanceAppId
,
int
page
,
int
size
)
{
ResponseEntity
<
PageDTO
<
InstanceDTO
>>
entity
=
restTemplate
.
get
(
env
,
"/instances/by-namespace?appId={appId}"
+
"&clusterName={clusterName}&namespaceName={namespaceName}&instanceAppId={instanceAppId}"
+
"&page={page}&size={size}"
,
pageInstanceDtoType
,
appId
,
clusterName
,
namespaceName
,
instanceAppId
,
page
,
size
);
return
entity
.
getBody
();
}
public
int
getInstanceCountByNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
Integer
count
=
restTemplate
.
get
(
env
,
"/instances/by-namespace/count?appId={appId}&clusterName={clusterName}&namespaceName={namespaceName}"
,
Integer
.
class
,
appId
,
clusterName
,
namespaceName
);
if
(
count
==
null
)
{
return
0
;
}
return
count
;
}
}
@Service
public
static
class
NamespaceBranchAPI
extends
API
{
public
NamespaceDTO
createBranch
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
String
operator
)
{
return
restTemplate
.
post
(
env
,
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches?operator={operator}"
,
null
,
NamespaceDTO
.
class
,
appId
,
clusterName
,
namespaceName
,
operator
);
}
public
NamespaceDTO
findBranch
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
return
restTemplate
.
get
(
env
,
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
,
NamespaceDTO
.
class
,
appId
,
clusterName
,
namespaceName
);
}
public
GrayReleaseRuleDTO
findBranchGrayRules
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
String
branchName
)
{
return
restTemplate
.
get
(
env
,
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules"
,
GrayReleaseRuleDTO
.
class
,
appId
,
clusterName
,
namespaceName
,
branchName
);
}
public
void
updateBranchGrayRules
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
String
branchName
,
GrayReleaseRuleDTO
rules
)
{
restTemplate
.
put
(
env
,
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules"
,
rules
,
appId
,
clusterName
,
namespaceName
,
branchName
);
}
public
void
deleteBranch
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
String
branchName
,
String
operator
)
{
restTemplate
.
delete
(
env
,
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}?operator={operator}"
,
appId
,
clusterName
,
namespaceName
,
branchName
,
operator
);
}
}
@Service
public
static
class
ReleaseHistoryAPI
extends
API
{
private
ParameterizedTypeReference
<
PageDTO
<
ReleaseHistoryDTO
>>
type
=
new
ParameterizedTypeReference
<
PageDTO
<
ReleaseHistoryDTO
>>()
{
};
};
public
List
<
NamespaceDTO
>
findNamespaceByCluster
(
String
appId
,
Env
env
,
String
clusterName
)
{
NamespaceDTO
[]
namespaceDTOs
=
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces"
,
NamespaceDTO
[].
class
,
appId
,
clusterName
);
return
Arrays
.
asList
(
namespaceDTOs
);
}
public
NamespaceDTO
loadNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
return
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}"
,
NamespaceDTO
.
class
,
appId
,
clusterName
,
namespaceName
);
}
public
NamespaceDTO
findPublicNamespaceForAssociatedNamespace
(
Env
env
,
String
appId
,
String
clusterName
,
String
namespaceName
)
{
return
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/associated-public-namespace"
,
NamespaceDTO
.
class
,
appId
,
clusterName
,
namespaceName
);
}
public
NamespaceDTO
createNamespace
(
Env
env
,
NamespaceDTO
namespace
)
{
return
restTemplate
.
post
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces"
,
namespace
,
NamespaceDTO
.
class
,
namespace
.
getAppId
(),
namespace
.
getClusterName
());
}
public
AppNamespaceDTO
createAppNamespace
(
Env
env
,
AppNamespaceDTO
appNamespace
)
{
return
restTemplate
.
post
(
env
,
"apps/{appId}/appnamespaces"
,
appNamespace
,
AppNamespaceDTO
.
class
,
appNamespace
.
getAppId
());
}
public
void
deleteNamespace
(
Env
env
,
String
appId
,
String
clusterName
,
String
namespaceName
,
String
operator
)
{
restTemplate
.
delete
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}?operator={operator}"
,
appId
,
clusterName
,
namespaceName
,
operator
);
}
public
Map
<
String
,
Boolean
>
getNamespacePublishInfo
(
Env
env
,
String
appId
)
{
return
restTemplate
.
get
(
env
,
"apps/{appId}/namespaces/publish_info"
,
typeReference
,
appId
).
getBody
();
}
public
List
<
NamespaceDTO
>
getPublicAppNamespaceAllNamespaces
(
Env
env
,
String
publicNamespaceName
,
int
page
,
int
size
)
{
NamespaceDTO
[]
namespaceDTOs
=
restTemplate
.
get
(
env
,
"/appnamespaces/{publicNamespaceName}/namespaces?page={page}&size={size}"
,
NamespaceDTO
[].
class
,
publicNamespaceName
,
page
,
size
);
return
Arrays
.
asList
(
namespaceDTOs
);
}
public
int
countPublicAppNamespaceAssociatedNamespaces
(
Env
env
,
String
publicNamesapceName
)
{
Integer
count
=
restTemplate
.
get
(
env
,
"/appnamespaces/{publicNamespaceName}/associated-namespaces/count"
,
Integer
.
class
,
publicNamesapceName
);
return
count
==
null
?
0
:
count
;
}
}
@Service
public
static
class
ItemAPI
extends
API
{
public
List
<
ItemDTO
>
findItems
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
ItemDTO
[]
itemDTOs
=
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items"
,
ItemDTO
[].
class
,
appId
,
clusterName
,
namespaceName
);
return
Arrays
.
asList
(
itemDTOs
);
}
public
ItemDTO
loadItem
(
Env
env
,
String
appId
,
String
clusterName
,
String
namespaceName
,
String
key
)
{
return
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key}"
,
ItemDTO
.
class
,
appId
,
clusterName
,
namespaceName
,
key
);
}
public
void
updateItemsByChangeSet
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
ItemChangeSets
changeSets
)
{
restTemplate
.
post
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/itemset"
,
changeSets
,
Void
.
class
,
appId
,
clusterName
,
namespace
);
}
public
void
updateItem
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
long
itemId
,
ItemDTO
item
)
{
restTemplate
.
put
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{itemId}"
,
item
,
appId
,
clusterName
,
namespace
,
itemId
);
}
public
ItemDTO
createItem
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
ItemDTO
item
)
{
return
restTemplate
.
post
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items"
,
item
,
ItemDTO
.
class
,
appId
,
clusterName
,
namespace
);
}
public
void
deleteItem
(
Env
env
,
long
itemId
,
String
operator
)
{
restTemplate
.
delete
(
env
,
"items/{itemId}?operator={operator}"
,
itemId
,
operator
);
}
}
@Service
public
static
class
ClusterAPI
extends
API
{
public
List
<
ClusterDTO
>
findClustersByApp
(
String
appId
,
Env
env
)
{
ClusterDTO
[]
clusterDTOs
=
restTemplate
.
get
(
env
,
"apps/{appId}/clusters"
,
ClusterDTO
[].
class
,
appId
);
return
Arrays
.
asList
(
clusterDTOs
);
}
public
ClusterDTO
loadCluster
(
String
appId
,
Env
env
,
String
clusterName
)
{
return
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}"
,
ClusterDTO
.
class
,
appId
,
clusterName
);
}
public
boolean
isClusterUnique
(
String
appId
,
Env
env
,
String
clusterName
)
{
return
restTemplate
.
get
(
env
,
"apps/{appId}/cluster/{clusterName}/unique"
,
Boolean
.
class
,
appId
,
clusterName
);
}
public
ClusterDTO
create
(
Env
env
,
ClusterDTO
cluster
)
{
return
restTemplate
.
post
(
env
,
"apps/{appId}/clusters"
,
cluster
,
ClusterDTO
.
class
,
cluster
.
getAppId
());
}
public
void
delete
(
Env
env
,
String
appId
,
String
clusterName
,
String
operator
)
{
restTemplate
.
delete
(
env
,
"apps/{appId}/clusters/{clusterName}?operator={operator}"
,
appId
,
clusterName
,
operator
);
}
}
@Service
public
static
class
ReleaseAPI
extends
API
{
private
static
final
Joiner
JOINER
=
Joiner
.
on
(
","
);
public
ReleaseDTO
loadRelease
(
Env
env
,
long
releaseId
)
{
return
restTemplate
.
get
(
env
,
"releases/{releaseId}"
,
ReleaseDTO
.
class
,
releaseId
);
}
public
List
<
ReleaseDTO
>
findReleaseByIds
(
Env
env
,
Set
<
Long
>
releaseIds
)
{
if
(
CollectionUtils
.
isEmpty
(
releaseIds
))
{
return
Collections
.
emptyList
();
}
ReleaseDTO
[]
releases
=
restTemplate
.
get
(
env
,
"/releases?releaseIds={releaseIds}"
,
ReleaseDTO
[].
class
,
JOINER
.
join
(
releaseIds
));
return
Arrays
.
asList
(
releases
);
}
public
List
<
ReleaseDTO
>
findAllReleases
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
int
page
,
int
size
)
{
ReleaseDTO
[]
releaseDTOs
=
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/all?page={page}&size={size}"
,
ReleaseDTO
[].
class
,
appId
,
clusterName
,
namespaceName
,
page
,
size
);
return
Arrays
.
asList
(
releaseDTOs
);
}
public
List
<
ReleaseDTO
>
findActiveReleases
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
int
page
,
int
size
)
{
ReleaseDTO
[]
releaseDTOs
=
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/active?page={page}&size={size}"
,
ReleaseDTO
[].
class
,
appId
,
clusterName
,
namespaceName
,
page
,
size
);
return
Arrays
.
asList
(
releaseDTOs
);
}
public
ReleaseDTO
loadLatestRelease
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
)
{
ReleaseDTO
releaseDTO
=
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/latest"
,
ReleaseDTO
.
class
,
appId
,
clusterName
,
namespace
);
return
releaseDTO
;
}
public
ReleaseDTO
createRelease
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
String
releaseName
,
String
releaseComment
,
String
operator
,
boolean
isEmergencyPublish
)
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
parseMediaType
(
MediaType
.
APPLICATION_FORM_URLENCODED_VALUE
+
";charset=UTF-8"
));
MultiValueMap
<
String
,
String
>
parameters
=
new
LinkedMultiValueMap
<>();
parameters
.
add
(
"name"
,
releaseName
);
parameters
.
add
(
"comment"
,
releaseComment
);
parameters
.
add
(
"operator"
,
operator
);
parameters
.
add
(
"isEmergencyPublish"
,
String
.
valueOf
(
isEmergencyPublish
));
HttpEntity
<
MultiValueMap
<
String
,
String
>>
entity
=
new
HttpEntity
<>(
parameters
,
headers
);
ReleaseDTO
response
=
restTemplate
.
post
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases"
,
entity
,
ReleaseDTO
.
class
,
appId
,
clusterName
,
namespace
);
return
response
;
}
public
ReleaseDTO
updateAndPublish
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
String
releaseName
,
String
releaseComment
,
String
branchName
,
boolean
isEmergencyPublish
,
boolean
deleteBranch
,
ItemChangeSets
changeSets
)
{
return
restTemplate
.
post
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/updateAndPublish?"
+
"releaseName={releaseName}&releaseComment={releaseComment}&branchName={branchName}"
+
"&deleteBranch={deleteBranch}&isEmergencyPublish={isEmergencyPublish}"
,
changeSets
,
ReleaseDTO
.
class
,
appId
,
clusterName
,
namespace
,
releaseName
,
releaseComment
,
branchName
,
deleteBranch
,
isEmergencyPublish
);
}
public
void
rollback
(
Env
env
,
long
releaseId
,
String
operator
)
{
restTemplate
.
put
(
env
,
"releases/{releaseId}/rollback?operator={operator}"
,
null
,
releaseId
,
operator
);
}
}
@Service
public
static
class
CommitAPI
extends
API
{
public
List
<
CommitDTO
>
find
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
int
page
,
int
size
)
{
CommitDTO
[]
commitDTOs
=
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/commit?page={page}&size={size}"
,
CommitDTO
[].
class
,
appId
,
clusterName
,
namespaceName
,
page
,
size
);
return
Arrays
.
asList
(
commitDTOs
);
}
}
@Service
public
static
class
NamespaceLockAPI
extends
API
{
public
NamespaceLockDTO
getNamespaceLockOwner
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
return
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock"
,
NamespaceLockDTO
.
class
,
appId
,
clusterName
,
namespaceName
);
}
}
@Service
public
static
class
InstanceAPI
extends
API
{
private
Joiner
joiner
=
Joiner
.
on
(
","
);
private
ParameterizedTypeReference
<
PageDTO
<
InstanceDTO
>>
pageInstanceDtoType
=
new
ParameterizedTypeReference
<
PageDTO
<
InstanceDTO
>>()
{
};
public
PageDTO
<
InstanceDTO
>
getByRelease
(
Env
env
,
long
releaseId
,
int
page
,
int
size
)
{
ResponseEntity
<
PageDTO
<
InstanceDTO
>>
entity
=
restTemplate
.
get
(
env
,
"/instances/by-release?releaseId={releaseId}&page={page}&size={size}"
,
pageInstanceDtoType
,
releaseId
,
page
,
size
);
return
entity
.
getBody
();
}
public
List
<
InstanceDTO
>
getByReleasesNotIn
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
Set
<
Long
>
releaseIds
)
{
InstanceDTO
[]
instanceDTOs
=
restTemplate
.
get
(
env
,
"/instances/by-namespace-and-releases-not-in?appId={appId}&clusterName={clusterName}&namespaceName={namespaceName}&releaseIds={releaseIds}"
,
InstanceDTO
[].
class
,
appId
,
clusterName
,
namespaceName
,
joiner
.
join
(
releaseIds
));
return
Arrays
.
asList
(
instanceDTOs
);
}
public
PageDTO
<
InstanceDTO
>
getByNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
String
instanceAppId
,
int
page
,
int
size
)
{
ResponseEntity
<
PageDTO
<
InstanceDTO
>>
entity
=
restTemplate
.
get
(
env
,
"/instances/by-namespace?appId={appId}"
+
"&clusterName={clusterName}&namespaceName={namespaceName}&instanceAppId={instanceAppId}"
+
"&page={page}&size={size}"
,
pageInstanceDtoType
,
appId
,
clusterName
,
namespaceName
,
instanceAppId
,
page
,
size
);
return
entity
.
getBody
();
}
public
int
getInstanceCountByNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
Integer
count
=
restTemplate
.
get
(
env
,
"/instances/by-namespace/count?appId={appId}&clusterName={clusterName}&namespaceName={namespaceName}"
,
Integer
.
class
,
appId
,
clusterName
,
namespaceName
);
if
(
count
==
null
)
{
return
0
;
}
return
count
;
}
}
@Service
public
static
class
NamespaceBranchAPI
extends
API
{
public
NamespaceDTO
createBranch
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
String
operator
)
{
return
restTemplate
.
post
(
env
,
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches?operator={operator}"
,
null
,
NamespaceDTO
.
class
,
appId
,
clusterName
,
namespaceName
,
operator
);
}
public
NamespaceDTO
findBranch
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
return
restTemplate
.
get
(
env
,
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
,
NamespaceDTO
.
class
,
appId
,
clusterName
,
namespaceName
);
}
public
GrayReleaseRuleDTO
findBranchGrayRules
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
String
branchName
)
{
return
restTemplate
.
get
(
env
,
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules"
,
GrayReleaseRuleDTO
.
class
,
appId
,
clusterName
,
namespaceName
,
branchName
);
}
public
void
updateBranchGrayRules
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
String
branchName
,
GrayReleaseRuleDTO
rules
)
{
restTemplate
.
put
(
env
,
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules"
,
rules
,
appId
,
clusterName
,
namespaceName
,
branchName
);
}
public
void
deleteBranch
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
String
branchName
,
String
operator
)
{
restTemplate
.
delete
(
env
,
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}?operator={operator}"
,
appId
,
clusterName
,
namespaceName
,
branchName
,
operator
);
}
}
@Service
public
static
class
ReleaseHistoryAPI
extends
API
{
private
ParameterizedTypeReference
<
PageDTO
<
ReleaseHistoryDTO
>>
type
=
new
ParameterizedTypeReference
<
PageDTO
<
ReleaseHistoryDTO
>>()
{
};
public
PageDTO
<
ReleaseHistoryDTO
>
findReleaseHistoriesByNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
int
page
,
int
size
)
{
return
restTemplate
.
get
(
env
,
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/histories?page={page}&size={size}"
,
type
,
appId
,
clusterName
,
namespaceName
,
page
,
size
).
getBody
();
}
public
PageDTO
<
ReleaseHistoryDTO
>
findByReleaseIdAndOperation
(
Env
env
,
long
releaseId
,
int
operation
,
int
page
,
int
size
)
{
return
restTemplate
.
get
(
env
,
"/releases/histories/by_release_id_and_operation?releaseId={releaseId}&operation={operation}&page={page}&size={size}"
,
type
,
releaseId
,
operation
,
page
,
size
).
getBody
();
}
public
PageDTO
<
ReleaseHistoryDTO
>
findByPreviousReleaseIdAndOperation
(
Env
env
,
long
previousReleaseId
,
int
operation
,
int
page
,
int
size
)
{
return
restTemplate
.
get
(
env
,
"/releases/histories/by_previous_release_id_and_operation?previousReleaseId={releaseId}&operation={operation}&page={page}&size={size}"
,
type
,
previousReleaseId
,
operation
,
page
,
size
).
getBody
();
}
public
PageDTO
<
ReleaseHistoryDTO
>
findReleaseHistoriesByNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
int
page
,
int
size
)
{
return
restTemplate
.
get
(
env
,
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/histories?page={page}&size={size}"
,
type
,
appId
,
clusterName
,
namespaceName
,
page
,
size
).
getBody
();
}
public
PageDTO
<
ReleaseHistoryDTO
>
findByReleaseIdAndOperation
(
Env
env
,
long
releaseId
,
int
operation
,
int
page
,
int
size
)
{
return
restTemplate
.
get
(
env
,
"/releases/histories/by_release_id_and_operation?releaseId={releaseId}&operation={operation}&page={page}&size={size}"
,
type
,
releaseId
,
operation
,
page
,
size
).
getBody
();
}
}
public
PageDTO
<
ReleaseHistoryDTO
>
findByPreviousReleaseIdAndOperation
(
Env
env
,
long
previousReleaseId
,
int
operation
,
int
page
,
int
size
)
{
return
restTemplate
.
get
(
env
,
"/releases/histories/by_previous_release_id_and_operation?previousReleaseId={releaseId}&operation={operation}&page={page}&size={size}"
,
type
,
previousReleaseId
,
operation
,
page
,
size
).
getBody
();
}
}
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java
View file @
2d9ece83
...
@@ -142,14 +142,12 @@ public class AppController {
...
@@ -142,14 +142,12 @@ public class AppController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@RequestMapping
(
value
=
"/{appId:.+}"
,
method
=
RequestMethod
.
DELETE
)
@RequestMapping
(
value
=
"/{appId:.+}"
,
method
=
RequestMethod
.
DELETE
)
public
void
deleteApp
(
@PathVariable
String
appId
)
{
public
void
deleteApp
(
@PathVariable
String
appId
)
{
App
app
=
appService
.
deleteAppInLocal
(
appId
);
App
app
=
appService
.
load
(
appId
);
publisher
.
publishEvent
(
new
AppDeletionEvent
(
app
));
publisher
.
publishEvent
(
new
AppDeletionEvent
(
app
));
appService
.
deleteAppInLocal
(
appId
);
}
}
@RequestMapping
(
value
=
"/{appId}/miss_envs"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/{appId}/miss_envs"
,
method
=
RequestMethod
.
GET
)
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppDeletionEvent.java
View file @
2d9ece83
...
@@ -8,7 +8,6 @@ public class AppDeletionEvent extends ApplicationEvent {
...
@@ -8,7 +8,6 @@ public class AppDeletionEvent extends ApplicationEvent {
public
AppDeletionEvent
(
Object
source
)
{
public
AppDeletionEvent
(
Object
source
)
{
super
(
source
);
super
(
source
);
}
}
public
App
getApp
()
{
public
App
getApp
()
{
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppInfoChangedListener.java
View file @
2d9ece83
...
@@ -24,8 +24,6 @@ public class AppInfoChangedListener {
...
@@ -24,8 +24,6 @@ public class AppInfoChangedListener {
private
AdminServiceAPI
.
AppAPI
appAPI
;
private
AdminServiceAPI
.
AppAPI
appAPI
;
@Autowired
@Autowired
private
PortalSettings
portalSettings
;
private
PortalSettings
portalSettings
;
@Autowired
private
UserInfoHolder
userInfoHolder
;
@EventListener
@EventListener
public
void
onAppInfoChange
(
AppInfoChangedEvent
event
)
{
public
void
onAppInfoChange
(
AppInfoChangedEvent
event
)
{
...
@@ -47,7 +45,7 @@ public class AppInfoChangedListener {
...
@@ -47,7 +45,7 @@ public class AppInfoChangedListener {
public
void
onAppDelete
(
AppDeletionEvent
event
)
{
public
void
onAppDelete
(
AppDeletionEvent
event
)
{
AppDTO
appDTO
=
BeanUtils
.
transfrom
(
AppDTO
.
class
,
event
.
getApp
());
AppDTO
appDTO
=
BeanUtils
.
transfrom
(
AppDTO
.
class
,
event
.
getApp
());
String
appId
=
appDTO
.
getAppId
();
String
appId
=
appDTO
.
getAppId
();
String
operator
=
userInfoHolder
.
getUser
().
getName
();
String
operator
=
appDTO
.
getDataChangeLastModifiedBy
();
List
<
Env
>
envs
=
portalSettings
.
getActiveEnvs
();
List
<
Env
>
envs
=
portalSettings
.
getActiveEnvs
();
for
(
Env
env
:
envs
)
{
for
(
Env
env
:
envs
)
{
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java
View file @
2d9ece83
...
@@ -18,7 +18,5 @@ public interface AppNamespaceRepository extends PagingAndSortingRepository<AppNa
...
@@ -18,7 +18,5 @@ public interface AppNamespaceRepository extends PagingAndSortingRepository<AppNa
@Modifying
@Modifying
@Query
(
"UPDATE AppNamespace SET IsDeleted=1,DataChange_LastModifiedBy=?2 WHERE AppId=?1"
)
@Query
(
"UPDATE AppNamespace SET IsDeleted=1,DataChange_LastModifiedBy=?2 WHERE AppId=?1"
)
int
batchDeleteByDeleteApp
(
String
appId
,
String
operator
);
int
batchDeleteByAppId
(
String
appId
,
String
operator
);
int
countByAppId
(
String
appId
);
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java
View file @
2d9ece83
...
@@ -21,7 +21,5 @@ public interface FavoriteRepository extends PagingAndSortingRepository<Favorite,
...
@@ -21,7 +21,5 @@ public interface FavoriteRepository extends PagingAndSortingRepository<Favorite,
@Modifying
@Modifying
@Query
(
"UPDATE Favorite SET IsDeleted=1,DataChange_LastModifiedBy = ?2 WHERE AppId=?1"
)
@Query
(
"UPDATE Favorite SET IsDeleted=1,DataChange_LastModifiedBy = ?2 WHERE AppId=?1"
)
int
batchDeleteByDeleteApp
(
String
appId
,
String
operator
);
int
batchDeleteByAppId
(
String
appId
,
String
operator
);
int
countByAppId
(
String
appId
);
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/PermissionRepository.java
View file @
2d9ece83
...
@@ -8,6 +8,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
...
@@ -8,6 +8,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
import
org.springframework.data.repository.query.Param
;
/**
/**
* @author Jason Song(song_s@ctrip.com)
* @author Jason Song(song_s@ctrip.com)
...
@@ -24,12 +25,10 @@ public interface PermissionRepository extends PagingAndSortingRepository<Permiss
...
@@ -24,12 +25,10 @@ public interface PermissionRepository extends PagingAndSortingRepository<Permiss
List
<
Permission
>
findByPermissionTypeInAndTargetId
(
Collection
<
String
>
permissionTypes
,
List
<
Permission
>
findByPermissionTypeInAndTargetId
(
Collection
<
String
>
permissionTypes
,
String
targetId
);
String
targetId
);
/**
@Query
(
"SELECT p.id from Permission p where p.targetId = ?1 or p.targetId like CONCAT(?1, '+%'))"
)
* delete Permission when delete app.
List
<
Long
>
findPermissionIdsByAppId
(
String
appId
);
*/
@Modifying
@Modifying
@Query
(
"UPDATE Permission SET IsDeleted=1,"
+
@Query
(
"UPDATE Permission SET IsDeleted=1, DataChange_LastModifiedBy = ?2 WHERE Id in ?1"
)
"TargetId=CONCAT('DELETED_',TargetId,'_',CURRENT_TIMESTAMP),"
+
Integer
batchDelete
(
List
<
Long
>
permissionIds
,
String
operator
);
"DataChange_LastModifiedBy = ?2 WHERE TargetId LIKE ?1 OR TargetId LIKE CONCAT(?1,'+%')"
)
Integer
batchDeleteByDeleteApp
(
String
appId
,
String
operator
);
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java
View file @
2d9ece83
...
@@ -2,6 +2,8 @@ package com.ctrip.framework.apollo.portal.repository;
...
@@ -2,6 +2,8 @@ package com.ctrip.framework.apollo.portal.repository;
import
com.ctrip.framework.apollo.portal.entity.po.RolePermission
;
import
com.ctrip.framework.apollo.portal.entity.po.RolePermission
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
java.util.Collection
;
import
java.util.Collection
;
...
@@ -17,4 +19,7 @@ public interface RolePermissionRepository extends PagingAndSortingRepository<Rol
...
@@ -17,4 +19,7 @@ public interface RolePermissionRepository extends PagingAndSortingRepository<Rol
*/
*/
List
<
RolePermission
>
findByRoleIdIn
(
Collection
<
Long
>
roleId
);
List
<
RolePermission
>
findByRoleIdIn
(
Collection
<
Long
>
roleId
);
@Modifying
@Query
(
"UPDATE RolePermission SET IsDeleted=1, DataChange_LastModifiedBy = ?2 WHERE PermissionId in ?1"
)
Integer
batchDeleteByPermissionIds
(
List
<
Long
>
permissionIds
,
String
operator
);
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java
View file @
2d9ece83
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
repository
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
repository
;
import
com.ctrip.framework.apollo.portal.entity.po.Role
;
import
com.ctrip.framework.apollo.portal.entity.po.Role
;
import
java.util.List
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
org.springframework.data.repository.query.Param
;
/**
/**
* @author Jason Song(song_s@ctrip.com)
* @author Jason Song(song_s@ctrip.com)
*/
*/
public
interface
RoleRepository
extends
PagingAndSortingRepository
<
Role
,
Long
>
{
public
interface
RoleRepository
extends
PagingAndSortingRepository
<
Role
,
Long
>
{
/**
/**
* find role by role name
* find role by role name
*/
*/
Role
findTopByRoleName
(
String
roleName
);
Role
findTopByRoleName
(
String
roleName
);
@Query
(
"SELECT r.id from Role r where (r.roleName = CONCAT('Master+', ?1) "
+
"OR r.roleName like CONCAT('ModifyNamespace+', ?1, '+%') "
+
"OR r.roleName like CONCAT('ReleaseNamespace+', ?1, '+%'))"
)
List
<
Long
>
findRoleIdsByAppId
(
String
appId
);
@Modifying
@Modifying
@Query
(
"UPDATE Role SET IsDeleted=1,"
+
@Query
(
"UPDATE Role SET IsDeleted=1, DataChange_LastModifiedBy = ?2 WHERE Id in ?1"
)
"RoleName=CONCAT('DELETED_',RoleName,'_',CURRENT_TIMESTAMP),"
+
Integer
batchDelete
(
List
<
Long
>
roleIds
,
String
operator
);
"DataChange_LastModifiedBy = ?2 WHERE RoleName LIKE CONCAT('Master+',?1) "
+
"OR RoleName LIKE CONCAT('ModifyNamespace+',?1,'+%') "
+
"OR RoleName LIKE CONCAT('ReleaseNamespace+',?1,'+%')"
)
Integer
batchDeleteByDeleteApp
(
String
appId
,
String
operator
);
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java
View file @
2d9ece83
...
@@ -2,6 +2,8 @@ package com.ctrip.framework.apollo.portal.repository;
...
@@ -2,6 +2,8 @@ package com.ctrip.framework.apollo.portal.repository;
import
com.ctrip.framework.apollo.portal.entity.po.UserRole
;
import
com.ctrip.framework.apollo.portal.entity.po.UserRole
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
java.util.Collection
;
import
java.util.Collection
;
...
@@ -26,4 +28,8 @@ public interface UserRoleRepository extends PagingAndSortingRepository<UserRole,
...
@@ -26,4 +28,8 @@ public interface UserRoleRepository extends PagingAndSortingRepository<UserRole,
*/
*/
List
<
UserRole
>
findByUserIdInAndRoleId
(
Collection
<
String
>
userId
,
long
roleId
);
List
<
UserRole
>
findByUserIdInAndRoleId
(
Collection
<
String
>
userId
,
long
roleId
);
@Modifying
@Query
(
"UPDATE UserRole SET IsDeleted=1, DataChange_LastModifiedBy = ?2 WHERE RoleId in ?1"
)
Integer
batchDeleteByRoleIds
(
List
<
Long
>
roleIds
,
String
operator
);
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppNamespaceService.java
View file @
2d9ece83
...
@@ -118,9 +118,7 @@ public class AppNamespaceService {
...
@@ -118,9 +118,7 @@ public class AppNamespaceService {
return
createdAppNamespace
;
return
createdAppNamespace
;
}
}
public
void
deleteApp
(
String
appId
,
String
operator
)
{
public
void
batchDeleteByAppId
(
String
appId
,
String
operator
)
{
if
(
appNamespaceRepository
.
countByAppId
(
appId
)
>
0
)
{
appNamespaceRepository
.
batchDeleteByAppId
(
appId
,
operator
);
appNamespaceRepository
.
batchDeleteByDeleteApp
(
appId
,
operator
);
}
}
}
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppService.java
View file @
2d9ece83
...
@@ -144,22 +144,28 @@ public class AppService {
...
@@ -144,22 +144,28 @@ public class AppService {
}
}
@Transactional
@Transactional
public
void
deleteAppInLocal
(
String
appId
)
{
public
App
deleteAppInLocal
(
String
appId
)
{
App
managedApp
=
appRepository
.
findByAppId
(
appId
);
App
managedApp
=
appRepository
.
findByAppId
(
appId
);
if
(
managedApp
==
null
)
{
if
(
managedApp
==
null
)
{
throw
new
BadRequestException
(
String
.
format
(
"App not exists. AppId = %s"
,
appId
));
throw
new
BadRequestException
(
String
.
format
(
"App not exists. AppId = %s"
,
appId
));
}
}
String
operator
=
userInfoHolder
.
getUser
().
getUserId
();
String
operator
=
userInfoHolder
.
getUser
().
getUserId
();
//this operator is passed to com.ctrip.framework.apollo.portal.listener.AppInfoChangedListener.onAppDelete
managedApp
.
setDataChangeLastModifiedBy
(
operator
);
//删除portal数据库中的app
//删除portal数据库中的app
appRepository
.
deleteApp
(
appId
,
operator
);
appRepository
.
deleteApp
(
appId
,
operator
);
//删除portal数据库中的appNamespace
//删除portal数据库中的appNamespace
appNamespaceService
.
deleteApp
(
appId
,
operator
);
appNamespaceService
.
batchDeleteByAppId
(
appId
,
operator
);
//删除portal数据库中的收藏表
//删除portal数据库中的收藏表
favoriteService
.
deleteApp
(
appId
,
operator
);
favoriteService
.
batchDeleteByAppId
(
appId
,
operator
);
//删除portal数据库中Per
i
mission、Role相关数据
//删除portal数据库中Permission、Role相关数据
rolePermissionService
.
deleteRolePermissionsByAppId
(
appId
,
operator
);
rolePermissionService
.
deleteRolePermissionsByAppId
(
appId
,
operator
);
return
managedApp
;
}
}
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/FavoriteService.java
View file @
2d9ece83
...
@@ -108,9 +108,7 @@ public class FavoriteService {
...
@@ -108,9 +108,7 @@ public class FavoriteService {
}
}
}
}
public
void
deleteApp
(
String
appId
,
String
operator
)
{
public
void
batchDeleteByAppId
(
String
appId
,
String
operator
)
{
if
(
favoriteRepository
.
countByAppId
(
appId
)
>
0
)
{
favoriteRepository
.
batchDeleteByAppId
(
appId
,
operator
);
favoriteRepository
.
batchDeleteByDeleteApp
(
appId
,
operator
);
}
}
}
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultRolePermissionService.java
View file @
2d9ece83
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
spi
.
defaultimpl
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
spi
.
defaultimpl
;
import
com.ctrip.framework.apollo.common.entity.BaseEntity
;
import
com.ctrip.framework.apollo.openapi.repository.ConsumerRoleRepository
;
import
com.ctrip.framework.apollo.portal.component.config.PortalConfig
;
import
com.ctrip.framework.apollo.portal.component.config.PortalConfig
;
import
com.ctrip.framework.apollo.portal.entity.bo.UserInfo
;
import
com.ctrip.framework.apollo.portal.entity.bo.UserInfo
;
import
com.ctrip.framework.apollo.portal.entity.po.Permission
;
import
com.ctrip.framework.apollo.portal.entity.po.Permission
;
...
@@ -16,6 +18,8 @@ import com.google.common.collect.FluentIterable;
...
@@ -16,6 +18,8 @@ import com.google.common.collect.FluentIterable;
import
com.google.common.collect.HashMultimap
;
import
com.google.common.collect.HashMultimap
;
import
com.google.common.collect.Multimap
;
import
com.google.common.collect.Multimap
;
import
com.google.common.collect.Sets
;
import
com.google.common.collect.Sets
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
...
@@ -36,7 +40,8 @@ public class DefaultRolePermissionService implements RolePermissionService {
...
@@ -36,7 +40,8 @@ public class DefaultRolePermissionService implements RolePermissionService {
private
PermissionRepository
permissionRepository
;
private
PermissionRepository
permissionRepository
;
@Autowired
@Autowired
private
PortalConfig
portalConfig
;
private
PortalConfig
portalConfig
;
@Autowired
private
ConsumerRoleRepository
consumerRoleRepository
;
/**
/**
* Create role with permissions, note that role name should be unique
* Create role with permissions, note that role name should be unique
...
@@ -223,7 +228,27 @@ public class DefaultRolePermissionService implements RolePermissionService {
...
@@ -223,7 +228,27 @@ public class DefaultRolePermissionService implements RolePermissionService {
@Transactional
@Transactional
@Override
@Override
public
void
deleteRolePermissionsByAppId
(
String
appId
,
String
operator
)
{
public
void
deleteRolePermissionsByAppId
(
String
appId
,
String
operator
)
{
permissionRepository
.
batchDeleteByDeleteApp
(
appId
,
operator
);
List
<
Long
>
permissionIds
=
permissionRepository
.
findPermissionIdsByAppId
(
appId
);
roleRepository
.
batchDeleteByDeleteApp
(
appId
,
operator
);
if
(!
permissionIds
.
isEmpty
())
{
// 1. delete Permission
permissionRepository
.
batchDelete
(
permissionIds
,
operator
);
// 2. delete Role Permission
rolePermissionRepository
.
batchDeleteByPermissionIds
(
permissionIds
,
operator
);
}
List
<
Long
>
roleIds
=
roleRepository
.
findRoleIdsByAppId
(
appId
);
if
(!
roleIds
.
isEmpty
())
{
// 3. delete Role
roleRepository
.
batchDelete
(
roleIds
,
operator
);
// 4. delete User Role
userRoleRepository
.
batchDeleteByRoleIds
(
roleIds
,
operator
);
// 5. delete Consumer Role
consumerRoleRepository
.
batchDeleteByRoleIds
(
roleIds
,
operator
);
}
}
}
}
}
scripts/docker-quick-start/sql/apolloconfigdb.sql
View file @
2d9ece83
...
@@ -364,38 +364,38 @@ CREATE TABLE `ServerConfig` (
...
@@ -364,38 +364,38 @@ CREATE TABLE `ServerConfig` (
#
------------------------------------------------------------
#
------------------------------------------------------------
INSERT
INTO
`ServerConfig`
(
`Key`
,
`Cluster`
,
`Value`
,
`Comment`
)
INSERT
INTO
`ServerConfig`
(
`Key`
,
`Cluster`
,
`Value`
,
`Comment`
)
VALUES
VALUES
(
'eureka.service.url'
,
'default'
,
'http://localhost:8080/eureka/'
,
'Eureka服务Url,多个service以英文逗号分隔'
),
(
'eureka.service.url'
,
'default'
,
'http://localhost:8080/eureka/'
,
'Eureka服务Url,多个service以英文逗号分隔'
),
(
'namespace.lock.switch'
,
'default'
,
'false'
,
'一次发布只能有一个人修改开关'
),
(
'namespace.lock.switch'
,
'default'
,
'false'
,
'一次发布只能有一个人修改开关'
),
(
'item.value.length.limit'
,
'default'
,
'20000'
,
'item value最大长度限制'
),
(
'item.value.length.limit'
,
'default'
,
'20000'
,
'item value最大长度限制'
),
(
'config-service.cache.enabled'
,
'default'
,
'false'
,
'ConfigService是否开启缓存,开启后能提高性能,但是会增大内存消耗!'
),
(
'config-service.cache.enabled'
,
'default'
,
'false'
,
'ConfigService是否开启缓存,开启后能提高性能,但是会增大内存消耗!'
),
(
'item.key.length.limit'
,
'default'
,
'128'
,
'item key 最大长度限制'
);
(
'item.key.length.limit'
,
'default'
,
'128'
,
'item key 最大长度限制'
);
#
Sample
Data
#
Sample
Data
#
------------------------------------------------------------
#
------------------------------------------------------------
INSERT
INTO
`App`
(
`AppId`
,
`Name`
,
`OrgId`
,
`OrgName`
,
`OwnerName`
,
`OwnerEmail`
)
INSERT
INTO
`App`
(
`AppId`
,
`Name`
,
`OrgId`
,
`OrgName`
,
`OwnerName`
,
`OwnerEmail`
)
VALUES
VALUES
(
'SampleApp'
,
'Sample App'
,
'TEST1'
,
'样例部门1'
,
'apollo'
,
'apollo@acme.com'
);
(
'SampleApp'
,
'Sample App'
,
'TEST1'
,
'样例部门1'
,
'apollo'
,
'apollo@acme.com'
);
INSERT
INTO
`AppNamespace`
(
`Name`
,
`AppId`
,
`Format`
,
`IsPublic`
,
`Comment`
)
INSERT
INTO
`AppNamespace`
(
`Name`
,
`AppId`
,
`Format`
,
`IsPublic`
,
`Comment`
)
VALUES
VALUES
(
'application'
,
'SampleApp'
,
'properties'
,
0
,
'default app namespace'
);
(
'application'
,
'SampleApp'
,
'properties'
,
0
,
'default app namespace'
);
INSERT
INTO
`Cluster`
(
`Name`
,
`AppId`
)
INSERT
INTO
`Cluster`
(
`Name`
,
`AppId`
)
VALUES
VALUES
(
'default'
,
'SampleApp'
);
(
'default'
,
'SampleApp'
);
INSERT
INTO
`Namespace`
(
`Id`
,
`AppId`
,
`ClusterName`
,
`NamespaceName`
)
INSERT
INTO
`Namespace`
(
`Id`
,
`AppId`
,
`ClusterName`
,
`NamespaceName`
)
VALUES
VALUES
(
1
,
'SampleApp'
,
'default'
,
'application'
);
(
1
,
'SampleApp'
,
'default'
,
'application'
);
INSERT
INTO
`Item`
(
`NamespaceId`
,
`Key`
,
`Value`
,
`Comment`
,
`LineNum`
)
INSERT
INTO
`Item`
(
`NamespaceId`
,
`Key`
,
`Value`
,
`Comment`
,
`LineNum`
)
VALUES
VALUES
(
1
,
'timeout'
,
'100'
,
'sample timeout配置'
,
1
);
(
1
,
'timeout'
,
'100'
,
'sample timeout配置'
,
1
);
INSERT
INTO
`Release`
(
`ReleaseKey`
,
`Name`
,
`Comment`
,
`AppId`
,
`ClusterName`
,
`NamespaceName`
,
`Configurations`
)
INSERT
INTO
`Release`
(
`ReleaseKey`
,
`Name`
,
`Comment`
,
`AppId`
,
`ClusterName`
,
`NamespaceName`
,
`Configurations`
)
VALUES
VALUES
(
'20161009155425-d3a0749c6e20bc15'
,
'20161009155424-release'
,
'Sample发布'
,
'SampleApp'
,
'default'
,
'application'
,
'{
\"
timeout
\"
:
\"
100
\"
}'
);
(
'20161009155425-d3a0749c6e20bc15'
,
'20161009155424-release'
,
'Sample发布'
,
'SampleApp'
,
'default'
,
'application'
,
'{
\"
timeout
\"
:
\"
100
\"
}'
);
INSERT
INTO
`ReleaseHistory`
(
`AppId`
,
`ClusterName`
,
`NamespaceName`
,
`BranchName`
,
`ReleaseId`
,
`PreviousReleaseId`
,
`Operation`
,
`OperationContext`
,
`DataChange_CreatedBy`
,
`DataChange_LastModifiedBy`
)
INSERT
INTO
`ReleaseHistory`
(
`AppId`
,
`ClusterName`
,
`NamespaceName`
,
`BranchName`
,
`ReleaseId`
,
`PreviousReleaseId`
,
`Operation`
,
`OperationContext`
,
`DataChange_CreatedBy`
,
`DataChange_LastModifiedBy`
)
VALUES
VALUES
...
...
scripts/docker-quick-start/sql/apolloportaldb.sql
View file @
2d9ece83
...
@@ -307,16 +307,16 @@ CREATE TABLE `Authorities` (
...
@@ -307,16 +307,16 @@ CREATE TABLE `Authorities` (
#
------------------------------------------------------------
#
------------------------------------------------------------
INSERT
INTO
`ServerConfig`
(
`Key`
,
`Value`
,
`Comment`
)
INSERT
INTO
`ServerConfig`
(
`Key`
,
`Value`
,
`Comment`
)
VALUES
VALUES
(
'apollo.portal.envs'
,
'dev'
,
'可支持的环境列表'
),
(
'apollo.portal.envs'
,
'dev'
,
'可支持的环境列表'
),
(
'organizations'
,
'[{
\"
orgId
\"
:
\"
TEST1
\"
,
\"
orgName
\"
:
\"
样例部门1
\"
},{
\"
orgId
\"
:
\"
TEST2
\"
,
\"
orgName
\"
:
\"
样例部门2
\"
}]'
,
'部门列表'
),
(
'organizations'
,
'[{
\"
orgId
\"
:
\"
TEST1
\"
,
\"
orgName
\"
:
\"
样例部门1
\"
},{
\"
orgId
\"
:
\"
TEST2
\"
,
\"
orgName
\"
:
\"
样例部门2
\"
}]'
,
'部门列表'
),
(
'superAdmin'
,
'apollo'
,
'Portal超级管理员'
),
(
'superAdmin'
,
'apollo'
,
'Portal超级管理员'
),
(
'api.readTimeout'
,
'10000'
,
'http接口read timeout'
),
(
'api.readTimeout'
,
'10000'
,
'http接口read timeout'
),
(
'consumer.token.salt'
,
'someSalt'
,
'consumer token salt'
),
(
'consumer.token.salt'
,
'someSalt'
,
'consumer token salt'
),
(
'admin.createPrivateNamespace.switch'
,
'false'
,
'是否允许项目管理员创建私有namespace'
);
(
'admin.createPrivateNamespace.switch'
,
'false'
,
'是否允许项目管理员创建私有namespace'
);
INSERT
INTO
`Users`
(
`Username`
,
`Password`
,
`Email`
,
`Enabled`
)
INSERT
INTO
`Users`
(
`Username`
,
`Password`
,
`Email`
,
`Enabled`
)
VALUES
VALUES
(
'apollo'
,
'$2a$10$7r20uS.BQ9uBpf3Baj3uQOZvMVvB1RN3PYoKE94gtz2.WAOuiiwXS'
,
'apollo@acme.com'
,
1
);
(
'apollo'
,
'$2a$10$7r20uS.BQ9uBpf3Baj3uQOZvMVvB1RN3PYoKE94gtz2.WAOuiiwXS'
,
'apollo@acme.com'
,
1
);
INSERT
INTO
`Authorities`
(
`Username`
,
`Authority`
)
VALUES
(
'apollo'
,
'ROLE_user'
);
INSERT
INTO
`Authorities`
(
`Username`
,
`Authority`
)
VALUES
(
'apollo'
,
'ROLE_user'
);
...
@@ -324,39 +324,39 @@ INSERT INTO `Authorities` (`Username`, `Authority`) VALUES ('apollo', 'ROLE_user
...
@@ -324,39 +324,39 @@ INSERT INTO `Authorities` (`Username`, `Authority`) VALUES ('apollo', 'ROLE_user
#
------------------------------------------------------------
#
------------------------------------------------------------
INSERT
INTO
`App`
(
`AppId`
,
`Name`
,
`OrgId`
,
`OrgName`
,
`OwnerName`
,
`OwnerEmail`
)
INSERT
INTO
`App`
(
`AppId`
,
`Name`
,
`OrgId`
,
`OrgName`
,
`OwnerName`
,
`OwnerEmail`
)
VALUES
VALUES
(
'SampleApp'
,
'Sample App'
,
'TEST1'
,
'样例部门1'
,
'apollo'
,
'apollo@acme.com'
);
(
'SampleApp'
,
'Sample App'
,
'TEST1'
,
'样例部门1'
,
'apollo'
,
'apollo@acme.com'
);
INSERT
INTO
`AppNamespace`
(
`Name`
,
`AppId`
,
`Format`
,
`IsPublic`
,
`Comment`
)
INSERT
INTO
`AppNamespace`
(
`Name`
,
`AppId`
,
`Format`
,
`IsPublic`
,
`Comment`
)
VALUES
VALUES
(
'application'
,
'SampleApp'
,
'properties'
,
0
,
'default app namespace'
);
(
'application'
,
'SampleApp'
,
'properties'
,
0
,
'default app namespace'
);
INSERT
INTO
`Permission`
(
`Id`
,
`PermissionType`
,
`TargetId`
)
INSERT
INTO
`Permission`
(
`Id`
,
`PermissionType`
,
`TargetId`
)
VALUES
VALUES
(
1
,
'CreateCluster'
,
'SampleApp'
),
(
1
,
'CreateCluster'
,
'SampleApp'
),
(
2
,
'CreateNamespace'
,
'SampleApp'
),
(
2
,
'CreateNamespace'
,
'SampleApp'
),
(
3
,
'AssignRole'
,
'SampleApp'
),
(
3
,
'AssignRole'
,
'SampleApp'
),
(
4
,
'ModifyNamespace'
,
'SampleApp+application'
),
(
4
,
'ModifyNamespace'
,
'SampleApp+application'
),
(
5
,
'ReleaseNamespace'
,
'SampleApp+application'
);
(
5
,
'ReleaseNamespace'
,
'SampleApp+application'
);
INSERT
INTO
`Role`
(
`Id`
,
`RoleName`
)
INSERT
INTO
`Role`
(
`Id`
,
`RoleName`
)
VALUES
VALUES
(
1
,
'Master+SampleApp'
),
(
1
,
'Master+SampleApp'
),
(
2
,
'ModifyNamespace+SampleApp+application'
),
(
2
,
'ModifyNamespace+SampleApp+application'
),
(
3
,
'ReleaseNamespace+SampleApp+application'
);
(
3
,
'ReleaseNamespace+SampleApp+application'
);
INSERT
INTO
`RolePermission`
(
`RoleId`
,
`PermissionId`
)
INSERT
INTO
`RolePermission`
(
`RoleId`
,
`PermissionId`
)
VALUES
VALUES
(
1
,
1
),
(
1
,
1
),
(
1
,
2
),
(
1
,
2
),
(
1
,
3
),
(
1
,
3
),
(
2
,
4
),
(
2
,
4
),
(
3
,
5
);
(
3
,
5
);
INSERT
INTO
`UserRole`
(
`UserId`
,
`RoleId`
)
INSERT
INTO
`UserRole`
(
`UserId`
,
`RoleId`
)
VALUES
VALUES
(
'apollo'
,
1
),
(
'apollo'
,
1
),
(
'apollo'
,
2
),
(
'apollo'
,
2
),
(
'apollo'
,
3
);
(
'apollo'
,
3
);
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */
;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */
;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */
;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */
;
...
...
scripts/sql/apolloconfigdb.sql
View file @
2d9ece83
...
@@ -364,11 +364,11 @@ CREATE TABLE `ServerConfig` (
...
@@ -364,11 +364,11 @@ CREATE TABLE `ServerConfig` (
#
------------------------------------------------------------
#
------------------------------------------------------------
INSERT
INTO
`ServerConfig`
(
`Key`
,
`Cluster`
,
`Value`
,
`Comment`
)
INSERT
INTO
`ServerConfig`
(
`Key`
,
`Cluster`
,
`Value`
,
`Comment`
)
VALUES
VALUES
(
'eureka.service.url'
,
'default'
,
'http://localhost:8080/eureka/'
,
'Eureka服务Url,多个service以英文逗号分隔'
),
(
'eureka.service.url'
,
'default'
,
'http://localhost:8080/eureka/'
,
'Eureka服务Url,多个service以英文逗号分隔'
),
(
'namespace.lock.switch'
,
'default'
,
'false'
,
'一次发布只能有一个人修改开关'
),
(
'namespace.lock.switch'
,
'default'
,
'false'
,
'一次发布只能有一个人修改开关'
),
(
'item.key.length.limit'
,
'default'
,
'128'
,
'item key 最大长度限制'
),
(
'item.key.length.limit'
,
'default'
,
'128'
,
'item key 最大长度限制'
),
(
'item.value.length.limit'
,
'default'
,
'20000'
,
'item value最大长度限制'
),
(
'item.value.length.limit'
,
'default'
,
'20000'
,
'item value最大长度限制'
),
(
'config-service.cache.enabled'
,
'default'
,
'false'
,
'ConfigService是否开启缓存,开启后能提高性能,但是会增大内存消耗!'
);
(
'config-service.cache.enabled'
,
'default'
,
'false'
,
'ConfigService是否开启缓存,开启后能提高性能,但是会增大内存消耗!'
);
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */
;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */
;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */
;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */
;
...
...
scripts/sql/apolloportaldb.sql
View file @
2d9ece83
...
@@ -307,16 +307,16 @@ CREATE TABLE `Authorities` (
...
@@ -307,16 +307,16 @@ CREATE TABLE `Authorities` (
#
------------------------------------------------------------
#
------------------------------------------------------------
INSERT
INTO
`ServerConfig`
(
`Key`
,
`Value`
,
`Comment`
)
INSERT
INTO
`ServerConfig`
(
`Key`
,
`Value`
,
`Comment`
)
VALUES
VALUES
(
'apollo.portal.envs'
,
'dev'
,
'可支持的环境列表'
),
(
'apollo.portal.envs'
,
'dev'
,
'可支持的环境列表'
),
(
'organizations'
,
'[{
\"
orgId
\"
:
\"
TEST1
\"
,
\"
orgName
\"
:
\"
样例部门1
\"
},{
\"
orgId
\"
:
\"
TEST2
\"
,
\"
orgName
\"
:
\"
样例部门2
\"
}]'
,
'部门列表'
),
(
'organizations'
,
'[{
\"
orgId
\"
:
\"
TEST1
\"
,
\"
orgName
\"
:
\"
样例部门1
\"
},{
\"
orgId
\"
:
\"
TEST2
\"
,
\"
orgName
\"
:
\"
样例部门2
\"
}]'
,
'部门列表'
),
(
'superAdmin'
,
'apollo'
,
'Portal超级管理员'
),
(
'superAdmin'
,
'apollo'
,
'Portal超级管理员'
),
(
'api.readTimeout'
,
'10000'
,
'http接口read timeout'
),
(
'api.readTimeout'
,
'10000'
,
'http接口read timeout'
),
(
'consumer.token.salt'
,
'someSalt'
,
'consumer token salt'
),
(
'consumer.token.salt'
,
'someSalt'
,
'consumer token salt'
),
(
'admin.createPrivateNamespace.switch'
,
'false'
,
'是否允许项目管理员创建私有namespace'
);
(
'admin.createPrivateNamespace.switch'
,
'false'
,
'是否允许项目管理员创建私有namespace'
);
INSERT
INTO
`Users`
(
`Username`
,
`Password`
,
`Email`
,
`Enabled`
)
INSERT
INTO
`Users`
(
`Username`
,
`Password`
,
`Email`
,
`Enabled`
)
VALUES
VALUES
(
'apollo'
,
'$2a$10$7r20uS.BQ9uBpf3Baj3uQOZvMVvB1RN3PYoKE94gtz2.WAOuiiwXS'
,
'apollo@acme.com'
,
1
);
(
'apollo'
,
'$2a$10$7r20uS.BQ9uBpf3Baj3uQOZvMVvB1RN3PYoKE94gtz2.WAOuiiwXS'
,
'apollo@acme.com'
,
1
);
INSERT
INTO
`Authorities`
(
`Username`
,
`Authority`
)
VALUES
(
'apollo'
,
'ROLE_user'
);
INSERT
INTO
`Authorities`
(
`Username`
,
`Authority`
)
VALUES
(
'apollo'
,
'ROLE_user'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment