147 lines
4.7 KiB
Java
147 lines
4.7 KiB
Java
package com.yzdx.AiInterviewer.service.impl;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.yzdx.AiInterviewer.entity.Company;
|
|
import com.yzdx.AiInterviewer.entity.JobEntity;
|
|
import com.yzdx.AiInterviewer.entity.User;
|
|
import com.yzdx.AiInterviewer.entity.VxEntityDto.VxNoticeDto;
|
|
import com.yzdx.AiInterviewer.entity.vxEntity.VxInterviewNotice;
|
|
import com.yzdx.AiInterviewer.mapper.JobMapper;
|
|
import com.yzdx.AiInterviewer.mapper.UserMapper;
|
|
import com.yzdx.AiInterviewer.mapper.VxMapper.InterviewNoticeMapper;
|
|
import com.yzdx.AiInterviewer.service.CompanyService;
|
|
import com.yzdx.AiInterviewer.service.InterviewNoticeService;
|
|
import com.yzdx.AiInterviewer.utiles.EmailUtil;
|
|
import com.yzdx.AiInterviewer.utiles.TimeUtil;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
|
|
@Service
|
|
public class InterviewNoticeServiceImpl extends ServiceImpl<InterviewNoticeMapper, VxInterviewNotice> implements InterviewNoticeService {
|
|
|
|
@Autowired
|
|
private InterviewNoticeMapper interviewNoticeMapper;
|
|
@Autowired
|
|
private UserMapper userMapper;
|
|
@Autowired
|
|
private CompanyService companyService;
|
|
|
|
@Autowired
|
|
private JobMapper jobMapper;
|
|
|
|
@Override
|
|
public Integer addInterviewNotice(String encoding, Integer recipient, Integer jobId, Integer postId,
|
|
Integer inviteId,Integer userId) {
|
|
|
|
LambdaQueryWrapper<VxInterviewNotice> queryWrapper=new LambdaQueryWrapper<>();
|
|
|
|
queryWrapper.eq(VxInterviewNotice::getCompanyEncoding,encoding).eq(VxInterviewNotice::getJobId,jobId)
|
|
.eq(VxInterviewNotice::getPostId,postId).eq(VxInterviewNotice::getInviteId,inviteId);
|
|
|
|
VxInterviewNotice vxInterviewNotice = interviewNoticeMapper.selectOne(queryWrapper);
|
|
|
|
if(vxInterviewNotice!=null){
|
|
|
|
return -2;
|
|
}
|
|
|
|
VxInterviewNotice newVxInterviewNotice=new VxInterviewNotice();
|
|
|
|
newVxInterviewNotice.setCompanyEncoding(encoding);
|
|
|
|
newVxInterviewNotice.setRecipient(recipient);
|
|
|
|
newVxInterviewNotice.setJobId(jobId);
|
|
|
|
newVxInterviewNotice.setPostId(postId);
|
|
|
|
newVxInterviewNotice.setInviteId(inviteId);
|
|
|
|
newVxInterviewNotice.setCreateTime(TimeUtil.getTime());
|
|
|
|
newVxInterviewNotice.setUpdateTime(TimeUtil.getTime());
|
|
|
|
newVxInterviewNotice.setCreateUser(userId);
|
|
|
|
newVxInterviewNotice.setUpdateUser(userId);
|
|
|
|
//查询用户的信息
|
|
User user = userMapper.selectById(recipient);
|
|
|
|
//查询公司信息
|
|
Company companyDetail = companyService.getCompanyDetail(encoding);
|
|
|
|
//查询岗位信息
|
|
JobEntity jobEntity = jobMapper.selectById(jobId);
|
|
|
|
|
|
String companyName=companyDetail.getCompanyName();
|
|
|
|
String email=user.getEmail();
|
|
|
|
String userName=user.getUsername();
|
|
|
|
String jobName=jobEntity.getJobName();
|
|
if(email==null||userName==null||companyName==null||jobName==null){
|
|
return -3;
|
|
}
|
|
|
|
try {
|
|
EmailUtil.sendEmail(email,userName,companyName,jobName);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
return -3;
|
|
}
|
|
|
|
Integer rows = interviewNoticeMapper.insert(newVxInterviewNotice);
|
|
|
|
return rows;
|
|
}
|
|
|
|
@Override
|
|
public List<VxNoticeDto> getInterviewNoticeByUserId(Integer userId) {
|
|
LambdaQueryWrapper<VxInterviewNotice> queryWrapper=new LambdaQueryWrapper<>();
|
|
|
|
queryWrapper.eq(VxInterviewNotice::getRecipient,userId);
|
|
|
|
List<VxInterviewNotice> vxInterviewNotices = interviewNoticeMapper.selectList(queryWrapper);
|
|
|
|
List<VxNoticeDto> VxNoticeDtoList=vxInterviewNotices.stream().map(item->{
|
|
|
|
VxNoticeDto vxNoticeDto=new VxNoticeDto();
|
|
|
|
BeanUtils.copyProperties(item,vxNoticeDto);
|
|
|
|
vxNoticeDto.setCompanyEncoding(item.getCompanyEncoding());
|
|
|
|
Company companyDetail = companyService.getCompanyDetail(item.getCompanyEncoding());
|
|
|
|
vxNoticeDto.setCompanyName(companyDetail.getCompanyName());
|
|
|
|
vxNoticeDto.setInterviewSendTime(item.getCreateTime());
|
|
|
|
vxNoticeDto.setCompanyLogoUrl(companyDetail.getCompanyLogo());
|
|
|
|
User user = userMapper.selectById(item.getRecipient());
|
|
|
|
vxNoticeDto.setInterviewer(user.getUsername());
|
|
|
|
JobEntity jobEntity = jobMapper.selectById(item.getJobId());
|
|
|
|
vxNoticeDto.setJob(jobEntity.getJobName());
|
|
|
|
return vxNoticeDto;
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
return VxNoticeDtoList;
|
|
}
|
|
|
|
|
|
}
|