2023-11-16 13:22:51 +00:00
|
|
|
|
package com.yzdx.AiInterviewer.service.impl;
|
|
|
|
|
|
2023-11-18 07:36:40 +00:00
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
2023-11-16 13:22:51 +00:00
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
2023-11-19 07:50:14 +00:00
|
|
|
|
import com.yzdx.AiInterviewer.comment.R;
|
2023-11-20 02:38:57 +00:00
|
|
|
|
import com.yzdx.AiInterviewer.entity.*;
|
2023-11-19 05:19:41 +00:00
|
|
|
|
import com.yzdx.AiInterviewer.entity.dto.SharedQuestionBankDto;
|
2023-11-20 02:38:57 +00:00
|
|
|
|
import com.yzdx.AiInterviewer.mapper.QuestionBankMapper;
|
|
|
|
|
import com.yzdx.AiInterviewer.mapper.QuestionMapper;
|
2023-11-16 13:22:51 +00:00
|
|
|
|
import com.yzdx.AiInterviewer.mapper.SharedQuestionBankMapper;
|
2023-11-20 02:38:57 +00:00
|
|
|
|
import com.yzdx.AiInterviewer.mapper.SharedQuestionMapper;
|
2023-11-19 05:19:41 +00:00
|
|
|
|
import com.yzdx.AiInterviewer.service.CompanyService;
|
2023-11-16 13:22:51 +00:00
|
|
|
|
import com.yzdx.AiInterviewer.service.SharedQuestionBankService;
|
2023-11-19 05:19:41 +00:00
|
|
|
|
import com.yzdx.AiInterviewer.service.UserService;
|
2023-11-18 07:36:40 +00:00
|
|
|
|
import com.yzdx.AiInterviewer.utiles.TimeUtil;
|
2023-11-19 05:19:41 +00:00
|
|
|
|
import org.springframework.beans.BeanUtils;
|
2023-11-16 13:22:51 +00:00
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
2023-11-20 02:38:57 +00:00
|
|
|
|
import java.util.ArrayList;
|
2023-11-19 05:19:41 +00:00
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
2023-11-16 13:22:51 +00:00
|
|
|
|
@Service
|
|
|
|
|
public class SharedQuestionBankServiceImpl extends ServiceImpl<SharedQuestionBankMapper,SharedQuestionBank> implements SharedQuestionBankService{
|
|
|
|
|
@Autowired
|
|
|
|
|
private SharedQuestionBankMapper sharedQuestionBankMapper;
|
2023-11-19 05:19:41 +00:00
|
|
|
|
@Autowired
|
|
|
|
|
private CompanyService companyService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserService userService;
|
2023-11-20 02:38:57 +00:00
|
|
|
|
@Autowired
|
|
|
|
|
private QuestionBankMapper questionBankMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private SharedQuestionMapper sharedQuestionMapper;
|
|
|
|
|
@Autowired
|
2023-11-20 11:07:50 +00:00
|
|
|
|
private QuestionMapper questionMapper;///
|
2023-11-16 13:22:51 +00:00
|
|
|
|
|
|
|
|
|
|
2023-11-18 07:36:40 +00:00
|
|
|
|
@Override
|
2023-11-19 05:19:41 +00:00
|
|
|
|
public SharedQuestionBank addSharedQuestionBank(String typeName, Integer type, String description, Integer userId,String encoding) {
|
|
|
|
|
|
|
|
|
|
|
2023-11-18 07:36:40 +00:00
|
|
|
|
LambdaQueryWrapper<SharedQuestionBank> queryWrapper=new LambdaQueryWrapper<>();
|
2023-11-16 13:22:51 +00:00
|
|
|
|
|
2023-11-19 05:19:41 +00:00
|
|
|
|
queryWrapper.eq(SharedQuestionBank::getTypeName,typeName).eq(SharedQuestionBank::getCreateCompany,encoding);
|
2023-11-18 07:36:40 +00:00
|
|
|
|
|
|
|
|
|
SharedQuestionBank sharedQuestionBank = sharedQuestionBankMapper.selectOne(queryWrapper);
|
|
|
|
|
|
|
|
|
|
if (sharedQuestionBank!=null){
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
SharedQuestionBank newSharedBank=new SharedQuestionBank();
|
|
|
|
|
|
|
|
|
|
newSharedBank.setTypeName(typeName);
|
|
|
|
|
newSharedBank.setType(type);
|
|
|
|
|
newSharedBank.setDescription(description);
|
|
|
|
|
newSharedBank.setCreateUser(userId);
|
2023-11-19 05:19:41 +00:00
|
|
|
|
newSharedBank.setUpdateUser(userId);
|
|
|
|
|
newSharedBank.setUpdateTime(TimeUtil.getTime());
|
2023-11-18 07:36:40 +00:00
|
|
|
|
newSharedBank.setCreateTime(TimeUtil.getTime());
|
2023-11-19 05:19:41 +00:00
|
|
|
|
newSharedBank.setCreateCompany(encoding);
|
2023-11-18 07:36:40 +00:00
|
|
|
|
|
|
|
|
|
sharedQuestionBankMapper.insert(newSharedBank);
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<SharedQuestionBank> bankLambdaQueryWrapper=new LambdaQueryWrapper<>();
|
|
|
|
|
|
|
|
|
|
bankLambdaQueryWrapper.eq(SharedQuestionBank::getTypeName,typeName).eq(BaseEntity::getCreateUser,userId);
|
|
|
|
|
|
|
|
|
|
return sharedQuestionBankMapper.selectOne(bankLambdaQueryWrapper);
|
|
|
|
|
|
|
|
|
|
}
|
2023-11-19 07:50:14 +00:00
|
|
|
|
@Override
|
|
|
|
|
public SharedQuestionBank getSharedQuestionBankById(Integer bankId) {
|
|
|
|
|
LambdaQueryWrapper<SharedQuestionBank> queryWrapper=new LambdaQueryWrapper<>();
|
|
|
|
|
|
|
|
|
|
queryWrapper.eq(SharedQuestionBank::getId,bankId);
|
|
|
|
|
|
|
|
|
|
SharedQuestionBank sharedQuestionBank = sharedQuestionBankMapper.selectOne(queryWrapper);
|
|
|
|
|
|
|
|
|
|
return sharedQuestionBank;
|
|
|
|
|
}
|
2023-11-19 05:19:41 +00:00
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SharedQuestionBankDto> getSharedQuestionBank() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SharedQuestionBank> sharedQuestionBanks = sharedQuestionBankMapper.selectList(null);
|
|
|
|
|
|
|
|
|
|
List<SharedQuestionBankDto> sharedQuestionBankDtos=sharedQuestionBanks.stream().map(item->{
|
|
|
|
|
SharedQuestionBankDto sharedQuestionBankDto=new SharedQuestionBankDto();
|
|
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(item,sharedQuestionBankDto);
|
|
|
|
|
|
|
|
|
|
Company companyDetail = companyService.getCompanyDetail(sharedQuestionBankDto.getCreateCompany());
|
|
|
|
|
|
|
|
|
|
sharedQuestionBankDto.setCreateCompany(null);
|
|
|
|
|
|
|
|
|
|
sharedQuestionBankDto.setCreateCompanyName(companyDetail.getCompanyName());
|
|
|
|
|
|
|
|
|
|
User createUser = userService.getUserById(sharedQuestionBankDto.getCreateUser());
|
|
|
|
|
|
|
|
|
|
sharedQuestionBankDto.setCreateUserName(createUser.getUsername());
|
|
|
|
|
|
|
|
|
|
User updateUser = userService.getUserById(sharedQuestionBankDto.getUpdateUser());
|
|
|
|
|
|
|
|
|
|
sharedQuestionBankDto.setUpdateUserName(updateUser.getUsername());
|
|
|
|
|
|
|
|
|
|
return sharedQuestionBankDto;
|
|
|
|
|
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
return sharedQuestionBankDtos;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-19 07:50:14 +00:00
|
|
|
|
|
2023-11-19 05:19:41 +00:00
|
|
|
|
@Override
|
2023-11-19 07:50:14 +00:00
|
|
|
|
public SharedQuestionBank getShareQuestionTypeByCompany(String encoding){
|
2023-11-19 05:19:41 +00:00
|
|
|
|
LambdaQueryWrapper<SharedQuestionBank> queryWrapper=new LambdaQueryWrapper<>();
|
2023-11-19 07:50:14 +00:00
|
|
|
|
queryWrapper.eq(SharedQuestionBank::getCreateCompany,encoding);
|
|
|
|
|
SharedQuestionBank sharedQuestionBank =sharedQuestionBankMapper.selectOne(queryWrapper);
|
|
|
|
|
return sharedQuestionBank;
|
|
|
|
|
}
|
2023-11-19 05:19:41 +00:00
|
|
|
|
|
2023-11-20 02:38:57 +00:00
|
|
|
|
@Override
|
|
|
|
|
public List<SharedQuestionBankDto> searchSharedQuestionType(String searchName) {
|
|
|
|
|
LambdaQueryWrapper<SharedQuestionBank> queryWrapper=new LambdaQueryWrapper<>();
|
|
|
|
|
queryWrapper.like(SharedQuestionBank::getTypeName,searchName);
|
|
|
|
|
List<SharedQuestionBank> sharedQuestionBanks = sharedQuestionBankMapper.selectList(queryWrapper);
|
|
|
|
|
List<SharedQuestionBankDto> sharedQuestionBankDtos=sharedQuestionBanks.stream().map(item->{
|
|
|
|
|
SharedQuestionBankDto sharedQuestionBankDto=new SharedQuestionBankDto();
|
|
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(item,sharedQuestionBankDto);
|
|
|
|
|
|
|
|
|
|
Company companyDetail = companyService.getCompanyDetail(sharedQuestionBankDto.getCreateCompany());
|
|
|
|
|
|
|
|
|
|
sharedQuestionBankDto.setCreateCompany(null);
|
|
|
|
|
|
|
|
|
|
sharedQuestionBankDto.setCreateCompanyName(companyDetail.getCompanyName());
|
|
|
|
|
|
|
|
|
|
User createUser = userService.getUserById(sharedQuestionBankDto.getCreateUser());
|
|
|
|
|
|
|
|
|
|
sharedQuestionBankDto.setCreateUserName(createUser.getUsername());
|
|
|
|
|
|
|
|
|
|
User updateUser = userService.getUserById(sharedQuestionBankDto.getUpdateUser());
|
|
|
|
|
|
|
|
|
|
sharedQuestionBankDto.setUpdateUserName(updateUser.getUsername());
|
|
|
|
|
|
|
|
|
|
return sharedQuestionBankDto;
|
|
|
|
|
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
return sharedQuestionBankDtos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String addQuestionTypeFromShare(List<Integer>SharedBankIds, Integer userId, String encoding) {
|
|
|
|
|
String bankResult="题库:";
|
|
|
|
|
String questionResult="题目:";
|
|
|
|
|
//遍历分享题库id
|
|
|
|
|
for (Integer SharedBankId:SharedBankIds) {
|
|
|
|
|
//根据分享题库id查找每条分享题库的信息
|
|
|
|
|
LambdaQueryWrapper<SharedQuestionBank> queryWrapper=new LambdaQueryWrapper<>();
|
|
|
|
|
queryWrapper.eq(SharedQuestionBank::getId,SharedBankId);
|
|
|
|
|
SharedQuestionBank sharedQuestionBank = sharedQuestionBankMapper.selectOne(queryWrapper);
|
|
|
|
|
//根据分享题库的信息添加题库信息
|
|
|
|
|
LambdaQueryWrapper<QuestionBank> queryWrapper1=new LambdaQueryWrapper<>();
|
|
|
|
|
queryWrapper1.eq(QuestionBank::getTypeName,sharedQuestionBank.getTypeName());
|
|
|
|
|
QuestionBank questionBank1 = questionBankMapper.selectOne(queryWrapper1);
|
|
|
|
|
if (questionBank1!=null){
|
|
|
|
|
bankResult=bankResult+sharedQuestionBank.getTypeName();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
QuestionBank questionBank=new QuestionBank();
|
|
|
|
|
questionBank.setTypeName(sharedQuestionBank.getTypeName());
|
|
|
|
|
questionBank.setType(sharedQuestionBank.getType());
|
|
|
|
|
questionBank.setDescription(sharedQuestionBank.getDescription());
|
|
|
|
|
questionBank.setCompanyEncoding(encoding);
|
|
|
|
|
questionBank.setCreateUser(userId);
|
|
|
|
|
questionBank.setUpdateUser(userId);
|
|
|
|
|
questionBank.setCreateTime(TimeUtil.getTime());
|
|
|
|
|
questionBank.setUpdateTime(TimeUtil.getTime());
|
|
|
|
|
//将新数据插入到题库中
|
|
|
|
|
questionBankMapper.insert(questionBank);
|
|
|
|
|
//根据题库名字,公司编码查找题库中的题库id
|
|
|
|
|
LambdaQueryWrapper<QuestionBank> queryWrapper2=new LambdaQueryWrapper<>();
|
|
|
|
|
queryWrapper2.eq(QuestionBank::getTypeName,sharedQuestionBank.getTypeName()).eq(QuestionBank::getCompanyEncoding,encoding);
|
|
|
|
|
QuestionBank questionBank2 = questionBankMapper.selectOne(queryWrapper2);
|
|
|
|
|
Integer bankId = questionBank2.getId();
|
|
|
|
|
//根据题库id查找分享题目的信息
|
|
|
|
|
LambdaQueryWrapper<SharedQuestion> queryWrapper3=new LambdaQueryWrapper<>();
|
|
|
|
|
queryWrapper3.eq(SharedQuestion::getBankId,sharedQuestionBank.getId());
|
|
|
|
|
List<SharedQuestion> sharedQuestions = sharedQuestionMapper.selectList(queryWrapper3);
|
|
|
|
|
for (SharedQuestion sharedQuestion:
|
|
|
|
|
sharedQuestions) {
|
|
|
|
|
//根据题目信息添加题目
|
|
|
|
|
LambdaQueryWrapper<Question> queryWrapper4=new LambdaQueryWrapper<>();
|
|
|
|
|
queryWrapper4.eq(Question::getTitle,sharedQuestion.getTitle()).eq(Question::getCompanyEncoding,encoding);
|
|
|
|
|
Question questions = questionMapper.selectOne(queryWrapper4);
|
|
|
|
|
if(questions!=null){
|
|
|
|
|
questionResult=questionResult+sharedQuestion.getTitle();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
Question question=new Question();
|
|
|
|
|
question.setDetails(sharedQuestion.getDetails());
|
|
|
|
|
question.setBankId(bankId);
|
|
|
|
|
question.setPromote(sharedQuestion.getPromote());
|
|
|
|
|
question.setCompanyEncoding(encoding);
|
|
|
|
|
question.setTitle(sharedQuestion.getTitle());
|
|
|
|
|
question.setCreateTime(TimeUtil.getTime());
|
|
|
|
|
question.setUpdateTime(TimeUtil.getTime());
|
|
|
|
|
question.setCreateUser(userId);
|
|
|
|
|
question.setUpdateUser(userId);
|
|
|
|
|
questionMapper.insert(question);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return bankResult+"/n"+questionResult+"已存在添加题库中";
|
|
|
|
|
}
|
2023-11-20 11:02:00 +00:00
|
|
|
|
@Override
|
|
|
|
|
public List<SharedQuestionBankDto> getOurQuestionTypeList(String encoding) {
|
|
|
|
|
LambdaQueryWrapper<SharedQuestionBank> queryWrapper=new LambdaQueryWrapper<>();
|
|
|
|
|
queryWrapper.eq(SharedQuestionBank::getCreateCompany,encoding);
|
|
|
|
|
List<SharedQuestionBank> sharedQuestionBanks = sharedQuestionBankMapper.selectList(queryWrapper);
|
|
|
|
|
List<SharedQuestionBankDto> sharedQuestionBankDtos=sharedQuestionBanks.stream().map(item->{
|
|
|
|
|
SharedQuestionBankDto sharedQuestionBankDto=new SharedQuestionBankDto();
|
|
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(item,sharedQuestionBankDto);
|
|
|
|
|
|
|
|
|
|
Company companyDetail = companyService.getCompanyDetail(sharedQuestionBankDto.getCreateCompany());
|
|
|
|
|
|
|
|
|
|
sharedQuestionBankDto.setCreateCompany(null);
|
|
|
|
|
|
|
|
|
|
sharedQuestionBankDto.setCreateCompanyName(companyDetail.getCompanyName());
|
|
|
|
|
|
|
|
|
|
User createUser = userService.getUserById(sharedQuestionBankDto.getCreateUser());
|
|
|
|
|
|
|
|
|
|
sharedQuestionBankDto.setCreateUserName(createUser.getUsername());
|
|
|
|
|
|
|
|
|
|
User updateUser = userService.getUserById(sharedQuestionBankDto.getUpdateUser());
|
|
|
|
|
|
|
|
|
|
sharedQuestionBankDto.setUpdateUserName(updateUser.getUsername());
|
|
|
|
|
|
|
|
|
|
return sharedQuestionBankDto;
|
|
|
|
|
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
return sharedQuestionBankDtos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SharedQuestionBankDto> searchOurSharedQuestionType(String encoding, String searchName) {
|
|
|
|
|
LambdaQueryWrapper<SharedQuestionBank> queryWrapper=new LambdaQueryWrapper<>();
|
|
|
|
|
queryWrapper.like(SharedQuestionBank::getCreateCompany,encoding).like(SharedQuestionBank::getTypeName,searchName);
|
|
|
|
|
List<SharedQuestionBank> sharedQuestionBanks = sharedQuestionBankMapper.selectList(queryWrapper);
|
|
|
|
|
List<SharedQuestionBankDto> sharedQuestionBankDtos=sharedQuestionBanks.stream().map(item->{
|
|
|
|
|
SharedQuestionBankDto sharedQuestionBankDto=new SharedQuestionBankDto();
|
|
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(item,sharedQuestionBankDto);
|
|
|
|
|
|
|
|
|
|
Company companyDetail = companyService.getCompanyDetail(sharedQuestionBankDto.getCreateCompany());
|
|
|
|
|
|
|
|
|
|
sharedQuestionBankDto.setCreateCompany(null);
|
|
|
|
|
|
|
|
|
|
sharedQuestionBankDto.setCreateCompanyName(companyDetail.getCompanyName());
|
|
|
|
|
|
|
|
|
|
User createUser = userService.getUserById(sharedQuestionBankDto.getCreateUser());
|
|
|
|
|
|
|
|
|
|
sharedQuestionBankDto.setCreateUserName(createUser.getUsername());
|
|
|
|
|
|
|
|
|
|
User updateUser = userService.getUserById(sharedQuestionBankDto.getUpdateUser());
|
|
|
|
|
|
|
|
|
|
sharedQuestionBankDto.setUpdateUserName(updateUser.getUsername());
|
|
|
|
|
|
|
|
|
|
return sharedQuestionBankDto;
|
|
|
|
|
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
return sharedQuestionBankDtos;
|
|
|
|
|
}
|
2023-11-20 02:38:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-11-19 05:19:41 +00:00
|
|
|
|
|
2023-11-16 13:22:51 +00:00
|
|
|
|
}
|
2023-11-20 02:38:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|