-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from Yeong-Huns/mission03
미니 프로젝트 Step03
- Loading branch information
Showing
27 changed files
with
465 additions
and
28 deletions.
There are no files selected for viewing
6 changes: 5 additions & 1 deletion
6
Yeong-Huns/src/main/java/org/example/yeonghuns/YeongHunsApplication.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,12 +1,16 @@ | ||
package org.example.yeonghuns; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
import java.time.Duration; | ||
import java.time.LocalDate; | ||
@SpringBootApplication | ||
public class YeongHunsApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(YeongHunsApplication.class, args);} | ||
SpringApplication.run(YeongHunsApplication.class, args); | ||
} | ||
|
||
} |
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
8 changes: 8 additions & 0 deletions
8
...a/org/example/yeonghuns/config/Error/exception/annualLeave/AcceptTeamPolicyException.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,8 @@ | ||
package org.example.yeonghuns.config.Error.exception.annualLeave; | ||
|
||
import org.example.yeonghuns.config.Error.ErrorCode; | ||
import org.example.yeonghuns.config.Error.exception.BadRequestException; | ||
|
||
public class AcceptTeamPolicyException extends BadRequestException { | ||
public AcceptTeamPolicyException() { super(ErrorCode.DECLINE_ANNUAL_LEAVE_REQUEST); } | ||
} |
8 changes: 8 additions & 0 deletions
8
.../org/example/yeonghuns/config/Error/exception/annualLeave/AlreadyRegisteredException.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,8 @@ | ||
package org.example.yeonghuns.config.Error.exception.annualLeave; | ||
|
||
import org.example.yeonghuns.config.Error.ErrorCode; | ||
import org.example.yeonghuns.config.Error.exception.BadRequestException; | ||
|
||
public class AlreadyRegisteredException extends BadRequestException { | ||
public AlreadyRegisteredException() { super(ErrorCode.ALREADY_EXISTS_ANNUAL_LEAVE); } | ||
} |
21 changes: 21 additions & 0 deletions
21
...n/java/org/example/yeonghuns/config/Error/exception/annualLeave/BeforeTodayException.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,21 @@ | ||
package org.example.yeonghuns.config.Error.exception.annualLeave; | ||
|
||
import org.example.yeonghuns.config.Error.ErrorCode; | ||
import org.example.yeonghuns.config.Error.exception.BadRequestException; | ||
|
||
/** | ||
* packageName : org.example.yeonghuns.config.Error.exception | ||
* fileName : AlreadyAttendanceException | ||
* author : Yeong-Huns | ||
* date : 2024-03-05 | ||
* description : | ||
* =========================================================== | ||
* DATE AUTHOR NOTE | ||
* ----------------------------------------------------------- | ||
* 2024-03-05 Yeong-Huns 최초 생성 | ||
*/ | ||
public class BeforeTodayException extends BadRequestException { | ||
public BeforeTodayException() { | ||
super(ErrorCode.REQUEST_BEFORE_TODAY); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...org/example/yeonghuns/config/Error/exception/annualLeave/RemainAnnualLeavesException.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,8 @@ | ||
package org.example.yeonghuns.config.Error.exception.annualLeave; | ||
|
||
import org.example.yeonghuns.config.Error.ErrorCode; | ||
import org.example.yeonghuns.config.Error.exception.BadRequestException; | ||
|
||
public class RemainAnnualLeavesException extends BadRequestException { | ||
public RemainAnnualLeavesException() { super(ErrorCode.NOT_REMAIN_ANNUAL_LEAVE); } | ||
} |
21 changes: 21 additions & 0 deletions
21
...java/org/example/yeonghuns/config/Error/exception/commute/UsingAnnualLeavesException.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,21 @@ | ||
package org.example.yeonghuns.config.Error.exception.commute; | ||
|
||
import org.example.yeonghuns.config.Error.ErrorCode; | ||
import org.example.yeonghuns.config.Error.exception.BadRequestException; | ||
|
||
/** | ||
* packageName : org.example.yeonghuns.config.Error.exception | ||
* fileName : AlreadyAttendanceException | ||
* author : Yeong-Huns | ||
* date : 2024-03-05 | ||
* description : | ||
* =========================================================== | ||
* DATE AUTHOR NOTE | ||
* ----------------------------------------------------------- | ||
* 2024-03-05 Yeong-Huns 최초 생성 | ||
*/ | ||
public class UsingAnnualLeavesException extends BadRequestException { | ||
public UsingAnnualLeavesException() { | ||
super(ErrorCode.USING_ANNUAL_LEAVES); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
Yeong-Huns/src/main/java/org/example/yeonghuns/controller/AnnualLeaveController.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,44 @@ | ||
package org.example.yeonghuns.controller; | ||
|
||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.example.yeonghuns.dto.annualLeave.request.GetRemainAnnualLeavesRequest; | ||
import org.example.yeonghuns.dto.annualLeave.request.RegisterAnnualLeaveRequest; | ||
import org.example.yeonghuns.dto.annualLeave.response.GetRemainAnnualLeavesResponse; | ||
import org.example.yeonghuns.service.annual.AnnualLeaveService; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* packageName : org.example.yeonghuns.controller | ||
* fileName : AnnualController | ||
* author : Yeong-Huns | ||
* date : 2024-03-06 | ||
* description : | ||
* =========================================================== | ||
* DATE AUTHOR NOTE | ||
* ----------------------------------------------------------- | ||
* 2024-03-06 Yeong-Huns 최초 생성 | ||
*/ | ||
@RestController | ||
@RequiredArgsConstructor | ||
public class AnnualLeaveController { | ||
private final AnnualLeaveService annualLeaveService; | ||
|
||
@PostMapping("/annual") | ||
public ResponseEntity<Void> registerAnnualLeave(@RequestBody @Valid RegisterAnnualLeaveRequest request) { | ||
annualLeaveService.registerAnnualLeave(request); | ||
return ResponseEntity.status(HttpStatus.CREATED).build(); | ||
} | ||
|
||
@GetMapping("/annual") | ||
public ResponseEntity<GetRemainAnnualLeavesResponse> getRemainAnnualLeaves(@Valid GetRemainAnnualLeavesRequest request) { | ||
long remainAnnualLeaves = annualLeaveService.getRemainAnnualLeaves(request); | ||
GetRemainAnnualLeavesResponse response = new GetRemainAnnualLeavesResponse(remainAnnualLeaves); | ||
return ResponseEntity.ok(response); | ||
} | ||
} |
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
40 changes: 40 additions & 0 deletions
40
Yeong-Huns/src/main/java/org/example/yeonghuns/domain/AnnualLeave.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,40 @@ | ||
package org.example.yeonghuns.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDate; | ||
|
||
/** | ||
* packageName : org.example.yeonghuns.domain | ||
* fileName : Annual | ||
* author : Yeong-Huns | ||
* date : 2024-03-06 | ||
* description : | ||
* =========================================================== | ||
* DATE AUTHOR NOTE | ||
* ----------------------------------------------------------- | ||
* 2024-03-06 Yeong-Huns 최초 생성 | ||
*/ | ||
@Getter | ||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class AnnualLeave { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private long id; | ||
|
||
private LocalDate annualLeaveDate; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Member member; | ||
|
||
@Builder | ||
public AnnualLeave(LocalDate annualLeaveDate, Member member) { | ||
this.annualLeaveDate = annualLeaveDate; | ||
this.member = member; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
Yeong-Huns/src/main/java/org/example/yeonghuns/domain/JoinDate.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 org.example.yeonghuns.domain; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
/** | ||
* packageName : org.example.yeonghuns.domain | ||
* fileName : WorkStartDay | ||
* author : Yeong-Huns | ||
* date : 2024-03-08 | ||
* description : | ||
* =========================================================== | ||
* DATE AUTHOR NOTE | ||
* ----------------------------------------------------------- | ||
* 2024-03-08 Yeong-Huns 최초 생성 | ||
*/ | ||
|
||
@RequiredArgsConstructor | ||
public enum JoinDate { | ||
OVER_ONE_YEAR(15L), | ||
UNDER_ONE_YEAR(11L); | ||
|
||
private final long maxAnnualLeaves; | ||
public long getAnnualLeaves(){return maxAnnualLeaves;} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
...main/java/org/example/yeonghuns/dto/annualLeave/request/GetRemainAnnualLeavesRequest.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,17 @@ | ||
package org.example.yeonghuns.dto.annualLeave.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
/** | ||
* packageName : org.example.yeonghuns.dto.annual.request | ||
* fileName : GetRemainAnnualLeaves | ||
* author : Yeong-Huns | ||
* date : 2024-03-07 | ||
* description : | ||
* =========================================================== | ||
* DATE AUTHOR NOTE | ||
* ----------------------------------------------------------- | ||
* 2024-03-07 Yeong-Huns 최초 생성 | ||
*/ | ||
public record GetRemainAnnualLeavesRequest(@NotNull long id) { | ||
} |
28 changes: 28 additions & 0 deletions
28
...c/main/java/org/example/yeonghuns/dto/annualLeave/request/RegisterAnnualLeaveRequest.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,28 @@ | ||
package org.example.yeonghuns.dto.annualLeave.request; | ||
|
||
import jakarta.validation.constraints.Future; | ||
import jakarta.validation.constraints.NotNull; | ||
import org.example.yeonghuns.domain.AnnualLeave; | ||
import org.example.yeonghuns.domain.Member; | ||
|
||
import java.time.LocalDate; | ||
|
||
/** | ||
* packageName : org.example.yeonghuns.dto.annual.request | ||
* fileName : RegistAnnualRequest | ||
* author : Yeong-Huns | ||
* date : 2024-03-07 | ||
* description : | ||
* =========================================================== | ||
* DATE AUTHOR NOTE | ||
* ----------------------------------------------------------- | ||
* 2024-03-07 Yeong-Huns 최초 생성 | ||
*/ | ||
public record RegisterAnnualLeaveRequest(@NotNull long id, @Future LocalDate date) { | ||
public AnnualLeave toEntity(Member member){ | ||
return AnnualLeave.builder() | ||
.annualLeaveDate(date) | ||
.member(member) | ||
.build(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...in/java/org/example/yeonghuns/dto/annualLeave/response/GetRemainAnnualLeavesResponse.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,15 @@ | ||
package org.example.yeonghuns.dto.annualLeave.response; | ||
|
||
/** | ||
* packageName : org.example.yeonghuns.dto.annual.response | ||
* fileName : GetRemainAnnualLeavesResponse | ||
* author : Yeong-Huns | ||
* date : 2024-03-07 | ||
* description : | ||
* =========================================================== | ||
* DATE AUTHOR NOTE | ||
* ----------------------------------------------------------- | ||
* 2024-03-07 Yeong-Huns 최초 생성 | ||
*/ | ||
public record GetRemainAnnualLeavesResponse(long remainAnnualLeaves) { | ||
} |
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
Oops, something went wrong.