From f3af721367165ba74b195a8c87de6875c4f7dc7e Mon Sep 17 00:00:00 2001 From: hye-on Date: Sun, 5 Nov 2023 10:29:30 +0900 Subject: [PATCH] =?UTF-8?q?[CHORE]=20:=20=EC=BD=94=EB=93=9C=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=20=EB=B0=8F=20=EC=A3=BC=EC=84=9D=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../togetUp/api/alarm/AlarmRepository.java | 1 - .../togetUp/api/auth/AuthController.java | 8 +-- .../togetUp/api/auth/AuthUserResolver.java | 8 +-- .../api/auth/apple/AppleClaimsValidator.java | 2 +- .../togetUp/api/auth/apple/AppleClient.java | 4 +- .../api/auth/apple/AppleJwtParser.java | 11 ++-- .../api/auth/apple/ApplePublicKeys.java | 1 + .../api/auth/apple/PublicKeyGenerator.java | 1 + .../api/auth/dto/request/AppleLoginReq.java | 1 - .../api/auth/dto/request/SocialLoginReq.java | 7 +-- .../api/auth/dto/response/KakaoLoginRes.java | 1 + .../api/auth/dto/response/LoginRes.java | 2 +- .../togetUp/api/auth/kakao/KakaoUserApi.java | 2 +- .../auth/service/AppleLoginServiceImpl.java | 32 +++++----- .../togetUp/api/auth/service/AuthService.java | 1 + .../auth/service/KakaoLoginServiceImpl.java | 6 +- .../api/auth/service/SocialLoginService.java | 1 + .../togetUp/api/avatar/model/Avatar.java | 8 +-- .../togetUp/api/dev/DevController.java | 5 +- .../togetUp/api/dev/DevService.java | 6 +- .../togetUp/api/file/FileController.java | 2 + .../togetUp/api/file/FileService.java | 4 +- .../api/file/dto/response/PostFileRes.java | 1 + .../api/mission/MissionObjectRepository.java | 1 + .../togetUp/api/mission/domain/Letterbox.java | 3 +- .../togetUp/api/mission/domain/ODResult.java | 1 + .../mission/domain/ObjectDetectionModel.java | 6 -- .../dto/request/MissionLogCreateReq.java | 2 + .../togetUp/api/room/RoomController.java | 63 +++++++++---------- .../togetUp/api/room/RoomUserRepository.java | 23 +++---- .../togetUp/api/room/dto/request/RoomReq.java | 4 +- .../dto/request/RoomUserLogMissionReq.java | 7 +-- .../api/room/dto/response/RoomDetailRes.java | 22 +++---- .../api/room/dto/response/RoomInfoRes.java | 15 +++-- .../api/room/dto/response/RoomRes.java | 10 +-- .../dto/response/RoomUserMissionLogRes.java | 18 +++--- .../togetUp/api/room/model/Room.java | 18 +++--- .../togetUp/api/room/model/RoomUser.java | 5 +- .../api/users/UserAvatarRepository.java | 5 +- .../togetUp/api/users/UserAvatarService.java | 2 + .../togetUp/api/users/UserController.java | 26 ++++---- .../togetUp/api/users/UserService.java | 2 + .../api/users/dto/response/UserRes.java | 2 +- .../togetUp/api/users/fcmToken/FcmToken.java | 3 +- .../users/fcmToken/FcmTokenRepository.java | 1 - .../togetUp/api/users/model/User.java | 2 + .../togetUp/api/users/model/UserAvatar.java | 2 + .../api/users/vo/UserProgressionResult.java | 2 +- .../togetUp/common/Constant.java | 16 ++--- .../togetUp/common/dto/BaseResponse.java | 2 +- .../togetUp/utils/JwtService.java | 23 ++++--- .../togetUp/utils/TimeFormatter.java | 37 +++++------ 52 files changed, 220 insertions(+), 218 deletions(-) diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/alarm/AlarmRepository.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/alarm/AlarmRepository.java index 9e4cbd13..8895d3ca 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/alarm/AlarmRepository.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/alarm/AlarmRepository.java @@ -45,5 +45,4 @@ public interface AlarmRepository extends JpaRepository { Optional findByInvitationCode(@Param("invitationCode") String invitationCode); - } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/AuthController.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/AuthController.java index b3a9224d..966d0ca9 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/AuthController.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/AuthController.java @@ -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") @@ -21,14 +22,13 @@ public class AuthController { @PostMapping("/login") public BaseResponse 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); } - } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/AuthUserResolver.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/AuthUserResolver.java index e1b4a21e..012e305f 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/AuthUserResolver.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/AuthUserResolver.java @@ -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); diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/AppleClaimsValidator.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/AppleClaimsValidator.java index 00052d22..069ea87d 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/AppleClaimsValidator.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/AppleClaimsValidator.java @@ -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); - } + } } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/AppleClient.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/AppleClient.java index db015572..7d659425 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/AppleClient.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/AppleClient.java @@ -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); } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/AppleJwtParser.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/AppleJwtParser.java index 26fd9ca2..8129afe3 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/AppleJwtParser.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/AppleJwtParser.java @@ -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; @@ -26,8 +27,8 @@ public Map 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 에러 바꾸기 } } @@ -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 에러 바꾸기 } } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/ApplePublicKeys.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/ApplePublicKeys.java index 379bbcce..089f3b32 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/ApplePublicKeys.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/ApplePublicKeys.java @@ -2,6 +2,7 @@ import java.util.List; + import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/PublicKeyGenerator.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/PublicKeyGenerator.java index dd550146..b7db356b 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/PublicKeyGenerator.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/apple/PublicKeyGenerator.java @@ -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; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/dto/request/AppleLoginReq.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/dto/request/AppleLoginReq.java index 7c27c1fc..fa5ed59d 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/dto/request/AppleLoginReq.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/dto/request/AppleLoginReq.java @@ -1,7 +1,6 @@ package com.wakeUpTogetUp.togetUp.api.auth.dto.request; - import com.wakeUpTogetUp.togetUp.api.auth.LoginType; import lombok.*; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/dto/request/SocialLoginReq.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/dto/request/SocialLoginReq.java index a3f1ad0b..af919ddb 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/dto/request/SocialLoginReq.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/dto/request/SocialLoginReq.java @@ -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.*; @@ -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; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/dto/response/KakaoLoginRes.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/dto/response/KakaoLoginRes.java index f3bc1fcd..54f109b2 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/dto/response/KakaoLoginRes.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/dto/response/KakaoLoginRes.java @@ -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 diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/dto/response/LoginRes.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/dto/response/LoginRes.java index 1108d155..7ec3be16 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/dto/response/LoginRes.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/dto/response/LoginRes.java @@ -12,6 +12,6 @@ public class LoginRes { private Integer userId; private String userName; private String email; - private String accessToken; + private String accessToken; } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/kakao/KakaoUserApi.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/kakao/KakaoUserApi.java index bf109c80..18abb24f 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/kakao/KakaoUserApi.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/kakao/KakaoUserApi.java @@ -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 getUserInfo(@RequestHeader Map header); diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/service/AppleLoginServiceImpl.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/service/AppleLoginServiceImpl.java index fc6814be..569a5977 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/service/AppleLoginServiceImpl.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/service/AppleLoginServiceImpl.java @@ -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; @@ -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() @@ -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()); @@ -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"); + } } - } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/service/AuthService.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/service/AuthService.java index 72e2a223..e919ac82 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/service/AuthService.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/service/AuthService.java @@ -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; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/service/KakaoLoginServiceImpl.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/service/KakaoLoginServiceImpl.java index 9ecdbd4c..0deacfb3 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/service/KakaoLoginServiceImpl.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/service/KakaoLoginServiceImpl.java @@ -33,13 +33,13 @@ public LoginType getServiceName() { @Override public SocialUserRes getUserInfo(String accessToken) { - Map headerMap = new HashMap<>(); + Map 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(); diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/service/SocialLoginService.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/service/SocialLoginService.java index cb7eca65..513c717d 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/service/SocialLoginService.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/auth/service/SocialLoginService.java @@ -8,5 +8,6 @@ @Service public interface SocialLoginService { LoginType getServiceName(); + SocialUserRes getUserInfo(String accessToken); } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/avatar/model/Avatar.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/avatar/model/Avatar.java index 1791a8cd..341b858a 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/avatar/model/Avatar.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/avatar/model/Avatar.java @@ -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 { @@ -34,9 +35,4 @@ public class Avatar { @Column(columnDefinition = "TIMESTAMP") private String createdAt; -// @PrePersist -// void createdAt() { -// this.createdAt = Timestamp.from(Instant.now()); -// } - } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/dev/DevController.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/dev/DevController.java index ea5514a0..30f8d467 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/dev/DevController.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/dev/DevController.java @@ -29,7 +29,7 @@ public class DevController { public BaseResponse> user() { - return new BaseResponse<>(Status.SUCCESS,devService.get()); + return new BaseResponse<>(Status.SUCCESS, devService.get()); } @@ -40,10 +40,9 @@ public BaseResponse join(@Parameter(description = "jwt 받고 싶은 유 String jwt = devService.devGetJwt(userId); - return new BaseResponse<>(Status.SUCCESS,jwt); + return new BaseResponse<>(Status.SUCCESS, jwt); } - } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/dev/DevService.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/dev/DevService.java index f28bcbea..b8f1248a 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/dev/DevService.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/dev/DevService.java @@ -15,13 +15,13 @@ public class DevService { private final UserRepository userRepository; private final JwtService jwtService; - public List get() - { + + public List get() { return userRepository.findAll(); } - public String devGetJwt(Integer userId) { + public String devGetJwt(Integer userId) { //accessToken 만들기 String accessToken = jwtService.generateAccessToken(userId); diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/file/FileController.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/file/FileController.java index 2d29c451..51744505 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/file/FileController.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/file/FileController.java @@ -18,6 +18,7 @@ public class FileController { /** * upload 메소드 + * * @param type * @return * @throws Exception @@ -33,6 +34,7 @@ public BaseResponse uploadFiles( /** * 파일 삭제 + * * @param name * @return */ diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/file/FileService.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/file/FileService.java index ba1f9087..63d1d516 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/file/FileService.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/file/FileService.java @@ -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); @@ -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()); diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/file/dto/response/PostFileRes.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/file/dto/response/PostFileRes.java index 55e1df64..5cc70fc0 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/file/dto/response/PostFileRes.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/file/dto/response/PostFileRes.java @@ -5,6 +5,7 @@ import lombok.NoArgsConstructor; import java.util.List; + @Getter @NoArgsConstructor @AllArgsConstructor diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/MissionObjectRepository.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/MissionObjectRepository.java index 8ed0c428..1ec4be00 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/MissionObjectRepository.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/MissionObjectRepository.java @@ -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 { diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/domain/Letterbox.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/domain/Letterbox.java index 7d32edfa..b5071a2e 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/domain/Letterbox.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/domain/Letterbox.java @@ -1,4 +1,5 @@ package com.wakeUpTogetUp.togetUp.api.mission.domain; + import org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.core.Size; @@ -9,7 +10,7 @@ public class Letterbox { private Size newShape = new Size(1280, 1280); - private double[] color = new double[]{114,114,114}; + private double[] color = new double[]{114, 114, 114}; private Boolean auto = false; private Boolean scaleUp = false; private Integer stride = 32; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/domain/ODResult.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/domain/ODResult.java index d447bf5d..a77ad331 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/domain/ODResult.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/domain/ODResult.java @@ -1,4 +1,5 @@ package com.wakeUpTogetUp.togetUp.api.mission.domain; + import java.text.DecimalFormat; public class ODResult { diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/domain/ObjectDetectionModel.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/domain/ObjectDetectionModel.java index 5bfb224f..16245a9e 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/domain/ObjectDetectionModel.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/domain/ObjectDetectionModel.java @@ -19,10 +19,4 @@ public class ObjectDetectionModel { @Value("${my.path.model-path}") private String modelPath; -// @PostConstruct -// public void init() throws OrtException { -// environment = OrtEnvironment.getEnvironment(); -// sessionOptions = new OrtSession.SessionOptions(); -// session = environment.createSession(modelPath, sessionOptions); -// } } \ No newline at end of file diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/dto/request/MissionLogCreateReq.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/dto/request/MissionLogCreateReq.java index baa25d26..3df68e31 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/dto/request/MissionLogCreateReq.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/mission/dto/request/MissionLogCreateReq.java @@ -1,8 +1,10 @@ package com.wakeUpTogetUp.togetUp.api.mission.dto.request; import io.swagger.v3.oas.annotations.media.Schema; + import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/RoomController.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/RoomController.java index f52a7353..b82c6e78 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/RoomController.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/RoomController.java @@ -33,15 +33,15 @@ public class RoomController { private final RoomService roomService; private final MissionLogRepository missionLogRepository; - @Operation(summary= "그룹과 그룹 알람 생성") + @Operation(summary = "그룹과 그룹 알람 생성") @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "생성 되었습니다."), @ApiResponse(responseCode = "404", description = "존재하지 않는 유저 입니다.")}) @ResponseBody @PostMapping() // - public BaseResponse create(@Parameter(hidden = true) @AuthUser Integer userId, @RequestBody RoomReq roomReq ) { + public BaseResponse create(@Parameter(hidden = true) @AuthUser Integer userId, @RequestBody RoomReq roomReq) { - roomService.createRoom(userId,roomReq); + roomService.createRoom(userId, roomReq); return new BaseResponse(Status.SUCCESS_CREATED); } @@ -52,26 +52,26 @@ public BaseResponse create(@Parameter(hidden = true) @AuthUser Integer u )}) @Operation(summary = "그룹 리스트 불러오기") @GetMapping() - public BaseResponse> getList(@Parameter(hidden = true) @AuthUser Integer userId ) { + public BaseResponse> getList(@Parameter(hidden = true) @AuthUser Integer userId) { - return new BaseResponse(Status.SUCCESS,roomService.getRoomList(userId)); + return new BaseResponse(Status.SUCCESS, roomService.getRoomList(userId)); } @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "요청에 성공하였습니다.", content = @Content(schema = @Schema(implementation = RoomUserMissionLogRes.class))), - }) - @Operation(summary = "그룹게시판의 미션기록 불러오기",description = "그룹의 멤버의 미션기록 보기") + }) + @Operation(summary = "그룹게시판의 미션기록 불러오기", description = "그룹의 멤버의 미션기록 보기") @GetMapping("/user/mission-log") public BaseResponse getRoomLogDetailByDate(@Parameter(hidden = true) @AuthUser Integer userId, - @Parameter(description = "룸 아이디",example = "1") Integer roomId, - @Parameter(description = "기록을 가져올 날의 LocalDateTime String 값" , example = "2023-09-20 11:55:38") String localDateTime - ) { + @Parameter(description = "룸 아이디", example = "1") Integer roomId, + @Parameter(description = "기록을 가져올 날의 LocalDateTime String 값", example = "2023-09-20 11:55:38") String localDateTime + ) { - return new BaseResponse(Status.SUCCESS,roomService.getRoomUserLogList(userId,roomId,localDateTime)); + return new BaseResponse(Status.SUCCESS, roomService.getRoomUserLogList(userId, roomId, localDateTime)); } @@ -79,85 +79,82 @@ public BaseResponse getRoomLogDetailByDate(@Parameter(hid @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "요청에 성공하였습니다."), @ApiResponse(responseCode = "404", description = "그룹의 멤버가 없습니다."), - @ApiResponse(responseCode = "404",description = "존재하지 않는 알람입니다.") + @ApiResponse(responseCode = "404", description = "존재하지 않는 알람입니다.") }) @DeleteMapping("{roomId}/member") - public BaseResponse leaveRoom(@Parameter(hidden = true) @AuthUser Integer userId ,@PathVariable Integer roomId ) { + public BaseResponse leaveRoom(@Parameter(hidden = true) @AuthUser Integer userId, @PathVariable Integer roomId) { - roomService.leaveRoom(roomId,userId); + roomService.leaveRoom(roomId, userId); return new BaseResponse(Status.SUCCESS); } - @Operation(summary= "방장 변경하기") + @Operation(summary = "방장 변경하기") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "요청에 성공하였습니다."), @ApiResponse(responseCode = "400", description = "방장의 id가 아닙니다.")}) @ResponseBody @PostMapping("/{roomId}/host/{selectedUserId}") - public BaseResponse changeRoomHost(@Parameter(hidden = true) @AuthUser Integer userId, @PathVariable Integer roomId,@Parameter Integer selectedUserId) { + public BaseResponse changeRoomHost(@Parameter(hidden = true) @AuthUser Integer userId, @PathVariable Integer roomId, @Parameter Integer selectedUserId) { - roomService.changeRoomHost(roomId,userId,selectedUserId); + roomService.changeRoomHost(roomId, userId, selectedUserId); return new BaseResponse(Status.SUCCESS); } - @Operation(summary = "그룹 디테일 보기 ",description = "그룹 디테일 보기 (설정 화면)") + @Operation(summary = "그룹 디테일 보기 ", description = "그룹 디테일 보기 (설정 화면)") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "요청에 성공하였습니다.", content = @Content(schema = @Schema(implementation = RoomDetailRes.class))), - @ApiResponse(responseCode = "404",description = "존재하지 않는 알람입니다.")}) + @ApiResponse(responseCode = "404", description = "존재하지 않는 알람입니다.")}) @GetMapping("/{roomId}") - public BaseResponse getRoomDetail(@Parameter(hidden = true) @AuthUser Integer userId,@PathVariable Integer roomId) { + public BaseResponse getRoomDetail(@Parameter(hidden = true) @AuthUser Integer userId, @PathVariable Integer roomId) { - return new BaseResponse(Status.SUCCESS,roomService.getRoomDetail(roomId , userId)); + return new BaseResponse(Status.SUCCESS, roomService.getRoomDetail(roomId, userId)); } - @Operation(summary= "그룹 푸쉬 알림 설정") + @Operation(summary = "그룹 푸쉬 알림 설정") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "요청에 성공하였습니다."), @ApiResponse(responseCode = "404", description = "그룹의 멤버가 없습니다."),}) @ResponseBody @PostMapping("/user/push/{roomId}") - public BaseResponse updateAgreePush(@Parameter(hidden = true) @AuthUser Integer userId, @PathVariable Integer roomId,@Parameter(description = "알람동의 값",example = "true")@RequestParam() boolean agreePush) { + public BaseResponse updateAgreePush(@Parameter(hidden = true) @AuthUser Integer userId, @PathVariable Integer roomId, @Parameter(description = "알람동의 값", example = "true") @RequestParam() boolean agreePush) { - roomService.updateAgreePush(roomId,userId,agreePush); + roomService.updateAgreePush(roomId, userId, agreePush); return new BaseResponse(Status.SUCCESS); } - - @Operation(summary= "그룹에 참가") + @Operation(summary = "그룹에 참가") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "요청에 성공하였습니다.")}) @ResponseBody @PostMapping("/join/{roomId}") - public BaseResponse joinRoom(@Parameter(hidden = true) @AuthUser Integer invitedUserId , @PathVariable Integer roomId) { + public BaseResponse joinRoom(@Parameter(hidden = true) @AuthUser Integer invitedUserId, @PathVariable Integer roomId) { - roomService.joinRoom(roomId,invitedUserId,false); + roomService.joinRoom(roomId, invitedUserId, false); return new BaseResponse(Status.SUCCESS); } - @Operation(summary = "초대 받은 사람에게 보이는 그룹 정보 보기 ",description = "초대 받은 사람에게 보이는 앱 내 페이지") + @Operation(summary = "초대 받은 사람에게 보이는 그룹 정보 보기 ", description = "초대 받은 사람에게 보이는 앱 내 페이지") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "요청에 성공하였습니다.", content = @Content(schema = @Schema(implementation = RoomInfoRes.class))), - @ApiResponse(responseCode = "404" , description = "존재하지 않는 알람 입니다."), + @ApiResponse(responseCode = "404", description = "존재하지 않는 알람 입니다."), @ApiResponse(responseCode = "404", description = "존재하지 않는 룸입니다.") }) @GetMapping("/information") public BaseResponse getRoomIntro(@RequestParam() String invitationCode) { - return new BaseResponse(Status.SUCCESS,roomService.getRoomInformation(invitationCode)); + return new BaseResponse(Status.SUCCESS, roomService.getRoomInformation(invitationCode)); } - - } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/RoomUserRepository.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/RoomUserRepository.java index f0a4d58c..831eb5ca 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/RoomUserRepository.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/RoomUserRepository.java @@ -16,14 +16,14 @@ public interface RoomUserRepository extends JpaRepository { List findByUserId(Integer userId); @Query("SELECT ru FROM RoomUser ru " + - "JOIN User u ON (ru.user.id = u.id) " + - "WHERE ru.room.id = :roomId " + - "ORDER BY " + - "CASE WHEN ru.user.id = :userId THEN 0 " + - "WHEN ru.isHost = true THEN 1 " + - "ELSE 2 " + - "END, u.name") - List findAllByRoom_IdOrderByPreference(Integer roomId ,Integer userId); + "JOIN User u ON (ru.user.id = u.id) " + + "WHERE ru.room.id = :roomId " + + "ORDER BY " + + "CASE WHEN ru.user.id = :userId THEN 0 " + + "WHEN ru.isHost = true THEN 1 " + + "ELSE 2 " + + "END, u.name") + List findAllByRoom_IdOrderByPreference(Integer roomId, Integer userId); @Query("SELECT ru.room.id " + @@ -35,15 +35,16 @@ public interface RoomUserRepository extends JpaRepository { Integer countByUserId(Integer userId); Integer countByRoomId(Integer roomId); + void deleteByUserId(Integer userId); - Optional findByRoom_IdAndUser_Id(Integer roomId , Integer userId); + Optional findByRoom_IdAndUser_Id(Integer roomId, Integer userId); - Boolean existsRoomUserByRoom_IdAndUser_Id(Integer roomId , Integer userId); + Boolean existsRoomUserByRoom_IdAndUser_Id(Integer roomId, Integer userId); void deleteByRoom_IdAndUser_Id(Integer roomId, Integer userId); - List findAllByRoom_IdOrderByCreatedAt(Integer roomId); + List findAllByRoom_IdOrderByCreatedAt(Integer roomId); } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/request/RoomReq.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/request/RoomReq.java index aa177f93..02df49f5 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/request/RoomReq.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/request/RoomReq.java @@ -16,11 +16,11 @@ @Data public class RoomReq { - @Schema( description = "룸 이름",requiredMode = Schema.RequiredMode.REQUIRED ,example = "일찍 일어나는 새들의 방") + @Schema(description = "룸 이름", requiredMode = Schema.RequiredMode.REQUIRED, example = "일찍 일어나는 새들의 방") @NotBlank(message = "룸 이름은 공백일 수 없습니다.") private String name; - @Schema( description = "룸 설명", example = "설여대 소융이들의 방입니다.") + @Schema(description = "룸 설명", example = "설여대 소융이들의 방입니다.") private String intro; @NotBlank(message = "룸의 알람은 공백일 수 없습니다.") diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/request/RoomUserLogMissionReq.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/request/RoomUserLogMissionReq.java index efcf0d02..e95957e8 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/request/RoomUserLogMissionReq.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/request/RoomUserLogMissionReq.java @@ -15,19 +15,18 @@ @NoArgsConstructor public class RoomUserLogMissionReq { - @Schema( description = "룸 id",requiredMode = Schema.RequiredMode.REQUIRED ,example = "1") + @Schema(description = "룸 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @NotBlank(message = "룸 id는 공백일 수 없습니다.") Integer roomId; - @Schema(description = "기록을 가져올 날의 LocalDateTime ",requiredMode = Schema.RequiredMode.REQUIRED ,example ="2023-09-20 11:55:38") + @Schema(description = "기록을 가져올 날의 LocalDateTime ", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-09-20 11:55:38") @NotBlank(message = "기록 시간은 공백일 수 없습니다.") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime localDateTime; - @Schema(description = "알람이 울리는 날인지 여부",requiredMode = Schema.RequiredMode.REQUIRED,example = "true") + @Schema(description = "알람이 울리는 날인지 여부", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") @NotBlank(message = "알람이 울리는 날인지 여부는 공백일 수 없습니다.") Boolean isAlarmActive; - } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomDetailRes.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomDetailRes.java index baf75022..c42646e8 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomDetailRes.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomDetailRes.java @@ -21,26 +21,27 @@ public class RoomDetailRes { @Schema(description = "룸의 유저들 정보 리스트") private List userList; + @Builder @Data public static class RoomData { - @Schema( description = "룸이 가지고 있는 알람의 아이콘",example = "⏰") + @Schema(description = "룸이 가지고 있는 알람의 아이콘", example = "⏰") private String icon; @Schema(description = "room name", example = "설여대 기상방") private String name; - @Schema(description = "room 소개",example = "소프트웨어융학학과 기상방입니다.") + @Schema(description = "room 소개", example = "소프트웨어융학학과 기상방입니다.") private String intro; - @Schema(description = "room 개설일",example = "2020.02.03") + @Schema(description = "room 개설일", example = "2020.02.03") private String createdAt; - @Schema(description = "함께하는 인원수",example = "6") + @Schema(description = "함께하는 인원수", example = "6") private Integer personnel; - @Schema(description = "룸 초대코드" ,example = "4c905") + @Schema(description = "룸 초대코드", example = "4c905") private String invitationCode; @@ -50,23 +51,22 @@ public static class RoomData { @Data public static class AlarmData { - @Schema(description = "룸에서 울리는 알람아이디",example = "2") + @Schema(description = "룸에서 울리는 알람아이디", example = "2") private Integer id; - @Schema(description = "미션의 한국말",example = "자동차") + @Schema(description = "미션의 한국말", example = "자동차") private String missionKr; @Schema(description = "알람 시간", example = "pm 13:00") private String alarmTime; - @Schema(description = "그룹알람 울리는 날",example = "주중") + @Schema(description = "그룹알람 울리는 날", example = "주중") private String alarmDay; } - @Builder @Data public static class UserData { @@ -77,10 +77,10 @@ public static class UserData { @Schema(description = "유저 이름", example = "조혜온") private String userName; - @Schema(description = "- 신입 병아리 \n - 눈을 반짝이는 곰돌이 \n - 깜찍한 토끼" ,example = "신입 병아리") + @Schema(description = "- 신입 병아리 \n - 눈을 반짝이는 곰돌이 \n - 깜찍한 토끼", example = "신입 병아리") private String theme; - @Schema(description = "유저의 레벨" , example = "1") + @Schema(description = "유저의 레벨", example = "1") private Integer level; @Schema(description = "방장인지 여부", example = "true") diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomInfoRes.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomInfoRes.java index 58aaa2bb..e5df98ad 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomInfoRes.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomInfoRes.java @@ -22,39 +22,38 @@ public class RoomInfoRes { @Data public static class RoomData { - @Schema(description = "룸아이디" ,example = "1") + @Schema(description = "룸아이디", example = "1") private Integer id; - @Schema( description = "룸이 가지고 있는 알람의 아이콘",example = "⏰") + @Schema(description = "룸이 가지고 있는 알람의 아이콘", example = "⏰") private String icon; @Schema(description = "room name", example = "설여대 기상방") private String name; - @Schema(description = "room 소개",example = "소프트웨어융학학과 기상방입니다.") + @Schema(description = "room 소개", example = "소프트웨어융학학과 기상방입니다.") private String intro; - @Schema(description = "room 개설일",example = "2020.02.03") + @Schema(description = "room 개설일", example = "2020.02.03") private String createdAt; - @Schema(description = "함께하는 인원수",example = "6") + @Schema(description = "함께하는 인원수", example = "6") private Integer personnel; - } @Builder @Data public static class AlarmData { - @Schema(description = "미션의 한국말",example = "자동차") + @Schema(description = "미션의 한국말", example = "자동차") private String missionKr; @Schema(description = "알람 시간", example = "pm 13:00") private String alarmTime; - @Schema(description = "그룹알람 울리는 날",example = "주중") + @Schema(description = "그룹알람 울리는 날", example = "주중") private String alarmDay; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomRes.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomRes.java index 0cfa33d3..4de98484 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomRes.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomRes.java @@ -12,19 +12,19 @@ @Builder public class RoomRes { - @Schema( description = "룸 id", example = "1") + @Schema(description = "룸 id", example = "1") private Integer roomId; - @Schema( description = "룸이 가지고 있는 알람의 아이콘", example = "⏰") + @Schema(description = "룸이 가지고 있는 알람의 아이콘", example = "⏰") private String icon; - @Schema( description = "룸 이름", example = "일찍 일어나는 새들의 방") + @Schema(description = "룸 이름", example = "일찍 일어나는 새들의 방") private String name; - @Schema( description = "룸이 가지고 있는 알람의 미션", example = "수저 찍기") + @Schema(description = "룸이 가지고 있는 알람의 미션", example = "수저 찍기") private String mission; - @Schema(description = "미션의 한국말",example = "자동차") + @Schema(description = "미션의 한국말", example = "자동차") private String kr; } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomUserMissionLogRes.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomUserMissionLogRes.java index ad4a6b27..1ca0472c 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomUserMissionLogRes.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomUserMissionLogRes.java @@ -4,6 +4,7 @@ import com.wakeUpTogetUp.togetUp.api.room.UserCompleteType; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; + import java.util.List; @@ -13,10 +14,10 @@ @NoArgsConstructor public class RoomUserMissionLogRes { - @Schema(description = "room name",example = "설여대 기상방") + @Schema(description = "room name", example = "설여대 기상방") private String name; - @Schema(description = "- 신입 병아리 \n - 눈을 반짝이는 곰돌이 \n - 깜찍한 토끼" ,example = "신입 병아리") + @Schema(description = "- 신입 병아리 \n - 눈을 반짝이는 곰돌이 \n - 깜찍한 토끼", example = "신입 병아리") private String theme; private List userLogList; @@ -24,26 +25,23 @@ public class RoomUserMissionLogRes { @Builder @Data public static class UserLogData { - @Schema(description = "유저 Id",example = "1") + @Schema(description = "유저 Id", example = "1") private Integer userId; - @Schema(description = "유저 이름",example = "조혜온") + @Schema(description = "유저 이름", example = "조혜온") private String userName; - @Schema(description = "나인지 다른 멤버인지 여부",example = "true") + @Schema(description = "나인지 다른 멤버인지 여부", example = "true") private Boolean isMyLog; - @Schema(description = "유저의 미션 수행 상태 (성공 SUCCESS, 실패 FAIL, 아직 수행 안함 WAITING, 수행하는 날 아님 NOT_MISSION)",example = "WAITING") + @Schema(description = "유저의 미션 수행 상태 (성공 SUCCESS, 실패 FAIL, 아직 수행 안함 WAITING, 수행하는 날 아님 NOT_MISSION)", example = "WAITING") private UserCompleteType userCompleteType; - @Schema(description = "미션 수행 사진",example = "http://~~~") + @Schema(description = "미션 수행 사진", example = "http://~~~") private String missionPicLink; } - - - } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/model/Room.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/model/Room.java index 60e686c8..4759296c 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/model/Room.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/model/Room.java @@ -28,13 +28,13 @@ public class Room { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id=null; + private Integer id = null; - @Column(name = "name",length = 10) + @Column(name = "name", length = 10) private String name; - @Column(name = "intro",length = 30) + @Column(name = "intro", length = 30) private String intro; @@ -43,12 +43,12 @@ public class Room { /** * todo uuid */ - @Column(name = "invitation_code",length = 10) + @Column(name = "invitation_code", length = 10) private String invitationCode; - // @JsonIgnore + // @JsonIgnore @OneToMany(mappedBy = "room") - private List roomUsers= new ArrayList<>(); + private List roomUsers = new ArrayList<>(); @Column(name = "created_at") @@ -75,12 +75,12 @@ public Room(Integer id, String name, String intro) { this.id = id; this.name = name; this.intro = intro; - this.topic = UUID.randomUUID().toString();; - this.invitationCode = UUID.randomUUID().toString().substring(0,Constant.INVITATION_CODE_LENGTH); + this.topic = UUID.randomUUID().toString(); + ; + this.invitationCode = UUID.randomUUID().toString().substring(0, Constant.INVITATION_CODE_LENGTH); } - } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/model/RoomUser.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/model/RoomUser.java index e908846a..10793f93 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/model/RoomUser.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/model/RoomUser.java @@ -7,6 +7,7 @@ import javax.persistence.*; import java.sql.Timestamp; import java.time.Instant; + @Entity @Table(name = "room_user") @Data @@ -17,7 +18,7 @@ public class RoomUser { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column( columnDefinition = "INT UNSIGNED") + @Column(columnDefinition = "INT UNSIGNED") private Integer id = null; @@ -30,7 +31,6 @@ public class RoomUser { private Room room; - @Column(name = "created_at") private Timestamp createdAt; @@ -52,5 +52,4 @@ public void setUser(User user) { } - } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/UserAvatarRepository.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/UserAvatarRepository.java index 3afc9165..1bb138ad 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/UserAvatarRepository.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/UserAvatarRepository.java @@ -1,17 +1,20 @@ package com.wakeUpTogetUp.togetUp.api.users; import com.wakeUpTogetUp.togetUp.api.users.model.UserAvatar; + import java.util.List; import java.util.Optional; + import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository public interface UserAvatarRepository extends JpaRepository { - UserAvatar findByUser_Id(Integer userId); Optional findByUser_IdAndAvatar_Id(int userId, int avatarId); + Optional findByUser_IdAndIsActiveIsTrue(int userId); + List findAllByUser_Id(Integer userId); } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/UserAvatarService.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/UserAvatarService.java index 8b7d85bc..3629883f 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/UserAvatarService.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/UserAvatarService.java @@ -8,7 +8,9 @@ import com.wakeUpTogetUp.togetUp.common.Status; import com.wakeUpTogetUp.togetUp.exception.BaseException; import com.wakeUpTogetUp.togetUp.utils.mapper.EntityDtoMapper; + import java.util.List; + import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/UserController.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/UserController.java index 07c6f892..9c300d7c 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/UserController.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/UserController.java @@ -8,7 +8,9 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; + import java.util.List; + import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; import io.swagger.v3.oas.annotations.Operation; @@ -21,7 +23,7 @@ @RestController @RequiredArgsConstructor @RequestMapping("/app/users") -public class UserController { +public class UserController { private final UserService userService; private final UserAvatarService userAvatarService; @@ -31,39 +33,39 @@ public class UserController { @ApiResponse(responseCode = "200", description = "요청에 성공하였습니다."), @ApiResponse(responseCode = "404", description = "존재하지 않는 유저 입니다.")}) @PatchMapping("/fcm-token") - public BaseResponse updateFcmToken(@Parameter(hidden = true) @AuthUser Integer userId, @Parameter(description = "디바이스토큰 id")@RequestParam( required = false) Integer fcmTokenId, @Parameter(description = "토큰값",required = true) @RequestParam String fcmToken){ - Integer updatedFcmTokenId =userService.updateFcmToken(userId,fcmTokenId,fcmToken); - return new BaseResponse<>(Status.SUCCESS,updatedFcmTokenId); + public BaseResponse updateFcmToken(@Parameter(hidden = true) @AuthUser Integer userId, @Parameter(description = "디바이스토큰 id") @RequestParam(required = false) Integer fcmTokenId, @Parameter(description = "토큰값", required = true) @RequestParam String fcmToken) { + Integer updatedFcmTokenId = userService.updateFcmToken(userId, fcmTokenId, fcmToken); + return new BaseResponse<>(Status.SUCCESS, updatedFcmTokenId); } - @Operation(summary="알림설정 동의 변경") + @Operation(summary = "알림설정 동의 변경") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "요청에 성공하였습니다."), @ApiResponse(responseCode = "404", description = "존재하지 않는 유저 입니다.")}) @PatchMapping("/push") - public BaseResponse updateAgreePush(@Parameter(hidden = true) @AuthUser Integer userId,@Parameter(description = "알람동의 값",example = "true")@RequestParam() boolean agreePush){ - userService.updateAgreePush(userId,agreePush); + public BaseResponse updateAgreePush(@Parameter(hidden = true) @AuthUser Integer userId, @Parameter(description = "알람동의 값", example = "true") @RequestParam() boolean agreePush) { + userService.updateAgreePush(userId, agreePush); return new BaseResponse<>(Status.SUCCESS); } - @Operation(summary="카카오 유저 탈퇴") + @Operation(summary = "카카오 유저 탈퇴") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "요청에 성공하였습니다."), @ApiResponse(responseCode = "404", description = "존재하지 않는 유저 입니다.")}) @DeleteMapping() - public BaseResponse deleteKaKaoUser(@Parameter(hidden = true) @AuthUser Integer userId){ + public BaseResponse deleteKaKaoUser(@Parameter(hidden = true) @AuthUser Integer userId) { userService.deleteById(userId); return new BaseResponse<>(Status.SUCCESS); } - @Operation(summary="애플 유저 탈퇴") + @Operation(summary = "애플 유저 탈퇴") @ApiResponse(responseCode = "200", description = "요청에 성공하였습니다.") @DeleteMapping("apple") public BaseResponse deleteAppleUser(@Parameter(hidden = true) @AuthUser Integer userId, - @RequestBody @Valid AppleUserDeleteReq appleUserDeleteReq) throws IOException{ - userService.deleteAppleUser(userId,appleUserDeleteReq.getAuthorizationCode()); + @RequestBody @Valid AppleUserDeleteReq appleUserDeleteReq) throws IOException { + userService.deleteAppleUser(userId, appleUserDeleteReq.getAuthorizationCode()); return new BaseResponse<>(Status.SUCCESS); } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/UserService.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/UserService.java index 9654555f..a809af76 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/UserService.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/UserService.java @@ -8,7 +8,9 @@ import com.wakeUpTogetUp.togetUp.api.users.vo.UserProgressionResult; import com.wakeUpTogetUp.togetUp.common.Status; import com.wakeUpTogetUp.togetUp.exception.BaseException; + import java.io.IOException; + import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/dto/response/UserRes.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/dto/response/UserRes.java index a47bc461..7c03ce59 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/dto/response/UserRes.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/dto/response/UserRes.java @@ -11,6 +11,6 @@ public class UserRes { private Integer id; - //private String jwt; + } \ No newline at end of file diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/fcmToken/FcmToken.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/fcmToken/FcmToken.java index c26f8fbd..03f8cd4a 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/fcmToken/FcmToken.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/fcmToken/FcmToken.java @@ -27,12 +27,13 @@ public class FcmToken { @Column(name = "updated_at") private Timestamp updatedAt; + @PreUpdate void updatedAt() { this.updatedAt = Timestamp.from(Instant.now()); } - public void updateFcmToken(String fcmToken){ + public void updateFcmToken(String fcmToken) { setValue(fcmToken); } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/fcmToken/FcmTokenRepository.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/fcmToken/FcmTokenRepository.java index 77318e32..6ec4f0bc 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/fcmToken/FcmTokenRepository.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/fcmToken/FcmTokenRepository.java @@ -4,7 +4,6 @@ import org.springframework.stereotype.Repository; - @Repository public interface FcmTokenRepository extends JpaRepository { diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/model/User.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/model/User.java index c37a0272..44a76b4a 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/model/User.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/model/User.java @@ -7,6 +7,7 @@ import com.wakeUpTogetUp.togetUp.api.users.fcmToken.FcmToken; import com.wakeUpTogetUp.togetUp.common.Status; import com.wakeUpTogetUp.togetUp.exception.BaseException; + import java.sql.Timestamp; import java.time.Instant; import java.util.ArrayList; @@ -23,6 +24,7 @@ import javax.persistence.PreUpdate; import javax.persistence.Table; import javax.validation.constraints.NotNull; + import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/model/UserAvatar.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/model/UserAvatar.java index 27a84143..e80f7b8b 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/model/UserAvatar.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/model/UserAvatar.java @@ -1,6 +1,7 @@ package com.wakeUpTogetUp.togetUp.api.users.model; import com.wakeUpTogetUp.togetUp.api.avatar.model.Avatar; + import java.time.LocalDateTime; import javax.persistence.Column; import javax.persistence.Entity; @@ -11,6 +12,7 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/vo/UserProgressionResult.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/vo/UserProgressionResult.java index 91f64d64..c46bc0cd 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/users/vo/UserProgressionResult.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/users/vo/UserProgressionResult.java @@ -9,7 +9,7 @@ public class UserProgressionResult { @Schema(description = "현재 레벨") private int level; - + @Schema(description = "현재 경험치") private int experience; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/common/Constant.java b/src/main/java/com/wakeUpTogetUp/togetUp/common/Constant.java index dacdf461..ac19be79 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/common/Constant.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/common/Constant.java @@ -5,18 +5,18 @@ public class Constant { public static final String API_NAME = "TOGETUP-API"; public static final String API_VERSION = "v1"; public static final String API_DESCRIPTION = "TOGEPUP API DESCRIPTION"; - public static final String BEARER= "jwt"; - public static final String JWT_PREFIX= "Bearer"; - public static final Integer INVITATION_CODE_LENGTH =5; - public static final String AUTHORIZATION_CODE= "authorization_code" ; + public static final String BEARER = "jwt"; + public static final String JWT_PREFIX = "Bearer"; + public static final Integer INVITATION_CODE_LENGTH = 5; + public static final String AUTHORIZATION_CODE = "authorization_code"; public static final String GET_ALARM_MODE_PERSONAL = "personal"; public static final String GET_ALARM_MODE_GROUP = "group"; - public static final String ROOM_USER_MISSION_IMG_WAITING="http://waiting~"; - public static final String ROOM_USER_MISSION_IMG_FAIL="http://fail~"; - public static final String ROOM_USER_MISSION_IMG_NOT_MISSION="http://not-mission~"; + public static final String ROOM_USER_MISSION_IMG_WAITING = "http://waiting~"; + public static final String ROOM_USER_MISSION_IMG_FAIL = "http://fail~"; + public static final String ROOM_USER_MISSION_IMG_NOT_MISSION = "http://not-mission~"; - public static final Integer MINIMUM_NUMBER_TO_CHANGE_HOST=2; + public static final Integer MINIMUM_NUMBER_TO_CHANGE_HOST = 2; public static final Integer DEFAULT_AVATAR_ID = 1; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/common/dto/BaseResponse.java b/src/main/java/com/wakeUpTogetUp/togetUp/common/dto/BaseResponse.java index b29d98cb..e23f3eca 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/common/dto/BaseResponse.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/common/dto/BaseResponse.java @@ -36,6 +36,6 @@ public BaseResponse(BaseException exception) { this.httpReasonPhrase = exception.getStatus().getHttpStatus().getReasonPhrase(); this.message = exception.getStatus().getMessage(); } - + // TODO : 정적 메소드 만들기 } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/utils/JwtService.java b/src/main/java/com/wakeUpTogetUp/togetUp/utils/JwtService.java index 5ca5fa3c..9c77ccfd 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/utils/JwtService.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/utils/JwtService.java @@ -22,29 +22,29 @@ @Component public class JwtService { @Value("${jwt.secret-key}") - private String key; + private String key; @Value("${jwt.token-expired-time}") - private Long expiredTimeMs; + private Long expiredTimeMs; public Boolean validate(String token, String userEmail, String key) { String useremailByToken = getUseremail(token, key); return useremailByToken.equals(userEmail) && !isTokenExpired(token, key); } - public String getJwt(){ + public String getJwt() { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest(); return request.getHeader("X-ACCESS-TOKEN"); } public Integer getUserId(String accessToken) { Claims claims; - try{ + try { claims = Jwts.parserBuilder() .setSigningKey(getSigningKey()) .build() .parseClaimsJws(accessToken) .getBody(); - } catch(Exception e) { + } catch (Exception e) { System.out.println(e.getMessage()); throw new BaseException(Status.INVALID_JWT); } @@ -52,21 +52,20 @@ public Integer getUserId(String accessToken) { } /** - * * @return int * @throws BaseException */ // TODO :getUserId 와 합치기 - public int getUserNum() throws BaseException{ + public int getUserNum() throws BaseException { //1. JWT 추출 String accessToken = getJwt(); - if(accessToken == null || accessToken.length() == 0){ + if (accessToken == null || accessToken.length() == 0) { throw new BaseException(Status.EMPTY_JWT); } // 2. JWT parsing Claims claims; - try{ + try { claims = Jwts.parserBuilder() .setSigningKey(getSigningKey()) .build() @@ -77,7 +76,7 @@ public int getUserNum() throws BaseException{ } // 3. userId 추출 - return claims.get("userId",Integer.class); + return claims.get("userId", Integer.class); } public Claims extractAllClaims(String token, String key) { @@ -92,7 +91,7 @@ public String getUseremail(String token, String key) { return extractAllClaims(token, key).get("username", String.class); } - private Key getSigningKey() { + private Key getSigningKey() { byte[] keyBytes = key.getBytes(StandardCharsets.UTF_8); return Keys.hmacShaKeyFor(keyBytes); } @@ -126,7 +125,7 @@ public Boolean isTokenExpired(String token, String key) { // return doGenerateToken(userId, expiredTimeMs, key); // } - public String generateAccessToken(Integer userId) { + public String generateAccessToken(Integer userId) { return doGenerateToken(userId, expiredTimeMs, key); } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/utils/TimeFormatter.java b/src/main/java/com/wakeUpTogetUp/togetUp/utils/TimeFormatter.java index 72f1f1dc..fd0441c6 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/utils/TimeFormatter.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/utils/TimeFormatter.java @@ -16,28 +16,28 @@ public class TimeFormatter { public static SimpleDateFormat simpleDateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static SimpleDateFormat simpleDotDateFormat = new SimpleDateFormat("yyyy.MM.dd"); + public static String timestampFormat(Timestamp timestamp) { return simpleDateTimeFormat.format(timestamp); } - public LocalTime stringToLocalTime(String timeString) - { + public LocalTime stringToLocalTime(String timeString) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss"); LocalTime localTime = LocalTime.parse(timeString, formatter); return localTime; } + //yyyy-MM-dd HH:mm:ss - public String timestampToDotDateFormat(Timestamp timestamp){ + public String timestampToDotDateFormat(Timestamp timestamp) { String formattedDate = simpleDotDateFormat.format(timestamp); - return formattedDate; + return formattedDate; } - public LocalDateTime stringToLocalDateTime(String timeString) - { + public LocalDateTime stringToLocalDateTime(String timeString) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); LocalDateTime localDateTime = LocalDateTime.parse(timeString, formatter); return localDateTime; @@ -51,40 +51,37 @@ public String timeStringToAMPMFormat(String timeString) { } - - public String formatDaysOfWeek(boolean monday, boolean tuesday, boolean wednesday, boolean thursday, boolean friday, boolean saturday, boolean sunday) { StringBuilder formattedDays = new StringBuilder(); - Boolean[] weekDays= {true, true, true, true, true, false, false }; + Boolean[] weekDays = {true, true, true, true, true, false, false}; Boolean[] weekend = {false, false, false, false, false, true, true}; Boolean[] none = {false, false, false, false, false, false, false}; - Boolean[] everyDay= {true, true, true, true, true, true, true }; + Boolean[] everyDay = {true, true, true, true, true, true, true}; - Boolean[] alarmDays = {monday, tuesday, wednesday, thursday, friday, saturday, sunday }; + Boolean[] alarmDays = {monday, tuesday, wednesday, thursday, friday, saturday, sunday}; - if(Objects.deepEquals(weekDays,alarmDays)) + if (Objects.deepEquals(weekDays, alarmDays)) formattedDays.append("주중"); - else if(Objects.deepEquals(weekend,alarmDays)) + else if (Objects.deepEquals(weekend, alarmDays)) formattedDays.append("주말"); - else if (Objects.deepEquals(none,alarmDays)) + else if (Objects.deepEquals(none, alarmDays)) formattedDays.append(""); - else if(Objects.deepEquals(everyDay,alarmDays)) + else if (Objects.deepEquals(everyDay, alarmDays)) formattedDays.append("매일"); - else - { + else { for (int i = 0; i < alarmDays.length; i++) { if (alarmDays[i]) { - formattedDays.append(new String[]{"월", "화", "수", "목", "금","토","일"}[i]); + formattedDays.append(new String[]{"월", "화", "수", "목", "금", "토", "일"}[i]); formattedDays.append(","); } } //요일이 한개이면 - if (formattedDays.length()==2) - return formattedDays.toString().replace(",","요일"); + if (formattedDays.length() == 2) + return formattedDays.toString().replace(",", "요일"); formattedDays.deleteCharAt(formattedDays.length() - 1); }