當前位置: 首頁>>代碼示例>>Java>>正文


Java DeleteMapping類代碼示例

本文整理匯總了Java中org.springframework.web.bind.annotation.DeleteMapping的典型用法代碼示例。如果您正苦於以下問題:Java DeleteMapping類的具體用法?Java DeleteMapping怎麽用?Java DeleteMapping使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DeleteMapping類屬於org.springframework.web.bind.annotation包,在下文中一共展示了DeleteMapping類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: remover

import org.springframework.web.bind.annotation.DeleteMapping; //導入依賴的package包/類
/**
 * Remove um lançamento por ID.
 * 
 * @param id
 * @return ResponseEntity<Response<Lancamento>>
 */
@DeleteMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN')")
public ResponseEntity<Response<String>> remover(@PathVariable("id") Long id) {
	log.info("Removendo lançamento: {}", id);
	Response<String> response = new Response<String>();
	Optional<Lancamento> lancamento = this.lancamentoService.buscarPorId(id);

	if (!lancamento.isPresent()) {
		log.info("Erro ao remover devido ao lançamento ID: {} ser inválido.", id);
		response.getErrors().add("Erro ao remover lançamento. Registro não encontrado para o id " + id);
		return ResponseEntity.badRequest().body(response);
	}

	this.lancamentoService.remover(id);
	return ResponseEntity.ok(new Response<String>());
}
 
開發者ID:m4rciosouza,項目名稱:ponto-inteligente-api,代碼行數:23,代碼來源:LancamentoController.java

示例2: deleteUser

import org.springframework.web.bind.annotation.DeleteMapping; //導入依賴的package包/類
@DeleteMapping("/users/{id}")
public void deleteUser(@PathVariable int id) {
	User user = service.deleteById(id);
	
	if(user==null)
		throw new UserNotFoundException("id-"+ id);		
}
 
開發者ID:in28minutes,項目名稱:spring-web-services,代碼行數:8,代碼來源:UserResource.java

示例3: deleteFile

import org.springframework.web.bind.annotation.DeleteMapping; //導入依賴的package包/類
/**
   * 刪除文件
   * @param id
   * @return
   */
  @DeleteMapping("/{id}")
  @ResponseBody
  public ResponseEntity<String> deleteFile(@PathVariable String id) {
 
  	try {
	fileService.removeFile(id);
	return ResponseEntity.status(HttpStatus.OK).body("DELETE Success!");
} catch (Exception e) {
	return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
}
  }
 
開發者ID:waylau,項目名稱:mongodb-file-server,代碼行數:17,代碼來源:FileController.java

示例4: deleteUser

import org.springframework.web.bind.annotation.DeleteMapping; //導入依賴的package包/類
/**
 * DELETE /users/:userKey : delete the "userKey" User.
 *
 * @param userKey the user key of the user to delete
 * @return the ResponseEntity with status 200 (OK)
 */
@DeleteMapping("/users/{userKey}")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<Void> deleteUser(@PathVariable String userKey) {
    userService.deleteUser(userKey);
    return ResponseEntity.ok().headers(HeaderUtil.createAlert("userManagement.deleted", userKey)).build();
}
 
開發者ID:xm-online,項目名稱:xm-uaa,代碼行數:14,代碼來源:UserResource.java

示例5: findMappingAnnotation

import org.springframework.web.bind.annotation.DeleteMapping; //導入依賴的package包/類
Annotation findMappingAnnotation(AnnotatedElement element) {
  Annotation mappingAnnotation = element.getAnnotation(RequestMapping.class);

  if (mappingAnnotation == null) {
    mappingAnnotation = element.getAnnotation(GetMapping.class);

    if (mappingAnnotation == null) {
      mappingAnnotation = element.getAnnotation(PostMapping.class);

      if (mappingAnnotation == null) {
        mappingAnnotation = element.getAnnotation(PutMapping.class);

        if (mappingAnnotation == null) {
          mappingAnnotation = element.getAnnotation(DeleteMapping.class);

          if (mappingAnnotation == null) {
            mappingAnnotation = element.getAnnotation(PatchMapping.class);
          }
        }
      }
    }
  }

  if (mappingAnnotation == null) {
    if (element instanceof Method) {
      Method method = (Method) element;
      mappingAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
    } else {
      Class<?> clazz = (Class<?>) element;
      mappingAnnotation = AnnotationUtils.findAnnotation(clazz, RequestMapping.class);
    }
  }

  return mappingAnnotation;
}
 
開發者ID:mental-party,項目名稱:meparty,代碼行數:36,代碼來源:RestApiProxyInvocationHandler.java

示例6: canProcess

import org.springframework.web.bind.annotation.DeleteMapping; //導入依賴的package包/類
@Override
public boolean canProcess(Method method) {
  return method.getAnnotation(RequestMapping.class) != null ||
      method.getAnnotation(GetMapping.class) != null ||
      method.getAnnotation(PutMapping.class) != null ||
      method.getAnnotation(PostMapping.class) != null ||
      method.getAnnotation(PatchMapping.class) != null ||
      method.getAnnotation(DeleteMapping.class) != null;
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:10,代碼來源:SpringmvcSwaggerGeneratorContext.java

示例7: usingDeleteMapping

import org.springframework.web.bind.annotation.DeleteMapping; //導入依賴的package包/類
@DeleteMapping(
    path = "usingDeleteMapping/{targetName}",
    consumes = {"text/plain", "application/*"},
    produces = {"text/plain", "application/*"})
public String usingDeleteMapping(@RequestBody User srcUser, @RequestHeader String header,
    @PathVariable String targetName, @RequestParam(name = "word") String word, @RequestAttribute String form) {
  return String.format("%s %s %s %s %s", srcUser.name, header, targetName, word, form);
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:9,代碼來源:MethodMixupAnnotations.java

示例8: deleteBook

import org.springframework.web.bind.annotation.DeleteMapping; //導入依賴的package包/類
@DeleteMapping("/books/{ISBN}")
public ResponseEntity<Book> deleteBook(@PathVariable long ISBN) {

	Book book = bookDAO.getBook(ISBN);
	
	if (book == null) {
		return new ResponseEntity<Book>(HttpStatus.NOT_FOUND);
	}
	boolean deleted = bookDAO.deleteBook(ISBN);
	return new ResponseEntity(book, HttpStatus.OK);
}
 
開發者ID:PacktPublishing,項目名稱:Learning-Spring-5.0,代碼行數:12,代碼來源:MyBookController.java

示例9: removeAccount

import org.springframework.web.bind.annotation.DeleteMapping; //導入依賴的package包/類
@PreAuthorize("isFullyAuthenticated()")
@DeleteMapping("/api/account/remove")
public ResponseEntity<GeneralController.RestMsg> removeAccount(Principal principal){
    boolean isDeleted = accountService.removeAuthenticatedAccount();
    if ( isDeleted ) {
        return new ResponseEntity<>(
                new GeneralController.RestMsg(String.format("[%s] removed.", principal.getName())),
                HttpStatus.OK
        );
    } else {
        return new ResponseEntity<GeneralController.RestMsg>(
                new GeneralController.RestMsg(String.format("An error ocurred while delete [%s]", principal.getName())),
                HttpStatus.BAD_REQUEST
        );
    }
}
 
開發者ID:tinmegali,項目名稱:Using-Spring-Oauth2-to-secure-REST,代碼行數:17,代碼來源:AccountController.java

示例10: delete

import org.springframework.web.bind.annotation.DeleteMapping; //導入依賴的package包/類
@DeleteMapping("")
public RestResult<Boolean> delete(@RequestParam("job_name") String jobName,
		@RequestParam("job_group_name") String jobGroupName) throws SchedulerException {
	jobService.delete(jobName, jobGroupName);

	return new RestResult<>(true);
}
 
開發者ID:easynet-cn,項目名稱:easynetcn-cloud,代碼行數:8,代碼來源:JobServiceController.java

示例11: deleteVote

import org.springframework.web.bind.annotation.DeleteMapping; //導入依賴的package包/類
/**
 * DELETE  /votes/:id : delete the "id" vote.
 *
 * @param id the id of the vote to delete
 * @return the ResponseEntity with status 200 (OK)
 */
@DeleteMapping("/votes/{id}")
@Timed
public ResponseEntity<Void> deleteVote(@PathVariable Long id) {
    log.debug("REST request to delete Vote : {}", id);
    voteRepository.delete(id);
    voteSearchRepository.delete(id);
    return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
}
 
開發者ID:xm-online,項目名稱:xm-ms-entity,代碼行數:15,代碼來源:VoteResource.java

示例12: delete

import org.springframework.web.bind.annotation.DeleteMapping; //導入依賴的package包/類
@DeleteMapping(value = "/{username}")
@PreAuthorize("hasRole('ROLE_ADMIN')")
@ApiOperation(value = "${UserController.delete}")
@ApiResponses(value = {//
    @ApiResponse(code = 400, message = "Something went wrong"), //
    @ApiResponse(code = 403, message = "Access denied"), //
    @ApiResponse(code = 404, message = "The user doesn't exist"), //
    @ApiResponse(code = 500, message = "Expired or invalid JWT token")})
public String delete(@ApiParam("Username") @PathVariable String username) {
  userService.delete(username);
  return username;
}
 
開發者ID:murraco,項目名稱:spring-boot-jwt,代碼行數:13,代碼來源:UserController.java

示例13: deleteUser

import org.springframework.web.bind.annotation.DeleteMapping; //導入依賴的package包/類
@DeleteMapping(value = "/{id}")
public ResponseEntity<User> deleteUser(@PathVariable("id") long id) {
	logger.info("Deleting User with id : {}", id);

	Optional<User> optionalUser = userService.findById(id);
	if (optionalUser.isPresent()) {
		userService.deleteUserById(id);
		return ResponseEntity.noContent().build();
	}
	else {
		logger.info("User with id: {} not found", id);
		return ResponseEntity.notFound().build();
	}

}
 
開發者ID:gauravrmazra,項目名稱:gauravbytes,代碼行數:16,代碼來源:UserController.java

示例14: deleteSelfLinkTarget

import org.springframework.web.bind.annotation.DeleteMapping; //導入依賴的package包/類
@DeleteMapping("/xm-entities/self/links/targets/{targetId}")
@Timed
public ResponseEntity<Void> deleteSelfLinkTarget(@PathVariable String targetId) {
    log.debug("REST request to delete link target {} for self", targetId);
    xmEntityService.deleteSelfLinkTarget(targetId);
    return ResponseEntity.ok().build();
}
 
開發者ID:xm-online,項目名稱:xm-ms-entity,代碼行數:8,代碼來源:XmEntityResource.java

示例15: deleteStock

import org.springframework.web.bind.annotation.DeleteMapping; //導入依賴的package包/類
/**
 * Delete relation between {@link by.kraskovski.pms.domain.model.Stock} and {@link Store}
 */
@DeleteMapping("/stock-manage")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteStock(@RequestParam final String storeId,
                        @RequestParam final String stockId) {
    log.info("Start delete stock: {} from store: {}", stockId, storeId);
    storeService.deleteStock(storeId, stockId);
}
 
開發者ID:akraskovski,項目名稱:product-management-system,代碼行數:11,代碼來源:StoreController.java


注:本文中的org.springframework.web.bind.annotation.DeleteMapping類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。