下面列出了怎么用org.hibernate.validator.constraints.Range的API类实例代码及写法,或者点击链接到github查看源代码。
@ApiOperation(value = "Get the list of existing brokers, support paging, the default is 10 per page")
@ApiResponses({
@ApiResponse(code = 200, message = "ok"),
@ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/brokers/{cluster}", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getBrokers(
@ApiParam(value = "page_num", defaultValue = "1", example = "1")
@RequestParam(name = "page_num", defaultValue = "1")
@Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
Integer pageNum,
@ApiParam(value = "page_size", defaultValue = "10", example = "10")
@RequestParam(name="page_size", defaultValue = "10")
@Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
Integer pageSize,
@PathVariable String cluster) {
String requestServiceUrl = environmentCacheService.getServiceUrl(request, cluster);
Map<String, Object> result = brokersService.getBrokersList(pageNum, pageSize, cluster, requestServiceUrl);
return ResponseEntity.ok(result);
}
@ApiOperation(value = "Query list by the name of tenant or namespace, support paging, the default is 10 per page")
@ApiResponses({
@ApiResponse(code = 200, message = "ok"),
@ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/namespaces/{tenantOrNamespace}", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getNamespacesByTenant(
@ApiParam(value = "The name of tenant or namespace.")
@Size(min = 1, max = 255)
@PathVariable String tenantOrNamespace,
@ApiParam(value = "page_num", defaultValue = "1", example = "1")
@RequestParam(name = "page_num", defaultValue = "1")
@Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
Integer pageNum,
@ApiParam(value = "page_size", defaultValue = "10", example = "10")
@RequestParam(name="page_size", defaultValue = "10")
@Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
Integer pageSize) {
String requestHost = environmentCacheService.getServiceUrl(request);
Map<String, Object> result = namespacesService.getNamespaceList(pageNum, pageSize, tenantOrNamespace, requestHost);
return ResponseEntity.ok(result);
}
@ApiOperation(value = "Get users list")
@ApiResponses({
@ApiResponse(code = 200, message = "ok"),
@ApiResponse(code = 404, message = "Not found"),
@ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/users", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getUsers(
@ApiParam(value = "page_num", defaultValue = "1", example = "1")
@RequestParam(name = "page_num", defaultValue = "1")
@Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
Integer pageNum,
@ApiParam(value = "page_size", defaultValue = "10", example = "10")
@RequestParam(name = "page_size", defaultValue = "10")
@Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
Integer pageSize) {
Page<UserInfoEntity> userInfoEntities = usersRepository.findUsersList(pageNum, pageSize);
Map<String, Object> result = Maps.newHashMap();
result.put("total", userInfoEntities.getTotal());
result.put("data", userInfoEntities.getResult());
return ResponseEntity.ok(result);
}
@ApiOperation(value = "Query topic info by tenant and namespace")
@ApiResponses({
@ApiResponse(code = 200, message = "ok"),
@ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/topics/{tenant}/{namespace}", method = RequestMethod.GET)
public Map<String, Object> getTopicsByTenantNamespace(
@ApiParam(value = "page_num", defaultValue = "1", example = "1")
@RequestParam(name = "page_num", defaultValue = "1")
@Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
Integer pageNum,
@ApiParam(value = "page_size", defaultValue = "10", example = "10")
@RequestParam(name="page_size", defaultValue = "10")
@Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
Integer pageSize,
@ApiParam(value = "The name of tenant")
@Size(min = 1, max = 255)
@PathVariable String tenant,
@ApiParam(value = "The name of namespace")
@Size(min = 1, max = 255)
@PathVariable String namespace) {
String requestHost = environmentCacheService.getServiceUrl(request);
return topicsService.getTopicsList(pageNum, pageSize, tenant, namespace, requestHost);
}
@ApiOperation(value = "Get the list of existing bookies, support paging, the default is 10 per page")
@ApiResponses({
@ApiResponse(code = 200, message = "ok"),
@ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/bookies/{cluster}", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getClusters(
@ApiParam(value = "page_num", defaultValue = "1", example = "1")
@RequestParam(name = "page_num", defaultValue = "1")
@Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
Integer pageNum,
@ApiParam(value = "page_size", defaultValue = "10", example = "10")
@RequestParam(name="page_size", defaultValue = "10")
@Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
Integer pageSize,
@PathVariable String cluster) {
Map<String, Object> result = bookiesService.getBookiesList(pageNum, pageSize, cluster);
return ResponseEntity.ok(result);
}
@ApiOperation(value = "Get the list of existing broker tokens, support paging, the default is 10 per page")
@ApiResponses({
@ApiResponse(code = 200, message = "ok"),
@ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/tokens", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getEnvironmentsList(
@ApiParam(value = "page_num", defaultValue = "1", example = "1")
@RequestParam(name = "page_num", defaultValue = "1")
@Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
Integer pageNum,
@ApiParam(value = "page_size", defaultValue = "10", example = "10")
@RequestParam(name="page_size", defaultValue = "10")
@Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
Integer pageSize) {
Page<BrokerTokenEntity> brokerTokenEntityPage = brokerTokensRepository.getBrokerTokensList(pageNum, pageSize);
Map<String, Object> result = Maps.newHashMap();
result.put("total", brokerTokenEntityPage.getTotal());
result.put("data", brokerTokenEntityPage);
return ResponseEntity.ok(result);
}
@GetMapping("/create-homeworld")
public String createHomeworld(@RequestParam @Range(min = 1, max = 5) int galaxy,
@RequestParam @Range(min = 1, max = 500) int system,
Model model) {
model.addAttribute("galaxy", galaxy);
model.addAttribute("system", system);
model.addAttribute("slots", galaxyService.getSlots(galaxy, system));
return "create-homeworld";
}
@PostMapping("/body-settings/change-image")
@PreAuthorize("hasPermission(#bodyId, 'ACCESS')")
@Activity(bodies = "#bodyId")
public String doChangeImage(@RequestParam(name = "body") long bodyId,
@RequestParam @Range(min = 1, max = 10) int image) {
bodyService.setImage(bodyId, image);
return "redirect:/overview?body=" + bodyId;
}
@ApiOperation(value = "Get the list of existing roles, support paging, the default is 10 per page")
@ApiResponses({
@ApiResponse(code = 200, message = "ok"),
@ApiResponse(code = 404, message = "Not found"),
@ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/roles", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getRoles(
@ApiParam(value = "page_num", defaultValue = "1", example = "1")
@RequestParam(name = "page_num", defaultValue = "1")
@Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
Integer pageNum,
@ApiParam(value = "page_size", defaultValue = "10", example = "10")
@RequestParam(name = "page_size", defaultValue = "10")
@Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
Integer pageSize) {
String token = request.getHeader("token");
Map<String, Object> result = Maps.newHashMap();
String tenant = request.getHeader("tenant");
if (rolesService.isSuperUser(token)) {
List<RoleInfoEntity> roleInfoEntities = rolesRepository.findAllRolesList();
result.put("total", roleInfoEntities.size());
result.put("data", roleInfoEntities);
return ResponseEntity.ok(result);
}
Map<String, String> validateResult = rolesService.validateCurrentTenant(token, tenant);
if (validateResult.get("error") != null) {
result.put("error", validateResult.get("error"));
return ResponseEntity.ok(result);
}
List<RoleInfoEntity> roleInfoLists = rolesRepository.findRolesListByRoleSource(tenant);
result.put("total", roleInfoLists.size());
result.put("data", roleInfoLists);
return ResponseEntity.ok(result);
}
@ApiOperation(value = "Get the list of role binding")
@ApiResponses({
@ApiResponse(code = 200, message = "ok"),
@ApiResponse(code = 404, message = "Not found"),
@ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/role-binding", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getRoleBingList(
@ApiParam(value = "page_num", defaultValue = "1", example = "1")
@RequestParam(name = "page_num", defaultValue = "1")
@Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
Integer pageNum,
@ApiParam(value = "page_size", defaultValue = "10", example = "10")
@RequestParam(name="page_size", defaultValue = "10")
@Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
Integer pageSize) {
Map<String, Object> result = Maps.newHashMap();
HttpServletRequest request = ((ServletRequestAttributes)
RequestContextHolder.getRequestAttributes()).getRequest();
String token = request.getHeader("token");
String tenant = request.getHeader("tenant");
if (rolesService.isSuperUser(token)) {
List<Map<String, Object>> roleBindingList = roleBindingService.getAllRoleBindingList();
result.put("total", roleBindingList.size());
result.put("data", roleBindingList);
return ResponseEntity.ok(result);
}
Map<String, String> validateResult = rolesService.validateCurrentTenant(token, tenant);
if (validateResult.get("error") != null) {
result.put("error", validateResult.get("error"));
return ResponseEntity.ok(result);
}
List<Map<String, Object>> userRoleInfo = roleBindingService.getRoleBindingList(token, tenant);
result.put("total", userRoleInfo.size());
result.put("data", userRoleInfo);
return ResponseEntity.ok(result);
}
@ApiOperation(value = "Query topic stats info by tenant and namespace")
@ApiResponses({
@ApiResponse(code = 200, message = "ok"),
@ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/topics/{tenant}/{namespace}/stats", method = RequestMethod.GET)
public Map<String, Object> getTopicsStats(
@ApiParam(value = "page_num", defaultValue = "1", example = "1")
@RequestParam(name = "page_num", defaultValue = "1")
@Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
Integer pageNum,
@ApiParam(value = "page_size", defaultValue = "10", example = "10")
@RequestParam(name="page_size", defaultValue = "10")
@Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
Integer pageSize,
@ApiParam(value = "The name of tenant")
@Size(min = 1, max = 255)
@PathVariable String tenant,
@ApiParam(value = "The name of namespace")
@Size(min = 1, max = 255)
@PathVariable String namespace) {
String env = request.getHeader("environment");
String serviceUrl = environmentCacheService.getServiceUrl(request);
return topicsService.getTopicStats(
pageNum, pageSize,
tenant, namespace,
env, serviceUrl);
}
@ApiOperation(value = "Get the list of existing clusters, support paging, the default is 10 per page")
@ApiResponses({
@ApiResponse(code = 200, message = "ok"),
@ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/clusters", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getClusters(
@ApiParam(value = "page_num", defaultValue = "1", example = "1")
@RequestParam(name = "page_num", defaultValue = "1")
@Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
Integer pageNum,
@ApiParam(value = "page_size", defaultValue = "10", example = "10")
@RequestParam(name="page_size", defaultValue = "10")
@Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
Integer pageSize) {
String requestHost = environmentCacheService.getServiceUrl(request);
String token = request.getHeader("token");
Map<String, Object> result = Maps.newHashMap();
if (!rolesService.isSuperUser(token)) {
result.put("isPage", false);
result.put("total", 0);
result.put("data", new ArrayList());
result.put("pageNum", 0);
result.put("pageSize", 0);
return ResponseEntity.ok(result);
}
result = clusterService.getClustersList(
pageNum, pageSize, requestHost, cluster -> {
String environment = request.getHeader("environment");
if (null == environment) {
return requestHost;
} else {
return environmentCacheService.getServiceUrl(environment, cluster);
}
});
return ResponseEntity.ok(result);
}
@Range(min = 0, max = 2)
public int getQos() {
return this.qos;
}
@Override
protected Class<Range> getAnnotationType() {
return Range.class;
}
@Range(min = 0, max = 255)
public Integer getMaxPriority() {
return this.maxPriority;
}
@Range(min = 0, max = 65535)
public int getPort() {
return this.port;
}
@Range(min = 0, max = 65535)
public int getPort() {
return this.port;
}
@Range(min = 0, max = 65535)
public int getPort() {
return this.port;
}
@NotNull
@Range(min = 1, max = 1)
Integer getSchema_version();
/**
* During autoconfiguration for RM, the share dictates the percentage of the
* role's overall memory allotment that should be set aside for this memory
* quantity.
* <p>
* If null, parameter is not autoconfigured for RM.
*/
@Range(min = 0, max = 100)
Integer getAutoConfigShare();