Skip to content

Commit

Permalink
Merge branch 'develop' into fe/design/#50
Browse files Browse the repository at this point in the history
  • Loading branch information
jung2941 committed Sep 29, 2024
2 parents 5089fbe + f0e73ad commit 5fad487
Show file tree
Hide file tree
Showing 60 changed files with 2,976 additions and 367 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codereview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ permissions:

on:
pull_request:
types: [opened, reopened, synchronize]
types: [opened, reopened]

jobs:
test:
Expand Down
4 changes: 3 additions & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ out/
### Generated ###
/src/main/generated/

.env
backend-secret.env
.env_*
.DS_Store
43 changes: 43 additions & 0 deletions backend/Dockerfile-develop
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM openjdk:17
COPY --from=builder build/libs/*.jar app.jar
# builder 이미지에서 build/libs/*.jar 파일을 app.jar로 복사

FROM openjdk:17 AS builder
VOLUME /tmp

COPY ./gradlew .
# gradlew 복사
COPY ./gradle gradle
# gradle 복사
COPY ./build.gradle .
# build.gradle 복사
COPY ./settings.gradle .
# settings.gradle 복사
COPY ./src src
# 웹 어플리케이션 소스 복사
RUN chmod +x ./gradlew
# gradlew 실행 권한 부여

# 불필요한 패키지 설치 제거 (필요 없으면)
RUN microdnf install findutils

RUN ./gradlew bootJar
# 실행 가능한 JAR 파일 생성

# 최종 이미지
FROM openjdk:17
COPY --from=builder build/libs/*.jar app.jar
# 빌더에서 생성된 JAR 파일을 복사

# RUN mkdir -p /var/log/spring-boot
# 로그 디렉토리 생성

EXPOSE 8080
# 컨테이너의 8080 포트를 외부로 노출

COPY wait-for-it.sh wait-for-it.sh
RUN chmod +x wait-for-it.sh
# wait-for-it.sh 스크립트 복사 및 실행 권한 부여

# wait-for-it.sh가 성공한 후 애플리케이션 실행
ENTRYPOINT ["./wait-for-it.sh", "mysqldb:3306", "-s", "-t", "100", "--", "java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/app.jar"]
6 changes: 5 additions & 1 deletion backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,18 @@ dependencies {
// implementation 'mysql:mysql-connector-j'
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-web'

implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'io.jsonwebtoken:jjwt:0.12.5'

implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
// implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-validation'



implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.4'
implementation 'org.springframework.boot:spring-boot-starter-web'
// implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
Expand Down
43 changes: 43 additions & 0 deletions backend/docker-compose.deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
services:
db:
image: mysql:8.0
container_name: mysqldb
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}


backend:
build:
context: .
dockerfile: Dockerfile-develop
container_name: backend
restart: always
depends_on:
- db
environment:
SPRING_DATASOURCE_URL: ${MYSQL_URL}
SPRING_DATASOURCE_USERNAME: ${MYSQL_USER}
SPRING_DATASOURCE_PASSWORD: ${MYSQL_PASSWORD}
ports:
- "8080:8080"
volumes:
- .:/app
# - ./logs:/var/log/spring-boot

agent:
container_name: newrelic-infra
build:
context: .
dockerfile: newrelic-infra.dockerfile
cap_add:
- SYS_PTRACE
network_mode: bridge
pid: host
privileged: true
volumes:
- "/:/host:ro"
- "/var/run/docker.sock:/var/run/docker.sock"
restart: unless-stopped
43 changes: 21 additions & 22 deletions backend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
services:
# backend:
# build:
# context: .
# container_name: backend
# restart: always
# environment:
# SPRING_DATASOURCE_URL: ${MYSQL_URL}
# SPRING_DATASOURCE_USERNAME: ${MYSQL_USER}
# SPRING_DATASOURCE_PASSWORD: ${MYSQL_PASSWORD}
# SPRING_PROFILES_ACTIVE: prod
# ports:
# - "8080:8080"
# env_file:
# - .env
# volumes:
# - .:/app
# - ./logs:/var/log/spring-boot

mysqldb:
db:
image: mysql:8.0
container_name: mysqldb
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: techeer
MYSQL_ROOT_PASSWORD: "1234"
env_file:
- backend-secret.env

backend:
build:
context: .
dockerfile: Dockerfile-develop
container_name: backend
restart: always
depends_on:
- db
env_file:
- backend-secret.env
ports:
- "8080:8080"
volumes:
- .:/app
# - ./logs:/var/log/spring-boot


2 changes: 2 additions & 0 deletions backend/newrelic-infra.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM newrelic/infrastructure:latest
ADD newrelic-infra/newrelic-infra.yml /etc/newrelic-infra.yml
1 change: 1 addition & 0 deletions backend/newrelic-infra/newrelic-infra.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
license_key: ${NEW_RELIC_LICENSE_KEY}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.techeer.backend.api.feedback.controller;

import com.techeer.backend.api.feedback.service.FeedbackService;
import com.techeer.backend.api.feedback.dto.FeedbackCreateRequest;
import com.techeer.backend.api.feedback.dto.FeedbackResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;


@Slf4j
@Tag(name = "이력서 피드백 등록 API", description = "Feedback API")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/resumes/") // 공통 api
public class FeedbackController {

private final FeedbackService feedbackService;


@Operation(summary = "피드백 등록", description = "원하는 위치에 피드백을 작성합니다.")
@PostMapping("/{resume_id}/feedbacks")
public ResponseEntity<FeedbackResponse> createFeedback(
@PathVariable Long resume_id,
@Valid @RequestBody FeedbackCreateRequest feedbackRequest) {

log.info("이력서 ID: {} 에 대한 피드백 생성 요청", resume_id);

// 피드백 생성 후 응답 생성
FeedbackResponse feedbackResponse = feedbackService.createFeedback(
resume_id,
feedbackRequest.getContent(),
feedbackRequest.getXCoordinate(),
feedbackRequest.getYCoordinate()
);

log.info("피드백 생성 완료: {}", feedbackResponse);

return new ResponseEntity<>(feedbackResponse, HttpStatus.CREATED);
}

@Operation(summary = "피드백 삭제")
@DeleteMapping("/{resume_id}/feedbacks/{feedback_id}")
public ResponseEntity<Void> deleteFeedback(
@PathVariable Long resume_id,
@PathVariable Long feedback_id) {

log.info("이력서 ID: {}, 피드백 ID: {} 에 대한 삭제 요청", resume_id, feedback_id);

feedbackService.deleteFeedbackById(resume_id, feedback_id);

return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.techeer.backend.api.feedback.domain;

import com.techeer.backend.api.resume.domain.Resume;
import com.techeer.backend.global.common.BaseEntity;
import jakarta.persistence.*;
import lombok.Builder;
import lombok.Getter;

import java.math.BigDecimal;

@Getter
@Entity
@Table(name = "FEEDBACK")
public class Feedback extends BaseEntity {

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

// 한 개의 이력서가 여러 개의 피드백을 가질 수 있음.
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "resume_id", nullable = false)
private Resume resume;

@Column(nullable = false, length = 255)
private String content;

@Column(precision = 10, scale = 6)
private BigDecimal xCoordinate;

@Column(nullable = false,precision = 10, scale = 6)
private BigDecimal yCoordinate;

// 기본 생성자
protected Feedback() {
}

// 모든 필드를 포함한 생성자
public Feedback(Resume resume, String content, BigDecimal xCoordinate, BigDecimal yCoordinate) {
this.resume = resume;
this.content = content;
this.xCoordinate = xCoordinate;
this.yCoordinate = yCoordinate;
}

// Builder 패턴을 사용한 생성자
@Builder
public static Feedback createFeedback(Resume resume, String content, BigDecimal xCoordinate, BigDecimal yCoordinate) {
return new Feedback(resume, content, xCoordinate, yCoordinate);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.techeer.backend.api.feedback.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

import java.math.BigDecimal;

@Getter
@AllArgsConstructor
@ToString
public class FeedbackCreateRequest {

@NotBlank(message = "content는 필수입니다.")
private String content;

@NotNull(message = "x 좌표는 필수입니다.")
@JsonProperty("xCoordinate")
private BigDecimal xCoordinate;

@NotNull(message = "y 좌표는 필수입니다.")
@JsonProperty("yCoordinate")
private BigDecimal yCoordinate;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.techeer.backend.api.feedback.dto;

import lombok.Builder;
import lombok.Getter;

import java.math.BigDecimal;

@Getter
public class FeedbackResponse {

private final Long feedbackId;
private final Long resumeId;
private final String content;
private final BigDecimal xCoordinate;
private final BigDecimal yCoordinate;

@Builder
private FeedbackResponse(Long feedbackId, Long resumeId, String content, BigDecimal xCoordinate, BigDecimal yCoordinate) {
this.feedbackId = feedbackId;
this.resumeId = resumeId;
this.content = content;
this.xCoordinate = xCoordinate;
this.yCoordinate = yCoordinate;
}

public static FeedbackResponse of(Long feedbackId, Long resumeId, String content, BigDecimal xCoordinate, BigDecimal yCoordinate) {
return FeedbackResponse.builder()
.feedbackId(feedbackId)
.resumeId(resumeId)
.content(content)
.xCoordinate(xCoordinate)
.yCoordinate(yCoordinate)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.techeer.backend.api.feedback.repository;

import com.techeer.backend.api.feedback.domain.Feedback;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface FeedbackRepository extends JpaRepository<Feedback, Long> {
Optional<Feedback> findByIdAndResumeId(Long id, Long resumeId);
List<Feedback> findAllByResumeId(Long resumeId);
}
Loading

0 comments on commit 5fad487

Please sign in to comment.