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

[BE] v.2.0.0 릴리즈 #605

Merged
merged 10 commits into from
Oct 19, 2023
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
39 changes: 24 additions & 15 deletions .github/workflows/be-merge-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,22 @@ jobs:
- name: Gradle build 시작
run: ./gradlew clean build
working-directory: backend

- name: jar 파일 artifact에 업로드
uses: actions/upload-artifact@v3

- name: Docker buildx 설치
uses: docker/setup-buildx-action@v2.9.1

- name: Docker Hub 로그인
uses: docker/login-action@v2.2.0
with:
name: BackendApplication
path: backend/build/libs/mapbefine.jar
username: ${{ secrets.DOCKERHUB_DEV_USERNAME }}
password: ${{ secrets.DOCKERHUB_DEV_TOKEN }}

- name: Docker Image Build
working-directory: backend
run: docker build --platform linux/arm64/v8 -t mapbefine/mapbefine -f Dockerfile-dev .

- name: Docker Hub Push
run: docker push mapbefine/mapbefine

deploy:
if: github.event.pull_request.merged
Expand All @@ -54,17 +64,16 @@ jobs:
needs: build-and-upload

steps:
- name: 구버전 jar 파일 삭제
run: rm -rf /home/ubuntu/backend/build/*.jar

- name: jar파일 artifact에서 다운로드
uses: actions/download-artifact@v3
with:
name: BackendApplication
path: /home/ubuntu/backend/build/
- name: 최신 Docker Image 가져오기
run: |
sudo docker login --username ${{ secrets.DOCKERHUB_DEV_USERNAME }} --password ${{ secrets.DOCKERHUB_DEV_TOKEN }}
sudo docker pull mapbefine/mapbefine:latest

- name: 배포하기
run: /home/ubuntu/backend/deploy.sh
- name: Docker Compose
run: |
cd /home/ubuntu/backend
sudo sh zero-downtime-deploy.sh
sudo docker image prune -af

- name: 슬랙 메시지 보내기

Expand Down
51 changes: 30 additions & 21 deletions .github/workflows/be-merge-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ name: Backend production CI/CD

on:
workflow_dispatch:

pull_request:
branches: [ main ]
types: [ closed ]
paths: backend/**

permissions:
contents: read

jobs:
build-and-upload:
build-and-upload:
if: github.event.pull_request.merged

runs-on: ubuntu-22.04

steps:
Expand All @@ -41,30 +41,39 @@ jobs:
run: ./gradlew clean build
working-directory: backend

- name: jar 파일 artifact에 업로드
uses: actions/upload-artifact@v3
- name: Docker buildx 설치
uses: docker/setup-buildx-action@v2.9.1

- name: Docker Hub 로그인
uses: docker/login-action@v2.2.0
with:
name: BackendApplication
path: backend/build/libs/mapbefine.jar
username: ${{ secrets.DOCKERHUB_DEV_USERNAME }}
password: ${{ secrets.DOCKERHUB_DEV_TOKEN }}

- name: Docker Image Build
working-directory: backend
run: docker build --platform linux/arm64/v8 -t mapbefine/mapbefine -f Dockerfile-dev .

- name: Docker Hub Push
run: docker push mapbefine/mapbefine

deploy:
if: github.event.pull_request.merged

runs-on: [ self-hosted, prod ]
needs: build-and-upload

if: github.event.pull_request.merged

steps:
- name: 구버전 jar 파일 삭제
run: rm -rf /home/ubuntu/backend/build/*.jar

- name: jar파일 artifact에서 다운로드
uses: actions/download-artifact@v3
with:
name: BackendApplication
path: /home/ubuntu/backend/build/
steps:
- name: 최신 Docker Image 가져오기
run: |
sudo docker login --username ${{ secrets.DOCKERHUB_DEV_USERNAME }} --password ${{ secrets.DOCKERHUB_DEV_TOKEN }}
sudo docker pull mapbefine/mapbefine:latest

- name: 배포하기
run: /home/ubuntu/backend/deploy.sh
- name: Docker Compose
run: |
cd /home/ubuntu/backend
sudo sh zero-downtime-deploy.sh
sudo docker image prune -af

- name: 슬랙 메시지 보내기

Expand Down
3 changes: 3 additions & 0 deletions backend/Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM openjdk:17
COPY build/libs/mapbefine.jar mapbefine.jar
ENTRYPOINT ["java", "-jar","-Dspring.profiles.active=dev", "mapbefine.jar"]
3 changes: 3 additions & 0 deletions backend/Dockerfile-prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM openjdk:17
COPY build/libs/mapbefine.jar mapbefine.jar
ENTRYPOINT ["java", "-jar","-Dspring.profiles.active=prod", "mapbefine.jar"]
6 changes: 4 additions & 2 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation group: 'com.github.maricn', name: 'logback-slack-appender', version: '1.6.1'

implementation 'com.github.maricn:logback-slack-appender:1.6.1'
implementation 'org.hibernate:hibernate-spatial:6.2.5.Final'
implementation 'mysql:mysql-connector-java:8.0.32'

implementation 'io.jsonwebtoken:jjwt:0.9.1'
Expand All @@ -44,6 +44,8 @@ dependencies {
testImplementation 'io.rest-assured:rest-assured'
testImplementation 'io.rest-assured:spring-mock-mvc'
testImplementation 'org.assertj:assertj-core:3.19.0'
testImplementation 'org.testcontainers:mysql:1.17.2'
testImplementation 'org.testcontainers:junit-jupiter:1.17.2'

// S3
implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.1000')
Expand Down
58 changes: 29 additions & 29 deletions backend/src/docs/asciidoc/admin.adoc
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
// == 관리자 기능
//
// === 전체 회원 조회
//
// operation::admin-controller-test/find-all-member-details[snippets='http-request,http-response']
//
// === 회원 상세 조회
//
// operation::admin-controller-test/find-member[snippets='http-request,http-response']
//
// === 회원 차단(삭제)
//
// operation::admin-controller-test/delete-member[snippets='http-request,http-response']
//
// === 토픽 삭제
//
// operation::admin-controller-test/delete-topic[snippets='http-request,http-response']
//
// === 토픽 이미지 삭제
//
// operation::admin-controller-test/delete-topic-image[snippets='http-request,http-response']
//
// === 핀 삭제
//
// operation::admin-controller-test/delete-pin[snippets='http-request,http-response']
//
// === 핀 이미지 삭제
//
// operation::admin-controller-test/delete-pin-image[snippets='http-request,http-response']
== 관리자 기능

=== 전체 회원 조회

operation::admin-controller-test/find-all-member-details[snippets='http-request,http-response']

=== 회원 상세 조회

operation::admin-controller-test/find-member[snippets='http-request,http-response']

=== 회원 차단(삭제)

operation::admin-controller-test/delete-member[snippets='http-request,http-response']

=== 토픽 삭제

operation::admin-controller-test/delete-topic[snippets='http-request,http-response']

=== 토픽 이미지 삭제

operation::admin-controller-test/delete-topic-image[snippets='http-request,http-response']

=== 핀 삭제

operation::admin-controller-test/delete-pin[snippets='http-request,http-response']

=== 핀 이미지 삭제

operation::admin-controller-test/delete-pin-image[snippets='http-request,http-response']
4 changes: 2 additions & 2 deletions backend/src/docs/asciidoc/member.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

operation::member-controller-test/find-all-member[snippets='http-request,http-response']

=== 회원 단일 조회
=== 회원의 나의 프로필 조회

operation::member-controller-test/find-member-by-id[snippets='http-request,http-response']
operation::member-controller-test/find-my-profile[snippets='http-request,http-response']

=== 회원의 나의 지도 목록 조회

Expand Down
24 changes: 20 additions & 4 deletions backend/src/docs/asciidoc/pin.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,30 @@ operation::pin-controller-test/add[snippets='http-request,http-response']

operation::pin-controller-test/update[snippets='http-request,http-response']

=== 핀 삭제

operation::pin-controller-test/delete[snippets='http-request,http-response']

=== 핀 이미지 추가

operation::pin-controller-test/add-image[snippets='http-request,http-response']

=== 핀 이미지 삭제

operation::pin-controller-test/remove-image[snippets='http-request,http-response']

=== 핀 댓글 생성

operation::pin-controller-test/create-parent-pin-comment[snippets='http-request,http-response']

=== 핀 대댓글 생성

operation::pin-controller-test/create-child-pin-comment[snippets='http-request,http-response']

=== 핀 댓글 조회

operation::pin-controller-test/find-all-pin-comment-by-pin-id[snippets='http-request,http-response']

=== 핀 댓글 수정

operation::pin-controller-test/update-pin-comment[snippets='http-request,http-response']

=== 핀 댓글 삭제

operation::pin-controller-test/remove-pin-comment[snippets='http-request,http-response']
5 changes: 2 additions & 3 deletions backend/src/docs/asciidoc/topic.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ operation::topic-controller-test/copy-pin[snippets='http-request,http-response']

operation::topic-controller-test/update[snippets='http-request,http-response']

=== 토픽 삭제

operation::topic-controller-test/delete[snippets='http-request,http-response']
=== 토픽 이미지 수정

operation::topic-controller-test/update-image[snippets='http-request,http-response']
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public AdminCommandService(
public void blockMember(Long memberId) {
Member member = findMemberById(memberId);
member.updateStatus(Status.BLOCKED);
memberRepository.flush();

deleteAllRelatedMember(member);
}
Expand All @@ -63,11 +64,8 @@ private void deleteAllRelatedMember(Member member) {
Long memberId = member.getId();

permissionRepository.deleteAllByMemberId(memberId);
permissionRepository.flush();
atlasRepository.deleteAllByMemberId(memberId);
atlasRepository.flush();
bookmarkRepository.deleteAllByMemberId(memberId);
bookmarkRepository.flush();
pinImageRepository.deleteAllByPinIds(pinIds);
pinRepository.deleteAllByMemberId(memberId);
topicRepository.deleteAllByMemberId(memberId);
Expand All @@ -90,11 +88,8 @@ public void deleteTopic(Long topicId) {
List<Long> pinIds = extractPinIdsByTopic(topic);

permissionRepository.deleteAllByTopicId(topicId);
permissionRepository.flush();
atlasRepository.deleteAllByTopicId(topicId);
atlasRepository.flush();
bookmarkRepository.deleteAllByTopicId(topicId);
bookmarkRepository.flush();
pinImageRepository.deleteAllByPinIds(pinIds);
pinRepository.deleteAllByTopicId(topicId);
topicRepository.deleteById(topicId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class AdminController {
private final AdminQueryService adminQueryService;
private final AdminCommandService adminCommandService;


public AdminController(AdminQueryService adminQueryService, AdminCommandService adminCommandService) {
this.adminQueryService = adminQueryService;
this.adminCommandService = adminCommandService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.mapbefine.mapbefine.atlas.domain;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
Expand All @@ -10,7 +13,11 @@ public interface AtlasRepository extends JpaRepository<Atlas, Long> {

void deleteByMemberIdAndTopicId(Long memberId, Long topicId);

void deleteAllByMemberId(Long memberId);
@Modifying(clearAutomatically = true)
@Query("delete from Atlas a where a.member.id = :memberId")
void deleteAllByMemberId(@Param("memberId") Long memberId);

void deleteAllByTopicId(Long topicId);
@Modifying(clearAutomatically = true)
@Query("delete from Atlas a where a.topic.id = :topicId")
void deleteAllByTopicId(@Param("topicId") Long topicId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ protected AuthMember(
public abstract boolean canTopicUpdate(Topic topic);

public abstract boolean canPinCreateOrUpdate(Topic topic);

public abstract boolean canPinCommentCreate(Topic topic);

public Long getMemberId() {
return memberId;
Expand All @@ -36,4 +38,10 @@ public boolean isSameMember(Long memberId) {
return Objects.equals(memberId, this.memberId);
}

public abstract boolean isAdmin();

public abstract boolean isUser();

public abstract boolean isGuest();

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,24 @@ public boolean canPinCreateOrUpdate(Topic topic) {
return true;
}

@Override
public boolean canPinCommentCreate(Topic topic) {
return true;
}

@Override
public boolean isAdmin() {
return true;
}

@Override
public boolean isUser() {
return false;
}

@Override
public boolean isGuest() {
return false;
}

}
Loading
Loading