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
b0513014
Commit
b0513014
authored
Jul 07, 2016
by
lepdou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
admin server add update item api
parent
5c6081a0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
ItemController.java
...mework/apollo/adminservice/controller/ItemController.java
+35
-0
No files found.
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemController.java
View file @
b0513014
...
@@ -21,6 +21,7 @@ import com.ctrip.framework.apollo.biz.service.NamespaceService;
...
@@ -21,6 +21,7 @@ import com.ctrip.framework.apollo.biz.service.NamespaceService;
import
com.ctrip.framework.apollo.biz.utils.ConfigChangeContentBuilder
;
import
com.ctrip.framework.apollo.biz.utils.ConfigChangeContentBuilder
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.core.dto.ItemDTO
;
import
com.ctrip.framework.apollo.core.dto.ItemDTO
;
import
com.ctrip.framework.apollo.core.exception.BadRequestException
;
import
com.ctrip.framework.apollo.core.exception.NotFoundException
;
import
com.ctrip.framework.apollo.core.exception.NotFoundException
;
@RestController
@RestController
...
@@ -73,6 +74,40 @@ public class ItemController {
...
@@ -73,6 +74,40 @@ public class ItemController {
}
}
@PreAcquireNamespaceLock
@PreAcquireNamespaceLock
@RequestMapping
(
path
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items"
,
method
=
RequestMethod
.
PUT
)
public
ItemDTO
update
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@RequestBody
ItemDTO
itemDTO
)
{
Item
entity
=
BeanUtils
.
transfrom
(
Item
.
class
,
itemDTO
);
ConfigChangeContentBuilder
builder
=
new
ConfigChangeContentBuilder
();
Item
managedEntity
=
itemService
.
findOne
(
appId
,
clusterName
,
namespaceName
,
entity
.
getKey
());
if
(
managedEntity
==
null
)
{
throw
new
BadRequestException
(
"item not exist"
);
}
Item
beforeUpdateItem
=
BeanUtils
.
transfrom
(
Item
.
class
,
managedEntity
);
BeanUtils
.
copyEntityProperties
(
entity
,
managedEntity
);
entity
=
itemService
.
update
(
managedEntity
);
builder
.
updateItem
(
beforeUpdateItem
,
entity
);
itemDTO
=
BeanUtils
.
transfrom
(
ItemDTO
.
class
,
entity
);
Commit
commit
=
new
Commit
();
commit
.
setAppId
(
appId
);
commit
.
setClusterName
(
clusterName
);
commit
.
setNamespaceName
(
namespaceName
);
commit
.
setChangeSets
(
builder
.
build
());
commit
.
setDataChangeCreatedBy
(
itemDTO
.
getDataChangeLastModifiedBy
());
commit
.
setDataChangeLastModifiedBy
(
itemDTO
.
getDataChangeLastModifiedBy
());
commitService
.
save
(
commit
);
return
itemDTO
;
}
@PreAcquireNamespaceLock
@RequestMapping
(
path
=
"/items/{itemId}"
,
method
=
RequestMethod
.
DELETE
)
@RequestMapping
(
path
=
"/items/{itemId}"
,
method
=
RequestMethod
.
DELETE
)
public
void
delete
(
@PathVariable
(
"itemId"
)
long
itemId
,
@RequestParam
String
operator
)
{
public
void
delete
(
@PathVariable
(
"itemId"
)
long
itemId
,
@RequestParam
String
operator
)
{
Item
entity
=
itemService
.
findOne
(
itemId
);
Item
entity
=
itemService
.
findOne
(
itemId
);
...
...
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