use of org.springframework.web.bind.annotation.GetMapping in project free-framework by a601942905git.
the class CodeToolController method generateCodeTool.
@GetMapping(CodeToolControllerMappingURL.CODE_TOOL)
@ResponseBody
public int generateCodeTool() throws Exception {
int count = 0;
GenerateCodeParam generateCodeParam = buildGenerateCodeParam();
DataBase2File dataBase2File = new DataBase2File(generateCodeParam);
try {
dataBase2File.generateFiles();
count = 1;
} catch (IOException e) {
log.error("【CodeToolController中generateCodeTool,IO异常】{}", e);
} catch (ClassNotFoundException e) {
log.error("【CodeToolController中generateCodeTool,ClassNotFoundException异常】{}", e);
} catch (SQLException e) {
log.error("【CodeToolController中generateCodeTool,SQLException异常】{}", e);
}
return count;
}
use of org.springframework.web.bind.annotation.GetMapping in project spring-cloud-gcp by spring-cloud.
the class VisionController method uploadImage.
/**
* This method downloads an image from a URL and sends its contents to the Vision API for label detection.
*
* @param imageUrl the URL of the image
* @return a string with the list of labels and percentage of certainty
* @throws Exception if the Vision API call produces an error
*/
@GetMapping("/vision")
public String uploadImage(String imageUrl) throws Exception {
// Copies the content of the image to memory.
byte[] imageBytes = StreamUtils.copyToByteArray(this.resourceLoader.getResource(imageUrl).getInputStream());
BatchAnnotateImagesResponse responses;
Image image = Image.newBuilder().setContent(ByteString.copyFrom(imageBytes)).build();
// Sets the type of request to label detection, to detect broad sets of categories in an image.
Feature feature = Feature.newBuilder().setType(Feature.Type.LABEL_DETECTION).build();
AnnotateImageRequest request = AnnotateImageRequest.newBuilder().setImage(image).addFeatures(feature).build();
responses = this.imageAnnotatorClient.batchAnnotateImages(Collections.singletonList(request));
StringBuilder responseBuilder = new StringBuilder("<table border=\"1\">");
responseBuilder.append("<tr><th>description</th><th>score</th></tr>");
// We're only expecting one response.
if (responses.getResponsesCount() == 1) {
AnnotateImageResponse response = responses.getResponses(0);
if (response.hasError()) {
throw new Exception(response.getError().getMessage());
}
for (EntityAnnotation annotation : response.getLabelAnnotationsList()) {
responseBuilder.append("<tr><td>").append(annotation.getDescription()).append("</td><td>").append(annotation.getScore()).append("</td></tr>");
}
}
responseBuilder.append("</table>");
responseBuilder.append("<p><img src='" + imageUrl + "'/></p>");
return responseBuilder.toString();
}
use of org.springframework.web.bind.annotation.GetMapping in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceBindingController method getServiceInstanceBinding.
@GetMapping(value = { "/{platformInstanceId}/v2/service_instances/{instanceId}/service_bindings/{bindingId}", "/v2/service_instances/{instanceId}/service_bindings/{bindingId}" })
public ResponseEntity<GetServiceInstanceBindingResponse> getServiceInstanceBinding(@PathVariable Map<String, String> pathVariables, @PathVariable(INSTANCE_ID_PATH_VARIABLE) String serviceInstanceId, @PathVariable(BINDING_ID_PATH_VARIABLE) String bindingId, @RequestHeader(value = API_INFO_LOCATION_HEADER, required = false) String apiInfoLocation, @RequestHeader(value = ORIGINATING_IDENTITY_HEADER, required = false) String originatingIdentityString) {
GetServiceInstanceBindingRequest request = GetServiceInstanceBindingRequest.builder().serviceInstanceId(serviceInstanceId).bindingId(bindingId).platformInstanceId(pathVariables.get(PLATFORM_INSTANCE_ID_VARIABLE)).apiInfoLocation(apiInfoLocation).originatingIdentity(parseOriginatingIdentity(originatingIdentityString)).build();
LOGGER.debug("Getting a service instance binding: request={}", request);
GetServiceInstanceBindingResponse response = serviceInstanceBindingService.getServiceInstanceBinding(request);
LOGGER.debug("Getting a service instance binding succeeded: bindingId={}", bindingId);
return new ResponseEntity<>(response, HttpStatus.OK);
}
use of org.springframework.web.bind.annotation.GetMapping in project fw-cloud-framework by liuweijw.
the class ApiController method findMenuByRole.
/**
* 通过用户名查询用户菜单
*/
@GetMapping("/findMenuByRole/{roleCode}")
public Set<AuthPermission> findMenuByRole(@PathVariable String roleCode) {
Set<AuthPermission> permissions = new HashSet<AuthPermission>();
Set<AuthMenu> menus = menuService.findMenuByRole(roleCode);
if (null == menus || menus.size() == 0)
return permissions;
menus.stream().forEach(r -> {
permissions.add(new AuthPermission(r.getUrl()));
});
return permissions;
}
use of org.springframework.web.bind.annotation.GetMapping in project fw-cloud-framework by liuweijw.
the class CodeController method createCode.
/**
* 创建验证码
*/
@GetMapping(SecurityConstant.DEFAULT_VALIDATE_CODE_URL_PREFIX + "/{randomStr}")
public void createCode(@PathVariable String randomStr, HttpServletRequest request, HttpServletResponse response) throws Exception {
Assert.isBlank(randomStr, "随机码不能为空");
response.setHeader("Cache-Control", "no-store, no-cache");
response.setContentType("image/jpeg");
// 生成文字验证码
String text = producer.createText();
// 生成图片验证码
BufferedImage image = producer.createImage(text);
userService.saveImageCode(randomStr, text);
ServletOutputStream out = response.getOutputStream();
ImageIO.write(image, "JPEG", out);
IOUtils.closeQuietly(out);
}
Aggregations