Package com.skava.foundation.web
Class TemplateController
java.lang.Object
com.skava.foundation.web.BaseController
com.skava.foundation.web.TemplateController
@RestController
@Validated
@RequestMapping("/template")
public class TemplateController
extends BaseController
Template controller class contains common operations related to Template Configuration
- Since:
- 8.0
- Version:
- 8.0
- Author:
- Infosys Equinox
-
Field Summary
Fields inherited from class com.skava.foundation.web.BaseController
DEFAULT_API_LOCALE, DEFAULT_API_VERSION, INVALID_REQUEST_DATA, message
-
Constructor Summary
ConstructorsConstructorDescriptionTemplateController
(Message message, TemplateService templateService) Default Constructor -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<TemplateResponse>
create
(String authToken, String locale, String version, Long storeId, Long businessId, @Valid TemplateRequest request) Create new template based on given requestorg.springframework.http.ResponseEntity<com.skava.core.ResponseModel>
This method is used to delete template on given request.filterRequestParam
(int page, int size, String search, String filters, org.springframework.data.domain.Sort sort) org.springframework.http.ResponseEntity<List<TemplateResponse>>
findAll
(String authToken, String locale, String version, Long businessId, Long storeId, @Valid FilterRequestParam filter) Loads all the Template.org.springframework.http.ResponseEntity<TemplateResponse>
Loads a Template by id.org.springframework.http.ResponseEntity<TemplateResponse>
patchUpdate
(String authToken, String locale, String version, TemplateRequest request, Long id, Long businessId, Long storeId) Patch Updates an existing template with given template idorg.springframework.http.ResponseEntity<TemplateResponse>
update
(String authToken, String locale, String version, @Valid TemplateRequest request, Long id, Long businessId, Long storeId) Updates an existing template with given auto-generated template idMethods inherited from class com.skava.foundation.web.BaseController
buildResponse, getErrorCode, getErrorMessage, getFailureResponseModel, handleAlreadyExistException, handleExceptionBadRequest, handleExceptionNotFound
-
Constructor Details
-
TemplateController
Default Constructor
-
-
Method Details
-
create
@ResponseStatus(CREATED) @PostMapping("") @PreAuthorize("hasRoleForBusinessById(\'ROLE_BUSINESS_ADMIN\', #businessId)") public org.springframework.http.ResponseEntity<TemplateResponse> create(@RequestHeader(value="x-auth-token",required=true) String authToken, @RequestHeader(value="x-locale",required=false,defaultValue="en_US") String locale, @RequestHeader(value="x-version",required=false,defaultValue="8.19.7") String version, @RequestParam(required=true) Long storeId, @RequestParam(required=true) Long businessId, @Valid @RequestBody(required=true) @Valid TemplateRequest request) Create new template based on given request- Parameters:
authToken
- It contains the authentication token required for the creation of template.locale
- API Response and error messages will be responded in the locale mentioned in this parameter.version
- It hold the value of version number of API.storeId
- unique identifier for store.request
- Instance ofTemplate
.- Returns:
- A
Template
object.
-
update
@ResponseStatus(OK) @PutMapping(value="/{templateId}", produces="application/json") @PreAuthorize("hasRoleForBusinessById(\'ROLE_BUSINESS_ADMIN\', #businessId)") public org.springframework.http.ResponseEntity<TemplateResponse> update(@RequestHeader(value="x-auth-token",required=true) String authToken, @RequestHeader(value="x-locale",required=false,defaultValue="en_US") String locale, @RequestHeader(value="x-version",required=false,defaultValue="8.19.7") String version, @Valid @RequestBody(required=true) @Valid TemplateRequest request, @PathVariable(value="templateId",required=true) Long id, @RequestParam(required=true) Long businessId, @RequestParam(required=true) Long storeId) Updates an existing template with given auto-generated template id- Parameters:
authToken
- It contains the authentication token required for the creation of template.locale
- API Response and error messages will be responded in the locale mentioned in this parameter.version
- It hold the value of version number of API.request
- Instance ofTemplate
.id
- Auto-generated unique identifier of the template to be updated.storeId
- unique identifier for store.- Returns:
- A
Template
object.
-
patchUpdate
@ResponseStatus(OK) @PatchMapping(value="/{templateId}", produces="application/json") @PreAuthorize("hasRoleForBusinessById(\'ROLE_BUSINESS_ADMIN\', #businessId)") public org.springframework.http.ResponseEntity<TemplateResponse> patchUpdate(@RequestHeader(value="x-auth-token",required=true) String authToken, @RequestHeader(value="x-locale",required=false,defaultValue="en_US") String locale, @RequestHeader(value="x-version",required=false,defaultValue="8.19.7") String version, @RequestBody(required=true) TemplateRequest request, @PathVariable(value="templateId",required=true) Long id, @RequestParam(required=true) Long businessId, @RequestParam(required=true) Long storeId) Patch Updates an existing template with given template id- Parameters:
authToken
- It contains the authentication token required for the creation of template.locale
- API Response and error messages will be responded in the locale mentioned in this parameter.version
- It hold the value of version number of API.request
- Instance ofTemplate
.id
- Auto-generated unique identifier of the template to be updated.storeId
- unique identifier for store.- Returns:
- A
Template
object.
-
findById
@ResponseStatus(OK) @GetMapping("/{templateId}") @PreAuthorize("hasValidSession()") public org.springframework.http.ResponseEntity<TemplateResponse> findById(@RequestHeader(value="x-auth-token",required=true) String authToken, @PathVariable(value="templateId",required=true) @Min(1L) @Min(1L) Long id, @RequestHeader(value="x-locale",required=true,defaultValue="en_US") String locale, @RequestParam(required=true) Long businessId, @RequestHeader(value="x-version",required=false,defaultValue="8.19.7") String version) Loads a Template by id.- Parameters:
locale
- API Response and error messages will be responded in the locale mentioned in this parameter.version
- It hold the value of version number of API. Using this parameter we can access the different version of the API. This token is used to authenticate the request.id
- Unique identifier of the Template to be loaded.authToken
- Contains auth token.- Returns:
- A
Template
object.
-
deleteById
@ResponseStatus(OK) @DeleteMapping("/{templateId}") @PreAuthorize("hasRoleForBusinessById(\'ROLE_BUSINESS_ADMIN\', #businessId)") public org.springframework.http.ResponseEntity<com.skava.core.ResponseModel> deleteById(@RequestHeader(value="x-auth-token",required=true) String authToken, @PathVariable(value="templateId",required=true) @Min(1L) @Min(1L) Long id, @RequestHeader(value="x-locale",required=false,defaultValue="en_US") String locale, @RequestParam(required=true) Long businessId, @RequestHeader(value="x-version",required=false,defaultValue="8.19.7") String version) This method is used to delete template on given request.- Parameters:
authToken
- It contains the authentication token required for the creation of Collection.locale
- API Response and error messages will be responded in the locale mentioned in this parameter.version
- versionid
- Unique Identifier of template- Returns:
- A Instance of
Template
.
-
findAll
@ResponseStatus(OK) @GetMapping @PreAuthorize("hasValidSession()") public org.springframework.http.ResponseEntity<List<TemplateResponse>> findAll(@RequestHeader(value="x-auth-token",required=true) String authToken, @RequestHeader(value="x-locale",required=true,defaultValue="en_US") String locale, @RequestHeader(value="x-version",required=false,defaultValue="8.19.7") String version, @RequestParam(required=true) Long businessId, @RequestParam(value="storeId",required=true) Long storeId, @Valid @ModelAttribute("filter") @Valid FilterRequestParam filter) Loads all the Template.- Parameters:
authToken
- It contains the authentication token required for the creation of Collection.locale
- API Response and error messages will be responded in the locale mentioned in this parameter.version
- It hold the value of version number of API. Using thisstoreId
- Unique Identifier of Store.filter
- Instance ofFilterRequestParam
- Returns:
- List of
Template
.
-
filterRequestParam
@ModelAttribute("filter") public FilterRequestParam filterRequestParam(@RequestParam(required=false,defaultValue="1") int page, @RequestParam(required=false,defaultValue="100") int size, @RequestParam(required=false) String search, @RequestParam(required=false) String filters, org.springframework.data.domain.Sort sort) - Parameters:
page
- This parameter will be available for all the services that support pagination. It indicates the starting index of the item to be responded by the API.size
- This parameter will be available for all the services that support pagination. It is used to specify the maximum number items that need to be responded for the request.search
- This parameter will be available for all the services that support search. It is used to specify the name,operator,value for a field to be searched.sort
- This parameter will be available for all the services that support sort. It is used to specify the sort field with order(ascending or descending) Default will be ascending.filters
- This parameter will be available for all the services that support filtration.- Returns:
- A
FilterRequestParam
object
-