Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/Shimpyo-House/Shimpyo_BE
Browse files Browse the repository at this point in the history
…into refactor/product-room-cart
  • Loading branch information
wocjf0513 committed Dec 15, 2023
2 parents f713d85 + 5474d98 commit fb92e7c
Show file tree
Hide file tree
Showing 37 changed files with 478 additions and 175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public CartDeleteResponse deleteCart(final Long cartId) {
}

public CartResponse getCartResponse(final Cart cart) {

List<Room> rooms = Optional.of(roomRepository.findByCode(cart.getRoomCode()))
.orElseThrow();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.fc.shimpyo_be.global.common.ResponseDto;
import com.fc.shimpyo_be.global.util.SecurityUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.HttpStatus;
Expand All @@ -20,35 +19,33 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/favorites")
public class FavoriteRestController {

private final FavoriteService favoriteService;
private final SecurityUtil securityUtil;
private static final int DEFAULT_SIZE = 10;
private static final int DEFAULT_PAGE = 0;

@PostMapping("/{productId}")
public ResponseEntity<ResponseDto<FavoriteResponseDto>> register(@PathVariable long productId) {
log.debug("memberId: {}, productId: {}", securityUtil.getCurrentMemberId(), productId);
return ResponseEntity.status(HttpStatus.CREATED).body(ResponseDto.res(HttpStatus.CREATED,
favoriteService.register(securityUtil.getCurrentMemberId(), productId),
"성공적으로 즐겨찾기를 등록했습니다."));
}

@GetMapping
public ResponseEntity<ResponseDto<FavoritesResponseDto>> getFavorites(
@PageableConstraint(Favorite.class) @PageableDefault(size = 10, page = 0) Pageable pageable) {
log.debug("memberId: {}", securityUtil.getCurrentMemberId());
@PageableConstraint(Favorite.class) @PageableDefault(size = DEFAULT_SIZE, page = DEFAULT_PAGE) Pageable pageable) {
return ResponseEntity.status(HttpStatus.OK)
.body(ResponseDto.res(HttpStatus.OK, favoriteService.getFavorites(
securityUtil.getCurrentMemberId(), pageable), "성공적으로 즐겨찾기 목록을 조회했습니다."));
}

@DeleteMapping("/{productId}")
public ResponseEntity<ResponseDto<FavoriteResponseDto>> cancel(@PathVariable long productId) {
log.debug("memberId: {}, productId: {}", securityUtil.getCurrentMemberId(), productId);
return ResponseEntity.status(HttpStatus.OK).body(ResponseDto.res(HttpStatus.OK,
favoriteService.delete(securityUtil.getCurrentMemberId(), productId),
"성공적으로 즐겨찾기를 취소했습니다."));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package com.fc.shimpyo_be.domain.favorite.dto;

import com.fc.shimpyo_be.domain.favorite.entity.Favorite;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class FavoriteResponseDto {

private Long favoriteId;
private Long memberId;
private Long productId;

@Builder
public FavoriteResponseDto(Long favoriteId, Long memberId, Long productId) {
private FavoriteResponseDto(Long favoriteId, Long memberId, Long productId) {
this.favoriteId = favoriteId;
this.memberId = memberId;
this.productId = productId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

import com.fc.shimpyo_be.domain.product.dto.response.ProductResponse;
import java.util.List;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class FavoritesResponseDto {

private int pageCount;
private List<ProductResponse> products;

@Builder
public FavoritesResponseDto(int pageCount, List<ProductResponse> products) {
private FavoritesResponseDto(int pageCount, List<ProductResponse> products) {
this.pageCount = pageCount;
this.products = products;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Favorite {
private Product product;

@Builder
public Favorite(Long id, Member member, Product product) {
private Favorite(Long id, Member member, Product product) {
this.id = id;
this.member = member;
this.product = product;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
import com.fc.shimpyo_be.global.common.ResponseDto;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/auth")
Expand All @@ -28,7 +26,6 @@ public class AuthRestController {
@PostMapping("/signup")
public ResponseEntity<ResponseDto<MemberResponseDto>> signUp(
@Valid @RequestBody SignUpRequestDto signUpRequestDto) {
log.debug("email: {}, name: {}", signUpRequestDto.getEmail(), signUpRequestDto.getName());
return ResponseEntity.status(HttpStatus.CREATED).body(
ResponseDto.res(HttpStatus.CREATED, authService.signUp(signUpRequestDto),
"성공적으로 회원가입 했습니다."));
Expand All @@ -37,7 +34,6 @@ public ResponseEntity<ResponseDto<MemberResponseDto>> signUp(
@PostMapping("/signin")
public ResponseEntity<ResponseDto<SignInResponseDto>> signIn(
@Valid @RequestBody SignInRequestDto signInRequestDto) {
log.debug("email: {}", signInRequestDto.getEmail());
return ResponseEntity.status(HttpStatus.OK).body(
ResponseDto.res(HttpStatus.OK, authService.signIn(signInRequestDto),
"성공적으로 로그인 했습니다."));
Expand All @@ -46,8 +42,6 @@ public ResponseEntity<ResponseDto<SignInResponseDto>> signIn(
@PostMapping("/refresh")
public ResponseEntity<ResponseDto<SignInResponseDto>> refresh(
@Valid @RequestBody RefreshRequestDto refreshRequestDto) {
log.debug("accessToken: {}, refreshToken: {}", refreshRequestDto.getAccessToken(),
refreshRequestDto.getRefreshToken());
return ResponseEntity.status(HttpStatus.OK).body(
ResponseDto.res(HttpStatus.OK, authService.refresh(refreshRequestDto),
"성공적으로 토큰을 재발급 했습니다."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.fc.shimpyo_be.global.common.ResponseDto;
import com.fc.shimpyo_be.global.util.SecurityUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -17,7 +16,6 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/members")
Expand All @@ -28,7 +26,6 @@ public class MemberRestController {

@GetMapping
public ResponseEntity<ResponseDto<MemberResponseDto>> getMember() {
log.debug("memberId: {}", securityUtil.getCurrentMemberId());
return ResponseEntity.status(HttpStatus.OK).body(
ResponseDto.res(HttpStatus.OK, memberService.getMember(),
"성공적으로 회원 정보를 조회했습니다."));
Expand All @@ -37,7 +34,6 @@ public ResponseEntity<ResponseDto<MemberResponseDto>> getMember() {
@PatchMapping
public ResponseEntity<ResponseDto<MemberResponseDto>> updateMember(@RequestBody
UpdateMemberRequestDto updateMemberRequestDto) {
log.debug("memberId: {}", securityUtil.getCurrentMemberId());
return ResponseEntity.status(HttpStatus.OK).body(
ResponseDto.res(HttpStatus.OK, memberService.updateMember(updateMemberRequestDto),
"성공적으로 회원 정보를 수정했습니다."));
Expand All @@ -46,7 +42,6 @@ public ResponseEntity<ResponseDto<MemberResponseDto>> updateMember(@RequestBody
@PostMapping
public ResponseEntity<ResponseDto<Void>> checkPassword(
@RequestBody CheckPasswordRequestDto checkPasswordRequestDto) {
log.debug("memberId: {}", securityUtil.getCurrentMemberId());
memberService.checkPassword(checkPasswordRequestDto);
return ResponseEntity.status(HttpStatus.OK).body(
ResponseDto.res(HttpStatus.OK, "비밀번호가 일치합니다."));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package com.fc.shimpyo_be.domain.member.dto.request;

import jakarta.validation.constraints.NotBlank;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class CheckPasswordRequestDto {

@NotBlank(message = "비밀번호를 입력하세요.")
private String password;

@Builder
public CheckPasswordRequestDto(String password) {
private CheckPasswordRequestDto(String password) {
this.password = password;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.fc.shimpyo_be.domain.member.dto.request;

import jakarta.validation.constraints.NotBlank;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class RefreshRequestDto {

@NotBlank(message = "Access Token 을 입력하세요.")
Expand All @@ -15,7 +16,7 @@ public class RefreshRequestDto {
private String refreshToken;

@Builder
public RefreshRequestDto(String accessToken, String refreshToken) {
private RefreshRequestDto(String accessToken, String refreshToken) {
this.accessToken = accessToken;
this.refreshToken = refreshToken;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;

@Getter
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class SignInRequestDto {

@NotBlank(message = "이메일을 입력하세요.")
Expand All @@ -19,12 +19,12 @@ public class SignInRequestDto {
private String password;

@Builder
public SignInRequestDto(String email, String password) {
private SignInRequestDto(String email, String password) {
this.email = email;
this.password = password;
}

public UsernamePasswordAuthenticationToken toAuthentication(){
public UsernamePasswordAuthenticationToken toAuthentication() {
return new UsernamePasswordAuthenticationToken(this.email, this.password);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,36 @@
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.security.crypto.password.PasswordEncoder;

@Getter
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class SignUpRequestDto {

private static final String EMAIL_REGEX = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
private static final int NAME_MIN = 2;
private static final int NAME_MAX = 30;
private static final String PASSWORD_REGEX = "^(?=.*[A-Za-z])(?=.*\\d)(?=.*[@$#^()!%*?&])[A-Za-z\\d@$!#^()%*?&]{8,30}$";

@NotBlank(message = "이메일을 입력하세요.")
@Pattern(regexp = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", message = "이메일 형식에 맞게 입력해주세요.")
@Pattern(regexp = EMAIL_REGEX, message = "이메일 형식에 맞게 입력해주세요.")
private String email;
@NotBlank(message = "이름을 입력하세요.")
@Size(min = 2, max = 30, message = "이름은 최소 2자 이상 최대 30자 이내로 입력하세요.")
@Size(min = NAME_MIN, max = NAME_MAX, message = "이름은 최소 2자 이상 최대 30자 이내로 입력하세요.")
private String name;
@NotBlank(message = "비밀번호를 입력하세요.")
@Pattern(regexp = PASSWORD_REGEX)
private String password;
@NotBlank(message = "비밀번호 확인을 입력하세요.")
@Pattern(regexp = PASSWORD_REGEX)
private String passwordConfirm;

@Builder
public SignUpRequestDto(String email, String name, String password, String passwordConfirm) {
private SignUpRequestDto(String email, String name, String password, String passwordConfirm) {
this.email = email;
this.name = name;
this.password = password;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package com.fc.shimpyo_be.domain.member.dto.request;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class UpdateMemberRequestDto {

private String password;
private String passwordConfirm;
private String photoUrl;

@Builder
public UpdateMemberRequestDto(String password, String passwordConfirm, String photoUrl) {
private UpdateMemberRequestDto(String password, String passwordConfirm, String photoUrl) {
this.password = password;
this.passwordConfirm = passwordConfirm;
this.photoUrl = photoUrl;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.fc.shimpyo_be.domain.member.dto.response;

import com.fc.shimpyo_be.domain.member.entity.Member;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class MemberResponseDto {

private Long memberId;
Expand All @@ -15,7 +16,7 @@ public class MemberResponseDto {
private String photoUrl;

@Builder
public MemberResponseDto(Long memberId, String email, String name, String photoUrl) {
private MemberResponseDto(Long memberId, String email, String name, String photoUrl) {
this.memberId = memberId;
this.email = email;
this.name = name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package com.fc.shimpyo_be.domain.member.dto.response;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class SignInResponseDto {

private MemberResponseDto member;
private TokenResponseDto token;

@Builder
public SignInResponseDto(MemberResponseDto member, TokenResponseDto token) {
private SignInResponseDto(MemberResponseDto member, TokenResponseDto token) {
this.member = member;
this.token = token;
}
Expand Down
Loading

0 comments on commit fb92e7c

Please sign in to comment.