分享题库功能完善

This commit is contained in:
Unique-Jerry 2023-11-19 20:32:02 +08:00
parent ca5414d779
commit 0bbfa546fc
3 changed files with 44 additions and 0 deletions

View File

@ -289,7 +289,13 @@ public class QuestionController {
return R.success(sharedQuestionList); return R.success(sharedQuestionList);
} }
@GetMapping("/get_sharedQuestionByBankId")
public R getSharedQuestionListBySharedBankId(Integer sharedBankId){
List<SharedQuestionDto> sharedQuestionList = sharedQuestionService.getSharedQuestionListBySharedBankId(sharedBankId);
return R.success(sharedQuestionList);
}
@PostMapping("/add_sharedQuestion") @PostMapping("/add_sharedQuestion")
public R addSharedQuestion(@RequestBody Map<String,Object> addInfo){ public R addSharedQuestion(@RequestBody Map<String,Object> addInfo){

View File

@ -21,4 +21,6 @@ public interface SharedQuestionService extends IService<SharedQuestion> {
List<SharedQuestionDto> getSharedQuestionList(); List<SharedQuestionDto> getSharedQuestionList();
List<SharedQuestionDto> getSharedQuestionListBySharedBankId(Integer SharedBankId);
} }

View File

@ -116,5 +116,41 @@ public class SharedQuestionServiceImpl extends ServiceImpl<SharedQuestionMapper,
return sharedQuestionDtos; return sharedQuestionDtos;
} }
@Override
public List<SharedQuestionDto> getSharedQuestionListBySharedBankId(Integer SharedBankId) {
LambdaQueryWrapper<SharedQuestion> queryWrapper=new LambdaQueryWrapper<>();
queryWrapper.eq(SharedQuestion::getBankId,SharedBankId);
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;
}
} }