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

Feat/store #22

Merged
merged 5 commits into from
Nov 18, 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
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public OAuth2User loadUser(OAuth2UserRequest oAuth2UserRequest) throws OAuth2Aut
}
} else if ("owner".equals(state)) {
User existUser = userRepository.findByProviderId(userId).orElse(null);
if (existUser == null) {
if (existUser == null || !existUser.getRole().equals("ROLE_OWNER")) {
User newUser = User.create(userId, oAuth2Response.getNickname(), oAuth2Response.getImage(),
"ROLE_OWNER");
userRepository.save(newUser);
Expand Down
24 changes: 16 additions & 8 deletions src/main/java/com/jangburich/domain/store/domain/Store.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package com.jangburich.domain.store.domain;

import java.time.DayOfWeek;
import java.time.LocalTime;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jangburich.domain.owner.domain.Owner;

import jakarta.persistence.CollectionTable;
import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
Expand Down Expand Up @@ -69,14 +76,19 @@ public class Store {
@Column(name = "location")
private String location;

@ElementCollection(targetClass = DayOfWeek.class)
@Enumerated(EnumType.STRING)
@CollectionTable(name = "work_days", joinColumns = @JoinColumn(name = "work_schedule_id"))
@Column(name = "day_of_week")
private String dayOfWeek;
private List<DayOfWeek> workDays;

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss")
@Column(name = "open_time")
private String openTime;
private LocalTime openTime;

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss")
@Column(name = "close_time")
private String closeTime;
private LocalTime closeTime;

@Column(name = "contact_number")
private String contactNumber;
Expand All @@ -87,17 +99,13 @@ public static Store of(Owner owner, StoreCreateRequestDTO storeCreateRequestDTO)
newStore.setName(storeCreateRequestDTO.getName());
newStore.setCategory(storeCreateRequestDTO.getCategory());
newStore.setRepresentativeImage(storeCreateRequestDTO.getRepresentativeImage());
newStore.setReservationAvailable(storeCreateRequestDTO.getReservationAvailable());
newStore.setMaxReservation(storeCreateRequestDTO.getMaxReservation());
newStore.setMinPrepayment(storeCreateRequestDTO.getMinPrepayment());
newStore.setPrepaymentDuration(storeCreateRequestDTO.getPrepaymentDuration());
newStore.setIntroduction(storeCreateRequestDTO.getIntroduction());
newStore.setLatitude(storeCreateRequestDTO.getLatitude());
newStore.setLongitude(storeCreateRequestDTO.getLongitude());
newStore.setAddress(storeCreateRequestDTO.getAddress());
newStore.setAddress(storeCreateRequestDTO.getAddress());
newStore.setLocation(storeCreateRequestDTO.getLocation());
newStore.setDayOfWeek(storeCreateRequestDTO.getDayOfWeek());
newStore.setWorkDays(storeCreateRequestDTO.getDayOfWeek());
newStore.setOpenTime(storeCreateRequestDTO.getOpenTime());
newStore.setCloseTime(storeCreateRequestDTO.getCloseTime());
newStore.setContactNumber(storeCreateRequestDTO.getContactNumber());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.jangburich.domain.store.domain;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@RequiredArgsConstructor
public class StoreAdditionalInfoCreateRequestDTO {
private Boolean reservationAvailable;
private Long maxReservation;
private Long minPrepayment;
private Long prepaymentDuration;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.jangburich.domain.store.domain;

import java.time.DayOfWeek;
import java.time.LocalTime;
import java.util.List;

import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import lombok.Getter;
Expand All @@ -17,10 +21,6 @@ public class StoreCreateRequestDTO {
private Category category;

private String representativeImage;
private Boolean reservationAvailable;
private Long maxReservation;
private Long minPrepayment;
private Long prepaymentDuration;
private String introduction;
private String contactNumber;

Expand All @@ -31,7 +31,7 @@ public class StoreCreateRequestDTO {
private String location;

// business hour
private String dayOfWeek;
private String openTime;
private String closeTime;
private List<DayOfWeek> dayOfWeek;
private LocalTime openTime;
private LocalTime closeTime;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.jangburich.domain.store.domain;

import java.time.DayOfWeek;
import java.time.LocalTime;
import java.util.List;

import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import lombok.Getter;
Expand Down Expand Up @@ -27,15 +31,16 @@ public class StoreGetResponseDTO {
private Double longitude;
private String address;
private String location;
private String dayOfWeek;
private String openTime;
private String closeTime;
private List<DayOfWeek> dayOfWeek;
private LocalTime openTime;
private LocalTime closeTime;

public StoreGetResponseDTO(Long id, String ownerId, String name, Category category, String representativeImage,
Boolean reservationAvailable, Long maxReservation, Long minPrepayment, Long prepaymentDuration,
String introduction,
Double latitude, Double longitude, String address, String location, String dayOfWeek, String openTime,
String closeTime) {
Double latitude, Double longitude, String address, String location, List<DayOfWeek> dayOfWeek,
LocalTime openTime,
LocalTime closeTime) {
this.id = id;
this.ownerId = ownerId;
this.name = name;
Expand Down Expand Up @@ -71,7 +76,7 @@ public StoreGetResponseDTO of(Store store) {
store.getLongitude(),
store.getAddress(),
store.getLocation(),
store.getDayOfWeek(),
store.getWorkDays(),
store.getOpenTime(),
store.getCloseTime()
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.jangburich.domain.store.domain;

import java.time.DayOfWeek;
import java.time.LocalTime;
import java.util.List;

import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import lombok.Getter;
Expand All @@ -22,7 +26,7 @@ public class StoreUpdateRequestDTO {
private Double longitude;
private String address;
private String location;
private String dayOfWeek;
private String openTime;
private String closeTime;
private List<DayOfWeek> dayOfWeek;
private LocalTime openTime;
private LocalTime closeTime;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.web.bind.annotation.RestController;

import com.jangburich.domain.oauth.domain.CustomOAuthUser;
import com.jangburich.domain.store.domain.StoreAdditionalInfoCreateRequestDTO;
import com.jangburich.domain.store.domain.StoreCreateRequestDTO;
import com.jangburich.domain.store.domain.StoreGetResponseDTO;
import com.jangburich.domain.store.domain.StoreUpdateRequestDTO;
Expand Down Expand Up @@ -39,6 +40,17 @@ public ResponseCustom<Message> createStore(Authentication authentication,
.build());
}

@Operation(summary = "κ°€κ²Œ 좔가정보 μ €μž₯", description = "μ˜ˆμ•½ κ°€λŠ₯ μ—¬λΆ€, μ΅œμ†Œ μ„ κ²°μ œ κΈˆμ•‘, μ„ κ²°μ œ μ‚¬μš© 기간을 μ €μž₯ν•©λ‹ˆλ‹€.")
@PostMapping("/create/additionalInfo")
public ResponseCustom<Message> createAdditionalInfo(Authentication authentication, @RequestBody
StoreAdditionalInfoCreateRequestDTO storeAdditionalInfoCreateRequestDTO) {
CustomOAuthUser customOAuthUser = (CustomOAuthUser)authentication.getPrincipal();
storeService.CreateAdditionalInfo(customOAuthUser, storeAdditionalInfoCreateRequestDTO);
return ResponseCustom.OK(Message.builder()
.message("success")
.build());
}

@Operation(summary = "κ°€κ²Œ 정보 μˆ˜μ •", description = "κ°€κ²Œ 정보λ₯Ό μˆ˜μ •ν•©λ‹ˆλ‹€.")
@PatchMapping("/{storeId}/update")
public ResponseCustom<Message> updateStore(Authentication authentication, @PathVariable Long storeId, @RequestBody
Expand All @@ -51,9 +63,9 @@ public ResponseCustom<Message> updateStore(Authentication authentication, @PathV
}

@Operation(summary = "κ°€κ²Œ 정보 쑰회", description = "κ°€κ²Œ 상세 정보λ₯Ό μ‘°νšŒν•©λ‹ˆλ‹€.")
@GetMapping("/{storeId}")
public ResponseCustom<StoreGetResponseDTO> getStoreInfo(Authentication authentication, @PathVariable Long storeId) {
@GetMapping("")
public ResponseCustom<StoreGetResponseDTO> getStoreInfo(Authentication authentication) {
CustomOAuthUser customOAuth2User = (CustomOAuthUser)authentication.getPrincipal();
return ResponseCustom.OK(storeService.getStoreInfo(customOAuth2User, storeId));
return ResponseCustom.OK(storeService.getStoreInfo(customOAuth2User));
}
}
Loading