From 1849e192edf6828453dadc6e1bafcafdab45f36b Mon Sep 17 00:00:00 2001 From: kseysh Date: Wed, 29 May 2024 14:19:09 +0900 Subject: [PATCH 01/35] =?UTF-8?q?deploy=20-=20#145=20codedeploy=20shell=20?= =?UTF-8?q?script=20=ED=99=98=EA=B2=BD=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/start.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/script/start.sh b/script/start.sh index 1cf49ca4..abc9f911 100644 --- a/script/start.sh +++ b/script/start.sh @@ -1,12 +1,8 @@ # 인스턴스에 클론 받은 디렉토리 이름을 `app`으로 바꿔야합니다. APPLICATION_PATH=/home/ubuntu/app -# shellcheck disable=SC2164 cd $APPLICATION_PATH -# shellcheck disable=SC2010 JAR_NAME=$(ls $APPLICATION_PATH/build/libs/ | grep '.jar' | tail -n 1) - -# shellcheck disable=SC2034 JAR_PATH=build/libs/$JAR_NAME JAR_PID=$(pgrep -f $JAR_NAME) @@ -20,7 +16,15 @@ JAR_PID=$(pgrep -f $JAR_NAME) fi echo "> $JAR_PATH 배포" #3 - # shellcheck disable=SC2153 - # shellcheck disable=SC2024 + source ~/.bashrc - sudo nohup java -jar -Dspring.profiles.active=prod "$JAR_PATH" >nohup.out 2>&1 nohup.out 2>&1 nohup.out 2>&1 Date: Wed, 29 May 2024 14:20:02 +0900 Subject: [PATCH 02/35] =?UTF-8?q?deploy=20-=20#145=20ci=20=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=EC=9A=B0=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/hmh-cd-prod.yml | 2 +- .../workflows/{hmh-ci.yml => hmh-ci-dev.yml} | 2 - .github/workflows/hmh-ci-prod.yml | 40 +++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) rename .github/workflows/{hmh-ci.yml => hmh-ci-dev.yml} (96%) create mode 100644 .github/workflows/hmh-ci-prod.yml diff --git a/.github/workflows/hmh-cd-prod.yml b/.github/workflows/hmh-cd-prod.yml index 0ca6ee51..3353b393 100644 --- a/.github/workflows/hmh-cd-prod.yml +++ b/.github/workflows/hmh-cd-prod.yml @@ -49,7 +49,7 @@ jobs: aws-region: ${{ secrets.AWS_REGION }} - name: 🚀 s3 upload - run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{matrix.s3-bucket}}/prod/deploy/$GITHUB_SHA.zip # 수정 고려 + run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{matrix.s3-bucket}}/prod/deploy/$GITHUB_SHA.zip - name: ☀️ CodeDeploy~! run: aws deploy create-deployment diff --git a/.github/workflows/hmh-ci.yml b/.github/workflows/hmh-ci-dev.yml similarity index 96% rename from .github/workflows/hmh-ci.yml rename to .github/workflows/hmh-ci-dev.yml index eedf0287..8648100a 100644 --- a/.github/workflows/hmh-ci.yml +++ b/.github/workflows/hmh-ci-dev.yml @@ -3,8 +3,6 @@ name: 🏭 APPLICATION-BUILD! on: pull_request: branches: [ "develop" ] - push: - branches: [ "develop" ] permissions: contents: read diff --git a/.github/workflows/hmh-ci-prod.yml b/.github/workflows/hmh-ci-prod.yml new file mode 100644 index 00000000..c9aa1877 --- /dev/null +++ b/.github/workflows/hmh-ci-prod.yml @@ -0,0 +1,40 @@ +name: 🏭 APPLICATION-BUILD! + +on: + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: checkout + uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'corretto' + + - name: Copy application.yml + run: | + mkdir ./src/main/resources + touch ./src/main/resources/application.yml + + echo "${{ secrets.APPLICATION_PROD_YML }}" >> ./src/main/resources/application.yml + + cat ./src/main/resources/application.yml + shell: bash + + - name: Grant execute permission for gradlew + run: | + chmod +x gradlew + + - name: Build with Gradle + run: | + ./gradlew clean build \ No newline at end of file From ee49c71d360e0fb2bfe3754df309a2e966dd5f94 Mon Sep 17 00:00:00 2001 From: kseysh Date: Thu, 30 May 2024 20:07:44 +0900 Subject: [PATCH 03/35] =?UTF-8?q?modify=20-=20#123=20RedisManagerService?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmh/domain/user/controller/UserApi.java | 2 +- .../user/controller/UserController.java | 3 +-- .../hmh/domain/user/service/UserService.java | 9 -------- .../org/hmh/global/auth/jwt/TokenService.java | 3 --- .../auth/redis/RedisManagerService.java | 21 ------------------- 5 files changed, 2 insertions(+), 36 deletions(-) delete mode 100644 src/main/java/sopt/org/hmh/global/auth/redis/RedisManagerService.java diff --git a/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java b/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java index 56617336..d4a29939 100644 --- a/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java +++ b/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java @@ -9,7 +9,7 @@ public interface UserApi { @Operation(summary = "로그아웃") - ResponseEntity> orderLogout(@UserId @Parameter(hidden = true) final Long userId); + ResponseEntity> orderLogout(); @Operation(summary = "유저 정보 불러오기") ResponseEntity> orderGetUserInfo(@UserId @Parameter(hidden = true) final Long userId); diff --git a/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java b/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java index 853f88b7..86d14391 100644 --- a/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java +++ b/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java @@ -22,8 +22,7 @@ public class UserController implements UserApi{ @PostMapping("/logout") @Override - public ResponseEntity> orderLogout(@UserId final Long userId) { - userService.logout(userId); + public ResponseEntity> orderLogout() { return ResponseEntity .status(UserSuccess.LOGOUT_SUCCESS.getHttpStatus()) .body(BaseResponse.success(UserSuccess.LOGOUT_SUCCESS, new EmptyJsonResponse())); diff --git a/src/main/java/sopt/org/hmh/domain/user/service/UserService.java b/src/main/java/sopt/org/hmh/domain/user/service/UserService.java index a631adb7..fdca204f 100644 --- a/src/main/java/sopt/org/hmh/domain/user/service/UserService.java +++ b/src/main/java/sopt/org/hmh/domain/user/service/UserService.java @@ -12,8 +12,6 @@ import sopt.org.hmh.domain.auth.exception.AuthException; import sopt.org.hmh.domain.auth.repository.OnboardingInfoRepository; import sopt.org.hmh.domain.auth.repository.ProblemRepository; -import sopt.org.hmh.domain.challenge.domain.exception.ChallengeError; -import sopt.org.hmh.domain.challenge.domain.exception.ChallengeException; import sopt.org.hmh.domain.user.domain.OnboardingInfo; import sopt.org.hmh.domain.user.domain.OnboardingProblem; import sopt.org.hmh.domain.user.domain.User; @@ -22,7 +20,6 @@ import sopt.org.hmh.domain.user.domain.exception.UserException; import sopt.org.hmh.domain.user.dto.response.UserInfoResponse; import sopt.org.hmh.domain.user.repository.UserRepository; -import sopt.org.hmh.global.auth.redis.RedisManagerService; import sopt.org.hmh.global.auth.social.SocialPlatform; @Service @@ -30,7 +27,6 @@ @Transactional(readOnly = true) public class UserService { - private final RedisManagerService redisManagerService; private final UserRepository userRepository; private final OnboardingInfoRepository onboardingInfoRepository; private final ProblemRepository problemRepository; @@ -38,14 +34,9 @@ public class UserService { @Transactional public void withdraw(Long userId) { - redisManagerService.deleteRefreshToken(userId); this.findByIdOrThrowException(userId).softDelete(); } - public void logout(Long userId) { - redisManagerService.deleteRefreshToken(userId); - } - public UserInfoResponse getUserInfo(Long userId) { return UserInfoResponse.of(this.findByIdOrThrowException(userId)); } diff --git a/src/main/java/sopt/org/hmh/global/auth/jwt/TokenService.java b/src/main/java/sopt/org/hmh/global/auth/jwt/TokenService.java index 66292c1e..64e2f6b9 100644 --- a/src/main/java/sopt/org/hmh/global/auth/jwt/TokenService.java +++ b/src/main/java/sopt/org/hmh/global/auth/jwt/TokenService.java @@ -6,7 +6,6 @@ import sopt.org.hmh.domain.auth.dto.response.ReissueResponse; import sopt.org.hmh.global.auth.jwt.exception.JwtError; import sopt.org.hmh.global.auth.jwt.exception.JwtException; -import sopt.org.hmh.global.auth.redis.RedisManagerService; @Service @RequiredArgsConstructor @@ -14,14 +13,12 @@ public class TokenService { private final JwtProvider jwtProvider; private final JwtValidator jwtValidator; - private final RedisManagerService redisManagerService; @Transactional public ReissueResponse reissueToken(String refreshToken) { String parsedRefreshToken = parseTokenString(refreshToken); Long userId = jwtProvider.getSubject(parsedRefreshToken); jwtValidator.validateRefreshToken(parsedRefreshToken); - redisManagerService.deleteRefreshToken(userId); return ReissueResponse.of(jwtProvider.issueToken(userId)); } diff --git a/src/main/java/sopt/org/hmh/global/auth/redis/RedisManagerService.java b/src/main/java/sopt/org/hmh/global/auth/redis/RedisManagerService.java deleted file mode 100644 index 812a5681..00000000 --- a/src/main/java/sopt/org/hmh/global/auth/redis/RedisManagerService.java +++ /dev/null @@ -1,21 +0,0 @@ -package sopt.org.hmh.global.auth.redis; - -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import sopt.org.hmh.global.auth.jwt.exception.JwtError; -import sopt.org.hmh.global.auth.jwt.exception.JwtException; - -@Service -@RequiredArgsConstructor -public class RedisManagerService { - - private final TokenRepository tokenRepository; - - public void deleteRefreshToken(Long userId) { - if (tokenRepository.existsById(userId)) { - tokenRepository.deleteById(userId); - } else { - throw new JwtException(JwtError.INVALID_REFRESH_TOKEN); - } - } -} From 0976ed96d51d4c59e37b6b99125291cca12ebdf8 Mon Sep 17 00:00:00 2001 From: kseysh Date: Fri, 31 May 2024 21:16:45 +0900 Subject: [PATCH 04/35] =?UTF-8?q?modify=20-=20#123=20redis=20repository=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/hmh/global/auth/jwt/JwtGenerator.java | 16 +----------- .../hmh/global/auth/redis/RefreshToken.java | 25 ------------------- .../global/auth/redis/TokenRepository.java | 6 ----- 3 files changed, 1 insertion(+), 46 deletions(-) delete mode 100644 src/main/java/sopt/org/hmh/global/auth/redis/RefreshToken.java delete mode 100644 src/main/java/sopt/org/hmh/global/auth/redis/TokenRepository.java diff --git a/src/main/java/sopt/org/hmh/global/auth/jwt/JwtGenerator.java b/src/main/java/sopt/org/hmh/global/auth/jwt/JwtGenerator.java index 185280db..5da40648 100644 --- a/src/main/java/sopt/org/hmh/global/auth/jwt/JwtGenerator.java +++ b/src/main/java/sopt/org/hmh/global/auth/jwt/JwtGenerator.java @@ -11,8 +11,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; -import sopt.org.hmh.global.auth.redis.RefreshToken; -import sopt.org.hmh.global.auth.redis.TokenRepository; @Component @RequiredArgsConstructor @@ -25,29 +23,17 @@ public class JwtGenerator { @Value("${jwt.refresh-token-expiration-time}") private Long REFRESH_TOKEN_EXPIRATION_TIME; - private final TokenRepository tokenRepository; - public String generateToken(Long userId, boolean isRefreshToken) { final Date now = generateNowDate(); final Date expiration = generateExpirationDate(isRefreshToken, now); - String token = Jwts.builder() + return Jwts.builder() .setHeaderParam(Header.TYPE, Header.JWT_TYPE) .setSubject(String.valueOf(userId)) .setIssuedAt(now) .setExpiration(expiration) .signWith(getSigningKey()) .compact(); - - if (isRefreshToken) { - tokenRepository.save( - RefreshToken.builder() - .userId(userId) - .token(token) - .expiration(REFRESH_TOKEN_EXPIRATION_TIME / 1000) - .build()); - } - return token; } public JwtParser getJwtParser() { diff --git a/src/main/java/sopt/org/hmh/global/auth/redis/RefreshToken.java b/src/main/java/sopt/org/hmh/global/auth/redis/RefreshToken.java deleted file mode 100644 index cfb6e848..00000000 --- a/src/main/java/sopt/org/hmh/global/auth/redis/RefreshToken.java +++ /dev/null @@ -1,25 +0,0 @@ -package sopt.org.hmh.global.auth.redis; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.springframework.data.annotation.Id; -import org.springframework.data.redis.core.RedisHash; -import org.springframework.data.redis.core.TimeToLive; - -@Getter -@RedisHash(value = "refresh") -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class RefreshToken { - - @Id - private Long userId; - - private String token; - - @TimeToLive - private Long expiration; -} \ No newline at end of file diff --git a/src/main/java/sopt/org/hmh/global/auth/redis/TokenRepository.java b/src/main/java/sopt/org/hmh/global/auth/redis/TokenRepository.java deleted file mode 100644 index e550e700..00000000 --- a/src/main/java/sopt/org/hmh/global/auth/redis/TokenRepository.java +++ /dev/null @@ -1,6 +0,0 @@ -package sopt.org.hmh.global.auth.redis; - -import org.springframework.data.repository.CrudRepository; - -public interface TokenRepository extends CrudRepository { -} \ No newline at end of file From b218e64f2578b693c8149740ef0ab88a181ceed6 Mon Sep 17 00:00:00 2001 From: kseysh Date: Fri, 31 May 2024 21:19:02 +0900 Subject: [PATCH 05/35] =?UTF-8?q?modify=20-=20#123=20redis=20config=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/hmh/global/config/RedisConfig.java | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 src/main/java/sopt/org/hmh/global/config/RedisConfig.java diff --git a/src/main/java/sopt/org/hmh/global/config/RedisConfig.java b/src/main/java/sopt/org/hmh/global/config/RedisConfig.java deleted file mode 100644 index ff8e702e..00000000 --- a/src/main/java/sopt/org/hmh/global/config/RedisConfig.java +++ /dev/null @@ -1,32 +0,0 @@ -package sopt.org.hmh.global.config; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.data.redis.connection.RedisStandaloneConfiguration; -import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; -import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; - -@Configuration -@EnableRedisRepositories -public class RedisConfig { - - @Value("${spring.data.redis.host}") - private String host; - - @Value("${spring.data.redis.port}") - private int port; - - @Value("${spring.data.redis.password}") - private String password; - - @Bean - public RedisConnectionFactory redisConnectionFactory() { - RedisStandaloneConfiguration redisConfiguration = new RedisStandaloneConfiguration(); - redisConfiguration.setHostName(host); - redisConfiguration.setPort(port); - redisConfiguration.setPassword(password); - return new LettuceConnectionFactory(redisConfiguration); - } -} \ No newline at end of file From a349d3003494141f53d7542c3139517822a0d218 Mon Sep 17 00:00:00 2001 From: kseysh Date: Fri, 31 May 2024 21:23:49 +0900 Subject: [PATCH 06/35] =?UTF-8?q?chore=20-=20#123=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/HMH-Server.iml | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/HMH-Server.iml diff --git a/src/HMH-Server.iml b/src/HMH-Server.iml deleted file mode 100644 index e69de29b..00000000 From e097086aab20114b9dc19f4aee2846115714d983 Mon Sep 17 00:00:00 2001 From: kseysh Date: Fri, 31 May 2024 21:24:07 +0900 Subject: [PATCH 07/35] =?UTF-8?q?docs=20-=20#123=20readme=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/README.md b/README.md index 1a8eb0cc..352f5b01 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ - **Language** : Java (jdk-17) - **Web application Framework** : Spring boot (3.2.1), Spring Data JPA -- **DataBase** : MySql (8.1.0), Redis +- **DataBase** : MySql (8.1.0) - **Cloud/Infra** : Aws EC2, RDS, code deploy - **web server** : Tomcat, Nginx - **Collaborative Tool** : Github, Slack, Notion @@ -28,34 +28,4 @@ | image | image | | [jumining](https://github.com/jumining) | [kseysh](https://github.com/kseysh) | -
- -## ✅ Convention - - - -### 🚀Convention - -- [💻 협업 컨벤션](https://hmhteam.notion.site/6fa22000670d4cf783559f7808c01d1a?pvs=4)
- -### 🚀 Branch Strategy - -- [💻 브랜치 전략](https://hmhteam.notion.site/9d8065b238c543b890ceeb9912966dd0?pvs=4) - -
- -## 💾 ERD - -![image](https://github.com/Team-HMH/HMH-Server/assets/69035864/f4b95b3d-6507-4d33-be41-8a4847bc076f) - -
- -
- -## ⚙️ Architecture - -![architecture](https://github.com/Team-HMH/HMH-Server/assets/69035864/e0eefac1-d8be-4a08-a3de-6e9786557042) - - -
From 34c4757d92bf0a8b999b03d2e45bae1451a05ff9 Mon Sep 17 00:00:00 2001 From: kseysh Date: Fri, 31 May 2024 22:18:08 +0900 Subject: [PATCH 08/35] =?UTF-8?q?refactor=20-=20#151=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=EB=AC=B8=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/org/hmh/domain/point/controller/PointController.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/sopt/org/hmh/domain/point/controller/PointController.java b/src/main/java/sopt/org/hmh/domain/point/controller/PointController.java index e05e862a..0e2d3b93 100644 --- a/src/main/java/sopt/org/hmh/domain/point/controller/PointController.java +++ b/src/main/java/sopt/org/hmh/domain/point/controller/PointController.java @@ -1,8 +1,6 @@ package sopt.org.hmh.domain.point.controller; import java.time.LocalDate; -import java.util.List; - import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -10,7 +8,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import sopt.org.hmh.domain.challenge.domain.Challenge; import sopt.org.hmh.domain.point.dto.response.*; import sopt.org.hmh.domain.point.exception.PointSuccess; import sopt.org.hmh.domain.point.service.PointFacade; From d1fc1db016a94893e410b57b4401663ea995cbb8 Mon Sep 17 00:00:00 2001 From: kseysh Date: Fri, 31 May 2024 22:50:55 +0900 Subject: [PATCH 09/35] =?UTF-8?q?fix=20-=20#151=20LocalDate=EB=A5=BC=20DTO?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EB=B0=9B=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/org/hmh/domain/point/controller/PointApi.java | 9 +++------ .../hmh/domain/point/controller/PointController.java | 10 +++++----- .../domain/point/dto/request/ChallengeDateRequest.java | 8 ++++++++ 3 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 src/main/java/sopt/org/hmh/domain/point/dto/request/ChallengeDateRequest.java diff --git a/src/main/java/sopt/org/hmh/domain/point/controller/PointApi.java b/src/main/java/sopt/org/hmh/domain/point/controller/PointApi.java index a06ed9af..527575ce 100644 --- a/src/main/java/sopt/org/hmh/domain/point/controller/PointApi.java +++ b/src/main/java/sopt/org/hmh/domain/point/controller/PointApi.java @@ -6,15 +6,12 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; -import java.time.LocalDate; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PatchMapping; +import sopt.org.hmh.domain.point.dto.request.ChallengeDateRequest; import sopt.org.hmh.domain.point.dto.response.ChallengePointStatusListResponse; import sopt.org.hmh.domain.point.dto.response.EarnPointResponse; import sopt.org.hmh.domain.point.dto.response.UsagePointResponse; import sopt.org.hmh.domain.point.dto.response.UsePointResponse; -import sopt.org.hmh.domain.point.exception.PointSuccess; -import sopt.org.hmh.global.auth.UserId; import sopt.org.hmh.global.auth.jwt.JwtConstants; import sopt.org.hmh.global.common.response.BaseResponse; @@ -54,7 +51,7 @@ ResponseEntity> orderGetChallenge description = "서버 내부 오류입니다.", content = @Content)}) ResponseEntity> orderUsagePointAndChallengeFailed( - @Parameter(hidden = true) Long userId, LocalDate challengeDate); + @Parameter(hidden = true) Long userId, ChallengeDateRequest challengeDateRequest); @Operation( summary = "포인트 받기 API", @@ -71,7 +68,7 @@ ResponseEntity> orderUsagePointAndChallengeFailed description = "서버 내부 오류입니다.", content = @Content)}) ResponseEntity> orderEarnPointAndChallengeEarned( - @Parameter(hidden = true) Long userId, LocalDate challengeDate); + @Parameter(hidden = true) Long userId, ChallengeDateRequest challengeDateRequest); @Operation( summary = "사용할 포인트 받기 API", diff --git a/src/main/java/sopt/org/hmh/domain/point/controller/PointController.java b/src/main/java/sopt/org/hmh/domain/point/controller/PointController.java index 0e2d3b93..209b5f2c 100644 --- a/src/main/java/sopt/org/hmh/domain/point/controller/PointController.java +++ b/src/main/java/sopt/org/hmh/domain/point/controller/PointController.java @@ -1,6 +1,5 @@ package sopt.org.hmh.domain.point.controller; -import java.time.LocalDate; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -8,6 +7,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import sopt.org.hmh.domain.point.dto.request.ChallengeDateRequest; import sopt.org.hmh.domain.point.dto.response.*; import sopt.org.hmh.domain.point.exception.PointSuccess; import sopt.org.hmh.domain.point.service.PointFacade; @@ -37,24 +37,24 @@ public ResponseEntity> orderGetCh @PatchMapping("/use") public ResponseEntity> orderUsagePointAndChallengeFailed( @UserId final Long userId, - @RequestBody final LocalDate challengeDate + @RequestBody final ChallengeDateRequest challengeDateRequest ) { return ResponseEntity .status(PointSuccess.POINT_USAGE_SUCCESS.getHttpStatus()) .body(BaseResponse.success(PointSuccess.POINT_USAGE_SUCCESS, - pointFacade.usePointAndChallengeFailed(userId, challengeDate))); + pointFacade.usePointAndChallengeFailed(userId, challengeDateRequest.challengeDate()))); } @Override @PatchMapping("/earn") public ResponseEntity> orderEarnPointAndChallengeEarned( @UserId final Long userId, - @RequestBody final LocalDate challengeDate + @RequestBody final ChallengeDateRequest challengeDateRequest ) { return ResponseEntity .status(PointSuccess.POINT_EARN_SUCCESS.getHttpStatus()) .body(BaseResponse.success(PointSuccess.POINT_EARN_SUCCESS, - pointFacade.earnPointAndChallengeEarned(userId, challengeDate))); + pointFacade.earnPointAndChallengeEarned(userId, challengeDateRequest.challengeDate()))); } @Override diff --git a/src/main/java/sopt/org/hmh/domain/point/dto/request/ChallengeDateRequest.java b/src/main/java/sopt/org/hmh/domain/point/dto/request/ChallengeDateRequest.java new file mode 100644 index 00000000..931db058 --- /dev/null +++ b/src/main/java/sopt/org/hmh/domain/point/dto/request/ChallengeDateRequest.java @@ -0,0 +1,8 @@ +package sopt.org.hmh.domain.point.dto.request; + +import java.time.LocalDate; + +public record ChallengeDateRequest( + LocalDate challengeDate +) { +} \ No newline at end of file From 1be5bb95cadea994444b08a6929aaf29861047bf Mon Sep 17 00:00:00 2001 From: kseysh Date: Fri, 31 May 2024 23:10:36 +0900 Subject: [PATCH 10/35] =?UTF-8?q?refactor=20-=20#153=20dummy=20api=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/org/hmh/domain/dummy/DummyApp.java | 14 --------- .../hmh/domain/dummy/DummyAppController.java | 21 ------------- .../domain/dummy/DummyAppListResponse.java | 17 ---------- .../org/hmh/domain/dummy/DummyAppSuccess.java | 31 ------------------- 4 files changed, 83 deletions(-) delete mode 100644 src/main/java/sopt/org/hmh/domain/dummy/DummyApp.java delete mode 100644 src/main/java/sopt/org/hmh/domain/dummy/DummyAppController.java delete mode 100644 src/main/java/sopt/org/hmh/domain/dummy/DummyAppListResponse.java delete mode 100644 src/main/java/sopt/org/hmh/domain/dummy/DummyAppSuccess.java diff --git a/src/main/java/sopt/org/hmh/domain/dummy/DummyApp.java b/src/main/java/sopt/org/hmh/domain/dummy/DummyApp.java deleted file mode 100644 index f6ff4f55..00000000 --- a/src/main/java/sopt/org/hmh/domain/dummy/DummyApp.java +++ /dev/null @@ -1,14 +0,0 @@ -package sopt.org.hmh.domain.dummy; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Deprecated -@Getter -@AllArgsConstructor -public class DummyApp { - String appName; - String appImageUrl; - Long goalTime; - Long usageTime; -} diff --git a/src/main/java/sopt/org/hmh/domain/dummy/DummyAppController.java b/src/main/java/sopt/org/hmh/domain/dummy/DummyAppController.java deleted file mode 100644 index 6ffeedf8..00000000 --- a/src/main/java/sopt/org/hmh/domain/dummy/DummyAppController.java +++ /dev/null @@ -1,21 +0,0 @@ -package sopt.org.hmh.domain.dummy; - -import lombok.RequiredArgsConstructor; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import sopt.org.hmh.global.common.response.BaseResponse; - -@RestController -@RequiredArgsConstructor -@RequestMapping("/api/v1/dummy") -@Deprecated -public class DummyAppController { - @GetMapping("/app") - public ResponseEntity> orderModifyDailyChallenge() { - return ResponseEntity - .status(DummyAppSuccess.GET_DUMMY_SUCCESS.getHttpStatus()) - .body(BaseResponse.success(DummyAppSuccess.GET_DUMMY_SUCCESS, DummyAppListResponse.of())); - } -} diff --git a/src/main/java/sopt/org/hmh/domain/dummy/DummyAppListResponse.java b/src/main/java/sopt/org/hmh/domain/dummy/DummyAppListResponse.java deleted file mode 100644 index 40a92324..00000000 --- a/src/main/java/sopt/org/hmh/domain/dummy/DummyAppListResponse.java +++ /dev/null @@ -1,17 +0,0 @@ -package sopt.org.hmh.domain.dummy; - -import java.util.ArrayList; -import java.util.List; - -@Deprecated -public record DummyAppListResponse( - List apps -) { - public static DummyAppListResponse of() { - List dummyAppList = new ArrayList<>(); - dummyAppList.add(new DummyApp("Netflix","https://github.com/Team-HMH/HMH-Server/assets/69035864/dd068b83-641a-4bff-b4f5-381ea6e04d44",2_400_000L,1_320_000L)); - dummyAppList.add(new DummyApp("Instagram","https://github.com/Team-HMH/HMH-Server/assets/69035864/bd572377-9dd9-47e7-a9f4-9efbbe66cd2e",5_400_000L,2_880_000L)); - dummyAppList.add(new DummyApp("YouTube","https://github.com/Team-HMH/HMH-Server/assets/69035864/8afa60c0-bf1d-4ff0-9b50-4d1558a71f0a",3_300_000L,900_000L)); - return new DummyAppListResponse(dummyAppList); - } -} diff --git a/src/main/java/sopt/org/hmh/domain/dummy/DummyAppSuccess.java b/src/main/java/sopt/org/hmh/domain/dummy/DummyAppSuccess.java deleted file mode 100644 index 49f1a2c4..00000000 --- a/src/main/java/sopt/org/hmh/domain/dummy/DummyAppSuccess.java +++ /dev/null @@ -1,31 +0,0 @@ -package sopt.org.hmh.domain.dummy; - -import lombok.AllArgsConstructor; -import org.springframework.http.HttpStatus; -import sopt.org.hmh.global.common.exception.base.SuccessBase; - -@AllArgsConstructor -@Deprecated -public enum DummyAppSuccess implements SuccessBase { - - GET_DUMMY_SUCCESS(HttpStatus.OK, "더미 데이터 가져오기에 성공하였습니다."), - ; - - private final HttpStatus status; - private final String successMessage; - - @Override - public int getHttpStatusCode() { - return this.status.value(); - } - - @Override - public HttpStatus getHttpStatus() { - return this.status; - } - - @Override - public String getSuccessMessage() { - return this.successMessage; - } -} From 64925cd9677d2aacf4d40a30a48df401546bc03a Mon Sep 17 00:00:00 2001 From: kseysh Date: Fri, 31 May 2024 23:10:59 +0900 Subject: [PATCH 11/35] =?UTF-8?q?refactor=20-=20#153=20SecurityConfig?= =?UTF-8?q?=EC=97=90=EC=84=9C=20dummy=20api=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/sopt/org/hmh/global/config/SecurityConfig.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/sopt/org/hmh/global/config/SecurityConfig.java b/src/main/java/sopt/org/hmh/global/config/SecurityConfig.java index 7c07c0c0..5c7e1203 100644 --- a/src/main/java/sopt/org/hmh/global/config/SecurityConfig.java +++ b/src/main/java/sopt/org/hmh/global/config/SecurityConfig.java @@ -41,9 +41,6 @@ public class SecurityConfig { "/api/v1/user/reissue", "/api/v1/user/signup", "/api/v1/user/social/token/kakao", - - // etc - "/api/v1/dummy/**", }; @Bean From 5e99b64b0ecb8b95d3a1d642a556728c79facc7a Mon Sep 17 00:00:00 2001 From: kseysh Date: Sun, 9 Jun 2024 03:37:30 +0900 Subject: [PATCH 12/35] =?UTF-8?q?fix=20-=20#155=20=EC=95=B1=20=EC=B5=9C?= =?UTF-8?q?=EB=8C=80=20=EC=8B=9C=EA=B0=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/sopt/org/hmh/domain/app/domain/AppConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/sopt/org/hmh/domain/app/domain/AppConstants.java b/src/main/java/sopt/org/hmh/domain/app/domain/AppConstants.java index 5d4e6c17..744ee28d 100644 --- a/src/main/java/sopt/org/hmh/domain/app/domain/AppConstants.java +++ b/src/main/java/sopt/org/hmh/domain/app/domain/AppConstants.java @@ -6,5 +6,5 @@ @NoArgsConstructor(access = AccessLevel.PRIVATE) public abstract class AppConstants { public static final Long MINIMUM_APP_TIME = 0L; - public static final Long MAXIMUM_APP_TIME = 3659000L; + public static final Long MAXIMUM_APP_TIME = 21_600_000L; // 6시간 } \ No newline at end of file From 23478a2f9035e1dd218124b91104486b30a06e18 Mon Sep 17 00:00:00 2001 From: kseysh Date: Sun, 9 Jun 2024 20:25:00 +0900 Subject: [PATCH 13/35] =?UTF-8?q?feat=20-=20#149=20=EB=B0=9B=EC=9D=84=20?= =?UTF-8?q?=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EB=B0=98=ED=99=98=20api=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmh/domain/point/controller/PointApi.java | 17 +++++++++++++++++ .../point/controller/PointController.java | 12 +++++++++++- .../point/dto/response/EarnedPointResponse.java | 6 ++++++ .../point/dto/response/UsagePointResponse.java | 3 ++- .../domain/point/exception/PointSuccess.java | 1 + 5 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 src/main/java/sopt/org/hmh/domain/point/dto/response/EarnedPointResponse.java diff --git a/src/main/java/sopt/org/hmh/domain/point/controller/PointApi.java b/src/main/java/sopt/org/hmh/domain/point/controller/PointApi.java index 527575ce..97d5eea4 100644 --- a/src/main/java/sopt/org/hmh/domain/point/controller/PointApi.java +++ b/src/main/java/sopt/org/hmh/domain/point/controller/PointApi.java @@ -10,6 +10,7 @@ import sopt.org.hmh.domain.point.dto.request.ChallengeDateRequest; import sopt.org.hmh.domain.point.dto.response.ChallengePointStatusListResponse; import sopt.org.hmh.domain.point.dto.response.EarnPointResponse; +import sopt.org.hmh.domain.point.dto.response.EarnedPointResponse; import sopt.org.hmh.domain.point.dto.response.UsagePointResponse; import sopt.org.hmh.domain.point.dto.response.UsePointResponse; import sopt.org.hmh.global.auth.jwt.JwtConstants; @@ -85,4 +86,20 @@ ResponseEntity> orderEarnPointAndChallengeEarned description = "서버 내부 오류입니다.", content = @Content)}) ResponseEntity> orderGetUsagePoint(); + + @Operation( + summary = "받을 포인트 받기 API", + responses = { + @ApiResponse( + responseCode = "200", + description = "사용할 포인트 반환에 성공하였습니다."), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content), + @ApiResponse( + responseCode = "500", + description = "서버 내부 오류입니다.", + content = @Content)}) + ResponseEntity> orderGetEarnedPoint(); } diff --git a/src/main/java/sopt/org/hmh/domain/point/controller/PointController.java b/src/main/java/sopt/org/hmh/domain/point/controller/PointController.java index 209b5f2c..5ed744ea 100644 --- a/src/main/java/sopt/org/hmh/domain/point/controller/PointController.java +++ b/src/main/java/sopt/org/hmh/domain/point/controller/PointController.java @@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import sopt.org.hmh.domain.challenge.domain.ChallengeConstants; import sopt.org.hmh.domain.point.dto.request.ChallengeDateRequest; import sopt.org.hmh.domain.point.dto.response.*; import sopt.org.hmh.domain.point.exception.PointSuccess; @@ -57,12 +58,21 @@ public ResponseEntity> orderEarnPointAndChalleng pointFacade.earnPointAndChallengeEarned(userId, challengeDateRequest.challengeDate()))); } + @Override + @GetMapping("/earn") + public ResponseEntity> orderGetEarnedPoint() { + return ResponseEntity + .status(PointSuccess.GET_EARNED_POINT_SUCCESS.getHttpStatus()) + .body(BaseResponse.success(PointSuccess.GET_EARNED_POINT_SUCCESS, + new EarnedPointResponse(ChallengeConstants.EARNED_POINT))); + } + @Override @GetMapping("/use") public ResponseEntity> orderGetUsagePoint() { return ResponseEntity .status(PointSuccess.GET_USAGE_POINT_SUCCESS.getHttpStatus()) .body(BaseResponse.success(PointSuccess.GET_USAGE_POINT_SUCCESS, - pointFacade.getUsagePoint())); + new UsagePointResponse(ChallengeConstants.USAGE_POINT))); } } diff --git a/src/main/java/sopt/org/hmh/domain/point/dto/response/EarnedPointResponse.java b/src/main/java/sopt/org/hmh/domain/point/dto/response/EarnedPointResponse.java new file mode 100644 index 00000000..85c892a0 --- /dev/null +++ b/src/main/java/sopt/org/hmh/domain/point/dto/response/EarnedPointResponse.java @@ -0,0 +1,6 @@ +package sopt.org.hmh.domain.point.dto.response; + +public record EarnedPointResponse( + Integer earnPoint +) { +} diff --git a/src/main/java/sopt/org/hmh/domain/point/dto/response/UsagePointResponse.java b/src/main/java/sopt/org/hmh/domain/point/dto/response/UsagePointResponse.java index e394564d..a5b614d0 100644 --- a/src/main/java/sopt/org/hmh/domain/point/dto/response/UsagePointResponse.java +++ b/src/main/java/sopt/org/hmh/domain/point/dto/response/UsagePointResponse.java @@ -1,6 +1,7 @@ package sopt.org.hmh.domain.point.dto.response; public record UsagePointResponse( - Integer usagePoint + Integer usagePoint ) { + } diff --git a/src/main/java/sopt/org/hmh/domain/point/exception/PointSuccess.java b/src/main/java/sopt/org/hmh/domain/point/exception/PointSuccess.java index 31cf7471..ea6608e0 100644 --- a/src/main/java/sopt/org/hmh/domain/point/exception/PointSuccess.java +++ b/src/main/java/sopt/org/hmh/domain/point/exception/PointSuccess.java @@ -10,6 +10,7 @@ public enum PointSuccess implements SuccessBase { POINT_USAGE_SUCCESS(HttpStatus.OK, "포인트 사용에 성공하였습니다"), POINT_EARN_SUCCESS(HttpStatus.OK, "포인트 받기에 성공하였습니다"), GET_USAGE_POINT_SUCCESS(HttpStatus.OK, "사용할 포인트 반환에 성공하였습니다"), + GET_EARNED_POINT_SUCCESS(HttpStatus.OK, "받을 포인트 반환에 성공하였습니다"), GET_CHALLENGE_POINT_STATUS_LIST_SUCCESS(HttpStatus.OK, "챌린지 포인트 수령 여부 리스트 조회에 성공하였습니다."), ; From f22435794f3ac5c2f7be8c03090349fa7bcc67b1 Mon Sep 17 00:00:00 2001 From: kseysh Date: Sun, 9 Jun 2024 20:25:30 +0900 Subject: [PATCH 14/35] =?UTF-8?q?refactor=20-=20#149=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=A0=20=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EB=B0=98=ED=99=98=20?= =?UTF-8?q?controller=EC=97=90=EC=84=9C=20=ED=95=B4=EA=B2=B0=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/org/hmh/domain/point/service/PointFacade.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/java/sopt/org/hmh/domain/point/service/PointFacade.java b/src/main/java/sopt/org/hmh/domain/point/service/PointFacade.java index 26cf8b05..c150a476 100644 --- a/src/main/java/sopt/org/hmh/domain/point/service/PointFacade.java +++ b/src/main/java/sopt/org/hmh/domain/point/service/PointFacade.java @@ -1,9 +1,7 @@ package sopt.org.hmh.domain.point.service; import java.time.LocalDate; -import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -52,11 +50,6 @@ public EarnPointResponse earnPointAndChallengeEarned(Long userId, LocalDate chal ); } - @Transactional(readOnly = true) - public UsagePointResponse getUsagePoint() { - return new UsagePointResponse(ChallengeConstants.USAGE_POINT); - } - public ChallengePointStatusListResponse getChallengePointStatusList(Long userId) { Challenge challenge = challengeService.findCurrentChallengeByUserId(userId); List challengePointStatusResponseList = From b9fa28eb7d7a3661648c4d7a119e495999638e06 Mon Sep 17 00:00:00 2001 From: kseysh Date: Sun, 9 Jun 2024 23:38:36 +0900 Subject: [PATCH 15/35] =?UTF-8?q?feat=20-=20#158=20=EC=B1=8C=EB=A6=B0?= =?UTF-8?q?=EC=A7=80=20=EC=84=B1=EA=B3=B5=20=EC=97=AC=EB=B6=80=20=EC=A0=84?= =?UTF-8?q?=EC=86=A1=20controller=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DailyChallengeApi.java | 10 +++++++++- .../controller/DailyChallengeController.java | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/sopt/org/hmh/domain/dailychallenge/controller/DailyChallengeApi.java b/src/main/java/sopt/org/hmh/domain/dailychallenge/controller/DailyChallengeApi.java index a902fbd7..62c85780 100644 --- a/src/main/java/sopt/org/hmh/domain/dailychallenge/controller/DailyChallengeApi.java +++ b/src/main/java/sopt/org/hmh/domain/dailychallenge/controller/DailyChallengeApi.java @@ -8,6 +8,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.http.ResponseEntity; import sopt.org.hmh.domain.dailychallenge.dto.request.FinishedDailyChallengeListRequest; +import sopt.org.hmh.domain.dailychallenge.dto.request.FinishedDailyChallengeStatusListRequest; import sopt.org.hmh.global.auth.jwt.JwtConstants; import sopt.org.hmh.global.common.response.BaseResponse; import sopt.org.hmh.global.common.response.EmptyJsonResponse; @@ -33,6 +34,13 @@ public interface DailyChallengeApi { ResponseEntity> orderAddHistoryDailyChallenge( @Parameter(hidden = true) final Long userId, final String os, - final FinishedDailyChallengeListRequest request); + final FinishedDailyChallengeListRequest request + ); + + ResponseEntity> orderChangeStatusDailyChallenge( + @Parameter(hidden = true) final Long userId, + final String os, + final FinishedDailyChallengeStatusListRequest request + ); } diff --git a/src/main/java/sopt/org/hmh/domain/dailychallenge/controller/DailyChallengeController.java b/src/main/java/sopt/org/hmh/domain/dailychallenge/controller/DailyChallengeController.java index 2a30c4db..6f3c37a1 100644 --- a/src/main/java/sopt/org/hmh/domain/dailychallenge/controller/DailyChallengeController.java +++ b/src/main/java/sopt/org/hmh/domain/dailychallenge/controller/DailyChallengeController.java @@ -5,7 +5,9 @@ import org.springframework.web.bind.annotation.*; import sopt.org.hmh.domain.dailychallenge.domain.exception.DailyChallengeSuccess; import sopt.org.hmh.domain.dailychallenge.dto.request.FinishedDailyChallengeListRequest; +import sopt.org.hmh.domain.dailychallenge.dto.request.FinishedDailyChallengeStatusListRequest; import sopt.org.hmh.domain.dailychallenge.service.DailyChallengeFacade; +import sopt.org.hmh.domain.dailychallenge.service.DailyChallengeService; import sopt.org.hmh.global.auth.UserId; import sopt.org.hmh.global.common.response.BaseResponse; import sopt.org.hmh.global.common.response.EmptyJsonResponse; @@ -16,6 +18,7 @@ public class DailyChallengeController implements DailyChallengeApi { private final DailyChallengeFacade dailyChallengeFacade; + private final DailyChallengeService dailyChallengeService; @Override @PostMapping("/finish") @@ -29,4 +32,17 @@ public ResponseEntity> orderAddHistoryDailyChall .status(DailyChallengeSuccess.SEND_FINISHED_DAILY_CHALLENGE_SUCCESS.getHttpStatus()) .body(BaseResponse.success(DailyChallengeSuccess.SEND_FINISHED_DAILY_CHALLENGE_SUCCESS, new EmptyJsonResponse())); } + + @Override + @PostMapping("/success") + public ResponseEntity> orderChangeStatusDailyChallenge( + @UserId final Long userId, + @RequestHeader("OS") final String os, + @RequestBody final FinishedDailyChallengeStatusListRequest request + ) { + dailyChallengeService.changeDailyChallengeStatusByIsSuccess(userId, request); + return ResponseEntity + .status(DailyChallengeSuccess.SEND_FINISHED_DAILY_CHALLENGE_SUCCESS.getHttpStatus()) + .body(BaseResponse.success(DailyChallengeSuccess.SEND_FINISHED_DAILY_CHALLENGE_SUCCESS, new EmptyJsonResponse())); + } } \ No newline at end of file From 8395f71ab20437f3a02589648ccc0a33628b1add Mon Sep 17 00:00:00 2001 From: kseysh Date: Sun, 9 Jun 2024 23:38:46 +0900 Subject: [PATCH 16/35] =?UTF-8?q?feat=20-=20#158=20=EC=B1=8C=EB=A6=B0?= =?UTF-8?q?=EC=A7=80=20=EC=84=B1=EA=B3=B5=20=EC=97=AC=EB=B6=80=20=EC=A0=84?= =?UTF-8?q?=EC=86=A1=20request=20DTO=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FinishedDailyChallengeStatusListRequest.java | 9 +++++++++ .../request/FinishedDailyChallengeStatusRequest.java | 10 ++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/main/java/sopt/org/hmh/domain/dailychallenge/dto/request/FinishedDailyChallengeStatusListRequest.java create mode 100644 src/main/java/sopt/org/hmh/domain/dailychallenge/dto/request/FinishedDailyChallengeStatusRequest.java diff --git a/src/main/java/sopt/org/hmh/domain/dailychallenge/dto/request/FinishedDailyChallengeStatusListRequest.java b/src/main/java/sopt/org/hmh/domain/dailychallenge/dto/request/FinishedDailyChallengeStatusListRequest.java new file mode 100644 index 00000000..d5692b78 --- /dev/null +++ b/src/main/java/sopt/org/hmh/domain/dailychallenge/dto/request/FinishedDailyChallengeStatusListRequest.java @@ -0,0 +1,9 @@ +package sopt.org.hmh.domain.dailychallenge.dto.request; + +import java.util.List; + +public record FinishedDailyChallengeStatusListRequest( + List finishedDailyChallenges +) { + +} diff --git a/src/main/java/sopt/org/hmh/domain/dailychallenge/dto/request/FinishedDailyChallengeStatusRequest.java b/src/main/java/sopt/org/hmh/domain/dailychallenge/dto/request/FinishedDailyChallengeStatusRequest.java new file mode 100644 index 00000000..a2baadc0 --- /dev/null +++ b/src/main/java/sopt/org/hmh/domain/dailychallenge/dto/request/FinishedDailyChallengeStatusRequest.java @@ -0,0 +1,10 @@ +package sopt.org.hmh.domain.dailychallenge.dto.request; + +import java.time.LocalDate; + +public record FinishedDailyChallengeStatusRequest( + LocalDate challengeDate, + boolean isSuccess +) { + +} From 8fc3a7d7250cc2e5f1e2ffcf8a188afb874cf11c Mon Sep 17 00:00:00 2001 From: kseysh Date: Sun, 9 Jun 2024 23:39:06 +0900 Subject: [PATCH 17/35] =?UTF-8?q?feat=20-=20#158=20=EC=B1=8C=EB=A6=B0?= =?UTF-8?q?=EC=A7=80=20=EC=84=B1=EA=B3=B5=20=EC=97=AC=EB=B6=80=20=EC=A0=84?= =?UTF-8?q?=EC=86=A1=20service=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/DailyChallengeService.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/sopt/org/hmh/domain/dailychallenge/service/DailyChallengeService.java b/src/main/java/sopt/org/hmh/domain/dailychallenge/service/DailyChallengeService.java index 3134f88d..a9e264cd 100644 --- a/src/main/java/sopt/org/hmh/domain/dailychallenge/service/DailyChallengeService.java +++ b/src/main/java/sopt/org/hmh/domain/dailychallenge/service/DailyChallengeService.java @@ -1,6 +1,7 @@ package sopt.org.hmh.domain.dailychallenge.service; import java.time.LocalDate; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -8,6 +9,7 @@ import sopt.org.hmh.domain.dailychallenge.domain.Status; import sopt.org.hmh.domain.dailychallenge.domain.exception.DailyChallengeError; import sopt.org.hmh.domain.dailychallenge.domain.exception.DailyChallengeException; +import sopt.org.hmh.domain.dailychallenge.dto.request.FinishedDailyChallengeStatusListRequest; import sopt.org.hmh.domain.dailychallenge.repository.DailyChallengeRepository; @Service @@ -22,10 +24,13 @@ public DailyChallenge findByChallengeDateAndUserIdOrThrowException(LocalDate cha .orElseThrow(() -> new DailyChallengeException(DailyChallengeError.DAILY_CHALLENGE_NOT_FOUND)); } - public void validateDailyChallengeStatus(DailyChallenge dailyChallenge, Status expected) { - if (dailyChallenge.getStatus() != expected) { - throw new DailyChallengeException(DailyChallengeError.DAILY_CHALLENGE_ALREADY_PROCESSED); - } + public void validateDailyChallengeStatus(Status dailyChallengeStatus, List expectedStatuses) { + expectedStatuses.forEach(expected -> { + if (dailyChallengeStatus != expected) { + throw new DailyChallengeException(DailyChallengeError.DAILY_CHALLENGE_ALREADY_PROCESSED); + } + }); + } public void changeStatusByCurrentStatus(DailyChallenge dailyChallenge) { @@ -42,4 +47,17 @@ private void handleAlreadyProcessedDailyChallenge(DailyChallenge dailyChallenge) } throw new DailyChallengeException(DailyChallengeError.DAILY_CHALLENGE_ALREADY_PROCESSED); } + + public void changeDailyChallengeStatusByIsSuccess(Long userId, FinishedDailyChallengeStatusListRequest requests) { + requests.finishedDailyChallenges().forEach(request -> { + DailyChallenge dailyChallenge = this.findByChallengeDateAndUserIdOrThrowException(request.challengeDate(), userId); + if (request.isSuccess()) { + this.validateDailyChallengeStatus(dailyChallenge.getStatus(), List.of(Status.NONE)); + dailyChallenge.changeStatus(Status.UNEARNED); + } else { + this.validateDailyChallengeStatus(dailyChallenge.getStatus(), List.of(Status.NONE, Status.FAILURE)); + dailyChallenge.changeStatus(Status.FAILURE); + } + }); + } } \ No newline at end of file From 611dbff8a0650eccdca89038172b2b36d408ad31 Mon Sep 17 00:00:00 2001 From: kseysh Date: Sun, 9 Jun 2024 23:39:22 +0900 Subject: [PATCH 18/35] =?UTF-8?q?refactor=20-=20#158=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/sopt/org/hmh/domain/point/service/PointFacade.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/sopt/org/hmh/domain/point/service/PointFacade.java b/src/main/java/sopt/org/hmh/domain/point/service/PointFacade.java index 26cf8b05..18027788 100644 --- a/src/main/java/sopt/org/hmh/domain/point/service/PointFacade.java +++ b/src/main/java/sopt/org/hmh/domain/point/service/PointFacade.java @@ -1,9 +1,7 @@ package sopt.org.hmh.domain.point.service; import java.time.LocalDate; -import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -31,7 +29,7 @@ public UsePointResponse usePointAndChallengeFailed(Long userId, LocalDate challe DailyChallenge dailyChallenge = dailyChallengeService.findByChallengeDateAndUserIdOrThrowException(challengeDate, userId); User user = userService.findByIdOrThrowException(userId); - dailyChallengeService.validateDailyChallengeStatus(dailyChallenge, Status.NONE); + dailyChallengeService.validateDailyChallengeStatus(dailyChallenge.getStatus(), List.of(Status.NONE)); dailyChallenge.changeStatus(Status.FAILURE); return new UsePointResponse( @@ -44,7 +42,7 @@ public EarnPointResponse earnPointAndChallengeEarned(Long userId, LocalDate chal DailyChallenge dailyChallenge = dailyChallengeService.findByChallengeDateAndUserIdOrThrowException(challengeDate, userId); User user = userService.findByIdOrThrowException(userId); - dailyChallengeService.validateDailyChallengeStatus(dailyChallenge, Status.UNEARNED); + dailyChallengeService.validateDailyChallengeStatus(dailyChallenge.getStatus(), List.of(Status.UNEARNED)); dailyChallenge.changeStatus(Status.EARNED); return new EarnPointResponse( From 88c34cc2e8e4296524a625340689430846a23438 Mon Sep 17 00:00:00 2001 From: kseysh Date: Mon, 10 Jun 2024 00:51:47 +0900 Subject: [PATCH 19/35] =?UTF-8?q?fix=20-=20#158=20status=20validate=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/DailyChallengeService.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/sopt/org/hmh/domain/dailychallenge/service/DailyChallengeService.java b/src/main/java/sopt/org/hmh/domain/dailychallenge/service/DailyChallengeService.java index a9e264cd..bf8a48ca 100644 --- a/src/main/java/sopt/org/hmh/domain/dailychallenge/service/DailyChallengeService.java +++ b/src/main/java/sopt/org/hmh/domain/dailychallenge/service/DailyChallengeService.java @@ -25,12 +25,17 @@ public DailyChallenge findByChallengeDateAndUserIdOrThrowException(LocalDate cha } public void validateDailyChallengeStatus(Status dailyChallengeStatus, List expectedStatuses) { - expectedStatuses.forEach(expected -> { - if (dailyChallengeStatus != expected) { - throw new DailyChallengeException(DailyChallengeError.DAILY_CHALLENGE_ALREADY_PROCESSED); + boolean isAlreadyProcessed = true; + for (Status expected : expectedStatuses) { + if (dailyChallengeStatus == expected) { + isAlreadyProcessed = false; + break; } - }); + } + if (isAlreadyProcessed) { + throw new DailyChallengeException(DailyChallengeError.DAILY_CHALLENGE_ALREADY_PROCESSED); + } } public void changeStatusByCurrentStatus(DailyChallenge dailyChallenge) { From 9580701142b8cb24642e850cea740856121b2031 Mon Sep 17 00:00:00 2001 From: kseysh Date: Tue, 11 Jun 2024 23:27:07 +0900 Subject: [PATCH 20/35] =?UTF-8?q?fix=20-=20#155=20=EC=B1=8C=EB=A6=B0?= =?UTF-8?q?=EC=A7=80=20=EC=B5=9C=EC=86=8C=20=EC=8B=9C=EA=B0=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/hmh/domain/challenge/domain/ChallengeConstants.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/sopt/org/hmh/domain/challenge/domain/ChallengeConstants.java b/src/main/java/sopt/org/hmh/domain/challenge/domain/ChallengeConstants.java index 55da8024..3696732d 100644 --- a/src/main/java/sopt/org/hmh/domain/challenge/domain/ChallengeConstants.java +++ b/src/main/java/sopt/org/hmh/domain/challenge/domain/ChallengeConstants.java @@ -5,8 +5,8 @@ @NoArgsConstructor(access = AccessLevel.PRIVATE) public abstract class ChallengeConstants { - public static final Long MINIMUM_GOAL_TIME = 7200000L; - public static final Long MAXIMUM_GOAL_TIME = 21600000L; + public static final Long MINIMUM_GOAL_TIME = 0L; + public static final Long MAXIMUM_GOAL_TIME = 21_600_000L; public static final Integer USAGE_POINT = 100; public static final Integer EARNED_POINT = 20; From 8bfde54e7e7b5a19a87a7c203b1d0b07816e3867 Mon Sep 17 00:00:00 2001 From: kseysh Date: Tue, 11 Jun 2024 23:46:55 +0900 Subject: [PATCH 21/35] =?UTF-8?q?fix=20-=20#155=20=EC=B1=8C=EB=A6=B0?= =?UTF-8?q?=EC=A7=80=20=EC=B5=9C=EC=86=8C=20=EC=8B=9C=EA=B0=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/hmh/domain/challenge/domain/ChallengeConstants.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/sopt/org/hmh/domain/challenge/domain/ChallengeConstants.java b/src/main/java/sopt/org/hmh/domain/challenge/domain/ChallengeConstants.java index 3696732d..d12eb0c3 100644 --- a/src/main/java/sopt/org/hmh/domain/challenge/domain/ChallengeConstants.java +++ b/src/main/java/sopt/org/hmh/domain/challenge/domain/ChallengeConstants.java @@ -5,8 +5,8 @@ @NoArgsConstructor(access = AccessLevel.PRIVATE) public abstract class ChallengeConstants { - public static final Long MINIMUM_GOAL_TIME = 0L; - public static final Long MAXIMUM_GOAL_TIME = 21_600_000L; + public static final Long MINIMUM_GOAL_TIME = 3_600_000L; // 1시간 + public static final Long MAXIMUM_GOAL_TIME = 21_600_000L; // 6시간 public static final Integer USAGE_POINT = 100; public static final Integer EARNED_POINT = 20; From 79a9dbe226f6377c795bf32d0d381636ec72059f Mon Sep 17 00:00:00 2001 From: kseysh Date: Thu, 13 Jun 2024 15:47:37 +0900 Subject: [PATCH 22/35] =?UTF-8?q?refactor=20-=20#164=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=ED=95=84=EB=93=9C=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/sopt/org/hmh/domain/challenge/domain/Challenge.java | 3 --- .../org/hmh/domain/challenge/service/ChallengeService.java | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/main/java/sopt/org/hmh/domain/challenge/domain/Challenge.java b/src/main/java/sopt/org/hmh/domain/challenge/domain/Challenge.java index 70931e99..a4ab2e9e 100644 --- a/src/main/java/sopt/org/hmh/domain/challenge/domain/Challenge.java +++ b/src/main/java/sopt/org/hmh/domain/challenge/domain/Challenge.java @@ -26,8 +26,6 @@ public class Challenge extends BaseTimeEntity { private Integer period; private Long goalTime; - private boolean isChallengeFailedToday; - @OneToMany(mappedBy = "challenge", cascade = CascadeType.REMOVE, orphanRemoval = true) private List apps = new ArrayList<>(); @@ -39,7 +37,6 @@ private Challenge(Integer period, Long userId, Long goalTime, List this.period = period; this.userId = userId; this.goalTime = goalTime; - this.isChallengeFailedToday = false; this.apps = apps; } } \ No newline at end of file diff --git a/src/main/java/sopt/org/hmh/domain/challenge/service/ChallengeService.java b/src/main/java/sopt/org/hmh/domain/challenge/service/ChallengeService.java index 5e08363f..c1761772 100644 --- a/src/main/java/sopt/org/hmh/domain/challenge/service/ChallengeService.java +++ b/src/main/java/sopt/org/hmh/domain/challenge/service/ChallengeService.java @@ -100,9 +100,6 @@ public DailyChallengeResponse getDailyChallenge(Long userId) { Challenge challenge = findCurrentChallengeByUserId(userId); return DailyChallengeResponse.builder() - .status(Boolean.TRUE.equals(challenge.isChallengeFailedToday()) - ? Status.FAILURE - : Status.NONE) .goalTime(challenge.getGoalTime()) .apps(challenge.getApps().stream() .map(app -> new ChallengeAppResponse(app.getAppCode(), app.getGoalTime())).toList()) From b1a5a61cb2d615099643922e717fcf6fa2250571 Mon Sep 17 00:00:00 2001 From: kseysh Date: Thu, 13 Jun 2024 15:51:04 +0900 Subject: [PATCH 23/35] =?UTF-8?q?refactor=20-=20#166=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/org/hmh/domain/challenge/service/ChallengeService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/sopt/org/hmh/domain/challenge/service/ChallengeService.java b/src/main/java/sopt/org/hmh/domain/challenge/service/ChallengeService.java index c1761772..628589bd 100644 --- a/src/main/java/sopt/org/hmh/domain/challenge/service/ChallengeService.java +++ b/src/main/java/sopt/org/hmh/domain/challenge/service/ChallengeService.java @@ -20,7 +20,6 @@ import sopt.org.hmh.domain.challenge.dto.response.DailyChallengeResponse; import sopt.org.hmh.domain.challenge.repository.ChallengeRepository; import sopt.org.hmh.domain.dailychallenge.domain.DailyChallenge; -import sopt.org.hmh.domain.dailychallenge.domain.Status; import sopt.org.hmh.domain.dailychallenge.repository.DailyChallengeRepository; import sopt.org.hmh.domain.user.domain.User; import sopt.org.hmh.domain.user.service.UserService; From 45a121d1d31e214776d518e4fdaeec6368cf5435 Mon Sep 17 00:00:00 2001 From: kseysh Date: Thu, 13 Jun 2024 16:14:35 +0900 Subject: [PATCH 24/35] =?UTF-8?q?feat=20-=20#166=20User=20=EB=8F=84?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=EC=97=90=20=EC=B5=9C=EA=B7=BC=20=EC=9E=A0?= =?UTF-8?q?=EA=B8=88=20=EB=82=A0=EC=A7=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/sopt/org/hmh/domain/user/domain/User.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/sopt/org/hmh/domain/user/domain/User.java b/src/main/java/sopt/org/hmh/domain/user/domain/User.java index 9f92f77a..d67594a8 100644 --- a/src/main/java/sopt/org/hmh/domain/user/domain/User.java +++ b/src/main/java/sopt/org/hmh/domain/user/domain/User.java @@ -11,6 +11,7 @@ import jakarta.persistence.Id; import jakarta.persistence.Table; import jakarta.validation.constraints.Min; +import java.time.LocalDate; import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.Builder; @@ -45,6 +46,8 @@ public class User extends BaseTimeEntity { @Column(columnDefinition = "TEXT") private String profileImageUrl; + private LocalDate recentLockDate; + private boolean isDeleted = false; private LocalDateTime deletedAt; @@ -88,4 +91,8 @@ public Integer increasePoint(Integer earnedPoint) { public void changeCurrentChallengeId(Long currentChallengeId) { this.currentChallengeId = currentChallengeId; } + + public void changeRecentLockDate(LocalDate recentLockDate) { + this.recentLockDate = recentLockDate; + } } \ No newline at end of file From de1ba60e93ccbfd4d3e2e78360491ef24e15d477 Mon Sep 17 00:00:00 2001 From: kseysh Date: Thu, 13 Jun 2024 16:17:05 +0900 Subject: [PATCH 25/35] =?UTF-8?q?feat=20-=20#166=20=EC=B5=9C=EA=B7=BC=20lo?= =?UTF-8?q?ck=20=EB=82=A0=EC=A7=9C=20=EB=B3=80=EA=B2=BD=20controller=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmh/domain/user/controller/UserApi.java | 17 ++++++++++----- .../user/controller/UserController.java | 21 +++++++++++++++---- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java b/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java index d4a29939..b8685bb2 100644 --- a/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java +++ b/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java @@ -3,22 +3,29 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import org.springframework.http.ResponseEntity; -import sopt.org.hmh.global.auth.UserId; +import sopt.org.hmh.domain.user.dto.request.UserRequest.LockDateRequest; +import sopt.org.hmh.domain.user.dto.response.UserInfoResponse; import sopt.org.hmh.global.common.response.BaseResponse; +import sopt.org.hmh.global.common.response.EmptyJsonResponse; public interface UserApi { @Operation(summary = "로그아웃") - ResponseEntity> orderLogout(); + ResponseEntity> orderLogout(); @Operation(summary = "유저 정보 불러오기") - ResponseEntity> orderGetUserInfo(@UserId @Parameter(hidden = true) final Long userId); + ResponseEntity> orderGetUserInfo(@Parameter(hidden = true) final Long userId); @Operation(summary = "유저 포인트 정보 불러오기") - public ResponseEntity> orderGetUserPoint(@UserId final Long userId); + ResponseEntity> orderGetUserPoint(@Parameter(hidden = true) final Long userId); @Operation( summary = "회원 탈퇴") - ResponseEntity> orderWithdraw(@UserId @Parameter(hidden = true) final Long userId); + ResponseEntity> orderWithdraw(@Parameter(hidden = true) final Long userId); + + @Operation( + summary = "당일 잠금 여부 전송") + ResponseEntity> orderChangeRecentLockDate( + @Parameter(hidden = true) final Long userId, final LockDateRequest request); } diff --git a/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java b/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java index 86d14391..c51efa9a 100644 --- a/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java +++ b/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java @@ -5,9 +5,12 @@ import org.springframework.web.bind.annotation.DeleteMapping; 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.RequestMapping; import org.springframework.web.bind.annotation.RestController; import sopt.org.hmh.domain.user.domain.exception.UserSuccess; +import sopt.org.hmh.domain.user.dto.request.UserRequest.LockDateRequest; +import sopt.org.hmh.domain.user.dto.response.UserInfoResponse; import sopt.org.hmh.domain.user.service.UserService; import sopt.org.hmh.global.auth.UserId; import sopt.org.hmh.global.common.response.BaseResponse; @@ -22,7 +25,7 @@ public class UserController implements UserApi{ @PostMapping("/logout") @Override - public ResponseEntity> orderLogout() { + public ResponseEntity> orderLogout() { return ResponseEntity .status(UserSuccess.LOGOUT_SUCCESS.getHttpStatus()) .body(BaseResponse.success(UserSuccess.LOGOUT_SUCCESS, new EmptyJsonResponse())); @@ -30,7 +33,7 @@ public ResponseEntity> orderLogout() { @GetMapping @Override - public ResponseEntity> orderGetUserInfo(@UserId final Long userId) { + public ResponseEntity> orderGetUserInfo(@UserId final Long userId) { return ResponseEntity .status(UserSuccess.GET_USER_INFO_SUCCESS.getHttpStatus()) .body(BaseResponse.success(UserSuccess.GET_USER_INFO_SUCCESS, userService.getUserInfo(userId))); @@ -38,18 +41,28 @@ public ResponseEntity> orderGetUserInfo(@UserId final Long userI @GetMapping("/point") @Override - public ResponseEntity> orderGetUserPoint(@UserId final Long userId) { + public ResponseEntity> orderGetUserPoint(@UserId final Long userId) { return ResponseEntity .status(UserSuccess.GET_USER_POINT_SUCCESS.getHttpStatus()) .body(BaseResponse.success(UserSuccess.GET_USER_POINT_SUCCESS, userService.getUserInfo(userId).point())); } @DeleteMapping - public ResponseEntity> orderWithdraw(@UserId final Long userId) { + public ResponseEntity> orderWithdraw(@UserId final Long userId) { userService.withdraw(userId); return ResponseEntity .status(UserSuccess.WITHDRAW_SUCCESS.getHttpStatus()) .body(BaseResponse.success(UserSuccess.WITHDRAW_SUCCESS, new EmptyJsonResponse())); } + @PostMapping("/daily/lock") + @Override + public ResponseEntity> orderChangeRecentLockDate( + @UserId final Long userId, @RequestBody final LockDateRequest request) { + userService.changeRecentLockDate(userId, request.lockDate()); + return ResponseEntity + .status(UserSuccess.GET_USER_POINT_SUCCESS.getHttpStatus()) + .body(BaseResponse.success(UserSuccess.GET_USER_POINT_SUCCESS,new EmptyJsonResponse())); + } + } From 6df6ab697c6bce53fe91781fbafccf385a60d940 Mon Sep 17 00:00:00 2001 From: kseysh Date: Thu, 13 Jun 2024 16:17:49 +0900 Subject: [PATCH 26/35] =?UTF-8?q?feat=20-=20#166=20lockDateRequest=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmh/domain/user/dto/request/UserRequest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/main/java/sopt/org/hmh/domain/user/dto/request/UserRequest.java diff --git a/src/main/java/sopt/org/hmh/domain/user/dto/request/UserRequest.java b/src/main/java/sopt/org/hmh/domain/user/dto/request/UserRequest.java new file mode 100644 index 00000000..f4800444 --- /dev/null +++ b/src/main/java/sopt/org/hmh/domain/user/dto/request/UserRequest.java @@ -0,0 +1,16 @@ +package sopt.org.hmh.domain.user.dto.request; + +import java.time.LocalDate; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class UserRequest { + + public record LockDateRequest( + @DateTimeFormat(pattern = "yyyy-MM-dd") + LocalDate lockDate + ) { + } +} From f85791065031731476a7ad9ec2b1fc4be0ecf29c Mon Sep 17 00:00:00 2001 From: kseysh Date: Thu, 13 Jun 2024 16:18:07 +0900 Subject: [PATCH 27/35] =?UTF-8?q?feat=20-=20#166=20lockDate=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20service=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/sopt/org/hmh/domain/user/service/UserService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/sopt/org/hmh/domain/user/service/UserService.java b/src/main/java/sopt/org/hmh/domain/user/service/UserService.java index fdca204f..d8fb75ae 100644 --- a/src/main/java/sopt/org/hmh/domain/user/service/UserService.java +++ b/src/main/java/sopt/org/hmh/domain/user/service/UserService.java @@ -1,5 +1,6 @@ package sopt.org.hmh.domain.user.service; +import java.time.LocalDate; import java.util.List; import java.util.Optional; @@ -100,4 +101,8 @@ public Long getCurrentChallengeIdByUserId(Long userId) { return Optional.ofNullable(this.findByIdOrThrowException(userId).getCurrentChallengeId()) .orElseThrow(() -> new UserException(UserError.NOT_FOUND_CURRENT_CHALLENGE_ID)); } + + public void changeRecentLockDate(Long userId, LocalDate localDate) { + this.findByIdOrThrowException(userId).changeRecentLockDate(localDate); + } } \ No newline at end of file From 7e21c2675b6e649772a3244ddd790f5f468667a2 Mon Sep 17 00:00:00 2001 From: kseysh Date: Thu, 13 Jun 2024 16:32:02 +0900 Subject: [PATCH 28/35] =?UTF-8?q?feat=20-=20#166=20userResponse=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=97=AC=EB=9F=AC=20response=EB=A5=BC=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmh/domain/user/controller/UserApi.java | 16 ++++++++---- .../user/dto/response/UserInfoResponse.java | 15 ----------- .../user/dto/response/UserResponse.java | 26 +++++++++++++++++++ 3 files changed, 37 insertions(+), 20 deletions(-) delete mode 100644 src/main/java/sopt/org/hmh/domain/user/dto/response/UserInfoResponse.java create mode 100644 src/main/java/sopt/org/hmh/domain/user/dto/response/UserResponse.java diff --git a/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java b/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java index b8685bb2..c246007e 100644 --- a/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java +++ b/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java @@ -3,8 +3,12 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestBody; +import sopt.org.hmh.domain.user.dto.request.UserRequest.LockCheckDateRequest; import sopt.org.hmh.domain.user.dto.request.UserRequest.LockDateRequest; -import sopt.org.hmh.domain.user.dto.response.UserInfoResponse; +import sopt.org.hmh.domain.user.dto.response.UserResponse.IsLockTodayResponse; +import sopt.org.hmh.domain.user.dto.response.UserResponse.UserInfoResponse; +import sopt.org.hmh.global.auth.UserId; import sopt.org.hmh.global.common.response.BaseResponse; import sopt.org.hmh.global.common.response.EmptyJsonResponse; @@ -19,13 +23,15 @@ public interface UserApi { @Operation(summary = "유저 포인트 정보 불러오기") ResponseEntity> orderGetUserPoint(@Parameter(hidden = true) final Long userId); - @Operation( - summary = "회원 탈퇴") + @Operation(summary = "회원 탈퇴") ResponseEntity> orderWithdraw(@Parameter(hidden = true) final Long userId); - @Operation( - summary = "당일 잠금 여부 전송") + @Operation(summary = "당일 잠금 여부 전송") ResponseEntity> orderChangeRecentLockDate( @Parameter(hidden = true) final Long userId, final LockDateRequest request); + @Operation(summary = "당일 잠금 여부 확인") + ResponseEntity> orderGetRecentLockDate( + @UserId final Long userId, @RequestBody final LockCheckDateRequest request); + } diff --git a/src/main/java/sopt/org/hmh/domain/user/dto/response/UserInfoResponse.java b/src/main/java/sopt/org/hmh/domain/user/dto/response/UserInfoResponse.java deleted file mode 100644 index 0cf207b8..00000000 --- a/src/main/java/sopt/org/hmh/domain/user/dto/response/UserInfoResponse.java +++ /dev/null @@ -1,15 +0,0 @@ -package sopt.org.hmh.domain.user.dto.response; - -import sopt.org.hmh.domain.user.domain.User; - -public record UserInfoResponse( - String name, - Integer point -) { - public static UserInfoResponse of(User user) { - return new UserInfoResponse( - user.getName(), - user.getPoint() - ); - } -} \ No newline at end of file diff --git a/src/main/java/sopt/org/hmh/domain/user/dto/response/UserResponse.java b/src/main/java/sopt/org/hmh/domain/user/dto/response/UserResponse.java new file mode 100644 index 00000000..e91748a0 --- /dev/null +++ b/src/main/java/sopt/org/hmh/domain/user/dto/response/UserResponse.java @@ -0,0 +1,26 @@ +package sopt.org.hmh.domain.user.dto.response; + +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import sopt.org.hmh.domain.user.domain.User; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class UserResponse { + + public record UserInfoResponse( + String name, + Integer point + ) { + public static UserInfoResponse of(User user) { + return new UserInfoResponse( + user.getName(), + user.getPoint() + ); + } + } + + public record IsLockTodayResponse( + boolean isLockToday + ) { + } +} From ca52647782adfadd1f8e9b18cdd68e9705939edc Mon Sep 17 00:00:00 2001 From: kseysh Date: Thu, 13 Jun 2024 16:32:21 +0900 Subject: [PATCH 29/35] =?UTF-8?q?feat=20-=20#166=20=EB=8B=B9=EC=9D=BC=20?= =?UTF-8?q?=EC=9E=A0=EA=B8=88=20=EC=97=AC=EB=B6=80=20=ED=99=95=EC=9D=B8=20?= =?UTF-8?q?controller=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/controller/UserController.java | 21 +++++++++++++++---- .../domain/user/dto/request/UserRequest.java | 6 ++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java b/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java index c51efa9a..2bb8991f 100644 --- a/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java +++ b/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java @@ -9,8 +9,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import sopt.org.hmh.domain.user.domain.exception.UserSuccess; +import sopt.org.hmh.domain.user.dto.request.UserRequest.LockCheckDateRequest; import sopt.org.hmh.domain.user.dto.request.UserRequest.LockDateRequest; -import sopt.org.hmh.domain.user.dto.response.UserInfoResponse; +import sopt.org.hmh.domain.user.dto.response.UserResponse.IsLockTodayResponse; +import sopt.org.hmh.domain.user.dto.response.UserResponse.UserInfoResponse; import sopt.org.hmh.domain.user.service.UserService; import sopt.org.hmh.global.auth.UserId; import sopt.org.hmh.global.common.response.BaseResponse; @@ -19,7 +21,7 @@ @RestController @RequiredArgsConstructor @RequestMapping("/api/v1/user") -public class UserController implements UserApi{ +public class UserController implements UserApi { private final UserService userService; @@ -44,7 +46,8 @@ public ResponseEntity> orderGetUserInfo(@UserId f public ResponseEntity> orderGetUserPoint(@UserId final Long userId) { return ResponseEntity .status(UserSuccess.GET_USER_POINT_SUCCESS.getHttpStatus()) - .body(BaseResponse.success(UserSuccess.GET_USER_POINT_SUCCESS, userService.getUserInfo(userId).point())); + .body(BaseResponse.success(UserSuccess.GET_USER_POINT_SUCCESS, + userService.getUserInfo(userId).point())); } @DeleteMapping @@ -62,7 +65,17 @@ public ResponseEntity> orderChangeRecentLockDate userService.changeRecentLockDate(userId, request.lockDate()); return ResponseEntity .status(UserSuccess.GET_USER_POINT_SUCCESS.getHttpStatus()) - .body(BaseResponse.success(UserSuccess.GET_USER_POINT_SUCCESS,new EmptyJsonResponse())); + .body(BaseResponse.success(UserSuccess.GET_USER_POINT_SUCCESS, new EmptyJsonResponse())); + } + + @GetMapping("/daily/lock") + @Override + public ResponseEntity> orderGetRecentLockDate( + @UserId final Long userId, @RequestBody final LockCheckDateRequest request) { + return ResponseEntity + .status(UserSuccess.GET_USER_POINT_SUCCESS.getHttpStatus()) + .body(BaseResponse.success(UserSuccess.GET_USER_POINT_SUCCESS, + userService.checkIsTodayLock(userId, request.lockCheckDate()))); } } diff --git a/src/main/java/sopt/org/hmh/domain/user/dto/request/UserRequest.java b/src/main/java/sopt/org/hmh/domain/user/dto/request/UserRequest.java index f4800444..1aca1ac0 100644 --- a/src/main/java/sopt/org/hmh/domain/user/dto/request/UserRequest.java +++ b/src/main/java/sopt/org/hmh/domain/user/dto/request/UserRequest.java @@ -13,4 +13,10 @@ public record LockDateRequest( LocalDate lockDate ) { } + + public record LockCheckDateRequest( + @DateTimeFormat(pattern = "yyyy-MM-dd") + LocalDate lockCheckDate + ) { + } } From 15da16ff72c7529cfad897eaae460c23f2de6bcf Mon Sep 17 00:00:00 2001 From: kseysh Date: Thu, 13 Jun 2024 16:32:33 +0900 Subject: [PATCH 30/35] =?UTF-8?q?feat=20-=20#166=20=EB=8B=B9=EC=9D=BC=20?= =?UTF-8?q?=EC=9E=A0=EA=B8=88=20=EC=97=AC=EB=B6=80=20=ED=99=95=EC=9D=B8=20?= =?UTF-8?q?service=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/sopt/org/hmh/domain/user/service/UserService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/sopt/org/hmh/domain/user/service/UserService.java b/src/main/java/sopt/org/hmh/domain/user/service/UserService.java index d8fb75ae..efb75903 100644 --- a/src/main/java/sopt/org/hmh/domain/user/service/UserService.java +++ b/src/main/java/sopt/org/hmh/domain/user/service/UserService.java @@ -19,7 +19,8 @@ import sopt.org.hmh.domain.user.domain.UserConstants; import sopt.org.hmh.domain.user.domain.exception.UserError; import sopt.org.hmh.domain.user.domain.exception.UserException; -import sopt.org.hmh.domain.user.dto.response.UserInfoResponse; +import sopt.org.hmh.domain.user.dto.response.UserResponse.IsLockTodayResponse; +import sopt.org.hmh.domain.user.dto.response.UserResponse.UserInfoResponse; import sopt.org.hmh.domain.user.repository.UserRepository; import sopt.org.hmh.global.auth.social.SocialPlatform; @@ -105,4 +106,8 @@ public Long getCurrentChallengeIdByUserId(Long userId) { public void changeRecentLockDate(Long userId, LocalDate localDate) { this.findByIdOrThrowException(userId).changeRecentLockDate(localDate); } + + public IsLockTodayResponse checkIsTodayLock(Long userId, LocalDate lockCheckDate) { + return new IsLockTodayResponse(this.findByIdOrThrowException(userId).getRecentLockDate().equals(lockCheckDate)); + } } \ No newline at end of file From 5a81b52e2ffe4bf27454079e2200f9f32da4feed Mon Sep 17 00:00:00 2001 From: kseysh Date: Thu, 13 Jun 2024 16:37:16 +0900 Subject: [PATCH 31/35] =?UTF-8?q?feat=20-=20#166=20=EB=8B=B9=EC=9D=BC=20?= =?UTF-8?q?=EC=9E=A0=EA=B8=88=20=EC=97=AC=EB=B6=80=20response=20message=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/hmh/domain/user/controller/UserController.java | 8 ++++---- .../org/hmh/domain/user/domain/exception/UserSuccess.java | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java b/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java index 2bb8991f..95d750ed 100644 --- a/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java +++ b/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java @@ -64,8 +64,8 @@ public ResponseEntity> orderChangeRecentLockDate @UserId final Long userId, @RequestBody final LockDateRequest request) { userService.changeRecentLockDate(userId, request.lockDate()); return ResponseEntity - .status(UserSuccess.GET_USER_POINT_SUCCESS.getHttpStatus()) - .body(BaseResponse.success(UserSuccess.GET_USER_POINT_SUCCESS, new EmptyJsonResponse())); + .status(UserSuccess.CHANGE_RECENT_LOCK_DATE_SUCCESS.getHttpStatus()) + .body(BaseResponse.success(UserSuccess.CHANGE_RECENT_LOCK_DATE_SUCCESS, new EmptyJsonResponse())); } @GetMapping("/daily/lock") @@ -73,8 +73,8 @@ public ResponseEntity> orderChangeRecentLockDate public ResponseEntity> orderGetRecentLockDate( @UserId final Long userId, @RequestBody final LockCheckDateRequest request) { return ResponseEntity - .status(UserSuccess.GET_USER_POINT_SUCCESS.getHttpStatus()) - .body(BaseResponse.success(UserSuccess.GET_USER_POINT_SUCCESS, + .status(UserSuccess.GET_RECENT_LOCK_DATE_SUCCESS.getHttpStatus()) + .body(BaseResponse.success(UserSuccess.GET_RECENT_LOCK_DATE_SUCCESS, userService.checkIsTodayLock(userId, request.lockCheckDate()))); } diff --git a/src/main/java/sopt/org/hmh/domain/user/domain/exception/UserSuccess.java b/src/main/java/sopt/org/hmh/domain/user/domain/exception/UserSuccess.java index afd35fb3..8f2c3757 100644 --- a/src/main/java/sopt/org/hmh/domain/user/domain/exception/UserSuccess.java +++ b/src/main/java/sopt/org/hmh/domain/user/domain/exception/UserSuccess.java @@ -12,6 +12,8 @@ public enum UserSuccess implements SuccessBase { GET_USER_POINT_SUCCESS(HttpStatus.OK, "유저의 포인트 정보를 불러오는데에 성공했습니다."), LOGOUT_SUCCESS(HttpStatus.OK, "로그아웃에 성공했습니다."), WITHDRAW_SUCCESS(HttpStatus.OK, "회원 탈퇴를 성공하였습니다."), + CHANGE_RECENT_LOCK_DATE_SUCCESS(HttpStatus.OK, "당일 잠금 여부 전송에 성공했습니다."), + GET_RECENT_LOCK_DATE_SUCCESS(HttpStatus.OK, "당일 잠금 여부 확인에 성공했습니다."), ; private final HttpStatus status; From 856245e521f112f847728615c307b619c5d8922f Mon Sep 17 00:00:00 2001 From: kseysh Date: Thu, 13 Jun 2024 17:11:04 +0900 Subject: [PATCH 32/35] =?UTF-8?q?feat=20-=20#166=20GET=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=EC=97=90=EC=84=9C=20param=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EB=B0=9B=EC=9D=84=20=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/org/hmh/domain/user/controller/UserApi.java | 6 ++---- .../org/hmh/domain/user/controller/UserController.java | 9 ++++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java b/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java index c246007e..e390f419 100644 --- a/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java +++ b/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java @@ -2,13 +2,11 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import java.time.LocalDate; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestBody; -import sopt.org.hmh.domain.user.dto.request.UserRequest.LockCheckDateRequest; import sopt.org.hmh.domain.user.dto.request.UserRequest.LockDateRequest; import sopt.org.hmh.domain.user.dto.response.UserResponse.IsLockTodayResponse; import sopt.org.hmh.domain.user.dto.response.UserResponse.UserInfoResponse; -import sopt.org.hmh.global.auth.UserId; import sopt.org.hmh.global.common.response.BaseResponse; import sopt.org.hmh.global.common.response.EmptyJsonResponse; @@ -32,6 +30,6 @@ ResponseEntity> orderChangeRecentLockDate( @Operation(summary = "당일 잠금 여부 확인") ResponseEntity> orderGetRecentLockDate( - @UserId final Long userId, @RequestBody final LockCheckDateRequest request); + @Parameter(hidden = true) final Long userId, final LocalDate lockCheckDate); } diff --git a/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java b/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java index 95d750ed..31a91495 100644 --- a/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java +++ b/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java @@ -1,15 +1,17 @@ package sopt.org.hmh.domain.user.controller; +import java.time.LocalDate; import lombok.RequiredArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; 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.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import sopt.org.hmh.domain.user.domain.exception.UserSuccess; -import sopt.org.hmh.domain.user.dto.request.UserRequest.LockCheckDateRequest; import sopt.org.hmh.domain.user.dto.request.UserRequest.LockDateRequest; import sopt.org.hmh.domain.user.dto.response.UserResponse.IsLockTodayResponse; import sopt.org.hmh.domain.user.dto.response.UserResponse.UserInfoResponse; @@ -71,11 +73,12 @@ public ResponseEntity> orderChangeRecentLockDate @GetMapping("/daily/lock") @Override public ResponseEntity> orderGetRecentLockDate( - @UserId final Long userId, @RequestBody final LockCheckDateRequest request) { + @UserId final Long userId, + @RequestParam(name = "lockCheckDate") @DateTimeFormat(pattern = "yyyy-MM-dd") final LocalDate lockCheckDate) { return ResponseEntity .status(UserSuccess.GET_RECENT_LOCK_DATE_SUCCESS.getHttpStatus()) .body(BaseResponse.success(UserSuccess.GET_RECENT_LOCK_DATE_SUCCESS, - userService.checkIsTodayLock(userId, request.lockCheckDate()))); + userService.checkIsTodayLock(userId, lockCheckDate))); } } From 933afe50ae2a6963084d3e90ff715cf158e59fc9 Mon Sep 17 00:00:00 2001 From: kseysh Date: Thu, 13 Jun 2024 17:11:13 +0900 Subject: [PATCH 33/35] =?UTF-8?q?feat=20-=20#166=20GET=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=EC=97=90=EC=84=9C=20param=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EB=B0=9B=EC=9D=84=20=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/org/hmh/domain/user/dto/request/UserRequest.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/sopt/org/hmh/domain/user/dto/request/UserRequest.java b/src/main/java/sopt/org/hmh/domain/user/dto/request/UserRequest.java index 1aca1ac0..21dbce75 100644 --- a/src/main/java/sopt/org/hmh/domain/user/dto/request/UserRequest.java +++ b/src/main/java/sopt/org/hmh/domain/user/dto/request/UserRequest.java @@ -14,9 +14,4 @@ public record LockDateRequest( ) { } - public record LockCheckDateRequest( - @DateTimeFormat(pattern = "yyyy-MM-dd") - LocalDate lockCheckDate - ) { - } } From f4c749eee1964cbdf2a05739c2ade5fb73886ad0 Mon Sep 17 00:00:00 2001 From: kseysh Date: Thu, 13 Jun 2024 17:11:42 +0900 Subject: [PATCH 34/35] =?UTF-8?q?feat=20-=20#166=20userRecentLockDate?= =?UTF-8?q?=EA=B0=80=20null=EC=9D=BC=20=EB=95=8C=20validate=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/org/hmh/domain/user/service/UserService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/sopt/org/hmh/domain/user/service/UserService.java b/src/main/java/sopt/org/hmh/domain/user/service/UserService.java index efb75903..54466c4d 100644 --- a/src/main/java/sopt/org/hmh/domain/user/service/UserService.java +++ b/src/main/java/sopt/org/hmh/domain/user/service/UserService.java @@ -103,11 +103,18 @@ public Long getCurrentChallengeIdByUserId(Long userId) { .orElseThrow(() -> new UserException(UserError.NOT_FOUND_CURRENT_CHALLENGE_ID)); } + @Transactional public void changeRecentLockDate(Long userId, LocalDate localDate) { this.findByIdOrThrowException(userId).changeRecentLockDate(localDate); } public IsLockTodayResponse checkIsTodayLock(Long userId, LocalDate lockCheckDate) { - return new IsLockTodayResponse(this.findByIdOrThrowException(userId).getRecentLockDate().equals(lockCheckDate)); + LocalDate userRecentLockDate = this.findByIdOrThrowException(userId).getRecentLockDate(); + + if (userRecentLockDate == null) { + return new IsLockTodayResponse(false); + } + + return new IsLockTodayResponse(userRecentLockDate.equals(lockCheckDate)); } } \ No newline at end of file From c2df7fd2d5ec231e06c9c79430adf02c77ad047b Mon Sep 17 00:00:00 2001 From: kseysh Date: Thu, 13 Jun 2024 17:20:08 +0900 Subject: [PATCH 35/35] =?UTF-8?q?feat=20-=20#166=20LocalDateRequest?= =?UTF-8?q?=EA=B0=80=20null=EC=9D=BC=20=EB=95=8C=20validate=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/org/hmh/domain/user/controller/UserController.java | 3 ++- .../java/sopt/org/hmh/domain/user/dto/request/UserRequest.java | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java b/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java index 31a91495..9e5d80f9 100644 --- a/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java +++ b/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java @@ -1,5 +1,6 @@ package sopt.org.hmh.domain.user.controller; +import jakarta.validation.Valid; import java.time.LocalDate; import lombok.RequiredArgsConstructor; import org.springframework.format.annotation.DateTimeFormat; @@ -63,7 +64,7 @@ public ResponseEntity> orderWithdraw(@UserId fin @PostMapping("/daily/lock") @Override public ResponseEntity> orderChangeRecentLockDate( - @UserId final Long userId, @RequestBody final LockDateRequest request) { + @UserId final Long userId, @Valid @RequestBody final LockDateRequest request) { userService.changeRecentLockDate(userId, request.lockDate()); return ResponseEntity .status(UserSuccess.CHANGE_RECENT_LOCK_DATE_SUCCESS.getHttpStatus()) diff --git a/src/main/java/sopt/org/hmh/domain/user/dto/request/UserRequest.java b/src/main/java/sopt/org/hmh/domain/user/dto/request/UserRequest.java index 21dbce75..3a3f9bbc 100644 --- a/src/main/java/sopt/org/hmh/domain/user/dto/request/UserRequest.java +++ b/src/main/java/sopt/org/hmh/domain/user/dto/request/UserRequest.java @@ -1,5 +1,6 @@ package sopt.org.hmh.domain.user.dto.request; +import jakarta.validation.constraints.NotNull; import java.time.LocalDate; import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -10,6 +11,7 @@ public class UserRequest { public record LockDateRequest( @DateTimeFormat(pattern = "yyyy-MM-dd") + @NotNull(message = "잠금 날짜는 null일 수 없습니다.") LocalDate lockDate ) { }