io.mosip.pms.device.controller.DeviceDetailController Maven / Gradle / Ivy
The newest version!
package io.mosip.pms.device.controller;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.mosip.kernel.core.http.ResponseFilter;
import io.mosip.pms.common.dto.DeviceFilterValueDto;
import io.mosip.pms.common.dto.PageResponseDto;
import io.mosip.pms.common.request.dto.RequestWrapper;
import io.mosip.pms.common.response.dto.ResponseWrapper;
import io.mosip.pms.device.authdevice.entity.DeviceDetail;
import io.mosip.pms.device.authdevice.entity.RegistrationDeviceSubType;
import io.mosip.pms.device.authdevice.service.DeviceDetailService;
import io.mosip.pms.device.constant.DeviceConstant;
import io.mosip.pms.device.request.dto.DeviceDetailDto;
import io.mosip.pms.device.request.dto.DeviceDetailUpdateDto;
import io.mosip.pms.device.request.dto.DeviceSearchDto;
import io.mosip.pms.device.request.dto.UpdateDeviceDetailStatusDto;
import io.mosip.pms.device.response.dto.DeviceDetailSearchResponseDto;
import io.mosip.pms.device.response.dto.FilterResponseCodeDto;
import io.mosip.pms.device.response.dto.IdDto;
import io.mosip.pms.device.response.dto.RegistrationSubTypeDto;
import io.mosip.pms.device.util.AuditUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.v3.oas.annotations.Operation;
@RestController
@RequestMapping(value = "/devicedetail")
@Api(tags = { "DeviceDetail" })
public class DeviceDetailController {
@Autowired
AuditUtil auditUtil;
@Autowired
DeviceDetailService deviceDetaillService;
/**
* Post API to insert a new row of DeviceDetail data
*
* @param deviceDetailRequestDto input parameter deviceRequestDto
*
* @return ResponseEntity DeviceDetail which is inserted successfully
* {@link ResponseEntity}
*/
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostdevicedetail())")
@ResponseFilter
@PostMapping
@Operation(summary = "Service to save DeviceDetail", description = "Saves DeviceDetail and return DeviceDetail id")
@ApiResponses({ @ApiResponse(code = 201, message = "When DeviceDetail successfully created"),
@ApiResponse(code = 400, message = "When Request body passed is null or invalid"),
@ApiResponse(code = 500, message = "While creating DeviceDetail any error occured") })
public ResponseWrapper createDeviceDetail(
@Valid @RequestBody RequestWrapper deviceDetailRequestDto) {
auditUtil.auditRequest(
DeviceConstant.CREATE_API_IS_CALLED + DeviceDetailDto.class.getCanonicalName(),
DeviceConstant.AUDIT_SYSTEM,
DeviceConstant.CREATE_API_IS_CALLED + DeviceDetailDto.class.getCanonicalName(),
"AUT-001", deviceDetailRequestDto.getRequest().getDeviceProviderId(), "partnerId");
ResponseWrapper responseWrapper = new ResponseWrapper<>();
responseWrapper
.setResponse(deviceDetaillService.createDeviceDetails(deviceDetailRequestDto.getRequest()));
auditUtil.auditRequest(
String.format(DeviceConstant.SUCCESSFUL_CREATE , DeviceDetailDto.class.getCanonicalName()),
DeviceConstant.AUDIT_SYSTEM,
String.format(DeviceConstant.SUCCESSFUL_CREATE , DeviceDetailDto.class.getCanonicalName()),
"AUT-005", deviceDetailRequestDto.getRequest().getDeviceProviderId(), "partnerId");
return responseWrapper;
}
/**
* Put API to update a row of DeviceDetail data
*
* @param deviceDetailRequestDto input parameter deviceRequestDto
*
* @return ResponseEntity DeviceDetail which is updated successfully
* {@link ResponseEntity}
*/
@PreAuthorize("hasAnyRole(@authorizedRoles.getPutdevicedetail())")
@ResponseFilter
@PutMapping
@Operation(summary = "Service to update DeviceDetails", description = "Updates DeviceDetails")
@ApiResponses({ @ApiResponse(code = 201, message = "When DeviceDetail successfully updated"),
@ApiResponse(code = 400, message = "When Request body passed is null or invalid"),
@ApiResponse(code = 500, message = "While updating DeviceDetail any error occured") })
public ResponseWrapper updateDeviceDetail(
@Valid @RequestBody RequestWrapper deviceDetailRequestDto) {
auditUtil.auditRequest(
DeviceConstant.UPDATE_API_IS_CALLED + DeviceDetailDto.class.getCanonicalName(),
DeviceConstant.AUDIT_SYSTEM,
DeviceConstant.UPDATE_API_IS_CALLED + DeviceDetailDto.class.getCanonicalName(),
"AUT-006", deviceDetailRequestDto.getRequest().getId(), "deviceDetailId");
ResponseWrapper responseWrapper = new ResponseWrapper<>();
responseWrapper
.setResponse(deviceDetaillService.updateDeviceDetails(deviceDetailRequestDto.getRequest()));
auditUtil.auditRequest(
String.format(DeviceConstant.SUCCESSFUL_UPDATE , DeviceDetailDto.class.getCanonicalName()),
DeviceConstant.AUDIT_SYSTEM,
String.format(DeviceConstant.SUCCESSFUL_UPDATE , DeviceDetailDto.class.getCanonicalName()),
"AUT-007", deviceDetailRequestDto.getRequest().getId(), "deviceDetailId");
return responseWrapper;
}
/**
*
* @param deviceDetailRequestDto
* @return
*/
@PreAuthorize("hasAnyRole(@authorizedRoles.getPatchdevicedetail())")
@ResponseFilter
@PatchMapping
@Operation(summary = "Service to approve/reject DeviceDetail", description = "Approve DeviceDetail and returns success message")
@ApiResponses({ @ApiResponse(code = 201, message = "When DeviceDetail successfully approved/rejected"),
@ApiResponse(code = 400, message = "When Request body passed is null or invalid"),
@ApiResponse(code = 500, message = "While approving/rejecting DeviceDetail any error occured") })
public ResponseWrapper approveDeviceDetails(
@Valid @RequestBody RequestWrapper deviceDetailRequestDto){
auditUtil.auditRequest(
DeviceConstant.STATUS_UPDATE_API_IS_CALLED + UpdateDeviceDetailStatusDto.class.getCanonicalName(),
DeviceConstant.AUDIT_SYSTEM,
DeviceConstant.STATUS_UPDATE_API_IS_CALLED + UpdateDeviceDetailStatusDto.class.getCanonicalName(),
"AUT-006", deviceDetailRequestDto.getRequest().getId(), "deviceDetailId");
ResponseWrapper responseWrapper = new ResponseWrapper<>();
responseWrapper
.setResponse(deviceDetaillService.updateDeviceDetailStatus(deviceDetailRequestDto.getRequest()));
auditUtil.auditRequest(
String.format(DeviceConstant.SUCCESSFUL_UPDATE , UpdateDeviceDetailStatusDto.class.getCanonicalName()),
DeviceConstant.AUDIT_SYSTEM,
String.format(DeviceConstant.SUCCESSFUL_UPDATE , UpdateDeviceDetailStatusDto.class.getCanonicalName()),
"AUT-007", deviceDetailRequestDto.getRequest().getId(), "deviceDetailId");
return responseWrapper;
}
@ResponseFilter
@PostMapping("/search")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostdevicedetailsearch())")
@Operation(summary = "Service to search DeviceDetails", description = "ervice to search DeviceDetails")
public ResponseWrapper> searchDeviceDetails(
@RequestBody @Valid RequestWrapper request) {
ResponseWrapper> responseWrapper = new ResponseWrapper<>();
responseWrapper.setResponse(deviceDetaillService.searchDeviceDetails(DeviceDetail.class, request.getRequest()));
return responseWrapper;
}
@ResponseFilter
@PostMapping("/deviceType/search")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostdevicedetaildevicetypesearch())")
@Operation(summary = "Service to search DeviceTypes", description = "service to search DeviceTypes")
public ResponseWrapper> searchDeviceType(
@RequestBody @Valid RequestWrapper request) {
ResponseWrapper> responseWrapper = new ResponseWrapper<>();
responseWrapper.setResponse(deviceDetaillService.searchDeviceType(RegistrationDeviceSubType.class, request.getRequest()));
return responseWrapper;
}
@ResponseFilter
@PostMapping("/filtervalues")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostdevicedetailfiltervalues())")
@Operation(summary = "Service to filter DeviceDetails", description = "Service to filter DeviceDetails")
public ResponseWrapper filterValues(
@RequestBody @Valid RequestWrapper request) {
ResponseWrapper responseWrapper = new ResponseWrapper<>();
responseWrapper.setResponse(deviceDetaillService.deviceFilterValues(request.getRequest()));
return responseWrapper;
}
@ResponseFilter
@PostMapping("/deviceType/filtervalues")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostdevicedetaildevicetypefiltervalues())")
@Operation(summary = "Service to filter DeviceTypes", description = "Service to filter DeviceTypes")
public ResponseWrapper filterDeviceType(
@RequestBody @Valid RequestWrapper request) {
ResponseWrapper responseWrapper = new ResponseWrapper<>();
responseWrapper.setResponse(deviceDetaillService.deviceTypeFilterValues(request.getRequest()));
return responseWrapper;
}
@ResponseFilter
@PostMapping("/deviceSubType/filtervalues")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostdevicedetaildevicesubtypefiltervalues())")
@Operation(summary = "Service to filter DeviceSubTypes", description = "Service to filter DeviceSubTypes")
public ResponseWrapper filterDeviceSubType(
@RequestBody @Valid RequestWrapper request) {
ResponseWrapper responseWrapper = new ResponseWrapper<>();
responseWrapper.setResponse(deviceDetaillService.deviceSubTypeFilterValues(request.getRequest()));
return responseWrapper;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy