Skip to content

Commit

Permalink
chore: resolve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Kang1221 committed Apr 24, 2024
2 parents 0ee72e7 + e47f226 commit ee0d871
Show file tree
Hide file tree
Showing 40 changed files with 825 additions and 328 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
push:
branches: [ "main" ]

jobs:
#Build
build:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
## 체크아웃
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.TOKEN }}
submodules: true
## JDK 17
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

# Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md

## Gradle build (Test 제외)
- name: Build with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: clean build -x test

## Docker build & push
- name: Docker build and push
run: |
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
docker build -t ${{ secrets.DOCKERHUB_REPOSITORY }} .
docker tag ${{ secrets.DOCKERHUB_REPOSITORY }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:${GITHUB_SHA::7}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:${GITHUB_SHA::7}
#Deploy
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VM_INSTANCE }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
envs: GITHUB_SHA
script: |
sudo docker-compose down
sudo docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:${GITHUB_SHA::7}
sudo docker tag ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:${GITHUB_SHA::7} donut
sudo docker-compose up -d --remove-orphans
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@ out/
.vscode/

### gcs access iam ###
adroit-metric-413519-7d23d8bb1152.json
adroit-metric-413519-d4e6d7038d34.json
*.json
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "Donut-Server-yml"]
path = Donut-Server-yml
url = https://github.com/Donut-DONationUTile/Donut-Server-yml.git
1 change: 1 addition & 0 deletions Donut-Server-yml
Submodule Donut-Server-yml added at 8c5345
12 changes: 12 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ dependencies {
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'
//WebClient
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-webflux'

}

