-
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.
- Loading branch information
Showing
18 changed files
with
502 additions
and
42 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
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
80 changes: 80 additions & 0 deletions
80
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,80 @@ | ||
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.PutMapping; | ||
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); | ||
} | ||
|
||
/** | ||
* 修改简历 | ||
*/ | ||
@PutMapping | ||
public BaseResponse update(@RequestParam String address,@RequestBody HiringVO hiringVO) { | ||
hireService.update(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> { | ||
} |
175 changes: 175 additions & 0 deletions
175
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,175 @@ | ||
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.HiringSkillVO; | ||
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(); | ||
BeanUtils.copyProperties(mainSkill, hiringSkill); | ||
hiringSkill.setType(Constants.HIRING_MAIN_SKILL); | ||
hiringSkill.setHiringId(hiring.getId()); | ||
hiringSkillRepository.save(hiringSkill); | ||
}); | ||
|
||
hiringVO.getOtherSkills().forEach(otherSkill -> { | ||
HiringSkill hiringSkill = new HiringSkill(); | ||
BeanUtils.copyProperties(otherSkill, hiringSkill); | ||
hiringSkill.setType(Constants.HIRING_OTHER_SKILL); | ||
hiringSkill.setHiringId(hiring.getId()); | ||
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<HiringSkillVO> mainSkills = hiringSkillRepository.findByHiringId(hiring.getId()) | ||
.stream() | ||
.filter(hiringSkill -> hiringSkill.getType() == Constants.HIRING_MAIN_SKILL) | ||
.map(hiringSkill -> { | ||
HiringSkillVO hiringSkillVO = new HiringSkillVO(); | ||
BeanUtils.copyProperties(hiringSkill, hiringSkillVO); | ||
return hiringSkillVO; | ||
}) | ||
.collect(Collectors.toList()); | ||
List<HiringSkillVO> otherSkills = hiringSkillRepository.findByHiringId(hiring.getId()) | ||
.stream() | ||
.filter(hiringSkill -> hiringSkill.getType() == Constants.HIRING_OTHER_SKILL) | ||
.map(hiringSkill -> { | ||
HiringSkillVO hiringSkillVO = new HiringSkillVO(); | ||
BeanUtils.copyProperties(hiringSkill, hiringSkillVO); | ||
return hiringSkillVO; | ||
}) | ||
.collect(Collectors.toList()); | ||
HiringVO hiringVO = new HiringVO(); | ||
BeanUtils.copyProperties(hiring, hiringVO); | ||
hiringVO.setMainSkills(mainSkills); | ||
hiringVO.setOtherSkills(otherSkills); | ||
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<HiringSkillVO> mailSkills = hiringSkills.stream() | ||
.filter(hiringSkill -> hiringSkill.getType() == Constants.HIRING_MAIN_SKILL) | ||
.map(hiringSkill -> { | ||
HiringSkillVO hiringSkillVO = new HiringSkillVO(); | ||
BeanUtils.copyProperties(hiringSkill, hiringSkillVO); | ||
return hiringSkillVO; | ||
}) | ||
.collect(Collectors.toList()); | ||
hiringVO.setMainSkills(mailSkills); | ||
List<HiringSkillVO> otherSkills = hiringSkills.stream() | ||
.filter(hiringSkill -> hiringSkill.getType() == Constants.HIRING_OTHER_SKILL) | ||
.map(hiringSkill -> { | ||
HiringSkillVO hiringSkillVO = new HiringSkillVO(); | ||
BeanUtils.copyProperties(hiringSkill, hiringSkillVO); | ||
return hiringSkillVO; | ||
}) | ||
.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<HiringSkillVO> mainSkills = hiringSkills.stream() | ||
.filter(hiringSkill -> hiringSkill.getHiringId().equals(hiring.getId())) | ||
.filter(hiringSkill -> hiringSkill.getType() == Constants.HIRING_MAIN_SKILL) | ||
.map(hiringSkill -> { | ||
HiringSkillVO hiringSkillVO = new HiringSkillVO(); | ||
BeanUtils.copyProperties(hiringSkill, hiringSkillVO); | ||
return hiringSkillVO; | ||
}) | ||
.collect(Collectors.toList()); | ||
|
||
List<HiringSkillVO> otherSkills = hiringSkills.stream() | ||
.filter(hiringSkill -> hiringSkill.getHiringId().equals(hiring.getId())) | ||
.filter(hiringSkill -> hiringSkill.getType() == Constants.HIRING_OTHER_SKILL) | ||
.map(hiringSkill -> { | ||
HiringSkillVO hiringSkillVO = new HiringSkillVO(); | ||
BeanUtils.copyProperties(hiringSkill, hiringSkillVO); | ||
return hiringSkillVO; | ||
}) | ||
.collect(Collectors.toList()); | ||
hiringVO.setMainSkills(mainSkills); | ||
hiringVO.setOtherSkills(otherSkills); | ||
hiringVOList.add(hiringVO); | ||
}); | ||
return hiringVOList; | ||
} | ||
|
||
/** | ||
* 修改简历 | ||
* @param hiringVO | ||
*/ | ||
public void update(HiringVO hiringVO) { | ||
Hiring hiring = hireRepository.findById(hiringVO.getId()) | ||
.orElseThrow(() -> new BizException(NOT_FOUND_JD.getCode(), NOT_FOUND_JD.getMsg())); | ||
BeanUtils.copyProperties(hiringVO, hiring); | ||
hireRepository.save(hiring); | ||
//删除原有的技能 | ||
hiringSkillRepository.deleteByHiringId(hiring.getId()); | ||
//添加新的技能 | ||
hiringVO.getMainSkills().forEach(mainSkill -> { | ||
HiringSkill hiringSkill = new HiringSkill(); | ||
BeanUtils.copyProperties(mainSkill, hiringSkill); | ||
hiringSkill.setHiringId(hiring.getId()); | ||
hiringSkillRepository.save(hiringSkill); | ||
}); | ||
|
||
hiringVO.getOtherSkills().forEach(otherSkill -> { | ||
HiringSkill hiringSkill = new HiringSkill(); | ||
BeanUtils.copyProperties(otherSkill, hiringSkill); | ||
hiringSkill.setHiringId(hiring.getId()); | ||
hiringSkillRepository.save(hiringSkill); | ||
}); | ||
} | ||
} |
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; | ||
|
||
} |
Oops, something went wrong.