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
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
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/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
...
@@ -72,6 +73,40 @@ public class ItemController {
...
@@ -72,6 +73,40 @@ public class ItemController {
return
dto
;
return
dto
;
}
}
@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
@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
)
{
...
...
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