提交 ea20fad0 编写于 作者: L lepdou

用户信息通过dto传递

上级 be118512
......@@ -4,7 +4,6 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -15,7 +14,6 @@ import org.springframework.web.bind.annotation.RestController;
import com.ctrip.framework.apollo.biz.entity.App;
import com.ctrip.framework.apollo.biz.service.AdminService;
import com.ctrip.framework.apollo.biz.service.AppService;
import com.ctrip.framework.apollo.common.auth.ActiveUser;
import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.AppDTO;
import com.ctrip.framework.apollo.core.exception.NotFoundException;
......@@ -31,16 +29,14 @@ public class AppController {
private AdminService adminService;
@RequestMapping(path = "/apps", method = RequestMethod.POST)
public AppDTO createOrUpdate(@RequestBody AppDTO dto, @ActiveUser UserDetails user) {
public AppDTO createOrUpdate(@RequestBody AppDTO dto) {
App entity = BeanUtils.transfrom(App.class, dto);
App managedEntity = appService.findOne(entity.getAppId());
if (managedEntity != null) {
managedEntity.setDataChangeLastModifiedBy(user.getUsername());
managedEntity.setDataChangeLastModifiedBy(entity.getDataChangeLastModifiedBy());
BeanUtils.copyEntityProperties(entity, managedEntity);
entity = appService.update(managedEntity);
} else {
entity.setDataChangeCreatedBy(user.getUsername());
entity.setDataChangeLastModifiedBy(user.getUsername());
entity = adminService.createNewApp(entity);
}
......@@ -49,10 +45,10 @@ public class AppController {
}
@RequestMapping(path = "/apps/{appId}", method = RequestMethod.DELETE)
public void delete(@PathVariable("appId") String appId, @ActiveUser UserDetails user) {
public void delete(@PathVariable("appId") String appId, @RequestParam String operator) {
App entity = appService.findOne(appId);
if (entity == null) throw new NotFoundException("app not found for appId " + appId);
appService.delete(entity.getId(), user.getUsername());
appService.delete(entity.getId(), operator);
}
@RequestMapping("/apps")
......
package com.ctrip.framework.apollo.adminservice.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -10,7 +9,6 @@ import org.springframework.web.bind.annotation.RestController;
import com.ctrip.framework.apollo.biz.entity.AppNamespace;
import com.ctrip.framework.apollo.biz.service.AppNamespaceService;
import com.ctrip.framework.apollo.common.auth.ActiveUser;
import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.AppNamespaceDTO;
......@@ -35,20 +33,17 @@ public class AppNamespaceController {
}
@RequestMapping(value = "/apps/{appId}/appnamespaces", method = RequestMethod.POST)
public AppNamespaceDTO createOrUpdate( @RequestBody AppNamespaceDTO appNamespace, @ActiveUser UserDetails user){
public AppNamespaceDTO createOrUpdate( @RequestBody AppNamespaceDTO appNamespace){
AppNamespace entity = BeanUtils.transfrom(AppNamespace.class, appNamespace);
AppNamespace managedEntity = appNamespaceService.findOne(entity.getAppId(), entity.getName());
String userName = user.getUsername();
if (managedEntity != null){
managedEntity.setDataChangeLastModifiedBy(userName);
managedEntity.setDataChangeLastModifiedBy(entity.getDataChangeLastModifiedBy());
BeanUtils.copyEntityProperties(entity, managedEntity);
entity = appNamespaceService.update(managedEntity);
}else {
entity.setDataChangeLastModifiedBy(userName);
entity.setDataChangeCreatedBy(userName);
entity = appNamespaceService.createAppNamespace(entity, userName);
entity = appNamespaceService.createAppNamespace(entity, entity.getDataChangeCreatedBy());
}
return BeanUtils.transfrom(AppNamespaceDTO.class, entity);
......
......@@ -3,16 +3,15 @@ package com.ctrip.framework.apollo.adminservice.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ctrip.framework.apollo.biz.entity.Cluster;
import com.ctrip.framework.apollo.biz.service.ClusterService;
import com.ctrip.framework.apollo.common.auth.ActiveUser;
import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.ClusterDTO;
import com.ctrip.framework.apollo.core.exception.NotFoundException;
......@@ -24,16 +23,13 @@ public class ClusterController {
private ClusterService clusterService;
@RequestMapping(path = "/apps/{appId}/clusters", method = RequestMethod.POST)
public ClusterDTO createOrUpdate(@PathVariable("appId") String appId, @RequestBody ClusterDTO dto,
@ActiveUser UserDetails user) {
public ClusterDTO createOrUpdate(@PathVariable("appId") String appId, @RequestBody ClusterDTO dto) {
Cluster entity = BeanUtils.transfrom(Cluster.class, dto);
Cluster managedEntity = clusterService.findOne(appId, entity.getName());
if (managedEntity != null) {
managedEntity.setDataChangeLastModifiedBy(user.getUsername());
BeanUtils.copyEntityProperties(entity, managedEntity);
entity = clusterService.update(managedEntity);
} else {
entity.setDataChangeCreatedBy(user.getUsername());
entity = clusterService.save(entity);
}
......@@ -41,13 +37,13 @@ public class ClusterController {
return dto;
}
@RequestMapping(path = "/apps/{appId}/clusters/{clusterName}", method = RequestMethod.DELETE)
@RequestMapping(path = "/apps/{appId}/clusters/{clusterName:.+}", method = RequestMethod.DELETE)
public void delete(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName, @ActiveUser UserDetails user) {
@PathVariable("clusterName") String clusterName, @RequestParam String operator) {
Cluster entity = clusterService.findOne(appId, clusterName);
if (entity == null)
throw new NotFoundException("cluster not found for clusterName " + clusterName);
clusterService.delete(entity.getId(), user.getUsername());
clusterService.delete(entity.getId(), operator);
}
@RequestMapping("/apps/{appId}/clusters")
......@@ -56,7 +52,7 @@ public class ClusterController {
return BeanUtils.batchTransform(ClusterDTO.class, clusters);
}
@RequestMapping("/apps/{appId}/clusters/{clusterName}")
@RequestMapping("/apps/{appId}/clusters/{clusterName:.+}")
public ClusterDTO get(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName) {
Cluster cluster = clusterService.findOne(appId, clusterName);
......
......@@ -4,16 +4,15 @@ import java.util.LinkedList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ctrip.framework.apollo.biz.entity.Item;
import com.ctrip.framework.apollo.biz.service.ItemService;
import com.ctrip.framework.apollo.common.auth.ActiveUser;
import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.ItemDTO;
import com.ctrip.framework.apollo.core.exception.NotFoundException;
......@@ -26,24 +25,21 @@ public class ItemController {
@RequestMapping(path = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items", method = RequestMethod.POST)
public ItemDTO createOrUpdate(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName, @RequestBody ItemDTO dto,
@ActiveUser UserDetails user) {
@PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName, @RequestBody ItemDTO dto) {
Item entity = BeanUtils.transfrom(Item.class, dto);
Item managedEntity = itemService.findOne(appId, clusterName, namespaceName, entity.getKey());
if (managedEntity != null) {
managedEntity.setDataChangeLastModifiedBy(user.getUsername());
BeanUtils.copyEntityProperties(entity, managedEntity);
entity = itemService.update(managedEntity);
} else {
Item lastItem = itemService.findLastOne(appId, clusterName, namespaceName);
int lineNum = 1;
if (lastItem != null){
lineNum = lastItem.getLineNum() + 1;
if (lastItem != null) {
Integer lastItemNum = lastItem.getLineNum();
lineNum = lastItemNum == null ? 1 : lastItemNum + 1;
}
entity.setLineNum(lineNum);
entity.setDataChangeCreatedBy(user.getUsername());
entity.setDataChangeLastModifiedBy(user.getUsername());
entity = itemService.save(entity);
}
......@@ -52,20 +48,22 @@ public class ItemController {
}
@RequestMapping(path = "/items/{itemId}", method = RequestMethod.DELETE)
public void delete(@PathVariable("itemId") long itemId, @ActiveUser UserDetails user) {
public void delete(@PathVariable("itemId") long itemId, @RequestParam String operator) {
Item entity = itemService.findOne(itemId);
if (entity == null) throw new NotFoundException("item not found for itemId " + itemId);
itemService.delete(entity.getId(), user.getUsername());
if (entity == null) {
throw new NotFoundException("item not found for itemId " + itemId);
}
itemService.delete(entity.getId(), operator);
}
@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items")
public List<ItemDTO> findItems(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName) {
@PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName) {
List<Item> items = itemService.findItems(appId, clusterName, namespaceName);
List<ItemDTO> itemDTOs = new LinkedList<>();
for (Item item: items){
for (Item item : items) {
ItemDTO itemDTO = BeanUtils.transfrom(ItemDTO.class, item);
itemDTO.setLastModifiedBy(item.getDataChangeLastModifiedBy());
itemDTO.setLastModifiedTime(item.getDataChangeLastModifiedTime());
......@@ -77,17 +75,21 @@ public class ItemController {
@RequestMapping("/items/{itemId}")
public ItemDTO get(@PathVariable("itemId") long itemId) {
Item item = itemService.findOne(itemId);
if (item == null) throw new NotFoundException("item not found for itemId " + itemId);
if (item == null) {
throw new NotFoundException("item not found for itemId " + itemId);
}
return BeanUtils.transfrom(ItemDTO.class, item);
}
@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key}")
@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key:.+}")
public ItemDTO get(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName, @PathVariable("key") String key) {
@PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName, @PathVariable("key") String key) {
Item item = itemService.findOne(appId, clusterName, namespaceName, key);
if (item == null) throw new NotFoundException(
String.format("item not found for %s %s %s %s", appId, clusterName, namespaceName, key));
if (item == null) {
throw new NotFoundException(
String.format("item not found for %s %s %s %s", appId, clusterName, namespaceName, key));
}
return BeanUtils.transfrom(ItemDTO.class, item);
}
}
......@@ -3,14 +3,12 @@ package com.ctrip.framework.apollo.adminservice.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.ctrip.framework.apollo.biz.service.ItemSetService;
import com.ctrip.framework.apollo.common.auth.ActiveUser;
import com.ctrip.framework.apollo.core.dto.ItemChangeSets;
@RestController
......@@ -20,8 +18,8 @@ public class ItemSetController {
private ItemSetService itemSetService;
@RequestMapping(path = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/itemset", method = RequestMethod.POST)
public ResponseEntity<Void> create(@RequestBody ItemChangeSets changeSet, @ActiveUser UserDetails user) {
itemSetService.updateSet(changeSet, user.getUsername());
public ResponseEntity<Void> create(@RequestBody ItemChangeSets changeSet) {
itemSetService.updateSet(changeSet);
return ResponseEntity.status(HttpStatus.OK).build();
}
}
......@@ -3,16 +3,15 @@ package com.ctrip.framework.apollo.adminservice.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ctrip.framework.apollo.biz.entity.Namespace;
import com.ctrip.framework.apollo.biz.service.NamespaceService;
import com.ctrip.framework.apollo.common.auth.ActiveUser;
import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.NamespaceDTO;
import com.ctrip.framework.apollo.core.exception.NotFoundException;
......@@ -25,16 +24,13 @@ public class NamespaceController {
@RequestMapping(path = "/apps/{appId}/clusters/{clusterName}/namespaces", method = RequestMethod.POST)
public NamespaceDTO createOrUpdate(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName, @RequestBody NamespaceDTO dto,
@ActiveUser UserDetails user) {
@PathVariable("clusterName") String clusterName, @RequestBody NamespaceDTO dto) {
Namespace entity = BeanUtils.transfrom(Namespace.class, dto);
Namespace managedEntity = namespaceService.findOne(appId, clusterName, entity.getNamespaceName());
if (managedEntity != null) {
managedEntity.setDataChangeLastModifiedBy(user.getUsername());
BeanUtils.copyEntityProperties(entity, managedEntity);
entity = namespaceService.update(managedEntity);
} else {
entity.setDataChangeCreatedBy(user.getUsername());
entity = namespaceService.save(entity);
}
......@@ -42,14 +38,14 @@ public class NamespaceController {
return dto;
}
@RequestMapping(path = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}", method = RequestMethod.DELETE)
@RequestMapping(path = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName:.+}", method = RequestMethod.DELETE)
public void delete(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName, @ActiveUser UserDetails user) {
@PathVariable("namespaceName") String namespaceName, @RequestParam String operator) {
Namespace entity = namespaceService.findOne(appId, clusterName, namespaceName);
if (entity == null) throw new NotFoundException(
String.format("namespace not found for %s %s %s", appId, clusterName, namespaceName));
namespaceService.delete(entity.getId(), user.getUsername());
namespaceService.delete(entity.getId(), operator);
}
@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces")
......@@ -67,7 +63,7 @@ public class NamespaceController {
return BeanUtils.transfrom(NamespaceDTO.class, namespace);
}
@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}")
@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName:.+}")
public NamespaceDTO get(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName) {
......
......@@ -9,14 +9,12 @@ import com.ctrip.framework.apollo.biz.message.Topics;
import com.ctrip.framework.apollo.biz.service.ConfigService;
import com.ctrip.framework.apollo.biz.service.NamespaceService;
import com.ctrip.framework.apollo.biz.service.ReleaseService;
import com.ctrip.framework.apollo.common.auth.ActiveUser;
import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.core.dto.ReleaseDTO;
import com.ctrip.framework.apollo.core.exception.NotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......@@ -78,13 +76,13 @@ public class ReleaseController {
@PathVariable("namespaceName") String namespaceName,
@RequestParam("name") String name,
@RequestParam(name = "comment", required = false) String comment,
@ActiveUser UserDetails user) {
@RequestParam("operator") String operator) {
Namespace namespace = namespaceService.findOne(appId, clusterName, namespaceName);
if (namespace == null) {
throw new NotFoundException(String.format("Could not find namespace for %s %s %s", appId,
clusterName, namespaceName));
}
Release release = releaseService.buildRelease(name, comment, namespace, user.getUsername());
Release release = releaseService.buildRelease(name, comment, namespace, operator);
messageSender.sendMessage(assembleKey(appId, clusterName, namespaceName),
Topics.APOLLO_RELEASE_TOPIC);
return BeanUtils.transfrom(ReleaseDTO.class, release);
......
......@@ -85,8 +85,7 @@ public class ControllerExceptionTest {
when(adminService.createNewApp(any(App.class)))
.thenThrow(new ServiceException("create app failed"));
UserDetails user = new User("user", "", new ArrayList<GrantedAuthority>());
appController.createOrUpdate(dto, user);
appController.createOrUpdate(dto);
}
private AppDTO generateSampleDTOData() {
......@@ -95,6 +94,8 @@ public class ControllerExceptionTest {
dto.setName("someName");
dto.setOwnerName("someOwner");
dto.setOwnerEmail("someOwner@ctrip.com");
dto.setDataChangeLastModifiedBy("test");
dto.setDataChangeCreatedBy("test");
return dto;
}
}
......@@ -46,6 +46,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
Assert.assertEquals("application", namespace.getNamespaceName());
ItemChangeSets itemSet = new ItemChangeSets();
itemSet.setDataChangeLastModifiedBy("created");
RestTemplate createdTemplate = new TestRestTemplate("created", "");
createdTemplate.setMessageConverters(restTemplate.getMessageConverters());
......@@ -94,6 +95,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
Assert.assertEquals("application", namespace.getNamespaceName());
ItemChangeSets createChangeSet = new ItemChangeSets();
createChangeSet.setDataChangeLastModifiedBy("created");
RestTemplate createdRestTemplate = new TestRestTemplate("created", "");
createdRestTemplate.setMessageConverters(restTemplate.getMessageConverters());
......@@ -118,20 +120,22 @@ public class ItemSetControllerTest extends AbstractControllerTest {
+ cluster.getName() + "/namespaces/" + namespace.getNamespaceName() + "/items",
ItemDTO[].class);
ItemChangeSets udpateChangeSet = new ItemChangeSets();
ItemChangeSets updateChangeSet = new ItemChangeSets();
updateChangeSet.setDataChangeLastModifiedBy("updated");
RestTemplate updatedRestTemplate = new TestRestTemplate("updated", "");
updatedRestTemplate.setMessageConverters(restTemplate.getMessageConverters());
int updatedSize = 2;
for (int i = 0; i < updatedSize; i++) {
items[i].setValue("updated_value_" + i);
udpateChangeSet.addUpdateItem(items[i]);
updateChangeSet.addUpdateItem(items[i]);
}
response = updatedRestTemplate.postForEntity(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName()
+ "/namespaces/" + namespace.getNamespaceName() + "/itemset",
udpateChangeSet, Void.class);
updateChangeSet, Void.class);
Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
List<Item> savedItems = itemRepository.findByNamespaceIdOrderByLineNumAsc(namespace.getId());
Assert.assertEquals(createdSize, savedItems.size());
......@@ -165,6 +169,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
Assert.assertEquals("application", namespace.getNamespaceName());
ItemChangeSets createChangeSet = new ItemChangeSets();
createChangeSet.setDataChangeLastModifiedBy("created");
RestTemplate createdTemplate = new TestRestTemplate("created", "");
createdTemplate.setMessageConverters(restTemplate.getMessageConverters());
......@@ -190,6 +195,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
ItemDTO[].class);
ItemChangeSets deleteChangeSet = new ItemChangeSets();
deleteChangeSet.setDataChangeLastModifiedBy("deleted");
RestTemplate deletedTemplate = new TestRestTemplate("deleted", "");
deletedTemplate.setMessageConverters(restTemplate.getMessageConverters());
......
......@@ -76,6 +76,7 @@ public class ReleaseControllerTest extends AbstractControllerTest {
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
parameters.add("name", "someReleaseName");
parameters.add("comment", "someComment");
parameters.add("operator", "test");
HttpEntity<MultiValueMap<String, String>> entity =
new HttpEntity<MultiValueMap<String, String>>(parameters, headers);
ResponseEntity<ReleaseDTO> response = restTemplate.postForEntity(
......@@ -111,7 +112,6 @@ public class ReleaseControllerTest extends AbstractControllerTest {
ReleaseService someReleaseService = mock(ReleaseService.class);
MessageSender someMessageSender = mock(MessageSender.class);
Namespace someNamespace = mock(Namespace.class);
UserDetails someUser = mock(UserDetails.class);
ReleaseController releaseController = new ReleaseController();
ReflectionTestUtils.setField(releaseController, "releaseService", someReleaseService);
......@@ -120,10 +120,9 @@ public class ReleaseControllerTest extends AbstractControllerTest {
when(someNamespaceService.findOne(someAppId, someCluster, someNamespaceName))
.thenReturn(someNamespace);
when(someUser.getUsername()).thenReturn(someUserName);
releaseController
.buildRelease(someAppId, someCluster, someNamespaceName, someName, someComment, someUser);
.buildRelease(someAppId, someCluster, someNamespaceName, someName, someComment, "test");
verify(someMessageSender, times(1))
.sendMessage(Joiner.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR)
......
......@@ -21,7 +21,8 @@ public class ItemSetService {
private AuditService auditService;
@Transactional
public void updateSet(ItemChangeSets changeSet, String owner) {
public void updateSet(ItemChangeSets changeSet) {
String owner = changeSet.getDataChangeLastModifiedBy();
if (changeSet.getCreateItems() != null) {
for (ItemDTO item : changeSet.getCreateItems()) {
Item entity = BeanUtils.transfrom(Item.class, item);
......
......@@ -24,6 +24,7 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.favorPathExtension(false);
configurer.ignoreAcceptHeader(true).defaultContentType(MediaType.APPLICATION_JSON);
}
......
......@@ -226,6 +226,5 @@ public class BeanUtils {
org.springframework.beans.BeanUtils.copyProperties(source, target, COPY_IGNORED_PROPERTIES);
}
private static final String[] COPY_IGNORED_PROPERTIES = {"id", "dataChangeCreatedBy",
"dataChangeCreatedTime", "dataChangeLastModifiedBy", "dataChangeLastModifiedTime"};
private static final String[] COPY_IGNORED_PROPERTIES = {"id", "dataChangeCreatedTime", "dataChangeLastModifiedTime"};
}
package com.ctrip.framework.apollo.core.dto;
public class AppDTO {
public class AppDTO extends BaseDTO{
private long id;
......
package com.ctrip.framework.apollo.core.dto;
public class AppNamespaceDTO {
public class AppNamespaceDTO extends BaseDTO{
private long id;
private String name;
......
package com.ctrip.framework.apollo.core.dto;
public class BaseDTO {
protected String dataChangeCreatedBy;
protected String dataChangeLastModifiedBy;
public String getDataChangeCreatedBy() {
return dataChangeCreatedBy;
}
public void setDataChangeCreatedBy(String dataChangeCreatedBy) {
this.dataChangeCreatedBy = dataChangeCreatedBy;
}
public String getDataChangeLastModifiedBy() {
return dataChangeLastModifiedBy;
}
public void setDataChangeLastModifiedBy(String dataChangeLastModifiedBy) {
this.dataChangeLastModifiedBy = dataChangeLastModifiedBy;
}
}
package com.ctrip.framework.apollo.core.dto;
public class ClusterDTO {
public class ClusterDTO extends BaseDTO{
private long id;
......
......@@ -6,7 +6,7 @@ import java.util.List;
/**
* storage cud result
*/
public class ItemChangeSets {
public class ItemChangeSets extends BaseDTO{
private List<ItemDTO> createItems = new LinkedList<>();
private List<ItemDTO> updateItems = new LinkedList<>();
......
......@@ -2,7 +2,7 @@ package com.ctrip.framework.apollo.core.dto;
import java.util.Date;
public class ItemDTO {
public class ItemDTO extends BaseDTO{
private long id;
......
package com.ctrip.framework.apollo.core.dto;
public class NamespaceDTO{
public class NamespaceDTO extends BaseDTO{
private long id;
private String appId;
......
package com.ctrip.framework.apollo.core.dto;
public class ReleaseDTO{
public class ReleaseDTO extends BaseDTO{
private long id;
private String releaseKey;
......
......@@ -73,9 +73,9 @@ public class PortalSettings {
healthCheckService = Executors.newScheduledThreadPool(1);
healthCheckService
.scheduleWithFixedDelay(new HealthCheckTask(applicationContext), 1000, HEALTH_CHECK_INTERVAL,
TimeUnit.MILLISECONDS);
// healthCheckService
// .scheduleWithFixedDelay(new HealthCheckTask(applicationContext), 1000, HEALTH_CHECK_INTERVAL,
// TimeUnit.MILLISECONDS);
}
......
......@@ -25,6 +25,7 @@ public class API {
}
public String getAdminServiceHost(Env env) {
return serviceLocator.getServiceAddress(env).getHomepageUrl();
return "http://localhost:8090";
// return serviceLocator.getServiceAddress(env).getHomepageUrl();
}
}
......@@ -27,9 +27,9 @@ import java.util.List;
public class AdminServiceAPI {
@Service
public static class HealthAPI extends API{
public static class HealthAPI extends API {
public Health health(Env env){
public Health health(Env env) {
return restTemplate.getForObject(getAdminServiceHost(env) + "/health", Health.class);
}
}
......@@ -37,20 +37,18 @@ public class AdminServiceAPI {
@Service
public static class AppAPI extends API {
public static String APP_API = "/apps";
public List<AppDTO> findApps(Env env) {
AppDTO[] appDTOs =
restTemplate.getForObject(getAdminServiceHost(env) + APP_API, AppDTO[].class);
restTemplate.getForObject("{host}/apps", AppDTO[].class, getAdminServiceHost(env));
return Arrays.asList(appDTOs);
}
public AppDTO loadApp(Env env, String appId){
return restTemplate.getForObject(getAdminServiceHost(env) + APP_API + "/" + appId, AppDTO.class);
public AppDTO loadApp(Env env, String appId) {
return restTemplate.getForObject("{host}/apps/{appId}", AppDTO.class, getAdminServiceHost(env), appId);
}
public AppDTO createApp(Env env, AppDTO app) {
return restTemplate.postForEntity(getAdminServiceHost(env) + APP_API, app, AppDTO.class)
return restTemplate.postForEntity("{host}/apps", app, AppDTO.class, getAdminServiceHost(env))
.getBody();
}
}
......@@ -60,38 +58,36 @@ public class AdminServiceAPI {
public static class NamespaceAPI extends API {
public List<NamespaceDTO> findNamespaceByCluster(String appId, Env env, String clusterName) {
NamespaceDTO[] namespaceDTOs = restTemplate.getForObject(
getAdminServiceHost(env)
+ String.format("apps/%s/clusters/%s/namespaces", appId, clusterName),
NamespaceDTO[].class);
NamespaceDTO[] namespaceDTOs = restTemplate.getForObject("{host}/apps/{appId}/clusters/{clusterName}/namespaces",
NamespaceDTO[].class, getAdminServiceHost(env), appId,
clusterName);
return Arrays.asList(namespaceDTOs);
}
public NamespaceDTO loadNamespace(String appId, Env env, String clusterName,
String namespaceName) {
return restTemplate.getForObject(getAdminServiceHost(env)
+ String.format("apps/%s/clusters/%s/namespaces/%s", appId, clusterName, namespaceName),
NamespaceDTO.class);
String namespaceName) {
NamespaceDTO dto = restTemplate.getForObject("{host}/apps/{appId}/clusters/{clusterName}/namespaces/" + namespaceName,
NamespaceDTO.class, getAdminServiceHost(env), appId, clusterName);
return dto;
}
public List<AppNamespaceDTO> findPublicAppNamespaces(Env env){
AppNamespaceDTO[] appNamespaceDTOs = restTemplate.getForObject(
getAdminServiceHost(env)+ "appnamespaces/public",
AppNamespaceDTO[].class);
public List<AppNamespaceDTO> findPublicAppNamespaces(Env env) {
AppNamespaceDTO[]
appNamespaceDTOs =
restTemplate.getForObject("{host}/appnamespaces/public", AppNamespaceDTO[].class
, getAdminServiceHost(env));
return Arrays.asList(appNamespaceDTOs);
}
public NamespaceDTO createNamespace(Env env, NamespaceDTO namespace) {
return restTemplate.postForEntity(getAdminServiceHost(env) +
String.format("/apps/%s/clusters/%s/namespaces", namespace.getAppId(),
namespace.getClusterName()), namespace, NamespaceDTO.class)
.getBody();
return restTemplate
.postForEntity("{host}/apps/{appId}/clusters/{clusterName}/namespaces", namespace, NamespaceDTO.class,
getAdminServiceHost(env), namespace.getAppId(), namespace.getClusterName()).getBody();
}
public AppNamespaceDTO createAppNamespace(Env env, AppNamespaceDTO appNamespace) {
return restTemplate.postForEntity(getAdminServiceHost(env) +
String.format("/apps/%s/appnamespaces", appNamespace.getAppId()), appNamespace, AppNamespaceDTO.class)
.getBody();
public AppNamespaceDTO createOrUpdate(Env env, AppNamespaceDTO appNamespace) {
return restTemplate.postForEntity("{host}/apps/{appId}/appnamespaces", appNamespace, AppNamespaceDTO.class,
getAdminServiceHost(env), appNamespace.getAppId()).getBody();
}
}
......@@ -102,28 +98,27 @@ public class AdminServiceAPI {
public List<ItemDTO> findItems(String appId, Env env, String clusterName, String namespace) {
ItemDTO[] itemDTOs =
restTemplate
.getForObject(
getAdminServiceHost(env) + String.format(
"apps/%s/clusters/%s/namespaces/%s/items", appId, clusterName, namespace),
ItemDTO[].class);
.getForObject("{host}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items",
ItemDTO[].class,
getAdminServiceHost(env), appId, clusterName, namespace);
return Arrays.asList(itemDTOs);
}
public void updateItems(String appId, Env env, String clusterName, String namespace,
ItemChangeSets changeSets) {
restTemplate.postForEntity(getAdminServiceHost(env) + String
.format("apps/%s/clusters/%s/namespaces/%s/itemset", appId, clusterName, namespace),
changeSets, Void.class);
ItemChangeSets changeSets) {
restTemplate.postForEntity("{host}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/itemset",
changeSets, Void.class, getAdminServiceHost(env), appId, clusterName, namespace);
}
public ItemDTO createOrUpdateItem(String appId, Env env, String clusterName, String namespace, ItemDTO item){
return restTemplate.postForEntity(getAdminServiceHost(env) + String
.format("apps/%s/clusters/%s/namespaces/%s/items", appId, clusterName, namespace),
item, ItemDTO.class).getBody();
public ItemDTO createOrUpdateItem(String appId, Env env, String clusterName, String namespace, ItemDTO item) {
return restTemplate.postForEntity("{host}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items",
item, ItemDTO.class, getAdminServiceHost(env), appId, clusterName, namespace)
.getBody();
}
public void deleteItem( Env env, long itemId){
restTemplate.delete(getAdminServiceHost(env) + "items/" + itemId);
public void deleteItem(Env env, long itemId, String operator) {
restTemplate.delete("{host}/items/{itemId}?operator={operator}", getAdminServiceHost(env), itemId, operator);
}
}
......@@ -131,8 +126,8 @@ public class AdminServiceAPI {
public static class ClusterAPI extends API {
public List<ClusterDTO> findClustersByApp(String appId, Env env) {
ClusterDTO[] clusterDTOs = restTemplate.getForObject(
getAdminServiceHost(env) + String.format("apps/%s/clusters", appId), ClusterDTO[].class);
ClusterDTO[] clusterDTOs = restTemplate.getForObject("{host}/apps/{appId}/clusters", ClusterDTO[].class,
getAdminServiceHost(env), appId);
return Arrays.asList(clusterDTOs);
}
}
......@@ -142,29 +137,31 @@ public class AdminServiceAPI {
public ReleaseDTO loadLatestRelease(String appId, Env env, String clusterName,
String namespace) {
ReleaseDTO releaseDTO = restTemplate.getForObject(
getAdminServiceHost(env) + String.format(
"apps/%s/clusters/%s/namespaces/%s/releases/latest", appId, clusterName, namespace),
ReleaseDTO.class);
ReleaseDTO
releaseDTO =
restTemplate
.getForObject("{host}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/latest",
ReleaseDTO.class, getAdminServiceHost(env), appId, clusterName, namespace);
return releaseDTO;
}
public ReleaseDTO release(String appId, Env env, String clusterName, String namespace,
String releaseBy, String comment) {
String releaseBy, String comment, String operator) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
parameters.add("name", releaseBy);
parameters.add("comment", comment);
parameters.add("operator", operator);
HttpEntity<MultiValueMap<String, String>> entity =
new HttpEntity<MultiValueMap<String, String>>(parameters, headers);
ResponseEntity<ReleaseDTO> response =
restTemplate
.postForEntity(
getAdminServiceHost(env) + String.format(
"apps/%s/clusters/%s/namespaces/%s/releases", appId, clusterName, namespace),
entity, ReleaseDTO.class);
.postForEntity("{host}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases", entity,
ReleaseDTO.class,
getAdminServiceHost(env), appId, clusterName, namespace);
return response.getBody();
}
}
}
......@@ -17,6 +17,7 @@ import com.ctrip.framework.apollo.core.exception.BadRequestException;
import com.ctrip.framework.apollo.core.exception.ServiceException;
import com.ctrip.framework.apollo.portal.PortalSettings;
import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
import com.ctrip.framework.apollo.portal.auth.UserInfoHolder;
import com.ctrip.framework.apollo.portal.entity.vo.EnvClusterInfo;
@Service
......@@ -24,6 +25,9 @@ public class PortalAppService {
private Logger logger = LoggerFactory.getLogger(PortalAppService.class);
@Autowired
private UserInfoHolder userInfoHolder;
@Autowired
private PortalClusterService clusterService;
......@@ -71,6 +75,7 @@ public class PortalAppService {
}
public void createAppInAllEnvs(AppDTO app) {
enrichUserInfo(app);
List<Env> envs = portalSettings.getActiveEnvs();
for (Env env : envs) {
try {
......@@ -83,6 +88,7 @@ public class PortalAppService {
}
public void createApp(Env env, AppDTO app) {
enrichUserInfo(app);
try {
appAPI.createApp(env, app);
} catch (HttpStatusCodeException e) {
......@@ -91,6 +97,12 @@ public class PortalAppService {
}
}
private void enrichUserInfo(AppDTO app){
String username = userInfoHolder.getUser().getUsername();
app.setDataChangeCreatedBy(username);
app.setDataChangeLastModifiedBy(username);
}
public EnvClusterInfo createEnvNavNode(Env env, String appId){
EnvClusterInfo node = new EnvClusterInfo(env);
node.setClusters(clusterService.findClusters(env, appId));
......
......@@ -17,7 +17,9 @@ import com.ctrip.framework.apollo.core.dto.ReleaseDTO;
import com.ctrip.framework.apollo.core.exception.BadRequestException;
import com.ctrip.framework.apollo.core.exception.NotFoundException;
import com.ctrip.framework.apollo.core.exception.ServiceException;
import com.ctrip.framework.apollo.core.utils.StringUtils;
import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
import com.ctrip.framework.apollo.portal.auth.UserInfoHolder;
import com.ctrip.framework.apollo.portal.entity.vo.ItemDiffs;
import com.ctrip.framework.apollo.portal.entity.vo.NamespaceIdentifer;
import com.ctrip.framework.apollo.portal.entity.form.NamespaceTextModel;
......@@ -33,13 +35,14 @@ public class PortalConfigService {
private Logger logger = LoggerFactory.getLogger(PortalConfigService.class);
@Autowired
private UserInfoHolder userInfoHolder;
@Autowired
private AdminServiceAPI.NamespaceAPI namespaceAPI;
@Autowired
private AdminServiceAPI.ItemAPI itemAPI;
@Autowired
private AdminServiceAPI.ReleaseAPI releaseAPI;
@Autowired
private ConfigTextResolver resolver;
......@@ -62,7 +65,9 @@ public class PortalConfigService {
if (changeSets.isEmpty()) {
return;
}
try {
changeSets.setDataChangeLastModifiedBy(userInfoHolder.getUser().getUsername());
itemAPI.updateItems(appId, env, clusterName, namespaceName, changeSets);
} catch (Exception e) {
logger.error("itemAPI.updateItems error. appId{},env:{},clusterName:{},namespaceName:{}", appId, env, clusterName,
......@@ -72,41 +77,49 @@ public class PortalConfigService {
}
public ItemDTO createOrUpdateItem(String appId, Env env, String clusterName, String namespaceName, ItemDTO item){
public ItemDTO createOrUpdateItem(String appId, Env env, String clusterName, String namespaceName, ItemDTO item) {
NamespaceDTO namespace = namespaceAPI.loadNamespace(appId, env, clusterName, namespaceName);
if (namespace == null){
if (namespace == null) {
throw new BadRequestException(
"namespace:" + namespaceName + " not exist in env:" + env + ", cluster:" + clusterName);
}
String username = userInfoHolder.getUser().getUsername();
if (StringUtils.isEmpty(item.getDataChangeCreatedBy())) {
item.setDataChangeCreatedBy(username);
}
item.setDataChangeLastModifiedBy(username);
item.setNamespaceId(namespace.getId());
return itemAPI.createOrUpdateItem(appId, env, clusterName, namespaceName, item);
}
public void deleteItem(Env env, long itemId){
itemAPI.deleteItem(env, itemId);
public void deleteItem(Env env, long itemId) {
itemAPI.deleteItem(env, itemId, userInfoHolder.getUser().getUsername());
}
/**
* createRelease config items
*/
public ReleaseDTO createRelease(NamespaceReleaseModel model) {
return releaseAPI.release(model.getAppId(), model.getEnv(), model.getClusterName(),
model.getNamespaceName(), model.getReleaseBy(), model.getReleaseComment());
model.getNamespaceName(), model.getReleaseBy(), model.getReleaseComment()
, userInfoHolder.getUser().getUsername());
}
public List<ItemDTO> findItems(String appId, Env env, String clusterName, String namespaceName) {
return itemAPI.findItems(appId, env, clusterName, namespaceName);
}
public void syncItems(List<NamespaceIdentifer> comparedNamespaces, List<ItemDTO> sourceItems){
public void syncItems(List<NamespaceIdentifer> comparedNamespaces, List<ItemDTO> sourceItems) {
List<ItemDiffs> itemDiffs = compare(comparedNamespaces, sourceItems);
for (ItemDiffs itemDiff: itemDiffs){
for (ItemDiffs itemDiff : itemDiffs) {
NamespaceIdentifer namespaceIdentifer = itemDiff.getNamespace();
ItemChangeSets changeSets = itemDiff.getDiffs();
changeSets.setDataChangeLastModifiedBy(userInfoHolder.getUser().getUsername());
try {
itemAPI
.updateItems(namespaceIdentifer.getAppId(), namespaceIdentifer.getEnv(),
namespaceIdentifer.getClusterName(),
namespaceIdentifer.getNamespaceName(), itemDiff.getDiffs());
namespaceIdentifer.getNamespaceName(), changeSets);
} catch (HttpClientErrorException e) {
logger.error("sync items error. namespace:{}", namespaceIdentifer);
throw new ServiceException(String.format("sync item error. env:%s, clusterName:%s", namespaceIdentifer.getEnv(),
......@@ -147,7 +160,7 @@ public class PortalConfigService {
return namespaceDTO.getId();
}
private ItemChangeSets parseChangeSets(NamespaceIdentifer namespace, List<ItemDTO> sourceItems){
private ItemChangeSets parseChangeSets(NamespaceIdentifer namespace, List<ItemDTO> sourceItems) {
ItemChangeSets changeSets = new ItemChangeSets();
List<ItemDTO>
targetItems =
......@@ -175,8 +188,7 @@ public class PortalConfigService {
changeSets.addCreateItem(buildItem(namespaceId, ++maxLineNum, sourceItem));
} else if (!sourceValue.equals(targetItem.getValue()) || !sourceComment
.equals(targetItem.getComment())) {//modified items
} else if (isModified(sourceValue, targetItem.getValue(), sourceComment, targetItem.getComment())) {//modified items
targetItem.setValue(sourceValue);
targetItem.setComment(sourceComment);
changeSets.addUpdateItem(targetItem);
......@@ -194,4 +206,19 @@ public class PortalConfigService {
createdItem.setNamespaceId(namespaceId);
return createdItem;
}
private boolean isModified(String sourceValue, String targetValue, String sourceComment, String targetComment) {
if (!sourceValue.equals(targetValue)) {
return true;
}
if (sourceComment == null) {
return !StringUtils.isEmpty(targetComment);
} else if (targetComment != null) {
return !sourceComment.equals(targetComment);
} else {
return false;
}
}
}
......@@ -8,10 +8,10 @@ import com.ctrip.framework.apollo.core.dto.ItemDTO;
import com.ctrip.framework.apollo.core.dto.NamespaceDTO;
import com.ctrip.framework.apollo.core.dto.ReleaseDTO;
import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.core.exception.NotFoundException;
import com.ctrip.framework.apollo.core.utils.StringUtils;
import com.ctrip.framework.apollo.portal.PortalSettings;
import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
import com.ctrip.framework.apollo.portal.auth.UserInfoHolder;
import com.ctrip.framework.apollo.portal.entity.vo.NamespaceVO;
import org.slf4j.Logger;
......@@ -33,15 +33,14 @@ public class PortalNamespaceService {
private Logger logger = LoggerFactory.getLogger(PortalNamespaceService.class);
@Autowired
private UserInfoHolder userInfoHolder;
@Autowired
private AdminServiceAPI.ItemAPI itemAPI;
@Autowired
private AdminServiceAPI.ReleaseAPI releaseAPI;
@Autowired
private AdminServiceAPI.NamespaceAPI namespaceAPI;
@Autowired
private PortalSettings portalSettings;
......@@ -53,13 +52,22 @@ public class PortalNamespaceService {
}
public NamespaceDTO createNamespace(Env env, NamespaceDTO namespace) {
if (StringUtils.isEmpty(namespace.getDataChangeCreatedBy())){
namespace.setDataChangeCreatedBy(userInfoHolder.getUser().getUsername());
}
namespace.setDataChangeLastModifiedBy(userInfoHolder.getUser().getUsername());
return namespaceAPI.createNamespace(env, namespace);
}
public void createAppNamespace(AppNamespaceDTO appNamespace) {
String operator = userInfoHolder.getUser().getUsername();
if (StringUtils.isEmpty(appNamespace.getDataChangeCreatedBy())){
appNamespace.setDataChangeCreatedBy(operator);
}
appNamespace.setDataChangeLastModifiedBy(operator);
for (Env env : portalSettings.getActiveEnvs()) {
try {
namespaceAPI.createAppNamespace(env, appNamespace);
namespaceAPI.createOrUpdate(env, appNamespace);
} catch (HttpStatusCodeException e) {
logger.error(ExceptionUtils.toString(e));
throw e;
......
......@@ -278,7 +278,7 @@
<span class="glyphicon glyphicon-eye-open" aria-hidden="true"
data-tooltip="tooltip" data-placement="bottom" title="查看"
data-toggle="modal" data-target="#itemModal"
ng-click="retrieveItem(config.item, config.oldValue)">
ng-click="retrieveItem(namespace, config.item, config.oldValue)">
</span>
&nbsp;
<span class="glyphicon glyphicon-edit" aria-hidden="true"
......
......@@ -128,7 +128,7 @@
</div>
<div class="row" style="margin-top: 10px;" ng-show="diff.diffs.updateItems.length > 0">
<div class="form-horizontal">
<label class="col-sm-2 control-label">更新的配置</label>
<label class="col-sm-2 control-label">修改的配置</label>
<div class="col-sm-9">
<table class="table table-bordered table-striped table-hover">
<thead>
......@@ -169,6 +169,9 @@
<div ng-include="'../views/common/footer.html'"></div>
<!-- jquery.js -->
<script src="../vendor/jquery.min.js" type="text/javascript"></script>
<!--angular-->
<script src="../vendor/angular/angular.min.js"></script>
<script src="../vendor/angular/angular-route.min.js"></script>
......@@ -176,8 +179,7 @@
<script src="../vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script>
<script src="../vendor/angular/loading-bar.min.js"></script>
<!-- jquery.js -->
<script src="vendor/jquery.min.js" type="text/javascript"></script>
<!-- bootstrap.js -->
<script src="../vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
......
......@@ -170,10 +170,11 @@ application_module.controller("ConfigNamespaceController",
$scope.tableViewOperType = '', $scope.item = {};
//查看配置
$scope.retrieveItem = function (item, oldValue) {
$scope.retrieveItem = function (namespace, item, oldValue) {
switchTableViewOperType(TABLE_VIEW_OPER_TYPE.RETRIEVE);
$scope.item = item;
$scope.item.oldValue = oldValue;
toOperationNamespaceName = namespace.namespace.namespaceName;
};
var toDeleteItemId = 0;
......@@ -234,8 +235,8 @@ application_module.controller("ConfigNamespaceController",
toOperationNamespaceName,
$scope.item).then(
function (result) {
toastr.success("[" + cluster.env + "," + cluster.name + "]",
"创建成功");
toastr.success(cluster.env + " , " + $scope.item.key,
"添加成功");
itemModal.modal('hide');
$rootScope.refreshNamespaces(namespace_view_type.TABLE);
}, function (result) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册