分享题库功能完善

This commit is contained in:
Unique-Jerry 2023-11-19 13:19:41 +08:00
parent 7acc89a027
commit ab390e59c1
13 changed files with 217 additions and 18 deletions

View File

@ -5,6 +5,8 @@ import com.yzdx.AiInterviewer.entity.Question;
import com.yzdx.AiInterviewer.entity.QuestionBank; import com.yzdx.AiInterviewer.entity.QuestionBank;
import com.yzdx.AiInterviewer.entity.SharedQuestionBank; 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.SharedQuestionDto;
import com.yzdx.AiInterviewer.service.QuestionBankService; import com.yzdx.AiInterviewer.service.QuestionBankService;
import com.yzdx.AiInterviewer.service.QuestionService; import com.yzdx.AiInterviewer.service.QuestionService;
import com.yzdx.AiInterviewer.service.SharedQuestionBankService; import com.yzdx.AiInterviewer.service.SharedQuestionBankService;
@ -239,7 +241,6 @@ public class QuestionController {
} }
return R.success("修改成功!"); return R.success("修改成功!");
} }
/** /**
*删除题目 *删除题目
* @param id 删除题目的id * @param id 删除题目的id
@ -256,28 +257,47 @@ public class QuestionController {
return R.success("删除成功!"); return R.success("删除成功!");
} }
@PostMapping("/add_question_sharedQuestionBank") @GetMapping("/get_sharedQuestionType")
public R getSharedQuestionBankList(){
List<SharedQuestionBankDto> sharedQuestionBank = sharedQuestionBankService.getSharedQuestionBank();
return R.success(sharedQuestionBank);
}
@PostMapping("/add_sharedQuestionBank")
public R addSharedQuestionType(@RequestBody Map<String ,Object> addInfo){ public R addSharedQuestionType(@RequestBody Map<String ,Object> addInfo){
String typeName=(String) addInfo.get("typeName"); String typeName=(String) addInfo.get("typeName");
Integer type=(Integer) addInfo.get("type"); Integer type=(Integer) addInfo.get("type");
String description=(String) addInfo.get("description"); String description=(String) addInfo.get("description");
Integer userId=(Integer) addInfo.get("userId"); Integer userId=(Integer) addInfo.get("userId");
String encoding=(String)addInfo.get("encoding");
SharedQuestionBank sharedQuestionBank = sharedQuestionBankService.addSharedQuestionBank(typeName, type, description, userId); SharedQuestionBank sharedQuestionBank = sharedQuestionBankService.addSharedQuestionBank(typeName, type, description, userId,encoding);
if(sharedQuestionBank==null){ if(sharedQuestionBank==null){
return R.error("添加失败,可能创建了相同名称的题库!"); return R.error("添加失败,贵公司可能创建了相同名称的题库!");
} }
return R.success("添加成功",sharedQuestionBank); return R.success("添加成功",sharedQuestionBank);
} }
@PostMapping("/add_question_sharedQuestion") @GetMapping("/get_sharedQuestion")
public R getSharedQuestionList(){
List<SharedQuestionDto> sharedQuestionList = sharedQuestionService.getSharedQuestionList();
return R.success(sharedQuestionList);
}
@PostMapping("/add_sharedQuestion")
public R addSharedQuestion(@RequestBody Map<String,Object> addInfo){ public R addSharedQuestion(@RequestBody Map<String,Object> addInfo){
Integer sharedBankId=(Integer) addInfo.get("sharedBankId"); Integer sharedBankId=(Integer) addInfo.get("sharedBankId");
List<Integer> selectQuestionId=(List<Integer>) addInfo.get("selectQuestionId"); List<Integer> selectQuestionId=(List<Integer>) addInfo.get("selectQuestionId");
Integer userId =(Integer) addInfo.get("userId"); Integer userId =(Integer) addInfo.get("userId");
String encoding=(String)addInfo.get("encoding");
String result = sharedQuestionService.addSharedQuestions(sharedBankId, selectQuestionId, userId); String result = sharedQuestionService.addSharedQuestions(sharedBankId, selectQuestionId, userId,encoding);
if(result.equals("已存在添加题库中")){ if(result.equals("已存在添加题库中")){
return R.success("分享成功"); return R.success("分享成功");

View File

@ -196,7 +196,7 @@ public class UploadController {
if(videoPath==null||videoPath.equals("")){ if(videoPath==null||videoPath.equals("")){
return R.error("删除失败!"); return R.error("删除失败!");
} }
String uploadPath = request.getSession().getServletContext().getRealPath("/upload/picture/"); String uploadPath = request.getSession().getServletContext().getRealPath("/upload/video/");
try { try {
File folder = new File(uploadPath); File folder = new File(uploadPath);
File[] files = folder.listFiles(); File[] files = folder.listFiles();

View File

@ -22,4 +22,6 @@ public class SharedQuestion extends BaseEntity {
private String promote; private String promote;
@ApiModelProperty("题库id") @ApiModelProperty("题库id")
private Integer bankId; private Integer bankId;
@ApiModelProperty("创建公司编码")
private String createCompany;
} }

View File

@ -20,4 +20,6 @@ public class SharedQuestionBank extends BaseEntity{
private Integer type; private Integer type;
@ApiModelProperty("描述") @ApiModelProperty("描述")
private String description; private String description;
@ApiModelProperty("创建公司编码")
private String createCompany;
} }

View File

@ -15,6 +15,8 @@ public class JobSettingDto extends InterviewSetting {
private String backgroundUrl; private String backgroundUrl;
@ApiModelProperty("形象图片") @ApiModelProperty("形象图片")
private String imageUrl; private String imageUrl;
@ApiModelProperty("形象视频")
private String videoUrl;
@ApiModelProperty("logo图片") @ApiModelProperty("logo图片")
private String logoUrl; private String logoUrl;
@ApiModelProperty("题库名数组") @ApiModelProperty("题库名数组")

View File

@ -0,0 +1,14 @@
package com.yzdx.AiInterviewer.entity.dto;
import com.yzdx.AiInterviewer.entity.SharedQuestionBank;
import lombok.Data;
@Data
public class SharedQuestionBankDto extends SharedQuestionBank {
private String createUserName;
private String updateUserName;
private String createCompanyName;
}

View File

@ -0,0 +1,17 @@
package com.yzdx.AiInterviewer.entity.dto;
import com.yzdx.AiInterviewer.entity.SharedQuestion;
import lombok.Data;
@Data
public class SharedQuestionDto extends SharedQuestion {
private String createUserName;
private String updateUserName;
private String createCompanyName;
private String SharedQuestionBankName;
}

View File

@ -41,4 +41,6 @@ public interface CompanyService extends IService<Company> {
String treatment, String treatment,
String registeredCapital, String registeredCapital,
Integer userId); Integer userId);
} }

View File

@ -2,6 +2,9 @@ package com.yzdx.AiInterviewer.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yzdx.AiInterviewer.entity.SharedQuestionBank; import com.yzdx.AiInterviewer.entity.SharedQuestionBank;
import com.yzdx.AiInterviewer.entity.dto.SharedQuestionBankDto;
import java.util.List;
public interface SharedQuestionBankService extends IService<SharedQuestionBank> { public interface SharedQuestionBankService extends IService<SharedQuestionBank> {
@ -13,7 +16,20 @@ public interface SharedQuestionBankService extends IService<SharedQuestionBank>
* @param userId 创建人 * @param userId 创建人
* @return 创建的SharedQuestionBank对象 * @return 创建的SharedQuestionBank对象
* */ * */
SharedQuestionBank addSharedQuestionBank(String typeName,Integer type,String description,Integer userId); SharedQuestionBank addSharedQuestionBank(String typeName,Integer type,String description,Integer userId,String encoding);
/**
* 获取分享题库列表
* @return 分享题库列表
* */
List<SharedQuestionBankDto> getSharedQuestionBank();
/**
* 根据id查找分享题库对象
* @param bankId 题库ID
* @return 题库对象
*
* */
SharedQuestionBank getSharedQuestionBankById(Integer bankId);
} }

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.SharedQuestionDto;
import java.util.List; import java.util.List;
@ -15,6 +16,9 @@ public interface SharedQuestionService extends IService<SharedQuestion> {
* @return 影响的行数 * @return 影响的行数
* *
* */ * */
String addSharedQuestions(Integer sharedBankId, List<Integer> selectQuestionId,Integer userId); String addSharedQuestions(Integer sharedBankId, List<Integer> selectQuestionId,Integer userId,String encoding);
///
List<SharedQuestionDto> getSharedQuestionList();
} }

View File

@ -102,7 +102,12 @@ public class InterviewSettingServiceImpl extends ServiceImpl<InterviewSettingMap
ImagesEntity findImage = imagesMapper.selectOne(imagesEntityLambdaQueryWrapper); ImagesEntity findImage = imagesMapper.selectOne(imagesEntityLambdaQueryWrapper);
jobSettingDto.setImageUrl(findImage.getImage()); if(findImage.getImage()==null||findImage.getImage().equals("")){
jobSettingDto.setVideoUrl(findImage.getVideo());
}else {
jobSettingDto.setImageUrl(findImage.getImage());
}
//得到logo地址 //得到logo地址
LambdaQueryWrapper<LogoEntity> logoEntityLambdaQueryWrapper=new LambdaQueryWrapper<>(); LambdaQueryWrapper<LogoEntity> logoEntityLambdaQueryWrapper=new LambdaQueryWrapper<>();
@ -210,8 +215,12 @@ public class InterviewSettingServiceImpl extends ServiceImpl<InterviewSettingMap
ImagesEntity findImage = imagesMapper.selectOne(imagesEntityLambdaQueryWrapper); ImagesEntity findImage = imagesMapper.selectOne(imagesEntityLambdaQueryWrapper);
jobSettingDto.setImageUrl(findImage.getImage()); if(findImage==null||findImage.equals("")){
jobSettingDto.setImageUrl(findImage.getVideo());
}else {
jobSettingDto.setImageUrl(findImage.getImage());
}
//得到logo地址 //得到logo地址
LambdaQueryWrapper<LogoEntity> logoEntityLambdaQueryWrapper=new LambdaQueryWrapper<>(); LambdaQueryWrapper<LogoEntity> logoEntityLambdaQueryWrapper=new LambdaQueryWrapper<>();

View File

@ -3,25 +3,39 @@ package com.yzdx.AiInterviewer.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yzdx.AiInterviewer.entity.BaseEntity; import com.yzdx.AiInterviewer.entity.BaseEntity;
import com.yzdx.AiInterviewer.entity.QuestionBank; import com.yzdx.AiInterviewer.entity.Company;
import com.yzdx.AiInterviewer.entity.SharedQuestionBank; import com.yzdx.AiInterviewer.entity.SharedQuestionBank;
import com.yzdx.AiInterviewer.entity.User;
import com.yzdx.AiInterviewer.entity.dto.SharedQuestionBankDto;
import com.yzdx.AiInterviewer.mapper.SharedQuestionBankMapper; import com.yzdx.AiInterviewer.mapper.SharedQuestionBankMapper;
import com.yzdx.AiInterviewer.service.CompanyService;
import com.yzdx.AiInterviewer.service.SharedQuestionBankService; import com.yzdx.AiInterviewer.service.SharedQuestionBankService;
import com.yzdx.AiInterviewer.service.UserService;
import com.yzdx.AiInterviewer.utiles.TimeUtil; import com.yzdx.AiInterviewer.utiles.TimeUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service @Service
public class SharedQuestionBankServiceImpl extends ServiceImpl<SharedQuestionBankMapper,SharedQuestionBank> implements SharedQuestionBankService{ public class SharedQuestionBankServiceImpl extends ServiceImpl<SharedQuestionBankMapper,SharedQuestionBank> implements SharedQuestionBankService{
@Autowired @Autowired
private SharedQuestionBankMapper sharedQuestionBankMapper; private SharedQuestionBankMapper sharedQuestionBankMapper;
@Autowired
private CompanyService companyService;
@Autowired
private UserService userService;
@Override @Override
public SharedQuestionBank addSharedQuestionBank(String typeName, Integer type, String description, Integer userId) { public SharedQuestionBank addSharedQuestionBank(String typeName, Integer type, String description, Integer userId,String encoding) {
LambdaQueryWrapper<SharedQuestionBank> queryWrapper=new LambdaQueryWrapper<>(); LambdaQueryWrapper<SharedQuestionBank> queryWrapper=new LambdaQueryWrapper<>();
queryWrapper.eq(SharedQuestionBank::getTypeName,typeName).eq(BaseEntity::getCreateUser,userId); queryWrapper.eq(SharedQuestionBank::getTypeName,typeName).eq(SharedQuestionBank::getCreateCompany,encoding);
SharedQuestionBank sharedQuestionBank = sharedQuestionBankMapper.selectOne(queryWrapper); SharedQuestionBank sharedQuestionBank = sharedQuestionBankMapper.selectOne(queryWrapper);
@ -34,7 +48,10 @@ public class SharedQuestionBankServiceImpl extends ServiceImpl<SharedQuestionBan
newSharedBank.setType(type); newSharedBank.setType(type);
newSharedBank.setDescription(description); newSharedBank.setDescription(description);
newSharedBank.setCreateUser(userId); newSharedBank.setCreateUser(userId);
newSharedBank.setUpdateUser(userId);
newSharedBank.setUpdateTime(TimeUtil.getTime());
newSharedBank.setCreateTime(TimeUtil.getTime()); newSharedBank.setCreateTime(TimeUtil.getTime());
newSharedBank.setCreateCompany(encoding);
sharedQuestionBankMapper.insert(newSharedBank); sharedQuestionBankMapper.insert(newSharedBank);
@ -45,4 +62,47 @@ public class SharedQuestionBankServiceImpl extends ServiceImpl<SharedQuestionBan
return sharedQuestionBankMapper.selectOne(bankLambdaQueryWrapper); return sharedQuestionBankMapper.selectOne(bankLambdaQueryWrapper);
} }
@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;
}
@Override
public SharedQuestionBank getSharedQuestionBankById(Integer bankId) {
LambdaQueryWrapper<SharedQuestionBank> queryWrapper=new LambdaQueryWrapper<>();
queryWrapper.eq(SharedQuestionBank::getId,bankId);
SharedQuestionBank sharedQuestionBank = sharedQuestionBankMapper.selectOne(queryWrapper);
return sharedQuestionBank;
}
} }

