Skip to content

Brand 허가 상태 변경 오류 수정 #55

Description

@taeGnues

@transactional 키워드를 명시해서 DB에 flush를 하지 않느 오류를 수정.
save만 사용하면 flush가 발생하지 않아서 문제가 생김.

Before

    @Override
    public void changeBrandAuthority(Long brandId, AuthorityStatus status) {
        Brand brand = brandRepository.findById(brandId).orElseThrow(
                () -> new BaseException(ErrorCode.BRAND_BY_SELLER_NOT_FOUND)
        );

        switch (status) {
            case DENIED -> brand.deny();
            case PENDING -> brand.pending();
            case APPROVED -> brand.approve();
        }

        brandRepository.save(brand);
    }

After

    /*
    브랜드등록 거부
     */
    @Transactional
    public void denyBrandPost(Long brandId){
        brandService.changeBrandAuthority(brandId, AuthorityStatus.DENIED);

        // TODO : 1. 해당 브랜드가 판매하는 모든 등록된 상품들 deny
    }

......
    @Override
    public void changeBrandAuthority(Long brandId, AuthorityStatus status) {
        Brand brand = brandRepository.findById(brandId).orElseThrow(
                () -> new BaseException(ErrorCode.BRAND_BY_SELLER_NOT_FOUND)
        );
        log.info("[changeBrandAuthority] before brand status {}", brand.getAuthorityStatus());
        switch (status) {
            case DENIED -> brand.deny();
            case PENDING -> brand.pending();
            case APPROVED -> brand.approve();
        }
        log.info("[changeBrandAuthority] after brand status {}", brand.getAuthorityStatus());
    }

Metadata

Metadata

Assignees

Labels

버그Something isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions