Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DTO na
- private String dealerMaster;
- private String dealerSub;
- private DataStatus dealerStatus;
- private CreationalSpecificationDTO dealerCreationalDTO;
- REST na
- @RequestMapping(value = "/update.dealer.group.mapping/{dealerMaster}",
- method = RequestMethod.POST,
- consumes = MediaType.APPLICATION_JSON_VALUE,
- produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<DealerGroupMappingDTO> updateDealerGroupMapping(@RequestBody DealerGroupMappingDTO dto, @PathVariable("dealerMaster") String dealerMaster) throws CustomException {
- DealerGroupMapping dealerGroup = (DealerGroupMapping) repo.findDealerGroupMappingByMaster(dealerMaster);
- if(dealerGroup == null){
- String message = env.getProperty("data.not.found.message");
- message = MessageFormat.format(message, dto.getDealerMaster());
- throw new CustomException(new DealerGroupMappingDTO(), message, HttpStatus.NOT_FOUND);
- }
- dealerGroup.setDealerMaster(dealerMaster);
- dealerGroup.setDealerSub(dto.getDealerSub());
- dealerGroup.setDataStatus(DataStatus.ACTIVE);
- try{
- repo.save(dealerGroup);
- }catch(ConstraintViolationException ex){
- throw new CustomConstraintViolationException(ex.getMessage(), ex.getConstraintViolations(), new DealerGroupMappingDTO());
- }catch(DataIntegrityViolationException ex){
- throw new CustomDataIntegrityException(ex, ex.getMessage(), new DealerGroupMappingDTO());
- }
- return ResponseEntity.status(HttpStatus.CREATED).body(new DealerGroupMappingAssembler().toDTO(dealerGroup));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement