org.springframework.web.bind.annotation.DeleteMapping Java Examples

The following examples show how to use org.springframework.web.bind.annotation.DeleteMapping. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OSSFileController.java    From jeecg-cloud with Apache License 2.0 8 votes vote down vote up
@ResponseBody
@DeleteMapping("/delete")
public Result delete(@RequestParam(name = "id") String id) {
	Result result = new Result();
	OSSFile file = ossFileService.getById(id);
	if (file == null) {
		result.error500("未找到对应实体");
	}
	else {
		boolean ok = ossFileService.delete(file);
		if (ok) {
			result.success("删除成功!");
		}
	}
	return result;
}
 
Example #2
Source File: UsersController.java    From studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Delete users API
 *
 * @param userIds List of user identifiers
 * @param usernames List of usernames
 * @return Response object
 */
@DeleteMapping()
public ResponseBody deleteUser(
        @RequestParam(value = REQUEST_PARAM_ID, required = false) List<Long> userIds,
        @RequestParam(value = REQUEST_PARAM_USERNAME, required = false) List<String> usernames)
        throws ServiceLayerException, AuthenticationException, UserNotFoundException {
    ValidationUtils.validateAnyListNonEmpty(userIds, usernames);

    userService.deleteUsers(userIds != null? userIds : Collections.emptyList(),
                            usernames != null? usernames : Collections.emptyList());

    ResponseBody responseBody = new ResponseBody();
    Result result = new Result();
    result.setResponse(DELETED);
    responseBody.setResult(result);
    return responseBody;
}
 
Example #3
Source File: AuthorityRuleController.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
@DeleteMapping("/rule/{id}")
@AuthAction(PrivilegeType.DELETE_RULE)
public Result<Long> apiDeleteRule(@PathVariable("id") Long id) {
    if (id == null) {
        return Result.ofFail(-1, "id cannot be null");
    }
    AuthorityRuleEntity oldEntity = repository.findById(id);
    if (oldEntity == null) {
        return Result.ofSuccess(null);
    }
    try {
        repository.delete(id);
    } catch (Exception e) {
        return Result.ofFail(-1, e.getMessage());
    }
    if (!publishRules(oldEntity.getApp(), oldEntity.getIp(), oldEntity.getPort())) {
        logger.error("Publish authority rules failed after rule delete");
    }
    return Result.ofSuccess(id);
}
 
Example #4
Source File: SysPermissionController.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
/**
 * 删除权限标识
 * 参考 /permissions/1
 * @param id
 */
@PreAuthorize("hasAuthority('permission:delete/permissions/{id}')")
@ApiOperation(value = "后台管理删除权限标识")
@DeleteMapping("/permissions/{id}")
@LogAnnotation(module="user-center",recordRequestParam=false)
public Result delete(@PathVariable Long id) {

	try{
		sysPermissionService.delete(id);
		return  Result.succeed("操作成功");
	}catch (Exception ex){
		ex.printStackTrace();
		return  Result.failed("操作失败");
	}

}
 
Example #5
Source File: TodoJpaResource.java    From docker-crash-course with MIT License 6 votes vote down vote up
@DeleteMapping("/jpa/users/{username}/todos/{id}")
public ResponseEntity<Void> deleteTodo(
		@PathVariable String username, @PathVariable long id) {

	todoJpaRepository.deleteById(id);

	return ResponseEntity.noContent().build();
}
 
Example #6
Source File: TaskCommentController.java    From taskana with Apache License 2.0 6 votes vote down vote up
@DeleteMapping(path = Mapping.URL_TASK_COMMENT)
@Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<TaskCommentRepresentationModel> deleteTaskComment(
    @PathVariable String taskCommentId)
    throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
        InvalidArgumentException {
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("Entry to deleteTaskComment(taskCommentId= {})", taskCommentId);
  }

  taskService.deleteTaskComment(taskCommentId);

  ResponseEntity<TaskCommentRepresentationModel> result = ResponseEntity.noContent().build();

  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("Exit from deleteTaskComment(), returning {}", result);
  }

  return result;
}
 
Example #7
Source File: ProcessDefinitionIdentityLinkResource.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Delete a candidate starter from a process definition", tags = { "Process Definitions" })
@ApiResponses(value = {
        @ApiResponse(code = 204, message = "Indicates the process definition was found and the identity link was removed. The response body is intentionally empty."),
        @ApiResponse(code = 404, message = "Indicates the requested process definition was not found or the process definition does not have an identity-link that matches the url.")
})
@DeleteMapping(value = "/repository/process-definitions/{processDefinitionId}/identitylinks/{family}/{identityId}")
public void deleteIdentityLink(@ApiParam(name = "processDefinitionId") @PathVariable("processDefinitionId") String processDefinitionId,
        @ApiParam(name = "family") @PathVariable("family") String family, @ApiParam(name = "identityId") @PathVariable("identityId") String identityId,
        HttpServletResponse response) {

    ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);

    validateIdentityLinkArguments(family, identityId);

    // Check if identitylink to delete exists
    IdentityLink link = getIdentityLink(family, identityId, processDefinition.getId());
    if (link.getUserId() != null) {
        repositoryService.deleteCandidateStarterUser(processDefinition.getId(), link.getUserId());
    } else {
        repositoryService.deleteCandidateStarterGroup(processDefinition.getId(), link.getGroupId());
    }

    response.setStatus(HttpStatus.NO_CONTENT.value());
}
 
Example #8
Source File: JobResource.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Delete a deadletter job", tags = { "Jobs" })
@ApiResponses(value = {
        @ApiResponse(code = 204, message = "Indicates the job was found and has been deleted. Response-body is intentionally empty."),
        @ApiResponse(code = 404, message = "Indicates the requested job was not found.")
})
@DeleteMapping("/cmmn-management/deadletter-jobs/{jobId}")
public void deleteDeadLetterJob(@ApiParam(name = "jobId") @PathVariable String jobId, HttpServletResponse response) {
    Job job = getDeadLetterJobById(jobId);
    try {
        managementService.deleteDeadLetterJob(job.getId());
    } catch (FlowableObjectNotFoundException aonfe) {
        // Re-throw to have consistent error-messaging across REST-api
        throw new FlowableObjectNotFoundException("Could not find a job with id '" + jobId + "'.", Job.class);
    }
    response.setStatus(HttpStatus.NO_CONTENT.value());
}
 
Example #9
Source File: WindowRestController.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 6 votes vote down vote up
@DeleteMapping("/{windowId}")
public List<JSONDocument> deleteRootDocumentsList(
		@PathVariable("windowId") final String windowIdStr //
		, @RequestParam(name = "ids") @ApiParam("comma separated documentIds") final String idsListStr //
)
{
	final WindowId windowId = WindowId.fromJson(windowIdStr);
	final List<DocumentPath> documentPaths = DocumentPath.rootDocumentPathsList(windowId, idsListStr);
	if (documentPaths.isEmpty())
	{
		throw new IllegalArgumentException("No ids provided");
	}

	return deleteDocuments(documentPaths);
}
 
Example #10
Source File: FormDeploymentResource.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Delete a form deployment", tags = { "Form Deployments" })
@ApiResponses(value = {
        @ApiResponse(code = 204, message = "Indicates the form deployment was found and has been deleted. Response-body is intentionally empty."),
        @ApiResponse(code = 404, message = "Indicates the requested form deployment was not found.")
})
@DeleteMapping(value = "/form-repository/deployments/{deploymentId}", produces = "application/json")
public void deleteFormDeployment(@ApiParam(name = "deploymentId") @PathVariable String deploymentId, HttpServletResponse response) {
    FormDeployment deployment = formRepositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();

    if (deployment == null) {
        throw new FlowableObjectNotFoundException("Could not find a Form deployment with id '" + deploymentId);
    }
    
    if (restApiInterceptor != null) {
        restApiInterceptor.deleteDeployment(deployment);
    }
    
    formRepositoryService.deleteDeployment(deploymentId);
    response.setStatus(HttpStatus.NO_CONTENT.value());
}
 
