Skip to content
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
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.idea/
*.iml
*.iws
target/
.sonar/
.sonarlint/
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Stage 1: Build
FROM openjdk:17-jdk-slim AS builder

# 작업 디렉토리 설정
WORKDIR /app

# Gradle Wrapper와 설정 파일 복사
COPY gradle /app/gradle
COPY gradlew /app/gradlew
COPY build.gradle /app/
COPY settings.gradle /app/

# Gradle 의존성 캐시를 먼저 준비
RUN ./gradlew build -x test --no-daemon || return 0

# 나머지 소스 코드 복사
COPY src /app/src
COPY .env /app/.env

# Gradle Wrapper를 사용하여 clean과 build 실행
RUN ./gradlew clean build -x test --no-daemon

# Stage 2: Run
FROM openjdk:17-jdk-slim

# 작업 디렉토리 설정
WORKDIR /app

# 빌드 결과물 복사
COPY --from=builder /app/build/libs/*.jar app.jar

# 포트 노출
EXPOSE 8080

# 애플리케이션 실행
ENTRYPOINT ["java", "-jar", "app.jar"]
6 changes: 2 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'

compileOnly 'org.projectlombok:lombok'
// runtimeOnly 'com.mysql:mysql-connector-j'
runtimeOnly 'com.mysql:mysql-connector-j'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
Expand Down Expand Up @@ -78,8 +77,7 @@ dependencies {
//WIREMOCK (외부 의존성 테스트용)
implementation 'org.wiremock.integrations:wiremock-spring-boot:3.3.0'

// ModelMapper 사용
//객체 간 매핑 처리
// ModelMapper 사용, 객체 간 매핑 처리
implementation 'org.modelmapper:modelmapper:3.1.0'

// swagger
Expand Down
29 changes: 29 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
services:
mongodb:
image: mongo:latest
container_name: mongodb
ports:
- "27017:27017"
volumes:
- mongodb_data:/data/db
env_file:
- .env

backend:
image: taeyoungkims/danpat:latest
container_name: backend
ports:
- "8080:8080"
volumes:
- logs:/app/logs
- ./src:/app/src
environment:
- SPRING_DATA_MONGODB_URI=${MONGO_URI}
env_file:
- .env
depends_on:
- mongodb

volumes:
mongodb_data:
logs:
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ public class QLocation extends EntityPathBase<Location> {

public static final QLocation location = new QLocation("location");

public final com.example.api.domain.QBaseEntity _super = new com.example.api.domain.QBaseEntity(this);

public final StringPath address = createString("address");

//inherited
public final DateTimePath<java.time.LocalDateTime> createdDate = _super.createdDate;

public final StringPath detailAddress = createString("detailAddress");

public final NumberPath<Long> id = createNumber("id", Long.class);

//inherited
public final DateTimePath<java.time.LocalDateTime> updatedDate = _super.updatedDate;

public final StringPath zipcode = createString("zipcode");

public QLocation(String variable) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/generated/com/example/api/domain/QReviewReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@ public class QReviewReport extends EntityPathBase<ReviewReport> {

public static final QReviewReport reviewReport = new QReviewReport("reviewReport");

public final QBaseEntity _super = new QBaseEntity(this);

//inherited
public final DateTimePath<java.time.LocalDateTime> createdDate = _super.createdDate;

public final StringPath reason = createString("reason");

public final NumberPath<Long> reportId = createNumber("reportId", Long.class);

public final QReview review;

//inherited
public final DateTimePath<java.time.LocalDateTime> updatedDate = _super.updatedDate;

public QReviewReport(String variable) {
this(ReviewReport.class, forVariable(variable), INITS);
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/example/api/account/entity/Location.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.api.account.entity;

import com.example.api.domain.BaseEntity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.ToString;
Expand All @@ -9,7 +10,7 @@
@Entity
@Getter
@ToString
public class Location {
public class Location extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "LOCATION_UNIQUE_ID")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
"join oe.business b " +
"where b.businessId = :businessId and c.contractSucceeded = true")
List<ReviewAvailableResponse> findAvailableReviewsByBusinessId(@Param("businessId") Long businessId);

}
3 changes: 3 additions & 0 deletions src/main/java/com/example/api/contracts/ContractService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import com.example.api.contracts.dto.*;
import com.example.api.contracts.update.UpdateContractConditionManager;
import com.example.api.domain.ChatRoom;
import com.example.api.contracts.dto.AcceptSuggestCommand;
import com.example.api.contracts.dto.UpdateContractConditionCommand;
import com.example.api.contracts.dto.QueryAllSuggestsForMeCommand;
import com.example.api.domain.Contract;
import com.example.api.domain.OfferEmployment;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package com.example.api.contracts.controller;

import com.example.api.contracts.dto.ContractDTO;
import com.example.api.contracts.ContractService;
import com.example.api.contracts.dto.AcceptContractCommand;
import com.example.api.contracts.dto.AcceptSuggestCommand;
import com.example.api.contracts.dto.QueryAllSuggestsForMeCommand;
import com.example.api.contracts.dto.SuggestedBusinessResponse;
import com.example.api.contracts.dto.UpdateContractConditionCommand;
import com.example.api.contracts.dto.UpdateContractConditionRequest;
import com.example.api.contracts.dto.*;

import java.time.LocalDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
Expand All @@ -30,20 +26,13 @@ public ResponseEntity<List<SuggestedBusinessResponse>> getAllSuggest(

@PostMapping("/api/v1/contracts/suggests/{suggestId}/accept")
public ResponseEntity<?> acceptContractContact(
@RequestBody final AcceptSuggestCommand acceptSuggestCommand
@PathVariable(required = true) final Long suggestId
) {
final AcceptSuggestCommand acceptSuggestCommand = new AcceptSuggestCommand(suggestId);
contractService.acceptSuggest(acceptSuggestCommand);
return ResponseEntity.ok(null);
}

@PostMapping("/api/v1/contracts/suggests/{suggestId}/chatroom")
public ResponseEntity<?> createChatRoom(
@RequestBody final AcceptSuggestCommand acceptSuggestCommand
) {
contractService.createChatRoom(acceptSuggestCommand);
return ResponseEntity.ok(null);
}

@PutMapping("/api/v1/contracts/{contractId}")
public ResponseEntity<?> updateContractCondition(
@PathVariable(required = true) final Long contractId,
Expand All @@ -54,6 +43,24 @@ public ResponseEntity<?> updateContractCondition(
return ResponseEntity.ok(null);
}

record UpdateContractConditionRequest(
LocalDateTime suggestStartDateTime,
LocalDateTime suggestEndDateTime,
Integer suggestHourlyPayment
) {
UpdateContractConditionCommand toCommand(final Long contractId) {
return new UpdateContractConditionCommand(contractId, this.suggestStartDateTime, this.suggestEndDateTime, this.suggestHourlyPayment);
}
}

@PostMapping("/api/v1/contracts/suggests/{suggestId}/chatroom")
public ResponseEntity<?> createChatRoom(
@RequestBody final AcceptSuggestCommand acceptSuggestCommand
) {
contractService.createChatRoom(acceptSuggestCommand);
return ResponseEntity.ok(null);
}

@PostMapping("/api/v1/contracts/{contractId}/accepts")
public ResponseEntity<?> acceptContract(
@PathVariable(required = true) final Long contractId
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/example/api/domain/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,8 @@ public void setDeleted(boolean deleted){
public void setOpenStatus(boolean openStatus) {
this.openStatus = openStatus;
}

public void setAccountId(long l) {
this.accountId = l;
}
}
2 changes: 2 additions & 0 deletions src/main/java/com/example/api/domain/ChatRoom.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import jakarta.persistence.*;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

Expand All @@ -12,6 +13,7 @@
@Getter
@EqualsAndHashCode
@Table(name = "CHAT_ROOM")
@NoArgsConstructor
public class ChatRoom {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/example/api/domain/Contract.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.time.LocalDateTime;

@Entity
@Setter
@Getter
@Table(name = "CONTRACT")
@EqualsAndHashCode(callSuper = false)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/example/api/domain/ExternalCareer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@Entity
@Getter
@EqualsAndHashCode(callSuper = false)
@Table(name = "EXTERANL_CARRER")
@Table(name = "EXTERNAL_CAREER")
public class ExternalCareer extends BaseEntity{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/com/example/api/domain/OfferEmployment.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import lombok.*;

import java.time.LocalDateTime;

import static jakarta.persistence.FetchType.*;

@Entity
Expand All @@ -21,29 +20,21 @@ public class OfferEmployment {
@OneToOne(fetch = LAZY)
@JoinColumn(name = "BUSINESS_ID", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
private Business business;

@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "EMPLOYEE_ID")
private Account employee;

@OneToOne(mappedBy = "offerEmployment", cascade = CascadeType.ALL)
private Contract contract;

@Column(name = "SUGGEST_START_TIME")
private LocalDateTime suggestStartTime;

@Column(name = "SUGGEST_END_TIME")
private LocalDateTime suggestEndTime;

@Column(name = "SUGGEST_HOURLY_PAY")
private int suggestHourlyPay;

@Column(name = "SUGGEST_READED", columnDefinition = "boolean DEFAULT false")
private boolean suggestReaded;

@Column(name = "SUGGEST_SUCCEDED", columnDefinition = "boolean DEFAULT false")
private boolean suggestSucceeded;

@Column(name = "SUGGEST_REGISTER_TIME")
private LocalDateTime suggestRegisterTime;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/example/api/domain/ReviewReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "REVIEW_REPORT")
public class ReviewReport {
public class ReviewReport extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long reportId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
exceptionHandling.authenticationEntryPoint(new FailedAuthenticationEntryPoint()))
.authorizeHttpRequests(authorize -> authorize
.requestMatchers("/**", "/error", "/favicon.ico", "/**/*.png", "/**/*.gif","/**/*.webp", "/**/*.svg", "/**/*.jpg", "/**/*.html", "/**/*.css", "/**/*.js").permitAll()
.requestMatchers("/api/auth/**", "/oauth2/**", "/swagger-ui/**", "/v3/api-docs/**", "/api/v1/**", "/aws").permitAll()
.requestMatchers("/api/auth/**", "/oauth2/**", "/swagger-ui/**", "/v3/api-docs/**", "/api/v1/**", "/aws", "/ws/**").permitAll()
.anyRequest().authenticated()
)
.oauth2Login(oauth2 -> oauth2
Expand Down
34 changes: 14 additions & 20 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,28 @@ spring.application.name=api

spring.config.import=optional:file:.env[.properties]

# H2 Database Configuration (In-Memory)
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
# mysql Database Configuration
spring.datasource.url=jdbc:mysql://52.79.243.139:3306/danpat?useSSL=false&serverTimezone=Asia/Seoul&characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=password
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

# Mongo Database Configuration
spring.data.mongodb.auto-index-creation=true

# JPA and Hibernate Configuration
spring.jpa.hibernate.ddl-auto=create
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect

# H2 Console Configuration
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect

# Logging (Optional)
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE

# Mongo Database Configuration
spring.data.mongodb.uri=mongodb://localhost:27017/testdb

spring.data.mongodb.host=localhost
#spring.data.mongodb.port=27017
#spring.data.mongodb.authentication-database=admin
#spring.data.mongodb.database=testdb
#spring.data.mongodb.auto-index-creation=true
logging.file.name=/app/logs/application.log
logging.level.root=INFO
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n
logging.pattern.file=%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n

# SMTP
spring.mail.host=smtp.gmail.com
Expand Down
Loading
Loading