Skip to content

Commit

Permalink
[CHORE] : 코드 정렬 및 주석제거 (#75)
Browse files Browse the repository at this point in the history
## ☀️ 작업 사항
- 코드 정렬했습니다.

## ☀️ 참고 사항

- 이 후 작업 내용은 정렬되어서 올라올 예정입니다
  • Loading branch information
05AM authored Nov 5, 2023
2 parents e06809a + f3af721 commit 5be7101
Show file tree
Hide file tree
Showing 52 changed files with 220 additions and 218 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ public interface AlarmRepository extends JpaRepository<Alarm, Integer> {
Optional<Alarm> findByInvitationCode(@Param("invitationCode") String invitationCode);



}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
@Tag(name = "Auth(로그인)",description = "로그인 및 유저의 권한 인증")

@Tag(name = "Auth(로그인)", description = "로그인 및 유저의 권한 인증")
@RestController
@RequiredArgsConstructor
@RequestMapping("/app/auth")
Expand All @@ -21,14 +22,13 @@ public class AuthController {
@PostMapping("/login")
public BaseResponse<LoginRes> join(@RequestBody SocialLoginReq loginReq) {

LoginRes loginRes = authService.socialLogin(loginReq);
LoginRes loginRes = authService.socialLogin(loginReq);

return new BaseResponse<>(Status.SUCCESS_CREATED,loginRes);
return new BaseResponse<>(Status.SUCCESS_CREATED, loginRes);

}



}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public boolean supportsParameter(MethodParameter parameter) {
}

@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) {
if(webRequest.getHeader("Authorization")==null)
throw new BaseException(Status.UNAUTHORIZED);
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) {
if (webRequest.getHeader("Authorization") == null)
throw new BaseException(Status.UNAUTHORIZED);
String jwt = webRequest.getHeader("Authorization").replace("Bearer", "").trim();
if(jwt.isEmpty())
if (jwt.isEmpty())
throw new BaseException(Status.UNAUTHORIZED);

return jwtService.getUserId(jwt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public boolean isValid(Claims claims) {
return claims.getIssuer().contains(iss) &&
claims.getAudience().equals(clientId);
// claims.get(NONCE_KEY, String.class).equals(nonce);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public interface AppleClient {
@GetMapping("/keys")
ApplePublicKeys getApplePublicKeys();

@PostMapping(value = "/token",consumes = "application/x-www-form-urlencoded")
@PostMapping(value = "/token", consumes = "application/x-www-form-urlencoded")
AppleTokenRes findAppleToken(@RequestBody AppleTokenReq req);

@PostMapping(value = "/revoke",consumes = "application/x-www-form-urlencoded")
@PostMapping(value = "/revoke", consumes = "application/x-www-form-urlencoded")
void revoke(AppleRevokeReq req);
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.wakeUpTogetUp.togetUp.api.auth.apple;



import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.wakeUpTogetUp.togetUp.common.Status;
import com.wakeUpTogetUp.togetUp.exception.BaseException;
import io.jsonwebtoken.*;

import java.security.PublicKey;
import java.util.Map;

import org.springframework.stereotype.Component;
import org.springframework.util.Base64Utils;

Expand All @@ -26,8 +27,8 @@ public Map<String, String> parseHeaders(String identityToken) {
String decodedHeader = new String(Base64Utils.decodeFromUrlSafeString(encodedHeader));
return OBJECT_MAPPER.readValue(decodedHeader, Map.class);
} catch (JsonProcessingException | ArrayIndexOutOfBoundsException e) {
// throw new InvalidTokenException("Apple OAuth Identity Token 형식이 올바르지 않습니다.");
throw new BaseException(Status.UNAUTHORIZED); //todo 에러 바꾸기
// throw new InvalidTokenException("Apple OAuth Identity Token 형식이 올바르지 않습니다.");
throw new BaseException(Status.UNAUTHORIZED); //todo 에러 바꾸기
}
}

Expand All @@ -39,11 +40,11 @@ public Claims parsePublicKeyAndGetClaims(String idToken, PublicKey publicKey) {
.getBody();
} catch (ExpiredJwtException e) {
//throw new TokenExpiredException("Apple OAuth 로그인 중 Identity Token 유효기간이 만료됐습니다.");
throw new BaseException(Status.UNAUTHORIZED); //todo 에러 바꾸기
throw new BaseException(Status.UNAUTHORIZED); //todo 에러 바꾸기

} catch (UnsupportedJwtException | MalformedJwtException | SignatureException | IllegalArgumentException e) {
//throw new InvalidTokenException("Apple OAuth Identity Token 값이 올바르지 않습니다.");
throw new BaseException(Status.UNAUTHORIZED); //todo 에러 바꾸기
throw new BaseException(Status.UNAUTHORIZED); //todo 에러 바꾸기

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import java.util.List;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.security.spec.InvalidKeySpecException;
import java.security.spec.RSAPublicKeySpec;
import java.util.Map;

import org.springframework.stereotype.Component;
import org.springframework.util.Base64Utils;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.wakeUpTogetUp.togetUp.api.auth.dto.request;



import com.wakeUpTogetUp.togetUp.api.auth.LoginType;
import lombok.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.wakeUpTogetUp.togetUp.api.auth.dto.request;



import com.wakeUpTogetUp.togetUp.api.auth.LoginType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
Expand All @@ -16,14 +15,14 @@
public class SocialLoginReq {

@NotNull
@Schema( description = "로그인 플랫폼 엑세스 토큰",requiredMode = Schema.RequiredMode.REQUIRED ,example = "asjdfadjkfasdfafafadsfdfaf")
@Schema(description = "로그인 플랫폼 엑세스 토큰", requiredMode = Schema.RequiredMode.REQUIRED, example = "asjdfadjkfasdfafafadsfdfaf")
private String oauthAccessToken;

@NotNull
@Schema( description = "로그인 타입",requiredMode = Schema.RequiredMode.REQUIRED ,example = "KAKAO")
@Schema(description = "로그인 타입", requiredMode = Schema.RequiredMode.REQUIRED, example = "KAKAO")
private LoginType loginType;

@Schema( description = "유저이름",requiredMode = Schema.RequiredMode.NOT_REQUIRED ,example = "조혜온")
@Schema(description = "유저이름", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "조혜온")
private String userName;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public static class KakaoLoginData {
private KakaoProfile profile = KakaoProfile.builder().build();
@Builder.Default
private KakaoPropery properties = KakaoPropery.builder().build();

@Builder
@Data
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public class LoginRes {
private Integer userId;
private String userName;
private String email;
private String accessToken;
private String accessToken;

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import java.util.Map;

@FeignClient(value = "kakaoUser", url="https://kapi.kakao.com", configuration = {FeignConfig.class})
@FeignClient(value = "kakaoUser", url = "https://kapi.kakao.com", configuration = {FeignConfig.class})
public interface KakaoUserApi {
@GetMapping("/v2/user/me")
ResponseEntity<String> getUserInfo(@RequestHeader Map<String, String> header);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class AppleLoginServiceImpl implements SocialLoginService {
private String iss;
@Value("${oauth.apple.key-id}")
private String keyId;

@Override
public LoginType getServiceName() {
return LoginType.APPLE;
Expand All @@ -86,10 +87,11 @@ public SocialUserRes getUserInfo(String accessToken) {

private void validateClaims(Claims claims) {
if (!appleClaimsValidator.isValid(claims)) {
throw new BaseException(Status.Invalid_APPLE_Token);
throw new BaseException(Status.Invalid_APPLE_Token);

}
}

public AppleTokenRes getAppleToken(String authorizationCode) throws IOException {

AppleTokenReq appleTokenReq = AppleTokenReq.builder()
Expand All @@ -102,8 +104,7 @@ public AppleTokenRes getAppleToken(String authorizationCode) throws IOException
return appleClient.findAppleToken(appleTokenReq);
}

public String createClientSecret() throws IOException{

public String createClientSecret() throws IOException {


Date expirationDate = Date.from(LocalDateTime.now().plusDays(30).atZone(ZoneId.systemDefault()).toInstant());
Expand Down Expand Up @@ -136,20 +137,19 @@ private PrivateKey getPrivateKey() throws IOException {
}


public void revoke (String accessToken) throws IOException {
try {
AppleRevokeReq appleRevokeReq = AppleRevokeReq.builder()
.client_id(clientId)
.client_secret(this.createClientSecret())
.token(accessToken)
.token_type_hint("access_token")
.build();
appleClient.revoke(appleRevokeReq);
} catch (HttpClientErrorException e) {
throw new RuntimeException("Apple Revoke Error");
}
public void revoke(String accessToken) throws IOException {
try {
AppleRevokeReq appleRevokeReq = AppleRevokeReq.builder()
.client_id(clientId)
.client_secret(this.createClientSecret())
.token(accessToken)
.token_type_hint("access_token")
.build();
appleClient.revoke(appleRevokeReq);
} catch (HttpClientErrorException e) {
throw new RuntimeException("Apple Revoke Error");
}
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.io.IOException;
import java.util.List;
import java.util.Objects;

import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public LoginType getServiceName() {

@Override
public SocialUserRes getUserInfo(String accessToken) {
Map<String ,String> headerMap = new HashMap<>();
Map<String, String> headerMap = new HashMap<>();
headerMap.put("authorization", "Bearer " + accessToken);

ResponseEntity<?> response =null;
ResponseEntity<?> response = null;
try {
response = kakaoUserApi.getUserInfo(headerMap);
}catch (Exception e){
} catch (Exception e) {
throw new BaseException(Status.UNAUTHORIZED_KAKAO_TOKEN);
}
String jsonString = response.getBody().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
@Service
public interface SocialLoginService {
LoginType getServiceName();

SocialUserRes getUserInfo(String accessToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
import lombok.Setter;

import javax.persistence.*;

import org.hibernate.annotations.DynamicInsert;

@Setter
@Getter
@Entity
@Table(name="avatar")
@Table(name = "avatar")
@DynamicInsert
@NoArgsConstructor
public class Avatar {
Expand All @@ -34,9 +35,4 @@ public class Avatar {
@Column(columnDefinition = "TIMESTAMP")
private String createdAt;

// @PrePersist
// void createdAt() {
// this.createdAt = Timestamp.from(Instant.now());
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class DevController {
public BaseResponse<List<User>> user() {


return new BaseResponse<>(Status.SUCCESS,devService.get());
return new BaseResponse<>(Status.SUCCESS, devService.get());

}

Expand All @@ -40,10 +40,9 @@ public BaseResponse<String> join(@Parameter(description = "jwt 받고 싶은 유

String jwt = devService.devGetJwt(userId);

return new BaseResponse<>(Status.SUCCESS,jwt);
return new BaseResponse<>(Status.SUCCESS, jwt);

}



}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public class DevService {

private final UserRepository userRepository;
private final JwtService jwtService;
public List<User> get()
{

public List<User> get() {
return userRepository.findAll();
}


public String devGetJwt(Integer userId) {
public String devGetJwt(Integer userId) {

//accessToken 만들기
String accessToken = jwtService.generateAccessToken(userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class FileController {

/**
* upload 메소드
*
* @param type
* @return
* @throws Exception
Expand All @@ -33,6 +34,7 @@ public BaseResponse<PostFileRes> uploadFiles(

/**
* 파일 삭제
*
* @param name
* @return
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public String uploadFile(MultipartFile file, String type) throws Exception {

@Transactional
public String uploadMissionImage(MultipartFile file, ImageDrawResult imageDrawResult,
String type) throws Exception {
String type) throws Exception {
if (type.equals("mission")) {
String uploadFilePath = ("mission/" + getFolderName());
return uploadToBucket(file, uploadFilePath, imageDrawResult);
Expand Down Expand Up @@ -90,7 +90,7 @@ public String uploadToBucket(MultipartFile file, String uploadFilePath) throws E
}

public String uploadToBucket(MultipartFile file, String uploadFilePath,
ImageDrawResult imageDrawResult) throws Exception {
ImageDrawResult imageDrawResult) throws Exception {
// 파일 이름
String uploadFileName = getUuidFileName(file.getName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.NoArgsConstructor;

import java.util.List;

@Getter
@NoArgsConstructor
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.wakeUpTogetUp.togetUp.api.mission.model.MissionObject;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface MissionObjectRepository extends JpaRepository<MissionObject, Integer> {

Expand Down
Loading

0 comments on commit 5be7101

Please sign in to comment.