Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy - main <- develop #168

Merged
merged 44 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1849e19
deploy - #145 codedeploy shell script ํ™˜๊ฒฝ ๋ถ„๋ฆฌ
kseysh May 29, 2024
262e255
deploy - #145 ci ํ”Œ๋กœ์šฐ ๋ถ„๋ฆฌ
kseysh May 29, 2024
466674c
Merge pull request #148 from Team-HMH/deploy/#145-build-prod-server
kseysh May 29, 2024
ee49c71
modify - #123 RedisManagerService ์‚ญ์ œ
kseysh May 30, 2024
0976ed9
modify - #123 redis repository ์‚ญ์ œ
kseysh May 31, 2024
b218e64
modify - #123 redis config ์‚ญ์ œ
kseysh May 31, 2024
a349d30
chore - #123 ์‚ฌ์šฉ๋˜์ง€ ์•Š๋Š” ํŒŒ์ผ ์‚ญ์ œ
kseysh May 31, 2024
e097086
docs - #123 readme ํŒŒ์ผ ๋ณ€๊ฒฝ
kseysh May 31, 2024
34c4757
refactor - #151 ์‚ฌ์šฉ๋˜์ง€ ์•Š๋Š” import๋ฌธ ์ œ๊ฑฐ
kseysh May 31, 2024
d1fc1db
fix - #151 LocalDate๋ฅผ DTO์—์„œ ๋ฐ›๋„๋ก ๋ณ€๊ฒฝ
kseysh May 31, 2024
ccc6916
Merge pull request #152 from Team-HMH/fix/#151-localdate-deserialize-โ€ฆ
kseysh May 31, 2024
1be5bb9
refactor - #153 dummy api ๊ด€๋ จ ํด๋ž˜์Šค ์ œ๊ฑฐ
kseysh May 31, 2024
64925cd
refactor - #153 SecurityConfig์—์„œ dummy api ์ œ๊ฑฐ
kseysh May 31, 2024
b416277
Merge pull request #150 from Team-HMH/modify/#123-delete-redis
kseysh Jun 8, 2024
23af87d
Merge pull request #154 from Team-HMH/refactor/#153-delete-dummy-api
kseysh Jun 8, 2024
5e99b64
fix - #155 ์•ฑ ์ตœ๋Œ€ ์‹œ๊ฐ„ ๋ณ€๊ฒฝ
kseysh Jun 8, 2024
23478a2
feat - #149 ๋ฐ›์„ ํฌ์ธํŠธ ๋ฐ˜ํ™˜ api ์ถ”๊ฐ€
kseysh Jun 9, 2024
f224357
refactor - #149 ์‚ฌ์šฉํ•  ํฌ์ธํŠธ ๋ฐ˜ํ™˜ controller์—์„œ ํ•ด๊ฒฐํ•˜๋„๋ก ์ˆ˜์ •
kseysh Jun 9, 2024
b9fa28e
feat - #158 ์ฑŒ๋ฆฐ์ง€ ์„ฑ๊ณต ์—ฌ๋ถ€ ์ „์†ก controller ๊ตฌํ˜„
kseysh Jun 9, 2024
8395f71
feat - #158 ์ฑŒ๋ฆฐ์ง€ ์„ฑ๊ณต ์—ฌ๋ถ€ ์ „์†ก request DTO ๊ตฌํ˜„
kseysh Jun 9, 2024
8fc3a7d
feat - #158 ์ฑŒ๋ฆฐ์ง€ ์„ฑ๊ณต ์—ฌ๋ถ€ ์ „์†ก service ๊ตฌํ˜„
kseysh Jun 9, 2024
611dbff
refactor - #158 ์‚ฌ์šฉ๋˜์ง€ ์•Š๋Š” import ์ œ๊ฑฐ
kseysh Jun 9, 2024
7b42e37
Merge pull request #157 from Team-HMH/feat/#149-get-earned-point-api
kseysh Jun 9, 2024
88c34cc
fix - #158 status validate ๋กœ์ง ์ˆ˜์ •
kseysh Jun 9, 2024
7c99349
Merge pull request #159 from Team-HMH/feat/#158-send-challenge-is-sucโ€ฆ
kseysh Jun 9, 2024
f2c1848
Merge pull request #156 from Team-HMH/fix/#155-modify-app-maximum-time
kseysh Jun 10, 2024
9580701
fix - #155 ์ฑŒ๋ฆฐ์ง€ ์ตœ์†Œ ์‹œ๊ฐ„ ์ˆ˜์ •
kseysh Jun 11, 2024
8bfde54
fix - #155 ์ฑŒ๋ฆฐ์ง€ ์ตœ์†Œ ์‹œ๊ฐ„ ์ˆ˜์ •
kseysh Jun 11, 2024
79a9dbe
refactor - #164 ์‚ฌ์šฉ๋˜์ง€ ์•Š๋Š” ํ•„๋“œ ์ œ๊ฑฐ
kseysh Jun 13, 2024
b1a5a61
refactor - #166 ์‚ฌ์šฉ๋˜์ง€ ์•Š๋Š” import ์ œ๊ฑฐ
kseysh Jun 13, 2024
45a121d
feat - #166 User ๋„๋ฉ”์ธ์— ์ตœ๊ทผ ์ž ๊ธˆ ๋‚ ์งœ ์ถ”๊ฐ€
kseysh Jun 13, 2024
de1ba60
feat - #166 ์ตœ๊ทผ lock ๋‚ ์งœ ๋ณ€๊ฒฝ controller ์ถ”๊ฐ€
kseysh Jun 13, 2024
6df6ab6
feat - #166 lockDateRequest ์ถ”๊ฐ€
kseysh Jun 13, 2024
f857910
feat - #166 lockDate ๋ณ€๊ฒฝ service ์ถ”๊ฐ€
kseysh Jun 13, 2024
7e21c26
feat - #166 userResponse์—์„œ ์—ฌ๋Ÿฌ response๋ฅผ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋„๋ก ๋ณ€๊ฒฝ
kseysh Jun 13, 2024
ca52647
feat - #166 ๋‹น์ผ ์ž ๊ธˆ ์—ฌ๋ถ€ ํ™•์ธ controller ๊ตฌํ˜„
kseysh Jun 13, 2024
15da16f
feat - #166 ๋‹น์ผ ์ž ๊ธˆ ์—ฌ๋ถ€ ํ™•์ธ service ๊ตฌํ˜„
kseysh Jun 13, 2024
5a81b52
feat - #166 ๋‹น์ผ ์ž ๊ธˆ ์—ฌ๋ถ€ response message ์„ค์ •
kseysh Jun 13, 2024
856245e
feat - #166 GET ๋ฉ”์„œ๋“œ์—์„œ param์œผ๋กœ ๋ฐ›์„ ์ˆ˜ ์žˆ๋„๋ก ๋ณ€๊ฒฝ
kseysh Jun 13, 2024
933afe5
feat - #166 GET ๋ฉ”์„œ๋“œ์—์„œ param์œผ๋กœ ๋ฐ›์„ ์ˆ˜ ์žˆ๋„๋ก ๋ณ€๊ฒฝ
kseysh Jun 13, 2024
f4c749e
feat - #166 userRecentLockDate๊ฐ€ null์ผ ๋•Œ validate ์ ์šฉ
kseysh Jun 13, 2024
c2df7fd
feat - #166 LocalDateRequest๊ฐ€ null์ผ ๋•Œ validate ์ ์šฉ
kseysh Jun 13, 2024
1e54d66
Merge pull request #163 from Team-HMH/fix/#155-modify-app-maximum-time
kseysh Jun 14, 2024
f219314
Merge pull request #167 from Team-HMH/feat/#166-check-day-lock-api
kseysh Jun 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/hmh-cd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: ๐Ÿญ APPLICATION-BUILD!
on:
pull_request:
branches: [ "develop" ]
push:
branches: [ "develop" ]

