| @@ -113,6 +113,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { | |||
| .and() | |||
| .authorizeRequests() | |||
| .antMatchers("/api/register").permitAll() | |||
| .antMatchers("/api/tb-code-details/scan/**").permitAll() | |||
| .antMatchers("/api/activate").permitAll() | |||
| .antMatchers("/api/authenticate").permitAll() | |||
| .antMatchers("/api/account/reset-password/init").permitAll() | |||
| @@ -54,6 +54,11 @@ public class TBCode implements Serializable { | |||
| @Column(name = "tb_example_stamp_id", insertable = false, updatable = false) | |||
| private Long tbExampleStampId; | |||
| // @JsonIgnore | |||
| // @OneToOne | |||
| // @JoinColumn(name = "tb_example_stamp_id") | |||
| // private TBExampleStamp tbExampleStamp; | |||
| @Column(name = "created_date") | |||
| private Instant createdDate; | |||
| @@ -233,4 +238,12 @@ public class TBCode implements Serializable { | |||
| public void setTbExampleStampId(Long tbExampleStampId) { | |||
| this.tbExampleStampId = tbExampleStampId; | |||
| } | |||
| // public TBExampleStamp getTbExampleStamp() { | |||
| // return tbExampleStamp; | |||
| // } | |||
| // | |||
| // public void setTbExampleStamp(TBExampleStamp tbExampleStamp) { | |||
| // this.tbExampleStamp = tbExampleStamp; | |||
| // } | |||
| } | |||
| @@ -51,7 +51,7 @@ public class AuthzFilter extends GenericFilterBean { | |||
| "/api/update-common-activity-guideline-details/", | |||
| "/api/delete-common-activity-guideline-details/", | |||
| "/api/tb-customers-api-key", | |||
| "/api/tb-code-details/scan/", | |||
| // "/api/tb-code-details/scan/", | |||
| "/api/notification/update-person-in-charge")); | |||
| List<String> whiteListWithGetMethod = new ArrayList<>( | |||
| @@ -143,7 +143,8 @@ public class AuthzFilter extends GenericFilterBean { | |||
| "/api/tb-codes", | |||
| "/api/tb-code-details", | |||
| "/api/activity-environment-update/", | |||
| "/api/tb-example-stamp")); | |||
| "/api/tb-example-stamp", | |||
| "/api/tb-code-details/scan/")); | |||
| List<String> apiKeyListWithGetMethod = new ArrayList<>( | |||
| Arrays.asList( | |||
| @@ -7,9 +7,11 @@ import org.springframework.transaction.annotation.Transactional; | |||
| import vn.azteam.tpf.domain.TBCode; | |||
| import vn.azteam.tpf.domain.TBCodeDetails; | |||
| import vn.azteam.tpf.domain.TBCodeStatusEnum; | |||
| import vn.azteam.tpf.domain.TBExampleStamp; | |||
| import vn.azteam.tpf.repository.TBCodeDetailsRepository; | |||
| import vn.azteam.tpf.repository.TBCodeRepository; | |||
| import vn.azteam.tpf.repository.TBDetailUserRepository; | |||
| import vn.azteam.tpf.repository.TBExampleStampRepository; | |||
| import vn.azteam.tpf.repository.search.TBCodeSearchRepository; | |||
| import vn.azteam.tpf.service.TBCodeDetailsService; | |||
| import vn.azteam.tpf.service.TBCodeService; | |||
| @@ -40,6 +42,8 @@ public class TBCodeServiceImpl implements TBCodeService { | |||
| private final TBCodeRepository tbCodeRepository; | |||
| private final TBExampleStampRepository tbExampleStampRepository; | |||
| private final TBCodeDetailsRepository tbCodeDetailsRepository; | |||
| private final TBCodeDetailsService tbCodeDetailsService; | |||
| @@ -50,10 +54,11 @@ public class TBCodeServiceImpl implements TBCodeService { | |||
| private final TBDetailUserRepository tBDetailUserRepository; | |||
| public TBCodeServiceImpl(TBCodeRepository tbCodeRepository, | |||
| TBCodeDetailsRepository tbCodeDetailsRepository, TBCodeDetailsService tbCodeDetailsService, TBCodeMapper tBCodeMapper, | |||
| TBExampleStampRepository tbExampleStampRepository, TBCodeDetailsRepository tbCodeDetailsRepository, TBCodeDetailsService tbCodeDetailsService, TBCodeMapper tBCodeMapper, | |||
| TBCodeSearchRepository tBCodeSearchRepository, | |||
| TBDetailUserRepository tBDetailUserRepository) { | |||
| this.tbCodeRepository = tbCodeRepository; | |||
| this.tbExampleStampRepository = tbExampleStampRepository; | |||
| this.tbCodeDetailsRepository = tbCodeDetailsRepository; | |||
| this.tbCodeDetailsService = tbCodeDetailsService; | |||
| this.tBCodeMapper = tBCodeMapper; | |||
| @@ -68,6 +73,13 @@ public class TBCodeServiceImpl implements TBCodeService { | |||
| log.debug("Request to save TBCodeDTO : {}", tBCodeDTO); | |||
| TBCode tbCode = tBCodeMapper.toEntity(tBCodeDTO); | |||
| if(tBCodeDTO.getTbExampleStampId() != null) { | |||
| Optional<TBExampleStamp> tbExampleStampOptional = | |||
| tbExampleStampRepository.findById(tBCodeDTO.getTbExampleStampId()); | |||
| if(tbExampleStampOptional.isPresent()) { | |||
| tbCode.setTbExampleStampId(tBCodeDTO.getTbExampleStampId()); | |||
| } | |||
| } | |||
| tbCode = tbCodeRepository.save(tbCode); | |||
| TBCodeDTO result = tBCodeMapper.toDto(tbCode); | |||
| tBCodeSearchRepository.save(tbCode); | |||
| @@ -14,6 +14,7 @@ public interface TBCodeMapper extends EntityMapper<TBCodeDTO, TBCode> { | |||
| TBCodeDTO toDto(TBCode tbCode); | |||
| @Mapping(source = "tbCrop", target = "tbCrop") | |||
| // @Mapping(source = "tbCrop", target = "tbCrop") | |||
| @Mapping(source = "createdById", target = "createdBy") | |||
| @Mapping(source = "modifiedById", target = "modifiedBy") | |||
| @Mapping(source = "deletedById", target = "deletedBy") | |||
| @@ -274,8 +274,8 @@ public class TBCodeResource { | |||
| if(!tbCode.isPresent()) { | |||
| throw new BadRequestAlertException("1047", ENTITY_NAME, "1047"); | |||
| } else { | |||
| if(!tbCode.get().getStatus().equals(TBCodeStatusEnum.ACTIVE) | |||
| || !tbCode.get().getStatus().equals(TBCodeStatusEnum.NEW)) { | |||
| if(tbCode.get().getStatus().equals(TBCodeStatusEnum.EXPIRED) | |||
| || tbCode.get().getStatus().equals(TBCodeStatusEnum.CANCELED)) { | |||
| throw new BadRequestAlertException("1047", "TB Code is not active", "1047"); | |||
| } | |||
| } | |||