Skip to content

Instantly share code, notes, and snippets.

@Vinodh-thimmisetty
Last active August 31, 2019 05:28
Show Gist options
  • Save Vinodh-thimmisetty/662ef0f2335743d649108ec5fe51c80b to your computer and use it in GitHub Desktop.
Save Vinodh-thimmisetty/662ef0f2335743d649108ec5fe51c80b to your computer and use it in GitHub Desktop.
---- File and Code Templates for @Controller class in Spring boot -------------
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
#set ($string = ${NAME})
#set ($capitilizeFirst = $string.substring(0, 1).toUpperCase() + $string.substring(1))
#parse("File Header.java")
@RestController
@RequestMapping("/api/v1")
@Api(value = "${capitilizeFirst}Controller", tags = {"${capitilizeFirst}"})
public class ${capitilizeFirst}Controller {
#if (${GET_API_ENDPOINT} &&
${GET_API_ENDPOINT} != "")
@GetMapping("/${GET_API_ENDPOINT}")
@ApiOperation(value = "find${capitilizeFirst}", tags = {})
public String find${capitilizeFirst}(){
return null;
}
#end
#if (${POST_API_ENDPOINT} &&
${POST_API_ENDPOINT} != "")
@PostMapping("/${POST_API_ENDPOINT}")
@ApiOperation(value = "create${capitilizeFirst}", tags = {})
public String create${capitilizeFirst}(){
return null;
}
#end
#if (${PUT_API_ENDPOINT} &&
${PUT_API_ENDPOINT} != "")
@PutMapping("/${PUT_API_ENDPOINT}")
@ApiOperation(value = "update${capitilizeFirst}", tags = {})
public String update${capitilizeFirst}(){
return null;
}
#end
#if (${DELETE_API_ENDPOINT} &&
${DELETE_API_ENDPOINT} != "")
@DeleteMapping("/${DELETE_API_ENDPOINT}")
@ApiOperation(value = "delete${capitilizeFirst}", tags = {})
public String delete${capitilizeFirst}(){
return null;
}
#end
}
--- Live Tempates for adding any end points ----------
Select Language as JAVA and Edit Template Variables with endPoint <-- CamelCase; methodName <-- methodName()
Abbr: getApi; Desc: Generate the Stub for GET MAPPING inside Controller
@GetMapping("/$endPoint$")
@ApiOperation(value = "find$methodName$", tags = {})
public String find$methodName$() {
return null;
}
Abbr: postApi; Desc: Generate the Stub for POST MAPPING inside Controller
@PostMapping("/$endPoint$")
@ApiOperation(value = "find$methodName$", tags = {})
public String create$methodName$() {
return null;
}
Abbr: putApi; Desc: Generate the Stub for PUT MAPPING inside Controller
@PutMapping("/$endPoint$")
@ApiOperation(value = "find$methodName$", tags = {})
public String update$methodName$() {
return null;
}
Abbr: deleteApi; Desc: Generate the Stub for DELETE MAPPING inside Controller
@DeleteMapping("/$endPoint$")
@ApiOperation(value = "find$methodName$", tags = {})
public String find$methodName$() {
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment