Skip to content
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 @@ -6,10 +6,7 @@
import com.petmatz.api.user.request.SignInRequestDto;
import com.petmatz.api.user.request.SignUpRequestDto;
import com.petmatz.domain.user.entity.User;
import com.petmatz.domain.user.response.CheckCertificationResponseDto;
import com.petmatz.domain.user.response.DeleteIdResponseDto;
import com.petmatz.domain.user.response.SignInResponseDto;
import com.petmatz.domain.user.response.SignUpResponseDto;
import com.petmatz.domain.user.response.*;
import com.petmatz.domain.user.service.AuthService;
import com.petmatz.user.common.LogInResponseDto;
import jakarta.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -45,8 +42,8 @@ public Response<Void> logout(HttpServletResponse res) {
}

@PostMapping("/sign-up")
public Response<SignUpResponseDto> signUp(@RequestBody @Valid SignUpRequestDto requestBody) throws MalformedURLException {
SignUpResponseDto responseDto = authService.signUp(SignUpRequestDto.of(requestBody));
public Response<SignUpResponse> signUp(@RequestBody @Valid SignUpRequestDto requestBody) throws MalformedURLException {
SignUpResponse responseDto = authService.signUp(SignUpRequestDto.of(requestBody));
return Response.success(responseDto);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
import com.petmatz.domain.user.service.HeartService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api")
public class HeartController {

private final HeartService heartService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
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;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api")
public class LocationController {

private final LocationService locationService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@
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;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api")
public class PasswordController {

private final PasswordService passwordService;

@PostMapping("/send-repassword")
public Response<SendRepasswordResponseDto> sendRepassword(@RequestBody @Valid SendRepasswordRequestDto requestBody) {
SendRepasswordResponseDto sendRepasswordResponseDto = passwordService.sendRepassword(requestBody);
return Response.success(sendRepasswordResponseDto);
public Response<Void> sendRepassword(@RequestBody @Valid SendRepasswordRequestDto requestBody) {
passwordService.sendRepassword(requestBody);
return Response.success();
}

@PostMapping("/repassword")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
import com.petmatz.domain.user.service.RankService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api")
public class RankController {

private final RankService rankService;

@GetMapping("/api/top-rankings")
@GetMapping("/top-rankings")
public Response<List<RankUserResponse>> getTopRankings() {
List<RankUserResponse> topRankings = rankService.getTopRankingsByRegion();
return Response.success(topRankings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api")
public class RecommendController {

private final RecommendService recommendService;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/petmatz/common/security/jwt/JwtManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ public String createAccessToken(Long userId, String accountId) {
}

public String createRefreshToken(Long userId) {
Date expireDate = Date.from(Instant.now().plus(2, ChronoUnit.WEEKS));
Date expireDate = Date.from(Instant.now().plus(7 * 7, ChronoUnit.DAYS));
SecretKey secretKey = Keys.hmacShaKeyFor(refreshKey.getBytes(StandardCharsets.UTF_8));

String refreshToken = Jwts.builder()
.signWith(secretKey, SignatureAlgorithm.RS256)
.signWith(secretKey, SignatureAlgorithm.HS256)
.setSubject(userId.toString())
.setIssuedAt(new Date())
.setExpiration(expireDate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import java.security.cert.CertificateException;
import java.time.LocalDateTime;

import static com.petmatz.domain.user.exception.UserErrorCode.CERTIFICATION_EXPIRED;
import static com.petmatz.domain.user.exception.UserErrorCode.MISS_MATCH_CODE;
import static com.petmatz.domain.user.exception.UserErrorCode.*;

@Component
@RequiredArgsConstructor
Expand Down Expand Up @@ -47,7 +46,7 @@ public User validateSignInCredentials(SignInInfo info) throws AuthenticationExce

String encodedPassword = user.getPassword();
if (!passwordEncoder.matches(password, encodedPassword)) {
// throw new UserException();
throw new UserException(PASS_WORD_MISMATCH);
}
return user;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.petmatz.domain.user.entity.KakaoRegion;
import com.petmatz.domain.user.exception.UserException;
import com.petmatz.domain.user.response.KakaoGeocodingResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
Expand All @@ -14,6 +15,7 @@
import static com.petmatz.domain.user.exception.UserErrorCode.INSUFFICIENT_LOCATION_DATA;

@Service
@Slf4j
public class GeocodingComponent {
@Value("${kakao-api-url}")
private String KAKAO_API_URL;
Expand Down Expand Up @@ -65,8 +67,10 @@ private void logInfo(KakaoRegion region) {
*/
public KakaoRegion getValidRegion(double latitude, double longitude) {
KakaoRegion kakaoRegion = getRegionFromCoordinates(latitude, longitude);
System.out.println("kakao region : " + kakaoRegion);
// 지역 정보 검증
if (kakaoRegion == null || kakaoRegion.getCodeAsInteger() == null) {
System.out.println("kakao region get code어쩌구 : " + kakaoRegion.getCodeAsInteger());
throw new UserException(INSUFFICIENT_LOCATION_DATA);
}
return kakaoRegion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public enum UserErrorCode implements BaseErrorCode {
HEART_USER_NOT_FOUND(404, "HEART_USER_NOT_FOUND", "찜한 사용자를 찾을 수 없습니다."),
FAIL_MAIL_SEND(400, "FAIL_MAIL_SEND", "메일 전송에 실패하였습니다."),
PASSWORD_MISMATCH(403, "PASSWORD_MISMATCH", "비밀번호가 일치하지 않습니다."),
HEART_USER_DUPLICATE(400, "HEART_USER_DUPLICATE", "찜한 사용자가 이미 존재합니다.");
HEART_USER_DUPLICATE(400, "HEART_USER_DUPLICATE", "찜한 사용자가 이미 존재합니다."),
PASS_WORD_MISMATCH(401, "LOGIN_FAILED", "비밀번호 불일치");


private final Integer status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
import org.springframework.http.ResponseEntity;

@Getter
public class EditMyProfileResponseDto extends LogInResponseDto {
public class EditMyProfileResponseDto {
private String resultImgURL;

public EditMyProfileResponseDto(String resultImgURL){
super();
this.resultImgURL=resultImgURL;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.List;

@Getter
public class GetMyProfileResponseDto extends LogInResponseDto {
public class GetMyProfileResponseDto {
private Long id;
private String accountId;
private String nickname;
Expand Down Expand Up @@ -45,14 +45,14 @@ public GetMyProfileResponseDto(User user) {
this.region = user.getRegion();
this.regionCode=user.getRegionCode();
}

public static ResponseEntity<LogInResponseDto> idNotFound() {
LogInResponseDto responseBody = new LogInResponseDto(ResponseCode.ID_NOT_FOUND, ResponseMessage.ID_NOT_FOUND);
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(responseBody);
}

public static ResponseEntity<GetMyProfileResponseDto> success(User user) { // 반환 타입 수정
GetMyProfileResponseDto responseBody = new GetMyProfileResponseDto(user);
return ResponseEntity.status(HttpStatus.OK).body(responseBody);
}
//
// public static ResponseEntity<LogInResponseDto> idNotFound() {
// LogInResponseDto responseBody = new LogInResponseDto(ResponseCode.ID_NOT_FOUND, ResponseMessage.ID_NOT_FOUND);
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(responseBody);
// }
//
// public static ResponseEntity<GetMyProfileResponseDto> success(User user) { // 반환 타입 수정
// GetMyProfileResponseDto responseBody = new GetMyProfileResponseDto(user);
// return ResponseEntity.status(HttpStatus.OK).body(responseBody);
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.List;

@Getter
public class GetOtherProfileResponseDto extends LogInResponseDto {
public class GetOtherProfileResponseDto{
private Long id;
private String accountId;
private String nickname;
Expand All @@ -31,7 +31,6 @@ public class GetOtherProfileResponseDto extends LogInResponseDto {
private boolean isMyHeartUser;

public GetOtherProfileResponseDto(User user, boolean isMyHeartUser) {
super();
this.id = user.getId();
this.accountId = user.getAccountId();
this.nickname = user.getNickname();
Expand All @@ -49,14 +48,14 @@ public GetOtherProfileResponseDto(User user, boolean isMyHeartUser) {
this.regionCode=user.getRegionCode();
}

public static ResponseEntity<LogInResponseDto> userNotFound() {
LogInResponseDto responseBody=new LogInResponseDto(ResponseCode.ID_NOT_FOUND, ResponseMessage.ID_NOT_FOUND);
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(responseBody);
}

public static ResponseEntity<LogInResponseDto> success(User user,boolean isMyHeartUser) {
GetOtherProfileResponseDto responseBody = new GetOtherProfileResponseDto(user,isMyHeartUser);
return ResponseEntity.status(HttpStatus.OK).body(responseBody);
}
// public static ResponseEntity<LogInResponseDto> userNotFound() {
// LogInResponseDto responseBody=new LogInResponseDto(ResponseCode.ID_NOT_FOUND, ResponseMessage.ID_NOT_FOUND);
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(responseBody);
// }
//
// public static ResponseEntity<LogInResponseDto> success(User user,boolean isMyHeartUser) {
// GetOtherProfileResponseDto responseBody = new GetOtherProfileResponseDto(user,isMyHeartUser);
// return ResponseEntity.status(HttpStatus.OK).body(responseBody);
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.springframework.http.ResponseEntity;

@Getter
public class GetRecommendationResponseDto extends LogInResponseDto {
public class GetRecommendationResponseDto{

private boolean isRecommended;
public GetRecommendationResponseDto(boolean isRecommended) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.springframework.http.ResponseEntity;

@Getter
public class SendRepasswordResponseDto extends LogInResponseDto{
public class SendRepasswordResponseDto{

public SendRepasswordResponseDto(){
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
import com.petmatz.domain.user.constant.LoginType;
import com.petmatz.domain.user.constant.PreferredSize;
import com.petmatz.domain.user.entity.User;
import com.petmatz.user.common.LogInResponseDto;
import com.petmatz.user.common.ResponseCode;
import com.petmatz.user.common.ResponseMessage;
import lombok.Getter;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import java.util.List;

@Getter
public class SignInResponseDto extends LogInResponseDto {
public class SignInResponseDto {
private Long id;
private String accountId;
private String nickname;
Expand All @@ -32,7 +27,6 @@ public class SignInResponseDto extends LogInResponseDto {
private Integer regionCode;

public SignInResponseDto(User user) {
super();
this.id = user.getId();
this.accountId = user.getAccountId();
this.nickname = user.getNickname();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.petmatz.domain.user.response;

import lombok.Getter;


public record SignUpResponse(
Long id,
String imgURL) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,12 @@
import org.springframework.http.ResponseEntity;

@Getter
public class UpdateLocationResponseDto extends LogInResponseDto{
public class UpdateLocationResponseDto {
private String region;
private Integer regionCode;

public UpdateLocationResponseDto(String region, Integer regionCode){
this.region = region;
this.regionCode=regionCode;
}

public static ResponseEntity<LogInResponseDto> wrongLocation(){
LogInResponseDto responseBody = new LogInResponseDto(ResponseCode.WRONG_LOCATION, ResponseMessage.WRONG_LOCATION);
return ResponseEntity.status(HttpStatus.FORBIDDEN).body(responseBody);
}

public static ResponseEntity<UpdateLocationResponseDto> success(String region,Integer regionCode) { // 반환 타입 수정
UpdateLocationResponseDto responseBody = new UpdateLocationResponseDto(region,regionCode);
return ResponseEntity.status(HttpStatus.OK).body(responseBody);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.petmatz.domain.user.repository.CertificationRepository;
import com.petmatz.domain.user.repository.UserRepository;
import com.petmatz.domain.user.response.SignInResponseDto;
import com.petmatz.domain.user.response.SignUpResponse;
import com.petmatz.domain.user.response.SignUpResponseDto;
import com.petmatz.domain.user.component.GeocodingComponent;
import jakarta.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -54,13 +55,13 @@ public class AuthService {
private PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();

@Transactional
public SignUpResponseDto signUp(SignUpInfo info) throws MalformedURLException {
public SignUpResponse signUp(SignUpInfo info) throws MalformedURLException {
String accountId = info.getAccountId();
String certificationNumber = info.getCertificationNumber();
String password = info.getPassword();

authenticationComponent.validateRequiredFields(accountId, certificationNumber, password);
authenticationComponent.validateCertification(accountId);
// authenticationComponent.validateCertification(accountId);
authenticationComponent.validateDuplicateAccountId(accountId);

String encodedPassword = passwordEncoder.encode(info.getPassword());
Expand All @@ -78,7 +79,7 @@ public SignUpResponseDto signUp(SignUpInfo info) throws MalformedURLException {
//인증 엔티티 삭제
certificationRepository.deleteAllByAccountId(accountId);

return new SignUpResponseDto(user.getId(), petImg.checkResultImg());
return new SignUpResponse(user.getId(), petImg.checkResultImg());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public class KakaoUserService {
public void editKakaoProfile(EditKakaoProfileInfo info) {
Long userId = jwtExtractProvider.findIdFromJwt();
userUtils.findJwtUser(userId);
userUtils.checkDuplicateId(userId);
User user = userUtils.findIdUser(userId);

KakaoRegion kakaoRegion = geocodingComponent.getRegionFromCoordinates(info.getLatitude(), info.getLongitude());
Expand Down
Loading