我的分享题库,题目渲染

This commit is contained in:
Unique-Jerry 2023-11-20 19:27:02 +08:00
commit 8fd6f06530
6 changed files with 187 additions and 5 deletions

View File

@ -7,10 +7,7 @@ import com.yzdx.AiInterviewer.entity.SharedQuestionBank;
import com.yzdx.AiInterviewer.entity.dto.QuestionDto; import com.yzdx.AiInterviewer.entity.dto.QuestionDto;
import com.yzdx.AiInterviewer.entity.dto.SharedQuestionBankDto; import com.yzdx.AiInterviewer.entity.dto.SharedQuestionBankDto;
import com.yzdx.AiInterviewer.entity.dto.SharedQuestionDto; import com.yzdx.AiInterviewer.entity.dto.SharedQuestionDto;
import com.yzdx.AiInterviewer.service.QuestionBankService; import com.yzdx.AiInterviewer.service.*;
import com.yzdx.AiInterviewer.service.QuestionService;
import com.yzdx.AiInterviewer.service.SharedQuestionBankService;
import com.yzdx.AiInterviewer.service.SharedQuestionService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -34,6 +31,7 @@ public class QuestionController {
@Autowired @Autowired
private SharedQuestionService sharedQuestionService; private SharedQuestionService sharedQuestionService;
/** /**
* 获取题库列表 * 获取题库列表
* @param encoding 公司编码 * @param encoding 公司编码
@ -347,7 +345,27 @@ public class QuestionController {
} }
return R.error(result); return R.error(result);
} }
@GetMapping("/get_OurQuestionTypeList")
public R getOurSharedQuestionTypeList(String encoding){
List<SharedQuestionBankDto> ourQuestionTypeList = sharedQuestionBankService.getOurQuestionTypeList(encoding);
return R.success(ourQuestionTypeList);
}
@GetMapping("/search_OurSharedQuestionType")
public R searchOurSharedQuestionType(String encoding,String searchName){
List<SharedQuestionBankDto> sharedQuestionBankDtoList = sharedQuestionBankService.searchOurSharedQuestionType(encoding, searchName);
return R.success(sharedQuestionBankDtoList);
}
@GetMapping("/get_OurQuestionList")
public R getOurSharedQuestionList(String encoding){
List<SharedQuestionDto> ourQuestionList = sharedQuestionService.getOurQuestionList(encoding);
return R.success(ourQuestionList);
}
@GetMapping("/search_OurSharedQuestion")
public R searchOurSharedQuestion(String encoding,String searchName){
List<SharedQuestionDto> sharedQuestionDtoList = sharedQuestionService.searchOurSharedQuestion(encoding, searchName);
return R.success(sharedQuestionDtoList);
}

View File

@ -53,5 +53,21 @@ public interface SharedQuestionBankService extends IService<SharedQuestionBank>
*/ */
String addQuestionTypeFromShare(List<Integer>SharedBankIds,Integer userId,String encoding); String addQuestionTypeFromShare(List<Integer>SharedBankIds,Integer userId,String encoding);
/**
* 根据公司编码获取本公司分享的题库
* @param encoding
* @return 题库列表
*/
List<SharedQuestionBankDto> getOurQuestionTypeList(String encoding);
/**
* 根据公司编码和题库名称搜索题库
* @param encoding
* @param searchName
* @return 题库列表
*/
List<SharedQuestionBankDto> searchOurSharedQuestionType(String encoding,String searchName);
} }

View File

@ -2,6 +2,7 @@ package com.yzdx.AiInterviewer.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yzdx.AiInterviewer.entity.SharedQuestion; import com.yzdx.AiInterviewer.entity.SharedQuestion;
import com.yzdx.AiInterviewer.entity.dto.SharedQuestionBankDto;
import com.yzdx.AiInterviewer.entity.dto.SharedQuestionDto; import com.yzdx.AiInterviewer.entity.dto.SharedQuestionDto;
import java.util.List; import java.util.List;
@ -41,5 +42,22 @@ public interface SharedQuestionService extends IService<SharedQuestion> {
String addQuestionFromShare(List<Integer> selectSharedQuestionIds,Integer bankId,Integer userId,String encoding); String addQuestionFromShare(List<Integer> selectSharedQuestionIds,Integer bankId,Integer userId,String encoding);
/**
* 根据公司编码获取本公司分享的题库
* @param encoding
* @return 题库列表
*/
List<SharedQuestionDto> getOurQuestionList(String encoding);
/**
* 根据公司编码和题库名称搜索题库
* @param encoding
* @param searchName
* @return 题库列表
*/
List<SharedQuestionDto> searchOurSharedQuestion(String encoding,String searchName);
} }

View File

@ -34,7 +34,7 @@ public class SharedQuestionBankServiceImpl extends ServiceImpl<SharedQuestionBan
@Autowired @Autowired
private SharedQuestionMapper sharedQuestionMapper; private SharedQuestionMapper sharedQuestionMapper;
@Autowired @Autowired
private QuestionMapper questionMapper; private QuestionMapper questionMapper;///
@Override @Override
@ -217,6 +217,67 @@ public class SharedQuestionBankServiceImpl extends ServiceImpl<SharedQuestionBan
} }
return bankResult+"/n"+questionResult+"已存在添加题库中"; return bankResult+"/n"+questionResult+"已存在添加题库中";
} }
@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;
}

View File

@ -219,5 +219,74 @@ public class SharedQuestionServiceImpl extends ServiceImpl<SharedQuestionMapper,
return result+"已添加到题目中"; return result+"已添加到题目中";
} }
@Override
public List<SharedQuestionDto> getOurQuestionList(String encoding) {
LambdaQueryWrapper<SharedQuestion> queryWrapper=new LambdaQueryWrapper<>();
queryWrapper.eq(SharedQuestion::getCreateCompany,encoding);
List<SharedQuestion> sharedQuestions = sharedQuestionMapper.selectList(queryWrapper);
List<SharedQuestionDto> sharedQuestionDtos=sharedQuestions.stream().map(item->{
SharedQuestionDto sharedQuestionDto=new SharedQuestionDto();
BeanUtils.copyProperties(item,sharedQuestionDto);
User findCreateUser = userService.getUserById(sharedQuestionDto.getCreateUser());
sharedQuestionDto.setCreateUserName(findCreateUser.getUsername());
User findUpdateUser = userService.getUserById(sharedQuestionDto.getUpdateUser());
sharedQuestionDto.setUpdateUserName(findUpdateUser.getUsername());
SharedQuestionBank sharedQuestionBankById = sharedQuestionBankService.getSharedQuestionBankById(sharedQuestionDto.getBankId());
sharedQuestionDto.setSharedQuestionBankName(sharedQuestionBankById.getTypeName());
Company companyDetail = companyService.getCompanyDetail(sharedQuestionDto.getCreateCompany());
sharedQuestionDto.setCreateCompanyName(companyDetail.getCompanyName());
return sharedQuestionDto;
}).collect(Collectors.toList());
return sharedQuestionDtos;
}
@Override
public List<SharedQuestionDto> searchOurSharedQuestion(String encoding, String searchName) {
LambdaQueryWrapper<SharedQuestion> queryWrapper=new LambdaQueryWrapper<>();
queryWrapper.eq(SharedQuestion::getCreateCompany,encoding).like(SharedQuestion::getTitle,searchName);
List<SharedQuestion> sharedQuestions = sharedQuestionMapper.selectList(queryWrapper);
List<SharedQuestionDto> sharedQuestionDtos=sharedQuestions.stream().map(item->{
SharedQuestionDto sharedQuestionDto=new SharedQuestionDto();
BeanUtils.copyProperties(item,sharedQuestionDto);
User findCreateUser = userService.getUserById(sharedQuestionDto.getCreateUser());
sharedQuestionDto.setCreateUserName(findCreateUser.getUsername());
User findUpdateUser = userService.getUserById(sharedQuestionDto.getUpdateUser());
sharedQuestionDto.setUpdateUserName(findUpdateUser.getUsername());
SharedQuestionBank sharedQuestionBankById = sharedQuestionBankService.getSharedQuestionBankById(sharedQuestionDto.getBankId());
sharedQuestionDto.setSharedQuestionBankName(sharedQuestionBankById.getTypeName());
Company companyDetail = companyService.getCompanyDetail(sharedQuestionDto.getCreateCompany());
sharedQuestionDto.setCreateCompanyName(companyDetail.getCompanyName());
return sharedQuestionDto;
}).collect(Collectors.toList());
return sharedQuestionDtos;
}
} }