From ecf16792a8b2240870d07297e538a2289c6bf092 Mon Sep 17 00:00:00 2001 From: KimMinheee <99alsgmlalsl@naver.com> Date: Sun, 1 Jan 2023 00:13:56 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Feat=20:=20=EC=A3=BC=EB=AC=B8=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C=20api=20-=20deliveryParty=20orderStatus=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20-=20=EC=8B=9C=EC=8A=A4=ED=85=9C=20=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EB=B0=9C=EC=86=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../geeksasang/domain/member/QMember.java | 103 ------------------ .../chat/DeliveryPartyChatController.java | 22 +++- .../domain/deliveryparty/DeliveryParty.java | 9 ++ .../dto/chat/chatparty/PatchOrderReq.java | 15 +++ .../post/PostDeliveryPartyRes.java | 8 +- .../chat/DeliveryPartyChatService.java | 26 +++++ .../deliveryparty/DeliveryPartyService.java | 10 ++ 7 files changed, 87 insertions(+), 106 deletions(-) delete mode 100644 src/main/generated/shop/geeksasang/domain/member/QMember.java create mode 100644 src/main/java/shop/geeksasang/dto/chat/chatparty/PatchOrderReq.java diff --git a/src/main/generated/shop/geeksasang/domain/member/QMember.java b/src/main/generated/shop/geeksasang/domain/member/QMember.java deleted file mode 100644 index 5ae7fec3..00000000 --- a/src/main/generated/shop/geeksasang/domain/member/QMember.java +++ /dev/null @@ -1,103 +0,0 @@ -package shop.geeksasang.domain.member; - -import static com.querydsl.core.types.PathMetadataFactory.*; - -import com.querydsl.core.types.dsl.*; - -import com.querydsl.core.types.PathMetadata; -import javax.annotation.processing.Generated; -import com.querydsl.core.types.Path; -import com.querydsl.core.types.dsl.PathInits; - - -/** - * QMember is a Querydsl query type for Member - */ -@Generated("com.querydsl.codegen.DefaultEntitySerializer") -public class QMember extends EntityPathBase { - - private static final long serialVersionUID = 759956961L; - - private static final PathInits INITS = PathInits.DIRECT2; - - public static final QMember member = new QMember("member1"); - - public final shop.geeksasang.config.domain.QBaseEntity _super = new shop.geeksasang.config.domain.QBaseEntity(this); - - public final ListPath blocks = this.createList("blocks", shop.geeksasang.domain.block.Block.class, shop.geeksasang.domain.block.QBlock.class, PathInits.DIRECT2); - - //inherited - public final StringPath createdAt = _super.createdAt; - - public final ListPath deliverPartyReportRecords = this.createList("deliverPartyReportRecords", shop.geeksasang.domain.report.record.DeliverPartyReportRecord.class, shop.geeksasang.domain.report.record.QDeliverPartyReportRecord.class, PathInits.DIRECT2); - - public final shop.geeksasang.domain.university.QDormitory dormitory; - - public final shop.geeksasang.domain.auth.QEmail email; - - public final StringPath fcmToken = createString("fcmToken"); - - public final NumberPath id = createNumber("id", Integer.class); - - public final StringPath informationAgreeStatus = createString("informationAgreeStatus"); - - public final StringPath jwtToken = createString("jwtToken"); - - public final StringPath loginId = createString("loginId"); - - public final EnumPath loginStatus = createEnum("loginStatus", shop.geeksasang.config.status.LoginStatus.class); - - public final EnumPath memberLoginType = createEnum("memberLoginType", shop.geeksasang.config.type.MemberLoginType.class); - - public final ListPath memberReportRecords = this.createList("memberReportRecords", shop.geeksasang.domain.report.record.MemberReportRecord.class, shop.geeksasang.domain.report.record.QMemberReportRecord.class, PathInits.DIRECT2); - - public final StringPath nickName = createString("nickName"); - - public final StringPath password = createString("password"); - - public final NumberPath perDayReportingCount = createNumber("perDayReportingCount", Integer.class); - - public final shop.geeksasang.domain.auth.QPhoneNumber phoneNumber; - - public final StringPath profileImgUrl = createString("profileImgUrl"); - - public final NumberPath reportedCount = createNumber("reportedCount", Integer.class); - - public final ListPath reportedMembers = this.createList("reportedMembers", shop.geeksasang.domain.report.MemberReport.class, shop.geeksasang.domain.report.QMemberReport.class, PathInits.DIRECT2); - - public final ListPath reportingMembers = this.createList("reportingMembers", shop.geeksasang.domain.report.MemberReport.class, shop.geeksasang.domain.report.QMemberReport.class, PathInits.DIRECT2); - - //inherited - public final EnumPath status = _super.status; - - public final shop.geeksasang.domain.university.QUniversity university; - - //inherited - public final StringPath updatedAt = _super.updatedAt; - - public QMember(String variable) { - this(Member.class, forVariable(variable), INITS); - } - - public QMember(Path path) { - this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); - } - - public QMember(PathMetadata metadata) { - this(metadata, PathInits.getFor(metadata, INITS)); - } - - public QMember(PathMetadata metadata, PathInits inits) { - this(Member.class, metadata, inits); - } - - public QMember(Class type, PathMetadata metadata, PathInits inits) { - super(type, metadata, inits); - this.dormitory = inits.isInitialized("dormitory") ? new shop.geeksasang.domain.university.QDormitory(forProperty("dormitory"), inits.get("dormitory")) : null; - this.email = inits.isInitialized("email") ? new shop.geeksasang.domain.auth.QEmail(forProperty("email"), inits.get("email")) : null; - this.phoneNumber = inits.isInitialized("phoneNumber") ? new shop.geeksasang.domain.auth.QPhoneNumber(forProperty("phoneNumber"), inits.get("phoneNumber")) : null; - this.university = inits.isInitialized("university") ? new shop.geeksasang.domain.university.QUniversity(forProperty("university")) : null; - } - -} - diff --git a/src/main/java/shop/geeksasang/controller/chat/DeliveryPartyChatController.java b/src/main/java/shop/geeksasang/controller/chat/DeliveryPartyChatController.java index 2bf8211c..55a513a8 100644 --- a/src/main/java/shop/geeksasang/controller/chat/DeliveryPartyChatController.java +++ b/src/main/java/shop/geeksasang/controller/chat/DeliveryPartyChatController.java @@ -16,6 +16,7 @@ import shop.geeksasang.dto.chat.PostChatImageReq; +import shop.geeksasang.dto.chat.chatparty.PatchOrderReq; import shop.geeksasang.dto.chat.partychatroom.GetPartyChatRoomsRes; import shop.geeksasang.dto.chat.PostChatReq; import shop.geeksasang.dto.chat.partychatroom.PartyChatRoomRes; @@ -181,11 +182,10 @@ public BaseResponse removeChatRoomMember(HttpServletRequest re return new BaseResponse(new SuccessCommonRes()); } - //todo : dto validation @ApiOperation(value = "송금 완료 ", notes = "(jwt 토큰 필요) 채팅방 내에서 송금완료 버튼을 누를 때 사용하는 api") @ApiResponses({ @ApiResponse(code = 1000 ,message ="요청에 성공하셨습니다."), - @ApiResponse(code = 2008 ,message ="채팅방 멤버가 존재하지 않습니다."), + @ApiResponse(code = 2208 ,message ="채팅방 멤버가 존재하지 않습니다."), @ApiResponse(code = 2009 ,message ="존재하지 않는 멤버입니다."), @ApiResponse(code = 2005 ,message ="채팅방이 존재하지 않습니다."), @ApiResponse(code = 4000 ,message ="서버 오류입니다.") @@ -196,4 +196,22 @@ public BaseResponse changeRemittance(HttpServletRequest request, @Valid deliveryPartyChatService.changeRemittance(jwtInfo.getUserId(), dto.getRoomId()); return new BaseResponse<>("요청에 성공하셨습니다."); } + + @ApiOperation(value = "주문 완료 ", notes = "(jwt 토큰 필요) 채팅방 내에서 주문 완료 버튼을 누를 때 사용하는 api") + @ApiResponses({ + @ApiResponse(code = 1000 ,message ="요청에 성공하셨습니다."), + @ApiResponse(code = 2208 ,message ="채팅방 멤버가 존재하지 않습니다."), + @ApiResponse(code = 2009 ,message ="존재하지 않는 멤버입니다."), + @ApiResponse(code = 2207 ,message ="채팅방이 존재하지 않습니다."), + @ApiResponse(code = 2010 ,message ="존재하지 않는 파티입니다."), + @ApiResponse(code = 2210 ,message ="채팅이 존재하지 않습니다."), + @ApiResponse(code = 4000 ,message ="서버 오류입니다."), + }) + @PatchMapping("/order") + public BaseResponse changeOrderStatus(HttpServletRequest request, @Valid @RequestBody PatchOrderReq dto){ + JwtInfo jwtInfo = (JwtInfo) request.getAttribute("jwtInfo"); + deliveryPartyChatService.changeOrderStatus(jwtInfo.getUserId(), dto.getRoomId()); + return new BaseResponse<>("요청에 성공하셨습니다."); + } + } diff --git a/src/main/java/shop/geeksasang/domain/deliveryparty/DeliveryParty.java b/src/main/java/shop/geeksasang/domain/deliveryparty/DeliveryParty.java index 38ad16ff..78f29686 100644 --- a/src/main/java/shop/geeksasang/domain/deliveryparty/DeliveryParty.java +++ b/src/main/java/shop/geeksasang/domain/deliveryparty/DeliveryParty.java @@ -6,6 +6,7 @@ import shop.geeksasang.config.domain.BaseEntity; import shop.geeksasang.config.status.MatchingStatus; +import shop.geeksasang.config.status.OrderStatus; import shop.geeksasang.config.type.OrderTimeCategoryType; import shop.geeksasang.config.status.BaseStatus; import shop.geeksasang.domain.location.Location; @@ -79,6 +80,9 @@ public class DeliveryParty extends BaseEntity { private String uuid; + @Enumerated(EnumType.STRING) + private OrderStatus orderStatus; + @Embedded @AttributeOverrides({ @AttributeOverride(name="latitude",column = @Column(name="latitude")), @@ -107,6 +111,7 @@ public static DeliveryParty makeParty(PostDeliveryPartyReq dto, OrderTimeCategor .reportedCount(0) .uuid(createUuid()) .deliveryPartyMembers(new ArrayList<>()) + .orderStatus(OrderStatus.BEFORE_ORDER) .build(); party.setStatus(BaseStatus.ACTIVE); @@ -224,4 +229,8 @@ public void deleteNowChief(){ public void removeDeliveryPartyMember(DeliveryPartyMember deliveryPartyMember){ deliveryPartyMembers.remove(deliveryPartyMember); } + + public void changeOrderStatusToOrderComplete(){ + this.orderStatus = OrderStatus.ORDER_COMPLETE; + } } diff --git a/src/main/java/shop/geeksasang/dto/chat/chatparty/PatchOrderReq.java b/src/main/java/shop/geeksasang/dto/chat/chatparty/PatchOrderReq.java new file mode 100644 index 00000000..1d9e09d5 --- /dev/null +++ b/src/main/java/shop/geeksasang/dto/chat/chatparty/PatchOrderReq.java @@ -0,0 +1,15 @@ +package shop.geeksasang.dto.chat.chatparty; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; + +@Getter +@NoArgsConstructor +public class PatchOrderReq { + @ApiModelProperty(example = "639ddf7e08c0c27e2d5e6090", value = "배달파티 채팅방 id", required = true) + @NotBlank(message = "배달 파티 채팅방 id를 입력하세요.") + private String roomId; +} diff --git a/src/main/java/shop/geeksasang/dto/deliveryParty/post/PostDeliveryPartyRes.java b/src/main/java/shop/geeksasang/dto/deliveryParty/post/PostDeliveryPartyRes.java index d1f07bda..ccc89643 100644 --- a/src/main/java/shop/geeksasang/dto/deliveryParty/post/PostDeliveryPartyRes.java +++ b/src/main/java/shop/geeksasang/dto/deliveryParty/post/PostDeliveryPartyRes.java @@ -6,6 +6,7 @@ import lombok.*; import shop.geeksasang.config.status.BelongStatus; import shop.geeksasang.config.status.MatchingStatus; +import shop.geeksasang.config.status.OrderStatus; import shop.geeksasang.domain.deliveryparty.DeliveryParty; import java.time.LocalDateTime; @@ -97,6 +98,9 @@ public class PostDeliveryPartyRes { @ApiModelProperty(example = "신한은행", value = "은행이름") private String bank; + @ApiModelProperty(example = "BEFORE_ORDER", value = "주문 상태를 나타내는 값 - 주문 전: BEFORE_ORDER, 주문 완료상태: ORDER_COMPLETE, 배달 완료: DELIVERY_COMPLETE ") + private OrderStatus orderStatus; + static public PostDeliveryPartyRes toDto(DeliveryParty deliveryParty){ return PostDeliveryPartyRes.builder() .id(deliveryParty.getId()) @@ -125,6 +129,7 @@ static public PostDeliveryPartyRes toDto(DeliveryParty deliveryParty){ .chatRoomName(deliveryParty.getChatRoomName()) .accountNumber(deliveryParty.getAccountNumber()) .bank(deliveryParty.getBank()) + .orderStatus(deliveryParty.getOrderStatus()) .build(); } @@ -132,7 +137,7 @@ static public PostDeliveryPartyRes toDto(DeliveryParty deliveryParty){ public PostDeliveryPartyRes(int id, String chief, int chiefId, String chiefProfileImgUrl, String foodCategory, boolean hashTag, String title, String content, LocalDateTime orderTime, int currentMatching, int maxMatching, MatchingStatus matchingStatus, String updatedAt, Double latitude, Double longitude, String storeUrl, boolean authorStatus, String uuid, BelongStatus belongStatus, int dormitoryId, - String dormitoryName, String createdAt, String orderTimeCategoryType, String chatRoomName, String accountNumber, String bank) { + String dormitoryName, String createdAt, String orderTimeCategoryType, String chatRoomName, String accountNumber, String bank, OrderStatus orderStatus) { this.id = id; this.chief = chief; this.chiefId = chiefId; @@ -159,6 +164,7 @@ public PostDeliveryPartyRes(int id, String chief, int chiefId, String chiefProfi this.chatRoomName = chatRoomName; this.accountNumber = accountNumber; this.bank = bank; + this.orderStatus = orderStatus; } //테스트용 diff --git a/src/main/java/shop/geeksasang/service/chat/DeliveryPartyChatService.java b/src/main/java/shop/geeksasang/service/chat/DeliveryPartyChatService.java index 93553d6b..1c32ff11 100644 --- a/src/main/java/shop/geeksasang/service/chat/DeliveryPartyChatService.java +++ b/src/main/java/shop/geeksasang/service/chat/DeliveryPartyChatService.java @@ -35,6 +35,7 @@ import shop.geeksasang.repository.member.MemberRepository; import shop.geeksasang.service.common.AwsS3Service; import shop.geeksasang.service.deliveryparty.DeliveryPartyMemberService; +import shop.geeksasang.service.deliveryparty.DeliveryPartyService; import java.io.IOException; import java.time.LocalDateTime; @@ -57,6 +58,7 @@ public class DeliveryPartyChatService { private final MemberRepository memberRepository; private final AwsS3Service awsS3Service; private final DeliveryPartyMemberService deliveryPartyMemberService; + private final DeliveryPartyService deliveryPartyService; private static final String PAGING_STANDARD = "createdAt"; @@ -339,5 +341,29 @@ public void changeRemittance(int memberId, String roomId) { deliveryPartyMemberService.changeAccountTransferStatus(chatRoom.getDeliveryPartyId(), member.getMemberId()); } + @Transactional(readOnly = false) + public void changeOrderStatus(int memberId, String roomId) { + + //mongo(채팅방) 회원 존재 여부 확인 + PartyChatRoomMember chatRoomMember = partyChatRoomMemberRepository + .findByMemberIdAndChatRoomId(memberId, new ObjectId(roomId)) + .orElseThrow(() -> new BaseException(NOT_EXISTS_PARTYCHATROOM_MEMBER)); + + //mysql 회원 존재 여부 확인 + Member member = memberRepository.findMemberById(memberId) + .orElseThrow(() -> new BaseException(NOT_EXISTS_PARTICIPANT)); + + //채팅방 존재 여부 확인 + PartyChatRoom partyChatRoom = partyChatRoomRepository.findByPartyChatRoomId(new ObjectId(roomId)) + .orElseThrow(() -> new BaseException(NOT_EXISTS_CHAT_ROOM)); + + //mysql - OrderStatus 값 바꾸기 + deliveryPartyService.changeOrderStatus(partyChatRoom.getDeliveryPartyId()); + + //주문 완료 시스템 메시지 + this.createChat(memberId, roomId, "주문이 완료되었습니다.", true, member.getProfileImgUrl(), "publish", "none", false); + + } + } // String exchange, String routingKey, Object message \ No newline at end of file diff --git a/src/main/java/shop/geeksasang/service/deliveryparty/DeliveryPartyService.java b/src/main/java/shop/geeksasang/service/deliveryparty/DeliveryPartyService.java index d408be7e..6d892dc1 100644 --- a/src/main/java/shop/geeksasang/service/deliveryparty/DeliveryPartyService.java +++ b/src/main/java/shop/geeksasang/service/deliveryparty/DeliveryPartyService.java @@ -342,4 +342,14 @@ public GetEndedDeliveryPartiesRes getEndedDeliveryParties(int userId, int cursor return endedDeliveryParties; } + + @Transactional(readOnly = false) + public void changeOrderStatus(int partyId){ + //배달파티 조회 + DeliveryParty deliveryParty = deliveryPartyRepository.findDeliveryPartyById(partyId) + .orElseThrow(() -> new BaseException(NOT_EXISTS_PARTY)); + + //주문 완료 상태 수정 + deliveryParty.changeOrderStatusToOrderComplete(); + } } \ No newline at end of file From 556c461e62cf1c960d42c87fc3d22ae7455a1a09 Mon Sep 17 00:00:00 2001 From: KimMinheee <99alsgmlalsl@naver.com> Date: Sun, 1 Jan 2023 00:34:16 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Feat=20:=20=EC=86=A1=EA=B8=88=EC=99=84?= =?UTF-8?q?=EB=A3=8C=20api=20response=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../geeksasang/controller/chat/DeliveryPartyChatController.java | 2 +- .../shop/geeksasang/service/chat/DeliveryPartyChatService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/shop/geeksasang/controller/chat/DeliveryPartyChatController.java b/src/main/java/shop/geeksasang/controller/chat/DeliveryPartyChatController.java index 55a513a8..c7a165fe 100644 --- a/src/main/java/shop/geeksasang/controller/chat/DeliveryPartyChatController.java +++ b/src/main/java/shop/geeksasang/controller/chat/DeliveryPartyChatController.java @@ -187,7 +187,7 @@ public BaseResponse removeChatRoomMember(HttpServletRequest re @ApiResponse(code = 1000 ,message ="요청에 성공하셨습니다."), @ApiResponse(code = 2208 ,message ="채팅방 멤버가 존재하지 않습니다."), @ApiResponse(code = 2009 ,message ="존재하지 않는 멤버입니다."), - @ApiResponse(code = 2005 ,message ="채팅방이 존재하지 않습니다."), + @ApiResponse(code = 2207 ,message ="채팅방이 존재하지 않습니다."), @ApiResponse(code = 4000 ,message ="서버 오류입니다.") }) @PatchMapping("/members/remittance") diff --git a/src/main/java/shop/geeksasang/service/chat/DeliveryPartyChatService.java b/src/main/java/shop/geeksasang/service/chat/DeliveryPartyChatService.java index 1c32ff11..aaa81681 100644 --- a/src/main/java/shop/geeksasang/service/chat/DeliveryPartyChatService.java +++ b/src/main/java/shop/geeksasang/service/chat/DeliveryPartyChatService.java @@ -332,7 +332,7 @@ public void changeRemittance(int memberId, String roomId) { //채팅방 존재 여부 확인 PartyChatRoom chatRoom = partyChatRoomRepository.findByPartyChatRoomId(new ObjectId(roomId)) - .orElseThrow(() -> new BaseException(NOT_EXIST_CHAT_ROOM_CHIEF)); + .orElseThrow(() -> new BaseException(NOT_EXISTS_CHAT_ROOM)); //mongo 데이터 수정 partyChatRoomMemberRepository.changeRemittance(new ObjectId(member.getId()), new ObjectId(roomId));