-
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.
Co-authored-by: kanghoon-choi <[email protected]>
- Loading branch information
Showing
14 changed files
with
223 additions
and
12 deletions.
There are no files selected for viewing
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
14 changes: 11 additions & 3 deletions
14
src/main/java/com/example/jehunonboarding/controller/request/JobPostingRegisterRequest.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,15 +1,23 @@ | ||
package com.example.jehunonboarding.controller.request; | ||
|
||
import com.example.jehunonboarding.domain.JobPostingRegisterInfo; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class JobPostingRegisterRequest { | ||
@NotNull | ||
private int companyId; | ||
private String companyName; | ||
private String nation; | ||
private String region; | ||
@NotNull | ||
private String jobPosition; | ||
@NotNull | ||
private long jobCompensation; | ||
@NotNull | ||
private String description; | ||
@NotNull | ||
private String skill; | ||
|
||
public JobPostingRegisterInfo toDomain() { | ||
return new JobPostingRegisterInfo(companyId, jobPosition, jobCompensation, description, skill); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/com/example/jehunonboarding/controller/response/JobPostingsSearchResponse.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,41 @@ | ||
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 JobPostingsSearchResponse { | ||
private List<JobPostingResponse> items; | ||
|
||
public JobPostingsSearchResponse(List<JobPosting> jobPostings) { | ||
this.items = jobPostings.stream() | ||
.map(JobPostingResponse::new) | ||
.collect(Collectors.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(); | ||
} | ||
} | ||
} | ||
|
||
|
20 changes: 20 additions & 0 deletions
20
src/main/java/com/example/jehunonboarding/domain/Company.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,20 @@ | ||
package com.example.jehunonboarding.domain; | ||
|
||
import jakarta.persistence.*; | ||
|
||
@Entity | ||
@Table(name = "company") | ||
public class Company { | ||
@Id | ||
@GeneratedValue | ||
private int id; | ||
|
||
@Column(nullable = false) | ||
private String companyName; | ||
|
||
@Column(nullable = false) | ||
private String nation; | ||
|
||
@Column(nullable = false) | ||
private String region; | ||
} |
11 changes: 7 additions & 4 deletions
11
...er/response/JobPostingSearchResponse.java → ...le/jehunonboarding/domain/JobPosting.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,14 +1,17 @@ | ||
package com.example.jehunonboarding.controller.response; | ||
package com.example.jehunonboarding.domain; | ||
|
||
import lombok.Data; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Data | ||
public class JobPostingSearchResponse { | ||
@Getter | ||
@AllArgsConstructor | ||
public class JobPosting { | ||
private int companyId; | ||
private String companyName; | ||
private String nation; | ||
private String region; | ||
private String jobPosition; | ||
private long jobCompensation; | ||
private String description; | ||
private String skill; | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/example/jehunonboarding/domain/JobPostingEntity.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,37 @@ | ||
package com.example.jehunonboarding.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Table(name = "job_posting") | ||
@NoArgsConstructor | ||
public class JobPostingEntity { | ||
@Id | ||
@GeneratedValue | ||
@Column(nullable = false) | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private int companyId; | ||
|
||
@Column(nullable = false) | ||
private String jobPosition; | ||
|
||
@Column(nullable = false) | ||
private long jobCompensation; | ||
|
||
@Column(nullable = false) | ||
private String description; | ||
|
||
@Column(nullable = false) | ||
private String skill; | ||
|
||
public JobPostingEntity(int companyId, String jobPosition, long jobCompensation, String description, String skill) { | ||
this.companyId = companyId; | ||
this.jobPosition = jobPosition; | ||
this.jobCompensation = jobCompensation; | ||
this.description = description; | ||
this.skill = skill; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/example/jehunonboarding/domain/JobPostingRegisterInfo.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,14 @@ | ||
package com.example.jehunonboarding.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class JobPostingRegisterInfo { | ||
private int companyId; | ||
private String jobPosition; | ||
private long jobCompensation; | ||
private String description; | ||
private String skill; | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/example/jehunonboarding/domain/JobPostingService.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,36 @@ | ||
package com.example.jehunonboarding.domain; | ||
|
||
import com.example.jehunonboarding.repository.CompanyRepository; | ||
import com.example.jehunonboarding.repository.JobPostingRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class JobPostingService { | ||
|
||
private final JobPostingRepository jobPostingRepository; | ||
private final CompanyRepository companyRepository; | ||
|
||
public void register(JobPostingRegisterInfo registerInfo) { | ||
companyRepository.findById(registerInfo.getCompanyId()) | ||
.orElseThrow(() -> new IllegalArgumentException("존재하지 않는 회사입니다.")); | ||
|
||
jobPostingRepository.save( | ||
new JobPostingEntity( | ||
registerInfo.getCompanyId(), | ||
registerInfo.getJobPosition(), | ||
registerInfo.getJobCompensation(), | ||
registerInfo.getDescription(), | ||
registerInfo.getSkill() | ||
) | ||
); | ||
} | ||
|
||
public List<JobPosting> search(Pageable pageable, String keyword) { | ||
return jobPostingRepository.findByKeyword(pageable, keyword); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/example/jehunonboarding/repository/CompanyRepository.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,7 @@ | ||
package com.example.jehunonboarding.repository; | ||
|
||
import com.example.jehunonboarding.domain.Company; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface CompanyRepository extends JpaRepository<Company, Integer> { | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/example/jehunonboarding/repository/JobPostingRepository.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 com.example.jehunonboarding.repository; | ||
|
||
import com.example.jehunonboarding.domain.JobPosting; | ||
import com.example.jehunonboarding.domain.JobPostingEntity; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
import java.util.List; | ||
|
||
public interface JobPostingRepository extends JpaRepository<JobPostingEntity, Long> { | ||
|
||
@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 WHERE jp.jobPosition LIKE %:keyword% OR c.companyName LIKE %:keyword%") | ||
List<JobPosting> findByKeyword(Pageable pageable, String keyword); | ||
} |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
spring: | ||
datasource: | ||
url: jdbc:h2:mem:testdb | ||
username: sa | ||
password: | ||
generate-unique-name: false | ||
jpa: | ||
defer-datasource-initialization: true | ||
properties: | ||
hibernate: | ||
format_sql: true | ||
show_sql: true | ||
ddl-auto: create | ||
database-platform: org.hibernate.dialect.H2Dialect | ||
h2: | ||
console: | ||
enabled: true |
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 @@ | ||
INSERT INTO company (id, company_name, nation, region) VALUES (1, '제훈테크', '한국', '서울'); |