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

The following examples show how to use org.springframework.web.bind.annotation.DeleteMapping. These examples are extracted from open source projects. 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 Project: jeecg-cloud   Source File: OSSFileController.java    License: 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 Project: docker-crash-course   Source File: TodoJpaResource.java    License: 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 3
Source Project: flowable-engine   Source File: FormDeploymentResource.java    License: 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 4
Source Project: studio   Source File: UsersController.java    License: 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 5
@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 6
Source Project: flowable-engine   Source File: JobResource.java    License: 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 7
Source Project: Sentinel   Source File: AuthorityRuleController.java    License: 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 8
Source Project: taskana   Source File: TaskCommentController.java    License: 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 9
/**
 * 删除权限标识
 * 参考 /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 10
Source Project: SpringBootLearn   Source File: TestController.java    License: 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 11
Source Project: genie   Source File: CommandRestController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Remove all the {@link Criterion} currently associated with the command.
 *
 * @param id The id of the command to remove the criteria for
 * @throws NotFoundException When no {@link Command} with the given {@literal id} exists
 */
@DeleteMapping(value = "/{id}/clusterCriteria")
@ResponseStatus(HttpStatus.OK)
public void removeAllClusterCriteriaFromCommand(
    @PathVariable("id") final String id
) throws NotFoundException {
    log.info("Called for command {}", id);
    this.persistenceService.removeAllClusterCriteriaForCommand(id);
}
 
Example 12
@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 13
Source Project: Moss   Source File: NotificationFilterController.java    License: 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 14
Source Project: logging-log4j-audit   Source File: CatalogController.java    License: 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 15
Source Project: Spring-5.0-Projects   Source File: CountryLanguageAPIController.java    License: 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 16
Source Project: BlogManagePlatform   Source File: DefaultEndPointPlugin.java    License: 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 17
/**
 * 删除配置
 */
@SysLog("删除配置")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('sys:config:delete')")
public ResponseEntity<Void> delete(@RequestBody Long[] configIds){
	sysConfigService.deleteBatch(configIds);
	return ResponseEntity.ok().build();
}
 
Example 18
Source Project: jeecg-boot   Source File: JoaDemoController.java    License: 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;
}
 
Example 19
Source Project: scava   Source File: UserResource.java    License: 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 20
Source Project: heimdall   Source File: CacheResource.java    License: 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 21
Source Project: tutorials   Source File: FooBarController.java    License: 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 22
@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 23
@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 24
Source Project: logging-log4j-audit   Source File: CatalogController.java    License: 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 25
Source Project: WeBASE-Front   Source File: ContractController.java    License: 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 26
Source Project: jeecg-boot   Source File: JeecgDemoController.java    License: 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 27
Source Project: sophia_scaffolding   Source File: CompanyController.java    License: 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 28
Source Project: sophia_scaffolding   Source File: ApiLoggerController.java    License: 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 29
Source Project: springdoc-openapi   Source File: UserApi.java    License: Apache License 2.0 5 votes vote down vote up
@Operation(summary = "Creates list of users with given input array", tags = { "user" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") })

@DeleteMapping(value = "/user/{username}")
default ResponseEntity<Void> deleteUser(
		@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The name that needs to be deleted", required = true) @PathVariable("username") String username) {
	return getDelegate().deleteUser(username);
}
 
Example 30
Source Project: coderadar   Source File: DeleteModuleController.java    License: MIT License 5 votes vote down vote up
@DeleteMapping(path = "/projects/{projectId}/modules/{moduleId}")
public ResponseEntity<HttpStatus> deleteModule(
    @PathVariable(name = "moduleId") long moduleId,
    @PathVariable(name = "projectId") long projectId) {
  deleteModuleUseCase.delete(moduleId, projectId);
  return new ResponseEntity<>(HttpStatus.OK);
}