Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHORE] 용량 데이터 타입 변경 #240

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public record DocumentCreateRequest(
@NotNull String fileUrl,
@Schema(description = "파일 key", example = "....jpg")
@NotNull String fileKey,
@Schema(description = "파일 용량", example = "1.23")
@NotNull double capacity
@Schema(description = "파일 용량 (단위 : byte)", example = "123")
paragon0107 marked this conversation as resolved.
Show resolved Hide resolved
@NotNull long capacity
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private record DeletedDocumentGetResponse(
@NotNull long documentId,
@NotNull String name,
@NotNull String url,
@NotNull double capacity
@NotNull long capacity
) {

private static DeletedDocumentGetResponse from(final DeletedDocument deletedDocument) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private record DocumentInfoGetResponse(
@NotNull long documentId,
@NotNull String name,
@NotNull String url,
@NotNull double capacity,
@NotNull long capacity,
@NotNull LocalDateTime createdTime
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class DeletedDocument extends BaseTime {
private long teamId;

@Column(nullable = false)
private double capacity;
private long capacity;

public static DeletedDocument of(final Document document) {
return DeletedDocument.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class Document extends BaseTime {
private String fileKey;

@Column(nullable = false)
private double capacity;
private long capacity;

@Column(nullable = false)
private long teamId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,6 @@ private Document saveDocument(final Team team, final Long folderId, final Docume

private void restoreTeamUsage(final long teamId, final List<DeletedDocument> deletedDocuments) {
Team team = teamFinder.findById(teamId);
team.restoreUsage(deletedDocuments.stream().mapToDouble(DeletedDocument::getCapacity).sum());
team.restoreUsage(deletedDocuments.stream().mapToLong(DeletedDocument::getCapacity).sum());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public record DocumentTagGetServiceResponse(
@NotNull long id,
@NotNull String fileName,
@NotNull String fileUrl,
@NotNull double capacity
@NotNull long capacity
) {

public static DocumentTagGetServiceResponse from(final Document document) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private record DocumentGetResponse(
@NotNull long documentId,
@NotNull String name,
@NotNull String url,
@NotNull double capacity,
@NotNull long capacity,
@NotNull LocalDateTime createdTime,
@NotNull String type
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

@Builder(access = PRIVATE)
public record UsageGetResponse(
@NotNull double capacity,
@NotNull double usage
@NotNull long capacity,
@NotNull long usage
) {

public static UsageGetResponse of(final double capacity, final double usage) {
public static UsageGetResponse of(final long capacity, final long usage) {
return UsageGetResponse.builder()
.capacity(capacity)
.usage(usage)
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/tiki/server/team/entity/Subscribe.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

@Getter
public enum Subscribe {
BASIC(6000, 30000, 30, false),
ADVANCED(13000, 150000, 120, true),
PREMIUM(25000, 500000, 999999, true);
BASIC(6000, 30L * 1073741824, 30, false),
ADVANCED(13000, 150L * 1073741824, 120, true),
PREMIUM(25000, 500L * 1073741824, 999999, true);

private final int price;
private final double capacity;
private final long capacity;
private final int memberLimit;
private final boolean bannerDiscount;

Subscribe(final int price, final double capacity, final int memberLimit, final boolean bannerDiscount) {
Subscribe(final int price, final long capacity, final int memberLimit, final boolean bannerDiscount) {
this.price = price;
this.capacity = capacity;
this.memberLimit = memberLimit;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/tiki/server/team/entity/Team.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class Team extends BaseTime {
private Subscribe subscribe;

@Column(nullable = false)
private double usage;
private long usage;

private String imageUrl;

Expand Down Expand Up @@ -109,18 +109,18 @@ public boolean isSameIconUrl(final String iconImageUrl) {
return this.iconImageUrl.equals(iconImageUrl);
}

public void addUsage(final double capacity) {
public void addUsage(final long capacity) {
if (usage + capacity > subscribe.getCapacity()) {
throw new TeamException(EXCEED_TEAM_CAPACITY);
}
usage += capacity;
}

public void restoreUsage(final double capacity) {
public void restoreUsage(final long capacity) {
usage -= capacity;
}

public double getCapacity() {
public long getCapacity() {
return subscribe.getCapacity();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/tiki/server/team/service/TeamService.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public void alterAdmin(final long memberId, final long teamId, final long target
public UsageGetResponse getCapacityInfo(final long memberId, final long teamId) {
memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId);
Team team = teamFinder.findById(teamId);
double capacity = team.getCapacity();
double usage = team.getUsage();
long capacity = team.getCapacity();
long usage = team.getUsage();
return UsageGetResponse.of(capacity, usage);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private record DocumentDetailGetResponse(
@NotNull long documentId,
@NotNull String fileName,
@NotNull String fileUrl,
@NotNull double capacity,
@NotNull long capacity,
@NotNull long tagId
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public record DocumentTagInfo(
@NotNull long documentId,
@NotNull String fileName,
@NotNull String fileUrl,
@NotNull double capacity,
@NotNull long capacity,
@NotNull long tagId
) {

Expand Down