| .and() | .and() | ||||
| .authorizeRequests() | .authorizeRequests() | ||||
| .antMatchers("/api/register").permitAll() | .antMatchers("/api/register").permitAll() | ||||
| .antMatchers("/api/tb-code-details/scan/**").permitAll() | |||||
| .antMatchers("/api/activate").permitAll() | .antMatchers("/api/activate").permitAll() | ||||
| .antMatchers("/api/authenticate").permitAll() | .antMatchers("/api/authenticate").permitAll() | ||||
| .antMatchers("/api/account/reset-password/init").permitAll() | .antMatchers("/api/account/reset-password/init").permitAll() |
| @Column(name = "tb_example_stamp_id", insertable = false, updatable = false) | @Column(name = "tb_example_stamp_id", insertable = false, updatable = false) | ||||
| private Long tbExampleStampId; | private Long tbExampleStampId; | ||||
| // @JsonIgnore | |||||
| // @OneToOne | |||||
| // @JoinColumn(name = "tb_example_stamp_id") | |||||
| // private TBExampleStamp tbExampleStamp; | |||||
| @Column(name = "created_date") | @Column(name = "created_date") | ||||
| private Instant createdDate; | private Instant createdDate; | ||||
| public void setTbExampleStampId(Long tbExampleStampId) { | public void setTbExampleStampId(Long tbExampleStampId) { | ||||
| this.tbExampleStampId = tbExampleStampId; | this.tbExampleStampId = tbExampleStampId; | ||||
| } | } | ||||
| // public TBExampleStamp getTbExampleStamp() { | |||||
| // return tbExampleStamp; | |||||
| // } | |||||
| // | |||||
| // public void setTbExampleStamp(TBExampleStamp tbExampleStamp) { | |||||
| // this.tbExampleStamp = tbExampleStamp; | |||||
| // } | |||||
| } | } |
| "/api/update-common-activity-guideline-details/", | "/api/update-common-activity-guideline-details/", | ||||
| "/api/delete-common-activity-guideline-details/", | "/api/delete-common-activity-guideline-details/", | ||||
| "/api/tb-customers-api-key", | "/api/tb-customers-api-key", | ||||
| "/api/tb-code-details/scan/", | |||||
| // "/api/tb-code-details/scan/", | |||||
| "/api/notification/update-person-in-charge")); | "/api/notification/update-person-in-charge")); | ||||
| List<String> whiteListWithGetMethod = new ArrayList<>( | List<String> whiteListWithGetMethod = new ArrayList<>( | ||||
| "/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")); | |||||
| "/api/tb-example-stamp", | |||||
| "/api/tb-code-details/scan/")); | |||||
| List<String> apiKeyListWithGetMethod = new ArrayList<>( | List<String> apiKeyListWithGetMethod = new ArrayList<>( | ||||
| Arrays.asList( | Arrays.asList( |
| import vn.azteam.tpf.domain.TBCode; | import vn.azteam.tpf.domain.TBCode; | ||||
| import vn.azteam.tpf.domain.TBCodeDetails; | import vn.azteam.tpf.domain.TBCodeDetails; | ||||
| import vn.azteam.tpf.domain.TBCodeStatusEnum; | import vn.azteam.tpf.domain.TBCodeStatusEnum; | ||||
| import vn.azteam.tpf.domain.TBExampleStamp; | |||||
| import vn.azteam.tpf.repository.TBCodeDetailsRepository; | import vn.azteam.tpf.repository.TBCodeDetailsRepository; | ||||
| import vn.azteam.tpf.repository.TBCodeRepository; | import vn.azteam.tpf.repository.TBCodeRepository; | ||||
| import vn.azteam.tpf.repository.TBDetailUserRepository; | import vn.azteam.tpf.repository.TBDetailUserRepository; | ||||
| import vn.azteam.tpf.repository.TBExampleStampRepository; | |||||
| import vn.azteam.tpf.repository.search.TBCodeSearchRepository; | import vn.azteam.tpf.repository.search.TBCodeSearchRepository; | ||||
| import vn.azteam.tpf.service.TBCodeDetailsService; | import vn.azteam.tpf.service.TBCodeDetailsService; | ||||
| import vn.azteam.tpf.service.TBCodeService; | import vn.azteam.tpf.service.TBCodeService; | ||||
| private final TBCodeRepository tbCodeRepository; | private final TBCodeRepository tbCodeRepository; | ||||
| private final TBExampleStampRepository tbExampleStampRepository; | |||||
| private final TBCodeDetailsRepository tbCodeDetailsRepository; | private final TBCodeDetailsRepository tbCodeDetailsRepository; | ||||
| private final TBCodeDetailsService tbCodeDetailsService; | private final TBCodeDetailsService tbCodeDetailsService; | ||||
| private final TBDetailUserRepository tBDetailUserRepository; | private final TBDetailUserRepository tBDetailUserRepository; | ||||
| public TBCodeServiceImpl(TBCodeRepository tbCodeRepository, | public TBCodeServiceImpl(TBCodeRepository tbCodeRepository, | ||||
| TBCodeDetailsRepository tbCodeDetailsRepository, TBCodeDetailsService tbCodeDetailsService, TBCodeMapper tBCodeMapper, | |||||
| TBExampleStampRepository tbExampleStampRepository, TBCodeDetailsRepository tbCodeDetailsRepository, TBCodeDetailsService tbCodeDetailsService, TBCodeMapper tBCodeMapper, | |||||
| TBCodeSearchRepository tBCodeSearchRepository, | TBCodeSearchRepository tBCodeSearchRepository, | ||||
| TBDetailUserRepository tBDetailUserRepository) { | TBDetailUserRepository tBDetailUserRepository) { | ||||
| this.tbCodeRepository = tbCodeRepository; | this.tbCodeRepository = tbCodeRepository; | ||||
| this.tbExampleStampRepository = tbExampleStampRepository; | |||||
| this.tbCodeDetailsRepository = tbCodeDetailsRepository; | this.tbCodeDetailsRepository = tbCodeDetailsRepository; | ||||
| this.tbCodeDetailsService = tbCodeDetailsService; | this.tbCodeDetailsService = tbCodeDetailsService; | ||||
| this.tBCodeMapper = tBCodeMapper; | this.tBCodeMapper = tBCodeMapper; | ||||
| log.debug("Request to save TBCodeDTO : {}", tBCodeDTO); | log.debug("Request to save TBCodeDTO : {}", tBCodeDTO); | ||||
| TBCode tbCode = tBCodeMapper.toEntity(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); | tbCode = tbCodeRepository.save(tbCode); | ||||
| TBCodeDTO result = tBCodeMapper.toDto(tbCode); | TBCodeDTO result = tBCodeMapper.toDto(tbCode); | ||||
| tBCodeSearchRepository.save(tbCode); | tBCodeSearchRepository.save(tbCode); |
| TBCodeDTO toDto(TBCode tbCode); | TBCodeDTO toDto(TBCode tbCode); | ||||
| @Mapping(source = "tbCrop", target = "tbCrop") | @Mapping(source = "tbCrop", target = "tbCrop") | ||||
| // @Mapping(source = "tbCrop", target = "tbCrop") | |||||
| @Mapping(source = "createdById", target = "createdBy") | @Mapping(source = "createdById", target = "createdBy") | ||||
| @Mapping(source = "modifiedById", target = "modifiedBy") | @Mapping(source = "modifiedById", target = "modifiedBy") | ||||
| @Mapping(source = "deletedById", target = "deletedBy") | @Mapping(source = "deletedById", target = "deletedBy") |
| if(!tbCode.isPresent()) { | if(!tbCode.isPresent()) { | ||||
| throw new BadRequestAlertException("1047", ENTITY_NAME, "1047"); | throw new BadRequestAlertException("1047", ENTITY_NAME, "1047"); | ||||
| } else { | } 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"); | throw new BadRequestAlertException("1047", "TB Code is not active", "1047"); | ||||
| } | } | ||||
| } | } |