Commit 2ca490a1 by lepdou

update

parent 6cd90c16
......@@ -2,6 +2,7 @@ package com.ctrip.framework.apollo.portal.controller;
import com.ctrip.framework.apollo.core.dto.ClusterDTO;
import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.auth.UserInfoHolder;
import com.ctrip.framework.apollo.portal.service.ClusterService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -13,20 +14,28 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import static com.ctrip.framework.apollo.common.utils.RequestPrecondition.checkArgument;
import static com.ctrip.framework.apollo.common.utils.RequestPrecondition.checkModel;
@RestController
public class ClusterController {
@Autowired
private ClusterService clusterService;
@Autowired
private UserInfoHolder userInfoHolder;
@PreAuthorize(value = "@permissionValidator.hasCreateClusterPermission(#appId)")
@RequestMapping(value = "apps/{appId}/envs/{env}/clusters", method = RequestMethod.POST)
public ClusterDTO createCluster(@PathVariable String appId, @PathVariable String env,
@RequestBody ClusterDTO cluster){
checkModel(cluster != null);
checkArgument(cluster.getAppId(), cluster.getName());
String operator = userInfoHolder.getUser().getUserId();
cluster.setDataChangeLastModifiedBy(operator);
cluster.setDataChangeCreatedBy(operator);
return clusterService.createCluster(Env.valueOf(env), cluster);
}
......
......@@ -3,7 +3,6 @@ package com.ctrip.framework.apollo.portal.service;
import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.core.dto.ClusterDTO;
import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
import com.ctrip.framework.apollo.portal.auth.UserInfoHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -14,8 +13,6 @@ import java.util.List;
public class ClusterService {
@Autowired
private UserInfoHolder userInfoHolder;
@Autowired
private AdminServiceAPI.ClusterAPI clusterAPI;
public List<ClusterDTO> findClusters(Env env, String appId){
......@@ -23,9 +20,6 @@ public class ClusterService {
}
public ClusterDTO createCluster(Env env, ClusterDTO cluster){
String operator = userInfoHolder.getUser().getUserId();
cluster.setDataChangeLastModifiedBy(operator);
cluster.setDataChangeCreatedBy(operator);
return clusterAPI.createOrUpdate(env, cluster);
}
......
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