-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] Job 도메인 구현 #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ce3e193
feat: Job 엔티티 추가
kosy00 9e17dd6
chore: gradlew LF 줄바꿈 설정
kosy00 65fe9e2
feat: JobCategory, JobStatus enum 추가
kosy00 86105a0
feat: JobService 추가, repository 메서드 추가
kosy00 6e2e511
feat: dto추가
kosy00 c9595e2
feat: 공고 상태 enum 수정
kosy00 d31d88e
feat: job.updatInfo() 인자 수정
kosy00 98b76ac
feat: 조회 메서드 Slice로 변경
kosy00 be07faa
feat: JobController 추가
kosy00 26eb1ac
fix: 잘못된 ErrorCode수정
kosy00 5ef4ba6
chore: 프로필분리에 따른 ddl-auto 수정
kosy00 d5db5ae
chore: 응답 코드 불일치 해결
kosy00 5916052
fix: 주소 수정 시 위,경도 함께 수정되도록
kosy00 1430e6d
fix: 근무시간 역전 검증 추가
kosy00 422aeb4
fix: ApiResponse.error() 시그니처 불일치 수정 및 코드정리
kosy00 2a28f2b
chore: ci 테스트용 환경변수 추가
kosy00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -46,3 +46,6 @@ logs/ | |
| ### Local config ### | ||
| application-local.yml | ||
| .env | ||
|
|
||
| # 정적 리소스 | ||
| src/main/resources/static/ | ||
Empty file.
This file contains hidden or 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 hidden or 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
85 changes: 85 additions & 0 deletions
85
src/main/java/com/ilson/spotwork/domain/job/controller/JobController.java
This file contains hidden or 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,85 @@ | ||
| package com.ilson.spotwork.domain.job.controller; | ||
|
|
||
| import com.ilson.spotwork.common.response.ApiResponse; | ||
| import com.ilson.spotwork.domain.job.dto.JobCreateRequestDto; | ||
| import com.ilson.spotwork.domain.job.dto.JobResponseDto; | ||
| import com.ilson.spotwork.domain.job.dto.JobUpdateRequestDto; | ||
| import com.ilson.spotwork.domain.job.service.JobService; | ||
| import com.ilson.spotwork.infra.security.jwt.CustomUserDetails; | ||
| import jakarta.validation.Valid; | ||
| import jakarta.validation.constraints.Min; | ||
| import jakarta.validation.constraints.Positive; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.PageRequest; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.domain.Slice; | ||
| import org.springframework.data.domain.Sort; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
| import org.springframework.validation.annotation.Validated; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| @Validated | ||
| @RestController | ||
| @RequestMapping("/api/jobs") | ||
| @RequiredArgsConstructor | ||
| public class JobController { | ||
|
|
||
| private final JobService jobService; | ||
|
|
||
| // 공고 등록 | ||
| @PostMapping | ||
| @ResponseStatus(HttpStatus.CREATED) | ||
| public ApiResponse<JobResponseDto> register( | ||
| @AuthenticationPrincipal CustomUserDetails userDetails, | ||
| @RequestBody @Valid JobCreateRequestDto request) { | ||
| JobResponseDto response = jobService.register(userDetails.getUserId(), request); | ||
| return ApiResponse.success(response); | ||
|
kosy00 marked this conversation as resolved.
kosy00 marked this conversation as resolved.
|
||
| } | ||
|
|
||
| // 공고 목록 조회 | ||
| @GetMapping | ||
| public ApiResponse<Slice<JobResponseDto>> getList( | ||
| @RequestParam(defaultValue = "0") @Min(0) int page, | ||
| @RequestParam(defaultValue = "10") @Positive int size) { | ||
| Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, "createdAt")); | ||
| Slice<JobResponseDto> response = jobService.getList(pageable); | ||
| return ApiResponse.success(response); | ||
| } | ||
|
|
||
| // 공고 상세 조회 | ||
| @GetMapping("/{jobId}") | ||
| public ApiResponse<JobResponseDto> getDetail(@PathVariable Long jobId) { | ||
| JobResponseDto response = jobService.getDetail(jobId); | ||
| return ApiResponse.success(response); | ||
| } | ||
|
|
||
| // 공고 수정 | ||
| @PatchMapping("/{jobId}") | ||
| public ApiResponse<JobResponseDto> update( | ||
| @AuthenticationPrincipal CustomUserDetails userDetails, | ||
| @PathVariable Long jobId, | ||
| @RequestBody @Valid JobUpdateRequestDto request) { | ||
| return ApiResponse.success(jobService.update(userDetails.getUserId(), jobId, request)); | ||
| } | ||
|
|
||
| // 공고 삭제 | ||
| @DeleteMapping("/{jobId}") | ||
| public ApiResponse<Void> delete( | ||
| @AuthenticationPrincipal CustomUserDetails userDetails, | ||
| @PathVariable Long jobId) { | ||
| jobService.delete(userDetails.getUserId(), jobId); | ||
| return ApiResponse.success(); | ||
| } | ||
|
|
||
| // 내 공고 목록 조회 | ||
| @GetMapping("/me") | ||
| public ApiResponse<Slice<JobResponseDto>> getMyJobs( | ||
| @AuthenticationPrincipal CustomUserDetails userDetails, | ||
| @RequestParam(defaultValue = "0") @Min(0) int page, | ||
| @RequestParam(defaultValue = "10") @Positive int size) { | ||
| Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, "createdAt")); | ||
| return ApiResponse.success(jobService.getMyJobs(userDetails.getUserId(), pageable)); | ||
| } | ||
|
|
||
| } | ||
54 changes: 54 additions & 0 deletions
54
src/main/java/com/ilson/spotwork/domain/job/dto/JobCreateRequestDto.java
This file contains hidden or 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,54 @@ | ||
| package com.ilson.spotwork.domain.job.dto; | ||
|
|
||
| import com.ilson.spotwork.domain.job.entity.JobCategory; | ||
| import jakarta.validation.constraints.*; | ||
| import lombok.Getter; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.LocalTime; | ||
|
|
||
| @Getter | ||
| public class JobCreateRequestDto { | ||
|
|
||
| @NotBlank(message = "제목은 필수입니다.") | ||
| private String title; | ||
|
|
||
| private String description; | ||
|
|
||
| @NotNull(message = "업종은 필수입니다.") | ||
| private JobCategory category; | ||
|
|
||
| @Min(value = 10030, message = "최저시급 이상이어야 합니다.") | ||
| private int hourlyWage; | ||
|
|
||
| @NotNull(message = "근무 날짜는 필수입니다.") | ||
| @FutureOrPresent(message = "근무 날짜는 오늘 이후여야 합니다.") | ||
| private LocalDate workDate; | ||
|
|
||
| @NotNull(message = "시작 시간은 필수입니다.") | ||
| private LocalTime startTime; | ||
|
|
||
| @NotNull(message = "종료 시간은 필수입니다.") | ||
| private LocalTime endTime; | ||
|
kosy00 marked this conversation as resolved.
|
||
|
|
||
| @AssertTrue(message = "종료 시간은 시작 시간보다 늦어야 합니다.") | ||
| private boolean isValidTimeRange() { | ||
| return startTime == null || endTime == null || endTime.isAfter(startTime); | ||
| } | ||
|
|
||
| @Min(value = 1, message = "모집 인원은 1명 이상이어야 합니다.") | ||
| private int headcount; | ||
|
|
||
| @NotBlank(message = "주소는 필수입니다.") | ||
| private String address; | ||
|
|
||
| @NotNull(message = "위도는 필수입니다.") | ||
| @DecimalMin(value = "-90.0", message = "위도는 -90 이상이어야 합니다.") | ||
| @DecimalMax(value = "90.0", message = "위도는 90 이하여야 합니다.") | ||
| private Double latitude; | ||
|
|
||
| @NotNull(message = "경도는 필수입니다.") | ||
| @DecimalMin(value = "-180.0", message = "경도는 -180 이상이어야 합니다.") | ||
| @DecimalMax(value = "180.0", message = "경도는 180 이하여야 합니다.") | ||
| private Double longitude; | ||
|
kosy00 marked this conversation as resolved.
|
||
| } | ||
64 changes: 64 additions & 0 deletions
64
src/main/java/com/ilson/spotwork/domain/job/dto/JobResponseDto.java
This file contains hidden or 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,64 @@ | ||
| package com.ilson.spotwork.domain.job.dto; | ||
|
|
||
| import com.ilson.spotwork.domain.job.entity.Job; | ||
| import com.ilson.spotwork.domain.job.entity.JobCategory; | ||
| import com.ilson.spotwork.domain.job.entity.JobStatus; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.LocalTime; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| public class JobResponseDto { | ||
|
|
||
| private Long id; | ||
| private String title; | ||
| private String description; | ||
| private JobCategory category; | ||
| private int hourlyWage; | ||
| private LocalDate workDate; | ||
| private LocalTime startTime; | ||
| private LocalTime endTime; | ||
| private int headcount; | ||
| private String address; | ||
| private double latitude; | ||
| private double longitude; | ||
| private JobStatus status; | ||
| private EmployerInfo employer; | ||
|
|
||
| // 사업자 정보 (중첩 DTO) | ||
| @Getter | ||
| @Builder | ||
| public static class EmployerInfo { | ||
| private Long id; | ||
| private String nickname; | ||
| private Double avgRating; | ||
| } | ||
|
|
||
| public static JobResponseDto from(Job job) { | ||
| return JobResponseDto.builder() | ||
| .id(job.getId()) | ||
| .title(job.getTitle()) | ||
| .description(job.getDescription()) | ||
| .category(job.getCategory()) | ||
| .hourlyWage(job.getHourlyWage()) | ||
| .workDate(job.getWorkDate()) | ||
| .startTime(job.getStartTime()) | ||
| .endTime(job.getEndTime()) | ||
| .headcount(job.getHeadcount()) | ||
| .address(job.getAddress()) | ||
| .latitude(job.getLatitude()) | ||
| .longitude(job.getLongitude()) | ||
| .status(job.getStatus()) | ||
| .employer(EmployerInfo.builder() | ||
| .id(job.getEmployer().getId()) | ||
| .nickname(job.getEmployer().getNickname()) | ||
| .avgRating(job.getEmployer().getAvgRating() != null | ||
| ? job.getEmployer().getAvgRating().doubleValue() | ||
| : null) | ||
| .build()) | ||
| .build(); | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/ilson/spotwork/domain/job/dto/JobUpdateRequestDto.java
This file contains hidden or 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,46 @@ | ||
| package com.ilson.spotwork.domain.job.dto; | ||
|
|
||
| import jakarta.validation.constraints.*; | ||
|
|
||
| import lombok.Getter; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.LocalTime; | ||
|
|
||
| @Getter | ||
| public class JobUpdateRequestDto { | ||
|
|
||
| @NotBlank(message = "제목은 필수입니다.") | ||
| private String title; | ||
|
|
||
| private String description; | ||
|
|
||
| @Min(value = 10030, message = "최저시급 이상이어야 합니다.") | ||
| private int hourlyWage; | ||
|
|
||
| @NotNull | ||
| @FutureOrPresent(message = "근무 날짜는 오늘 이후여야 합니다.") | ||
| private LocalDate workDate; | ||
|
kosy00 marked this conversation as resolved.
|
||
|
|
||
| @NotNull | ||
| private LocalTime startTime; | ||
|
|
||
| @NotNull | ||
| private LocalTime endTime; | ||
|
|
||
| @Min(value = 1, message = "모집 인원은 1명 이상이어야 합니다.") | ||
| private int headcount; | ||
|
|
||
| @NotBlank(message = "주소는 필수입니다.") | ||
| private String address; | ||
|
|
||
| @NotNull(message = "위도는 필수입니다.") | ||
| @DecimalMin(value = "-90.0", message = "위도는 -90 이상이어야 합니다.") | ||
| @DecimalMax(value = "90.0", message = "위도는 90 이하여야 합니다.") | ||
| private Double latitude; | ||
|
|
||
| @NotNull(message = "경도는 필수입니다.") | ||
| @DecimalMin(value = "-180.0", message = "경도는 -180 이상이어야 합니다.") | ||
| @DecimalMax(value = "180.0", message = "경도는 180 이하여야 합니다.") | ||
| private Double longitude; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.