#set($EntityCommonName2 = $EntityCommonName) #set($EntityCommonNamePlural2 = $EntityCommonNamePlural.substring(0,1).toUpperCase() + $EntityCommonNamePlural.substring(1)) #set( $array = $BasePath.split('/') ) #set($idArray=[]) #foreach( $arrElement in $array ) #if( $arrElement.contains("{")) #set($trail = $arrElement.indexOf('}') - 1) $idArray.add($arrElement.substring(1,$trail)) #end #end #if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end import com.asseco.cb.foundation.application.BaseController; import com.asseco.cb.foundation.application.Patch; import com.asseco.cb.foundation.application.PatchRequestBody; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.rest.webmvc.BasePathAwareController; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; #parse("File Header.java") @RestController @Api(tags = "$EntityCommonNamePlural2", description = "$EntityCommonNamePlural2") public class ${NAME}Controller extends BaseController<${NAME}> { private final static String basePath = "/$BasePath"; public ${NAME}Controller(${NAME}Repository repository) { super(repository); } @PostMapping(path = basePath) @ApiOperation("Add new $EntityCommonName") public ResponseEntity<${NAME}> addNew(@RequestBody ${NAME} entity) { return super.addNew(entity); } @GetMapping(path = basePath + _id) @ApiOperation("Get $EntityCommonName") public ResponseEntity<${NAME}> getOne(@PathVariable("id") Long id) { return super.getOne(id); } @PostMapping(path = basePath + _id_editable) @ApiOperation("Provide editable version of $EntityCommonName") public ResponseEntity<${NAME}> provideEditable(@PathVariable("id") Long id) { return super.provideEditable(id); } @PatchMapping(path = basePath + _id_editable_version) @Patch(service = ${NAME}Repository.class) @ResponseStatus(HttpStatus.OK) @ApiOperation("Update editable version of $EntityCommonName") public void updateEditable(@PathVariable("id") Long id, @PathVariable("version") Integer version, @RequestBody @PatchRequestBody ${NAME} edited) { super.updateEditable(id, version, edited); } @DeleteMapping(path = basePath + _id_version) @ResponseStatus(HttpStatus.OK) @ApiOperation("Remove $EntityCommonName") public void remove(@PathVariable("id") Long id, @PathVariable("version") Integer version) { super.remove(id, version); } @PostMapping(path = basePath + _id_editable_version_acceptance) @ResponseStatus(HttpStatus.OK) @ApiOperation("Accept new or edited $EntityCommonName") public void acceptEdited(@PathVariable("id") Long id, @PathVariable("version") Integer version) { super.acceptEdited(id, version); } @PostMapping(path = basePath + _id_editable_version_rejection) @ResponseStatus(HttpStatus.OK) @ApiOperation("Reject new or edited $EntityCommonName") public void rejectEdited(@PathVariable("id") Long id, @PathVariable("version") Integer version) { super.rejectEdited(id, version); } @GetMapping(path = basePath) @ResponseStatus(HttpStatus.OK) @ApiOperation("Get $EntityCommonNamePlural") public @ResponseBody Page<${NAME}> getAll(Pageable pageable #if( $idArray[0] != "" ) #foreach($id in $idArray) , Long $id #end #end) { return super.getAll( pageable); } }