|
|
|
|
|
|
|
|
*/ |
|
|
*/ |
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping("/api") |
|
|
@RequestMapping("/api") |
|
|
@SecurityRequirement(name = "api") |
|
|
|
|
|
|
|
|
//@SecurityRequirement(name = "api") |
|
|
public class TBCropResource { |
|
|
public class TBCropResource { |
|
|
|
|
|
|
|
|
private final Logger log = LoggerFactory.getLogger(TBCropResource.class); |
|
|
private final Logger log = LoggerFactory.getLogger(TBCropResource.class); |
|
|
|
|
|
|
|
|
Comparator.nullsFirst(Comparator.naturalOrder())).reversed()) |
|
|
Comparator.nullsFirst(Comparator.naturalOrder())).reversed()) |
|
|
.collect(Collectors.toList()); |
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
//Authorize get list crop by current user |
|
|
|
|
|
// result = result.stream() |
|
|
|
|
|
// .filter(item -> userRoleUtil.currentUserHasPermissionByCropId(item.getId())) |
|
|
|
|
|
// .collect(Collectors.toList()); |
|
|
|
|
|
Page<TBCropDTO> pageResult = pageableUtil.changeTBCropDTOToPageFromList(result, pageable); |
|
|
Page<TBCropDTO> pageResult = pageableUtil.changeTBCropDTOToPageFromList(result, pageable); |
|
|
for(TBCropDTO itemResult : result) { |
|
|
for(TBCropDTO itemResult : result) { |
|
|
logger.error("Start date: " + itemResult.getStartDate()); |
|
|
logger.error("Start date: " + itemResult.getStartDate()); |
|
|
|
|
|
|
|
|
@GetMapping("/tb-crops-scan-qrCode/{qrCode}") |
|
|
@GetMapping("/tb-crops-scan-qrCode/{qrCode}") |
|
|
@Timed |
|
|
@Timed |
|
|
public ResponseEntity<TBCropDetailDTO> getTBCropScanQRCode(@PathVariable String qrCode, Pageable pageable) { |
|
|
public ResponseEntity<TBCropDetailDTO> getTBCropScanQRCode(@PathVariable String qrCode, Pageable pageable) { |
|
|
Optional<UserDTO> currentUser = userService.getCurrentUserDTO(); |
|
|
|
|
|
Long currentUserId = currentUser.get().getId(); |
|
|
|
|
|
|
|
|
|
|
|
TBCropCriteria tbCropCriteria = new TBCropCriteria(); |
|
|
TBCropCriteria tbCropCriteria = new TBCropCriteria(); |
|
|
StringFilter qrCodeFilter = new StringFilter(); |
|
|
StringFilter qrCodeFilter = new StringFilter(); |
|
|
qrCodeFilter.setEquals(qrCode); |
|
|
qrCodeFilter.setEquals(qrCode); |
|
|
tbCropCriteria.setQrCode(qrCodeFilter); |
|
|
tbCropCriteria.setQrCode(qrCodeFilter); |
|
|
|
|
|
|
|
|
List<TBCropDTO> tBCropDTOs = tBCropQueryService.findByCriteria(tbCropCriteria); |
|
|
List<TBCropDTO> tBCropDTOs = tBCropQueryService.findByCriteria(tbCropCriteria); |
|
|
List<TBCropDTO> listTBCropDTOs = new ArrayList<>(); |
|
|
|
|
|
|
|
|
List<TBCropDTO> listTBCropDTOs; |
|
|
if (tBCropDTOs.size() > 0) { |
|
|
if (tBCropDTOs.size() > 0) { |
|
|
//@CUONGLT - Filter scope customer's data |
|
|
|
|
|
listTBCropDTOs = tBCropDTOs.stream() |
|
|
listTBCropDTOs = tBCropDTOs.stream() |
|
|
.filter(item -> userRoleUtil.currentUserHasPermissionByCropId(item.getId())) |
|
|
.filter(item -> userRoleUtil.currentUserHasPermissionByCropId(item.getId())) |
|
|
.collect(Collectors.toList()); |
|
|
.collect(Collectors.toList()); |