Example #11
Source File: SecretsController.java    From guardedbox with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Deletes a secret. It must belong to the current session account.
 *
 * @param secretId ID of the secret to be deleted.
 * @return Object with the deleted secret data.
 */
@DeleteMapping("/{secret-id}")
public SecretDto deleteSecret(
        @PathVariable(name = "secret-id", required = true) @NotNull UUID secretId) {

    return secretsService.deleteSecret(sessionAccount.getAccountId(), secretId);

}
 
Example #12
Source File: CompanyController.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
@SysLog("删除公司")
@DeleteMapping("/web/del/{id}")
@ApiOperation("删除公司")
public ApiResponse deleteCompany(@PathVariable String id){
    if (deptService.deleteDept(id)){
        return success("删除成功");
    }else {
        return fail("删除失败");
    }
}
 
Example #13
Source File: OrderApiController.java    From spring-in-action-5-samples with Apache License 2.0 5 votes vote down vote up
@DeleteMapping("/{orderId}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteOrder(@PathVariable("orderId") Long orderId) {
  try {
    repo.deleteById(orderId);
  } catch (EmptyResultDataAccessException e) {}
}
 
Example #14
Source File: NotificationFilterController.java    From Moss with Apache License 2.0 5 votes vote down vote up
@DeleteMapping(path = "/notifications/filters/{id}")
public ResponseEntity<Void> deleteFilter(@PathVariable("id") String id) {
    NotificationFilter deleted = filteringNotifier.removeFilter(id);
    if (deleted != null) {
        return ResponseEntity.ok().build();
    } else {
        return ResponseEntity.notFound().build();
    }
}
 
Example #15
Source File: CatalogController.java    From logging-log4j-audit with Apache License 2.0 5 votes vote down vote up
@ApiImplicitParams( {@ApiImplicitParam(dataType = "String", name = "Authorization", paramType = "header")})
@ApiOperation(value = "Deletes a catalog product", notes = "Deletes a catalog product", tags = {"Catalog"})
@DeleteMapping(value = "/product/{id}")
public ResponseEntity<?> deleteProduct(@RequestParam("id") Long productId) {
    productService.deleteProduct(productId);
    return new ResponseEntity<>(HttpStatus.OK);
}
 
Example #16
Source File: ContactController.java    From production-ready-microservices-starter with MIT License 5 votes vote down vote up
/**
 * Delete contact by id with all tenants and users.
 *
 * @param id the id
 * @return HTTP 204 No Content
 */
@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteContact(@PathVariable String id) {

    contactService.deleteContact(id);
    return new ResponseEntity(HttpStatus.NO_CONTENT);
}
 
Example #17
Source File: ApiLoggerController.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
@SysLog("删除日志")
@DeleteMapping(value = "/web/del/{id}")
@ApiOperation(value = "删除日志管理-后端管理日志管理", notes = "删除日志管理-后端管理日志管理")
public ApiResponse deleteApiLogger(@ApiParam(value = "日志id", required = true) @PathVariable String id) {
    if (StringUtils.isBlank(id)) {
        return fail("id不能为空");
    }
    if (apiLoggerService.deleteApiLogger(id)) {
        return success("删除成功");
    } else {
        return fail("删除失败");
    }
}
 
Example #18
Source File: HistoricProcessInstanceResource.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = " Delete a historic process instance", tags = { "History Process" }, nickname = "deleteHistoricProcessInstance")
@ApiResponses(value = {
        @ApiResponse(code = 204, message = "Indicates that the historic process instance was deleted."),
        @ApiResponse(code = 404, message = "Indicates that the historic process instance could not be found.") })
@DeleteMapping(value = "/history/historic-process-instances/{processInstanceId}")
public void deleteProcessInstance(@ApiParam(name = "processInstanceId") @PathVariable String processInstanceId, HttpServletResponse response) {
    HistoricProcessInstance processInstance = getHistoricProcessInstanceFromRequest(processInstanceId);
    
    if (restApiInterceptor != null) {
        restApiInterceptor.deleteHistoricProcess(processInstance);
    }
    
    historyService.deleteHistoricProcessInstance(processInstanceId);
    response.setStatus(HttpStatus.NO_CONTENT.value());
}
 
Example #19
Source File: TestController.java    From SpringBootLearn with Apache License 2.0 5 votes vote down vote up
/**
 * 删除记录
 * @return
 */
@DeleteMapping("/delete")
public String delete(String id) {
    if (StringUtils.isNotBlank(id)) {
        ElasticsearchUtil.deleteDataById(indexName, esType, id);
        return "删除id=" + id;
    } else {
        return "id为空";
    }
}
 
Example #20
Source File: JeecgDemoController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 批量删除
 *
 * @param ids
 * @return
 */
@DeleteMapping(value = "/deleteBatch")
@ApiOperation(value = "批量删除DEMO", notes = "批量删除DEMO")
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
    this.jeecgDemoService.removeByIds(Arrays.asList(ids.split(",")));
    return Result.ok("批量删除成功!");
}
 
Example #21
Source File: ContractController.java    From WeBASE-Front with Apache License 2.0 5 votes vote down vote up
/**
 * delete by contractId.
 */
@ApiOperation(value = "delete by contractId", notes = "delete by contractId")
@ApiImplicitParams({
        @ApiImplicitParam(name = "groupId", value = "groupId", required = true,
                dataType = "int"),
        @ApiImplicitParam(name = "contractId", value = "contractId", required = true,
                dataType = "Long")})
@DeleteMapping("/{groupId}/{contractId}")
public BaseResponse deleteByContractId(@PathVariable Integer groupId,
        @PathVariable Long contractId) throws FrontException {
    log.info("deleteByContractId start. groupId:{} contractId:{}", groupId, contractId);
    contractService.deleteContract(contractId, groupId);
    return new BaseResponse(ConstantCode.RET_SUCCEED);
}
 
Example #22
Source File: CatalogController.java    From logging-log4j-audit with Apache License 2.0 5 votes vote down vote up
@ApiImplicitParams( {@ApiImplicitParam(dataType = "String", name = "Authorization", paramType = "header")})
@ApiOperation(value = "Deletes a catalog event", notes = "Deletes a catalog event", tags = {"Catalog"})
@DeleteMapping(value = "/event/{id}")
public ResponseEntity<?> deleteEvent(@RequestParam("id") Long eventId) {
    eventService.deleteEvent(eventId);
    return new ResponseEntity<>(HttpStatus.OK);
}
 
Example #23
Source File: ContentSettingsController.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
@ApiOperation(value = "DELETE ContentSettingsCropRatio", nickname = "deleteContentSettingsCropRatio", tags = {"content-settings-controller"})
@ApiResponses(value = {
        @ApiResponse(code = 201, message = "Created"),
        @ApiResponse(code = 401, message = "Unauthorized")})
@DeleteMapping("/plugins/cms/contentSettings/cropRatios/{ratio}")
@RestAccessControl(permission = Permission.SUPERUSER)
public ResponseEntity<SimpleRestResponse<Map>> deleteCropRatio(@PathVariable String ratio) {
    logger.debug("REST request - delete content settings crop ratio: {}", ratio);

    service.removeCropRatio(ratio.trim());
    return ResponseEntity.ok(new SimpleRestResponse<>(new HashMap()));
}
 
Example #24
Source File: FooBarController.java    From tutorials with MIT License 5 votes vote down vote up
@Operation(summary = "Delete a foo")
@ApiResponses(value = {
        @ApiResponse(responseCode = "204", description = "foo deleted"),
        @ApiResponse(responseCode = "404", description = "Bad request", content = @Content) })
