Skip to content

Commit

Permalink
Feat: module architecture renewed
Browse files Browse the repository at this point in the history
  • Loading branch information
versatile0010 committed Feb 18, 2024
1 parent a60edad commit f51c13a
Show file tree
Hide file tree
Showing 129 changed files with 344 additions and 228 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/jib-build-depoly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: NumberOne-Backend-JIB-BUILD-DEPLOY
# event trigger
on:
push:
branches: [ "dev", "dev-check" ]
branches: [ "dev", "dev-check", "feat/multi-module" ]

permissions: write-all

Expand Down Expand Up @@ -74,8 +74,8 @@ jobs:

- name: 🐧 create application.yml
run: |
mkdir -p ./daepiro-api/src/main/resources
cd ./daepiro-api/src/main/resources
mkdir -p ./daepiro-app/src/main/resources
cd ./daepiro-app/src/main/resources
touch ./application.yml
echo "${{ secrets.PROPERTIES_PROD }}" | base64 --decode > ./application.yml
ls -la
Expand All @@ -91,7 +91,7 @@ jobs:

- name: Build with jib
run: |
./gradlew :daepiro-api:jib -x test \
./gradlew :daepiro-app:jib -x test \
-Djib.to.auth.username=${{ secrets.DOCKER_USERNAME }} \
-Djib.to.auth.password=${{ secrets.DOCKER_PASSWORD }} \
-Djib.to.image="${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE }}:latest"
Expand Down
29 changes: 1 addition & 28 deletions daepiro-api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
plugins {
id 'com.google.cloud.tools.jib' version '3.4.0'
}

