Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wrr-cat
apollo
提交
f1b91928
apollo
项目概览
wrr-cat
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f1b91928
编写于
6月 13, 2016
作者:
张
张乐
提交者:
GitHub
6月 13, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #262 from nobodyiam/adminservice-delete
fix admin service soft delete
上级
4f69747e
49832e6c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
57 addition
and
29 deletion
+57
-29
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppService.java
...va/com/ctrip/framework/apollo/biz/service/AppService.java
+10
-3
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ClusterService.java
...om/ctrip/framework/apollo/biz/service/ClusterService.java
+10
-3
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemService.java
...a/com/ctrip/framework/apollo/biz/service/ItemService.java
+17
-10
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java
...om/ctrip/framework/apollo/biz/service/ItemSetService.java
+9
-9
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java
.../ctrip/framework/apollo/biz/service/NamespaceService.java
+10
-3
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/GlobalDefaultExceptionHandler.java
...ollo/common/controller/GlobalDefaultExceptionHandler.java
+1
-1
未找到文件。
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppService.java
浏览文件 @
f1b91928
...
@@ -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
浏览文件 @
f1b91928
...
@@ -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
浏览文件 @
f1b91928
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
浏览文件 @
f1b91928
...
@@ -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
浏览文件 @
f1b91928
...
@@ -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
浏览文件 @
f1b91928
...
@@ -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
());
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录