Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
openSource
apollo
Commits
49832e6c
Commit
49832e6c
authored
Jun 13, 2016
by
Jason Song
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix admin service soft delete
parent
4f69747e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
29 deletions
+57
-29
AppService.java
...va/com/ctrip/framework/apollo/biz/service/AppService.java
+10
-3
ClusterService.java
...om/ctrip/framework/apollo/biz/service/ClusterService.java
+10
-3
ItemService.java
...a/com/ctrip/framework/apollo/biz/service/ItemService.java
+17
-10
ItemSetService.java
...om/ctrip/framework/apollo/biz/service/ItemSetService.java
+9
-9
NamespaceService.java
.../ctrip/framework/apollo/biz/service/NamespaceService.java
+10
-3
GlobalDefaultExceptionHandler.java
...ollo/common/controller/GlobalDefaultExceptionHandler.java
+1
-1
No files found.
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppService.java
View file @
49832e6c
...
@@ -30,10 +30,17 @@ public class AppService {
...
@@ -30,10 +30,17 @@ public class AppService {
}
}
@Transactional
@Transactional
public
void
delete
(
long
id
,
String
owner
)
{
public
void
delete
(
long
id
,
String
operator
)
{
appRepository
.
delete
(
id
);
App
app
=
appRepository
.
findOne
(
id
);
if
(
app
==
null
)
{
return
;
}
app
.
setDeleted
(
true
);
app
.
setDataChangeLastModifiedBy
(
operator
);
appRepository
.
save
(
app
);
auditService
.
audit
(
App
.
class
.
getSimpleName
(),
id
,
Audit
.
OP
.
DELETE
,
o
wne
r
);
auditService
.
audit
(
App
.
class
.
getSimpleName
(),
id
,
Audit
.
OP
.
DELETE
,
o
perato
r
);
}
}
public
List
<
App
>
findAll
(
Pageable
pageable
)
{
public
List
<
App
>
findAll
(
Pageable
pageable
)
{
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ClusterService.java
View file @
49832e6c
...
@@ -62,10 +62,17 @@ public class ClusterService {
...
@@ -62,10 +62,17 @@ public class ClusterService {
}
}
@Transactional
@Transactional
public
void
delete
(
long
id
,
String
owner
)
{
public
void
delete
(
long
id
,
String
operator
)
{
clusterRepository
.
delete
(
id
);
Cluster
cluster
=
clusterRepository
.
findOne
(
id
);
if
(
cluster
==
null
)
{
return
;
}
cluster
.
setDeleted
(
true
);
cluster
.
setDataChangeLastModifiedBy
(
operator
);
clusterRepository
.
save
(
cluster
);
auditService
.
audit
(
Cluster
.
class
.
getSimpleName
(),
id
,
Audit
.
OP
.
DELETE
,
o
wne
r
);
auditService
.
audit
(
Cluster
.
class
.
getSimpleName
(),
id
,
Audit
.
OP
.
DELETE
,
o
perato
r
);
}
}
@Transactional
@Transactional
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemService.java
View file @
49832e6c
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
service
;
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
service
;
import
java.util.Collections
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ctrip.framework.apollo.biz.entity.Audit
;
import
com.ctrip.framework.apollo.biz.entity.Audit
;
import
com.ctrip.framework.apollo.biz.entity.Item
;
import
com.ctrip.framework.apollo.biz.entity.Item
;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
...
@@ -15,6 +8,13 @@ import com.ctrip.framework.apollo.biz.repository.NamespaceRepository;
...
@@ -15,6 +8,13 @@ import com.ctrip.framework.apollo.biz.repository.NamespaceRepository;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.core.exception.NotFoundException
;
import
com.ctrip.framework.apollo.core.exception.NotFoundException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Collections
;
import
java.util.List
;
@Service
@Service
public
class
ItemService
{
public
class
ItemService
{
...
@@ -28,10 +28,17 @@ public class ItemService {
...
@@ -28,10 +28,17 @@ public class ItemService {
private
AuditService
auditService
;
private
AuditService
auditService
;
@Transactional
@Transactional
public
void
delete
(
long
id
,
String
owner
)
{
public
void
delete
(
long
id
,
String
operator
)
{
itemRepository
.
delete
(
id
);
Item
item
=
itemRepository
.
findOne
(
id
);
if
(
item
==
null
)
{
return
;
}
item
.
setDeleted
(
true
);
item
.
setDataChangeLastModifiedBy
(
operator
);
itemRepository
.
save
(
item
);
auditService
.
audit
(
Item
.
class
.
getSimpleName
(),
id
,
Audit
.
OP
.
DELETE
,
o
wne
r
);
auditService
.
audit
(
Item
.
class
.
getSimpleName
(),
id
,
Audit
.
OP
.
DELETE
,
o
perato
r
);
}
}
public
Item
findOne
(
String
appId
,
String
clusterName
,
String
namespaceName
,
String
key
)
{
public
Item
findOne
(
String
appId
,
String
clusterName
,
String
namespaceName
,
String
key
)
{
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java
View file @
49832e6c
...
@@ -23,15 +23,15 @@ public class ItemSetService {
...
@@ -23,15 +23,15 @@ public class ItemSetService {
@Transactional
@Transactional
public
void
updateSet
(
ItemChangeSets
changeSet
)
{
public
void
updateSet
(
ItemChangeSets
changeSet
)
{
String
o
wne
r
=
changeSet
.
getDataChangeLastModifiedBy
();
String
o
perato
r
=
changeSet
.
getDataChangeLastModifiedBy
();
if
(!
CollectionUtils
.
isEmpty
(
changeSet
.
getCreateItems
()))
{
if
(!
CollectionUtils
.
isEmpty
(
changeSet
.
getCreateItems
()))
{
for
(
ItemDTO
item
:
changeSet
.
getCreateItems
())
{
for
(
ItemDTO
item
:
changeSet
.
getCreateItems
())
{
Item
entity
=
BeanUtils
.
transfrom
(
Item
.
class
,
item
);
Item
entity
=
BeanUtils
.
transfrom
(
Item
.
class
,
item
);
entity
.
setDataChangeCreatedBy
(
o
wne
r
);
entity
.
setDataChangeCreatedBy
(
o
perato
r
);
entity
.
setDataChangeLastModifiedBy
(
o
wne
r
);
entity
.
setDataChangeLastModifiedBy
(
o
perato
r
);
itemRepository
.
save
(
entity
);
itemRepository
.
save
(
entity
);
}
}
auditService
.
audit
(
"ItemSet"
,
null
,
Audit
.
OP
.
INSERT
,
o
wne
r
);
auditService
.
audit
(
"ItemSet"
,
null
,
Audit
.
OP
.
INSERT
,
o
perato
r
);
}
}
if
(!
CollectionUtils
.
isEmpty
(
changeSet
.
getUpdateItems
()))
{
if
(!
CollectionUtils
.
isEmpty
(
changeSet
.
getUpdateItems
()))
{
...
@@ -39,20 +39,20 @@ public class ItemSetService {
...
@@ -39,20 +39,20 @@ public class ItemSetService {
Item
entity
=
BeanUtils
.
transfrom
(
Item
.
class
,
item
);
Item
entity
=
BeanUtils
.
transfrom
(
Item
.
class
,
item
);
Item
managedItem
=
itemRepository
.
findOne
(
entity
.
getId
());
Item
managedItem
=
itemRepository
.
findOne
(
entity
.
getId
());
BeanUtils
.
copyEntityProperties
(
entity
,
managedItem
);
BeanUtils
.
copyEntityProperties
(
entity
,
managedItem
);
managedItem
.
setDataChangeLastModifiedBy
(
o
wne
r
);
managedItem
.
setDataChangeLastModifiedBy
(
o
perato
r
);
itemRepository
.
save
(
managedItem
);
itemRepository
.
save
(
managedItem
);
}
}
auditService
.
audit
(
"ItemSet"
,
null
,
Audit
.
OP
.
UPDATE
,
o
wne
r
);
auditService
.
audit
(
"ItemSet"
,
null
,
Audit
.
OP
.
UPDATE
,
o
perato
r
);
}
}
if
(!
CollectionUtils
.
isEmpty
(
changeSet
.
getDeleteItems
()))
{
if
(!
CollectionUtils
.
isEmpty
(
changeSet
.
getDeleteItems
()))
{
for
(
ItemDTO
item
:
changeSet
.
getDeleteItems
())
{
for
(
ItemDTO
item
:
changeSet
.
getDeleteItems
())
{
Item
entity
=
BeanUtils
.
transfrom
(
Item
.
class
,
item
);
Item
entity
=
BeanUtils
.
transfrom
(
Item
.
class
,
item
);
entity
.
setDataChangeLastModifiedBy
(
owner
);
entity
.
setDeleted
(
true
);
entity
.
setDataChangeLastModifiedBy
(
operator
);
itemRepository
.
save
(
entity
);
itemRepository
.
save
(
entity
);
itemRepository
.
delete
(
item
.
getId
());
}
}
auditService
.
audit
(
"ItemSet"
,
null
,
Audit
.
OP
.
DELETE
,
o
wne
r
);
auditService
.
audit
(
"ItemSet"
,
null
,
Audit
.
OP
.
DELETE
,
o
perato
r
);
}
}
}
}
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java
View file @
49832e6c
...
@@ -33,10 +33,17 @@ public class NamespaceService {
...
@@ -33,10 +33,17 @@ public class NamespaceService {
}
}
@Transactional
@Transactional
public
void
delete
(
long
id
,
String
owner
)
{
public
void
delete
(
long
id
,
String
operator
)
{
namespaceRepository
.
delete
(
id
);
Namespace
namespace
=
namespaceRepository
.
findOne
(
id
);
if
(
namespace
==
null
)
{
return
;
}
namespace
.
setDeleted
(
true
);
namespace
.
setDataChangeLastModifiedBy
(
operator
);
namespaceRepository
.
save
(
namespace
);
auditService
.
audit
(
Namespace
.
class
.
getSimpleName
(),
id
,
Audit
.
OP
.
DELETE
,
o
wne
r
);
auditService
.
audit
(
Namespace
.
class
.
getSimpleName
(),
id
,
Audit
.
OP
.
DELETE
,
o
perato
r
);
}
}
public
Namespace
findOne
(
Long
namespaceId
)
{
public
Namespace
findOne
(
Long
namespaceId
)
{
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/GlobalDefaultExceptionHandler.java
View file @
49832e6c
...
@@ -62,7 +62,7 @@ public class GlobalDefaultExceptionHandler {
...
@@ -62,7 +62,7 @@ public class GlobalDefaultExceptionHandler {
errorAttributes
.
put
(
"timestamp"
,
errorAttributes
.
put
(
"timestamp"
,
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ISO_LOCAL_DATE_TIME
));
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ISO_LOCAL_DATE_TIME
));
errorAttributes
.
put
(
"exception"
,
resolveError
(
ex
).
getClass
().
getName
());
errorAttributes
.
put
(
"exception"
,
resolveError
(
ex
).
getClass
().
getName
());
errorAttributes
.
put
(
"stackTrace"
,
ex
.
getStackTrace
());
//
errorAttributes.put("stackTrace", ex.getStackTrace());
if
(
ex
instanceof
AbstractBaseException
)
{
if
(
ex
instanceof
AbstractBaseException
)
{
errorAttributes
.
put
(
"errorCode"
,
((
AbstractBaseException
)
ex
).
getErrorCode
());
errorAttributes
.
put
(
"errorCode"
,
((
AbstractBaseException
)
ex
).
getErrorCode
());
}
}
...
...
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