-
Notifications
You must be signed in to change notification settings - Fork 6
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 #68 from cheng521521/main
feat:添加招聘模块
- Loading branch information
Showing
11 changed files
with
335 additions
and
17 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
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
70 changes: 70 additions & 0 deletions
70
src/main/java/com/dl/officialsite/hiring/HireController.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,70 @@ | ||
package com.dl.officialsite.hiring; | ||
|
||
import com.dl.officialsite.common.base.BaseResponse; | ||
import com.dl.officialsite.hiring.vo.HiringVO; | ||
import java.util.List; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Sort; | ||
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.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* @ClassName HireController | ||
* @Author jackchen | ||
* @Date 2023/11/7 10:45 | ||
* @Description HireController | ||
**/ | ||
@RestController | ||
@RequestMapping("/hire") | ||
public class HireController { | ||
|
||
@Autowired | ||
private HireService hireService; | ||
|
||
/** | ||
* 添加简历 | ||
*/ | ||
@PostMapping | ||
public BaseResponse add(@RequestParam String address,@RequestBody HiringVO hiringVO) { | ||
hireService.add(hiringVO); | ||
return BaseResponse.successWithData(null); | ||
} | ||
|
||
/** | ||
* 查询简历详情 | ||
*/ | ||
@GetMapping | ||
public BaseResponse detail(@RequestParam String address,@RequestParam Long id) { | ||
HiringVO hiringVO = hireService.detail(id); | ||
return BaseResponse.successWithData(hiringVO); | ||
} | ||
|
||
/** | ||
* 查询所有简历 | ||
*/ | ||
@GetMapping("/all") | ||
public BaseResponse all(@RequestParam String address, | ||
@RequestParam(defaultValue = "1") Integer pageNumber, | ||
@RequestParam(defaultValue = "10") Integer pageSize) { | ||
Pageable pageable = PageRequest.of(pageNumber - 1, pageSize, Sort.by(Sort.Direction.DESC, "createTime")); | ||
Page<HiringVO> all = hireService.all(pageable); | ||
return BaseResponse.successWithData(all); | ||
} | ||
|
||
/** | ||
* 按照类型查看简历 | ||
*/ | ||
@GetMapping("/type") | ||
public BaseResponse all(@RequestParam String address,@RequestParam List<String> skills) { | ||
List<HiringVO> hiringVOList = hireService.selectBySkills(skills); | ||
return BaseResponse.successWithData(hiringVOList); | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/dl/officialsite/hiring/HireRepository.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,12 @@ | ||
package com.dl.officialsite.hiring; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
/** | ||
* @ClassName HireRepository | ||
* @Author jackchen | ||
* @Date 2023/11/7 10:45 | ||
* @Description TODO | ||
**/ | ||
public interface HireRepository extends JpaRepository<Hiring, Long> { | ||
} |
107 changes: 107 additions & 0 deletions
107
src/main/java/com/dl/officialsite/hiring/HireService.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,107 @@ | ||
package com.dl.officialsite.hiring; | ||
|
||
import static com.dl.officialsite.common.enums.CodeEnums.NOT_FOUND_JD; | ||
|
||
import com.dl.officialsite.common.constants.Constants; | ||
import com.dl.officialsite.common.exception.BizException; | ||
import com.dl.officialsite.hiring.vo.HiringVO; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import org.springframework.beans.BeanUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageImpl; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* @ClassName HireService | ||
* @Author jackchen | ||
* @Date 2023/11/7 10:45 | ||
* @Description HireService | ||
**/ | ||
@Service | ||
public class HireService { | ||
|
||
@Autowired | ||
private HireRepository hireRepository; | ||
|
||
@Autowired | ||
private HiringSkillRepository hiringSkillRepository; | ||
|
||
public void add(HiringVO hiringVO) { | ||
Hiring hiring = new Hiring(); | ||
BeanUtils.copyProperties(hiringVO, hiring); | ||
hireRepository.save(hiring); | ||
hiringVO.getMainSkills().forEach(mainSkill -> { | ||
HiringSkill hiringSkill = new HiringSkill(); | ||
hiringSkill.setHiringId(hiring.getId()); | ||
hiringSkill.setSkill(mainSkill); | ||
hiringSkill.setType(Constants.HIRING_MAIN_SKILL); | ||
hiringSkillRepository.save(hiringSkill); | ||
}); | ||
|
||
hiringVO.getOtherSkills().forEach(otherSkill -> { | ||
HiringSkill hiringSkill = new HiringSkill(); | ||
hiringSkill.setHiringId(hiring.getId()); | ||
hiringSkill.setSkill(otherSkill); | ||
hiringSkill.setType(Constants.HIRING_OTHER_SKILL); | ||
hiringSkillRepository.save(hiringSkill); | ||
}); | ||
} | ||
|
||
public Page<HiringVO> all(Pageable pageable) { | ||
List<HiringVO> hiringVOList = new ArrayList<>();; | ||
Page<Hiring> hiringPage = hireRepository.findAll(pageable); | ||
hiringPage.getContent().forEach(hiring -> { | ||
List<String> skills = hiringSkillRepository.findByHiringId(hiring.getId()).stream() | ||
.map(HiringSkill::getSkill) | ||
.collect(Collectors.toList()); | ||
HiringVO hiringVO = new HiringVO(); | ||
BeanUtils.copyProperties(hiring, hiringVO); | ||
hiringVO.setMainSkills(skills); | ||
hiringVOList.add(hiringVO); | ||
}); | ||
Page<HiringVO> hiringVOPage = new PageImpl<>(hiringVOList, pageable, hiringPage.getTotalElements()); | ||
return hiringVOPage; | ||
} | ||
|
||
public HiringVO detail(Long id) { | ||
HiringVO hiringVO = new HiringVO(); | ||
Hiring hiring = hireRepository.findById(id) | ||
.orElseThrow(() -> new BizException(NOT_FOUND_JD.getCode(), NOT_FOUND_JD.getMsg())); | ||
BeanUtils.copyProperties(hiring, hiringVO); | ||
List<HiringSkill> hiringSkills = hiringSkillRepository.findByHiringId(id); | ||
List<String> mailSkills = hiringSkills.stream() | ||
.filter(hiringSkill -> hiringSkill.getType() == Constants.HIRING_MAIN_SKILL) | ||
.map(HiringSkill::getSkill) | ||
.collect(Collectors.toList()); | ||
hiringVO.setMainSkills(mailSkills); | ||
List<String> otherSkills = hiringSkills.stream() | ||
.filter(hiringSkill -> hiringSkill.getType() == Constants.HIRING_OTHER_SKILL) | ||
.map(HiringSkill::getSkill) | ||
.collect(Collectors.toList()); | ||
hiringVO.setOtherSkills(otherSkills); | ||
return hiringVO; | ||
} | ||
|
||
public List<HiringVO> selectBySkills(List<String> skills) { | ||
//使用in查询 | ||
List<HiringSkill> hiringSkills = hiringSkillRepository.findBySkill(skills); | ||
//去重通过hiringId | ||
List<Long> hiringIds = hiringSkills.stream().map(HiringSkill::getHiringId).distinct().collect(Collectors.toList()); | ||
List<HiringVO> hiringVOList = new ArrayList<>(); | ||
hireRepository.findAllById(hiringIds).forEach(hiring -> { | ||
HiringVO hiringVO = new HiringVO(); | ||
BeanUtils.copyProperties(hiring, hiringVO); | ||
List<String> mainSkills = hiringSkills.stream() | ||
.filter(hiringSkill -> hiringSkill.getHiringId().equals(hiring.getId())) | ||
.map(HiringSkill::getSkill) | ||
.collect(Collectors.toList()); | ||
hiringVO.setMainSkills(mainSkills); | ||
hiringVOList.add(hiringVO); | ||
}); | ||
return hiringVOList; | ||
} | ||
} |
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,17 +1,47 @@ | ||
package com.dl.officialsite.hiring; | ||
|
||
|
||
import java.util.Date; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.Table; | ||
import lombok.Data; | ||
import org.hibernate.annotations.CreationTimestamp; | ||
|
||
@Data | ||
@Entity | ||
@Table(name = "hiring") | ||
public class Hiring { | ||
private String headline; | ||
private String employer; | ||
private String jd; | ||
private String role; | ||
private String requirement; | ||
private String locate; | ||
private String salary; | ||
private String memo; | ||
|
||
private String contact; | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String position; | ||
|
||
private String description; | ||
|
||
private String location; | ||
|
||
private String email; | ||
|
||
private String company; | ||
|
||
private String invoice; | ||
|
||
private int minYearlySalary; | ||
|
||
private int maxYearlySalary; | ||
|
||
private String benefits; | ||
|
||
private String twitter; | ||
|
||
@CreationTimestamp | ||
@Column(updatable = false, nullable = false) | ||
private Date createTime; | ||
|
||
} |
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,31 @@ | ||
package com.dl.officialsite.hiring; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.Table; | ||
import lombok.Data; | ||
|
||
/** | ||
* @ClassName HiringSkill | ||
* @Author jackchen | ||
* @Date 2023/12/7 00:33 | ||
* @Description TODO | ||
**/ | ||
@Data | ||
@Entity | ||
@Table(name = "hiring_skill") | ||
public class HiringSkill { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private Long hiringId; | ||
|
||
private String skill; | ||
|
||
private int type; | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/dl/officialsite/hiring/HiringSkillRepository.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 com.dl.officialsite.hiring; | ||
|
||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
/** | ||
* @ClassName HiringSkillRepository | ||
* @Author jackchen | ||
* @Date 2023/12/7 00:36 | ||
* @Description HiringSkillRepository | ||
**/ | ||
public interface HiringSkillRepository extends JpaRepository<HiringSkill, Long> { | ||
|
||
@Query(value = "select * from hiring_skill where hiring_id = :hiring_id",nativeQuery = true) | ||
List<HiringSkill> findByHiringId(@Param("hiring_id")Long hiring_id); | ||
|
||
@Query(value = "select * from hiring_skill where skill in (:skills)",nativeQuery = true) | ||
List<HiringSkill> findBySkill(@Param("skills")List<String> skills); | ||
} |
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.dl.officialsite.hiring.vo; | ||
|
||
import java.util.List; | ||
import lombok.Data; | ||
|
||
/** | ||
* @ClassName HiringVO | ||
* @Author jackchen | ||
* @Date 2023/12/7 00:37 | ||
* @Description HiringVO | ||
**/ | ||
@Data | ||
public class HiringVO { | ||
|
||
private Long id; | ||
|
||
private String position; | ||
|
||
private String description; | ||
|
||
private String location; | ||
|
||
private String email; | ||
|
||
private List<String> mainSkills; | ||
|
||
private List<String> otherSkills; | ||
|
||
private String company; | ||
|
||
private String invoice; | ||
|
||
private int minYearlySalary; | ||
|
||
private int maxYearlySalary; | ||
|
||
private String benefits; | ||
|
||
private String twitter; | ||
|
||
} |
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