-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
동시성 이슈 : 분산 Lock으로 해결
- Loading branch information
Showing
7 changed files
with
7,880 additions
and
89 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
src/main/java/com/soongsil/CoffeeChat/controller/handler/ApplicationExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.soongsil.CoffeeChat.controller.handler; | ||
|
||
import com.soongsil.CoffeeChat.controller.ApplicationController; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.server.ResponseStatusException; | ||
|
||
@ControllerAdvice(assignableTypes = ApplicationController.class) | ||
public class ApplicationExceptionHandler { | ||
|
||
@ExceptionHandler(ResponseStatusException.class) | ||
public ResponseEntity<String> handleResponseStatusException(ResponseStatusException ex) { | ||
return ResponseEntity.status(ex.getStatusCode()).body(ex.getReason()); | ||
} | ||
|
||
|
||
@ExceptionHandler(Exception.class) | ||
public ResponseEntity<String> handleException(Exception ex) { | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("An error occurred"); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 52 additions & 51 deletions
103
src/main/java/com/soongsil/CoffeeChat/entity/PossibleDate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,52 @@ | ||
package com.soongsil.CoffeeChat.entity; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalTime; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.soongsil.CoffeeChat.dto.PossibleDateRequestDto; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
@Entity | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
@ToString(of = {"id", "date", "startTime", "endTime", "isActive"}) | ||
public class PossibleDate { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "possible_date_id") | ||
private Long id; | ||
|
||
@Setter | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "mentor_id") | ||
private Mentor mentor; | ||
|
||
@JsonFormat(pattern = "yyyy-MM-dd") | ||
LocalDate date; | ||
|
||
@JsonFormat(pattern = "HH:mm") //datetimeformat은 ss까지 전부 다 받아야 오류안남 | ||
LocalTime startTime; | ||
|
||
@JsonFormat(pattern = "HH:mm") | ||
LocalTime endTime; | ||
|
||
@Column | ||
@Setter | ||
@Builder.Default | ||
private boolean isActive=true; | ||
|
||
public static PossibleDate from(PossibleDateRequestDto dto) { | ||
return PossibleDate.builder() | ||
.date(dto.getDate()) | ||
.startTime(dto.getStartTime()) | ||
.endTime(dto.getEndTime()) | ||
.isActive(true) | ||
.build(); | ||
} | ||
} | ||
package com.soongsil.CoffeeChat.entity; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalTime; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.soongsil.CoffeeChat.dto.PossibleDateRequestDto; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
@Entity | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
@Setter | ||
@ToString(of = {"id", "date", "startTime", "endTime", "isActive"}) | ||
public class PossibleDate { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "possible_date_id") | ||
private Long id; | ||
|
||
@Setter | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "mentor_id") | ||
private Mentor mentor; | ||
|
||
@JsonFormat(pattern = "yyyy-MM-dd") | ||
LocalDate date; | ||
|
||
@JsonFormat(pattern = "HH:mm") //datetimeformat은 ss까지 전부 다 받아야 오류안남 | ||
LocalTime startTime; | ||
|
||
@JsonFormat(pattern = "HH:mm") | ||
LocalTime endTime; | ||
|
||
@Column | ||
@Setter | ||
@Builder.Default | ||
private boolean isActive=true; | ||
|
||
public static PossibleDate from(PossibleDateRequestDto dto) { | ||
return PossibleDate.builder() | ||
.date(dto.getDate()) | ||
.startTime(dto.getStartTime()) | ||
.endTime(dto.getEndTime()) | ||
.isActive(true) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<configuration> | ||
|
||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] [transactionId=%X{transactionId}] [threadId=%X{threadId}] %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> | ||
<file>application.log</file> | ||
<append>true</append> | ||
<encoder> | ||
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] [transactionId=%X{transactionId}] [threadId=%X{threadId}] %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="info"> | ||
<appender-ref ref="CONSOLE" /> | ||
<appender-ref ref="FILE" /> | ||
</root> | ||
|
||
<logger name="com.soongsil.CoffeeChat" level="debug" additivity="false"> | ||
<appender-ref ref="CONSOLE" /> | ||
<appender-ref ref="FILE" /> | ||
</logger> | ||
|
||
</configuration> |
Oops, something went wrong.