From ede1914c6445b1ce74cedd4ff482fefdf2cfb890 Mon Sep 17 00:00:00 2001 From: JoJeHun Date: Sun, 30 Jul 2023 16:21:35 +0900 Subject: [PATCH 1/4] =?UTF-8?q?#3=20feat:=20=EC=B1=84=EC=9A=A9=EA=B3=B5?= =?UTF-8?q?=EA=B3=A0=20=EC=88=98=EC=A0=95/=EC=82=AD=EC=A0=9C=20API=20?= =?UTF-8?q?=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/JobPostingController.java | 10 +++++-- .../request/JobPostingEditRequest.java | 10 +++++-- .../response/JobPostingSearchResponse.java | 14 +++++++++ .../domain/JobPostingEditInfo.java | 14 +++++++++ .../domain/JobPostingEntity.java | 15 ++++++++++ .../domain/JobPostingRemoveInfo.java | 10 +++++++ .../domain/JobPostingService.java | 30 +++++++++++++++++++ 7 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/example/jehunonboarding/controller/response/JobPostingSearchResponse.java create mode 100644 src/main/java/com/example/jehunonboarding/domain/JobPostingEditInfo.java create mode 100644 src/main/java/com/example/jehunonboarding/domain/JobPostingRemoveInfo.java diff --git a/src/main/java/com/example/jehunonboarding/controller/JobPostingController.java b/src/main/java/com/example/jehunonboarding/controller/JobPostingController.java index c390ba0..64f9c68 100644 --- a/src/main/java/com/example/jehunonboarding/controller/JobPostingController.java +++ b/src/main/java/com/example/jehunonboarding/controller/JobPostingController.java @@ -5,6 +5,8 @@ import com.example.jehunonboarding.controller.response.JobPostingFindDetailResponse; import com.example.jehunonboarding.controller.response.JobPostingsSearchResponse; import com.example.jehunonboarding.domain.JobPosting; +import com.example.jehunonboarding.domain.JobPostingEditInfo; +import com.example.jehunonboarding.domain.JobPostingRemoveInfo; import com.example.jehunonboarding.domain.JobPostingService; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -28,12 +30,14 @@ public ResponseEntity register(@Valid @RequestBody JobPostingReg } @PutMapping("/v1/job-postings/{jobPostingId}") - public ResponseEntity edit(@RequestBody JobPostingEditRequest request) { + public ResponseEntity edit(@PathVariable int jobPostingId, @Valid @RequestBody JobPostingEditInfo request) { + jobPostingService.edit(jobPostingId, request); return new ResponseEntity(new CommonResponse(true), HttpStatus.OK); } - @DeleteMapping("/v1/job-postings/{jobPostingId}") - public ResponseEntity remove(@PathVariable int jobPostingId) { + @DeleteMapping("/v1/job-postings/{companyId}/{jobPostingId}") + public ResponseEntity remove(@PathVariable int companyId, @PathVariable int jobPostingId) { + jobPostingService.remove(companyId, jobPostingId); return new ResponseEntity(new CommonResponse(true), HttpStatus.OK); } diff --git a/src/main/java/com/example/jehunonboarding/controller/request/JobPostingEditRequest.java b/src/main/java/com/example/jehunonboarding/controller/request/JobPostingEditRequest.java index 7b8954c..06f1c3b 100644 --- a/src/main/java/com/example/jehunonboarding/controller/request/JobPostingEditRequest.java +++ b/src/main/java/com/example/jehunonboarding/controller/request/JobPostingEditRequest.java @@ -1,14 +1,18 @@ package com.example.jehunonboarding.controller.request; +import jakarta.validation.constraints.NotNull; import lombok.Data; @Data public class JobPostingEditRequest { - private String companyName; - private String nation; - private String region; + @NotNull + private int companyId; + @NotNull private String jobPosition; + @NotNull private long jobCompensation; + @NotNull private String description; + @NotNull private String skill; } diff --git a/src/main/java/com/example/jehunonboarding/controller/response/JobPostingSearchResponse.java b/src/main/java/com/example/jehunonboarding/controller/response/JobPostingSearchResponse.java new file mode 100644 index 0000000..bb79be6 --- /dev/null +++ b/src/main/java/com/example/jehunonboarding/controller/response/JobPostingSearchResponse.java @@ -0,0 +1,14 @@ +package com.example.jehunonboarding.controller.response; + +import lombok.Data; + +@Data +public class JobPostingSearchResponse { + private int companyId; + private String companyName; + private String nation; + private String region; + private String jobPosition; + private long jobCompensation; + private String skill; +} diff --git a/src/main/java/com/example/jehunonboarding/domain/JobPostingEditInfo.java b/src/main/java/com/example/jehunonboarding/domain/JobPostingEditInfo.java new file mode 100644 index 0000000..ccd5f38 --- /dev/null +++ b/src/main/java/com/example/jehunonboarding/domain/JobPostingEditInfo.java @@ -0,0 +1,14 @@ +package com.example.jehunonboarding.domain; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class JobPostingEditInfo { + private int companyId; + private String jobPosition; + private long jobCompensation; + private String description; + private String skill; +} diff --git a/src/main/java/com/example/jehunonboarding/domain/JobPostingEntity.java b/src/main/java/com/example/jehunonboarding/domain/JobPostingEntity.java index 23f97ab..09ee7b9 100644 --- a/src/main/java/com/example/jehunonboarding/domain/JobPostingEntity.java +++ b/src/main/java/com/example/jehunonboarding/domain/JobPostingEntity.java @@ -1,6 +1,7 @@ package com.example.jehunonboarding.domain; import jakarta.persistence.*; +import jakarta.validation.Valid; import lombok.NoArgsConstructor; @Entity @@ -34,4 +35,18 @@ public JobPostingEntity(int companyId, String jobPosition, long jobCompensation, this.description = description; this.skill = skill; } + + public void JobPostingEdit(@Valid JobPostingEditInfo editInfo) { + this.jobPosition = editInfo.getJobPosition(); + this.jobCompensation = editInfo.getJobCompensation(); + this.description = editInfo.getDescription(); + this.skill = editInfo.getSkill(); + } + + public boolean JobPostingRemove(int companyId, int jobPostingId) { + if (this.companyId == companyId && this.id == jobPostingId) { + return true; // 채용공고의 회사와 삭제 요청의 회사가 일치하고, 채용공고 ID도 일치하는 경우 true를 반환 + } + return false; // 그렇지 않은 경우 false를 반환 + } } diff --git a/src/main/java/com/example/jehunonboarding/domain/JobPostingRemoveInfo.java b/src/main/java/com/example/jehunonboarding/domain/JobPostingRemoveInfo.java new file mode 100644 index 0000000..475a81b --- /dev/null +++ b/src/main/java/com/example/jehunonboarding/domain/JobPostingRemoveInfo.java @@ -0,0 +1,10 @@ +package com.example.jehunonboarding.domain; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class JobPostingRemoveInfo { + private int companyId; +} diff --git a/src/main/java/com/example/jehunonboarding/domain/JobPostingService.java b/src/main/java/com/example/jehunonboarding/domain/JobPostingService.java index acd4215..e9dfdf0 100644 --- a/src/main/java/com/example/jehunonboarding/domain/JobPostingService.java +++ b/src/main/java/com/example/jehunonboarding/domain/JobPostingService.java @@ -1,10 +1,14 @@ package com.example.jehunonboarding.domain; +import com.example.jehunonboarding.controller.request.JobPostingEditRequest; +import com.example.jehunonboarding.controller.request.JobPostingRemoveRequest; import com.example.jehunonboarding.repository.CompanyRepository; import com.example.jehunonboarding.repository.JobPostingRepository; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.PathVariable; import java.util.List; @@ -33,4 +37,30 @@ public void register(JobPostingRegisterInfo registerInfo) { public List search(Pageable pageable, String keyword) { return jobPostingRepository.findByKeyword(pageable, keyword); } + + public void edit(int jobPostingId, @Valid JobPostingEditInfo editInfo) { + companyRepository.findById(editInfo.getCompanyId()) + .orElseThrow(() -> new IllegalArgumentException("존재하지 않는 회사입니다.")); + + JobPostingEntity jobPostingEntity = jobPostingRepository.findById((long) jobPostingId) + .orElseThrow(() -> new IllegalArgumentException("존재하지 않는 채용공고입니다.")); + + jobPostingEntity.JobPostingEdit(editInfo); + jobPostingRepository.save(jobPostingEntity); + } + + public void remove(int companyId, int jobPostingId) { + companyRepository.findById(companyId) + .orElseThrow(() -> new IllegalArgumentException("존재하지 않는 회사입니다.")); + + JobPostingEntity jobPostingEntity = jobPostingRepository.findById((long) jobPostingId) + .orElseThrow(() -> new IllegalArgumentException("존재하지 않는 채용공고입니다.")); + + if (jobPostingEntity.JobPostingRemove(companyId, jobPostingId)) { + jobPostingRepository.delete(jobPostingEntity); + } else { + throw new IllegalArgumentException("채용공고의 회사와 삭제 요청의 회사가 일치하지 않습니다."); + } + + } } From f9e5b4ace332d04c66e828429a1c3139f2860cf0 Mon Sep 17 00:00:00 2001 From: JoJeHun Date: Tue, 1 Aug 2023 16:52:42 +0900 Subject: [PATCH 2/4] =?UTF-8?q?#6=20feat:=20=EC=B1=84=EC=9A=A9=EA=B3=B5?= =?UTF-8?q?=EA=B3=A0=20=EC=83=81=EC=84=B8=EB=B3=B4=EA=B8=B0=20API=20?= =?UTF-8?q?=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/JobPostingController.java | 9 ++--- .../JobPostingFindDetailResponse.java | 40 +++++++++++++++---- .../domain/JobPostingEntity.java | 1 + .../domain/JobPostingService.java | 7 ++-- .../repository/JobPostingRepository.java | 2 + 5 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/example/jehunonboarding/controller/JobPostingController.java b/src/main/java/com/example/jehunonboarding/controller/JobPostingController.java index 64f9c68..c059ce2 100644 --- a/src/main/java/com/example/jehunonboarding/controller/JobPostingController.java +++ b/src/main/java/com/example/jehunonboarding/controller/JobPostingController.java @@ -4,10 +4,7 @@ import com.example.jehunonboarding.controller.response.CommonResponse; import com.example.jehunonboarding.controller.response.JobPostingFindDetailResponse; import com.example.jehunonboarding.controller.response.JobPostingsSearchResponse; -import com.example.jehunonboarding.domain.JobPosting; -import com.example.jehunonboarding.domain.JobPostingEditInfo; -import com.example.jehunonboarding.domain.JobPostingRemoveInfo; -import com.example.jehunonboarding.domain.JobPostingService; +import com.example.jehunonboarding.domain.*; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; @@ -49,12 +46,12 @@ public ResponseEntity search(String keyword, Pageable @GetMapping("/v1/job-postings/{jobPostingId}") public ResponseEntity findDetail(@PathVariable int jobPostingId) { - return new ResponseEntity(new JobPostingFindDetailResponse(), HttpStatus.OK); + List jobPostings = jobPostingService.findDetail(jobPostingId); + return new ResponseEntity(new JobPostingFindDetailResponse(jobPostings), HttpStatus.OK); } @PostMapping("/v1/job-postings/{jobPostingId}/apply") public ResponseEntity apply(@RequestBody JobPostingApplyRequest request) { return new ResponseEntity(new CommonResponse(true), HttpStatus.OK); } - } diff --git a/src/main/java/com/example/jehunonboarding/controller/response/JobPostingFindDetailResponse.java b/src/main/java/com/example/jehunonboarding/controller/response/JobPostingFindDetailResponse.java index 1bc83d7..37a4702 100644 --- a/src/main/java/com/example/jehunonboarding/controller/response/JobPostingFindDetailResponse.java +++ b/src/main/java/com/example/jehunonboarding/controller/response/JobPostingFindDetailResponse.java @@ -1,16 +1,40 @@ package com.example.jehunonboarding.controller.response; +import com.example.jehunonboarding.domain.JobPosting; import lombok.Data; +import java.util.List; +import java.util.stream.Collectors; + @Data public class JobPostingFindDetailResponse { - private int companyId; - private String companyName; - private String nation; - private String region; - private String jobPosition; - private long jobCompensation; - private String description; - private String skill; + private List details; + + public JobPostingFindDetailResponse(List jobPostings) { + this.details = jobPostings.stream() + .map(JobPostingResponse::new) + .toList(); + } + + @Data + static class JobPostingResponse { + private int companyId; + private String companyName; + private String nation; + private String region; + private String jobPosition; + private long jobCompensation; + private String skill; + + public JobPostingResponse(JobPosting jobPosting) { + this.companyId = jobPosting.getCompanyId(); + this.companyName = jobPosting.getCompanyName(); + this.nation = jobPosting.getNation(); + this.region = jobPosting.getRegion(); + this.jobPosition = jobPosting.getJobPosition(); + this.jobCompensation = jobPosting.getJobCompensation(); + this.skill = jobPosting.getSkill(); + } + } } diff --git a/src/main/java/com/example/jehunonboarding/domain/JobPostingEntity.java b/src/main/java/com/example/jehunonboarding/domain/JobPostingEntity.java index 09ee7b9..48cad92 100644 --- a/src/main/java/com/example/jehunonboarding/domain/JobPostingEntity.java +++ b/src/main/java/com/example/jehunonboarding/domain/JobPostingEntity.java @@ -28,6 +28,7 @@ public class JobPostingEntity { @Column(nullable = false) private String skill; + public JobPostingEntity(int companyId, String jobPosition, long jobCompensation, String description, String skill) { this.companyId = companyId; this.jobPosition = jobPosition; diff --git a/src/main/java/com/example/jehunonboarding/domain/JobPostingService.java b/src/main/java/com/example/jehunonboarding/domain/JobPostingService.java index e9dfdf0..70f55b3 100644 --- a/src/main/java/com/example/jehunonboarding/domain/JobPostingService.java +++ b/src/main/java/com/example/jehunonboarding/domain/JobPostingService.java @@ -1,14 +1,11 @@ package com.example.jehunonboarding.domain; -import com.example.jehunonboarding.controller.request.JobPostingEditRequest; -import com.example.jehunonboarding.controller.request.JobPostingRemoveRequest; import com.example.jehunonboarding.repository.CompanyRepository; import com.example.jehunonboarding.repository.JobPostingRepository; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; -import org.springframework.web.bind.annotation.PathVariable; import java.util.List; @@ -63,4 +60,8 @@ public void remove(int companyId, int jobPostingId) { } } + + public List findDetail(int jobPostingId) { + return jobPostingRepository.detailPosting(jobPostingId); + } } diff --git a/src/main/java/com/example/jehunonboarding/repository/JobPostingRepository.java b/src/main/java/com/example/jehunonboarding/repository/JobPostingRepository.java index 425692b..d10c188 100644 --- a/src/main/java/com/example/jehunonboarding/repository/JobPostingRepository.java +++ b/src/main/java/com/example/jehunonboarding/repository/JobPostingRepository.java @@ -12,4 +12,6 @@ public interface JobPostingRepository extends JpaRepository findByKeyword(Pageable pageable, String keyword); + @Query("SELECT new com.example.jehunonboarding.domain.JobPosting(c.id, c.companyName, c.nation, c.region, jp.jobPosition, jp.jobCompensation, jp.description, jp.skill) FROM JobPostingEntity jp INNER JOIN Company c ON jp.companyId = c.id") + List detailPosting(int jobPostingId); } From f4aabe82a21bcca707a424074fc17ab9e01489eb Mon Sep 17 00:00:00 2001 From: JoJeHun Date: Tue, 1 Aug 2023 23:35:31 +0900 Subject: [PATCH 3/4] =?UTF-8?q?#4=20feat:=20=EC=B1=84=EC=9A=A9=EA=B3=B5?= =?UTF-8?q?=EA=B3=A0=20=EC=A7=80=EC=9B=90=ED=95=98=EA=B8=B0=20API=20?= =?UTF-8?q?=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/JobPostingController.java | 3 ++- .../request/JobPostingApplyRequest.java | 2 +- .../domain/JobPostingEntity.java | 14 ++++++++++++++ .../domain/JobPostingService.java | 18 +++++++++++++++++- .../example/jehunonboarding/domain/Users.java | 14 ++++++++++++++ .../repository/UserRepository.java | 7 +++++++ src/main/resources/data.sql | 2 ++ 7 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/example/jehunonboarding/domain/Users.java create mode 100644 src/main/java/com/example/jehunonboarding/repository/UserRepository.java diff --git a/src/main/java/com/example/jehunonboarding/controller/JobPostingController.java b/src/main/java/com/example/jehunonboarding/controller/JobPostingController.java index c059ce2..bf6963a 100644 --- a/src/main/java/com/example/jehunonboarding/controller/JobPostingController.java +++ b/src/main/java/com/example/jehunonboarding/controller/JobPostingController.java @@ -51,7 +51,8 @@ public ResponseEntity findDetail(@PathVariable int } @PostMapping("/v1/job-postings/{jobPostingId}/apply") - public ResponseEntity apply(@RequestBody JobPostingApplyRequest request) { + public ResponseEntity apply(@PathVariable int jobPostingId, @Valid @RequestBody JobPostingApplyRequest request) { + jobPostingService.apply(jobPostingId, request); return new ResponseEntity(new CommonResponse(true), HttpStatus.OK); } } diff --git a/src/main/java/com/example/jehunonboarding/controller/request/JobPostingApplyRequest.java b/src/main/java/com/example/jehunonboarding/controller/request/JobPostingApplyRequest.java index 7557eff..bc1f34f 100644 --- a/src/main/java/com/example/jehunonboarding/controller/request/JobPostingApplyRequest.java +++ b/src/main/java/com/example/jehunonboarding/controller/request/JobPostingApplyRequest.java @@ -4,6 +4,6 @@ @Data public class JobPostingApplyRequest { - private int companyId; + private int jopPostingId; private int userId; } diff --git a/src/main/java/com/example/jehunonboarding/domain/JobPostingEntity.java b/src/main/java/com/example/jehunonboarding/domain/JobPostingEntity.java index 48cad92..68b95a9 100644 --- a/src/main/java/com/example/jehunonboarding/domain/JobPostingEntity.java +++ b/src/main/java/com/example/jehunonboarding/domain/JobPostingEntity.java @@ -4,6 +4,9 @@ import jakarta.validation.Valid; import lombok.NoArgsConstructor; +import java.util.HashSet; +import java.util.Set; + @Entity @Table(name = "job_posting") @NoArgsConstructor @@ -28,6 +31,9 @@ public class JobPostingEntity { @Column(nullable = false) private String skill; + // 채용공고 지원에서 필요하며 중복을 피하기 위한 HashSet + @ElementCollection + private Set applicants = new HashSet<>(); public JobPostingEntity(int companyId, String jobPosition, long jobCompensation, String description, String skill) { this.companyId = companyId; @@ -50,4 +56,12 @@ public boolean JobPostingRemove(int companyId, int jobPostingId) { } return false; // 그렇지 않은 경우 false를 반환 } + + public boolean isApplicant(String userId) { + return applicants.contains(userId); + } + + public void addApplicant(int userId) { + applicants.add(String.valueOf(userId)); + } } diff --git a/src/main/java/com/example/jehunonboarding/domain/JobPostingService.java b/src/main/java/com/example/jehunonboarding/domain/JobPostingService.java index 70f55b3..5a0e2b3 100644 --- a/src/main/java/com/example/jehunonboarding/domain/JobPostingService.java +++ b/src/main/java/com/example/jehunonboarding/domain/JobPostingService.java @@ -1,7 +1,9 @@ package com.example.jehunonboarding.domain; +import com.example.jehunonboarding.controller.request.JobPostingApplyRequest; import com.example.jehunonboarding.repository.CompanyRepository; import com.example.jehunonboarding.repository.JobPostingRepository; +import com.example.jehunonboarding.repository.UserRepository; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; @@ -58,10 +60,24 @@ public void remove(int companyId, int jobPostingId) { } else { throw new IllegalArgumentException("채용공고의 회사와 삭제 요청의 회사가 일치하지 않습니다."); } - } public List findDetail(int jobPostingId) { return jobPostingRepository.detailPosting(jobPostingId); } + + public void apply(int jobPostingId, JobPostingApplyRequest request) { + JobPostingEntity jobPostingEntity = jobPostingRepository.findById((long) jobPostingId) + .orElseThrow(() -> new IllegalArgumentException("존재하지 않는 채용공고입니다.")); + + int userId = request.getUserId(); + + if (jobPostingEntity.isApplicant(String.valueOf(userId))) { + throw new IllegalArgumentException("이미 지원한 채용공고입니다."); + } else { + jobPostingEntity.addApplicant(userId); + + jobPostingRepository.save(jobPostingEntity); + } + } } diff --git a/src/main/java/com/example/jehunonboarding/domain/Users.java b/src/main/java/com/example/jehunonboarding/domain/Users.java new file mode 100644 index 0000000..d362625 --- /dev/null +++ b/src/main/java/com/example/jehunonboarding/domain/Users.java @@ -0,0 +1,14 @@ +package com.example.jehunonboarding.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +@Entity +@Table(name = "users") +public class Users { + @Id + @GeneratedValue + private int id; +} diff --git a/src/main/java/com/example/jehunonboarding/repository/UserRepository.java b/src/main/java/com/example/jehunonboarding/repository/UserRepository.java new file mode 100644 index 0000000..160f064 --- /dev/null +++ b/src/main/java/com/example/jehunonboarding/repository/UserRepository.java @@ -0,0 +1,7 @@ +package com.example.jehunonboarding.repository; + +import com.example.jehunonboarding.domain.Users; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface UserRepository extends JpaRepository { +} diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 58cba22..3ed9f9e 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -1 +1,3 @@ INSERT INTO company (id, company_name, nation, region) VALUES (1, '제훈테크', '한국', '서울'); + +INSERT INTO users (id) VALUES (1); \ No newline at end of file From 2a8d3dacf7890e0aeeba6d398a71a4ef69417def Mon Sep 17 00:00:00 2001 From: JoJeHun Date: Sat, 5 Aug 2023 00:10:11 +0900 Subject: [PATCH 4/4] =?UTF-8?q?#4=20feat:=20=EC=B1=84=EC=9A=A9=EA=B3=B5?= =?UTF-8?q?=EA=B3=A0=20=EC=A7=80=EC=9B=90=ED=95=98=EA=B8=B0=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=EB=AA=85=20=EC=B9=B4=EB=A9=9C=EC=BC=80?= =?UTF-8?q?=EC=9D=B4=EC=8A=A4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jehunonboarding/controller/JobPostingController.java | 2 +- .../example/jehunonboarding/domain/JobPostingEntity.java | 9 +++------ .../jehunonboarding/domain/JobPostingService.java | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/example/jehunonboarding/controller/JobPostingController.java b/src/main/java/com/example/jehunonboarding/controller/JobPostingController.java index bf6963a..b2cc697 100644 --- a/src/main/java/com/example/jehunonboarding/controller/JobPostingController.java +++ b/src/main/java/com/example/jehunonboarding/controller/JobPostingController.java @@ -32,7 +32,7 @@ public ResponseEntity edit(@PathVariable int jobPostingId, @Vali return new ResponseEntity(new CommonResponse(true), HttpStatus.OK); } - @DeleteMapping("/v1/job-postings/{companyId}/{jobPostingId}") + @DeleteMapping("/v1/job-postings/{jobPostingId}/{companyId}") public ResponseEntity remove(@PathVariable int companyId, @PathVariable int jobPostingId) { jobPostingService.remove(companyId, jobPostingId); return new ResponseEntity(new CommonResponse(true), HttpStatus.OK); diff --git a/src/main/java/com/example/jehunonboarding/domain/JobPostingEntity.java b/src/main/java/com/example/jehunonboarding/domain/JobPostingEntity.java index 68b95a9..f7577d2 100644 --- a/src/main/java/com/example/jehunonboarding/domain/JobPostingEntity.java +++ b/src/main/java/com/example/jehunonboarding/domain/JobPostingEntity.java @@ -43,18 +43,15 @@ public JobPostingEntity(int companyId, String jobPosition, long jobCompensation, this.skill = skill; } - public void JobPostingEdit(@Valid JobPostingEditInfo editInfo) { + public void editJobPosting(JobPostingEditInfo editInfo) { this.jobPosition = editInfo.getJobPosition(); this.jobCompensation = editInfo.getJobCompensation(); this.description = editInfo.getDescription(); this.skill = editInfo.getSkill(); } - public boolean JobPostingRemove(int companyId, int jobPostingId) { - if (this.companyId == companyId && this.id == jobPostingId) { - return true; // 채용공고의 회사와 삭제 요청의 회사가 일치하고, 채용공고 ID도 일치하는 경우 true를 반환 - } - return false; // 그렇지 않은 경우 false를 반환 + public boolean removeJobPosting(int companyId, int jobPostingId) { + return this.companyId == companyId && this.id == jobPostingId; } public boolean isApplicant(String userId) { diff --git a/src/main/java/com/example/jehunonboarding/domain/JobPostingService.java b/src/main/java/com/example/jehunonboarding/domain/JobPostingService.java index 5a0e2b3..4360587 100644 --- a/src/main/java/com/example/jehunonboarding/domain/JobPostingService.java +++ b/src/main/java/com/example/jehunonboarding/domain/JobPostingService.java @@ -44,7 +44,7 @@ public void edit(int jobPostingId, @Valid JobPostingEditInfo editInfo) { JobPostingEntity jobPostingEntity = jobPostingRepository.findById((long) jobPostingId) .orElseThrow(() -> new IllegalArgumentException("존재하지 않는 채용공고입니다.")); - jobPostingEntity.JobPostingEdit(editInfo); + jobPostingEntity.editJobPosting(editInfo); jobPostingRepository.save(jobPostingEntity); } @@ -55,7 +55,7 @@ public void remove(int companyId, int jobPostingId) { JobPostingEntity jobPostingEntity = jobPostingRepository.findById((long) jobPostingId) .orElseThrow(() -> new IllegalArgumentException("존재하지 않는 채용공고입니다.")); - if (jobPostingEntity.JobPostingRemove(companyId, jobPostingId)) { + if (jobPostingEntity.removeJobPosting(companyId, jobPostingId)) { jobPostingRepository.delete(jobPostingEntity); } else { throw new IllegalArgumentException("채용공고의 회사와 삭제 요청의 회사가 일치하지 않습니다.");