mirror of
https://github.com/cna-bootcamp/lifesub.git
synced 2026-06-12 20:49:09 +00:00
release
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
dependencies {
|
||||
implementation project(':common')
|
||||
implementation 'org.springframework:spring-tx'
|
||||
}
|
||||
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// Category.java
|
||||
package com.unicorn.lifesub.mysub.biz.domain;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class Category {
|
||||
private final String categoryId;
|
||||
private final String name;
|
||||
|
||||
@Builder
|
||||
public Category(String categoryId, String name) {
|
||||
this.categoryId = categoryId;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.unicorn.lifesub.mysub.biz.domain;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class MySubscription {
|
||||
private final Long id;
|
||||
private final String userId;
|
||||
private final Subscription subscription;
|
||||
|
||||
@Builder
|
||||
public MySubscription(Long id, String userId, Subscription subscription) {
|
||||
this.id = id;
|
||||
this.userId = userId;
|
||||
this.subscription = subscription;
|
||||
}
|
||||
|
||||
public int getPrice() {
|
||||
return subscription.getPrice();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.unicorn.lifesub.mysub.biz.domain;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class Subscription {
|
||||
private final Long id;
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final String category;
|
||||
private final int price;
|
||||
private final int maxSharedUsers;
|
||||
private final String logoUrl;
|
||||
|
||||
@Builder
|
||||
public Subscription(Long id, String name, String description, String category,
|
||||
int price, int maxSharedUsers, String logoUrl) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.category = category;
|
||||
this.price = price;
|
||||
this.maxSharedUsers = maxSharedUsers;
|
||||
this.logoUrl = logoUrl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// CategoryResponse.java
|
||||
package com.unicorn.lifesub.mysub.biz.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class CategoryResponse {
|
||||
private final String categoryId;
|
||||
private final String categoryName;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.unicorn.lifesub.mysub.biz.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class MySubResponse {
|
||||
private final String serviceName;
|
||||
private final String logoUrl;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.unicorn.lifesub.mysub.biz.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
|
||||
public class ServiceListResponse {
|
||||
private String serviceId;
|
||||
private String serviceName;
|
||||
private String description;
|
||||
private int price;
|
||||
private String logoUrl;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.unicorn.lifesub.mysub.biz.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
|
||||
public class SubDetailResponse {
|
||||
private final String serviceName;
|
||||
private final String logoUrl;
|
||||
private final String category;
|
||||
private final String description;
|
||||
private final int price;
|
||||
private final int maxSharedUsers;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.unicorn.lifesub.mysub.biz.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class TotalFeeResponse {
|
||||
private final Long totalFee;
|
||||
private final String feeLevel;
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.unicorn.lifesub.mysub.biz.service;
|
||||
|
||||
import com.unicorn.lifesub.mysub.biz.domain.MySubscription;
|
||||
import com.unicorn.lifesub.mysub.biz.dto.MySubResponse;
|
||||
import com.unicorn.lifesub.mysub.biz.dto.TotalFeeResponse;
|
||||
import com.unicorn.lifesub.mysub.biz.usecase.in.MySubscriptionsUseCase;
|
||||
import com.unicorn.lifesub.mysub.biz.usecase.in.TotalFeeUseCase;
|
||||
import com.unicorn.lifesub.mysub.biz.usecase.out.MySubscriptionReader;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MySubscriptionService implements TotalFeeUseCase, MySubscriptionsUseCase {
|
||||
private final MySubscriptionReader mySubscriptionReader;
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public TotalFeeResponse getTotalFee(String userId) {
|
||||
List<MySubscription> subscriptions = mySubscriptionReader.findByUserId(userId);
|
||||
long totalFee = subscriptions.stream()
|
||||
.mapToLong(MySubscription::getPrice)
|
||||
.sum();
|
||||
|
||||
return TotalFeeResponse.builder()
|
||||
.totalFee(totalFee)
|
||||
.feeLevel(calculateFeeLevel(totalFee))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<MySubResponse> getMySubscriptions(String userId) {
|
||||
return mySubscriptionReader.findByUserId(userId).stream()
|
||||
.map(subscription -> MySubResponse.builder()
|
||||
.serviceName(subscription.getSubscription().getName())
|
||||
.logoUrl(subscription.getSubscription().getLogoUrl())
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private String calculateFeeLevel(long totalFee) {
|
||||
if (totalFee < 100000) return "구독을 좋아하는 사람";
|
||||
if (totalFee < 200000) return "구독 수집자";
|
||||
return "구독 사치왕";
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package com.unicorn.lifesub.mysub.biz.usecase.in;
|
||||
|
||||
public interface CancelSubscriptionUseCase {
|
||||
void cancel(Long subscriptionId);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.unicorn.lifesub.mysub.biz.usecase.in;
|
||||
|
||||
import com.unicorn.lifesub.mysub.biz.dto.CategoryResponse;
|
||||
import com.unicorn.lifesub.mysub.biz.dto.ServiceListResponse;
|
||||
import java.util.List;
|
||||
|
||||
public interface CategoryUseCase {
|
||||
List<CategoryResponse> getAllCategories();
|
||||
List<ServiceListResponse> getServicesByCategory(String categoryId);
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.unicorn.lifesub.mysub.biz.usecase.in;
|
||||
|
||||
import com.unicorn.lifesub.mysub.biz.dto.MySubResponse;
|
||||
import java.util.List;
|
||||
|
||||
public interface MySubscriptionsUseCase {
|
||||
List<MySubResponse> getMySubscriptions(String userId);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.unicorn.lifesub.mysub.biz.usecase.in;
|
||||
|
||||
public interface SubscribeUseCase {
|
||||
void subscribe(Long subscriptionId, String userId);
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.unicorn.lifesub.mysub.biz.usecase.in;
|
||||
|
||||
import com.unicorn.lifesub.mysub.biz.dto.SubDetailResponse;
|
||||
|
||||
public interface SubscriptionDetailUseCase {
|
||||
SubDetailResponse getSubscriptionDetail(Long subscriptionId);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.unicorn.lifesub.mysub.biz.usecase.in;
|
||||
|
||||
import com.unicorn.lifesub.mysub.biz.dto.TotalFeeResponse;
|
||||
|
||||
public interface TotalFeeUseCase {
|
||||
TotalFeeResponse getTotalFee(String userId);
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.unicorn.lifesub.mysub.biz.usecase.out;
|
||||
|
||||
import com.unicorn.lifesub.mysub.biz.domain.MySubscription;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface MySubscriptionReader {
|
||||
List<MySubscription> findByUserId(String userId);
|
||||
Optional<MySubscription> findById(Long id);
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.unicorn.lifesub.mysub.biz.usecase.out;
|
||||
|
||||
import com.unicorn.lifesub.mysub.biz.domain.MySubscription;
|
||||
|
||||
public interface MySubscriptionWriter {
|
||||
MySubscription save(String userId, Long subscriptionId);
|
||||
void delete(Long id);
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.unicorn.lifesub.mysub.biz.usecase.out;
|
||||
|
||||
import com.unicorn.lifesub.mysub.biz.domain.Category;
|
||||
import com.unicorn.lifesub.mysub.biz.domain.Subscription;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface SubscriptionReader {
|
||||
Optional<Subscription> findById(Long id);
|
||||
List<Subscription> findByCategory(String categoryId);
|
||||
List<Category> findAllCategories();
|
||||
}
|
||||
Reference in New Issue
Block a user