Skip to content

Commit

Permalink
[REFACTOR] memberId 관련 컬럼명 변경 (#227)
Browse files Browse the repository at this point in the history
* refactor: memberId 관련 컬럼, 변수명 xxxMemberId로 변경

* refactor: PR 리뷰 반영

- ChatRoom null 체크 삭제
- review 생성 시 RecipientId 결정 로직 수정
  • Loading branch information
ss0ngcode authored Nov 18, 2024
1 parent 4f5f14a commit eb553ce
Show file tree
Hide file tree
Showing 23 changed files with 83 additions and 84 deletions.
10 changes: 5 additions & 5 deletions omocha-api/src/main/java/org/omocha/api/bid/BidController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import java.util.List;

import org.omocha.api.auth.jwt.UserPrincipal;
import org.omocha.api.bid.dto.BidDto;
import org.omocha.api.bid.dto.BidDtoMapper;
import org.omocha.api.auth.jwt.UserPrincipal;
import org.omocha.api.common.response.ResultDto;
import org.omocha.domain.bid.BidCommand;
import org.omocha.domain.bid.BidInfo;
Expand Down Expand Up @@ -64,8 +64,8 @@ public ResponseEntity<ResultDto<BidDto.BidAddResponse>> bidAdd(
@PathVariable("auction_id") Long auctionId,
@RequestBody BidDto.BidAddRequest addRequest
) {
Long buyerId = userPrincipal.getId();
BidCommand.AddBid addBidCommand = bidDtoMapper.toCommand(buyerId, auctionId, addRequest);
Long buyerMemberId = userPrincipal.getId();
BidCommand.AddBid addBidCommand = bidDtoMapper.toCommand(buyerMemberId, auctionId, addRequest);

BidInfo.AddBid addBid = bidFacade.addBid(addBidCommand);
BidDto.BidAddResponse response = bidDtoMapper.toResponse(addBid);
Expand Down Expand Up @@ -145,9 +145,9 @@ public ResponseEntity<ResultDto<Void>> instantBuy(
@AuthenticationPrincipal UserPrincipal userPrincipal,
@PathVariable("auction_id") Long auctionId
) {
Long memberId = userPrincipal.getId();
Long buyerMemberId = userPrincipal.getId();

BidCommand.BuyNow buyNowCommand = bidDtoMapper.toCommand(memberId, auctionId);
BidCommand.BuyNow buyNowCommand = bidDtoMapper.toCommand(buyerMemberId, auctionId);

bidFacade.buyNow(buyNowCommand);

Expand Down
4 changes: 2 additions & 2 deletions omocha-api/src/main/java/org/omocha/api/bid/dto/BidDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class BidDto {

public record BidListResponse(
Long buyerId,
Long buyerMemberId,
Long bidPrice,
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
LocalDateTime createdAt
Expand All @@ -22,7 +22,7 @@ public record BidAddRequest(
}

public record BidAddResponse(
Long buyerId,
Long buyerMemberId,
Long bidPrice,
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
LocalDateTime createdAt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ default <T, R> Page<R> toResponsePage(Page<T> pageInfo, Function<T, R> mapper) {

List<BidDto.BidListResponse> toResponse(List<BidInfo.BidList> bidList);

BidCommand.AddBid toCommand(Long buyerId, Long auctionId, BidDto.BidAddRequest createRequest);
BidCommand.AddBid toCommand(Long buyerMemberId, Long auctionId, BidDto.BidAddRequest createRequest);

BidDto.BidAddResponse toResponse(BidInfo.AddBid createResponse);

Expand All @@ -45,5 +45,5 @@ default Page<BidDto.MyBidListResponse> toMyBidListResponse(Page<BidInfo.Retrieve

BidDto.MyBidListResponse toResponse(BidInfo.RetrieveMyBids retrieveMyBidsInfo);

BidCommand.BuyNow toCommand(Long memberId, Long auctionId);
BidCommand.BuyNow toCommand(Long buyerMemberId, Long auctionId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import java.time.LocalDateTime;

import org.omocha.api.chat.dto.ChatDtoMapper;
import org.omocha.api.auth.jwt.UserPrincipal;
import org.omocha.api.chat.dto.ChatDtoMapper;
import org.omocha.api.common.response.ResultDto;
import org.omocha.api.common.response.SliceResponseDto.SliceResponse;
import org.omocha.domain.chat.ChatCommand;
Expand Down Expand Up @@ -42,10 +42,10 @@ public ResponseEntity<ResultDto> chatRoomAdd(
@PathVariable Long auctionId,
@AuthenticationPrincipal UserPrincipal userPrincipal
) {
Long buyerId = userPrincipal.getId();
Long buyerMemberId = userPrincipal.getId();

ChatCommand.AddChatRoom chatRoomCommand = chatDtoMapper.toCommand(
auctionId, buyerId);
auctionId, buyerMemberId);
chatFacade.addChatRoom(chatRoomCommand);

ResultDto<Void> result = ResultDto.res(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ public class ChatDto {
public record ChatMessageRequest(
@NotBlank(message = "MessageType이 공백 또는 null 이면 안됨")
Chat.MessageType messageType,
Long senderId,
Long senderMemberId,
@NotBlank(message = "Message에 내용이 없음")
String message

) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)
public interface ChatDtoMapper {

ChatCommand.AddChatRoom toCommand(Long auctionId, Long buyerId);
ChatCommand.AddChatRoom toCommand(Long auctionId, Long buyerMemberId);

ChatCommand.RetrieveMyChatRoom toCommand(Long memberId);

Expand Down
2 changes: 1 addition & 1 deletion omocha-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spring:
dialect: org.hibernate.dialect.PostgreSQLDialect
show-sql: false
hibernate:
ddl-auto: update
ddl-auto: create
open-in-view: false
sql:
init:
Expand Down
2 changes: 1 addition & 1 deletion omocha-domain/src/main/java/org/omocha/domain/bid/Bid.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class Bid extends BaseEntity {
private Auction auction;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "buyer_id")
@JoinColumn(name = "buyer_member_id")
private Member buyer;

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ public class BidCommand {

public record AddBid(
Long auctionId,
Long buyerId,
Long buyerMemberId,
Long bidPrice
) {

}

public record BuyNow(
Long memberId,
Long buyerMemberId,
Long auctionId
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class BidInfo {

public record BidList(
Long buyerId,
Long buyerMemberId,
Long bidPrice,
LocalDateTime createdAt
) {
Expand All @@ -24,7 +24,7 @@ public static BidList toInfo(

public record AddBid(
Long bidId,
Long buyerId,
Long buyerMemberId,
Long bidPrice,
LocalDateTime createdAt
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ public List<BidInfo.BidList> retrieveBids(Long auctionId) {
@Transactional
public BidInfo.AddBid addBid(BidCommand.AddBid addBid) {

Long buyerId = addBid.buyerId();
Long buyerMemberId = addBid.buyerMemberId();
Long auctionId = addBid.auctionId();
Long bidPrice = addBid.bidPrice();

Auction auction = auctionReader.getAuction(auctionId);
auction.validateAuctionStatus();

bidValidator.bidValidate(auction, buyerId, bidPrice);
bidValidator.bidValidate(auction, buyerMemberId, bidPrice);

Member member = memberReader.getMember(buyerId);
Member member = memberReader.getMember(buyerMemberId);

Bid bid = bidStore.store(auction, member, bidPrice);

Expand All @@ -77,17 +77,17 @@ public BidInfo.NowPrice retrieveNowPrice(Long auctionId) {
@Override
@Transactional
public void buyNow(BidCommand.BuyNow buyNowCommand) {
Long buyerId = buyNowCommand.memberId();
Long buyerMemberId = buyNowCommand.buyerMemberId();

Auction auction = auctionReader.getAuction(buyNowCommand.auctionId());
auction.validateAuctionStatus();
bidValidator.instantBuyValidate(auction, buyerId);
bidValidator.instantBuyValidate(auction, buyerMemberId);

Member buyer = memberReader.getMember(buyerId);
Member buyer = memberReader.getMember(buyerMemberId);
Bid bid = bidStore.store(auction, buyer, auction.getInstantBuyPrice());
concludeStore.store(auction, bid);

var chatRoomCommand = new ChatCommand.AddChatRoom(auction.getAuctionId(), buyerId);
var chatRoomCommand = new ChatCommand.AddChatRoom(auction.getAuctionId(), buyerMemberId);
chatService.addChatRoom(chatRoomCommand);

auction.statusConcluded();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.omocha.domain.auction.Auction;

public interface BidValidator {
void bidValidate(Auction auction, Long buyerId, Long bidPrice);
void bidValidate(Auction auction, Long buyerMemberId, Long bidPrice);

void instantBuyValidate(Auction auction, Long buyerId);
void instantBuyValidate(Auction auction, Long buyerMemberId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class BidValidatorImpl implements BidValidator {
// 처음 입찰 : 시작가보다 낮은 입찰 가격이 발생할 때 예외
// 이후 입찰 : 입찰 가격 < 현재 최고가 보다 낮을 때 예외 발생
@Override
public void bidValidate(Auction auction, Long buyerId, Long bidPrice) {
validateSelfBid(auction, buyerId);
public void bidValidate(Auction auction, Long buyerMemberId, Long bidPrice) {
validateSelfBid(auction, buyerMemberId);

validateBidUnit(auction, bidPrice);

Expand All @@ -34,9 +34,9 @@ public void bidValidate(Auction auction, Long buyerId, Long bidPrice) {
validateBidBelowInstantBuyPrice(auction, bidPrice);
}

private void validateSelfBid(Auction auction, Long buyerId) {
if (auction.getMemberId().equals(buyerId)) {
throw new SelfBidNotAllowedException(auction.getAuctionId(), buyerId);
private void validateSelfBid(Auction auction, Long buyerMemberId) {
if (auction.getMemberId().equals(buyerMemberId)) {
throw new SelfBidNotAllowedException(auction.getAuctionId(), buyerMemberId);
}
}

Expand Down Expand Up @@ -76,7 +76,7 @@ private void validateBidBelowInstantBuyPrice(Auction auction, Long bidPrice) {
}

@Override
public void instantBuyValidate(Auction auction, Long buyerId) {
validateSelfBid(auction, buyerId);
public void instantBuyValidate(Auction auction, Long buyerMemberId) {
validateSelfBid(auction, buyerMemberId);
}
}
6 changes: 3 additions & 3 deletions omocha-domain/src/main/java/org/omocha/domain/chat/Chat.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Chat extends BaseEntity {
@Enumerated(EnumType.STRING)
private MessageType messageType;

private Long senderId;
private Long senderMemberId;

private String message;

Expand All @@ -49,12 +49,12 @@ public enum MessageType {
@Builder
public Chat(
MessageType messageType,
Long senderId,
Long senderMemberId,
String message,
Long roomId
) {
this.messageType = messageType;
this.senderId = senderId;
this.senderMemberId = senderMemberId;
this.message = message;
this.roomId = roomId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ public class ChatCommand {

public record AddChatRoom(
Long auctionId,
Long buyerId
Long buyerMemberId
) {
public ChatRoom toEntity(Auction auction) {
return ChatRoom.builder()
.roomName(auction.getTitle())
.buyerId(buyerId)
.sellerId(auction.getMemberId())
.buyerMemberId(buyerMemberId)
.sellerMemberId(auction.getMemberId())
.auctionId(auction.getAuctionId())
.build();
}
Expand All @@ -29,14 +29,14 @@ public record RetrieveMyChatRoom(

public record AddChatMessage(
Chat.MessageType messageType,
Long senderId,
Long senderMemberId,
String message,
Long roomId
) {
public Chat toEntity() {
return Chat.builder()
.messageType(messageType)
.senderId(senderId)
.senderMemberId(senderMemberId)
.message(message)
.roomId(roomId)
.build();
Expand Down
18 changes: 9 additions & 9 deletions omocha-domain/src/main/java/org/omocha/domain/chat/ChatInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public record RetrieveMyChatRoom(
Long auctionId,
Long roomId,
String roomName,
Long sellerId,
Long sellerMemberId,
String sellerName,
String sellerProfileImage,
String thumbnailPath,
Long concludePrice,
Long buyerId,
Long buyerMemberId,
String buyerName,
String buyerProfileImage,
LocalDateTime createdDate,
Expand All @@ -31,12 +31,12 @@ public RetrieveMyChatRoom(
Long auctionId,
Long roomId,
String roomName,
Long sellerId,
Long sellerMemberId,
String sellerName,
String sellerProfileImage,
String thumbnailPath,
Long concludePrice,
Long buyerId,
Long buyerMemberId,
String buyerName,
String buyerProfileImage,
LocalDateTime createdDate,
Expand All @@ -46,12 +46,12 @@ public RetrieveMyChatRoom(
this.auctionId = auctionId;
this.roomId = roomId;
this.roomName = roomName;
this.sellerId = sellerId;
this.sellerMemberId = sellerMemberId;
this.sellerName = sellerName;
this.sellerProfileImage = sellerProfileImage;
this.thumbnailPath = thumbnailPath;
this.concludePrice = concludePrice;
this.buyerId = buyerId;
this.buyerMemberId = buyerMemberId;
this.buyerName = buyerName;
this.buyerProfileImage = buyerProfileImage;
this.createdDate = createdDate;
Expand All @@ -63,7 +63,7 @@ public RetrieveMyChatRoom(

public record RetrieveChatRoomMessage(
MessageType messageType,
Long senderId,
Long senderMemberId,
Long roomId,
String nickname,
String senderProfileImage,
Expand All @@ -73,15 +73,15 @@ public record RetrieveChatRoomMessage(
@QueryProjection
public RetrieveChatRoomMessage(
MessageType messageType,
Long senderId,
Long senderMemberId,
Long roomId,
String nickname,
String senderProfileImage,
String message,
LocalDateTime createdAt
) {
this.messageType = messageType;
this.senderId = senderId;
this.senderMemberId = senderMemberId;
this.roomId = roomId;
this.nickname = nickname;
this.senderProfileImage = senderProfileImage;
Expand Down
Loading

0 comments on commit eb553ce

Please sign in to comment.