-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from HanaFun/dev
build: 배포 확인
- Loading branch information
Showing
116 changed files
with
3,465 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: CD with Gradle | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: make application yml | ||
run: | | ||
cd ./src/main/resources | ||
touch ./application.yml | ||
echo "${{ secrets.APPLICATION_YML }}" > ./application.yml | ||
shell: bash | ||
|
||
- name: Build with Gradle | ||
run: | | ||
chmod +x ./gradlew | ||
./gradlew clean build -x test | ||
- name: Docker build & push to docker repo | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME_YUB }} -p ${{ secrets.DOCKER_PASSWORD_YUB }} | ||
docker build -f Dockerfile -t "${{ secrets.DOCKER_USERNAME_YUB }}/hanafun:latest" . | ||
docker push "${{ secrets.DOCKER_USERNAME_YUB }}/hanafun:latest" | ||
- name: Deploy to server | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.EC2_HOST }} | ||
username: ec2-user | ||
key: ${{ secrets.EC2_SSH_KEY }} | ||
script: | | ||
sudo docker ps | ||
sudo docker pull "${{ secrets.DOCKER_USERNAME_YUB }}/hanafun:latest" | ||
sudo docker stop hanafun | ||
sudo docker rm hanafun | ||
sudo docker run -d -p 8080:8080 --name hanafun "${{ secrets.DOCKER_USERNAME_YUB }}/hanafun:latest" | ||
sudo docker image prune -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM openjdk:17-jdk | ||
LABEL maintainer="yubin" | ||
ARG JAR_FILE=build/libs/*.jar | ||
ADD ${JAR_FILE} app.jar | ||
EXPOSE 8099 | ||
ENTRYPOINT ["java","-jar","/app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/com/hanaro/hanafun/account/controller/AccountController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.hanaro.hanafun.account.controller; | ||
|
||
import com.hanaro.hanafun.account.dto.AccountResDto; | ||
import com.hanaro.hanafun.account.service.impl.AccountServiceImpl; | ||
import com.hanaro.hanafun.common.dto.ApiResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/account") | ||
@RequiredArgsConstructor | ||
public class AccountController { | ||
private final AccountServiceImpl accountService; | ||
|
||
@GetMapping("/list") | ||
ResponseEntity<ApiResponse> readAccountList(@AuthenticationPrincipal Long userId){ | ||
List<AccountResDto> accountResDtoList = accountService.readAccountList(userId); | ||
return ResponseEntity.ok(new ApiResponse(true, "ok", accountResDtoList)); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/hanaro/hanafun/account/domain/AccountEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.hanaro.hanafun.account.domain; | ||
|
||
import com.hanaro.hanafun.common.domain.BaseEntity; | ||
import com.hanaro.hanafun.user.domain.UserEntity; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
@Entity | ||
@Table(name = "account") | ||
@Data | ||
@EqualsAndHashCode(callSuper = false) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class AccountEntity extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "account_id") | ||
private Long accountId; | ||
|
||
@ManyToOne(optional = false) | ||
@JoinColumn(name = "user_id", nullable = false) | ||
private UserEntity userEntity; | ||
|
||
@Column(name = "account_number", length = 20, nullable = false) | ||
private String accountNumber; | ||
|
||
@Column(name = "account_name", length = 50) | ||
private String accountName; | ||
|
||
@Column(name = "password", length = 20, nullable = false) | ||
private String password; | ||
|
||
@Column(name = "balance", nullable = false) | ||
private Integer balance; | ||
|
||
@Column(name = "qr") | ||
private String qr; | ||
|
||
@Column(name = "is_deleted", nullable = false) | ||
private Boolean isDeleted; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/hanaro/hanafun/account/domain/AccountRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.hanaro.hanafun.account.domain; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface AccountRepository extends JpaRepository<AccountEntity, Long> { | ||
Optional<List<AccountEntity>> findByUserEntityUserId(Long userId); | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/hanaro/hanafun/account/dto/AccountResDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.hanaro.hanafun.account.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class AccountResDto { | ||
private long accountId; | ||
private String accountName; | ||
private String accountNumber; | ||
private int balance; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/hanaro/hanafun/account/exception/AccountBalanceException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.hanaro.hanafun.account.exception; | ||
|
||
import com.hanaro.hanafun.common.exception.CustomException; | ||
import org.springframework.http.HttpStatus; | ||
|
||
public class AccountBalanceException extends CustomException { | ||
static String MESSAGE = "INSUFFICIENT_BALANCE"; | ||
public AccountBalanceException(){ | ||
super(MESSAGE); | ||
} | ||
@Override | ||
public HttpStatus getHttpStatus() { | ||
return HttpStatus.BAD_REQUEST; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/hanaro/hanafun/account/exception/AccountNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.hanaro.hanafun.account.exception; | ||
|
||
import com.hanaro.hanafun.common.exception.CustomException; | ||
import org.springframework.http.HttpStatus; | ||
|
||
public class AccountNotFoundException extends CustomException { | ||
static String MESSAGE = "ACCOUNT_NOT_FOUND"; | ||
|
||
public AccountNotFoundException(){ | ||
super(MESSAGE); | ||
} | ||
@Override | ||
public HttpStatus getHttpStatus() { | ||
return HttpStatus.NOT_FOUND; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/hanaro/hanafun/account/mapper/AccountMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.hanaro.hanafun.account.mapper; | ||
|
||
import com.hanaro.hanafun.account.domain.AccountEntity; | ||
import com.hanaro.hanafun.account.dto.AccountResDto; | ||
import lombok.experimental.UtilityClass; | ||
|
||
@UtilityClass | ||
public class AccountMapper { | ||
public static AccountResDto entityToAccountResDto(AccountEntity accountEntity){ | ||
if(accountEntity == null) return null; | ||
|
||
return AccountResDto.builder() | ||
.accountId(accountEntity.getAccountId()) | ||
.accountNumber(accountEntity.getAccountNumber()) | ||
.accountName(accountEntity.getAccountName()) | ||
.balance(accountEntity.getBalance()) | ||
.build(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/hanaro/hanafun/account/service/AccountService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.hanaro.hanafun.account.service; | ||
|
||
import com.hanaro.hanafun.account.dto.AccountResDto; | ||
|
||
import java.util.List; | ||
|
||
public interface AccountService { | ||
List<AccountResDto> readAccountList(Long userId); | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/hanaro/hanafun/account/service/impl/AccountServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.hanaro.hanafun.account.service.impl; | ||
|
||
import com.hanaro.hanafun.account.domain.AccountEntity; | ||
import com.hanaro.hanafun.account.domain.AccountRepository; | ||
import com.hanaro.hanafun.account.dto.AccountResDto; | ||
import com.hanaro.hanafun.account.exception.AccountNotFoundException; | ||
import com.hanaro.hanafun.account.mapper.AccountMapper; | ||
import com.hanaro.hanafun.account.service.AccountService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class AccountServiceImpl implements AccountService { | ||
private final AccountRepository accountRepository; | ||
|
||
@Override | ||
public List<AccountResDto> readAccountList(Long userId) { | ||
List<AccountEntity> accountEntityList = accountRepository.findByUserEntityUserId(userId).orElseThrow(() -> new AccountNotFoundException()); | ||
if(accountEntityList.isEmpty()){ | ||
throw new AccountNotFoundException(); | ||
} | ||
|
||
return accountEntityList.stream().map(AccountMapper::entityToAccountResDto).toList(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/hanaro/hanafun/category/controller/CategoryController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.hanaro.hanafun.category.controller; | ||
|
||
import com.hanaro.hanafun.category.dto.response.CategoryResDto; | ||
import com.hanaro.hanafun.category.service.CategoryService; | ||
import com.hanaro.hanafun.common.dto.ApiResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class CategoryController { | ||
private final CategoryService categoryService; | ||
|
||
@GetMapping("/category") | ||
public ResponseEntity<ApiResponse> categoryList() { | ||
List<CategoryResDto> categoryResDtoList = categoryService.categoryList(); | ||
return ResponseEntity.ok(new ApiResponse<>(true, "ok", categoryResDtoList)); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/hanaro/hanafun/category/domain/CategoryEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.hanaro.hanafun.category.domain; | ||
|
||
import com.hanaro.hanafun.common.domain.BaseEntity; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
@Entity | ||
@Table(name = "category") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
public class CategoryEntity extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long categoryId; | ||
|
||
@Column(nullable = false) | ||
private String categoryName; | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/hanaro/hanafun/category/domain/CategoryRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.hanaro.hanafun.category.domain; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface CategoryRepository extends JpaRepository<CategoryEntity, Long> { | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/hanaro/hanafun/category/dto/response/CategoryResDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.hanaro.hanafun.category.dto.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class CategoryResDto { | ||
private Long categoryId; | ||
private String categoryName; | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/hanaro/hanafun/category/exception/CategoryNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.hanaro.hanafun.category.exception; | ||
|
||
import com.hanaro.hanafun.common.exception.CustomException; | ||
import org.springframework.http.HttpStatus; | ||
|
||
public class CategoryNotFoundException extends CustomException { | ||
static String MESSAGE = "CATEGORY_NOT_FOUND"; | ||
|
||
public CategoryNotFoundException() { | ||
super(MESSAGE); | ||
} | ||
|
||
@Override | ||
public HttpStatus getHttpStatus() { | ||
return HttpStatus.NOT_FOUND; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/hanaro/hanafun/category/service/CategoryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.hanaro.hanafun.category.service; | ||
|
||
import com.hanaro.hanafun.category.dto.response.CategoryResDto; | ||
|
||
import java.util.List; | ||
|
||
public interface CategoryService { | ||
List<CategoryResDto> categoryList(); | ||
} |
Oops, something went wrong.