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

[REFACTOR] 2차 리팩토링 #206

Merged
merged 1 commit into from
Feb 20, 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 @@ -10,6 +10,7 @@
import com.smeem.api.common.BaseResponse;
import com.smeem.common.util.Util;
import lombok.RequiredArgsConstructor;
import lombok.val;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

Expand All @@ -31,13 +32,13 @@ public class AuthController {
@PostMapping
public ResponseEntity<BaseResponse<?>> signIn(@RequestHeader("Authorization") String socialAccessToken,
@RequestBody SignInRequest request) throws NoSuchAlgorithmException, InvalidKeySpecException {
SignInResponse response = SignInResponse.of(authService.signIn(socialAccessToken, SignInServiceRequest.of(request)));
val response = SignInResponse.of(authService.signIn(socialAccessToken, SignInServiceRequest.of(request)));
return ApiResponseUtil.success(SUCCESS_SIGNIN, response);
}

@PostMapping("/token")
public ResponseEntity<BaseResponse<?>> reissueToken(Principal principal) {
TokenResponse response = TokenResponse.of(tokenService.issueToken(Util.getMemberId(principal)));
val response = TokenResponse.of(tokenService.issueToken(Util.getMemberId(principal)));
return ApiResponseUtil.success(SUCCESS_ISSUE_TOKEN, response);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.smeem.api.auth.controller.dto.response;


import com.smeem.api.auth.jwt.SmeemToken;
import com.smeem.api.auth.service.dto.response.SignInServiceResponse;
import lombok.Builder;

import static lombok.AccessLevel.PRIVATE;

@Builder

@Builder(access = PRIVATE)
public record SignInResponse(
String accessToken,
String refreshToken,
Expand All @@ -15,11 +16,11 @@ public record SignInResponse(
) {

public static SignInResponse of(SignInServiceResponse response) {
return new SignInResponse(
response.accessToken(),
response.refreshToken(),
response.isRegistered(),
response.hasPlan());
return SignInResponse.builder()
.accessToken(response.accessToken())
.refreshToken(response.refreshToken())
.isRegistered(response.isRegistered())
.hasPlan(response.hasPlan())
.build();
}

}
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
package com.smeem.api.auth.jwt;


import com.smeem.common.config.ValueConfig;
import com.smeem.common.exception.AuthException;
import io.jsonwebtoken.*;
import io.jsonwebtoken.security.Keys;
import io.jsonwebtoken.Header;
import io.jsonwebtoken.Jwts;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

import javax.crypto.SecretKey;
import java.util.Date;

import static com.smeem.api.auth.jwt.JwtValidationType.*;
import static java.util.Base64.getEncoder;

@Slf4j
@Component
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public record TokenServiceResponse(
) {

public static TokenServiceResponse of(SmeemToken token) {
return new TokenServiceResponse(
token.getAccessToken(),
token.getRefreshToken()
);
return TokenServiceResponse.builder()
.accessToken(token.getAccessToken())
.refreshToken(token.getRefreshToken())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.smeem.api.badge.controller;

import com.smeem.api.badge.controller.dto.response.BadgeListResponse;
import com.smeem.api.badge.service.BadgeService;
import com.smeem.api.common.ApiResponseUtil;
import com.smeem.api.common.BaseResponse;
import com.smeem.common.util.Util;
import lombok.RequiredArgsConstructor;
import lombok.val;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -24,7 +24,7 @@ public class BadgeController {

@GetMapping
public ResponseEntity<BaseResponse<?>> getBadges(Principal principal) {
BadgeListResponse response = badgeService.getBadges(Util.getMemberId(principal));
val response = badgeService.getBadges(Util.getMemberId(principal));
return ApiResponseUtil.success(SUCCESS_GET_BADGES, response);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.smeem.api.badge.controller.dto.response;

import com.smeem.api.badge.service.dto.response.BadgeServiceResponse;
import com.smeem.domain.badge.model.Badge;
import lombok.AccessLevel;
import lombok.Builder;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package com.smeem.api.member.controller.dto.response;

import com.smeem.api.member.service.dto.response.MemberNameServiceResponse;
import lombok.AccessLevel;
import lombok.Builder;

import static lombok.AccessLevel.PRIVATE;

@Builder(access = PRIVATE)
public record MemberNameResponse(
boolean isExist
) {

public static MemberNameResponse of(MemberNameServiceResponse response) {
return new MemberNameResponse(response.isExist());
return MemberNameResponse.builder()
.isExist(response.isExist())
.build();
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
package com.smeem.api.member.controller.dto.response;

import com.smeem.api.member.service.dto.response.TrainingTimeServiceResponse;
import lombok.Builder;

public record TrainingTimeResponse(String day, int hour, int minute) {
import static lombok.AccessLevel.PRIVATE;

@Builder(access = PRIVATE)
public record TrainingTimeResponse(
String day,
int hour,
int minute
) {
public static TrainingTimeResponse of(TrainingTimeServiceResponse response) {
return new TrainingTimeResponse(
response.day(),
response.hour(),
response.minute());
return TrainingTimeResponse.builder()
.day(response.day())
.hour(response.hour())
.minute(response.minute())
.build();
}
}
Loading