Skip to content

Commit

Permalink
Dev Branch Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
bongsh0112 committed Sep 16, 2023
2 parents d6bfeea + a456040 commit fa603dd
Show file tree
Hide file tree
Showing 24 changed files with 412 additions and 32 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/DBDOCS_BUILD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: DBDOCS_BUILD

on:
push:
branches: [ "dev" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

# DBDocs Install
- name: Install dbdocs
run: sudo npm install -g dbdocs

#DBDocs Install Check
- name: Check dbdocs
run: dbdocs

# Runs a set of commands using the runners shell
- name: Update dbdocs project

env:
DBDOCS_TOKEN: ${{ secrets.DBDOCS_TOKEN }}
run: dbdocs build ./Docs/Picasso.dbml --project=Picasso
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ jobs:
pwd
cd /var/app
ls -al
nohup java -jar -Dnaver.storage.access-key=${{ secrets.ACCESS_KEY }} -Dnaver.storage.secret-key=${{ secrets.SECRET_KEY }} app.jar > nohup.log &
nohup java -jar -Dnaver.storage.access-key=${{ secrets.ACCESS_KEY }} -Dnaver.storage.secret-key=${{ secrets.SECRET_KEY }} app.jar > nohup.log &
6 changes: 5 additions & 1 deletion Api/src/main/java/picasso/server/api/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
// EnableJpaRepositories Reference : https://stackoverflow.com/questions/46732402/spring-boot-autowiring-of-beans-is-not-working-in-maven-multi-module-project
@Slf4j
@EntityScan("picasso.server.domain")
@ComponentScan(basePackages = {"picasso.server"})
@EnableJpaRepositories(basePackages = {"picasso.server.domain"})
@SpringBootApplication
@RequiredArgsConstructor
public class Application {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package picasso.server.api.test;
package picasso.server.api;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;


@Slf4j
@Controller
public class HomeController {
@GetMapping("/")
public String index() {
return "/index";
}

@GetMapping("/layout")
public String layout() {
return "/test_layout";
}
}
21 changes: 21 additions & 0 deletions Api/src/main/java/picasso/server/api/TestService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package picasso.server.api;

import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import picasso.server.domain.domains.test.Test;
import picasso.server.domain.domains.test.TestRepository;

import java.util.Optional;

@Service
@Transactional
@RequiredArgsConstructor
public class TestService {
private final TestRepository testRepository;


public Optional<Test> test() {
return testRepository.findById(1L);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package picasso.server.api.config.advice;

import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import picasso.server.common.dto.ErrorDetail;
import picasso.server.common.exception.BaseException;
import picasso.server.common.exception.GlobalException;

//TODO : 현재 `GlobalRestControllerExceptionHandler`와 동일한 코드, 추후 수정 필요
@Slf4j
@RequiredArgsConstructor
@RestControllerAdvice
public class GlobalControllerExceptionHandler {
@ExceptionHandler(BaseException.class)
protected ResponseEntity<ErrorDetail> baseExceptionHandle(BaseException e, HttpServletRequest request) {
ErrorDetail errorDetail = e.getErrorCode().getErrorDetail();
log.warn("ExceptionName >>> {}, ErrorCode >>> {}, ExceptionReason >>> {}",
e.getClass(), errorDetail.getStatusCode(), errorDetail.getReason());

return ResponseEntity.status(errorDetail.getStatusCode()).body(errorDetail);
}

@ExceptionHandler(MethodArgumentNotValidException.class)
protected ResponseEntity<ErrorDetail> argumentNotValidHandle(MethodArgumentNotValidException e, HttpServletRequest request) {
ErrorDetail errorDetail = ErrorDetail.builder()
.statusCode(GlobalException.METHOD_ARGUMENT_ERROR.getStatusCode())
.reason(GlobalException.METHOD_ARGUMENT_ERROR.getReason())
.build();
return ResponseEntity.status(errorDetail.getStatusCode()).body(errorDetail);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package picasso.server.api.config.advice;

import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import picasso.server.common.dto.ErrorDetail;
import picasso.server.common.exception.BaseException;
import picasso.server.common.exception.GlobalException;

//TODO : 현재 `GlobalControllerExceptionHandler`와 동일한 코드, 추후 수정 필요
@Slf4j
@RequiredArgsConstructor
@RestControllerAdvice
public class GlobalRestControllerExceptionHandler {
@ExceptionHandler(BaseException.class)
protected ResponseEntity<ErrorDetail> baseExceptionHandle(BaseException e, HttpServletRequest request) {
ErrorDetail errorDetail = e.getErrorCode().getErrorDetail();
log.warn("ExceptionName >>> {}, ErrorCode >>> {}, ExceptionReason >>> {}",
e.getClass(), errorDetail.getStatusCode(), errorDetail.getReason());

return ResponseEntity.status(errorDetail.getStatusCode()).body(errorDetail);
}

@ExceptionHandler(MethodArgumentNotValidException.class)
protected ResponseEntity<ErrorDetail> argumentNotValidHandle(MethodArgumentNotValidException e, HttpServletRequest request) {
ErrorDetail errorDetail = ErrorDetail.builder()
.statusCode(GlobalException.METHOD_ARGUMENT_ERROR.getStatusCode())
.reason(GlobalException.METHOD_ARGUMENT_ERROR.getReason())
.build();
return ResponseEntity.status(errorDetail.getStatusCode()).body(errorDetail);
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package picasso.server.api.test;
package picasso.server.api.config.controller;


import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequestMapping("/test")
@RequiredArgsConstructor
@RestController
public class TestController {
private final TestMessage testMessage;
@RequestMapping("/health")
public class HealthController {

@GetMapping
public String rtnMsg() {
return testMessage.toString();
public ResponseEntity healthCheck() {
return ResponseEntity.ok().build();
}
}
12 changes: 0 additions & 12 deletions Api/src/main/java/picasso/server/api/test/TestMessage.java

This file was deleted.

29 changes: 29 additions & 0 deletions Api/src/main/resources/static/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* footer */
footer {
border-top: 1px solid #eee;
padding-top: 12px;
padding-bottom: 10px;
background-color: #bdbdbd;
}
footer .title {
font-weight: 700;
font-size: 16px;
color: #242424;
padding-left: 10px;
margin-bottom: 0;
}
footer .footer-menu {
margin-top: 24px;
display: flex;
justify-content: space-between;
}
footer .footer-menu li a {
font-size: 12px;
color: #6f6f6f;
}
footer .copyright {
color: #6f6f6f;
font-size: 10px;
margin-top: 10px;
padding-left: 10px;
}
2 changes: 2 additions & 0 deletions Api/src/main/resources/templates/fragment/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<link rel="stylesheet" type="text/css" href="/static/css/reset.css" />
<link rel="stylesheet" type="text/css" href="/static/css/normalize.css" />

<link rel="stylesheet" type="text/css" href="/static/css/style.css" />


<!-- Font -->
<link rel="stylesheet" as="style" crossorigin
Expand Down
15 changes: 13 additions & 2 deletions Api/src/main/resources/templates/fragment/footer.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<footer th:fragment="footerFragment">
<div style="background-color: rgba(61,255,37,0.41)">
footer.html
<div class="row">
<div class="col-12">
<div class="title">Picasso</div>
<ul class="footer-menu clearfix">
<li><a href="#">김선래</a></li>
<li><a href="#">곽나현</a></li>
<li><a href="#">오동현</a></li>
<li><a href="#">김현덕</a></li>
<li><a href="#">봉세환</a></li>
<li><a href="#">김종원</a></li>
</ul>
<p class="copyright">Copyright © 2023</p>
</div>
</div>
</footer>

Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package picasso.server.common.config;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties({
})
public class ConfigurationPropertiesConfig {
}
21 changes: 21 additions & 0 deletions Common/src/main/java/picasso/server/common/dto/ErrorDetail.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package picasso.server.common.dto;

import lombok.Builder;
import lombok.Getter;

/**
* StatusCode : ControllerAdvice, RestControllerAdvice에서 ResponseEntity의 Status를 찾기 위함.
* Reason : ResponseEntity에서 내용반환에 필요한 컬럼
*/
@Getter
@Builder
public class ErrorDetail {
private final Integer statusCode;
private final String reason;
public static ErrorDetail of(Integer statusCode, String reason ) {
return ErrorDetail.builder()
.statusCode(statusCode)
.reason(reason)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package picasso.server.common.exception;

import picasso.server.common.dto.ErrorDetail;

public interface BaseErrorCode {
ErrorDetail getErrorDetail();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package picasso.server.common.exception;

import lombok.AllArgsConstructor;
import lombok.Getter;
import picasso.server.common.dto.ErrorDetail;

@Getter
@AllArgsConstructor
public abstract class BaseException extends RuntimeException {
private BaseErrorCode errorCode;

public ErrorDetail getErrorDetail() {
return this.errorCode.getErrorDetail();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package picasso.server.common.exception;

public class ExampleException extends BaseException {

public static final BaseException EXCEPTION = new ExampleException();

private ExampleException() {
super(GlobalException.EXAMPLE_ERROR);
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package picasso.server.common.exception;

import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;

import lombok.AllArgsConstructor;
import lombok.Getter;
import picasso.server.common.dto.ErrorDetail;

@Getter
@AllArgsConstructor
public enum GlobalException implements BaseErrorCode {
EXAMPLE_ERROR(BAD_REQUEST.value(), "에러 예시 입니다."),
METHOD_ARGUMENT_ERROR(BAD_REQUEST.value(), "메서드 인자가 유효하지 않거나 @Valid를 통과하지 못하여 발생하는 예외입니다."),
INTERNAL_SERVER_ERRORS(INTERNAL_SERVER_ERROR.value(), "서버 내부 오류입니다."),
DATE_FORMAT_ERROR(BAD_REQUEST.value(), "날짜 형식을 확인해주세요."),
;

private final Integer statusCode;
private final String reason;

@Override
public ErrorDetail getErrorDetail() {
return ErrorDetail.of(statusCode, reason);
}
}
Loading

0 comments on commit fa603dd

Please sign in to comment.