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

요청, 응답의 소수 데이터 타입을 Float으로 통일 #557

Closed
wants to merge 2 commits into from
Closed
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 @@ -27,7 +27,7 @@ public record ReadAuctionDto(
Long sellerId,
Long sellerProfileId,
String sellerName,
double sellerReliability,
Float sellerReliability,
boolean isSellerDeleted,
AuctionStatus auctionStatus
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.ddang.ddang.review.application.dto.ReadReviewDetailDto;
import jakarta.annotation.Nullable;

public record ReadReviewDetailResponse(@Nullable Double score, @Nullable String content) {
public record ReadReviewDetailResponse(@Nullable Float score, @Nullable String content) {

public static ReadReviewDetailResponse from(final ReadReviewDetailDto readReviewDetailDto) {
return new ReadReviewDetailResponse(readReviewDetailDto.score(), readReviewDetailDto.content());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public record SellerResponse(
Long id,
String image,
String nickname,
double reliability
Float reliability
) {

public static SellerResponse from(final ReadAuctionDto auctionDto) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private User findOrPersistUser(final Oauth2Type oauth2Type, final UserInformatio
final User user = User.builder()
.name(oauth2Type.calculateNickname(calculateRandomNumber()))
.profileImage(findDefaultProfileImage())
.reliability(new Reliability(0.0d))
.reliability(new Reliability(0.0f))
.oauthId(userInformationDto.findUserId())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.ddang.ddang.image.application.util.ImageIdProcessor;
import com.ddang.ddang.user.domain.User;

public record ReadUserInChatRoomDto(Long id, String name, Long profileImageId, double reliability, boolean isDeleted) {
public record ReadUserInChatRoomDto(Long id, String name, Long profileImageId, Float reliability, boolean isDeleted) {

public static ReadUserInChatRoomDto from(final User user) {
return new ReadUserInChatRoomDto(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ public void run(final ApplicationArguments args) {
final User seller1 = User.builder()
.name("판매자1")
.profileImage(new ProfileImage("upload.png", "updateImage.png"))
.reliability(new Reliability(4.7d))
.reliability(new Reliability(4.7f))
.oauthId("12345")
.build();

final User buyer1 = User.builder()
.name("구매자1")
.profileImage(new ProfileImage("upload.png", "updateImage.png"))
.reliability(new Reliability(3.0d))
.reliability(new Reliability(3.0f))
.oauthId("12346")
.build();

final User buyer2 = User.builder()
.name("구매자2")
.profileImage(new ProfileImage("upload.png", "updateImage.png"))
.reliability(new Reliability(0.8d))
.reliability(new Reliability(0.8f))
.oauthId("12347")
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.ddang.ddang.image.application.util.ImageIdProcessor;
import com.ddang.ddang.user.domain.User;

public record ReadReporterDto(Long id, String name, Long profileImageId, double reliability, boolean isDeleted) {
public record ReadReporterDto(Long id, String name, Long profileImageId, Float reliability, boolean isDeleted) {

public static ReadReporterDto from(final User reporter) {
return new ReadReporterDto(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public record ReadUserInReportDto(
Long id,
String name,
Long profileImageId,
double reliability,
Float reliability,
String oauthId,
boolean isSellerDeleted
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.ddang.ddang.review.presentation.dto.request.CreateReviewRequest;
import com.ddang.ddang.user.domain.User;

public record CreateReviewDto(Long auctionId, Long writerId, Long targetId, String content, Double score) {
public record CreateReviewDto(Long auctionId, Long writerId, Long targetId, String content, Float score) {

public static CreateReviewDto of(final Long writerId, final CreateReviewRequest createReviewRequest) {
return new CreateReviewDto(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import javax.annotation.Nullable;

public record ReadReviewDetailDto(@Nullable Double score, @Nullable String content) {
public record ReadReviewDetailDto(@Nullable Float score, @Nullable String content) {

private static final Double EMPTY_SCORE = null;
private static final Float EMPTY_SCORE = null;
private static final String EMPTY_CONTENT = null;
public static final ReadReviewDetailDto EMPTY = new ReadReviewDetailDto(EMPTY_SCORE, EMPTY_CONTENT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public record ReadReviewDto(
Long id,
ReadUserInReviewDto writer,
String content,
Double score,
Float score,
LocalDateTime createdTime
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.ddang.ddang.user.domain.User;

public record ReadUserInReviewDto(Long id, String name, Long profileImageId, double reliability, String oauthId) {
public record ReadUserInReviewDto(Long id, String name, Long profileImageId, Float reliability, String oauthId) {

public static ReadUserInReviewDto from(final User user) {
return new ReadUserInReviewDto(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
@ToString
public class Score {

private static final double SCORE_UNIT = 0.5;
private static final float SCORE_UNIT = 0.5f;

private double value;
private float value;

public Score(final double value) {
public Score(final float value) {
if (value % SCORE_UNIT != 0) {
throw new InvalidScoreException("평가 점수는 0.5 단위여야 합니다.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public record CreateReviewRequest(

@NotNull(message = "점수가 입력되지 않았습니다.")
@Positive(message = "점수는 양수여야 합니다.")
Double score
float score
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import jakarta.annotation.Nullable;


public record ReadReviewDetailResponse(@Nullable Double score, @Nullable String content) {
public record ReadReviewDetailResponse(@Nullable Float score, @Nullable String content) {

public static ReadReviewDetailResponse from(final ReadReviewDetailDto readReviewDetailDto) {
return new ReadReviewDetailResponse(readReviewDetailDto.score(), readReviewDetailDto.content());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public record ReadReviewResponse(

String content,

Double score,
Float score,

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "Asia/Seoul")
LocalDateTime createdTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public record ReadUserDto(
Long id,
String name,
Long profileImageId,
double reliability,
Float reliability,
String oauthId,
boolean isDeleted
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public class Reliability {

public static final Reliability INITIAL_RELIABILITY = new Reliability(null);

private Double value;
private Float value;

public Reliability(final Double value) {
public Reliability(final Float value) {
this.value = value;
}

Expand All @@ -32,9 +32,11 @@ public void updateReliability(final List<Review> reviews) {
return;
}

this.value = reviews.stream()
.mapToDouble(review -> review.getScore().getValue())
.average()
.orElseGet(null);
Float scoreSum = 0.0f;
for (final Review review : reviews) {
scoreSum += review.getScore().getValue();
}

this.value = scoreSum / reviews.size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.ddang.ddang.user.application.dto.ReadUserDto;
import com.ddang.ddang.user.presentation.util.NameProcessor;

public record ReadUserResponse(String name, String profileImage, double reliability) {
public record ReadUserResponse(String name, String profileImage, Float reliability) {

public static ReadUserResponse from(final ReadUserDto readUserDto) {
final String name = NameProcessor.process(readUserDto.isDeleted(), readUserDto.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.ddang.ddang.user.application.dto.ReadUserDto;
import com.ddang.ddang.user.presentation.util.NameProcessor;

public record ReadUserResponse(String name, String profileImage, double reliability) {
public record ReadUserResponse(String name, String profileImage, Float reliability) {

public static ReadUserResponse from(final ReadUserDto readUserDto) {
return new ReadUserResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ public record SellerResponse(
Long id,
String image,
String nickname,
double reliability
Float reliability
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ public class AuctionServiceFixture {
protected User 판매자 = User.builder()
.name("판매자")
.profileImage(new ProfileImage("upload.png", "store.png"))
.reliability(new Reliability(4.7d))
.reliability(new Reliability(4.7f))
.oauthId("12345")
.build();
protected User 구매자 = User.builder()
.name("구매자")
.profileImage(new ProfileImage("upload.png", "store.png"))
.reliability(new Reliability(4.7d))
.reliability(new Reliability(4.7f))
.oauthId("54321")
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ public class AuctionFixture {
protected User 판매자 = User.builder()
.name("판매자")
.profileImage(new ProfileImage("upload.png", "store.png"))
.reliability(new Reliability(4.7d))
.reliability(new Reliability(4.7f))
.oauthId("12345")
.build();
protected User 구매자 = User.builder()
.name("구매자")
.profileImage(new ProfileImage("upload.png", "store.png"))
.reliability(new Reliability(4.7d))
.reliability(new Reliability(4.7f))
.oauthId("54321")
.build();
protected User 사용자 = User.builder()
.name("사용자")
.profileImage(new ProfileImage("upload.png", "store.png"))
.reliability(new Reliability(4.7d))
.reliability(new Reliability(4.7f))
.oauthId("98765")
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void setUp() {
사용자 = User.builder()
.name("사용자")
.profileImage(new ProfileImage("upload.png", "store.png"))
.reliability(new Reliability(4.7d))
.reliability(new Reliability(4.7f))
.oauthId("12345")
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,43 +71,43 @@ void commonFixtureSetUp() {
판매자_4_7점 = User.builder()
.name("판매자 4.7점")
.profileImage(new ProfileImage("upload.png", "store.png"))
.reliability(new Reliability(4.7d))
.reliability(new Reliability(4.7f))
.oauthId("1")
.build();
판매자_3_5점 = User.builder()
.name("판매자 3.5점")
.profileImage(new ProfileImage("upload.png", "store.png"))
.reliability(new Reliability(3.5d))
.reliability(new Reliability(3.5f))
.oauthId("2")
.build();
판매자_2_1점 = User.builder()
.name("판매자 2.1점 ")
.profileImage(new ProfileImage("upload.png", "store.png"))
.reliability(new Reliability(2.1d))
.reliability(new Reliability(2.1f))
.oauthId("3")
.build();
판매자_5_0점 = User.builder()
.name("판매자 5.0점")
.profileImage(new ProfileImage("upload.png", "store.png"))
.reliability(new Reliability(5.0d))
.reliability(new Reliability(5.0f))
.oauthId("4")
.build();
판매자_1_5점 = User.builder()
.name("판매자 1.5점")
.profileImage(new ProfileImage("upload.png", "store.png"))
.reliability(new Reliability(1.5d))
.reliability(new Reliability(1.5f))
.oauthId("5")
.build();
판매자_0_3점_1 = User.builder()
.name("판매자 0.3점 1")
.profileImage(new ProfileImage("upload.png", "store.png"))
.reliability(new Reliability(0.3d))
.reliability(new Reliability(0.3f))
.oauthId("6")
.build();
판매자_0_3점_2 = User.builder()
.name("판매자 0.3점 2")
.profileImage(new ProfileImage("upload.png", "store.png"))
.reliability(new Reliability(0.3d))
.reliability(new Reliability(0.3f))
.oauthId("7")
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void totalFixtureSetUp() {
판매자 = User.builder()
.name("판매자")
.profileImage(new ProfileImage("upload.png", "store.png"))
.reliability(new Reliability(4.7d))
.reliability(new Reliability(4.7f))
.oauthId("12345")
.build();
userRepository.save(판매자);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void setUp() {
)
.andExpectAll(
status().isOk(),
jsonPath("score", is(구매자가_판매자1에게_받은_평가_내용.score()), Double.class),
jsonPath("score", is(구매자가_판매자1에게_받은_평가_내용.score()), Float.class),
jsonPath("content", is(구매자가_판매자1에게_받은_평가_내용.content()))
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
import com.ddang.ddang.authentication.infrastructure.jwt.PrivateClaims;
import com.ddang.ddang.configuration.CommonControllerSliceTest;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.time.LocalDateTime;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockMultipartFile;

import java.time.LocalDateTime;
import java.util.List;

@SuppressWarnings("NonAsciiCharacters")
public class AuctionControllerFixture extends CommonControllerSliceTest {

Expand Down Expand Up @@ -155,7 +156,7 @@ void fixtureSetUp() throws JsonProcessingException {
1L,
1L,
"판매자",
3.5d,
3.5f,
false,
AuctionStatus.UNBIDDEN
);
Expand All @@ -178,7 +179,7 @@ void fixtureSetUp() throws JsonProcessingException {
1L,
1L,
"판매자",
3.5d,
3.5f,
false,
AuctionStatus.UNBIDDEN
);
Expand All @@ -201,7 +202,7 @@ void fixtureSetUp() throws JsonProcessingException {
1L,
1L,
"판매자",
3.5d,
3.5f,
false,
AuctionStatus.UNBIDDEN
);
Expand Down
Loading
Loading