MyCollectionServiceImpl.java 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. package com.sqx.modules.myCollection.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.core.metadata.IPage;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.sqx.common.utils.Result;
  6. import com.sqx.modules.app.service.UserService;
  7. import com.sqx.modules.app.vo.ResumesBrowseVo;
  8. import com.sqx.modules.app.vo.UserPostPushBrowseVo;
  9. import com.sqx.modules.myCollection.entity.MyCollection;
  10. import com.sqx.modules.myCollection.dao.MyCollectionDao;
  11. import com.sqx.modules.myCollection.service.MyCollectionService;
  12. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  13. import com.sqx.modules.resumes.dao.ResumesDao;
  14. import com.sqx.modules.resumes.entity.PostPush;
  15. import com.sqx.modules.resumes.entity.Resumes;
  16. import com.sqx.modules.resumes.entity.ResumesDetails;
  17. import com.sqx.modules.resumes.entity.ResumesListDto;
  18. import com.sqx.modules.resumes.service.CompanyService;
  19. import com.sqx.modules.resumes.service.PostPushService;
  20. import com.sqx.modules.resumes.service.ResumesDetailsService;
  21. import org.apache.commons.lang.StringUtils;
  22. import org.springframework.beans.factory.annotation.Autowired;
  23. import org.springframework.stereotype.Service;
  24. import java.time.LocalDateTime;
  25. /**
  26. * <p>
  27. * 服务实现类
  28. * </p>
  29. *
  30. * @author www.javacoder.top
  31. * @since 2023-01-17
  32. */
  33. @Service
  34. public class MyCollectionServiceImpl extends ServiceImpl<MyCollectionDao, MyCollection> implements MyCollectionService {
  35. @Autowired
  36. private UserService userService;
  37. @Autowired
  38. private PostPushService postPushService;
  39. @Autowired
  40. private ResumesDetailsService resumesDetailsService;
  41. @Autowired
  42. private MyCollectionService myCollectionService;
  43. @Autowired
  44. private ResumesDao resumesDao;
  45. @Override
  46. public Result saveCollection(MyCollection collection) {
  47. QueryWrapper<MyCollection> wrapper = new QueryWrapper<MyCollection>().eq("user_id", collection.getUserId());
  48. if (collection.getType() == 1) {
  49. wrapper.eq("post_push_id", collection.getPostPushId());
  50. } else {
  51. wrapper.eq("resumes_id", collection.getResumesId());
  52. }
  53. MyCollection myCollection = baseMapper.selectOne(wrapper);
  54. if (myCollection != null) {
  55. baseMapper.deleteById(myCollection.getCollectionId());
  56. return Result.success("取消收藏成功");
  57. }
  58. collection.setCreateTime(LocalDateTime.now());
  59. baseMapper.insert(collection);
  60. return Result.success("收藏成功");
  61. }
  62. @Override
  63. public IPage<MyCollection> getMyCollectionList(Integer page, Integer limit, MyCollection collection) {
  64. Page<MyCollection> pages;
  65. if (page != null && limit != null) {
  66. pages = new Page<>(page, limit);
  67. } else {
  68. pages = new Page<>();
  69. pages.setSize(-1);
  70. }
  71. IPage<MyCollection> selectPage = baseMapper.selectPage(pages, new QueryWrapper<>(collection).orderByDesc("create_time"));
  72. for (MyCollection record : selectPage.getRecords()) {
  73. record.setUserEntity(userService.getById(collection.getUserId()));
  74. record.setPostPush(postPushService.getById(collection.getPostPushId()));
  75. }
  76. return selectPage;
  77. }
  78. @Override
  79. public IPage<MyCollection> getCompanyCollectionList(Integer page, Integer limit, MyCollection collection, Resumes resumes, Long userId) {
  80. Page<MyCollection> pages;
  81. if (page != null && limit != null) {
  82. pages = new Page<>(page, limit);
  83. } else {
  84. pages = new Page<>();
  85. pages.setSize(-1);
  86. }
  87. // String[] resumesCompensation = StringUtils.isNotBlank(resumes.getResumesCompensation()) ? resumes.getResumesCompensation().split(",") : null;
  88. // String[] resumesEducation = StringUtils.isNotBlank(resumes.getResumesEducation()) ? resumes.getResumesEducation().split(",") : null;
  89. // String[] resumesWorkExperience = StringUtils.isNotBlank(resumes.getResumesWorkExperience()) ? resumes.getResumesWorkExperience().split(",") : null;
  90. // String[] industryName = StringUtils.isNotBlank(resumes.getIndustryName()) ? resumes.getIndustryName().split(",") : null;
  91. // IPage<ResumesBrowseVo> companyCollectionList = baseMapper.getCompanyCollectionList(pages, collection, resumes, resumesCompensation, resumesEducation, resumesWorkExperience, industryName);
  92. // for (ResumesBrowseVo record : companyCollectionList.getRecords()) {
  93. // record.setResumesCompanyList(resumesDetailsService.list(new QueryWrapper<ResumesDetails>().eq("resumes_id", record.getResumesId()).eq("resumes_classify", 1)));
  94. //
  95. // }
  96. QueryWrapper<MyCollection> queryWrapper = new QueryWrapper<>();
  97. queryWrapper.eq("user_id",userId).eq("type",2);
  98. IPage<MyCollection> companyCollectionList =myCollectionService.getBaseMapper().selectPage(pages,queryWrapper);
  99. for (MyCollection c : companyCollectionList.getRecords()){
  100. ResumesListDto resumesListDto = new ResumesListDto();
  101. resumesListDto.setResumesId(Long.valueOf(c.getResumesId()));
  102. c.setResumesListDto(resumesDao.selectResumesListHr(resumesListDto));
  103. }
  104. return companyCollectionList;
  105. }
  106. @Override
  107. public IPage<UserPostPushBrowseVo> getMyCollectionListV2(Integer page, Integer limit, MyCollection collection, PostPush postPush) {
  108. Page<UserPostPushBrowseVo> pages;
  109. if (page != null && limit != null) {
  110. pages = new Page<>(page, limit);
  111. } else {
  112. pages = new Page<>();
  113. pages.setSize(-1);
  114. }
  115. String[] industry = StringUtils.isNotBlank(postPush.getIndustry()) ? postPush.getIndustry().split(",") : null;
  116. String[] education = StringUtils.isNotBlank(postPush.getEducation()) ? postPush.getEducation().split(",") : null;
  117. String[] experience = StringUtils.isNotBlank(postPush.getExperience()) ? postPush.getExperience().split(",") : null;
  118. String[] companyPeople = StringUtils.isNotBlank(postPush.getCompanyPeople()) ? postPush.getCompanyPeople().split(",") : null;
  119. String[] salaryRange = StringUtils.isNotBlank(postPush.getSalaryRange()) ? postPush.getSalaryRange().split(",") : null;
  120. return baseMapper.getMyCollectionList(pages, collection, postPush, industry, education, experience, companyPeople, salaryRange);
  121. }
  122. }