Search in sources :

Example 76 with GetMapping

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;
}
Also used : DataBase2File(com.free.framework.code.tools.DataBase2File) SQLException(java.sql.SQLException) GenerateCodeParam(com.free.framework.code.tools.param.GenerateCodeParam) IOException(java.io.IOException) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 77 with GetMapping

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();
}
Also used : AnnotateImageRequest(com.google.cloud.vision.v1.AnnotateImageRequest) AnnotateImageResponse(com.google.cloud.vision.v1.AnnotateImageResponse) Image(com.google.cloud.vision.v1.Image) EntityAnnotation(com.google.cloud.vision.v1.EntityAnnotation) Feature(com.google.cloud.vision.v1.Feature) BatchAnnotateImagesResponse(com.google.cloud.vision.v1.BatchAnnotateImagesResponse) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 78 with GetMapping

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) GetServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingRequest) GetServiceInstanceBindingResponse(org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingResponse) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 79 with GetMapping

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;
}
Also used : AuthMenu(com.github.liuweijw.core.beans.system.AuthMenu) AuthPermission(com.github.liuweijw.core.beans.system.AuthPermission) HashSet(java.util.HashSet) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 80 with GetMapping

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);
}
Also used : ServletOutputStream(javax.servlet.ServletOutputStream) BufferedImage(java.awt.image.BufferedImage) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

GetMapping (org.springframework.web.bind.annotation.GetMapping)756 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)114 ResponseEntity (org.springframework.http.ResponseEntity)80 ArrayList (java.util.ArrayList)52 List (java.util.List)49 ModelAndView (org.springframework.web.servlet.ModelAndView)48 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)45 HttpHeaders (org.springframework.http.HttpHeaders)41 Map (java.util.Map)40 HashMap (java.util.HashMap)38 lombok.val (lombok.val)38 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)36 Grid (org.hisp.dhis.common.Grid)35 IOException (java.io.IOException)34 RequestParam (org.springframework.web.bind.annotation.RequestParam)34 ApiOperation (io.swagger.annotations.ApiOperation)31 RootNode (org.hisp.dhis.node.types.RootNode)31 PathVariable (org.springframework.web.bind.annotation.PathVariable)31 HttpServletRequest (javax.servlet.http.HttpServletRequest)30 FieldFilterParams (org.hisp.dhis.fieldfilter.FieldFilterParams)28