Source

https://github.com/jjangsky/coupon

Tech Stacks

Springboot JPA Mysql Redis Kafka

요구사항

<aside> 💡 선착순 100명에게 할인 쿠폰을 제공하는 이벤트를 진행

**이 이벤트는 아래와 같은 조건을 만족하여야 한다.

</aside>

발생할 수 있는 문제점


Service Logic

 public void apply(Long userId){
    long count = couponRepository.count();
    if(count > 100){
        return;
    }
    couponRepository.save(new Coupon(userId));
}