| @@ -1,5 +1,6 @@ | |||
| package vn.azteam.tpf.domain; | |||
| import com.fasterxml.jackson.annotation.JsonIgnore; | |||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |||
| import org.hibernate.annotations.Cache; | |||
| import org.hibernate.annotations.CacheConcurrencyStrategy; | |||
| @@ -23,6 +24,12 @@ public class TBCode implements Serializable { | |||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | |||
| private Long id; | |||
| @JsonIgnore | |||
| @OneToOne | |||
| @MapsId | |||
| @JoinColumn(name = "tb_crop_id") | |||
| private TBCrop tbCrop; | |||
| @Column(name = "code") | |||
| private String code; | |||
| @@ -182,4 +189,12 @@ public class TBCode implements Serializable { | |||
| public void setDeletedBy(TBDetailUser deletedBy) { | |||
| this.deletedBy = deletedBy; | |||
| } | |||
| public TBCrop getTbCrop() { | |||
| return tbCrop; | |||
| } | |||
| public void setTbCrop(TBCrop tbCrop) { | |||
| this.tbCrop = tbCrop; | |||
| } | |||
| } | |||
| @@ -98,12 +98,16 @@ public class TBCrop implements Serializable { | |||
| inverseJoinColumns = @JoinColumn(name = "tb_detail_users_id"/*, referencedColumnName = "id"*/)) | |||
| private Set<TBDetailUser> tbDetailUsers = new HashSet<>(); | |||
| @ManyToMany | |||
| @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) | |||
| @JoinTable(name = "tb_crop_code", | |||
| joinColumns = @JoinColumn(name = "tb_crop_id"/*, referencedColumnName = "id"*/), | |||
| inverseJoinColumns = @JoinColumn(name = "tb_code_id"/*, referencedColumnName = "id"*/)) | |||
| private Set<TBCode> tbCodes = new HashSet<>(); | |||
| @OneToOne(mappedBy = "tbCrop", cascade = CascadeType.ALL) | |||
| @PrimaryKeyJoinColumn | |||
| private TBCode tbCode; | |||
| // @ManyToMany | |||
| // @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) | |||
| // @JoinTable(name = "tb_crop_code", | |||
| // joinColumns = @JoinColumn(name = "tb_crop_id"/*, referencedColumnName = "id"*/), | |||
| // inverseJoinColumns = @JoinColumn(name = "tb_code_id"/*, referencedColumnName = "id"*/)) | |||
| // private Set<TBCode> tbCodes = new HashSet<>(); | |||
| // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove | |||
| public Long getId() { | |||
| @@ -374,6 +378,15 @@ public class TBCrop implements Serializable { | |||
| } | |||
| // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove | |||
| public TBCode getTbCode() { | |||
| return tbCode; | |||
| } | |||
| public void setTbCode(TBCode tbCode) { | |||
| this.tbCode = tbCode; | |||
| } | |||
| @Override | |||
| public boolean equals(Object o) { | |||
| if (this == o) { | |||
| @@ -0,0 +1,7 @@ | |||
| package vn.azteam.tpf.repository.search; | |||
| import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; | |||
| import vn.azteam.tpf.domain.TBCodeDetails; | |||
| public interface TBCodeDetailsSearchRepository extends ElasticsearchRepository<TBCodeDetails, Long> { | |||
| } | |||
| @@ -0,0 +1,7 @@ | |||
| package vn.azteam.tpf.repository.search; | |||
| import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; | |||
| import vn.azteam.tpf.domain.TBCode; | |||
| public interface TBCodeSearchRepository extends ElasticsearchRepository<TBCode, Long> { | |||
| } | |||
| @@ -0,0 +1,15 @@ | |||
| package vn.azteam.tpf.service; | |||
| import vn.azteam.tpf.service.dto.TBCodeDetailsDTO; | |||
| import java.util.List; | |||
| /** | |||
| * Service Interface for managing TBCodeDetailsService. | |||
| */ | |||
| public interface TBCodeDetailsService { | |||
| TBCodeDetailsDTO save(TBCodeDetailsDTO tBCodeDetailsDTO); | |||
| List<TBCodeDetailsDTO> saveAll(List<TBCodeDetailsDTO> tBCodeDetailsDTOs); | |||
| } | |||
| @@ -1,21 +1,17 @@ | |||
| package vn.azteam.tpf.service; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.Pageable; | |||
| import vn.azteam.tpf.service.dto.CropPersonInChargeDTO; | |||
| import vn.azteam.tpf.service.dto.TBCropDTO; | |||
| import vn.azteam.tpf.service.dto.TBCustomerHasCropTypeDTO; | |||
| import vn.azteam.tpf.service.dto.TBCodeDTO; | |||
| import java.util.List; | |||
| import java.util.Optional; | |||
| /** | |||
| * Service Interface for managing TBCode. | |||
| */ | |||
| public interface TBCodeService { | |||
| // TBCropDTO save(TBCropDTO tBCropDTO); | |||
| // | |||
| // | |||
| TBCodeDTO save(TBCodeDTO tBCodeDTO); | |||
| List<TBCodeDTO> saveAll(List<TBCodeDTO> tBCodeDTOs); | |||
| // /** | |||
| // * Update crop's PIC | |||
| // * @param cropPersonInChargeDTO | |||
| @@ -366,15 +366,15 @@ public class TBCropQueryService extends QueryService<TBCrop> { | |||
| return ageDay; | |||
| } | |||
| public String generateRandomStringFromUUID(int stringLength) { | |||
| String qrCode = UUID | |||
| .randomUUID() | |||
| .toString() | |||
| .replace("-", "") | |||
| .substring(0, stringLength) | |||
| .toUpperCase(); | |||
| return qrCode; | |||
| } | |||
| // public String generateRandomStringFromUUID(int stringLength) { | |||
| // String qrCode = UUID | |||
| // .randomUUID() | |||
| // .toString() | |||
| // .replace("-", "") | |||
| // .substring(0, stringLength) | |||
| // .toUpperCase(); | |||
| // return qrCode; | |||
| // } | |||
| /** | |||
| * Get all history of activities | |||
| @@ -0,0 +1,46 @@ | |||
| package vn.azteam.tpf.service.dto; | |||
| import java.io.Serializable; | |||
| public class TBCodeCreationDTO implements Serializable { | |||
| private Long tBCropId; | |||
| private String pathImage; | |||
| private Integer quantity; | |||
| private String description; | |||
| public Long gettBCropId() { | |||
| return tBCropId; | |||
| } | |||
| public void settBCropId(Long tBCropId) { | |||
| this.tBCropId = tBCropId; | |||
| } | |||
| public String getPathImage() { | |||
| return pathImage; | |||
| } | |||
| public void setPathImage(String pathImage) { | |||
| this.pathImage = pathImage; | |||
| } | |||
| 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; | |||
| } | |||
| } | |||
| @@ -12,6 +12,8 @@ public class TBCodeDTO implements Serializable { | |||
| private Long id; | |||
| private Long tBCropId; | |||
| private String code; | |||
| private Integer quantity; | |||
| @@ -149,4 +151,12 @@ public class TBCodeDTO implements Serializable { | |||
| public void setTbCodeDetails(Set<TBCodeDetails> tbCodeDetails) { | |||
| this.tbCodeDetails = tbCodeDetails; | |||
| } | |||
| public Long gettBCropId() { | |||
| return tBCropId; | |||
| } | |||
| public void settBCropId(Long tBCropId) { | |||
| this.tBCropId = tBCropId; | |||
| } | |||
| } | |||
| @@ -17,7 +17,7 @@ public class TBCodeDetailsDTO implements Serializable { | |||
| private TBCodeDetailsStatusEnum status; | |||
| private Instant expiredDate; | |||
| // private Instant expiredDate; | |||
| private Instant createdDate; | |||
| @@ -71,14 +71,6 @@ public class TBCodeDetailsDTO implements Serializable { | |||
| this.status = status; | |||
| } | |||
| public Instant getExpiredDate() { | |||
| return expiredDate; | |||
| } | |||
| public void setExpiredDate(Instant expiredDate) { | |||
| this.expiredDate = expiredDate; | |||
| } | |||
| public Instant getCreatedDate() { | |||
| return createdDate; | |||
| } | |||
| @@ -1,8 +1,19 @@ | |||
| package vn.azteam.tpf.service.impl; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import vn.azteam.tpf.domain.TBCodeDetails; | |||
| import vn.azteam.tpf.repository.TBCodeDetailsRepository; | |||
| import vn.azteam.tpf.repository.search.TBCodeDetailsSearchRepository; | |||
| import vn.azteam.tpf.service.TBCodeDetailsService; | |||
| import vn.azteam.tpf.service.dto.TBCodeDetailsDTO; | |||
| import vn.azteam.tpf.service.mapper.TBCodeDetailsMapper; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.stream.Collectors; | |||
| /** | |||
| * Service Implementation for managing TBCodeDetails. | |||
| @@ -11,4 +22,40 @@ import vn.azteam.tpf.service.TBCodeDetailsService; | |||
| @Service | |||
| @Transactional | |||
| public class TBCodeDetailsImpl implements TBCodeDetailsService { | |||
| private final Logger log = LoggerFactory.getLogger(TBCodeDetailsImpl.class); | |||
| private final TBCodeDetailsRepository tbCodeDetailsRepository; | |||
| private final TBCodeDetailsMapper tBCodeDetailsMapper; | |||
| private final TBCodeDetailsSearchRepository tBCodeDetailsSearchRepository; | |||
| public TBCodeDetailsImpl(TBCodeDetailsRepository tbCodeDetailsRepository, TBCodeDetailsMapper tBCodeDetailsMapper, TBCodeDetailsSearchRepository tBCodeDetailsSearchRepository) { | |||
| this.tbCodeDetailsRepository = tbCodeDetailsRepository; | |||
| this.tBCodeDetailsMapper = tBCodeDetailsMapper; | |||
| this.tBCodeDetailsSearchRepository = tBCodeDetailsSearchRepository; | |||
| } | |||
| @Override | |||
| public TBCodeDetailsDTO save(TBCodeDetailsDTO tBCodeDetailsDTO) { | |||
| log.debug("Request to save TBCodeDetailsDTO : {}", tBCodeDetailsDTO); | |||
| TBCodeDetails tBCodeDetails = tBCodeDetailsMapper.toEntity(tBCodeDetailsDTO); | |||
| tBCodeDetails = tbCodeDetailsRepository.save(tBCodeDetails); | |||
| TBCodeDetailsDTO result = tBCodeDetailsMapper.toDto(tBCodeDetails); | |||
| tBCodeDetailsSearchRepository.save(tBCodeDetails); | |||
| return result; | |||
| } | |||
| @Override | |||
| public List<TBCodeDetailsDTO> saveAll(List<TBCodeDetailsDTO> tBCodeDetailsDTOs) { | |||
| List<TBCodeDetails> tbCodes = new ArrayList<>(); | |||
| for (TBCodeDetailsDTO tBCodeDetailsDTO : tBCodeDetailsDTOs) { | |||
| TBCodeDetails tbCodeDetails = tBCodeDetailsMapper.toEntity(tBCodeDetailsDTO); | |||
| tbCodes.add(tbCodeDetails); | |||
| } | |||
| tbCodes = tbCodeDetailsRepository.saveAll(tbCodes); | |||
| return tbCodes.stream().map(tBCodeDetailsMapper::toDto).collect(Collectors.toList()); | |||
| } | |||
| } | |||
| @@ -1,8 +1,19 @@ | |||
| package vn.azteam.tpf.service.impl; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import vn.azteam.tpf.domain.TBCode; | |||
| import vn.azteam.tpf.repository.TBCodeRepository; | |||
| import vn.azteam.tpf.repository.search.TBCodeSearchRepository; | |||
| import vn.azteam.tpf.service.TBCodeService; | |||
| import vn.azteam.tpf.service.dto.TBCodeDTO; | |||
| import vn.azteam.tpf.service.mapper.TBCodeMapper; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.stream.Collectors; | |||
| /** | |||
| * Service Implementation for managing TBCode. | |||
| @@ -12,4 +23,41 @@ import vn.azteam.tpf.service.TBCodeService; | |||
| @Service | |||
| @Transactional | |||
| public class TBCodeServiceImpl implements TBCodeService { | |||
| private final Logger log = LoggerFactory.getLogger(TBCodeServiceImpl.class); | |||
| private final TBCodeRepository tbCodeRepository; | |||
| private final TBCodeMapper tBCodeMapper; | |||
| private final TBCodeSearchRepository tBCodeSearchRepository; | |||
| public TBCodeServiceImpl(TBCodeRepository tbCodeRepository, TBCodeMapper tBCodeMapper, TBCodeSearchRepository tBCodeSearchRepository) { | |||
| this.tbCodeRepository = tbCodeRepository; | |||
| this.tBCodeMapper = tBCodeMapper; | |||
| this.tBCodeSearchRepository = tBCodeSearchRepository; | |||
| } | |||
| @Override | |||
| public TBCodeDTO save(TBCodeDTO tBCodeDTO) { | |||
| log.debug("Request to save TBCodeDTO : {}", tBCodeDTO); | |||
| TBCode tbCode = tBCodeMapper.toEntity(tBCodeDTO); | |||
| tbCode = tbCodeRepository.save(tbCode); | |||
| TBCodeDTO result = tBCodeMapper.toDto(tbCode); | |||
| tBCodeSearchRepository.save(tbCode); | |||
| return result; | |||
| } | |||
| @Override | |||
| public List<TBCodeDTO> saveAll(List<TBCodeDTO> tBCodeDTOs) { | |||
| List<TBCode> tbCodes = new ArrayList<>(); | |||
| for (TBCodeDTO tbCodeDTO : tBCodeDTOs) { | |||
| TBCode tbCode = tBCodeMapper.toEntity(tbCodeDTO); | |||
| tbCodes.add(tbCode); | |||
| } | |||
| tbCodes = tbCodeRepository.saveAll(tbCodes); | |||
| return tbCodes.stream().map(tBCodeMapper::toDto).collect(Collectors.toList()); | |||
| } | |||
| } | |||
| @@ -0,0 +1,185 @@ | |||
| package vn.azteam.tpf.web.rest; | |||
| import com.codahale.metrics.annotation.Timed; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.Pageable; | |||
| import org.springframework.http.HttpHeaders; | |||
| import org.springframework.http.ResponseEntity; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import vn.azteam.tpf.domain.TBCodeDetailsStatusEnum; | |||
| import vn.azteam.tpf.domain.TBCodeStatusEnum; | |||
| import vn.azteam.tpf.service.*; | |||
| 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; | |||
| import vn.azteam.tpf.web.rest.util.HeaderUtil; | |||
| import vn.azteam.tpf.web.rest.util.PaginationUtil; | |||
| import vn.azteam.tpf.web.rest.util.RandomStringUtil; | |||
| import java.net.URI; | |||
| import java.net.URISyntaxException; | |||
| import java.time.Instant; | |||
| import java.util.ArrayList; | |||
| import java.util.Comparator; | |||
| import java.util.List; | |||
| import java.util.Optional; | |||
| import java.util.stream.Collectors; | |||
| @RestController | |||
| @RequestMapping("/api") | |||
| public class TBCodeResource { | |||
| private static final String ENTITY_NAME = "tBCode"; | |||
| private final Logger log = LoggerFactory.getLogger(TBCodeResource.class); | |||
| private final TBCodeService tBCodeService; | |||
| private final TBCodeDetailsService tbCodeDetailsService; | |||
| private final TBCropService tBCropService; | |||
| private final UserService userService; | |||
| private final TBCodeQueryService tBCodeQueryService; | |||
| private final UserRoleUtil userRoleUtil; | |||
| private final PageableUtil pageableUtil; | |||
| public TBCodeResource(TBCodeService tBCodeService, TBCodeDetailsService tbCodeDetailsService, TBCropService tBCropService, UserService userService, TBCodeQueryService tBCodeQueryService, UserRoleUtil userRoleUtil, PageableUtil pageableUtil) { | |||
| this.tBCodeService = tBCodeService; | |||
| this.tbCodeDetailsService = tbCodeDetailsService; | |||
| this.tBCropService = tBCropService; | |||
| this.userService = userService; | |||
| this.tBCodeQueryService = tBCodeQueryService; | |||
| this.userRoleUtil = userRoleUtil; | |||
| this.pageableUtil = pageableUtil; | |||
| } | |||
| /** | |||
| * GET /tb-codes-dropdown-list : get all the tBCode for dropdown options. | |||
| * | |||
| * @param criteria the criterias which the requested entities should match | |||
| * @return the ResponseEntity with status 200 (OK) and the list of tBCode in body | |||
| */ | |||
| @GetMapping("/tb-codes-dropdown-list") | |||
| @Timed | |||
| public ResponseEntity<List<TBCodeDTO>> getAllTBCodesForDropdown(TBCodeCriteria criteria) { | |||
| log.debug("REST request to get TBCodes by criteria: {}", criteria); | |||
| Page<TBCodeDTO> page = tBCodeQueryService.findByCriteria(criteria, Pageable.unpaged()); | |||
| //Authorize get list crop by customer of current user | |||
| List<TBCodeDTO> result = page.getContent().stream() | |||
| .filter(item -> userRoleUtil.currentUserHasPermissionByCustomerId(item.getId()) | |||
| && userRoleUtil.currentUserHasPermissionByCropId(item.getId())) | |||
| .sorted(Comparator.comparing( | |||
| TBCodeDTO::getCreatedDate, | |||
| Comparator.nullsFirst(Comparator.naturalOrder())).reversed()) | |||
| .collect(Collectors.toList()); | |||
| return ResponseEntity.ok().headers(null).body(result); | |||
| } | |||
| /** | |||
| * GET /tb-codes : get all the tBCodes. | |||
| * | |||
| * @param pageable the pagination information | |||
| * @param criteria the criterias which the requested entities should match | |||
| * @return the ResponseEntity with status 200 (OK) and the list of tBCrops in body | |||
| */ | |||
| @GetMapping("/tb-codes") | |||
| @Timed | |||
| public ResponseEntity<List<TBCodeDTO>> getAllTBCodes(TBCodeCriteria criteria, Pageable pageable) { | |||
| log.debug("REST request to get TBCrops by criteria: {}", criteria); | |||
| Page<TBCodeDTO> page = tBCodeQueryService.findByCriteria(criteria, Pageable.unpaged()); | |||
| //Authorize get list crop by customer of current user | |||
| List<TBCodeDTO> result = page.getContent().stream() | |||
| .filter(item -> userRoleUtil.currentUserHasPermissionByCustomerId(item.getId()) | |||
| && userRoleUtil.currentUserHasPermissionByCropId(item.getId())) | |||
| .sorted(Comparator.comparing( | |||
| TBCodeDTO::getCreatedDate, | |||
| Comparator.nullsFirst(Comparator.naturalOrder())).reversed()) | |||
| .collect(Collectors.toList()); | |||
| Page<TBCodeDTO> pageResult = pageableUtil.changeTBCodeDTOToPageFromList(result, pageable); | |||
| for (TBCodeDTO itemResult : result) { | |||
| //logger.error("Start date: " + itemResult.getStartDate()); | |||
| } | |||
| HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(pageResult, "/api/tb-codes"); | |||
| return ResponseEntity.ok().headers(headers).body(pageResult.getContent()); | |||
| } | |||
| @PostMapping("/tb-codes") | |||
| @Timed | |||
| public ResponseEntity<TBCodeDTO> createTBCrop(@RequestBody TBCodeCreationDTO tBCodeCreationDTO) throws URISyntaxException { | |||
| log.debug("REST request to save TBCode : {}", tBCodeCreationDTO); | |||
| //Set created by to current user login | |||
| UserDTO currentUser = userService.getCurrentUserDTO().get(); | |||
| if (tBCodeCreationDTO.gettBCropId() != null) { | |||
| throw new BadRequestAlertException("1047", ENTITY_NAME, "1047"); | |||
| } | |||
| if (tBCodeCreationDTO.getQuantity() != null && tBCodeCreationDTO.getQuantity() <= 0) { | |||
| throw new BadRequestAlertException("1047", ENTITY_NAME, "1047"); | |||
| } | |||
| Optional<TBCropDTO> tbCropDTO = tBCropService.findOne(tBCodeCreationDTO.gettBCropId()); | |||
| if (!tbCropDTO.isPresent()) { | |||
| throw new BadRequestAlertException("1019", ENTITY_NAME, "1019"); | |||
| } | |||
| try { | |||
| TBCodeDTO tBCodeDTO = new TBCodeDTO(); | |||
| tBCodeDTO.setDescription(StringUtils.isNotBlank(tBCodeCreationDTO.getDescription()) ? | |||
| tBCodeCreationDTO.getDescription() : ""); | |||
| tBCodeDTO.setQuantity(tBCodeCreationDTO.getQuantity()); | |||
| tBCodeDTO.setPathImage(StringUtils.isNotBlank(tBCodeCreationDTO.getPathImage()) ? | |||
| tBCodeCreationDTO.getPathImage() : ""); | |||
| tBCodeDTO.setCreatedDate(Instant.now()); | |||
| tBCodeDTO.setCreatedById(currentUser.getUserId()); | |||
| tBCodeDTO.setStatus(TBCodeStatusEnum.NEW); | |||
| TBCodeDTO result = null; | |||
| Boolean hasViolationException = false; | |||
| do { | |||
| try { | |||
| tBCodeDTO.setCode(RandomStringUtil.generateRandomStringFromUUID(8)); | |||
| result = tBCodeService.save(tBCodeDTO); | |||
| } catch (org.springframework.dao.DataIntegrityViolationException ex) { | |||
| if (ex.getMessage().contains("ux_tb_code_code")) { | |||
| hasViolationException = true; | |||
| } else { | |||
| throw ex; | |||
| } | |||
| } | |||
| } | |||
| while (hasViolationException); | |||
| if (result.getId() != null) { | |||
| List<TBCodeDetailsDTO> tbCodeDetailsDTOS = new ArrayList<>(); | |||
| for (int i = 1; i <= tBCodeCreationDTO.getQuantity(); i++) { | |||
| TBCodeDetailsDTO codeDetailsDTO = new TBCodeDetailsDTO(); | |||
| codeDetailsDTO.setCode(tBCodeDTO.getCode()); | |||
| codeDetailsDTO.setTbCode(tBCodeDTO); | |||
| codeDetailsDTO.setNumberScan(0); | |||
| codeDetailsDTO.setStatus(TBCodeDetailsStatusEnum.NEW); | |||
| codeDetailsDTO.setCreatedDate(Instant.now()); | |||
| tBCodeDTO.setCreatedById(currentUser.getUserId()); | |||
| tbCodeDetailsDTOS.add(codeDetailsDTO); | |||
| } | |||
| tbCodeDetailsService.saveAll(tbCodeDetailsDTOS); | |||
| } | |||
| return ResponseEntity.created(new URI("/api/tb-codes/" + result.getId())) | |||
| .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) | |||
| .body(result); | |||
| } catch (Exception exception) { | |||
| throw new RuntimeException(); | |||
| } | |||
| } | |||
| } | |||
| @@ -3,12 +3,19 @@ package vn.azteam.tpf.web.rest; | |||
| import com.codahale.metrics.annotation.Timed; | |||
| import io.github.jhipster.service.filter.LongFilter; | |||
| import io.github.jhipster.service.filter.StringFilter; | |||
| import io.swagger.v3.oas.annotations.security.SecurityRequirement; | |||
| import io.github.jhipster.web.util.ResponseUtil; | |||
| import org.apache.commons.logging.Log; | |||
| import org.apache.commons.logging.LogFactory; | |||
| import org.casbin.jcasbin.main.Enforcer; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.Pageable; | |||
| import org.springframework.http.HttpHeaders; | |||
| import org.springframework.http.HttpStatus; | |||
| import org.springframework.http.ResponseEntity; | |||
| import org.springframework.util.StringUtils; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import vn.azteam.tpf.service.*; | |||
| import vn.azteam.tpf.service.dto.*; | |||
| import vn.azteam.tpf.service.util.PageableUtil; | |||
| @@ -17,25 +24,19 @@ import vn.azteam.tpf.web.rest.errors.BadRequestAlertException; | |||
| import vn.azteam.tpf.web.rest.errors.ForbiddenException; | |||
| import vn.azteam.tpf.web.rest.util.HeaderUtil; | |||
| import vn.azteam.tpf.web.rest.util.PaginationUtil; | |||
| import io.github.jhipster.web.util.ResponseUtil; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.Pageable; | |||
| import org.springframework.http.HttpHeaders; | |||
| import org.springframework.http.ResponseEntity; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import vn.azteam.tpf.web.rest.util.RandomStringUtil; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.net.URI; | |||
| import java.net.URISyntaxException; | |||
| import java.time.Instant; | |||
| import java.util.*; | |||
| import java.util.Comparator; | |||
| import java.util.List; | |||
| import java.util.Optional; | |||
| import java.util.stream.Collectors; | |||
| import static vn.azteam.tpf.Constants.Constants.*; | |||
| import static vn.azteam.tpf.security.contants.Contants.*; | |||
| import static vn.azteam.tpf.security.contants.Contants.CUSID_API_KEY; | |||
| /** | |||
| * REST controller for managing TBCrop. | |||
| @@ -110,10 +111,10 @@ public class TBCropResource { | |||
| if (tBCropDTO.getId() != null) { | |||
| throw new BadRequestAlertException("1047", ENTITY_NAME, "1047"); | |||
| } | |||
| if(currentUser.getCustomerId() == null){ | |||
| if (currentUser.getCustomerId() == null) { | |||
| throw new BadRequestAlertException("1018", ENTITY_NAME, "1018"); | |||
| } | |||
| if(tBCropDTO.getTbCropTypeId() == null){ | |||
| if (tBCropDTO.getTbCropTypeId() == null) { | |||
| throw new BadRequestAlertException("1031", ENTITY_NAME, "1031"); | |||
| } | |||
| if (!userRoleUtil.currentUserHasPermissionByEntityId(tBCropDTO.getNetHouseId())) { | |||
| @@ -121,7 +122,7 @@ public class TBCropResource { | |||
| } | |||
| TBEntityDTO tbEntityDTO = tbEntityService.findOne(tBCropDTO.getNetHouseId()).get(); | |||
| if (currentUser.getCustomerId() != null | |||
| && !currentUser.getCustomerId().equals(tbEntityDTO.getTbCustomerId())){ | |||
| && !currentUser.getCustomerId().equals(tbEntityDTO.getTbCustomerId())) { | |||
| throw new BadRequestAlertException("1019", ENTITY_NAME, "1019"); | |||
| } | |||
| //Set created date to current timestamp | |||
| @@ -134,7 +135,7 @@ public class TBCropResource { | |||
| Boolean hasViolationException = false; | |||
| do { | |||
| try { | |||
| String qrCode = tBCropQueryService.generateRandomStringFromUUID(8); | |||
| String qrCode = RandomStringUtil.generateRandomStringFromUUID(8); | |||
| tBCropDTO.setQrCode(qrCode); | |||
| result = tBCropService.save(tBCropDTO); | |||
| } catch (org.springframework.dao.DataIntegrityViolationException ex) { | |||
| @@ -177,6 +178,7 @@ public class TBCropResource { | |||
| .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, tBCropDTO.getId().toString())) | |||
| .body(result); | |||
| } | |||
| /** | |||
| * GET /tb-crops-dropdown-list : get all the tBCrops for dropdown options. | |||
| * | |||
| @@ -200,6 +202,7 @@ public class TBCropResource { | |||
| return ResponseEntity.ok().headers(null).body(result); | |||
| } | |||
| /** | |||
| * GET /tb-crops : get all the tBCrops. | |||
| * | |||
| @@ -215,20 +218,21 @@ public class TBCropResource { | |||
| //Authorize get list crop by customer of current user | |||
| List<TBCropDTO> result = page.getContent().stream() | |||
| .filter(item -> userRoleUtil.currentUserHasPermissionByCustomerId(item.getId()) | |||
| && userRoleUtil.currentUserHasPermissionByCropId(item.getId())) | |||
| .sorted(Comparator.comparing( | |||
| TBCropDTO::getCreatedDate, | |||
| Comparator.nullsFirst(Comparator.naturalOrder())).reversed()) | |||
| .collect(Collectors.toList()); | |||
| .filter(item -> userRoleUtil.currentUserHasPermissionByCustomerId(item.getId()) | |||
| && userRoleUtil.currentUserHasPermissionByCropId(item.getId())) | |||
| .sorted(Comparator.comparing( | |||
| TBCropDTO::getCreatedDate, | |||
| Comparator.nullsFirst(Comparator.naturalOrder())).reversed()) | |||
| .collect(Collectors.toList()); | |||
| Page<TBCropDTO> pageResult = pageableUtil.changeTBCropDTOToPageFromList(result, pageable); | |||
| for(TBCropDTO itemResult : result) { | |||
| logger.error("Start date: " + itemResult.getStartDate()); | |||
| for (TBCropDTO itemResult : result) { | |||
| logger.error("Start date: " + itemResult.getStartDate()); | |||
| } | |||
| HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(pageResult, "/api/tb-crops"); | |||
| return ResponseEntity.ok().headers(headers).body(pageResult.getContent()); | |||
| } | |||
| @GetMapping("/ots/tb-crops-by-customer") | |||
| @Timed | |||
| public ResponseEntity<List<TBCropDTO>> getTBCropsByCustomer(HttpServletRequest request, TBCropCriteria criteria, Pageable pageable) { | |||
| @@ -243,12 +247,13 @@ public class TBCropResource { | |||
| .collect(Collectors.toList()); | |||
| Page<TBCropDTO> pageResult = pageableUtil.changeTBCropDTOToPageFromList(result, pageable); | |||
| for(TBCropDTO itemResult : result) { | |||
| logger.error("Start date: " + itemResult.getStartDate()); | |||
| for (TBCropDTO itemResult : result) { | |||
| logger.error("Start date: " + itemResult.getStartDate()); | |||
| } | |||
| HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(pageResult, "/api/ots/tb-crops-by-customer"); | |||
| return ResponseEntity.ok().headers(headers).body(pageResult.getContent()); | |||
| } | |||
| /** | |||
| * GET /tb-crops/:cropId : get the "id" tBCrop. | |||
| * | |||
| @@ -262,11 +267,12 @@ public class TBCropResource { | |||
| Long customer_id = Long.parseLong(request.getHeader(CUSID_API_KEY)); | |||
| Optional<TBCropDTO> tBCropDTO = tBCropService.findOne(cropId); | |||
| if (!tBCropDTO.get().getTbCustomerId().equals(customer_id)){ | |||
| if (!tBCropDTO.get().getTbCustomerId().equals(customer_id)) { | |||
| throw new ForbiddenException(); | |||
| } | |||
| return ResponseUtil.wrapOrNotFound(tBCropDTO); | |||
| } | |||
| /** | |||
| * GET /tb-crops/count : count all the tBCrops. | |||
| * | |||
| @@ -332,7 +338,7 @@ public class TBCropResource { | |||
| */ | |||
| @GetMapping("/ots/tb-crops-detail/{id}") | |||
| @Timed | |||
| public ResponseEntity<TBCropDetailDTO> getDetailTBCropForOts(@RequestParam(required=false) String type, @PathVariable Long id, HttpServletRequest request, Pageable pageable) { | |||
| public ResponseEntity<TBCropDetailDTO> getDetailTBCropForOts(@RequestParam(required = false) String type, @PathVariable Long id, HttpServletRequest request, Pageable pageable) { | |||
| log.debug("REST request to get TBCrop detail for app : {}", id); | |||
| return getCropDetailDTOResponseEntityOts(type, id, request, pageable); | |||
| @@ -467,7 +473,7 @@ public class TBCropResource { | |||
| && activity.getCreatedById() == null); | |||
| // Lo Uom | |||
| if(tBCropDTO.get().getTbCropTypeId() == 1) { | |||
| if (tBCropDTO.get().getTbCropTypeId() == 1) { | |||
| // Get sowing Date | |||
| TBActivityDTO nurseryActivity = allActivities.stream() | |||
| .sorted(Comparator.comparing( | |||
| @@ -479,7 +485,7 @@ public class TBCropResource { | |||
| if (nurseryActivity != null) { | |||
| tbCropDetailDTO.setSowingDate(nurseryActivity.getExecuteDate()); | |||
| List<TBObjectUpdateDTO> tbObjectUpdateDTOs = tbObjectUpdateService.findByTBActivityId(nurseryActivity.getId(), Pageable.unpaged()); | |||
| if(tbObjectUpdateDTOs!= null && tbObjectUpdateDTOs.size() > 0) { | |||
| if (tbObjectUpdateDTOs != null && tbObjectUpdateDTOs.size() > 0) { | |||
| tbObjectUpdateDTOs.forEach(item -> { | |||
| if (item.getTbObjectParameterDTO().getName().equals(THOI_GIAN_NGAM_HAT)) { | |||
| item.setIndex(item.getIndex() != null && !item.getIndex().isEmpty() ? item.getIndex() : "0"); | |||
| @@ -490,7 +496,7 @@ public class TBCropResource { | |||
| } | |||
| } | |||
| //Lo Trong | |||
| if(tBCropDTO.get().getTbCropTypeId() == 2) { | |||
| if (tBCropDTO.get().getTbCropTypeId() == 2) { | |||
| // Get planting Date | |||
| TBActivityDTO plantingActivity = allActivities.stream() | |||
| .sorted(Comparator.comparing( | |||
| @@ -504,16 +510,16 @@ public class TBCropResource { | |||
| List<Long> listActivities = allActivities.stream().map(TBActivityDTO::getId).collect(Collectors.toList()); | |||
| List<TBObjectUpdateDTO> tbObjectUpdateDTOs = tbObjectUpdateService.findByInListTBActivityId(listActivities, Pageable.unpaged()); | |||
| if(tbObjectUpdateDTOs!= null && tbObjectUpdateDTOs.size() > 0) { | |||
| if (tbObjectUpdateDTOs != null && tbObjectUpdateDTOs.size() > 0) { | |||
| tbObjectUpdateDTOs.forEach(item -> { | |||
| if (item.getTbObjectParameterDTO().getName().equals(SO_LUONG_CAY_TRONG)) { | |||
| item.setIndex(item.getIndex() != null && !item.getIndex().isEmpty() ? item.getIndex() : "0"); | |||
| tbCropDetailDTO.setNumberPlants(Integer.parseInt(item.getIndex().replaceAll("[^0-9]",""))); | |||
| tbCropDetailDTO.setNumberCurrentPlants(Integer.parseInt(item.getIndex().replaceAll("[^0-9]",""))); | |||
| tbCropDetailDTO.setNumberPlants(Integer.parseInt(item.getIndex().replaceAll("[^0-9]", ""))); | |||
| tbCropDetailDTO.setNumberCurrentPlants(Integer.parseInt(item.getIndex().replaceAll("[^0-9]", ""))); | |||
| } | |||
| if (item.getTbObjectParameterDTO().getName().equals(SO_LUONG_LOAI_BO)) { | |||
| item.setIndex(item.getIndex() != null && !item.getIndex().isEmpty() ? item.getIndex() : "0"); | |||
| Integer currentNumberPlants = tbCropDetailDTO.getNumberPlants() - Integer.parseInt(item.getIndex().replaceAll("[^0-9]","")); | |||
| Integer currentNumberPlants = tbCropDetailDTO.getNumberPlants() - Integer.parseInt(item.getIndex().replaceAll("[^0-9]", "")); | |||
| tbCropDetailDTO.setNumberCurrentPlants(currentNumberPlants > 0 ? currentNumberPlants : 0); | |||
| } | |||
| }); | |||
| @@ -522,7 +528,7 @@ public class TBCropResource { | |||
| //Filter assignment croptype by customer | |||
| if (currentUser.get().getCustomerId() != null) { | |||
| List<Long> ListActivityTypeId = tBCropService.getListActivityTypeIdByByCustomerAndCropType(currentUser.get().getCustomerId(),tBCropDTO.get().getTbCropTypeId()); | |||
| List<Long> ListActivityTypeId = tBCropService.getListActivityTypeIdByByCustomerAndCropType(currentUser.get().getCustomerId(), tBCropDTO.get().getTbCropTypeId()); | |||
| allActivities = allActivities.stream().filter(item -> ListActivityTypeId.contains(item.getActivityTypeId())).collect(Collectors.toList()); | |||
| } | |||
| if (isRequestedFromWeb) { | |||
| @@ -530,7 +536,7 @@ public class TBCropResource { | |||
| tBCropQueryService.getActivityTimeline(id, allActivities, pageable); | |||
| tbCropDetailDTO.setActivityTimeline(activityTimeline); | |||
| } else { | |||
| allActivities = pageableUtil.changeTBActivityDTOToPageFromList(allActivities,pageable).getContent(); | |||
| allActivities = pageableUtil.changeTBActivityDTOToPageFromList(allActivities, pageable).getContent(); | |||
| tbCropDetailDTO.setActivities(allActivities); | |||
| } | |||
| @@ -563,10 +569,10 @@ public class TBCropResource { | |||
| Pageable pageable) { | |||
| Long customerId = Long.parseLong(request.getHeader(CUSID_API_KEY)); | |||
| Optional<TBCropDTO> tBCropDTO = tBCropService.findOne(id); | |||
| if (!tBCropDTO.isPresent()){ | |||
| if (!tBCropDTO.isPresent()) { | |||
| throw new BadRequestAlertException("Customer not found", ENTITY_NAME, "idinvalid"); | |||
| } | |||
| if (!tBCropDTO.get().getTbCustomerId().equals(customerId)){ | |||
| if (!tBCropDTO.get().getTbCustomerId().equals(customerId)) { | |||
| throw new ForbiddenException(); | |||
| } | |||
| Optional<UserDTO> currentUser = userService.getCurrentUserDTO(); | |||
| @@ -592,11 +598,11 @@ public class TBCropResource { | |||
| && activity.getCreatedById() == null); | |||
| //Filter assignment croptype by customer | |||
| if (currentUser.get().getCustomerId() != null) { | |||
| List<Long> ListActivityTypeId = tBCropService.getListActivityTypeIdByByCustomerAndCropType(currentUser.get().getCustomerId(),tBCropDTO.get().getTbCropTypeId()); | |||
| List<Long> ListActivityTypeId = tBCropService.getListActivityTypeIdByByCustomerAndCropType(currentUser.get().getCustomerId(), tBCropDTO.get().getTbCropTypeId()); | |||
| allActivities = allActivities.stream().filter(item -> ListActivityTypeId.contains(item.getActivityTypeId())).collect(Collectors.toList()); | |||
| } | |||
| allActivities = pageableUtil.changeTBActivityDTOToPageFromList(allActivities,pageable).getContent(); | |||
| allActivities = pageableUtil.changeTBActivityDTOToPageFromList(allActivities, pageable).getContent(); | |||
| tbCropDetailDTO.setActivities(allActivities); | |||
| TBActivityDTO endActivity = allActivities.stream() | |||
| @@ -610,7 +616,7 @@ public class TBCropResource { | |||
| tbCropDetailDTO.setEndOfFarmingDate(endActivity.getExecuteDate()); | |||
| } | |||
| // Lo Uom | |||
| if(tBCropDTO.get().getTbCropTypeId() == 1) { | |||
| if (tBCropDTO.get().getTbCropTypeId() == 1) { | |||
| // Get sowing Date | |||
| TBActivityDTO nurseryActivity = allActivities.stream() | |||
| .sorted(Comparator.comparing( | |||
| @@ -622,7 +628,7 @@ public class TBCropResource { | |||
| if (nurseryActivity != null) { | |||
| tbCropDetailDTO.setSowingDate(nurseryActivity.getExecuteDate()); | |||
| List<TBObjectUpdateDTO> tbObjectUpdateDTOs = tbObjectUpdateService.findByTBActivityId(nurseryActivity.getId(), Pageable.unpaged()); | |||
| if(tbObjectUpdateDTOs!= null && tbObjectUpdateDTOs.size() > 0) { | |||
| if (tbObjectUpdateDTOs != null && tbObjectUpdateDTOs.size() > 0) { | |||
| tbObjectUpdateDTOs.forEach(item -> { | |||
| if (item.getTbObjectParameterDTO().getName().equals(THOI_GIAN_NGAM_HAT)) { | |||
| item.setIndex(item.getIndex() != null && !item.getIndex().isEmpty() ? item.getIndex() : "0"); | |||
| @@ -633,7 +639,7 @@ public class TBCropResource { | |||
| } | |||
| } | |||
| //Lo Trong | |||
| if(tBCropDTO.get().getTbCropTypeId() == 2) { | |||
| if (tBCropDTO.get().getTbCropTypeId() == 2) { | |||
| // Get planting Date | |||
| TBActivityDTO plantingActivity = allActivities.stream() | |||
| .sorted(Comparator.comparing( | |||
| @@ -647,16 +653,16 @@ public class TBCropResource { | |||
| List<Long> listActivities = allActivities.stream().map(TBActivityDTO::getId).collect(Collectors.toList()); | |||
| List<TBObjectUpdateDTO> tbObjectUpdateDTOs = tbObjectUpdateService.findByInListTBActivityId(listActivities, Pageable.unpaged()); | |||
| if(tbObjectUpdateDTOs!= null && tbObjectUpdateDTOs.size() > 0) { | |||
| if (tbObjectUpdateDTOs != null && tbObjectUpdateDTOs.size() > 0) { | |||
| tbObjectUpdateDTOs.forEach(item -> { | |||
| if (item.getTbObjectParameterDTO().getName().equals(SO_LUONG_CAY_TRONG)) { | |||
| item.setIndex(item.getIndex() != null && !item.getIndex().isEmpty() ? item.getIndex() : "0"); | |||
| tbCropDetailDTO.setNumberPlants(Integer.parseInt(item.getIndex().replaceAll("[^0-9]",""))); | |||
| tbCropDetailDTO.setNumberCurrentPlants(Integer.parseInt(item.getIndex().replaceAll("[^0-9]",""))); | |||
| tbCropDetailDTO.setNumberPlants(Integer.parseInt(item.getIndex().replaceAll("[^0-9]", ""))); | |||
| tbCropDetailDTO.setNumberCurrentPlants(Integer.parseInt(item.getIndex().replaceAll("[^0-9]", ""))); | |||
| } | |||
| if (item.getTbObjectParameterDTO().getName().equals(SO_LUONG_LOAI_BO)) { | |||
| item.setIndex(item.getIndex() != null && !item.getIndex().isEmpty() ? item.getIndex() : "0"); | |||
| Integer currentNumberPlants = tbCropDetailDTO.getNumberPlants() - Integer.parseInt(item.getIndex().replaceAll("[^0-9]","")); | |||
| Integer currentNumberPlants = tbCropDetailDTO.getNumberPlants() - Integer.parseInt(item.getIndex().replaceAll("[^0-9]", "")); | |||
| tbCropDetailDTO.setNumberCurrentPlants(currentNumberPlants > 0 ? currentNumberPlants : 0); | |||
| } | |||
| }); | |||
| @@ -0,0 +1,17 @@ | |||
| package vn.azteam.tpf.web.rest.util; | |||
| import java.util.UUID; | |||
| public final class RandomStringUtil { | |||
| public static String generateRandomStringFromUUID(int stringLength) { | |||
| String qrCode = UUID | |||
| .randomUUID() | |||
| .toString() | |||
| .replace("-", "") | |||
| .substring(0, stringLength) | |||
| .toUpperCase(); | |||
| return qrCode; | |||
| } | |||
| } | |||
| @@ -94,16 +94,6 @@ | |||
| <!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove--> | |||
| </createTable> | |||
| <createTable tableName="tb_assignment"> | |||
| <column name="tb_detail_users_id" type="bigint"> | |||
| <constraints nullable="false"/> | |||
| </column> | |||
| <column name="tb_crops_id" type="bigint"> | |||
| <constraints nullable="false"/> | |||
| </column> | |||
| </createTable> | |||
| <addPrimaryKey columnNames="tb_crops_id, tb_detail_users_id" tableName="tb_assignment"/> | |||
| </changeSet> | |||
| <!-- jhipster-needle-liquibase-add-changeset - JHipster will add changesets here, do not remove--> | |||
| @@ -0,0 +1,83 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <databaseChangeLog | |||
| xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | |||
| xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" | |||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
| xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd | |||
| http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> | |||
| <property name="now" value="now()" dbms="h2"/> | |||
| <property name="now" value="now()" dbms="mysql"/> | |||
| <property name="autoIncrement" value="true"/> | |||
| <property name="floatType" value="float4" dbms="postgresql, h2"/> | |||
| <property name="floatType" value="float" dbms="mysql, oracle, mssql"/> | |||
| <!-- | |||
| Added the entity TBCode. | |||
| --> | |||
| <changeSet id="20231209075003-1" author="jhipster"> | |||
| <createTable tableName="tb_code"> | |||
| <column name="id" type="bigint" autoIncrement="${autoIncrement}"> | |||
| <constraints primaryKey="true" nullable="false"/> | |||
| </column> | |||
| <column name="tb_crop_id" type="bigint"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="code" type="varchar(255)"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="quantity" type="integer"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="description" type="varchar(255)"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="path_image" type="varchar(255)"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="status" type="varchar(255)"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="expired_date" type="timestamp"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="created_date" type="timestamp"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="modified_date" type="timestamp"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="deleted_date" type="timestamp"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="created_by" type="bigint"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="modified_by" type="bigint"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="deleted_by" type="bigint"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove--> | |||
| </createTable> | |||
| </changeSet> | |||
| <!-- jhipster-needle-liquibase-add-changeset - JHipster will add changesets here, do not remove--> | |||
| </databaseChangeLog> | |||
| @@ -0,0 +1,71 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <databaseChangeLog | |||
| xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | |||
| xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" | |||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
| xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd | |||
| http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> | |||
| <property name="now" value="now()" dbms="h2"/> | |||
| <property name="now" value="now()" dbms="mysql"/> | |||
| <property name="autoIncrement" value="true"/> | |||
| <property name="floatType" value="float4" dbms="postgresql, h2"/> | |||
| <property name="floatType" value="float" dbms="mysql, oracle, mssql"/> | |||
| <!-- | |||
| Added the entity TBCode. | |||
| --> | |||
| <changeSet id="20231209075004-1" author="jhipster"> | |||
| <createTable tableName="tb_code_details"> | |||
| <column name="id" type="bigint" autoIncrement="${autoIncrement}"> | |||
| <constraints primaryKey="true" nullable="false"/> | |||
| </column> | |||
| <column name="tb_code_id" type="bigint"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="code" type="varchar(255)"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="number_scan" type="integer"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="status" type="varchar(255)"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="created_date" type="timestamp"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="modified_date" type="timestamp"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="deleted_date" type="timestamp"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="created_by" type="bigint"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="modified_by" type="bigint"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <column name="deleted_by" type="bigint"> | |||
| <constraints nullable="true" /> | |||
| </column> | |||
| <!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove--> | |||
| </createTable> | |||
| </changeSet> | |||
| <!-- jhipster-needle-liquibase-add-changeset - JHipster will add changesets here, do not remove--> | |||
| </databaseChangeLog> | |||
| @@ -228,6 +228,6 @@ | |||
| <include file="config/liquibase/changelog/20210518074106_added_entity_constraints_TBBlockDetailsReport" relativeToChangelogFile="false"/> | |||
| <include file="config/liquibase/changelog/20210518074444_added_entity_TBProductBlockDetailsReport.xml" relativeToChangelogFile="false"/> | |||
| <include file="config/liquibase/changelog/20210329175026_updated_entity_constraints_TBSuppliesUsingDetails.xml" relativeToChangelogFile="false"/> | |||
| <include file="config/liquibase/changelog/20231209075003_added_entity_TBCode.xml" relativeToChangelogFile="false"/> | |||
| <include file="config/liquibase/changelog/20231209075004_added_entity_TBCodeDetails.xml" relativeToChangelogFile="false"/> | |||
| </databaseChangeLog> | |||