dependencies {
implementation project(':daepiro-core')
implementation project(':daepiro-common')
Expand All @@ -15,7 +11,7 @@ dependencies {
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'

// jpa
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
api 'org.springframework.boot:spring-boot-starter-data-jpa'

annotationProcessor 'org.projectlombok:lombok'

Expand Down Expand Up @@ -52,27 +48,4 @@ dependencies {

tasks.named('test') {
useJUnitPlatform()
}

def serverIP = System.getenv("EC2_PUBLIC_IP")
def jmxPort = System.getenv("JMX_PORT")

jib {
from {
image = "openjdk:17"
}
to {
image = "versatile0010/numberone"
tags = ["latest"]
}
container {
mainClass = 'com.numberone.backend.BackendApplication'
creationTime = "USE_CURRENT_TIMESTAMP"
jvmFlags = ["-Duser.timezone=Asia/Seoul", "-Xms128m", "-Xmx128m", "-Dcom.sun.management.jmxremote=true", "-Dcom.sun.management.jmxremote.local.only=false", "-Dcom.sun.management.jmxremote.port="+jmxPort.toString(), "-Dcom.sun.management.jmxremote.ssl=false", "-Dcom.sun.management.jmxremote.authenticate=false", "-Djava.rmi.server.hostname=" + serverIP.toString(), "-Dcom.sun.management.jmxremote.rmi.port="+jmxPort.toString(), "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=/heap-dumps/heapdump.hprof"]
ports = ['8080']
}
}

tasks.bootJar {
enabled = true
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.numberone.backend.domain.admin.controller;

import com.numberone.backend.domain.admin.dto.SaveAdminDisasterRequest;
import com.numberone.backend.domain.admin.dto.response.GetAddressResponse;
import com.numberone.backend.domain.admin.service.AdminService;
import com.numberone.backend.domain.disaster.dto.request.SaveDisasterRequest;
import com.numberone.backend.domain.disaster.service.DisasterService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
Expand All @@ -22,16 +22,16 @@ public class AdminController {

@Operation(summary = "서버에 지역별 대피소 정보 Json 파일로 업로드하기", description =
"""
🔥 (주의) Shelter Database 정보를 json 형태로 서버 스토리지에 저장하는 기능으로, 10 분 이상 소요됩니다.
요청 시, 현재 저장된 대피소 db 를 기반으로
지역 별 대피소 정보를 Json 형태로 정리하여 서버 스토리지에 저장합니다.
대피소 db 를 업데이트 한 경우에, 실행하는 api 입니다.
""")
🔥 (주의) Shelter Database 정보를 json 형태로 서버 스토리지에 저장하는 기능으로, 10 분 이상 소요됩니다.
요청 시, 현재 저장된 대피소 db 를 기반으로
지역 별 대피소 정보를 Json 형태로 정리하여 서버 스토리지에 저장합니다.
대피소 db 를 업데이트 한 경우에, 실행하는 api 입니다.
""")
@PostMapping("/shelter-init")
public ResponseEntity<String> uploadAllShelterInfo() {
return ResponseEntity.created(URI.create("/api/admin/shelter-init"))
Expand All @@ -40,12 +40,12 @@ public ResponseEntity<String> uploadAllShelterInfo() {

@Operation(summary = "서버에 대피소 주소 정보 Json 파일로 업로드하기", description =
"""
🔥 (주의) Shelter Database 정보를 기반으로 주소 정보를 json 형태로 서버 스토리지에 저장하는 기능입니다.
대피소 db 를 업데이트 한 경우에, 실행하는 api 입니다.
""")
🔥 (주의) Shelter Database 정보를 기반으로 주소 정보를 json 형태로 서버 스토리지에 저장하는 기능입니다.
대피소 db 를 업데이트 한 경우에, 실행하는 api 입니다.
""")
@PostMapping("/address-info")
public ResponseEntity<String> uploadAllAddressInfo() {
return ResponseEntity.created(URI.create("/api/admin/address-info"))
Expand All @@ -60,8 +60,8 @@ public ResponseEntity<List<GetAddressResponse>> getAllAddressInfo() {

@Operation(summary = "(테스트용) 재난 발생시키기", description = """
지원되는 재난 유형:
DROUGHT("가뭄"),
STRONG_WIND("강풍"),
DRYNESS("건조"),
Expand Down Expand Up @@ -102,7 +102,7 @@ public ResponseEntity<List<GetAddressResponse>> getAllAddressInfo() {
OTHERS("기타"),
""")
@PostMapping("/disaster")
public ResponseEntity<SaveDisasterRequest> createDisaster(@RequestBody SaveDisasterRequest request){
public ResponseEntity<SaveAdminDisasterRequest> createDisaster(@RequestBody SaveAdminDisasterRequest request) {
disasterService.save(request);
return ResponseEntity.ok(request);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.numberone.backend.domain.disaster.dto.request;
package com.numberone.backend.domain.admin.dto;

import com.numberone.backend.domain.disaster.util.DisasterType;
import com.numberone.backend.domain.disaster.DisasterType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Builder
public class SaveDisasterRequest {
public class SaveAdminDisasterRequest {
@Schema(defaultValue = "HEAVY_RAIN")
private DisasterType disasterType;
@Schema(defaultValue = "서울특별시 성동구 성수동")
Expand All @@ -22,8 +22,8 @@ public class SaveDisasterRequest {
@Schema(defaultValue = "2023/11/25 15:40:00")
private String createdAt;

public static SaveDisasterRequest of(DisasterType disasterType, String location, String msg, Long disasterNum, String createdAt) {
return SaveDisasterRequest.builder()
public static SaveAdminDisasterRequest of(DisasterType disasterType, String location, String msg, Long disasterNum, String createdAt) {
return SaveAdminDisasterRequest.builder()
.disasterType(disasterType)
.location(location)
.msg(msg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.numberone.backend.domain.admin.dto.response.GetAddressResponse;
import com.numberone.backend.domain.shelter.dto.response.GetAllSheltersResponse;
import com.numberone.backend.domain.shelter.dto.GetAllSheltersResponse;
import com.numberone.backend.domain.shelter.repository.ShelterRepository;
import com.numberone.backend.provider.s3.S3Provider;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.numberone.backend.domain.article.controller;

import com.numberone.backend.domain.article.dto.parameter.ArticleSearchParameterDto;
import com.numberone.backend.domain.article.dto.request.ModifyArticleRequest;
import com.numberone.backend.domain.article.dto.request.UploadArticleRequest;
import com.numberone.backend.domain.article.dto.response.*;
import com.numberone.backend.domain.article.service.ArticleService;
import com.numberone.backend.domain.comment.dto.request.CreateCommentRequest;
import com.numberone.backend.domain.comment.dto.response.CreateCommentResponse;
import com.numberone.backend.domain.like.service.RedisLockLikeFacade;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand All @@ -25,7 +25,6 @@
public class ArticleController {

private final ArticleService articleService;
private final RedisLockLikeFacade redisLockLikeFacade;

@Operation(summary = "게시글 작성 API", description = """
Expand Down Expand Up @@ -87,37 +86,37 @@ public ResponseEntity<GetArticleDetailResponse> getArticleDetails(@PathVariable(
@GetMapping
public ResponseEntity<Slice<GetArticleListResponse>> getArticlePages(
Pageable pageable,
@ModelAttribute ArticleSearchParameter param) {
return ResponseEntity.ok(articleService.getArticleListPaging(param, pageable));
@ModelAttribute ArticleSearchParameterDto paramDto) {
return ResponseEntity.ok(articleService.getArticleListPaging(paramDto.toParameter(), pageable));
}

@Operation(summary = "게시글에 댓글 작성하기", description = """
게시글에 댓글을 작성하는 API 입니다.
게시글 아이디는 Path variable 으로 넘겨주세요 (article-id)
""")
@PostMapping("comments/{article-id}")
public ResponseEntity<CreateCommentResponse> createComment(
@PathVariable("article-id") Long articleId,
@RequestBody @Valid CreateCommentRequest request) {
return ResponseEntity.created(
URI.create(String.format("/api/articles/comment/%s", articleId)))
URI.create(String.format("/api/articles/comment/%s", articleId)))
.body(articleService.createComment(articleId, request));

}

@Operation(summary = "게시글 수정하기", description = """
게시글 내용을 수정하는 API 입니다.
반드시 access token 을 헤더에 포함해서 요청해주세요.
article-id 는 path variable 으로 넘겨주세요.
""")
@PutMapping("{article-id}/modify")
public ResponseEntity<ModifyArticleResponse> modifyArticle(
@PathVariable("article-id") Long articleId,
@RequestBody @Valid ModifyArticleRequest request ){
@RequestBody @Valid ModifyArticleRequest request) {
return ResponseEntity.ok(articleService.modifyArticle(articleId, request));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.numberone.backend.domain.article.dto.parameter;

import com.numberone.backend.domain.article.entity.ArticleTag;
import lombok.*;

@ToString
@Builder
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class ArticleSearchParameterDto {
private ArticleTag tag;
private Long lastArticleId;
private Double longitude;
private Double latitude;
private String regionLv2; // 구

public ArticleSearchParameter toParameter () {
return ArticleSearchParameter.builder()
.tag(tag)
.lastArticleId(lastArticleId)
.longitude(longitude)
.latitude(latitude)
.regionLv2(regionLv2)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.numberone.backend.domain.article.service;

import com.numberone.backend.domain.article.dto.parameter.ArticleSearchParameter;
import com.numberone.backend.domain.article.dto.request.ModifyArticleRequest;
import com.numberone.backend.domain.article.dto.request.UploadArticleRequest;
import com.numberone.backend.domain.article.dto.response.*;
Expand All @@ -23,13 +24,13 @@
import com.numberone.backend.domain.notification.repository.NotificationRepository;
import com.numberone.backend.domain.notificationregion.entity.NotificationRegion;
import com.numberone.backend.domain.notificationregion.repository.NotificationRegionRepository;
import com.numberone.backend.domain.token.util.SecurityContextProvider;
import com.numberone.backend.exception.conflict.UnauthorizedLocationException;
import com.numberone.backend.exception.notfound.NotFoundArticleException;
import com.numberone.backend.exception.notfound.NotFoundMemberException;
import com.numberone.backend.provider.fcm.service.FcmMessageProvider;
import com.numberone.backend.provider.s3.S3Provider;
import com.numberone.backend.provider.location.LocationProvider;
import com.numberone.backend.provider.s3.S3Provider;
import com.numberone.backend.provider.security.SecurityContextProvider;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Pageable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import com.numberone.backend.domain.comment.dto.request.CreateChildCommentRequest;
import com.numberone.backend.domain.comment.dto.response.CreateChildCommentResponse;
import com.numberone.backend.domain.comment.dto.response.DeleteCommentResponse;
import com.numberone.backend.domain.comment.dto.response.GetCommentDto;
import com.numberone.backend.domain.comment.dto.GetCommentDto;
import com.numberone.backend.domain.comment.service.CommentService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.sql.Delete;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.numberone.backend.domain.comment.dto.request.CreateChildCommentRequest;
import com.numberone.backend.domain.comment.dto.response.CreateChildCommentResponse;
import com.numberone.backend.domain.comment.dto.response.DeleteCommentResponse;
import com.numberone.backend.domain.comment.dto.response.GetCommentDto;
import com.numberone.backend.domain.comment.dto.GetCommentDto;
import com.numberone.backend.domain.comment.entity.CommentEntity;
import com.numberone.backend.domain.comment.repository.CommentRepository;
import com.numberone.backend.domain.like.entity.CommentLike;
Expand All @@ -17,7 +17,7 @@
import com.numberone.backend.domain.notification.entity.NotificationEntity;
import com.numberone.backend.domain.notification.entity.NotificationTag;
import com.numberone.backend.domain.notification.repository.NotificationRepository;
import com.numberone.backend.domain.token.util.SecurityContextProvider;
import com.numberone.backend.provider.security.SecurityContextProvider;
import com.numberone.backend.exception.notfound.NotFoundArticleException;
import com.numberone.backend.exception.notfound.NotFoundCommentException;
import com.numberone.backend.exception.notfound.NotFoundMemberException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import com.numberone.backend.domain.conversation.dto.request.CreateChildConversationRequest;
import com.numberone.backend.domain.conversation.dto.request.CreateConversationRequest;
import com.numberone.backend.domain.conversation.dto.response.GetConversationResponse;
import com.numberone.backend.domain.conversation.service.ConversationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.numberone.backend.domain.disaster.dto.response;

import com.numberone.backend.domain.disaster.entity.Disaster;
import com.numberone.backend.domain.disaster.util.DisasterType;
import com.numberone.backend.domain.disaster.DisasterType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.numberone.backend.domain.conversation.dto.response.GetConversationResponse;
import com.numberone.backend.domain.disaster.entity.Disaster;
import com.numberone.backend.domain.disaster.util.DisasterType;
import com.numberone.backend.domain.disaster.DisasterType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.numberone.backend.domain.disaster.service;

import com.numberone.backend.domain.disaster.event.DisasterEvent;
import com.numberone.backend.domain.disaster.util.DisasterType;
import com.numberone.backend.domain.disaster.DisasterType;
import com.numberone.backend.domain.friendship.entity.Friendship;
import com.numberone.backend.domain.member.entity.Member;
import com.numberone.backend.domain.member.repository.MemberRepository;
Expand Down
Loading

0 comments on commit f51c13a

Please sign in to comment.