|
|
|
@@ -14,10 +14,7 @@ import vn.azteam.tpf.Constants.Constants; |
|
|
|
import vn.azteam.tpf.service.TBExampleStampQueryService; |
|
|
|
import vn.azteam.tpf.service.TBExampleStampService; |
|
|
|
import vn.azteam.tpf.service.UserService; |
|
|
|
import vn.azteam.tpf.service.dto.TBExampleStampCreationDTO; |
|
|
|
import vn.azteam.tpf.service.dto.TBExampleStampCriteria; |
|
|
|
import vn.azteam.tpf.service.dto.TBExampleStampDTO; |
|
|
|
import vn.azteam.tpf.service.dto.UserDTO; |
|
|
|
import vn.azteam.tpf.service.dto.*; |
|
|
|
import vn.azteam.tpf.service.util.PageableUtil; |
|
|
|
import vn.azteam.tpf.service.util.UserRoleUtil; |
|
|
|
import vn.azteam.tpf.web.rest.errors.BadRequestAlertException; |
|
|
|
@@ -151,4 +148,53 @@ public class TBExampleStampResource { |
|
|
|
throw new RuntimeException(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@PutMapping("/tb-example-stamp") |
|
|
|
public ResponseEntity<TBExampleStampDTO> updateStamp(@RequestPart("data") TBExampleStampUpdateDTO tBExampleStampUpdateDTO, |
|
|
|
@RequestPart("file") MultipartFile file) { |
|
|
|
|
|
|
|
UserDTO currentUser = userService.getCurrentUserDTO().get(); |
|
|
|
if (tBExampleStampUpdateDTO.getId() == null) { |
|
|
|
throw new BadRequestAlertException("1019", ENTITY_NAME, "1019"); |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
TBExampleStampDTO tbExampleStampDTO = new TBExampleStampDTO(); |
|
|
|
tbExampleStampDTO.setId(tBExampleStampUpdateDTO.getId()); |
|
|
|
tbExampleStampDTO.setY(tBExampleStampUpdateDTO.getY()); |
|
|
|
tbExampleStampDTO.setX(tBExampleStampUpdateDTO.getX()); |
|
|
|
tbExampleStampDTO.setWidth(tBExampleStampUpdateDTO.getWidth()); |
|
|
|
tbExampleStampDTO.setHeight(tBExampleStampUpdateDTO.getHeight()); |
|
|
|
tbExampleStampDTO.setDescription(tBExampleStampUpdateDTO.getDescription()); |
|
|
|
tbExampleStampDTO.setExampleStampName(""); |
|
|
|
tbExampleStampDTO.setSize(tBExampleStampUpdateDTO.getSize()); |
|
|
|
|
|
|
|
tbExampleStampDTO.setModifiedDate(Instant.now()); |
|
|
|
tbExampleStampDTO.setModifiedById(currentUser.getUserId()); |
|
|
|
|
|
|
|
TBExampleStampDTO result = null; |
|
|
|
Boolean hasViolationException = false; |
|
|
|
do { |
|
|
|
try { |
|
|
|
if (!file.isEmpty()) { |
|
|
|
tbExampleStampDTO = tBExampleStampQueryService.saveUploadedFile(tbExampleStampDTO, file, Constants.EXAMPLE_STAMP); |
|
|
|
} |
|
|
|
result = tBExampleStampService.save(tbExampleStampDTO); |
|
|
|
} catch (org.springframework.dao.DataIntegrityViolationException ex) { |
|
|
|
if (ex.getMessage().contains("ux_tb_example_stamp")) { |
|
|
|
hasViolationException = true; |
|
|
|
} else { |
|
|
|
throw ex; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
while (hasViolationException); |
|
|
|
|
|
|
|
return ResponseEntity.created(new URI("/api/tb-example-stamp/" + result.getId())) |
|
|
|
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) |
|
|
|
.body(result); |
|
|
|
} catch (Exception exception) { |
|
|
|
throw new RuntimeException(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |