| cm.createCache(vn.azteam.tpf.domain.TBProductBlockDetailsReport.class.getName(), jcacheConfiguration); | cm.createCache(vn.azteam.tpf.domain.TBProductBlockDetailsReport.class.getName(), jcacheConfiguration); | ||||
| cm.createCache(vn.azteam.tpf.domain.TBCode.class.getName(), jcacheConfiguration); | cm.createCache(vn.azteam.tpf.domain.TBCode.class.getName(), jcacheConfiguration); | ||||
| cm.createCache(vn.azteam.tpf.domain.TBCodeDetails.class.getName(), jcacheConfiguration); | cm.createCache(vn.azteam.tpf.domain.TBCodeDetails.class.getName(), jcacheConfiguration); | ||||
| cm.createCache(vn.azteam.tpf.domain.TBProductLabel.class.getName(), jcacheConfiguration); | |||||
| //cm.createCache(vn.azteam.tpf.domain.TBProductLabel.class.getName(), jcacheConfiguration); | |||||
| cm.createCache(vn.azteam.tpf.domain.TBExampleStamp.class.getName(), jcacheConfiguration); | |||||
| // jhipster-needle-ehcache-add-entry | // jhipster-needle-ehcache-add-entry | ||||
| }; | }; | ||||
| } | } |
| 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; | |||||
| @Entity | |||||
| @Table(name = "tb_example_stamp") | |||||
| @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) | |||||
| @Document(indexName = "smf_tbexamplestamp") | |||||
| public class TBExampleStamp implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | |||||
| @Id | |||||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | |||||
| private Long id; | |||||
| @Column(name = "example_stamp_name") | |||||
| private String exampleStampName; | |||||
| @Column(name = "description") | |||||
| private String description; | |||||
| @Column(name = "width") | |||||
| private Integer width; | |||||
| @Column(name = "height") | |||||
| private Integer height; | |||||
| @Column(name = "x") | |||||
| private Integer x; | |||||
| @Column(name = "y") | |||||
| private Integer y; | |||||
| @Column(name = "size") | |||||
| private Integer size; | |||||
| @Column(name = "example_stamp_image") | |||||
| private String exampleStampImage; | |||||
| @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 String getDescription() { | |||||
| return description; | |||||
| } | |||||
| public void setDescription(String description) { | |||||
| this.description = description; | |||||
| } | |||||
| 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; | |||||
| } | |||||
| public String getExampleStampName() { | |||||
| return exampleStampName; | |||||
| } | |||||
| public void setExampleStampName(String exampleStampName) { | |||||
| this.exampleStampName = exampleStampName; | |||||
| } | |||||
| public Integer getWidth() { | |||||
| return width; | |||||
| } | |||||
| public void setWidth(Integer width) { | |||||
| this.width = width; | |||||
| } | |||||
| public Integer getHeight() { | |||||
| return height; | |||||
| } | |||||
| public void setHeight(Integer height) { | |||||
| this.height = height; | |||||
| } | |||||
| public Integer getX() { | |||||
| return x; | |||||
| } | |||||
| public void setX(Integer x) { | |||||
| this.x = x; | |||||
| } | |||||
| public Integer getY() { | |||||
| return y; | |||||
| } | |||||
| public void setY(Integer y) { | |||||
| this.y = y; | |||||
| } | |||||
| public Integer getSize() { | |||||
| return size; | |||||
| } | |||||
| public void setSize(Integer size) { | |||||
| this.size = size; | |||||
| } | |||||
| public String getExampleStampImage() { | |||||
| return exampleStampImage; | |||||
| } | |||||
| public void setExampleStampImage(String exampleStampImage) { | |||||
| this.exampleStampImage = exampleStampImage; | |||||
| } | |||||
| } |
| 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.TBExampleStamp; | |||||
| import java.util.Optional; | |||||
| @Repository | |||||
| public interface TBExampleStampRepository extends JpaRepository<TBExampleStamp, Long>, JpaSpecificationExecutor<TBExampleStamp> { | |||||
| Optional<TBExampleStamp> findById(Long id); | |||||
| } |
| "/api/tb-crops-dropdown-list", | "/api/tb-crops-dropdown-list", | ||||
| "/api/tb-codes", | "/api/tb-codes", | ||||
| "/api/tb-code-details", | "/api/tb-code-details", | ||||
| "/api/activity-environment-update/")); | |||||
| "/api/activity-environment-update/", | |||||
| "/api/tb-example-stamp")); | |||||
| List<String> apiKeyListWithGetMethod = new ArrayList<>( | List<String> apiKeyListWithGetMethod = new ArrayList<>( | ||||
| Arrays.asList( | Arrays.asList( |
| 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.TBDetailUser; | |||||
| import vn.azteam.tpf.domain.TBDetailUser_; | |||||
| import vn.azteam.tpf.domain.TBExampleStamp; | |||||
| import vn.azteam.tpf.domain.TBExampleStamp_; | |||||
| import vn.azteam.tpf.repository.TBExampleStampRepository; | |||||
| import vn.azteam.tpf.service.dto.TBExampleStampCriteria; | |||||
| import vn.azteam.tpf.service.dto.TBExampleStampDTO; | |||||
| import vn.azteam.tpf.service.mapper.TBExampleStampMapper; | |||||
| import javax.persistence.criteria.Join; | |||||
| import javax.persistence.criteria.JoinType; | |||||
| @Service | |||||
| @Transactional(readOnly = true) | |||||
| public class TBExampleStampQueryService extends QueryService<TBExampleStamp> { | |||||
| private final Logger log = LoggerFactory.getLogger(TBExampleStampQueryService.class); | |||||
| private final TBExampleStampRepository tBExampleStampRepository; | |||||
| private final TBExampleStampMapper TBExampleStampMapper; | |||||
| public TBExampleStampQueryService(TBExampleStampRepository tBExampleStampRepository, vn.azteam.tpf.service.mapper.TBExampleStampMapper tbExampleStampMapper) { | |||||
| this.tBExampleStampRepository = tBExampleStampRepository; | |||||
| TBExampleStampMapper = tbExampleStampMapper; | |||||
| } | |||||
| @Transactional(readOnly = true) | |||||
| public Page<TBExampleStampDTO> findByCriteria(TBExampleStampCriteria criteria, Pageable page) { | |||||
| log.debug("find by criteria : {}, page: {}", criteria, page); | |||||
| final Specification<TBExampleStamp> specification = createSpecification(criteria); | |||||
| return tBExampleStampRepository.findAll(specification, page) | |||||
| .map(TBExampleStampMapper::toDto); | |||||
| } | |||||
| private Specification<TBExampleStamp> initializeTBExampleStampSpecification() { | |||||
| return (Specification<TBExampleStamp>) (root, query, cb) -> { | |||||
| final Join<TBExampleStamp, TBDetailUser> detailUserJoin = root.join(TBExampleStamp_.deletedBy, JoinType.LEFT); | |||||
| return cb.isNull(detailUserJoin.get(TBDetailUser_.id)); | |||||
| }; | |||||
| } | |||||
| /** | |||||
| * Function to convert TBCodeCriteria to a {@link Specification} | |||||
| */ | |||||
| private Specification<TBExampleStamp> createSpecification(TBExampleStampCriteria criteria) { | |||||
| Specification<TBExampleStamp> specification = initializeTBExampleStampSpecification(); | |||||
| if (criteria != null) { | |||||
| if (criteria.getId() != null) { | |||||
| specification = specification.and(buildSpecification(criteria.getId(), TBExampleStamp_.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(), TBExampleStamp_.description)); | |||||
| } | |||||
| // if (criteria.getAgeDayStartAt() != null) { | |||||
| // specification = specification.and(buildRangeSpecification(criteria.getAgeDayStartAt(), TBCrop_.ageDayStartAt)); | |||||
| // } | |||||
| if (criteria.getCreatedDate() != null) { | |||||
| specification = specification.and(buildRangeSpecification(criteria.getCreatedDate(), TBExampleStamp_.createdDate)); | |||||
| } | |||||
| if (criteria.getModifiedDate() != null) { | |||||
| specification = specification.and(buildRangeSpecification(criteria.getModifiedDate(), TBExampleStamp_.modifiedDate)); | |||||
| } | |||||
| if (criteria.getDeletedDate() != null) { | |||||
| specification = specification.and(buildRangeSpecification(criteria.getDeletedDate(), TBExampleStamp_.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(TBExampleStamp_.createdBy, JoinType.LEFT).get(TBDetailUser_.id))); | |||||
| } | |||||
| if (criteria.getModifiedById() != null) { | |||||
| specification = specification.and(buildSpecification(criteria.getModifiedById(), | |||||
| root -> root.join(TBExampleStamp_.modifiedBy, JoinType.LEFT).get(TBDetailUser_.id))); | |||||
| } | |||||
| if (criteria.getDeletedById() != null) { | |||||
| specification = specification.and(buildSpecification(criteria.getDeletedById(), | |||||
| root -> root.join(TBExampleStamp_.deletedBy, JoinType.LEFT).get(TBDetailUser_.id))); | |||||
| } | |||||
| // if (criteria.getTbDetailUserId() != null) { | |||||
| // specification = specification.and(buildSpecification(criteria.getTbDetailUserId(), | |||||
| // root -> root.join(TBExampleStamp_.tbDetailUsers, JoinType.LEFT).get(TBDetailUser_.id))); | |||||
| // } | |||||
| } | |||||
| return specification; | |||||
| } | |||||
| } |
| 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 TBExampleStampCriteria 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; | |||||
| public LongFilter getId() { | |||||
| return id; | |||||
| } | |||||
| public void setId(LongFilter id) { | |||||
| this.id = id; | |||||
| } | |||||
| public StringFilter getDescription() { | |||||
| return description; | |||||
| } | |||||
| public void setDescription(StringFilter description) { | |||||
| this.description = description; | |||||
| } | |||||
| 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; | |||||
| } | |||||
| } |
| package vn.azteam.tpf.service.dto; | |||||
| import java.io.Serializable; | |||||
| import java.time.Instant; | |||||
| public class TBExampleStampDTO implements Serializable { | |||||
| private Long id; | |||||
| private String exampleStampName; | |||||
| private String description; | |||||
| private Integer width; | |||||
| private Integer height; | |||||
| private Integer x; | |||||
| private Integer y; | |||||
| private Integer size; | |||||
| private String exampleStampImage; | |||||
| 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 String getExampleStampName() { | |||||
| return exampleStampName; | |||||
| } | |||||
| public void setExampleStampName(String exampleStampName) { | |||||
| this.exampleStampName = exampleStampName; | |||||
| } | |||||
| public String getDescription() { | |||||
| return description; | |||||
| } | |||||
| public void setDescription(String description) { | |||||
| this.description = description; | |||||
| } | |||||
| public Integer getWidth() { | |||||
| return width; | |||||
| } | |||||
| public void setWidth(Integer width) { | |||||
| this.width = width; | |||||
| } | |||||
| public Integer getHeight() { | |||||
| return height; | |||||
| } | |||||
| public void setHeight(Integer height) { | |||||
| this.height = height; | |||||
| } | |||||
| public Integer getX() { | |||||
| return x; | |||||
| } | |||||
| public void setX(Integer x) { | |||||
| this.x = x; | |||||
| } | |||||
| public Integer getY() { | |||||
| return y; | |||||
| } | |||||
| public void setY(Integer y) { | |||||
| this.y = y; | |||||
| } | |||||
| public Integer getSize() { | |||||
| return size; | |||||
| } | |||||
| public void setSize(Integer size) { | |||||
| this.size = size; | |||||
| } | |||||
| public String getExampleStampImage() { | |||||
| return exampleStampImage; | |||||
| } | |||||
| public void setExampleStampImage(String exampleStampImage) { | |||||
| this.exampleStampImage = exampleStampImage; | |||||
| } | |||||
| 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; | |||||
| } | |||||
| } |
| package vn.azteam.tpf.service.mapper; | |||||
| import org.mapstruct.Mapper; | |||||
| import org.mapstruct.Mapping; | |||||
| import vn.azteam.tpf.domain.TBExampleStamp; | |||||
| import vn.azteam.tpf.service.dto.TBExampleStampDTO; | |||||
| @Mapper(componentModel = "spring", uses = {TBDetailUserMapper.class}) | |||||
| public interface TBExampleStampMapper extends EntityMapper<TBExampleStampDTO, TBExampleStamp> { | |||||
| @Mapping(source = "createdBy.id", target = "createdById") | |||||
| @Mapping(source = "modifiedBy.id", target = "modifiedById") | |||||
| @Mapping(source = "deletedBy.id", target = "deletedById") | |||||
| TBExampleStampDTO toDto(TBExampleStamp tBExampleStamp); | |||||
| //@Mapping(source = "tbCrop", target = "tbCrop") | |||||
| @Mapping(source = "createdById", target = "createdBy") | |||||
| @Mapping(source = "modifiedById", target = "modifiedBy") | |||||
| @Mapping(source = "deletedById", target = "deletedBy") | |||||
| TBExampleStamp toEntity(TBExampleStampDTO tBExampleStampDTO); | |||||
| default TBExampleStamp fromId(Long id) { | |||||
| if (id == null) { | |||||
| return null; | |||||
| } | |||||
| TBExampleStamp tbExampleStamp = new TBExampleStamp(); | |||||
| tbExampleStamp.setId(id); | |||||
| return tbExampleStamp; | |||||
| } | |||||
| } |
| } | } | ||||
| return new PageImpl<>(Lists.newArrayList(), pageable, tbCodeDTOS.size()); | return new PageImpl<>(Lists.newArrayList(), pageable, tbCodeDTOS.size()); | ||||
| } | } | ||||
| public Page<TBExampleStampDTO> changeTBExampleStampDTOToPageFromList(List<TBExampleStampDTO> tBExampleStampDTOS, | |||||
| Pageable pageable) { | |||||
| int start = Math.toIntExact(pageable.getOffset()); | |||||
| int end = Math.toIntExact((start + pageable.getPageSize()) > tBExampleStampDTOS.size() ? tBExampleStampDTOS.size() : (start + pageable.getPageSize())); | |||||
| if (tBExampleStampDTOS.size() > start) { | |||||
| return new PageImpl<>(tBExampleStampDTOS.subList(start, end), pageable, tBExampleStampDTOS.size()); | |||||
| } | |||||
| return new PageImpl<>(Lists.newArrayList(), pageable, tBExampleStampDTOS.size()); | |||||
| } | |||||
| } | } |
| package vn.azteam.tpf.web.rest; | |||||
| import com.codahale.metrics.annotation.Timed; | |||||
| 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.GetMapping; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import vn.azteam.tpf.service.TBExampleStampQueryService; | |||||
| import vn.azteam.tpf.service.dto.TBExampleStampCriteria; | |||||
| import vn.azteam.tpf.service.dto.TBExampleStampDTO; | |||||
| import vn.azteam.tpf.service.util.PageableUtil; | |||||
| import vn.azteam.tpf.service.util.UserRoleUtil; | |||||
| import vn.azteam.tpf.web.rest.util.PaginationUtil; | |||||
| import java.util.Comparator; | |||||
| import java.util.List; | |||||
| import java.util.stream.Collectors; | |||||
| @RestController | |||||
| @RequestMapping("/api") | |||||
| public class TBExampleStampResource { | |||||
| private static final String ENTITY_NAME = "tBExampleStamp"; | |||||
| private final Logger log = LoggerFactory.getLogger(TBExampleStampResource.class); | |||||
| private final TBExampleStampQueryService tBExampleStampQueryService; | |||||
| private final UserRoleUtil userRoleUtil; | |||||
| private final PageableUtil pageableUtil; | |||||
| public TBExampleStampResource(TBExampleStampQueryService tBExampleStampQueryService, UserRoleUtil userRoleUtil, PageableUtil pageableUtil){ | |||||
| this.tBExampleStampQueryService = tBExampleStampQueryService; | |||||
| this.userRoleUtil = userRoleUtil; | |||||
| this.pageableUtil = pageableUtil; | |||||
| } | |||||
| @GetMapping("/tb-example-stamp/dropdown-list") | |||||
| @Timed | |||||
| public ResponseEntity<List<TBExampleStampDTO>> getAllTBExampleStampForDropdown(TBExampleStampCriteria criteria) { | |||||
| log.debug("REST request to get TBExampleStamp by criteria: {}", criteria); | |||||
| Page<TBExampleStampDTO> page = tBExampleStampQueryService.findByCriteria(criteria, Pageable.unpaged()); | |||||
| //Authorize get list crop by customer of current user | |||||
| List<TBExampleStampDTO> result = page.getContent().stream() | |||||
| // .filter(item -> userRoleUtil.currentUserHasPermissionByCustomerId(item.getTbCrop().getId()) | |||||
| // && userRoleUtil.currentUserHasPermissionByCropId(item.getTbCrop().getId())) | |||||
| .sorted(Comparator.comparing( | |||||
| TBExampleStampDTO::getCreatedDate, | |||||
| Comparator.nullsFirst(Comparator.naturalOrder())).reversed()) | |||||
| .collect(Collectors.toList()); | |||||
| return ResponseEntity.ok().headers(null).body(result); | |||||
| } | |||||
| /** | |||||
| * GET /tb-example : get all the tb example. | |||||
| * | |||||
| * @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 TBCodes in body | |||||
| */ | |||||
| @GetMapping("/tb-example-stamp") | |||||
| @Timed | |||||
| public ResponseEntity<List<TBExampleStampDTO>> getAllTBCodes(TBExampleStampCriteria criteria, Pageable pageable) { | |||||
| log.debug("REST request to get TBCodes by criteria: {}", criteria); | |||||
| Page<TBExampleStampDTO> page = tBExampleStampQueryService.findByCriteria(criteria, Pageable.unpaged()); | |||||
| //Authorize get list crop by customer of current user | |||||
| List<TBExampleStampDTO> result = page.getContent().stream() | |||||
| //.filter(item -> userRoleUtil.currentUserHasPermissionByCustomerId(item.getTbCrop().getId()) | |||||
| // && userRoleUtil.currentUserHasPermissionByCropId(item.getTbCrop().getId())) | |||||
| .sorted(Comparator.comparing( | |||||
| TBExampleStampDTO::getCreatedDate, | |||||
| Comparator.nullsFirst(Comparator.naturalOrder())).reversed()) | |||||
| .collect(Collectors.toList()); | |||||
| Page<TBExampleStampDTO> pageResult = pageableUtil.changeTBExampleStampDTOToPageFromList(result, pageable); | |||||
| for (TBExampleStampDTO itemResult : result) { | |||||
| //logger.error("Start date: " + itemResult.getStartDate()); | |||||
| } | |||||
| HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(pageResult, "/api/tb-example-stamp"); | |||||
| return ResponseEntity.ok().headers(headers).body(pageResult.getContent()); | |||||
| } | |||||
| } |
| CREATE TABLE tb_example_stamp | |||||
| ( | |||||
| id bigint not null auto_increment, | |||||
| example_stamp_name varchar(255), | |||||
| description varchar(255), | |||||
| width int, | |||||
| height int, | |||||
| x int, | |||||
| y int, | |||||
| size int, | |||||
| example_stamp_image varchar(500), | |||||
| created_date timestamp, | |||||
| modified_date timestamp, | |||||
| deleted_date timestamp, | |||||
| created_by bigint, | |||||
| modified_by bigint, | |||||
| deleted_by bigint, | |||||
| PRIMARY KEY (id) | |||||
| ); | |||||