forked from apolloconfig/apollo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request apolloconfig#612 from lepdou/openapi-createnamespace
add create namespace open api
- Loading branch information
Showing
20 changed files
with
387 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/dto/OpenAppNamespaceDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.ctrip.framework.apollo.openapi.dto; | ||
|
||
|
||
import com.ctrip.framework.apollo.common.dto.BaseDTO; | ||
|
||
public class OpenAppNamespaceDTO extends BaseDTO { | ||
|
||
private String name; | ||
|
||
private String appId; | ||
|
||
private String format; | ||
|
||
private boolean isPublic; | ||
|
||
private String comment; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getAppId() { | ||
return appId; | ||
} | ||
|
||
public void setAppId(String appId) { | ||
this.appId = appId; | ||
} | ||
|
||
public String getFormat() { | ||
return format; | ||
} | ||
|
||
public void setFormat(String format) { | ||
this.format = format; | ||
} | ||
|
||
public boolean isPublic() { | ||
return isPublic; | ||
} | ||
|
||
public void setPublic(boolean aPublic) { | ||
isPublic = aPublic; | ||
} | ||
|
||
public String getComment() { | ||
return comment; | ||
} | ||
|
||
public void setComment(String comment) { | ||
this.comment = comment; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,9 +20,11 @@ | |
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.Calendar; | ||
import java.util.Collections; | ||
import java.util.Date; | ||
import java.util.GregorianCalendar; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* @author Jason Song([email protected]) | ||
|
@@ -65,17 +67,27 @@ public ConsumerToken getConsumerTokenByAppId(@RequestParam String appId) { | |
|
||
@PreAuthorize(value = "@permissionValidator.isSuperAdmin()") | ||
@RequestMapping(value = "/consumers/{token}/assign-role", method = RequestMethod.POST) | ||
public List<ConsumerRole> assignRoleToConsumer(@PathVariable String token, @RequestBody NamespaceDTO namespace) { | ||
public List<ConsumerRole> assignNamespaceRoleToConsumer(@PathVariable String token, | ||
@RequestParam String type, | ||
@RequestBody NamespaceDTO namespace) { | ||
|
||
String appId = namespace.getAppId(); | ||
String namespaceName = namespace.getNamespaceName(); | ||
|
||
if (StringUtils.isContainEmpty(appId, namespaceName)) { | ||
throw new BadRequestException("Params(AppId、NamespaceName) can not be empty."); | ||
if (StringUtils.isEmpty(appId)) { | ||
throw new BadRequestException("Params(AppId) can not be empty."); | ||
} | ||
|
||
return consumerService.assignNamespaceRoleToConsumer(token, appId, namespaceName); | ||
if (Objects.equals("AppRole", type)) { | ||
return Collections.singletonList(consumerService.assignAppRoleToConsumer(token, appId)); | ||
} else { | ||
if (StringUtils.isEmpty(namespaceName)) { | ||
throw new BadRequestException("Params(NamespaceName) can not be empty."); | ||
} | ||
return consumerService.assignNamespaceRoleToConsumer(token, appId, namespaceName); | ||
} | ||
} | ||
|
||
|
||
|
||
} |
Oops, something went wrong.