View File

@ -2,16 +2,21 @@ package com.yzdx.AiInterviewer.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yzdx.AiInterviewer.entity.Question; import com.yzdx.AiInterviewer.entity.*;
import com.yzdx.AiInterviewer.entity.SharedQuestion; import com.yzdx.AiInterviewer.entity.dto.SharedQuestionDto;
import com.yzdx.AiInterviewer.mapper.QuestionMapper; import com.yzdx.AiInterviewer.mapper.QuestionMapper;
import com.yzdx.AiInterviewer.mapper.SharedQuestionMapper; import com.yzdx.AiInterviewer.mapper.SharedQuestionMapper;
import com.yzdx.AiInterviewer.service.CompanyService;
import com.yzdx.AiInterviewer.service.SharedQuestionBankService;
import com.yzdx.AiInterviewer.service.SharedQuestionService; import com.yzdx.AiInterviewer.service.SharedQuestionService;
import com.yzdx.AiInterviewer.service.UserService;
import com.yzdx.AiInterviewer.utiles.TimeUtil; import com.yzdx.AiInterviewer.utiles.TimeUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Service @Service
public class SharedQuestionServiceImpl extends ServiceImpl<SharedQuestionMapper, SharedQuestion> implements SharedQuestionService { public class SharedQuestionServiceImpl extends ServiceImpl<SharedQuestionMapper, SharedQuestion> implements SharedQuestionService {
@ -22,8 +27,17 @@ public class SharedQuestionServiceImpl extends ServiceImpl<SharedQuestionMapper,
@Autowired @Autowired
private SharedQuestionMapper sharedQuestionMapper; private SharedQuestionMapper sharedQuestionMapper;
@Autowired
private UserService userService;
@Autowired
private SharedQuestionBankService sharedQuestionBankService;
@Autowired
private CompanyService companyService;
@Override @Override
public String addSharedQuestions(Integer sharedBankId, List<Integer> selectQuestionId, Integer userId) { public String addSharedQuestions(Integer sharedBankId, List<Integer> selectQuestionId, Integer userId,String encoding) {
String errorQuestion=""; String errorQuestion="";
@ -59,11 +73,48 @@ public class SharedQuestionServiceImpl extends ServiceImpl<SharedQuestionMapper,
sharedQuestion.setPromote(question.getPromote()); sharedQuestion.setPromote(question.getPromote());
sharedQuestion.setCreateUser(userId); sharedQuestion.setCreateUser(userId);
sharedQuestion.setCreateTime(TimeUtil.getTime()); sharedQuestion.setCreateTime(TimeUtil.getTime());
sharedQuestion.setUpdateUser(userId);
sharedQuestion.setUpdateTime(TimeUtil.getTime());
sharedQuestion.setBankId(sharedBankId); sharedQuestion.setBankId(sharedBankId);
sharedQuestion.setCreateCompany(encoding);
sharedQuestionMapper.insert(sharedQuestion); sharedQuestionMapper.insert(sharedQuestion);
} }
errorQuestion=errorQuestion+"已存在添加题库中"; errorQuestion=errorQuestion+"已存在添加题库中";
return errorQuestion; return errorQuestion;
} }
@Override
public List<SharedQuestionDto> getSharedQuestionList() {
List<SharedQuestion> sharedQuestions = sharedQuestionMapper.selectList(null);
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;
}
} }