Commit 6a80f254 by lepdou

重构 item update api

parent 81dc3b9c
...@@ -74,16 +74,18 @@ public class ItemController { ...@@ -74,16 +74,18 @@ public class ItemController {
} }
@PreAcquireNamespaceLock @PreAcquireNamespaceLock
@RequestMapping(path = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items", method = RequestMethod.PUT) @RequestMapping(path = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{itemId}", method = RequestMethod.PUT)
public ItemDTO update(@PathVariable("appId") String appId, public ItemDTO update(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName, @PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName, @RequestBody ItemDTO itemDTO) { @PathVariable("namespaceName") String namespaceName,
@PathVariable("itemId") long itemId,
@RequestBody ItemDTO itemDTO) {
Item entity = BeanUtils.transfrom(Item.class, itemDTO); Item entity = BeanUtils.transfrom(Item.class, itemDTO);
ConfigChangeContentBuilder builder = new ConfigChangeContentBuilder(); ConfigChangeContentBuilder builder = new ConfigChangeContentBuilder();
Item managedEntity = itemService.findOne(appId, clusterName, namespaceName, entity.getKey()); Item managedEntity = itemService.findOne(itemId);
if (managedEntity == null) { if (managedEntity == null) {
throw new BadRequestException("item not exist"); throw new BadRequestException("item not exist");
} }
......
...@@ -107,9 +107,9 @@ public class AdminServiceAPI { ...@@ -107,9 +107,9 @@ public class AdminServiceAPI {
changeSets, Void.class, getAdminServiceHost(env), appId, clusterName, namespace); changeSets, Void.class, getAdminServiceHost(env), appId, clusterName, namespace);
} }
public void updateItem(String appId, Env env, String clusterName, String namespace, ItemDTO item) { public void updateItem(String appId, Env env, String clusterName, String namespace, long itemId, ItemDTO item) {
restTemplate.put("{host}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items", restTemplate.put("{host}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{itemId}",
item, getAdminServiceHost(env), appId, clusterName, namespace); item, getAdminServiceHost(env), appId, clusterName, namespace, itemId);
} }
......
...@@ -100,7 +100,7 @@ public class ConfigService { ...@@ -100,7 +100,7 @@ public class ConfigService {
public void updateItem(String appId, Env env, String clusterName, String namespaceName, ItemDTO item) { public void updateItem(String appId, Env env, String clusterName, String namespaceName, ItemDTO item) {
String username = userInfoHolder.getUser().getUserId(); String username = userInfoHolder.getUser().getUserId();
item.setDataChangeLastModifiedBy(username); item.setDataChangeLastModifiedBy(username);
itemAPI.updateItem(appId, env, clusterName, namespaceName, item); itemAPI.updateItem(appId, env, clusterName, namespaceName, item.getId(), item);
} }
public void deleteItem(Env env, long itemId) { public void deleteItem(Env env, long itemId) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment