Skip to content

Commit

Permalink
Merge branch 'develop' into mvp/career
Browse files Browse the repository at this point in the history
  • Loading branch information
tape4 authored Jul 24, 2024
2 parents 4d9a2b8 + b6513c8 commit 03049c8
Show file tree
Hide file tree
Showing 67 changed files with 2,244 additions and 34 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/CICD_DEVELOP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ jobs:
- name: Generate application.properties
run: |
echo commit.hash=${{ steps.slug.outputs.sha7 }} >> ./src/main/resources/application-prod.properties
echo ${{ secrets.DATASOURCE_DB_URL }} >> ./src/main/resources/application-prod.properties
echo ${{ secrets.DATASOURCE_DB_USERNAME }} >> ./src/main/resources/application-prod.properties
echo ${{ secrets.DATASOURCE_DB_PASSWORD }} >> ./src/main/resources/application-prod.properties
echo "spring.datasource.url=jdbc:mysql://${{ secrets.DATASOURCE_DB_URL }}:3306/kkijuk?useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Seoul" >> ./src/main/resources/application-prod.properties
echo "spring.datasource.username=${{ secrets.DATASOURCE_DB_USERNAME }}" >> ./src/main/resources/application-prod.properties
echo "spring.datasource.password=${{ secrets.DATASOURCE_DB_PASSWORD }}" >> ./src/main/resources/application-prod.properties
- name: Build with Gradle Wrapper
run: ./gradlew build
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ out/

### VS Code ###
.vscode/

