I have created an annotation eg @SecurityCheck and a (Restfull) controller advice to check if the controller has @SecurityCheck annotation.
I have almost 300 controller methods. Its very difficult for me to apply @SecurityCheck on each and every method in all controller by hand .
Is there a way by which I can add a particular code snippit eg @SecurityCheck on every method of controller layer in my project. I am using InteliJ.
Example:
Here is a code snippet for a sample controller method. And every controller method has @ApiResponses() annotation.
/... some other annotations .../
@ApiResponses({
@ApiResponse(code = 200, message = "Success", response = Response.class) })
public Response getExampleResourceMethod(
@RequestBody String id) {
return someService.getData(id);
}
Method name can be different and Arguments. But almost All Methods has @ApiResponses() annotation with different annotation params.
Expected Output
/... some other annotations .../
@ApiResponses({
@ApiResponse(code = 200, message = "Success", response = Response.class) })
@SecurityCheck()
public Response getExampleResourceMethod(
@RequestBody String id) {
return someService.getData(id);
}
You might be able to do it with a Regex and the search & replace tool
EDIT: Quick example of a solution below:
Search: (@ApiResponses\((\S[\n]?.*)}\))
Replace: $1\r\n@SecurityCheck
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.