@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteFoo(@Parameter(description = "id of foo to be deleted") @PathVariable("id") long id) {
    try {
        repository.deleteById(id);
    } catch (Exception e) {
        return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
    }
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
 
Example #25
Source File: CacheResource.java    From heimdall with Apache License 2.0 5 votes vote down vote up
/**
 * Deletes a cache by its key and Id.
 * 
 * @param cacheKey				The cache key
 * @param cacheId				The cache Id
 * @return						{@link ResponseEntity}
 */
@ResponseBody
@ApiOperation(value = "Delete Cache")
@DeleteMapping(value = "/{cacheKey}/{cacheId}")
@PreAuthorize(ConstantsPrivilege.PRIVILEGE_DELETE_CACHES)
public ResponseEntity<?> delete(@PathVariable("cacheKey") String cacheKey, @PathVariable("cacheId") String cacheId) {
     
     amqpCacheService.dispatchClean(cacheKey, cacheId);
     
     return ResponseEntity.noContent().build();
}
 
Example #26
Source File: CountryLanguageAPIController.java    From Spring-5.0-Projects with MIT License 5 votes vote down vote up
@DeleteMapping("/{countryCode}/language/{language}")
public ResponseEntity<?> deleteLanguage(@PathVariable String countryCode, 
		@PathVariable String language){
	try {
		cLanguageDao.deleteLanguage(countryCode, language);;
		return ResponseEntity.ok().build();
	}catch(Exception ex) {
		System.out.println("Error occurred while deleting language : {}, for country: {}"+ 
				language+ countryCode+ ex);
		return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
			.body("Error occurred while deleting the language");
	}
}
 
Example #27
Source File: DefaultEndPointPlugin.java    From BlogManagePlatform with Apache License 2.0 5 votes vote down vote up
private String resolveApiName(OperationContext context) {
	Api api = context.findControllerAnnotation(Api.class).orNull();
	if (api != null) {
		return api.tags()[0];
	}
	GetMapping getMapping = context.findControllerAnnotation(GetMapping.class).orNull();
	if (getMapping != null) {
		return getMapping.name();
	}
	PostMapping postMapping = context.findControllerAnnotation(PostMapping.class).orNull();
	if (postMapping != null) {
		return postMapping.name();
	}
	DeleteMapping deleteMapping = context.findControllerAnnotation(DeleteMapping.class).orNull();
	if (deleteMapping != null) {
		return deleteMapping.name();
	}
	PutMapping putMapping = context.findControllerAnnotation(PutMapping.class).orNull();
	if (putMapping != null) {
		return putMapping.name();
	}
	RequestMapping requestMapping = context.findControllerAnnotation(RequestMapping.class).orNull();
	if (requestMapping != null) {
		return requestMapping.name();
	}
	return "";
}
 
Example #28
Source File: SysConfigController.java    From mall4j with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 删除配置
 */
@SysLog("删除配置")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('sys:config:delete')")
public ResponseEntity<Void> delete(@RequestBody Long[] configIds){
	sysConfigService.deleteBatch(configIds);
	return ResponseEntity.ok().build();
}
 
Example #29
Source File: UserResource.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * DELETE /users/:login : delete the "login" User.
 *
 * @param login the login of the user to delete
 * @return the ResponseEntity with status 200 (OK)
 */
@DeleteMapping("/user/{login:" + Constants.LOGIN_REGEX + "}")
@Timed
public ResponseEntity<Void> deleteUser(@PathVariable String login) {
    log.debug("REST request to delete User: {}", login);
    userService.deleteUser(login);
    return ResponseEntity.ok().headers(HeaderUtil.createAlert( "A user is deleted with identifier " + login, login)).build();
}
 
Example #30
Source File: JoaDemoController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
  *  批量删除
 * @param ids
 * @return
 */
@DeleteMapping(value = "/deleteBatch")
public Result<JoaDemo> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
	Result<JoaDemo> result = new Result<JoaDemo>();
	if(ids==null || "".equals(ids.trim())) {
		result.error500("参数不识别!");
	}else {
		this.joaDemoService.removeByIds(Arrays.asList(ids.split(",")));
		result.success("删除成功!");
	}
	return result;
}