permissions:
contents: read
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/hmh-ci-prod.yml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 1 addition & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,34 +28,4 @@
| <img width="300" alt="image" src="https://github.com/Team-HMH/HMH-Server/assets/76610340/ea57f67f-adcb-4abc-a198-7b962e61a6bc"> | <img width="300" alt="image" src="https://github.com/SOPT-33-iOS-Team-1/SOPKATHON_33-Server/assets/86935274/b1308faa-06cb-4818-878e-aeb8e17ac14c"> |
| [jumining](https://github.com/jumining) | [kseysh](https://github.com/kseysh) |

<br/>

## โœ… Convention



### ๐Ÿš€Convention

- [๐Ÿ’ป ํ˜‘์—… ์ปจ๋ฒค์…˜](https://hmhteam.notion.site/6fa22000670d4cf783559f7808c01d1a?pvs=4) <br>

### ๐Ÿš€ Branch Strategy

- [๐Ÿ’ป ๋ธŒ๋žœ์น˜ ์ „๋žต](https://hmhteam.notion.site/9d8065b238c543b890ceeb9912966dd0?pvs=4)

<br/>

## ๐Ÿ’พ ERD

![image](https://github.com/Team-HMH/HMH-Server/assets/69035864/f4b95b3d-6507-4d33-be41-8a4847bc076f)

<br>

<br>

## โš™๏ธ Architecture

![architecture](https://github.com/Team-HMH/HMH-Server/assets/69035864/e0eefac1-d8be-4a08-a3de-6e9786557042)


<br>

18 changes: 11 additions & 7 deletions script/start.sh
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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 </dev/null &

if [ "$DEPLOYMENT_GROUP_NAME" == "hmh-dev-deploy-group" ]
then
sudo nohup java -jar -Dspring.profiles.active=dev "$JAR_PATH" >nohup.out 2>&1 </dev/null &
fi

if [ "$DEPLOYMENT_GROUP_NAME" == "hmh-prod-deploy-group" ]
then
sudo nohup java -jar -Dspring.profiles.active=prod "$JAR_PATH" >nohup.out 2>&1 </dev/null &
fi
Empty file removed src/HMH-Server.iml
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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์‹œ๊ฐ„
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChallengeApp> apps = new ArrayList<>();

Expand All @@ -39,7 +37,6 @@ private Challenge(Integer period, Long userId, Long goalTime, List<ChallengeApp>
this.period = period;
this.userId = userId;
this.goalTime = goalTime;
this.isChallengeFailedToday = false;
this.apps = apps;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -100,9 +99,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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,6 +34,13 @@ public interface DailyChallengeApi {
ResponseEntity<BaseResponse<EmptyJsonResponse>> orderAddHistoryDailyChallenge(
@Parameter(hidden = true) final Long userId,
final String os,
final FinishedDailyChallengeListRequest request);
final FinishedDailyChallengeListRequest request
);

ResponseEntity<BaseResponse<EmptyJsonResponse>> orderChangeStatusDailyChallenge(
@Parameter(hidden = true) final Long userId,
final String os,
final FinishedDailyChallengeStatusListRequest request
);
}

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,6 +18,7 @@
public class DailyChallengeController implements DailyChallengeApi {

private final DailyChallengeFacade dailyChallengeFacade;
private final DailyChallengeService dailyChallengeService;

@Override
@PostMapping("/finish")
Expand All @@ -29,4 +32,17 @@ public ResponseEntity<BaseResponse<EmptyJsonResponse>> 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<BaseResponse<EmptyJsonResponse>> 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()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package sopt.org.hmh.domain.dailychallenge.dto.request;

import java.util.List;

public record FinishedDailyChallengeStatusListRequest(
List<FinishedDailyChallengeStatusRequest> finishedDailyChallenges
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package sopt.org.hmh.domain.dailychallenge.dto.request;

import java.time.LocalDate;

public record FinishedDailyChallengeStatusRequest(
LocalDate challengeDate,
boolean isSuccess
) {

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
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;
import sopt.org.hmh.domain.dailychallenge.domain.DailyChallenge;
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
Expand All @@ -22,8 +24,16 @@ public DailyChallenge findByChallengeDateAndUserIdOrThrowException(LocalDate cha
.orElseThrow(() -> new DailyChallengeException(DailyChallengeError.DAILY_CHALLENGE_NOT_FOUND));
}

public void validateDailyChallengeStatus(DailyChallenge dailyChallenge, Status expected) {
if (dailyChallenge.getStatus() != expected) {
public void validateDailyChallengeStatus(Status dailyChallengeStatus, List<Status> expectedStatuses) {
boolean isAlreadyProcessed = true;
for (Status expected : expectedStatuses) {
if (dailyChallengeStatus == expected) {
isAlreadyProcessed = false;
break;
}
}

if (isAlreadyProcessed) {
throw new DailyChallengeException(DailyChallengeError.DAILY_CHALLENGE_ALREADY_PROCESSED);
}
}
Expand All @@ -42,4 +52,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);
}
});
}
}
14 changes: 0 additions & 14 deletions src/main/java/sopt/org/hmh/domain/dummy/DummyApp.java

This file was deleted.

21 changes: 0 additions & 21 deletions src/main/java/sopt/org/hmh/domain/dummy/DummyAppController.java

This file was deleted.

17 changes: 0 additions & 17 deletions src/main/java/sopt/org/hmh/domain/dummy/DummyAppListResponse.java

This file was deleted.

Loading
Loading