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

[REFACTOR] 신청 디스코드 메시지 형식 변경 및 커스텀 도안 정렬 순서 변경 #159

Merged
merged 5 commits into from
Feb 21, 2024
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
1 change: 0 additions & 1 deletion .github/workflows/cicd_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
echo "${{ secrets.TATTOUR_DEV_APPLICATION }}" >> ./application.yaml
cat ./application.yaml
shell: bash


- name: Grant execute permission for gradlew
run: chmod +x ./server/gradlew
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public ResponseEntity<?> postCustom(
@RequestBody @Valid PostCustomReq request
) {
PostCustomRes response = PostCustomRes.from(
(customFacade.createCustom(request.getHaveDesign(), userId)));
customFacade.createCustom(request.getHaveDesign(), userId));
return BaseResponse.success(SuccessType.CREATE_CUSTOM_SUCCESS, response);
}

Expand All @@ -79,7 +79,10 @@ public ResponseEntity<?> patchCustom(
PatchCustomRes response =
PatchCustomRes.from(
customFacade.updateCustom(
customInfo.newUpdateCustomReq(userId, customImages, handDrawingImage)));
customInfo.newUpdateCustomReq(
userId,
customImages,
handDrawingImage)));

return BaseResponse.success(SuccessType.UPDATE_CUSTOM_SUCCESS, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public List<Custom> getCustomByUserIdAfterDate(int userId, String date) {

@Override
public List<Custom> getAllByUserIdAndIsCompleted(Integer userId) {
return customRepository.findAllByUserIdAndIsCompleted(userId);
return customRepository.findAllByUserIdAndIsCompletedOrderByLastUpdatedAt(userId);
}

@Override
public List<Custom> getAllByUserIdAndIsCompletedFalse(Integer userId) {
return customRepository.findAllByUserIdAndIsCompletedFalse(userId);
return customRepository.findAllByUserIdAndIsCompletedFalseOrderByLastUpdatedAt(userId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public interface CustomRepositoryCustom {

List<Custom> findAllByUserIdAndIsCompleted(Integer userId);
List<Custom> findAllByUserIdAndIsCompletedOrderByLastUpdatedAt(Integer userId);

List<Custom> findAllByUserIdAndIsCompletedFalse(Integer userId);
List<Custom> findAllByUserIdAndIsCompletedFalseOrderByLastUpdatedAt(Integer userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@ public class CustomRepositoryImpl implements CustomRepositoryCustom {
private final JPAQueryFactory queryFactory;

@Override
public List<Custom> findAllByUserIdAndIsCompleted(Integer userId) {
public List<Custom> findAllByUserIdAndIsCompletedOrderByLastUpdatedAt(Integer userId) {
return queryFactory
.select(custom)
.from(custom)
.where(custom.user.id.eq(userId), custom.isCompleted.eq(true))
.orderBy(custom.lastUpdatedAt.desc())
.fetch();
}

@Override
public List<Custom> findAllByUserIdAndIsCompletedFalse(Integer userId) {
public List<Custom> findAllByUserIdAndIsCompletedFalseOrderByLastUpdatedAt(Integer userId) {
return queryFactory
.select(custom)
.from(custom)
.where(custom.user.id.eq(userId), custom.isCompleted.eq(false))
.orderBy(custom.lastUpdatedAt.desc())
.fetch();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,29 @@ public class CustomApplyDiscordMessage {
DiscordCustomImage image;

public static CustomApplyDiscordMessage from(User user, Custom custom) {
String title = "Custom Id : " + custom.getId();
String description;
String title = "커스텀 도안 번호 : " + custom.getId();
StringBuilder description = new StringBuilder();

description.append("\n\n### [유저 정보]")
.append("\n- 연락처: ").append(user.getPhoneNumber())
.append("\n- 이름: ").append(custom.getName())
.append("\n\n### [도안 신청 정보]")
.append("\n- 사이즈: ").append(custom.getSize().getSize())
.append("\n- 수량: ").append(custom.getCount());

if (custom.getHaveDesign()) {
description = "유저 전화번호 : " + user.getPhoneNumber()
+ "\n이름 : " + custom.getName()
+ "\n사이즈 : " + custom.getSize().getSize()
+ "\n추가 요청 사항 : " + custom.getDemand()
+ "\n수량 : " + custom.getCount()
+ "\n그려둔 도안 있음";
description.append("\n- 추가 요청 사항: ").append(custom.getDemand())
.append("\n- 도안: ").append("`있음`");
} else {
description = "유저 전화번호 : " + user.getPhoneNumber()
+ "이름 : " + custom.getName()
+ "\n사이즈 : " + custom.getSize().getSize()
+ "\n추가 요청 사항 : " + custom.getDemand()
+ "\n색상 : " + custom.getIsColored()
+ "\n주제 및 설명 : " + custom.getDescription()
+ "\n수량 : " + custom.getCount()
+ "\n그려둔 도안 없음";
description.append("\n- 색상: ").append(custom.getIsColored())
.append("\n- 주제 및 설명: \n").append(custom.getDescription())
.append("\n- 추가 요청 사항: ").append(custom.getDemand())
.append("\n- 도안: ").append("`없음`");
}

return new CustomApplyDiscordMessage(
title,
description,
description.toString(),
new DiscordCustomImage(custom.getMainImageUrl())
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,28 @@ public static OrderStickerDiscordMessage from(
List<OrderedProduct> orderedProducts) {
String title = "주문 번호: " + orderHistory.getId();
StringBuilder description = new StringBuilder();

description.append("\n\n### [주문 정보]")
.append("\n유저 번호: ").append(orderHistory.getUser().getId())
.append("\n상품 금액: ").append(orderHistory.getProductAmount())
.append("\n총 주문 금액: ").append(orderHistory.getTotalAmount());
.append("\n- 유저 번호: ").append(orderHistory.getUser().getId())
.append("\n- 상품 금액: ").append(orderHistory.getProductAmount())
.append("\n- 총 주문 금액: ").append(orderHistory.getTotalAmount());

description.append("\n\n### [주문 상품 내역]");
orderedProducts.forEach(product -> {
description.append("\n");
description.append("\n상품 번호: ").append(product.getSticker().getId());
description.append("\n상품명: ").append(product.getSticker().getName());
description.append("\n가격: ").append(product.getPrice());
description.append("\n수량: ").append(product.getCount());
description.append("\n- 상품 번호: ").append(product.getSticker().getId());
description.append("\n- 상품명: ").append(product.getSticker().getName());
description.append("\n- 가격: ").append(product.getPrice());
description.append("\n- 수량: ").append(product.getCount());
});

description.append("\n\n### [배송 정보]")
.append("\n수령인: ").append(orderHistory.getRecipientName())
.append("\n연락처: ").append(orderHistory.getContact())
.append("\n우편 번호: ").append(orderHistory.getMailingAddress())
.append("\n기본 주소: ").append(orderHistory.getBaseAddress())
.append("\n싱세 주소: ").append(orderHistory.getDetailAddress())
.append("\n배송비: ").append(orderHistory.getShippingFee());
.append("\n- 수령인: ").append(orderHistory.getRecipientName())
.append("\n- 연락처: ").append(orderHistory.getContact())
.append("\n- 우편 번호: ").append(orderHistory.getMailingAddress())
.append("\n- 기본 주소: ").append(orderHistory.getBaseAddress())
.append("\n- 싱세 주소: ").append(orderHistory.getDetailAddress())
.append("\n- 배송비: ").append(orderHistory.getShippingFee());

return new OrderStickerDiscordMessage(title, description.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,22 @@ public class DiscordMessageService {

@Transactional
public void sendCustomApplyMessage(Custom custom) {
CustomApplyDiscordMessage payload = CustomApplyDiscordMessage.from(custom.getUser(),
custom);
sendDiscordMessage(customWebhookProperty.getClientId(), customWebhookProperty.getToken(),
custom.getUser(), "님이 커스텀 도안을 신청했습니다.", payload);
CustomApplyDiscordMessage payload =
CustomApplyDiscordMessage.from(custom.getUser(), custom);

sendDiscordMessage(customWebhookProperty.getClientId(),
customWebhookProperty.getToken(),
custom.getUser(),
"님이 커스텀 도안을 신청했습니다.",
payload);
}

@Transactional
public void sendOrderStickerMessage(OrderHistory orderHistory,
List<OrderedProduct> orderedProducts) {
OrderStickerDiscordMessage payload =
OrderStickerDiscordMessage.from(orderHistory, orderedProducts);

sendDiscordMessage(
orderWebhookProperty.getClientId(),
orderWebhookProperty.getToken(),
Expand Down
Loading