| @Enumerated(value = EnumType.STRING) | @Enumerated(value = EnumType.STRING) | ||||
| private TBCodeDetailsStatusEnum status = TBCodeDetailsStatusEnum.NEW; | private TBCodeDetailsStatusEnum status = TBCodeDetailsStatusEnum.NEW; | ||||
| @Column(name = "last_updated_date") | |||||
| private Instant lastUpdatedDate; | |||||
| @Column(name = "created_date") | @Column(name = "created_date") | ||||
| private Instant createdDate; | private Instant createdDate; | ||||
| public void setDeletedBy(TBDetailUser deletedBy) { | public void setDeletedBy(TBDetailUser deletedBy) { | ||||
| this.deletedBy = deletedBy; | this.deletedBy = deletedBy; | ||||
| } | } | ||||
| public Instant getLastUpdatedDate() { | |||||
| return lastUpdatedDate; | |||||
| } | |||||
| public void setLastUpdatedDate(Instant lastUpdatedDate) { | |||||
| this.lastUpdatedDate = lastUpdatedDate; | |||||
| } | |||||
| } | } |
| NEW("NEW"), | NEW("NEW"), | ||||
| ACTIVE("ACTIVE"), | |||||
| CANCELED("CANCELED"), | |||||
| UPDATED("UPDATED"), | UPDATED("UPDATED"), | ||||
| UPDATED_PRINTED("UPDATED_PRINTED"); | UPDATED_PRINTED("UPDATED_PRINTED"); | ||||
| private final String name; | private final String name; | ||||
| TBCodeStatusEnum(final String name) { | TBCodeStatusEnum(final String name) { |
| import org.springframework.stereotype.Repository; | import org.springframework.stereotype.Repository; | ||||
| import vn.azteam.tpf.domain.TBCodeDetails; | import vn.azteam.tpf.domain.TBCodeDetails; | ||||
| import java.util.Optional; | |||||
| @Repository | @Repository | ||||
| public interface TBCodeDetailsRepository extends JpaRepository<TBCodeDetails, Long>, JpaSpecificationExecutor<TBCodeDetails> { | public interface TBCodeDetailsRepository extends JpaRepository<TBCodeDetails, Long>, JpaSpecificationExecutor<TBCodeDetails> { | ||||
| // @Query("select tb_code_details from TBCodeDetails tb_code_details where tb_code_details.code =:code") | |||||
| Optional<TBCodeDetails> findByCode(String code); | |||||
| } | } |
| import org.springframework.data.jpa.repository.JpaRepository; | import org.springframework.data.jpa.repository.JpaRepository; | ||||
| import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||||
| import org.springframework.data.repository.query.Param; | |||||
| import org.springframework.stereotype.Repository; | import org.springframework.stereotype.Repository; | ||||
| import vn.azteam.tpf.domain.TBCode; | import vn.azteam.tpf.domain.TBCode; | ||||
| import vn.azteam.tpf.domain.TBCrop; | |||||
| import java.util.Optional; | |||||
| @Repository | @Repository | ||||
| public interface TBCodeRepository extends JpaRepository<TBCode, Long>, JpaSpecificationExecutor<TBCode> { | |||||
| public interface TBCodeRepository extends JpaRepository<TBCode, Long>, JpaSpecificationExecutor<TBCode> { | |||||
| //@Query("select tb_crop from TBCrop tb_crop left join fetch tb_crop.tbDetailUsers where tb_crop.id =:id") | |||||
| Optional<TBCode> findOneWithEagerRelationships(@Param("id") Long id); | |||||
| } | } |
| import org.springframework.data.jpa.domain.Specification; | import org.springframework.data.jpa.domain.Specification; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| import vn.azteam.tpf.domain.TBCodeDetails; | |||||
| import vn.azteam.tpf.domain.TBCodeDetails_; | |||||
| import vn.azteam.tpf.domain.TBDetailUser; | |||||
| import vn.azteam.tpf.domain.TBDetailUser_; | |||||
| import vn.azteam.tpf.domain.*; | |||||
| import vn.azteam.tpf.repository.TBCodeDetailsRepository; | import vn.azteam.tpf.repository.TBCodeDetailsRepository; | ||||
| import vn.azteam.tpf.service.dto.TBCodeDetailsCriteria; | import vn.azteam.tpf.service.dto.TBCodeDetailsCriteria; | ||||
| import vn.azteam.tpf.service.dto.TBCodeDetailsDTO; | import vn.azteam.tpf.service.dto.TBCodeDetailsDTO; | ||||
| import javax.persistence.criteria.Join; | import javax.persistence.criteria.Join; | ||||
| import javax.persistence.criteria.JoinType; | import javax.persistence.criteria.JoinType; | ||||
| import java.util.Optional; | |||||
| @Service | @Service | ||||
| @Transactional(readOnly = true) | @Transactional(readOnly = true) | ||||
| .map(tBCodeDetailsMapper::toDto); | .map(tBCodeDetailsMapper::toDto); | ||||
| } | } | ||||
| @Transactional(readOnly = true) | |||||
| public Optional<TBCodeDetailsDTO> findByCode(String code) { | |||||
| log.debug("find by criteria code : {}", code); | |||||
| return tBCodeDetailsRepository.findByCode(code) | |||||
| .map(tBCodeDetailsMapper::toDto); | |||||
| } | |||||
| private Specification<TBCodeDetails> initializeCropSpecification() { | private Specification<TBCodeDetails> initializeCropSpecification() { | ||||
| return (Specification<TBCodeDetails>) (root, query, cb) -> { | return (Specification<TBCodeDetails>) (root, query, cb) -> { | ||||
| final Join<TBCodeDetails, TBDetailUser> detailUserJoin = root.join(TBCodeDetails_.deletedBy, JoinType.LEFT); | final Join<TBCodeDetails, TBDetailUser> detailUserJoin = root.join(TBCodeDetails_.deletedBy, JoinType.LEFT); | ||||
| } | } | ||||
| /** | /** | ||||
| * Function to convert TBCodeCriteria to a {@link Specification} | |||||
| * Function to convert TBCodeDetailCriteria to a {@link Specification} | |||||
| */ | */ | ||||
| private Specification<TBCodeDetails> createSpecification(TBCodeDetailsCriteria criteria) { | private Specification<TBCodeDetails> createSpecification(TBCodeDetailsCriteria criteria) { | ||||
| Specification<TBCodeDetails> specification = initializeCropSpecification(); | Specification<TBCodeDetails> specification = initializeCropSpecification(); | ||||
| // if (criteria.getQrCode() != null) { | // if (criteria.getQrCode() != null) { | ||||
| // specification = specification.and(buildStringSpecification(criteria.getQrCode(), TBCrop_.qrCode)); | // specification = specification.and(buildStringSpecification(criteria.getQrCode(), TBCrop_.qrCode)); | ||||
| // } | // } | ||||
| // if (criteria.getCode() != null) { | |||||
| // specification = specification.and(buildStringSpecification(criteria.getCode(), TBCrop_.code)); | |||||
| // } | |||||
| if (criteria.getCode() != null) { | |||||
| specification = specification.and(buildStringSpecification(criteria.getCode(), TBCodeDetails_.code)); | |||||
| } | |||||
| // if (criteria.getAreaM2() != null) { | // if (criteria.getAreaM2() != null) { | ||||
| // specification = specification.and(buildRangeSpecification(criteria.getAreaM2(), TBCrop_.areaM2)); | // specification = specification.and(buildRangeSpecification(criteria.getAreaM2(), TBCrop_.areaM2)); | ||||
| // } | // } |
| package vn.azteam.tpf.service; | package vn.azteam.tpf.service; | ||||
| import vn.azteam.tpf.service.dto.TBCodeDetailsDTO; | import vn.azteam.tpf.service.dto.TBCodeDetailsDTO; | ||||
| import vn.azteam.tpf.web.rest.errors.BadRequestAlertException; | |||||
| import java.util.List; | import java.util.List; | ||||
| TBCodeDetailsDTO save(TBCodeDetailsDTO tBCodeDetailsDTO); | TBCodeDetailsDTO save(TBCodeDetailsDTO tBCodeDetailsDTO); | ||||
| List<TBCodeDetailsDTO> saveAll(List<TBCodeDetailsDTO> tBCodeDetailsDTOs); | List<TBCodeDetailsDTO> saveAll(List<TBCodeDetailsDTO> tBCodeDetailsDTOs); | ||||
| void updateNumberScan(String code) throws BadRequestAlertException; | |||||
| } | } |
| package vn.azteam.tpf.service; | package vn.azteam.tpf.service; | ||||
| import vn.azteam.tpf.domain.TBCodeStatusEnum; | |||||
| import vn.azteam.tpf.service.dto.TBCodeDTO; | import vn.azteam.tpf.service.dto.TBCodeDTO; | ||||
| import vn.azteam.tpf.service.dto.TBCodeUpdateDTO; | |||||
| import vn.azteam.tpf.service.dto.TBCropDTO; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Optional; | |||||
| /** | /** | ||||
| * Service Interface for managing TBCode. | * Service Interface for managing TBCode. | ||||
| List<TBCodeDTO> saveAll(List<TBCodeDTO> tBCodeDTOs); | List<TBCodeDTO> saveAll(List<TBCodeDTO> tBCodeDTOs); | ||||
| Optional<TBCodeDTO> findOne(Long id); | |||||
| Optional<TBCodeDTO> updateStatusTBCode(TBCodeDTO tBCodeDTO); | |||||
| // /** | // /** | ||||
| // * Update crop's PIC | // * Update crop's PIC | ||||
| // * @param cropPersonInChargeDTO | // * @param cropPersonInChargeDTO |
| package vn.azteam.tpf.service.dto; | package vn.azteam.tpf.service.dto; | ||||
| import java.io.Serializable; | import java.io.Serializable; | ||||
| import java.time.Instant; | |||||
| public class TBCodeCreationDTO implements Serializable { | public class TBCodeCreationDTO implements Serializable { | ||||
| private String description; | private String description; | ||||
| private Instant expiredDate; | |||||
| public Long gettBCropId() { | public Long gettBCropId() { | ||||
| return tBCropId; | return tBCropId; | ||||
| } | } | ||||
| public void setDescription(String description) { | public void setDescription(String description) { | ||||
| this.description = description; | this.description = description; | ||||
| } | } | ||||
| public Instant getExpiredDate() { | |||||
| return expiredDate; | |||||
| } | |||||
| public void setExpiredDate(Instant expiredDate) { | |||||
| this.expiredDate = expiredDate; | |||||
| } | |||||
| } | } |
| private TBCodeDetailsStatusEnum status; | private TBCodeDetailsStatusEnum status; | ||||
| // private Instant expiredDate; | |||||
| private Instant createdDate; | private Instant createdDate; | ||||
| private Instant modifiedDate; | private Instant modifiedDate; |
| package vn.azteam.tpf.service.dto; | |||||
| import vn.azteam.tpf.domain.TBCodeStatusEnum; | |||||
| import java.io.Serializable; | |||||
| import java.time.Instant; | |||||
| import java.util.HashSet; | |||||
| import java.util.Set; | |||||
| public class TBCodeUpdateDTO implements Serializable { | |||||
| private Long id; | |||||
| private TBCropDTO tbCropDTO; | |||||
| private Integer quantity; | |||||
| private String description; | |||||
| private String pathImage; | |||||
| private TBCodeStatusEnum status; | |||||
| private Instant expiredDate; | |||||
| public Long getId() { | |||||
| return id; | |||||
| } | |||||
| public void setId(Long id) { | |||||
| this.id = id; | |||||
| } | |||||
| public TBCropDTO getTbCropDTO() { | |||||
| return tbCropDTO; | |||||
| } | |||||
| public void setTbCropDTO(TBCropDTO tbCropDTO) { | |||||
| this.tbCropDTO = tbCropDTO; | |||||
| } | |||||
| public Integer getQuantity() { | |||||
| return quantity; | |||||
| } | |||||
| public void setQuantity(Integer quantity) { | |||||
| this.quantity = quantity; | |||||
| } | |||||
| public String getDescription() { | |||||
| return description; | |||||
| } | |||||
| public void setDescription(String description) { | |||||
| this.description = description; | |||||
| } | |||||
| public String getPathImage() { | |||||
| return pathImage; | |||||
| } | |||||
| public void setPathImage(String pathImage) { | |||||
| this.pathImage = pathImage; | |||||
| } | |||||
| public TBCodeStatusEnum getStatus() { | |||||
| return status; | |||||
| } | |||||
| public void setStatus(TBCodeStatusEnum status) { | |||||
| this.status = status; | |||||
| } | |||||
| public Instant getExpiredDate() { | |||||
| return expiredDate; | |||||
| } | |||||
| public void setExpiredDate(Instant expiredDate) { | |||||
| this.expiredDate = expiredDate; | |||||
| } | |||||
| } |
| import vn.azteam.tpf.service.TBCodeDetailsService; | import vn.azteam.tpf.service.TBCodeDetailsService; | ||||
| import vn.azteam.tpf.service.dto.TBCodeDetailsDTO; | import vn.azteam.tpf.service.dto.TBCodeDetailsDTO; | ||||
| import vn.azteam.tpf.service.mapper.TBCodeDetailsMapper; | import vn.azteam.tpf.service.mapper.TBCodeDetailsMapper; | ||||
| import vn.azteam.tpf.web.rest.errors.BadRequestAlertException; | |||||
| import java.time.Instant; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Optional; | |||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
| /** | /** | ||||
| return tbCodes.stream().map(tBCodeDetailsMapper::toDto).collect(Collectors.toList()); | return tbCodes.stream().map(tBCodeDetailsMapper::toDto).collect(Collectors.toList()); | ||||
| } | } | ||||
| @Transactional(readOnly = true) | |||||
| public void updateNumberScan(String code) throws BadRequestAlertException { | |||||
| Optional<TBCodeDetails> tbCodeDetailsOptional = tbCodeDetailsRepository.findByCode(code); | |||||
| if (tbCodeDetailsOptional.isPresent()) { | |||||
| TBCodeDetails tbCodeDetails = tbCodeDetailsOptional.get(); | |||||
| if(tbCodeDetails.getTbCode() != null) { | |||||
| } | |||||
| Integer numberScan = tbCodeDetails.getNumberScan(); | |||||
| tbCodeDetails.setNumberScan(numberScan.equals(0) ? 1 : numberScan + 1); | |||||
| tbCodeDetails.setLastUpdatedDate(Instant.now()); | |||||
| tbCodeDetailsRepository.save(tbCodeDetails); | |||||
| log.debug("update number scan find by criteria code : {}", code); | |||||
| } else { | |||||
| throw new BadRequestAlertException("Not found", "tb code details to update with code:", code); | |||||
| } | |||||
| } | |||||
| } | } |
| import vn.azteam.tpf.service.TBCodeService; | import vn.azteam.tpf.service.TBCodeService; | ||||
| import vn.azteam.tpf.service.dto.TBCodeDTO; | import vn.azteam.tpf.service.dto.TBCodeDTO; | ||||
| import vn.azteam.tpf.service.mapper.TBCodeMapper; | import vn.azteam.tpf.service.mapper.TBCodeMapper; | ||||
| import vn.azteam.tpf.web.rest.errors.BadRequestAlertException; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Optional; | |||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
| /** | /** | ||||
| private final TBCodeSearchRepository tBCodeSearchRepository; | private final TBCodeSearchRepository tBCodeSearchRepository; | ||||
| public TBCodeServiceImpl(TBCodeRepository tbCodeRepository, TBCodeMapper tBCodeMapper, TBCodeSearchRepository tBCodeSearchRepository) { | |||||
| public TBCodeServiceImpl(TBCodeRepository tbCodeRepository, | |||||
| TBCodeMapper tBCodeMapper, TBCodeSearchRepository tBCodeSearchRepository) { | |||||
| this.tbCodeRepository = tbCodeRepository; | this.tbCodeRepository = tbCodeRepository; | ||||
| this.tBCodeMapper = tBCodeMapper; | this.tBCodeMapper = tBCodeMapper; | ||||
| this.tBCodeSearchRepository = tBCodeSearchRepository; | this.tBCodeSearchRepository = tBCodeSearchRepository; | ||||
| tbCodes = tbCodeRepository.saveAll(tbCodes); | tbCodes = tbCodeRepository.saveAll(tbCodes); | ||||
| return tbCodes.stream().map(tBCodeMapper::toDto).collect(Collectors.toList()); | return tbCodes.stream().map(tBCodeMapper::toDto).collect(Collectors.toList()); | ||||
| } | } | ||||
| @Override | |||||
| @Transactional(readOnly = true) | |||||
| public Optional<TBCodeDTO> findOne(Long id) { | |||||
| log.debug("Request to get TBCode : {}", id); | |||||
| return tbCodeRepository.findOneWithEagerRelationships(id) | |||||
| .map(tBCodeMapper::toDto); | |||||
| } | |||||
| @Override | |||||
| @Transactional(readOnly = true) | |||||
| public Optional<TBCodeDTO> updateStatusTBCode(TBCodeDTO tbCodeDTO) { | |||||
| log.debug("Request to updateTBCode TBCode id: {}", tbCodeDTO.getId()); | |||||
| Optional<TBCode> tbCodeOptional = tbCodeRepository.findById(tbCodeDTO.getId()); | |||||
| if (!tbCodeOptional.isPresent()) { | |||||
| throw new BadRequestAlertException("Not found TBCode", "", | |||||
| tbCodeDTO.getId().toString()); | |||||
| } | |||||
| TBCode tbCode = tBCodeMapper.toEntity(tbCodeDTO); | |||||
| tbCode = tbCodeRepository.save(tbCode); | |||||
| return Optional.ofNullable(tBCodeMapper.toDto(tbCode)); | |||||
| } | |||||
| } | } |
| package vn.azteam.tpf.service.mapper; | package vn.azteam.tpf.service.mapper; | ||||
| import org.mapstruct.Mapper; | import org.mapstruct.Mapper; | ||||
| import org.mapstruct.Mapping; | |||||
| import vn.azteam.tpf.domain.TBCodeDetails; | import vn.azteam.tpf.domain.TBCodeDetails; | ||||
| import vn.azteam.tpf.service.dto.TBCodeDetailsDTO; | import vn.azteam.tpf.service.dto.TBCodeDetailsDTO; | ||||
| @Mapper(componentModel = "spring", uses = {}) | |||||
| @Mapper(componentModel = "spring", uses = {TBDetailUserMapper.class}) | |||||
| public interface TBCodeDetailsMapper extends EntityMapper<TBCodeDetailsDTO, TBCodeDetails> { | public interface TBCodeDetailsMapper extends EntityMapper<TBCodeDetailsDTO, TBCodeDetails> { | ||||
| @Mapping(source = "createdBy.id", target = "createdById") | |||||
| @Mapping(source = "modifiedBy.id", target = "modifiedById") | |||||
| @Mapping(source = "deletedBy.id", target = "deletedById") | |||||
| TBCodeDetailsDTO toDto(TBCodeDetails tBCodeDetails); | |||||
| @Mapping(source = "tbCode", target = "tbCode") | |||||
| @Mapping(source = "createdById", target = "createdBy") | |||||
| @Mapping(source = "modifiedById", target = "modifiedBy") | |||||
| @Mapping(source = "deletedById", target = "deletedBy") | |||||
| TBCodeDetails toEntity(TBCodeDetailsDTO tBCodeDetailsDTO); | |||||
| default TBCodeDetails fromId(Long id) { | |||||
| if (id == null) { | |||||
| return null; | |||||
| } | |||||
| TBCodeDetails tBCodeDetails = new TBCodeDetails(); | |||||
| tBCodeDetails.setId(id); | |||||
| return tBCodeDetails; | |||||
| } | |||||
| } | } |
| package vn.azteam.tpf.service.mapper; | package vn.azteam.tpf.service.mapper; | ||||
| import org.mapstruct.Mapper; | import org.mapstruct.Mapper; | ||||
| import org.mapstruct.Mapping; | |||||
| import vn.azteam.tpf.domain.TBCode; | import vn.azteam.tpf.domain.TBCode; | ||||
| import vn.azteam.tpf.domain.TBCodeDetails; | |||||
| import vn.azteam.tpf.service.dto.TBCodeDTO; | import vn.azteam.tpf.service.dto.TBCodeDTO; | ||||
| @Mapper(componentModel = "spring", uses = {}) | |||||
| @Mapper(componentModel = "spring", uses = {TBDetailUserMapper.class}) | |||||
| public interface TBCodeMapper extends EntityMapper<TBCodeDTO, TBCode> { | public interface TBCodeMapper extends EntityMapper<TBCodeDTO, TBCode> { | ||||
| @Mapping(source = "createdBy.id", target = "createdById") | |||||
| @Mapping(source = "modifiedBy.id", target = "modifiedById") | |||||
| @Mapping(source = "deletedBy.id", target = "deletedById") | |||||
| TBCodeDTO toDto(TBCode tbCode); | TBCodeDTO toDto(TBCode tbCode); | ||||
| @Mapping(source = "tbCrop", target = "tbCrop") | |||||
| @Mapping(source = "createdById", target = "createdBy") | |||||
| @Mapping(source = "modifiedById", target = "modifiedBy") | |||||
| @Mapping(source = "deletedById", target = "deletedBy") | |||||
| TBCode toEntity(TBCodeDTO tBCodeDTO); | |||||
| default TBCode fromId(Long id) { | |||||
| if (id == null) { | |||||
| return null; | |||||
| } | |||||
| TBCode tBCode = new TBCode(); | |||||
| tBCode.setId(id); | |||||
| return tBCode; | |||||
| } | |||||
| } | } |
| package vn.azteam.tpf.web.rest; | package vn.azteam.tpf.web.rest; | ||||
| import com.codahale.metrics.annotation.Timed; | |||||
| import io.searchbox.strings.StringUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.http.ResponseEntity; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.PathVariable; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
| import vn.azteam.tpf.service.TBCodeDetailsQueryService; | import vn.azteam.tpf.service.TBCodeDetailsQueryService; | ||||
| this.userRoleUtil = userRoleUtil; | this.userRoleUtil = userRoleUtil; | ||||
| this.pageableUtil = pageableUtil; | this.pageableUtil = pageableUtil; | ||||
| } | } | ||||
| @GetMapping("/tb-codes-scan/{code}") | |||||
| @Timed | |||||
| public ResponseEntity<?> getTBCodeScan(@PathVariable String code) { | |||||
| if (StringUtils.isBlank(code)) { | |||||
| return (ResponseEntity<?>) ResponseEntity.badRequest(); | |||||
| } | |||||
| tBCodeDetailsService.updateNumberScan(code); | |||||
| return ResponseEntity.ok().build(); | |||||
| } | |||||
| } | } |
| package vn.azteam.tpf.web.rest; | package vn.azteam.tpf.web.rest; | ||||
| import com.codahale.metrics.annotation.Timed; | import com.codahale.metrics.annotation.Timed; | ||||
| import io.github.jhipster.web.util.ResponseUtil; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| * @param criteria the criterias which the requested entities should match | * @param criteria the criterias which the requested entities should match | ||||
| * @return the ResponseEntity with status 200 (OK) and the list of tBCode in body | * @return the ResponseEntity with status 200 (OK) and the list of tBCode in body | ||||
| */ | */ | ||||
| @GetMapping("/tb-codes-dropdown-list") | |||||
| @GetMapping("/tb-codes/dropdown-list") | |||||
| @Timed | @Timed | ||||
| public ResponseEntity<List<TBCodeDTO>> getAllTBCodesForDropdown(TBCodeCriteria criteria) { | public ResponseEntity<List<TBCodeDTO>> getAllTBCodesForDropdown(TBCodeCriteria criteria) { | ||||
| log.debug("REST request to get TBCodes by criteria: {}", criteria); | log.debug("REST request to get TBCodes by criteria: {}", criteria); | ||||
| tBCodeDTO.setCreatedDate(Instant.now()); | tBCodeDTO.setCreatedDate(Instant.now()); | ||||
| tBCodeDTO.setCreatedById(currentUser.getUserId()); | tBCodeDTO.setCreatedById(currentUser.getUserId()); | ||||
| tBCodeDTO.setStatus(TBCodeStatusEnum.NEW); | tBCodeDTO.setStatus(TBCodeStatusEnum.NEW); | ||||
| tBCodeDTO.setExpiredDate(tBCodeCreationDTO.getExpiredDate()); | |||||
| TBCodeDTO result = null; | TBCodeDTO result = null; | ||||
| Boolean hasViolationException = false; | Boolean hasViolationException = false; | ||||
| do { | do { | ||||
| throw new RuntimeException(); | throw new RuntimeException(); | ||||
| } | } | ||||
| } | } | ||||
| @GetMapping("/tb-codes/{id}") | |||||
| @Timed | |||||
| public ResponseEntity<TBCodeDTO> getTBCodes(@PathVariable Long id) { | |||||
| log.debug("REST request to get TBCode : {}", id); | |||||
| Optional<TBCodeDTO> tBCropDTO = tBCodeService.findOne(id); | |||||
| //@CUONGLT - Filter scope customer's data | |||||
| // if (!userRoleUtil.currentUserHasPermissionByCropId(id)) { | |||||
| // throw new BadRequestAlertException("1018", ENTITY_NAME, "1018"); | |||||
| // } | |||||
| return ResponseUtil.wrapOrNotFound(tBCropDTO); | |||||
| } | |||||
| /** | |||||
| * Add or delete crop's person in charges | |||||
| * | |||||
| * @param cropPersonInChargeDTO | |||||
| * @return | |||||
| */ | |||||
| @PutMapping("/tb-codes/update/{id}/status/{status}") | |||||
| @Timed | |||||
| public ResponseEntity<TBCodeDTO> updateTBCode(@PathVariable Long id, String status) { | |||||
| log.debug("REST request to update tb codes : {}, status {} ", id, status); | |||||
| if (id == null || StringUtils.isBlank(status)) { | |||||
| throw new BadRequestAlertException("1039", ENTITY_NAME, "1039"); | |||||
| } | |||||
| try { | |||||
| TBCodeStatusEnum.valueOf(status); | |||||
| } catch (Exception exception) { | |||||
| throw new BadRequestAlertException("1039", ENTITY_NAME, "1039"); | |||||
| } | |||||
| UserDTO currentUser = userService.getCurrentUserDTO().get(); | |||||
| TBCodeDTO tbCodeDTO = new TBCodeDTO(); | |||||
| tbCodeDTO.setId(id); | |||||
| tbCodeDTO.setModifiedDate(Instant.now()); | |||||
| tbCodeDTO.setModifiedById(currentUser.getId()); | |||||
| tbCodeDTO.setStatus(TBCodeStatusEnum.valueOf(status)); | |||||
| Optional<TBCodeDTO> tBCodeUpdated = tBCodeService.updateStatusTBCode(tbCodeDTO); | |||||
| // if (null != tBCropDTO) { | |||||
| // sendNotificationPersonInCharge(cropPersonInChargeDTO, listAssignmentPrev); | |||||
| // } | |||||
| return ResponseUtil.wrapOrNotFound(tBCodeUpdated); | |||||
| } | |||||
| } | } |
| <constraints nullable="true" /> | <constraints nullable="true" /> | ||||
| </column> | </column> | ||||
| <column name="last_updated_date" type="timestamp"> | |||||
| <constraints nullable="true" /> | |||||
| </column> | |||||
| <column name="created_date" type="timestamp"> | <column name="created_date" type="timestamp"> | ||||
| <constraints nullable="true" /> | <constraints nullable="true" /> | ||||
| </column> | </column> |