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

feat: user 탈퇴/로그아웃 로직 구현 및 전반적인 리펙토링, 버그 수정 #92

Merged
merged 16 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 22 additions & 12 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Java CI/DE with Gradle(dev branch)
name: Java CI/DE with Gradle(main branch)

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read
Expand Down Expand Up @@ -38,6 +36,7 @@ jobs:
touch $OCCUPY_SECRET_DIR/$OCCUPY_SECRET_DIR_FILE_NAME

echo "$OCCUPY_SECRET" > $OCCUPY_SECRET_DIR/$OCCUPY_SECRET_DIR_FILE_NAME

# firebase 폴더 내 json 파일 github secret에서 복사해 오기
- name: Copy firebase
env:
Expand All @@ -48,6 +47,7 @@ jobs:
run: |
mkdir -p $OCCUPY_FIREBASE_DIR
echo "$OCCUPY_FIREBASE" > $OCCUPY_FIREBASE_DIR/$OCCUPY_FIREBASE_DIR_FILE_NAME

# gradlew 실행 권한 부여
- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew
Expand All @@ -64,15 +64,6 @@ jobs:
name: build-artifacts
path: |
build/libs/*.jar
- name: Upload project code
uses: appleboy/scp-action@master
with:
key: ${{ secrets.EC2_KEY }}
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
target: /home/ubuntu/app/spring_source
source: .


deploy:
name: CD with SSH
Expand All @@ -85,6 +76,15 @@ jobs:
with:
name: build-artifacts

- name: Upload project code
uses: appleboy/scp-action@master
with:
key: ${{ secrets.EC2_KEY }}
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
target: /home/ubuntu/app/spring_source
source: .

# JAR 파일을 EC2에 배포하는 step
- name: SCP JAR to EC2
uses: appleboy/scp-action@master
Expand All @@ -95,6 +95,16 @@ jobs:
source: "*.jar"
target: "/home/ubuntu/app"

# Redis Server 구동
- name: Start redis-server
uses: appleboy/ssh-action@master
with:
key: ${{ secrets.EC2_KEY }}
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
script: |
sudo systemctl start redis-server

# EC2에 SSH로 배포 커맨드를 입력하는 step
- name: Deploy SSH
uses: appleboy/ssh-action@master
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Java CI/DE with Gradle(main branch)

on:
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:
name: Build
runs-on: ubuntu-22.04

steps:
# 작업 엑세스 가능하게 $GITHUB_WORKSPACE에서 저장소를 체크아웃
- name: Checkout branch
uses: actions/checkout@v3

# java 버전 세팅
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'

# git ignore한 yml 파일들 github secret에서 복사해 오기
- name: Copy secret
env:
OCCUPY_SECRET: ${{ secrets.OCCUPY_SECRET_DEV }}
OCCUPY_SECRET_DIR: ./src/main/resources

OCCUPY_SECRET_DIR_FILE_NAME: application.yml
run: |

touch $OCCUPY_SECRET_DIR/$OCCUPY_SECRET_DIR_FILE_NAME

echo "$OCCUPY_SECRET" > $OCCUPY_SECRET_DIR/$OCCUPY_SECRET_DIR_FILE_NAME

# firebase 폴더 내 json 파일 github secret에서 복사해 오기
- name: Copy firebase
env:
OCCUPY_FIREBASE: ${{ secrets.FIREBASE_JSON }}
OCCUPY_FIREBASE_DIR: ./src/main/resources/firebase

OCCUPY_FIREBASE_DIR_FILE_NAME: ${{ secrets.FIREBASE_JSON_NAME }}
run: |
mkdir -p $OCCUPY_FIREBASE_DIR
echo "$OCCUPY_FIREBASE" > $OCCUPY_FIREBASE_DIR/$OCCUPY_FIREBASE_DIR_FILE_NAME

# gradlew 실행 권한 부여
- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew
shell: bash

# Build -> jar 파일 생성
- name: Build with Gradle
run: ./gradlew clean build -x test
shell: bash

- name: Upload Build artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: |
build/libs/*.jar
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.net.URI;
import java.util.List;

@Service
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/com/on/server/domain/alarm/domain/Alert.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package com.on.server.domain.alarm.domain;

import com.on.server.domain.user.domain.User;
import com.on.server.global.common.ResponseCode;
import com.on.server.global.common.exceptions.InternalServerException;
import com.on.server.global.domain.BaseEntity;
import jakarta.persistence.*;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDate;

@Entity
@Getter
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

public interface AlertRepository extends JpaRepository<Alert, Long> {
Page<Alert> findByUser(User user, Pageable pageable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import okhttp3.Response;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
Expand All @@ -34,7 +33,7 @@ public class AlertController {
// 사용자 디바이스 토큰 저장하기
@PostMapping("/deviceToken")
@Operation(summary = "사용자 디바이스 토큰 저장하기")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyRole('ACTIVE', 'AWAIT', 'TEMPORARY')")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyAuthority('ACTIVE', 'AWAIT', 'TEMPORARY')")
public ResponseEntity<?> saveDeviceToken(
@AuthenticationPrincipal UserDetails userDetails,
@RequestBody DeviceTokenRequestDto deviceTokenRequestDto
Expand All @@ -49,7 +48,7 @@ public ResponseEntity<?> saveDeviceToken(
// 알림 리스트 조회
@GetMapping("/list")
@Operation(summary = "사용자 알림 리스트 조회하기")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyRole('ACTIVE', 'AWAIT', 'TEMPORARY')")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyAuthority('ACTIVE', 'AWAIT', 'TEMPORARY')")
public ResponseEntity<?> getAlertList(
@AuthenticationPrincipal UserDetails userDetails,
@ParameterObject Pageable pageable
Expand All @@ -65,7 +64,7 @@ public ResponseEntity<?> getAlertList(
// 알림 이동 페이지 조회
@PostMapping("/{alertId}")
@Operation(summary = "사용자 알림 읽음 상태 업데이트 및 URL 반환")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyRole('ACTIVE', 'AWAIT', 'TEMPORARY')")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyAuthority('ACTIVE', 'AWAIT', 'TEMPORARY')")
public ResponseEntity<?> getRedirect(
@PathVariable Long alertId
) {
Expand All @@ -79,7 +78,7 @@ public ResponseEntity<?> getRedirect(
// 안 읽은 알림 개수
@GetMapping("/isNotRead")
@Operation(summary = "읽지 않은 알림 개수")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyRole('ACTIVE', 'AWAIT', 'TEMPORARY')")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyAuthority('ACTIVE', 'AWAIT', 'TEMPORARY')")
public ResponseEntity<?> isNotRead(
@AuthenticationPrincipal UserDetails userDetails
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class FcmTestController {

@PostMapping("/alert")
@Operation(summary = "알림 생성 테스트")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyRole('ACTIVE', 'AWAIT', 'TEMPORARY')")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyAuthority('ACTIVE', 'AWAIT', 'TEMPORARY')")
public ResponseEntity<?> pushMessage(
@AuthenticationPrincipal UserDetails userDetails
) throws IOException {
Expand All @@ -46,7 +46,7 @@ public ResponseEntity<?> pushMessage(

@PostMapping("/save")
@Operation(summary = "알림 저장 테스트")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyRole('ACTIVE', 'AWAIT', 'TEMPORARY')")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyAuthority('ACTIVE', 'AWAIT', 'TEMPORARY')")
public ResponseEntity<?> makeAlert(
@AuthenticationPrincipal UserDetails userDetails,
@RequestBody FcmRequestDto fcmRequestDto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
import com.on.server.domain.post.domain.repository.PostRepository;
import com.on.server.domain.post.dto.PostResponseDTO;
import com.on.server.domain.user.domain.User;
import com.on.server.domain.user.domain.UserStatus;
import com.on.server.domain.user.domain.repository.UserRepository;
import com.on.server.global.aws.s3.uuidFile.domain.UuidFile;
import com.on.server.global.common.ResponseCode;
import com.on.server.global.common.exceptions.BadRequestException;
import lombok.RequiredArgsConstructor;
Expand All @@ -18,7 +15,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.on.server.domain.board.domain.BoardType;
import com.on.server.domain.post.dto.PostResponseDTO;
import com.on.server.domain.user.domain.User;
import com.on.server.global.common.CommonResponse;
import com.on.server.global.security.SecurityService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
import com.on.server.domain.comment.domain.repository.CommentRepository;
import com.on.server.domain.comment.dto.CommentRequestDTO;
import com.on.server.domain.comment.dto.CommentResponseDTO;
import com.on.server.domain.comment.dto.WriterInfo;
import com.on.server.domain.post.domain.Post;
import com.on.server.domain.post.domain.repository.PostRepository;
import com.on.server.domain.user.domain.User;
import com.on.server.domain.user.domain.repository.UserRepository;
import com.on.server.global.common.exceptions.BadRequestException;
import com.on.server.global.common.ResponseCode;
import lombok.RequiredArgsConstructor;
Expand All @@ -24,7 +22,6 @@

import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;

@Service
@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
import jakarta.persistence.*;
import lombok.*;

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

@Getter
@Builder
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

@Tag(name = "댓글 작성")
@RestController
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.on.server.domain.companyParticipant.dto;

import com.on.server.domain.companyParticipant.domain.CompanyParticipantStatus;
import lombok.Getter;
import lombok.NoArgsConstructor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/on/server/domain/country/Country.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.on.server.global.domain.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import lombok.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class DiaryController {
// 0. 날짜 설정하기
@PostMapping("/startdate")
@Operation(summary = "시작 날짜 설정")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyRole('ACTIVE', 'AWAIT', 'TEMPORARY')")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyAuthority('ACTIVE', 'AWAIT', 'TEMPORARY')")
public ResponseEntity<?> setStartDate(@AuthenticationPrincipal UserDetails userDetails,
@RequestBody StartDateRequestDto startDateRequestDto) {
User user = securityService.getUserByUserDetails(userDetails);
Expand All @@ -39,7 +39,7 @@ public ResponseEntity<?> setStartDate(@AuthenticationPrincipal UserDetails userD
// 1. 일기 리스트 보여주는 일기 홈
@GetMapping("/list")
@Operation(summary = "일기 홈 조회", description = "D-Day 계산 : 2일 남은 경우 = 2, 당일인 경우 = 0, 2일 지난 경우 = -2")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyRole('ACTIVE', 'AWAIT', 'TEMPORARY')")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyAuthority('ACTIVE', 'AWAIT', 'TEMPORARY')")
public ResponseEntity<?> getDiaryHome(@AuthenticationPrincipal UserDetails userDetails) {

User user = securityService.getUserByUserDetails(userDetails);
Expand All @@ -49,7 +49,7 @@ public ResponseEntity<?> getDiaryHome(@AuthenticationPrincipal UserDetails userD
// 2, 일기 작성하기
@PostMapping()
@Operation(summary = "일기 작성하기")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyRole('ACTIVE', 'AWAIT', 'TEMPORARY')")
@PreAuthorize("@securityService.isNotTemporaryUser() and hasAnyAuthority('ACTIVE', 'AWAIT', 'TEMPORARY')")
public ResponseEntity<?> createDiary(@AuthenticationPrincipal UserDetails userDetails,
@RequestBody DiaryRequestDto diaryRequestDto) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package com.on.server.domain.dispatchCertify.dto.request;

import com.on.server.domain.dispatchCertify.domain.DispatchCertify;
import com.on.server.domain.dispatchCertify.domain.PermitStatus;
import com.on.server.domain.user.domain.DispatchType;
import jakarta.validation.constraints.NotBlank;
import lombok.Builder;
import lombok.Getter;
import org.hibernate.validator.constraints.URL;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Getter
@Builder
Expand Down
Loading
Loading