Expand All @@ -64,6 +66,16 @@ dependencyManagement {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

//yml submodule
task copyYML(type: Copy){
copy{
from './Donut-Server-yml'
include "*.yml" , "*.json"
into './src/main/resources'
}
}

tasks.named('test') {
useJUnitPlatform()
}
2 changes: 2 additions & 0 deletions src/main/java/zero/eight/donut/DonutApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableScheduling
@EnableJpaAuditing
@SpringBootApplication
public class DonutApplication {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package zero.eight.donut.service;
package zero.eight.donut.config.jwt;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
Expand All @@ -14,6 +15,7 @@

import java.util.Collection;

@Slf4j
@RequiredArgsConstructor
@Component
public class AuthUtils {
Expand All @@ -24,6 +26,8 @@ public class AuthUtils {
private final ReceiverRepository receiverRepository;

public Giver getGiver() {
log.info("사용자 이메일 -> {}", getCurrentUserEmail());
log.info("사용자 -> {}", giverRepository.findByEmail(getCurrentUserEmail()));
return giverRepository.findByEmail(getCurrentUserEmail()).get();
}

Expand Down
10 changes: 8 additions & 2 deletions src/main/java/zero/eight/donut/config/jwt/JwtUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.jsonwebtoken.*;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
Expand All @@ -21,14 +22,15 @@
import java.util.Date;
import java.util.concurrent.TimeUnit;

@Slf4j
@RequiredArgsConstructor
@Component
public class JwtUtils {

@Value("${secret.time.access}")
private long accessTokenTime; // 30분;
private long accessTokenTime; // 30일
@Value("${secret.time.refresh}")
private long refreshTokenTime; // 14일;
private long refreshTokenTime; // 30일
@Value("${secret.key}")
private String jwtSecretKey;
private final StringRedisTemplate stringRedisTemplate;
Expand Down Expand Up @@ -88,11 +90,15 @@ public boolean validateToken(String token) {
}
try {
Claims claims = Jwts.parser().setSigningKey(jwtSecretKey).parseClaimsJws(token).getBody();
log.info("token \"role\" : " + claims.get("role"));
log.info("token \"name\" : " + claims.get("name"));
return true;
} catch (MalformedJwtException e) {
throw new UnauthorizedException(Error.INVALID_JWT_EXCEPTION);
} catch (ExpiredJwtException e) {
throw new UnauthorizedException(Error.JWT_EXPIRED);
} catch (UnauthorizedException e) {
return false;
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/zero/eight/donut/controller/AuthController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import zero.eight.donut.common.response.ApiResponse;
import zero.eight.donut.dto.auth.AuthRequestDto;
import zero.eight.donut.dto.auth.AuthTestDto;
import zero.eight.donut.dto.auth.GoogleLoginDto;
import zero.eight.donut.service.AuthService;

@Slf4j
Expand All @@ -19,8 +20,8 @@ public class AuthController {

// 기부자 구글 로그인
@PostMapping("/giver/signin")
public ApiResponse<?> googleSignIn() {
return authService.googleSignIn(((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest().getHeader("Authorization"));
public ApiResponse<?> googleSignIn(@RequestBody GoogleLoginDto googleLoginDto) {
return authService.googleSignIn(googleLoginDto.getIdToken());
}

@PostMapping("/giver/test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.RequiredArgsConstructor;
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 zero.eight.donut.common.response.ApiResponse;
Expand All @@ -19,7 +20,7 @@ public class DonationController {
private final DonationService donationService;

@PostMapping("/receiver/assign")
public ApiResponse<?> assignGiftbox(GiftboxRequestDto giftboxRequestDto) {
public ApiResponse<?> assignGiftbox(@RequestBody GiftboxRequestDto giftboxRequestDto) {
return donationService.assignGiftbox(giftboxRequestDto);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import zero.eight.donut.common.response.ApiResponse;
import zero.eight.donut.service.AuthService;
import zero.eight.donut.service.HistoryGiverService;

import java.time.LocalDateTime;
Expand All @@ -16,6 +17,7 @@
@RequestMapping("/api/history/giver")
public class HistoryGiverController {
private final HistoryGiverService historyGiverService;
private final AuthService authService;

@GetMapping("/info/{donateDate}")
public ApiResponse<?> getDonationList(@PathVariable("donateDate")LocalDateTime donateDate){
Expand All @@ -26,4 +28,9 @@ public ApiResponse<?> getDonationList(@PathVariable("donateDate")LocalDateTime d
public ApiResponse<?> getDonationDetail(@PathVariable("giftId")Long giftId){
return historyGiverService.getDonationDetail(giftId);
}

@GetMapping("/giver/get")
public ApiResponse<?> getGiverEntity() {
return authService.getGiverEntity();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import zero.eight.donut.common.response.ApiResponse;
import zero.eight.donut.service.AuthUtils;
import zero.eight.donut.service.HomeReceiverService;

@RestController
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/zero/eight/donut/controller/ReportController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import zero.eight.donut.common.response.ApiResponse;
import zero.eight.donut.dto.report.ReportedRequestDto;
import zero.eight.donut.service.ReportService;

@RestController
Expand All @@ -11,8 +12,11 @@
public class ReportController {
private final ReportService reportService;
@PostMapping("/use")
public ApiResponse<?> createReport(@RequestParam(name = "giftId") Long giftId ){
return reportService.createReport(giftId);
public ApiResponse<?> createUsed(@RequestParam(name = "giftId") Long giftId ){
return reportService.createUsed(giftId);
}
@PostMapping("/cheat")
public ApiResponse<?> createReport(@RequestBody ReportedRequestDto requestDto){
return reportService.createReport(requestDto);
}

}
26 changes: 15 additions & 11 deletions src/main/java/zero/eight/donut/domain/Gift.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,43 +20,43 @@ public class Gift extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "gift_id")
private Long id;
private Long id; // 기프티콘 고유 ID

@Column(length = 100)
private String product;
private String product; // 상품명

@Column
private Boolean isAssigned;
private Boolean isAssigned; // 할당여부

@Column
private Boolean isMsgReceived;
private Boolean isMsgReceived; // 신규 메세지 등록 여부

@Enumerated(value = EnumType.STRING)
@Column
private Status status;
private Status status; // 상태(used/unused/reported/stored/selfUsed)

@Column
private Integer price;
private Integer price; // 가격

@Column(length = 500)
private String imageUrl;
private String imageUrl; // 이미지 URL

@Enumerated(value = EnumType.STRING)
@Column
private Store store;
private Store store; // 사용처

@Column
private LocalDateTime dueDate;
private LocalDateTime dueDate; // 사용 기한

//기부자
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "giver_id")
private Giver giver;
private Giver giver; // 기부자 고유 ID

//기프티콘꾸러미
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "giftbox_id")
private Giftbox giftbox;
private Giftbox giftbox; // 꾸러미 고유 ID

//신고 -> 단방향으로 수정
// @OneToOne(fetch = FetchType.LAZY)
Expand All @@ -77,4 +77,8 @@ public void setIsAssigned() {
public void updateGiftbox(Giftbox giftbox) {
this.giftbox = giftbox;
}

public void updateImageUrl(String imageUrl){
this.imageUrl = imageUrl;
}
}
4 changes: 4 additions & 0 deletions src/main/java/zero/eight/donut/domain/Receiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.crypto.password.PasswordEncoder;
import zero.eight.donut.common.domain.BaseTimeEntity;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Entity
@Builder
@Getter
Expand Down Expand Up @@ -50,6 +52,8 @@ public class Receiver extends BaseTimeEntity {
* @return 변경된 유저 Entity
*/
public Receiver encryptPassword(PasswordEncoder encoder) {
log.info("비밀번호 암호화 함수 진입");

this.password = encoder.encode(this.password);
return this;
}
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/zero/eight/donut/domain/Report.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package zero.eight.donut.domain;

import lombok.Getter;
import zero.eight.donut.common.domain.BaseTimeEntity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;


@Entity
@Builder
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class Report extends BaseTimeEntity {
Expand All @@ -32,7 +31,6 @@ public class Report extends BaseTimeEntity {
private Receiver receiver;

//기프티콘
// @OneToOne(mappedBy = "report")
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "gift_id")
private Gift gift;
Expand Down
Loading

0 comments on commit ee0d871

Please sign in to comment.