diff --git a/src/main/java/com/core/linkup/common/entity/BaseMembershipEntity.java b/src/main/java/com/core/linkup/common/entity/BaseMembershipEntity.java index 3204616..871df58 100644 --- a/src/main/java/com/core/linkup/common/entity/BaseMembershipEntity.java +++ b/src/main/java/com/core/linkup/common/entity/BaseMembershipEntity.java @@ -18,6 +18,7 @@ @NoArgsConstructor public abstract class BaseMembershipEntity extends BaseEntity{ + private Long officeId; private String location; private Long price; private Integer duration; diff --git a/src/main/java/com/core/linkup/reservation/membership/company/converter/CompanyMembershipConverter.java b/src/main/java/com/core/linkup/reservation/membership/company/converter/CompanyMembershipConverter.java index 4e71409..9ba59c3 100644 --- a/src/main/java/com/core/linkup/reservation/membership/company/converter/CompanyMembershipConverter.java +++ b/src/main/java/com/core/linkup/reservation/membership/company/converter/CompanyMembershipConverter.java @@ -31,10 +31,12 @@ public CompanyResponse toCompanyResponse(Company company) { .build(); } - public CompanyMembership toCompanyMembership(CompanyMembershipRequest request, + public CompanyMembership toCompanyMembership(Long officeId, + CompanyMembershipRequest request, Long companyId){ return CompanyMembership.builder() .location(request.getLocation()) + .officeId(officeId) .type(MembershipType.COMPANY_PASS) .price(request.getPrice()) .duration(request.getDuration()) @@ -49,6 +51,7 @@ public CompanyMembership toCompanyMembership(CompanyMembershipRequest request, public MembershipResponse toMembershipResponse(CompanyMembership companyMembership) { return MembershipResponse.builder() .id(companyMembership.getId()) + .officeId(companyMembership.getOfficeId()) .type(companyMembership.getType().getName()) .location(companyMembership.getLocation()) .duration(companyMembership.getDuration()) diff --git a/src/main/java/com/core/linkup/reservation/membership/company/service/CompanyMembershipService.java b/src/main/java/com/core/linkup/reservation/membership/company/service/CompanyMembershipService.java index 1e3fbdb..3fdca72 100644 --- a/src/main/java/com/core/linkup/reservation/membership/company/service/CompanyMembershipService.java +++ b/src/main/java/com/core/linkup/reservation/membership/company/service/CompanyMembershipService.java @@ -38,11 +38,12 @@ public class CompanyMembershipService { // 기업 생성, 기업 멤버십 생성 @Transactional public CompanyMembershipRegistrationResponse registerCompanyMembership( + Long officeId, CompanyMembershipRegistrationRequest request) { if (request.getCompany().isConsentContact()){ Company company = saveCompany(request.getCompany()); CompanyMembership companyMembership = - saveCompanyMembership(request.getCompanyMembership(), company.getId()); + saveCompanyMembership(officeId, request.getCompanyMembership(), company.getId()); String authCode = authCodeUtils.createCompanyAuthCode(); sendCompanyAuthCode(company, authCode); @@ -70,12 +71,13 @@ public void sendCompanyAuthCode(Company company, String authCode) { } // 기업 멤버십 생성 - public CompanyMembership saveCompanyMembership(CompanyMembershipRequest request, + public CompanyMembership saveCompanyMembership(Long officeId, + CompanyMembershipRequest request, Long companyId) { return companyMembershipRepository.save( companyMembershipConverter.toCompanyMembership( - request, companyId)); + officeId, request, companyId)); } public Company saveCompany(CompanyRequest request) { diff --git a/src/main/java/com/core/linkup/reservation/membership/individual/converter/IndividualMembershipConverter.java b/src/main/java/com/core/linkup/reservation/membership/individual/converter/IndividualMembershipConverter.java index 63601b3..35dadbc 100644 --- a/src/main/java/com/core/linkup/reservation/membership/individual/converter/IndividualMembershipConverter.java +++ b/src/main/java/com/core/linkup/reservation/membership/individual/converter/IndividualMembershipConverter.java @@ -10,10 +10,13 @@ @Converter public class IndividualMembershipConverter { - public IndividualMembership toIndividualMembershipEntity(IndividualMembershipRequest request, Member member) { + public IndividualMembership toIndividualMembershipEntity(Long officeId, + IndividualMembershipRequest + request, Member member) { MembershipType membershipType = MembershipType.fromKor(request.getType()); return IndividualMembership.builder() .location(request.getLocation()) + .officeId(officeId) .type(membershipType) .duration(request.getDuration()) .startDate(request.getStartDate().atStartOfDay()) @@ -28,6 +31,7 @@ public MembershipResponse toMembershipResponse(IndividualMembership individualMe .type(individualMembership.getType().getName()) .id(individualMembership.getId()) .location(individualMembership.getLocation()) + .officeId(individualMembership.getOfficeId()) .price(individualMembership.getPrice()) .duration(individualMembership.getDuration()) .startDate(individualMembership.getStartDate().toLocalDate()) diff --git a/src/main/java/com/core/linkup/reservation/membership/individual/service/IndividualMembershipService.java b/src/main/java/com/core/linkup/reservation/membership/individual/service/IndividualMembershipService.java index d4243ab..2ec93c8 100644 --- a/src/main/java/com/core/linkup/reservation/membership/individual/service/IndividualMembershipService.java +++ b/src/main/java/com/core/linkup/reservation/membership/individual/service/IndividualMembershipService.java @@ -19,10 +19,11 @@ public class IndividualMembershipService { private final IndividualMembershipRepository individualMembershipRepository; private final IndividualMembershipConverter individualMembershipConverter; - public IndividualMembership saveIndividualMembership(IndividualMembershipRequest request, + public IndividualMembership saveIndividualMembership(Long officeId, + IndividualMembershipRequest request, Member member) { return individualMembershipRepository.save( - individualMembershipConverter.toIndividualMembershipEntity(request, member)); + individualMembershipConverter.toIndividualMembershipEntity(officeId, request, member)); } } diff --git a/src/main/java/com/core/linkup/reservation/reservation/controller/CompanyMembershipReservationController.java b/src/main/java/com/core/linkup/reservation/reservation/controller/CompanyMembershipReservationController.java index 03f9f64..d791c61 100644 --- a/src/main/java/com/core/linkup/reservation/reservation/controller/CompanyMembershipReservationController.java +++ b/src/main/java/com/core/linkup/reservation/reservation/controller/CompanyMembershipReservationController.java @@ -25,11 +25,13 @@ public class CompanyMembershipReservationController { private final CompanyMembershipReservationService companyMembershipReservationService; // 기업 등록, 기업 멤버십 생성, 기업 인증번호 발송 - @PostMapping + @PostMapping("/{officeId}") public BaseResponse registerCompany( - @RequestBody CompanyMembershipRegistrationRequest request) { + @RequestBody CompanyMembershipRegistrationRequest request, + @PathVariable Long officeId + ) { CompanyMembershipRegistrationResponse response = - companyMembershipReservationService.registerCompanyMembership(request); + companyMembershipReservationService.registerCompanyMembership(officeId, request); return BaseResponse.response(response); } diff --git a/src/main/java/com/core/linkup/reservation/reservation/response/MembershipResponse.java b/src/main/java/com/core/linkup/reservation/reservation/response/MembershipResponse.java index d02c48e..eeeb97b 100644 --- a/src/main/java/com/core/linkup/reservation/reservation/response/MembershipResponse.java +++ b/src/main/java/com/core/linkup/reservation/reservation/response/MembershipResponse.java @@ -10,6 +10,7 @@ public class MembershipResponse { private Long id; private String location; + private Long officeId; private Long price; private String type; private Integer duration; diff --git a/src/main/java/com/core/linkup/reservation/reservation/service/CompanyMembershipReservationService.java b/src/main/java/com/core/linkup/reservation/reservation/service/CompanyMembershipReservationService.java index bfb31e0..279ee7d 100644 --- a/src/main/java/com/core/linkup/reservation/reservation/service/CompanyMembershipReservationService.java +++ b/src/main/java/com/core/linkup/reservation/reservation/service/CompanyMembershipReservationService.java @@ -38,8 +38,10 @@ public class CompanyMembershipReservationService { private final CompanyMembershipConverter companyMembershipConverter; // (생성, 응답 변환) 기업 문의하기 -> 기업, 기업 멤버십 생성 - public CompanyMembershipRegistrationResponse registerCompanyMembership(CompanyMembershipRegistrationRequest request) { - return companyMembershipService.registerCompanyMembership(request); + public CompanyMembershipRegistrationResponse registerCompanyMembership( + Long officeId, + CompanyMembershipRegistrationRequest request) { + return companyMembershipService.registerCompanyMembership(officeId, request); } // 사용자의 단일 기업 멤버십 diff --git a/src/main/java/com/core/linkup/reservation/reservation/service/IndividualMembershipReservationService.java b/src/main/java/com/core/linkup/reservation/reservation/service/IndividualMembershipReservationService.java index 474c6a3..5b99cb6 100644 --- a/src/main/java/com/core/linkup/reservation/reservation/service/IndividualMembershipReservationService.java +++ b/src/main/java/com/core/linkup/reservation/reservation/service/IndividualMembershipReservationService.java @@ -51,7 +51,7 @@ public MembershipReservationListResponse registerIndividualMembership( IndividualMembershipRegistrationRequest requests, Member member, Long officeId) { reservationValidationService.validateOfficeLocation(requests, officeId); IndividualMembership membership = - individualMembershipService.saveIndividualMembership(requests.getMembership(), member); + individualMembershipService.saveIndividualMembership(officeId, requests.getMembership(), member); List reservationResponses = reservationService.createReservationResponses(requests.getReservations(), membership); return reservationConverter.toMembershipReservationListResponse(