.DS_Store
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:17-alpine
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java", "-jar", "/app.jar", "--spring.profiles.active=prod "]
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=prod", "/app.jar"]
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repositories {

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package umc.kkijuk.server.common.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import umc.kkijuk.server.common.domian.exception.ResourceNotFoundException;
import umc.kkijuk.server.common.domian.exception.ReviewRecruitNotMatchException;
import umc.kkijuk.server.common.domian.response.ErrorResponse;

@RestControllerAdvice
@RequiredArgsConstructor
public class ExceptionControllerAdvice {

@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(ResourceNotFoundException.class)
public ErrorResponse resourceNotFoundException(ResourceNotFoundException exception) {
return new ErrorResponse(exception.getMessage());
}

@ResponseStatus(HttpStatus.FORBIDDEN)
@ExceptionHandler(ReviewRecruitNotMatchException.class)
public ErrorResponse ReviewRecruitMatchException(ReviewRecruitNotMatchException exception) {
return new ErrorResponse(exception.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package umc.kkijuk.server.common.domian.exception;

public class ResourceNotFoundException extends RuntimeException{
public ResourceNotFoundException(String dataSource, long id) {
super(dataSource + "에서 ID " + id + "를 찾을 수 없습니다.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package umc.kkijuk.server.common.domian.exception;

public class ReviewRecruitNotMatchException extends RuntimeException{
public ReviewRecruitNotMatchException(long recruitId, long reviewId) {
super("Recruit "+ recruitId + "에서 Review " + reviewId + "를 찾을수 없습니다.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package umc.kkijuk.server.common.domian.response;

import lombok.Getter;

@Getter
public class ErrorResponse {
private final String message;

public ErrorResponse(String message) {
this.message = message;
}
}
30 changes: 30 additions & 0 deletions src/main/java/umc/kkijuk/server/introduce/common/BaseResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package umc.kkijuk.server.introduce.common;

import lombok.Getter;

@Getter
public class BaseResponse<T> {

private final int status;
private String message;
private T data;

// Response constructor that includes status, message, and data
public BaseResponse(int status, String message, T data) {
this.status = status;
this.message = message;
this.data = data;
}

// Response constructor that includes status and message only
public BaseResponse(int status, String message) {
this.status = status;
this.message = message;
}

// Response constructor that includes status and data only
public BaseResponse(int status, T data) {
this.status = status;
this.data = data;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package umc.kkijuk.server.introduce.controller;

public class IntroduceController {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package umc.kkijuk.server.introduce.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import umc.kkijuk.server.introduce.common.BaseResponse;
import umc.kkijuk.server.introduce.domain.MasterIntroduce;
import umc.kkijuk.server.introduce.dto.MasterIntroduceReqDto;
import umc.kkijuk.server.introduce.dto.MasterIntroduceResDto;
import umc.kkijuk.server.introduce.error.BaseErrorResponse;
import umc.kkijuk.server.introduce.error.BaseException;
import umc.kkijuk.server.introduce.service.MasterIntroduceService;

import java.util.List;

@Tag(name = "master", description = "마스터 자기소개서 API")
@RestController
@RequiredArgsConstructor
@RequestMapping("/history/intro/master")
public class MasterIntroduceController {
private final MasterIntroduceService masterIntroduceService;

@PostMapping
public ResponseEntity<Object> save(@RequestBody MasterIntroduceReqDto masterIntroduceReqDto){
try {
MasterIntroduceResDto masterIntroduceResDto = masterIntroduceService.saveMasterIntro(masterIntroduceReqDto);
return ResponseEntity
.status(HttpStatus.OK)
.body(new BaseResponse<>(HttpStatus.OK.value(), "마스터 자기소개서 생성 완료", masterIntroduceResDto));
} catch (BaseException e) {
return ResponseEntity
.status(e.getCode())
.body(new BaseErrorResponse(e.getCode(), e.getMessage()));
} catch (Exception e) {
return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(new BaseErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error"));
}
}

@GetMapping
public ResponseEntity<Object> get(){
try {
List<MasterIntroduce> masterIntroduce = masterIntroduceService.getMasterIntro();
return ResponseEntity
.status(HttpStatus.OK)
.body(new BaseResponse<>(HttpStatus.OK.value(), "마스터 자기소개서 조회 완료", masterIntroduce));
} catch (BaseException e) {
return ResponseEntity
.status(e.getCode())
.body(new BaseErrorResponse(e.getCode(), e.getMessage()));
} catch (Exception e) {
return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(new BaseErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error"));
}
}

@PatchMapping
public ResponseEntity<Object> update(Long id, @RequestBody MasterIntroduceReqDto masterIntroduceReqDto){
try {
MasterIntroduceResDto masterIntroduceResDto = masterIntroduceService.updateMasterIntro(id, masterIntroduceReqDto);
return ResponseEntity
.status(HttpStatus.OK)
.body(new BaseResponse<>(HttpStatus.OK.value(), "마스터 자기소개서 수정 완료", masterIntroduceResDto));
} catch (BaseException e) {
return ResponseEntity
.status(e.getCode())
.body(new BaseErrorResponse(e.getCode(), e.getMessage()));
} catch (Exception e) {
return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(new BaseErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error"));
}
}

}
15 changes: 15 additions & 0 deletions src/main/java/umc/kkijuk/server/introduce/domain/Introduce.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package umc.kkijuk.server.introduce.domain;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;

@Entity
@Table(name="introduce")
@Getter
public class Introduce {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package umc.kkijuk.server.introduce.domain;

import org.springframework.data.jpa.repository.JpaRepository;

public interface IntroduceRepository extends JpaRepository<Introduce, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package umc.kkijuk.server.introduce.domain;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import org.springframework.data.annotation.CreatedDate;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

@Entity
@Table(name = "master_introduce")
@Getter
@NoArgsConstructor
public class MasterIntroduce {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Size(max = 24)
private String oneLiner;

private String subTitle;
private String content;

@CreationTimestamp
private LocalDateTime created_at;

@UpdateTimestamp
private LocalDateTime updated_at;

@Builder
public MasterIntroduce(String oneLiner, String subTitle, String content) {
this.oneLiner = oneLiner;
this.subTitle = subTitle;
this.content = content;
}

public String getUpdated_at() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
return updated_at != null ? updated_at.format(formatter) : null;
}

public void update(String oneLiner, String subTitle, String content) {
this.oneLiner = oneLiner;
this.subTitle = subTitle;
this.content = content;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package umc.kkijuk.server.introduce.domain;

import org.springframework.data.jpa.repository.JpaRepository;

public interface MasterIntroduceRepository extends JpaRepository<MasterIntroduce, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package umc.kkijuk.server.introduce.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

@Builder
@AllArgsConstructor
@Getter
public class MasterIntroduceReqDto {
private String oneLiner;
private String subTitle;
private String content;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package umc.kkijuk.server.introduce.dto;

import lombok.*;
import umc.kkijuk.server.introduce.domain.MasterIntroduce;

import java.time.LocalDateTime;

@Getter
@Setter
public class MasterIntroduceResDto {
private String oneLiner;
private String subTitle;
private String content;
private String updatedAt;

@Builder
public MasterIntroduceResDto(MasterIntroduce masterIntroduce) {
this.oneLiner = masterIntroduce.getOneLiner();
this.subTitle = masterIntroduce.getSubTitle();
this.content = masterIntroduce.getContent();
this.updatedAt = masterIntroduce.getUpdated_at();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package umc.kkijuk.server.introduce.error;
import lombok.Getter;

@Getter
public class BaseErrorResponse {
private final int status;
private final String message;

public BaseErrorResponse(int status, String message) {
this.status = status;
this.message = message;
}

public BaseErrorResponse(BaseException baseException) {
this.status = baseException.getCode();
this.message = baseException.getMessage();
}
}
16 changes: 16 additions & 0 deletions src/main/java/umc/kkijuk/server/introduce/error/BaseException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package umc.kkijuk.server.introduce.error;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class BaseException extends RuntimeException{
private final int code;
private final String message;

public BaseException(int code, String message) {
this.code = code;
this.message = message;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package umc.kkijuk.server.introduce.error;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; // 여기에 추가

@ControllerAdvice
public class GlobalExceptionHandler {

@ExceptionHandler(Exception.class)
public ResponseEntity<BaseErrorResponse> handleException(Exception e) {
BaseException exception = new BaseException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage());
return ResponseEntity.status(exception.getCode()).body(new BaseErrorResponse(exception));
}

@ExceptionHandler(BaseException.class)
public ResponseEntity<BaseErrorResponse> handleBaseException(BaseException e) {
return ResponseEntity.status(e.getCode()).body(new BaseErrorResponse(e));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package umc.kkijuk.server.introduce.service;

public class IntroduceService {
}
Loading

0 comments on commit 03049c8

Please sign in to comment.