| @@ -50,6 +50,13 @@ public class TBActivityType implements Serializable { | |||
| @Column(name = "is_guideline_using") | |||
| private Boolean isGuidelineUsing; | |||
| /* | |||
| false: before harvest | |||
| true: after harvest | |||
| */ | |||
| @Column(name = "is_after_harvest") | |||
| private Boolean isAfterHarvest; | |||
| @ManyToOne(fetch=FetchType.LAZY) | |||
| @JsonIgnoreProperties("") | |||
| @JoinColumn(name = "created_by") | |||
| @@ -0,0 +1,185 @@ | |||
| package vn.azteam.tpf.domain; | |||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |||
| import org.hibernate.annotations.Cache; | |||
| import org.hibernate.annotations.CacheConcurrencyStrategy; | |||
| import org.springframework.data.elasticsearch.annotations.Document; | |||
| import javax.persistence.*; | |||
| import java.io.Serializable; | |||
| import java.time.Instant; | |||
| import java.util.HashSet; | |||
| import java.util.Set; | |||
| @Entity | |||
| @Table(name = "tb_code") | |||
| @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) | |||
| @Document(indexName = "smf_tbcode") | |||
| public class TBCode implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | |||
| private Long id; | |||
| @Column(name = "code") | |||
| private String code; | |||
| @Column(name = "quantity") | |||
| private Integer quantity; | |||
| @Column(name = "description") | |||
| private String description; | |||
| @Column(name = "path_image") | |||
| private String pathImage; | |||
| @Column(name = "status") | |||
| @Enumerated(value = EnumType.STRING) | |||
| private TBCodeStatusEnum status = TBCodeStatusEnum.NEW; | |||
| @Column(name = "expired_date") | |||
| private Instant expiredDate; | |||
| @Column(name = "created_date") | |||
| private Instant createdDate; | |||
| @Column(name = "modified_date") | |||
| private Instant modifiedDate; | |||
| @Column(name = "deleted_date") | |||
| private Instant deletedDate; | |||
| @ManyToOne(fetch = FetchType.LAZY) | |||
| @JsonIgnoreProperties("") | |||
| @JoinColumn(name = "created_by") | |||
| private TBDetailUser createdBy; | |||
| @ManyToOne(fetch = FetchType.LAZY) | |||
| @JsonIgnoreProperties("") | |||
| @JoinColumn(name = "modified_by") | |||
| private TBDetailUser modifiedBy; | |||
| @ManyToOne(fetch = FetchType.LAZY) | |||
| @JsonIgnoreProperties("") | |||
| @JoinColumn(name = "deleted_by") | |||
| private TBDetailUser deletedBy; | |||
| @OneToMany(mappedBy = "tbCode", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) | |||
| @OrderBy("id ASC") | |||
| private Set<TBCodeDetails> tbCodeDetails = new HashSet<>(); | |||
| public Long getId() { | |||
| return id; | |||
| } | |||
| public void setId(Long id) { | |||
| this.id = id; | |||
| } | |||
| public String getCode() { | |||
| return code; | |||
| } | |||
| public void setCode(String code) { | |||
| this.code = code; | |||
| } | |||
| 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 getCreatedDate() { | |||
| return createdDate; | |||
| } | |||
| public void setCreatedDate(Instant createdDate) { | |||
| this.createdDate = createdDate; | |||
| } | |||
| public Instant getExpiredDate() { | |||
| return expiredDate; | |||
| } | |||
| public void setExpiredDate(Instant expiredDate) { | |||
| this.expiredDate = expiredDate; | |||
| } | |||
| public Instant getModifiedDate() { | |||
| return modifiedDate; | |||
| } | |||
| public void setModifiedDate(Instant modifiedDate) { | |||
| this.modifiedDate = modifiedDate; | |||
| } | |||
| public TBDetailUser getCreatedBy() { | |||
| return createdBy; | |||
| } | |||
| public void setCreatedBy(TBDetailUser createdBy) { | |||
| this.createdBy = createdBy; | |||
| } | |||
| public TBDetailUser getModifiedBy() { | |||
| return modifiedBy; | |||
| } | |||
| public void setModifiedBy(TBDetailUser modifiedBy) { | |||
| this.modifiedBy = modifiedBy; | |||
| } | |||
| public Set<TBCodeDetails> getTbCodeDetails() { | |||
| return tbCodeDetails; | |||
| } | |||
| public void setTbCodeDetails(Set<TBCodeDetails> tbCodeDetails) { | |||
| this.tbCodeDetails = tbCodeDetails; | |||
| } | |||
| public Instant getDeletedDate() { | |||
| return deletedDate; | |||
| } | |||
| public void setDeletedDate(Instant deletedDate) { | |||
| this.deletedDate = deletedDate; | |||
| } | |||
| public TBDetailUser getDeletedBy() { | |||
| return deletedBy; | |||
| } | |||
| public void setDeletedBy(TBDetailUser deletedBy) { | |||
| this.deletedBy = deletedBy; | |||
| } | |||
| } | |||
| @@ -0,0 +1,153 @@ | |||
| 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; | |||
| import org.springframework.data.elasticsearch.annotations.Document; | |||
| import javax.persistence.*; | |||
| import java.io.Serializable; | |||
| import java.time.Instant; | |||
| @Entity | |||
| @Table(name = "tb_code_details") | |||
| @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) | |||
| @Document(indexName = "smf_tbcodedetails") | |||
| public class TBCodeDetails implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | |||
| private Long id; | |||
| @ManyToOne(fetch = FetchType.LAZY) | |||
| @JsonIgnoreProperties("") | |||
| @JsonIgnore | |||
| @JoinColumn(name = "tb_code_id") | |||
| private TBCode tbCode; | |||
| @Column(name = "code") | |||
| private String code; | |||
| @Column(name = "number_scan") | |||
| private Integer numberScan; | |||
| @Column(name = "status") | |||
| @Enumerated(value = EnumType.STRING) | |||
| private TBCodeDetailsStatusEnum status = TBCodeDetailsStatusEnum.NEW; | |||
| @Column(name = "created_date") | |||
| private Instant createdDate; | |||
| @Column(name = "modified_date") | |||
| private Instant modifiedDate; | |||
| @Column(name = "deleted_date") | |||
| private Instant deletedDate; | |||
| @ManyToOne(fetch = FetchType.LAZY) | |||
| @JsonIgnoreProperties("") | |||
| @JoinColumn(name = "created_by") | |||
| private TBDetailUser createdBy; | |||
| @ManyToOne(fetch = FetchType.LAZY) | |||
| @JsonIgnoreProperties("") | |||
| @JoinColumn(name = "modified_by") | |||
| private TBDetailUser modifiedBy; | |||
| @ManyToOne(fetch = FetchType.LAZY) | |||
| @JsonIgnoreProperties("") | |||
| @JoinColumn(name = "deleted_by") | |||
| private TBDetailUser deletedBy; | |||
| public Long getId() { | |||
| return id; | |||
| } | |||
| public void setId(Long id) { | |||
| this.id = id; | |||
| } | |||
| public TBCode getTbCode() { | |||
| return tbCode; | |||
| } | |||
| public void setTbCode(TBCode tbCode) { | |||
| this.tbCode = tbCode; | |||
| } | |||
| public String getCode() { | |||
| return code; | |||
| } | |||
| public void setCode(String code) { | |||
| this.code = code; | |||
| } | |||
| public Integer getNumberScan() { | |||
| return numberScan; | |||
| } | |||
| public void setNumberScan(Integer numberScan) { | |||
| this.numberScan = numberScan; | |||
| } | |||
| public TBCodeDetailsStatusEnum getStatus() { | |||
| return status; | |||
| } | |||
| public void setStatus(TBCodeDetailsStatusEnum status) { | |||
| this.status = status; | |||
| } | |||
| public Instant getCreatedDate() { | |||
| return createdDate; | |||
| } | |||
| public void setCreatedDate(Instant createdDate) { | |||
| this.createdDate = createdDate; | |||
| } | |||
| public Instant getModifiedDate() { | |||
| return modifiedDate; | |||
| } | |||
| public void setModifiedDate(Instant modifiedDate) { | |||
| this.modifiedDate = modifiedDate; | |||
| } | |||
| public TBDetailUser getCreatedBy() { | |||
| return createdBy; | |||
| } | |||
| public void setCreatedBy(TBDetailUser createdBy) { | |||
| this.createdBy = createdBy; | |||
| } | |||
| public TBDetailUser getModifiedBy() { | |||
| return modifiedBy; | |||
| } | |||
| public void setModifiedBy(TBDetailUser modifiedBy) { | |||
| this.modifiedBy = modifiedBy; | |||
| } | |||
| public Instant getDeletedDate() { | |||
| return deletedDate; | |||
| } | |||
| public void setDeletedDate(Instant deletedDate) { | |||
| this.deletedDate = deletedDate; | |||
| } | |||
| public TBDetailUser getDeletedBy() { | |||
| return deletedBy; | |||
| } | |||
| public void setDeletedBy(TBDetailUser deletedBy) { | |||
| this.deletedBy = deletedBy; | |||
| } | |||
| } | |||
| @@ -0,0 +1,19 @@ | |||
| package vn.azteam.tpf.domain; | |||
| public enum TBCodeDetailsStatusEnum { | |||
| NEW("NEW"), | |||
| UPDATED("UPDATED"), | |||
| CANCELED("UPDATED_PRINTED"); | |||
| private final String name; | |||
| TBCodeDetailsStatusEnum(final String name) { | |||
| this.name = name; | |||
| } | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| } | |||
| @@ -0,0 +1,22 @@ | |||
| package vn.azteam.tpf.domain; | |||
| public enum TBCodeStatusEnum { | |||
| NEW("NEW"), | |||
| UPDATED("UPDATED"), | |||
| UPDATED_PRINTED("UPDATED_PRINTED"); | |||
| private final String name; | |||
| TBCodeStatusEnum(final String name) { | |||
| this.name = name; | |||
| } | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| } | |||
| @@ -3,15 +3,14 @@ package vn.azteam.tpf.domain; | |||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |||
| import org.hibernate.annotations.Cache; | |||
| import org.hibernate.annotations.CacheConcurrencyStrategy; | |||
| import org.springframework.data.elasticsearch.annotations.Document; | |||
| import javax.persistence.*; | |||
| import org.springframework.data.elasticsearch.annotations.Document; | |||
| import java.io.Serializable; | |||
| import java.time.Instant; | |||
| import java.util.HashSet; | |||
| import java.util.Set; | |||
| import java.util.Objects; | |||
| import java.util.Set; | |||
| /** | |||
| * A TBCrop. | |||
| @@ -77,17 +76,17 @@ public class TBCrop implements Serializable { | |||
| @JsonIgnoreProperties("") | |||
| private TBEntity tbEntity; | |||
| @ManyToOne(fetch=FetchType.LAZY) | |||
| @ManyToOne(fetch = FetchType.LAZY) | |||
| @JsonIgnoreProperties("") | |||
| @JoinColumn(name = "created_by") | |||
| private TBDetailUser createdBy; | |||
| @ManyToOne(fetch=FetchType.LAZY) | |||
| @ManyToOne(fetch = FetchType.LAZY) | |||
| @JsonIgnoreProperties("") | |||
| @JoinColumn(name = "modified_by") | |||
| private TBDetailUser modifiedBy; | |||
| @ManyToOne(fetch=FetchType.LAZY) | |||
| @ManyToOne(fetch = FetchType.LAZY) | |||
| @JsonIgnoreProperties("") | |||
| @JoinColumn(name = "deleted_by") | |||
| private TBDetailUser deletedBy; | |||
| @@ -95,10 +94,17 @@ public class TBCrop implements Serializable { | |||
| @ManyToMany | |||
| @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) | |||
| @JoinTable(name = "tb_assignment", | |||
| joinColumns = @JoinColumn(name = "tb_crops_id"/*, referencedColumnName = "id"*/), | |||
| inverseJoinColumns = @JoinColumn(name = "tb_detail_users_id"/*, referencedColumnName = "id"*/)) | |||
| joinColumns = @JoinColumn(name = "tb_crops_id"/*, referencedColumnName = "id"*/), | |||
| 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<>(); | |||
| // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove | |||
| public Long getId() { | |||
| return id; | |||
| @@ -133,6 +139,7 @@ public class TBCrop implements Serializable { | |||
| public String getCode() { | |||
| return code; | |||
| } | |||
| public TBCrop code(String code) { | |||
| this.code = code; | |||
| return this; | |||
| @@ -0,0 +1,10 @@ | |||
| package vn.azteam.tpf.repository; | |||
| import org.springframework.data.jpa.repository.JpaRepository; | |||
| import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | |||
| import org.springframework.stereotype.Repository; | |||
| import vn.azteam.tpf.domain.TBCodeDetails; | |||
| @Repository | |||
| public interface TBCodeDetailsRepository extends JpaRepository<TBCodeDetails, Long>, JpaSpecificationExecutor<TBCodeDetails> { | |||
| } | |||
| @@ -0,0 +1,11 @@ | |||
| package vn.azteam.tpf.repository; | |||
| import org.springframework.data.jpa.repository.JpaRepository; | |||
| import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | |||
| import org.springframework.stereotype.Repository; | |||
| import vn.azteam.tpf.domain.TBCode; | |||
| import vn.azteam.tpf.domain.TBCrop; | |||
| @Repository | |||
| public interface TBCodeRepository extends JpaRepository<TBCode, Long>, JpaSpecificationExecutor<TBCode> { | |||
| } | |||
| @@ -0,0 +1,131 @@ | |||
| package vn.azteam.tpf.service; | |||
| import io.github.jhipster.service.QueryService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.Pageable; | |||
| import org.springframework.data.jpa.domain.Specification; | |||
| import org.springframework.stereotype.Service; | |||
| 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.repository.TBCodeDetailsRepository; | |||
| import vn.azteam.tpf.service.dto.TBCodeDetailsCriteria; | |||
| import vn.azteam.tpf.service.dto.TBCodeDetailsDTO; | |||
| import vn.azteam.tpf.service.mapper.TBCodeDetailsMapper; | |||
| import javax.persistence.criteria.Join; | |||
| import javax.persistence.criteria.JoinType; | |||
| @Service | |||
| @Transactional(readOnly = true) | |||
| public class TBCodeDetailsQueryService extends QueryService<TBCodeDetails> { | |||
| private final Logger log = LoggerFactory.getLogger(TBCodeDetailsQueryService.class); | |||
| private final TBCodeDetailsRepository tBCodeDetailsRepository; | |||
| private final TBCodeDetailsMapper tBCodeDetailsMapper; | |||
| public TBCodeDetailsQueryService(TBCodeDetailsRepository tBCodeDetailsRepository, | |||
| TBCodeDetailsMapper tBCodeDetailsMapper) { | |||
| this.tBCodeDetailsRepository = tBCodeDetailsRepository; | |||
| this.tBCodeDetailsMapper = tBCodeDetailsMapper; | |||
| } | |||
| @Transactional(readOnly = true) | |||
| public Page<TBCodeDetailsDTO> findByCriteria(TBCodeDetailsCriteria criteria, Pageable page) { | |||
| log.debug("find by criteria : {}, page: {}", criteria, page); | |||
| final Specification<TBCodeDetails> specification = createSpecification(criteria); | |||
| return tBCodeDetailsRepository.findAll(specification, page) | |||
| .map(tBCodeDetailsMapper::toDto); | |||
| } | |||
| private Specification<TBCodeDetails> initializeCropSpecification() { | |||
| return (Specification<TBCodeDetails>) (root, query, cb) -> { | |||
| final Join<TBCodeDetails, TBDetailUser> detailUserJoin = root.join(TBCodeDetails_.deletedBy, JoinType.LEFT); | |||
| return cb.isNull(detailUserJoin.get(TBDetailUser_.id)); | |||
| }; | |||
| } | |||
| /** | |||
| * Function to convert TBCodeCriteria to a {@link Specification} | |||
| */ | |||
| private Specification<TBCodeDetails> createSpecification(TBCodeDetailsCriteria criteria) { | |||
| Specification<TBCodeDetails> specification = initializeCropSpecification(); | |||
| if (criteria != null) { | |||
| if (criteria.getId() != null) { | |||
| specification = specification.and(buildSpecification(criteria.getId(), TBCodeDetails_.id)); | |||
| } | |||
| // if (criteria.getQrCode() != null) { | |||
| // specification = specification.and(buildStringSpecification(criteria.getQrCode(), TBCrop_.qrCode)); | |||
| // } | |||
| // if (criteria.getCode() != null) { | |||
| // specification = specification.and(buildStringSpecification(criteria.getCode(), TBCrop_.code)); | |||
| // } | |||
| // if (criteria.getAreaM2() != null) { | |||
| // specification = specification.and(buildRangeSpecification(criteria.getAreaM2(), TBCrop_.areaM2)); | |||
| // } | |||
| // if (criteria.getTbCropType() != null) { | |||
| // specification = specification.and(buildSpecification(criteria.getTbCropType(), | |||
| // root -> root.join(TBCrop_.tbCropType, JoinType.LEFT).get(TBCropType_.id))); | |||
| // } | |||
| // if (criteria.getStartDate() != null) { | |||
| // specification = specification.and(buildRangeSpecification(criteria.getStartDate(), TBCrop_.startDate)); | |||
| // } | |||
| // if (criteria.getEndDate() != null) { | |||
| // specification = specification.and(buildRangeSpecification(criteria.getEndDate(), TBCrop_.endDate)); | |||
| // } | |||
| // if (criteria.getStatus() != null) { | |||
| // specification = specification.and(buildStringSpecification(criteria.getStatus(), TBCrop_.status)); | |||
| // } | |||
| // if (criteria.getDescription() != null) { | |||
| // specification = specification.and(buildStringSpecification(criteria.getDescription(), TBCrop_.description)); | |||
| // } | |||
| // if (criteria.getAgeDayStartAt() != null) { | |||
| // specification = specification.and(buildRangeSpecification(criteria.getAgeDayStartAt(), TBCrop_.ageDayStartAt)); | |||
| // } | |||
| // if (criteria.getCreatedDate() != null) { | |||
| // specification = specification.and(buildRangeSpecification(criteria.getCreatedDate(), TBCrop_.createdDate)); | |||
| // } | |||
| // if (criteria.getModifiedDate() != null) { | |||
| // specification = specification.and(buildRangeSpecification(criteria.getModifiedDate(), TBCrop_.modifiedDate)); | |||
| // } | |||
| // if (criteria.getDeletedDate() != null) { | |||
| // specification = specification.and(buildRangeSpecification(criteria.getDeletedDate(), TBCrop_.deletedDate)); | |||
| // } | |||
| // if (criteria.getTbSuppliesId() != null) { | |||
| // specification = specification.and(buildSpecification(criteria.getTbSuppliesId(), | |||
| // root -> root.join(TBCrop_.tbSupplies, JoinType.LEFT).get(TBSupplies_.id))); | |||
| // } | |||
| // if (criteria.getTbGuidelineId() != null) { | |||
| // specification = specification.and(buildSpecification(criteria.getTbGuidelineId(), | |||
| // root -> root.join(TBCrop_.tbGuideline, JoinType.LEFT).get(TBGuideline_.id))); | |||
| // } | |||
| // if (criteria.getNetHouseId() != null) { | |||
| // specification = specification.and(buildSpecification(criteria.getNetHouseId(), | |||
| // root -> root.join(TBCrop_.tbEntity, JoinType.LEFT).get(TBEntity_.id))); | |||
| // } | |||
| // if (criteria.getCreatedById() != null) { | |||
| // specification = specification.and(buildSpecification(criteria.getCreatedById(), | |||
| // root -> root.join(TBCrop_.createdBy, JoinType.LEFT).get(TBDetailUser_.id))); | |||
| // } | |||
| // if (criteria.getModifiedById() != null) { | |||
| // specification = specification.and(buildSpecification(criteria.getModifiedById(), | |||
| // root -> root.join(TBCrop_.modifiedBy, JoinType.LEFT).get(TBDetailUser_.id))); | |||
| // } | |||
| // if (criteria.getDeletedById() != null) { | |||
| // specification = specification.and(buildSpecification(criteria.getDeletedById(), | |||
| // root -> root.join(TBCrop_.deletedBy, JoinType.LEFT).get(TBDetailUser_.id))); | |||
| // } | |||
| // if (criteria.getTbDetailUserId() != null) { | |||
| // specification = specification.and(buildSpecification(criteria.getTbDetailUserId(), | |||
| // root -> root.join(TBCrop_.tbDetailUsers, JoinType.LEFT).get(TBDetailUser_.id))); | |||
| // } | |||
| } | |||
| return specification; | |||
| } | |||
| } | |||
| @@ -0,0 +1,127 @@ | |||
| package vn.azteam.tpf.service; | |||
| import io.github.jhipster.service.QueryService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.Pageable; | |||
| import org.springframework.data.jpa.domain.Specification; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import vn.azteam.tpf.domain.*; | |||
| import vn.azteam.tpf.repository.TBCodeRepository; | |||
| import vn.azteam.tpf.service.dto.TBCodeCriteria; | |||
| import vn.azteam.tpf.service.dto.TBCodeDTO; | |||
| import vn.azteam.tpf.service.mapper.TBCodeMapper; | |||
| import javax.persistence.criteria.Join; | |||
| import javax.persistence.criteria.JoinType; | |||
| @Service | |||
| @Transactional(readOnly = true) | |||
| public class TBCodeQueryService extends QueryService<TBCode> { | |||
| private final Logger log = LoggerFactory.getLogger(TBCodeQueryService.class); | |||
| private final TBCodeRepository tBCodeRepository; | |||
| private final TBCodeMapper tBCodeMapper; | |||
| public TBCodeQueryService(TBCodeRepository tBCodeRepository, TBCodeMapper tBCodeMapper) { | |||
| this.tBCodeRepository = tBCodeRepository; | |||
| this.tBCodeMapper = tBCodeMapper; | |||
| } | |||
| @Transactional(readOnly = true) | |||
| public Page<TBCodeDTO> findByCriteria(TBCodeCriteria criteria, Pageable page) { | |||
| log.debug("find by criteria : {}, page: {}", criteria, page); | |||
| final Specification<TBCode> specification = createSpecification(criteria); | |||
| return tBCodeRepository.findAll(specification, page) | |||
| .map(tBCodeMapper::toDto); | |||
| } | |||
| private Specification<TBCode> initializeCropSpecification() { | |||
| return (Specification<TBCode>) (root, query, cb) -> { | |||
| final Join<TBCode, TBDetailUser> detailUserJoin = root.join(TBCode_.deletedBy, JoinType.LEFT); | |||
| return cb.isNull(detailUserJoin.get(TBDetailUser_.id)); | |||
| }; | |||
| } | |||
| /** | |||
| * Function to convert TBCodeCriteria to a {@link Specification} | |||
| */ | |||
| private Specification<TBCode> createSpecification(TBCodeCriteria criteria) { | |||
| Specification<TBCode> specification = initializeCropSpecification(); | |||
| if (criteria != null) { | |||
| if (criteria.getId() != null) { | |||
| specification = specification.and(buildSpecification(criteria.getId(), TBCode_.id)); | |||
| } | |||
| // if (criteria.getQrCode() != null) { | |||
| // specification = specification.and(buildStringSpecification(criteria.getQrCode(), TBCrop_.qrCode)); | |||
| // } | |||
| // if (criteria.getCode() != null) { | |||
| // specification = specification.and(buildStringSpecification(criteria.getCode(), TBCrop_.code)); | |||
| // } | |||
| // if (criteria.getAreaM2() != null) { | |||
| // specification = specification.and(buildRangeSpecification(criteria.getAreaM2(), TBCrop_.areaM2)); | |||
| // } | |||
| // if (criteria.getTbCropType() != null) { | |||
| // specification = specification.and(buildSpecification(criteria.getTbCropType(), | |||
| // root -> root.join(TBCrop_.tbCropType, JoinType.LEFT).get(TBCropType_.id))); | |||
| // } | |||
| // if (criteria.getStartDate() != null) { | |||
| // specification = specification.and(buildRangeSpecification(criteria.getStartDate(), TBCrop_.startDate)); | |||
| // } | |||
| // if (criteria.getEndDate() != null) { | |||
| // specification = specification.and(buildRangeSpecification(criteria.getEndDate(), TBCrop_.endDate)); | |||
| // } | |||
| // if (criteria.getStatus() != null) { | |||
| // specification = specification.and(buildStringSpecification(criteria.getStatus(), TBCrop_.status)); | |||
| // } | |||
| // if (criteria.getDescription() != null) { | |||
| // specification = specification.and(buildStringSpecification(criteria.getDescription(), TBCrop_.description)); | |||
| // } | |||
| // if (criteria.getAgeDayStartAt() != null) { | |||
| // specification = specification.and(buildRangeSpecification(criteria.getAgeDayStartAt(), TBCrop_.ageDayStartAt)); | |||
| // } | |||
| // if (criteria.getCreatedDate() != null) { | |||
| // specification = specification.and(buildRangeSpecification(criteria.getCreatedDate(), TBCrop_.createdDate)); | |||
| // } | |||
| // if (criteria.getModifiedDate() != null) { | |||
| // specification = specification.and(buildRangeSpecification(criteria.getModifiedDate(), TBCrop_.modifiedDate)); | |||
| // } | |||
| // if (criteria.getDeletedDate() != null) { | |||
| // specification = specification.and(buildRangeSpecification(criteria.getDeletedDate(), TBCrop_.deletedDate)); | |||
| // } | |||
| // if (criteria.getTbSuppliesId() != null) { | |||
| // specification = specification.and(buildSpecification(criteria.getTbSuppliesId(), | |||
| // root -> root.join(TBCrop_.tbSupplies, JoinType.LEFT).get(TBSupplies_.id))); | |||
| // } | |||
| // if (criteria.getTbGuidelineId() != null) { | |||
| // specification = specification.and(buildSpecification(criteria.getTbGuidelineId(), | |||
| // root -> root.join(TBCrop_.tbGuideline, JoinType.LEFT).get(TBGuideline_.id))); | |||
| // } | |||
| // if (criteria.getNetHouseId() != null) { | |||
| // specification = specification.and(buildSpecification(criteria.getNetHouseId(), | |||
| // root -> root.join(TBCrop_.tbEntity, JoinType.LEFT).get(TBEntity_.id))); | |||
| // } | |||
| // if (criteria.getCreatedById() != null) { | |||
| // specification = specification.and(buildSpecification(criteria.getCreatedById(), | |||
| // root -> root.join(TBCrop_.createdBy, JoinType.LEFT).get(TBDetailUser_.id))); | |||
| // } | |||
| // if (criteria.getModifiedById() != null) { | |||
| // specification = specification.and(buildSpecification(criteria.getModifiedById(), | |||
| // root -> root.join(TBCrop_.modifiedBy, JoinType.LEFT).get(TBDetailUser_.id))); | |||
| // } | |||
| // if (criteria.getDeletedById() != null) { | |||
| // specification = specification.and(buildSpecification(criteria.getDeletedById(), | |||
| // root -> root.join(TBCrop_.deletedBy, JoinType.LEFT).get(TBDetailUser_.id))); | |||
| // } | |||
| // if (criteria.getTbDetailUserId() != null) { | |||
| // specification = specification.and(buildSpecification(criteria.getTbDetailUserId(), | |||
| // root -> root.join(TBCrop_.tbDetailUsers, JoinType.LEFT).get(TBDetailUser_.id))); | |||
| // } | |||
| } | |||
| return specification; | |||
| } | |||
| } | |||
| @@ -0,0 +1,85 @@ | |||
| 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 java.util.List; | |||
| import java.util.Optional; | |||
| /** | |||
| * Service Interface for managing TBCode. | |||
| */ | |||
| public interface TBCodeService { | |||
| // TBCropDTO save(TBCropDTO tBCropDTO); | |||
| // | |||
| // | |||
| // /** | |||
| // * Update crop's PIC | |||
| // * @param cropPersonInChargeDTO | |||
| // * @return the persisted entity | |||
| // */ | |||
| // Optional<TBCropDTO> updateCropPersonInCharge(CropPersonInChargeDTO cropPersonInChargeDTO); | |||
| // | |||
| // /** | |||
| // * Get all the tBCrops. | |||
| // * | |||
| // * @param pageable the pagination information | |||
| // * @return the list of entities | |||
| // */ | |||
| // Page<TBCropDTO> findAll(Pageable pageable); | |||
| // | |||
| // /** | |||
| // * Get all the TBCrop with eager load of many-to-many relationships. | |||
| // * | |||
| // * @return the list of entities | |||
| // */ | |||
| // Page<TBCropDTO> findAllWithEagerRelationships(Pageable pageable); | |||
| // | |||
| // /** | |||
| // * Get the "id" tBCrop. | |||
| // * | |||
| // * @param id the id of the entity | |||
| // * @return the entity | |||
| // */ | |||
| // Optional<TBCropDTO> findOne(Long id); | |||
| // | |||
| // /** | |||
| // * Delete the "id" tBCrop. | |||
| // * | |||
| // * @param id the id of the entity | |||
| // */ | |||
| // void delete(Long id); | |||
| // | |||
| // /** | |||
| // * Search for the tBCrop corresponding to the query. | |||
| // * | |||
| // * @param query the query of the search | |||
| // * | |||
| // * @param pageable the pagination information | |||
| // * @return the list of entities | |||
| // */ | |||
| // Page<TBCropDTO> search(String query, Pageable pageable); | |||
| // | |||
| // /** | |||
| // * Search for the tBCrop corresponding to the query, areaId or netHouseId. | |||
| // * | |||
| // * @param query the query of the search | |||
| // * @param areaId the areaId of the search | |||
| // * @param netHouseId the netHouseId of the search | |||
| // * | |||
| // * @param pageable the pagination information | |||
| // * @return the list of entities | |||
| // */ | |||
| // Page<TBCropDTO> searchCrop(String query, Long areaId, Long netHouseId, Pageable pageable); | |||
| // | |||
| // List<TBCustomerHasCropTypeDTO> getAllCustomerHasCropTypeByCustomerAndCropType(Long customerId, Long cropTypeId); | |||
| // | |||
| // List<Long> getListActivityTypeIdByByCustomerAndCropType(Long customerId, Long cropTypeId); | |||
| // | |||
| // List<String> getListActivityTypeNameByByCustomerAndCropType(Long customerId, Long cropTypeId); | |||
| // | |||
| // List<Long> getAllCropIdByCustomer(Long customerId); | |||
| } | |||
| @@ -0,0 +1,133 @@ | |||
| package vn.azteam.tpf.service.dto; | |||
| import io.github.jhipster.service.filter.InstantFilter; | |||
| import io.github.jhipster.service.filter.IntegerFilter; | |||
| import io.github.jhipster.service.filter.LongFilter; | |||
| import io.github.jhipster.service.filter.StringFilter; | |||
| import java.io.Serializable; | |||
| public class TBCodeCriteria implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| private LongFilter id; | |||
| private IntegerFilter quantity; | |||
| private StringFilter description; | |||
| private StringFilter pathImage; | |||
| private StringFilter status; | |||
| private InstantFilter createdDate; | |||
| private InstantFilter modifiedDate; | |||
| private InstantFilter deletedDate; | |||
| private LongFilter createdById; | |||
| private LongFilter modifiedById; | |||
| private LongFilter deletedById; | |||
| private StringFilter tbCodeDetails; | |||
| public LongFilter getId() { | |||
| return id; | |||
| } | |||
| public void setId(LongFilter id) { | |||
| this.id = id; | |||
| } | |||
| public IntegerFilter getQuantity() { | |||
| return quantity; | |||
| } | |||
| public void setQuantity(IntegerFilter quantity) { | |||
| this.quantity = quantity; | |||
| } | |||
| public StringFilter getDescription() { | |||
| return description; | |||
| } | |||
| public void setDescription(StringFilter description) { | |||
| this.description = description; | |||
| } | |||
| public StringFilter getPathImage() { | |||
| return pathImage; | |||
| } | |||
| public void setPathImage(StringFilter pathImage) { | |||
| this.pathImage = pathImage; | |||
| } | |||
| public StringFilter getStatus() { | |||
| return status; | |||
| } | |||
| public void setStatus(StringFilter status) { | |||
| this.status = status; | |||
| } | |||
| public InstantFilter getCreatedDate() { | |||
| return createdDate; | |||
| } | |||
| public void setCreatedDate(InstantFilter createdDate) { | |||
| this.createdDate = createdDate; | |||
| } | |||
| public InstantFilter getModifiedDate() { | |||
| return modifiedDate; | |||
| } | |||
| public void setModifiedDate(InstantFilter modifiedDate) { | |||
| this.modifiedDate = modifiedDate; | |||
| } | |||
| public InstantFilter getDeletedDate() { | |||
| return deletedDate; | |||
| } | |||
| public void setDeletedDate(InstantFilter deletedDate) { | |||
| this.deletedDate = deletedDate; | |||
| } | |||
| public LongFilter getCreatedById() { | |||
| return createdById; | |||
| } | |||
| public void setCreatedById(LongFilter createdById) { | |||
| this.createdById = createdById; | |||
| } | |||
| public LongFilter getModifiedById() { | |||
| return modifiedById; | |||
| } | |||
| public void setModifiedById(LongFilter modifiedById) { | |||
| this.modifiedById = modifiedById; | |||
| } | |||
| public LongFilter getDeletedById() { | |||
| return deletedById; | |||
| } | |||
| public void setDeletedById(LongFilter deletedById) { | |||
| this.deletedById = deletedById; | |||
| } | |||
| public StringFilter getTbCodeDetails() { | |||
| return tbCodeDetails; | |||
| } | |||
| public void setTbCodeDetails(StringFilter tbCodeDetails) { | |||
| this.tbCodeDetails = tbCodeDetails; | |||
| } | |||
| } | |||
| @@ -0,0 +1,152 @@ | |||
| package vn.azteam.tpf.service.dto; | |||
| import vn.azteam.tpf.domain.TBCodeDetails; | |||
| import vn.azteam.tpf.domain.TBCodeStatusEnum; | |||
| import java.io.Serializable; | |||
| import java.time.Instant; | |||
| import java.util.HashSet; | |||
| import java.util.Set; | |||
| public class TBCodeDTO implements Serializable { | |||
| private Long id; | |||
| private String code; | |||
| private Integer quantity; | |||
| private String description; | |||
| private String pathImage; | |||
| private TBCodeStatusEnum status; | |||
| private Instant expiredDate; | |||
| private Instant createdDate; | |||
| private Instant modifiedDate; | |||
| private Instant deletedDate; | |||
| private Long createdById; | |||
| private Long modifiedById; | |||
| private Long deletedById; | |||
| private Set<TBCodeDetails> tbCodeDetails = new HashSet<>(); | |||
| public Long getId() { | |||
| return id; | |||
| } | |||
| public void setId(Long id) { | |||
| this.id = id; | |||
| } | |||
| public String getCode() { | |||
| return code; | |||
| } | |||
| public void setCode(String code) { | |||
| this.code = code; | |||
| } | |||
| 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; | |||
| } | |||
| public Instant getCreatedDate() { | |||
| return createdDate; | |||
| } | |||
| public void setCreatedDate(Instant createdDate) { | |||
| this.createdDate = createdDate; | |||
| } | |||
| public Instant getModifiedDate() { | |||
| return modifiedDate; | |||
| } | |||
| public void setModifiedDate(Instant modifiedDate) { | |||
| this.modifiedDate = modifiedDate; | |||
| } | |||
| public Instant getDeletedDate() { | |||
| return deletedDate; | |||
| } | |||
| public void setDeletedDate(Instant deletedDate) { | |||
| this.deletedDate = deletedDate; | |||
| } | |||
| public Long getCreatedById() { | |||
| return createdById; | |||
| } | |||
| public void setCreatedById(Long createdById) { | |||
| this.createdById = createdById; | |||
| } | |||
| public Long getModifiedById() { | |||
| return modifiedById; | |||
| } | |||
| public void setModifiedById(Long modifiedById) { | |||
| this.modifiedById = modifiedById; | |||
| } | |||
| public Long getDeletedById() { | |||
| return deletedById; | |||
| } | |||
| public void setDeletedById(Long deletedById) { | |||
| this.deletedById = deletedById; | |||
| } | |||
| public Set<TBCodeDetails> getTbCodeDetails() { | |||
| return tbCodeDetails; | |||
| } | |||
| public void setTbCodeDetails(Set<TBCodeDetails> tbCodeDetails) { | |||
| this.tbCodeDetails = tbCodeDetails; | |||
| } | |||
| } | |||
| @@ -0,0 +1,123 @@ | |||
| package vn.azteam.tpf.service.dto; | |||
| import io.github.jhipster.service.filter.InstantFilter; | |||
| import io.github.jhipster.service.filter.IntegerFilter; | |||
| import io.github.jhipster.service.filter.LongFilter; | |||
| import io.github.jhipster.service.filter.StringFilter; | |||
| import java.io.Serializable; | |||
| public class TBCodeDetailsCriteria implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| private LongFilter id; | |||
| private StringFilter tbCode; | |||
| private StringFilter code; | |||
| private IntegerFilter numberScan; | |||
| private StringFilter status; | |||
| private InstantFilter expiredDate; | |||
| private InstantFilter modifiedDate; | |||
| private InstantFilter deletedDate; | |||
| private LongFilter createdById; | |||
| private LongFilter modifiedById; | |||
| private LongFilter deletedById; | |||
| public LongFilter getId() { | |||
| return id; | |||
| } | |||
| public void setId(LongFilter id) { | |||
| this.id = id; | |||
| } | |||
| public StringFilter getTbCode() { | |||
| return tbCode; | |||
| } | |||
| public void setTbCode(StringFilter tbCode) { | |||
| this.tbCode = tbCode; | |||
| } | |||
| public StringFilter getCode() { | |||
| return code; | |||
| } | |||
| public void setCode(StringFilter code) { | |||
| this.code = code; | |||
| } | |||
| public IntegerFilter getNumberScan() { | |||
| return numberScan; | |||
| } | |||
| public void setNumberScan(IntegerFilter numberScan) { | |||
| this.numberScan = numberScan; | |||
| } | |||
| public StringFilter getStatus() { | |||
| return status; | |||
| } | |||
| public void setStatus(StringFilter status) { | |||
| this.status = status; | |||
| } | |||
| public InstantFilter getExpiredDate() { | |||
| return expiredDate; | |||
| } | |||
| public void setExpiredDate(InstantFilter expiredDate) { | |||
| this.expiredDate = expiredDate; | |||
| } | |||
| public InstantFilter getModifiedDate() { | |||
| return modifiedDate; | |||
| } | |||
| public void setModifiedDate(InstantFilter modifiedDate) { | |||
| this.modifiedDate = modifiedDate; | |||
| } | |||
| public InstantFilter getDeletedDate() { | |||
| return deletedDate; | |||
| } | |||
| public void setDeletedDate(InstantFilter deletedDate) { | |||
| this.deletedDate = deletedDate; | |||
| } | |||
| public LongFilter getCreatedById() { | |||
| return createdById; | |||
| } | |||
| public void setCreatedById(LongFilter createdById) { | |||
| this.createdById = createdById; | |||
| } | |||
| public LongFilter getModifiedById() { | |||
| return modifiedById; | |||
| } | |||
| public void setModifiedById(LongFilter modifiedById) { | |||
| this.modifiedById = modifiedById; | |||
| } | |||
| public LongFilter getDeletedById() { | |||
| return deletedById; | |||
| } | |||
| public void setDeletedById(LongFilter deletedById) { | |||
| this.deletedById = deletedById; | |||
| } | |||
| } | |||
| @@ -0,0 +1,129 @@ | |||
| package vn.azteam.tpf.service.dto; | |||
| import vn.azteam.tpf.domain.TBCodeDetailsStatusEnum; | |||
| import java.io.Serializable; | |||
| import java.time.Instant; | |||
| public class TBCodeDetailsDTO implements Serializable { | |||
| private Long id; | |||
| private TBCodeDTO tbCode; | |||
| private String code; | |||
| private Integer numberScan; | |||
| private TBCodeDetailsStatusEnum status; | |||
| private Instant expiredDate; | |||
| private Instant createdDate; | |||
| private Instant modifiedDate; | |||
| private Instant deletedDate; | |||
| private Long createdById; | |||
| private Long modifiedById; | |||
| private Long deletedById; | |||
| public Long getId() { | |||
| return id; | |||
| } | |||
| public void setId(Long id) { | |||
| this.id = id; | |||
| } | |||
| public TBCodeDTO getTbCode() { | |||
| return tbCode; | |||
| } | |||
| public void setTbCode(TBCodeDTO tbCode) { | |||
| this.tbCode = tbCode; | |||
| } | |||
| public String getCode() { | |||
| return code; | |||
| } | |||
| public void setCode(String code) { | |||
| this.code = code; | |||
| } | |||
| public Integer getNumberScan() { | |||
| return numberScan; | |||
| } | |||
| public void setNumberScan(Integer numberScan) { | |||
| this.numberScan = numberScan; | |||
| } | |||
| public TBCodeDetailsStatusEnum getStatus() { | |||
| return status; | |||
| } | |||
| public void setStatus(TBCodeDetailsStatusEnum status) { | |||
| this.status = status; | |||
| } | |||
| public Instant getExpiredDate() { | |||
| return expiredDate; | |||
| } | |||
| public void setExpiredDate(Instant expiredDate) { | |||
| this.expiredDate = expiredDate; | |||
| } | |||
| public Instant getCreatedDate() { | |||
| return createdDate; | |||
| } | |||
| public void setCreatedDate(Instant createdDate) { | |||
| this.createdDate = createdDate; | |||
| } | |||
| public Instant getModifiedDate() { | |||
| return modifiedDate; | |||
| } | |||
| public void setModifiedDate(Instant modifiedDate) { | |||
| this.modifiedDate = modifiedDate; | |||
| } | |||
| public Instant getDeletedDate() { | |||
| return deletedDate; | |||
| } | |||
| public void setDeletedDate(Instant deletedDate) { | |||
| this.deletedDate = deletedDate; | |||
| } | |||
| public Long getCreatedById() { | |||
| return createdById; | |||
| } | |||
| public void setCreatedById(Long createdById) { | |||
| this.createdById = createdById; | |||
| } | |||
| public Long getModifiedById() { | |||
| return modifiedById; | |||
| } | |||
| public void setModifiedById(Long modifiedById) { | |||
| this.modifiedById = modifiedById; | |||
| } | |||
| public Long getDeletedById() { | |||
| return deletedById; | |||
| } | |||
| public void setDeletedById(Long deletedById) { | |||
| this.deletedById = deletedById; | |||
| } | |||
| } | |||
| @@ -0,0 +1,14 @@ | |||
| package vn.azteam.tpf.service.impl; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import vn.azteam.tpf.service.TBCodeDetailsService; | |||
| /** | |||
| * Service Implementation for managing TBCodeDetails. | |||
| */ | |||
| @Service | |||
| @Transactional | |||
| public class TBCodeDetailsImpl implements TBCodeDetailsService { | |||
| } | |||
| @@ -0,0 +1,15 @@ | |||
| package vn.azteam.tpf.service.impl; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import vn.azteam.tpf.service.TBCodeService; | |||
| /** | |||
| * Service Implementation for managing TBCode. | |||
| */ | |||
| @Service | |||
| @Transactional | |||
| public class TBCodeServiceImpl implements TBCodeService { | |||
| } | |||
| @@ -0,0 +1,9 @@ | |||
| package vn.azteam.tpf.service.mapper; | |||
| import org.mapstruct.Mapper; | |||
| import vn.azteam.tpf.domain.TBCodeDetails; | |||
| import vn.azteam.tpf.service.dto.TBCodeDetailsDTO; | |||
| @Mapper(componentModel = "spring", uses = {}) | |||
| public interface TBCodeDetailsMapper extends EntityMapper<TBCodeDetailsDTO, TBCodeDetails> { | |||
| } | |||
| @@ -0,0 +1,10 @@ | |||
| package vn.azteam.tpf.service.mapper; | |||
| import org.mapstruct.Mapper; | |||
| import vn.azteam.tpf.domain.TBCode; | |||
| import vn.azteam.tpf.service.dto.TBCodeDTO; | |||
| @Mapper(componentModel = "spring", uses = {}) | |||
| public interface TBCodeMapper extends EntityMapper<TBCodeDTO, TBCode> { | |||
| TBCodeDTO toDto(TBCode tbCode); | |||
| } | |||
| @@ -3,7 +3,6 @@ package vn.azteam.tpf.service.util; | |||
| import com.google.common.collect.Lists; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.context.annotation.Lazy; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.PageImpl; | |||
| import org.springframework.data.domain.Pageable; | |||
| @@ -31,10 +30,10 @@ public class PageableUtil { | |||
| return new PageImpl<>(Lists.newArrayList(), pageable, tbObjectParameterDTOs.size()); | |||
| } | |||
| public Page<TBActivityTypeDTO> changeTBActivityTypeDTOToPageFromList(List<TBActivityTypeDTO> tBActivityTypeDTOs, Pageable pageable){ | |||
| public Page<TBActivityTypeDTO> changeTBActivityTypeDTOToPageFromList(List<TBActivityTypeDTO> tBActivityTypeDTOs, Pageable pageable) { | |||
| int start = Math.toIntExact(pageable.getOffset()); | |||
| int end = Math.toIntExact((start + pageable.getPageSize()) > tBActivityTypeDTOs.size() ? tBActivityTypeDTOs.size() : (start + pageable.getPageSize())); | |||
| if(tBActivityTypeDTOs.size() > start) { | |||
| if (tBActivityTypeDTOs.size() > start) { | |||
| return new PageImpl<>(tBActivityTypeDTOs.subList(start, end), pageable, tBActivityTypeDTOs.size()); | |||
| } | |||
| return new PageImpl<>(Lists.newArrayList(), pageable, tBActivityTypeDTOs.size()); | |||
| @@ -60,19 +59,19 @@ public class PageableUtil { | |||
| } | |||
| public Page<TBDetailUserDTO> changeTBDetailUserDTOToPageFromList(List<TBDetailUserDTO> tbDetailUserDTOS, Pageable pageable){ | |||
| public Page<TBDetailUserDTO> changeTBDetailUserDTOToPageFromList(List<TBDetailUserDTO> tbDetailUserDTOS, Pageable pageable) { | |||
| int start = Math.toIntExact(pageable.getOffset()); | |||
| int end = Math.toIntExact((start + pageable.getPageSize()) > tbDetailUserDTOS.size() ? tbDetailUserDTOS.size() : (start + pageable.getPageSize())); | |||
| if(tbDetailUserDTOS.size() > start) { | |||
| if (tbDetailUserDTOS.size() > start) { | |||
| return new PageImpl<>(tbDetailUserDTOS.subList(start, end), pageable, tbDetailUserDTOS.size()); | |||
| } | |||
| return new PageImpl<>(Lists.newArrayList(), pageable, tbDetailUserDTOS.size()); | |||
| } | |||
| public Page<TBEquipmentDTO> changeTBEquipmentDTOToPageFromList(List<TBEquipmentDTO> tbEquipmentDTOS, Pageable pageable){ | |||
| public Page<TBEquipmentDTO> changeTBEquipmentDTOToPageFromList(List<TBEquipmentDTO> tbEquipmentDTOS, Pageable pageable) { | |||
| int start = Math.toIntExact(pageable.getOffset()); | |||
| int end = Math.toIntExact((start + pageable.getPageSize()) > tbEquipmentDTOS.size() ? tbEquipmentDTOS.size() : (start + pageable.getPageSize())); | |||
| if(tbEquipmentDTOS.size() > start) { | |||
| if (tbEquipmentDTOS.size() > start) { | |||
| return new PageImpl<>(tbEquipmentDTOS.subList(start, end), pageable, tbEquipmentDTOS.size()); | |||
| } | |||
| return new PageImpl<>(Lists.newArrayList(), pageable, tbEquipmentDTOS.size()); | |||
| @@ -87,10 +86,10 @@ public class PageableUtil { | |||
| return new PageImpl<>(Lists.newArrayList(), pageable, tbGuidelineDTOS.size()); | |||
| } | |||
| public Page<TBNotificationDTO> changeTBNotificationDTOToPageFromList(List<TBNotificationDTO> tbNotificationDTOS, Pageable pageable){ | |||
| public Page<TBNotificationDTO> changeTBNotificationDTOToPageFromList(List<TBNotificationDTO> tbNotificationDTOS, Pageable pageable) { | |||
| int start = Math.toIntExact(pageable.getOffset()); | |||
| int end = Math.toIntExact((start + pageable.getPageSize()) > tbNotificationDTOS.size() ? tbNotificationDTOS.size() : (start + pageable.getPageSize())); | |||
| if(tbNotificationDTOS.size() > start) { | |||
| if (tbNotificationDTOS.size() > start) { | |||
| return new PageImpl<>(tbNotificationDTOS.subList(start, end), pageable, tbNotificationDTOS.size()); | |||
| } | |||
| return new PageImpl<>(Lists.newArrayList(), pageable, tbNotificationDTOS.size()); | |||
| @@ -140,4 +139,13 @@ public class PageableUtil { | |||
| } | |||
| return new PageImpl<>(Lists.newArrayList(), pageable, tbCropDTOS.size()); | |||
| } | |||
| public Page<TBCodeDTO> changeTBCodeDTOToPageFromList(List<TBCodeDTO> tbCodeDTOS, Pageable pageable) { | |||
| int start = Math.toIntExact(pageable.getOffset()); | |||
| int end = Math.toIntExact((start + pageable.getPageSize()) > tbCodeDTOS.size() ? tbCodeDTOS.size() : (start + pageable.getPageSize())); | |||
| if (tbCodeDTOS.size() > start) { | |||
| return new PageImpl<>(tbCodeDTOS.subList(start, end), pageable, tbCodeDTOS.size()); | |||
| } | |||
| return new PageImpl<>(Lists.newArrayList(), pageable, tbCodeDTOS.size()); | |||
| } | |||
| } | |||
| @@ -0,0 +1,33 @@ | |||
| package vn.azteam.tpf.web.rest; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import vn.azteam.tpf.service.TBCodeDetailsQueryService; | |||
| import vn.azteam.tpf.service.TBCodeDetailsService; | |||
| import vn.azteam.tpf.service.util.PageableUtil; | |||
| import vn.azteam.tpf.service.util.UserRoleUtil; | |||
| @RestController | |||
| @RequestMapping("/api") | |||
| public class TBCodeDetailsResource { | |||
| private final Logger log = LoggerFactory.getLogger(TBCodeDetailsResource.class); | |||
| private final TBCodeDetailsService tBCodeDetailsService; | |||
| private final TBCodeDetailsQueryService tBCodeDetailsQueryService; | |||
| private final UserRoleUtil userRoleUtil; | |||
| private final PageableUtil pageableUtil; | |||
| public TBCodeDetailsResource(TBCodeDetailsService tBCodeDetailsService, TBCodeDetailsQueryService tBCodeDetailsQueryService, UserRoleUtil userRoleUtil, PageableUtil pageableUtil) { | |||
| this.tBCodeDetailsService = tBCodeDetailsService; | |||
| this.tBCodeDetailsQueryService = tBCodeDetailsQueryService; | |||
| this.userRoleUtil = userRoleUtil; | |||
| this.pageableUtil = pageableUtil; | |||
| } | |||
| } | |||