渲染题目列表
This commit is contained in:
parent
7927a35ba9
commit
032eb55c3b
|
@ -2,7 +2,10 @@ package com.yzdx.AiInterviewer.controller;
|
|||
|
||||
import com.yzdx.AiInterviewer.comment.R;
|
||||
import com.yzdx.AiInterviewer.entity.QuestionBank;
|
||||
import com.yzdx.AiInterviewer.entity.dto.QuestionDto;
|
||||
import com.yzdx.AiInterviewer.service.QuestionBankService;
|
||||
import com.yzdx.AiInterviewer.service.QuestionService;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
@ -16,13 +19,16 @@ public class QuestionController {
|
|||
@Autowired
|
||||
private QuestionBankService questionBankService;
|
||||
|
||||
@Autowired
|
||||
private QuestionService questionService;
|
||||
|
||||
/**
|
||||
* 获取题库列表
|
||||
* @param encoding 公司编码
|
||||
* @return 返回的该公司下的公司题库
|
||||
* */
|
||||
@GetMapping("/get_typeList")
|
||||
public R getTypeListByEncoding(@RequestParam Integer encoding){
|
||||
public R getTypeListByEncoding(@RequestParam @ApiParam("传入前端存入的encoding数据") String encoding){
|
||||
|
||||
List<QuestionBank> typeList = questionBankService.getTypeList(encoding);
|
||||
|
||||
|
@ -34,13 +40,13 @@ public class QuestionController {
|
|||
* @return R
|
||||
* */
|
||||
@PostMapping("/add_typeName")
|
||||
public R addTypeName(@RequestBody Map<String ,Object> addInfo){
|
||||
public R addTypeName(@RequestBody @ApiParam("addInfo:typeName,encoding,userId") Map<String ,Object> addInfo){
|
||||
|
||||
if(addInfo.size()==0){
|
||||
if(addInfo.size()==0||addInfo.get("typeName")==null){
|
||||
return R.error("添加失败,请检查输入");
|
||||
}
|
||||
String typeName=(String)addInfo.get("typeName");
|
||||
Integer encoding= Integer.parseInt((String)addInfo.get("encoding"));
|
||||
String encoding= (String)addInfo.get("encoding");
|
||||
Integer userId=(Integer)addInfo.get("userId");
|
||||
|
||||
Integer row=questionBankService.addTypeName(typeName,encoding,userId);
|
||||
|
@ -54,6 +60,74 @@ public class QuestionController {
|
|||
return R.success("添加成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据题库id删除题库
|
||||
* @param typeId 传入的题库id
|
||||
*
|
||||
* */
|
||||
@GetMapping("/delete_type")
|
||||
public R deleteTypeName(@RequestParam @ApiParam("typeId:传入的题库id") Integer typeId){
|
||||
if(typeId==null){
|
||||
return R.error("提交的信息错误,请检查输入");
|
||||
}
|
||||
Integer row= questionBankService.deleteType(typeId);
|
||||
|
||||
//判断是否删除成功
|
||||
if(row==0){
|
||||
return R.error("删除失败,请联系管理员");
|
||||
|
||||
}
|
||||
|
||||
return R.success("删除成功");
|
||||
}
|
||||
/**
|
||||
* 根据题库id更新题库
|
||||
* @param updateType 更新题库的信息
|
||||
*
|
||||
* */
|
||||
@PostMapping("/change_type")
|
||||
public R changeTypeName(@RequestBody @ApiParam("updateType:修改的内容 typeId 修改的题库id typeName 修改的题库名称 userId 修改人的id") Map<String ,Object> updateType){
|
||||
|
||||
if(updateType.size()==0){
|
||||
|
||||
return R.error("修改内容格式不正确,请检查输入");
|
||||
}
|
||||
|
||||
Integer typeId= (Integer) updateType.get("typeId");
|
||||
|
||||
String typeName=(String) updateType.get("typeName");
|
||||
|
||||
Integer userId=(Integer) updateType.get("userId");
|
||||
|
||||
Integer rows=questionBankService.changeType(typeId,typeName,userId);
|
||||
|
||||
if(rows==-2){
|
||||
return R.error("修改的题库名已存在!");
|
||||
}
|
||||
|
||||
if(rows==0){
|
||||
return R.error("修改失败,请稍后再试或联系管理员");
|
||||
}
|
||||
|
||||
return R.success("修改成功");
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据公司编码查找题目
|
||||
* @param encoding 公司编码
|
||||
*
|
||||
* */
|
||||
@GetMapping("/get_questionList")
|
||||
public R getQuestionList(@RequestParam String encoding){
|
||||
if(encoding==null){
|
||||
return R.error("出错了!请联系管理员");
|
||||
}
|
||||
List<QuestionDto> questionDtoList= questionService.getQuestionList(encoding);
|
||||
return R.success(questionDtoList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ public class UserController {
|
|||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@PostMapping("/login")
|
||||
@PostMapping("/login")
|
||||
public R adminLogin(@RequestBody @ApiParam("传入的值,phone,encoding,password") Map<String,Object> loginForm){
|
||||
if(loginForm.size()==0){
|
||||
return R.error("传来的数据有误,请检查输入");
|
||||
|
|
|
@ -44,5 +44,7 @@ public class Employee {
|
|||
private String age;
|
||||
@ApiModelProperty("员工证件照")
|
||||
private String avatar;
|
||||
@ApiModelProperty("员工状态,0离职,1在任")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,27 @@
|
|||
package com.yzdx.AiInterviewer.entity;
|
||||
|
||||
public class Question {
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ApiModel("题目实体类")
|
||||
@TableName("question")
|
||||
public class Question extends BaseEntity {
|
||||
@ApiModelProperty("题目id")
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
@ApiModelProperty("题目标题")
|
||||
private String title;
|
||||
@ApiModelProperty("题目详情")
|
||||
private String details;
|
||||
@ApiModelProperty("题目对应的promote")
|
||||
private String promote;
|
||||
@ApiModelProperty("题库id")
|
||||
private Integer bankId;
|
||||
@ApiModelProperty("公司编码")
|
||||
private String companyEncoding;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ public class QuestionBank extends BaseEntity{
|
|||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
@ApiModelProperty("题库名称")
|
||||
private String name;
|
||||
private String typeName;
|
||||
@ApiModelProperty("公司编码")
|
||||
private Integer companyEncoding;
|
||||
private String companyEncoding;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.yzdx.AiInterviewer.entity.dto;
|
||||
|
||||
import com.yzdx.AiInterviewer.entity.Question;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class QuestionDto extends Question {
|
||||
|
||||
@ApiModelProperty("题库名称")
|
||||
private String typeName;
|
||||
@ApiModelProperty("创建人姓名")
|
||||
private String createUserName;
|
||||
@ApiModelProperty("更新人姓名")
|
||||
private String updateUserName;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.yzdx.AiInterviewer.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yzdx.AiInterviewer.entity.Question;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface QuestionMapper extends BaseMapper<Question> {
|
||||
}
|
|
@ -5,22 +5,39 @@ import com.yzdx.AiInterviewer.entity.QuestionBank;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 题库业务层
|
||||
* */
|
||||
public interface QuestionBankService extends IService<QuestionBank> {
|
||||
|
||||
/**
|
||||
* 获取题库列表
|
||||
* @param encoding 公司编码
|
||||
* @return List<QuestionBank> 题库列表
|
||||
* */
|
||||
List<QuestionBank> getTypeList(Integer encoding);
|
||||
List<QuestionBank> getTypeList(String encoding);
|
||||
/**
|
||||
* @param typeName,encoding,userId
|
||||
* 添加题库信息
|
||||
* @param typeName 添加的题库名
|
||||
* @param encoding 添加题库的公司编码
|
||||
* @param userId 添加人
|
||||
* @return 返回影响行数
|
||||
* */
|
||||
Integer addTypeName(String typeName,Integer encoding,Integer userId);
|
||||
Integer addTypeName(String typeName,String encoding,Integer userId);
|
||||
/**
|
||||
* @param typeNameId,encoding,userId
|
||||
* 根据题库id删除题库信息
|
||||
* @param typeId 删除的题库id
|
||||
* @return 返回影响行数
|
||||
* @return 影响的行数
|
||||
* */
|
||||
Integer deleteTypeName(Integer typeNameId,Integer encoding,Integer userId);
|
||||
Integer deleteType(Integer typeId);
|
||||
|
||||
/**
|
||||
* @param typeId 修改的题库id
|
||||
* @param typeName 修改的题库名称
|
||||
* @param userId 修改人的id
|
||||
* @return 影响的行数
|
||||
* */
|
||||
Integer changeType(Integer typeId,String typeName,Integer userId);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.yzdx.AiInterviewer.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yzdx.AiInterviewer.entity.Question;
|
||||
import com.yzdx.AiInterviewer.entity.dto.QuestionDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface QuestionService extends IService<Question> {
|
||||
|
||||
/**
|
||||
* 获取题目列表
|
||||
* @param encoding 公司编码
|
||||
* @return 题目列表
|
||||
* */
|
||||
List<QuestionDto> getQuestionList(String encoding);
|
||||
}
|
|
@ -17,8 +17,9 @@ public class QuestionBankServiceImpl extends ServiceImpl<QuestionBankMapper, Que
|
|||
@Autowired
|
||||
private QuestionBankMapper questionBankMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public List<QuestionBank> getTypeList(Integer encoding) {
|
||||
public List<QuestionBank> getTypeList(String encoding) {
|
||||
//若公司编码为空,则返回空
|
||||
if(encoding==null){
|
||||
return null;
|
||||
|
@ -33,11 +34,11 @@ public class QuestionBankServiceImpl extends ServiceImpl<QuestionBankMapper, Que
|
|||
}
|
||||
|
||||
@Override
|
||||
public Integer addTypeName(String typeName, Integer encoding, Integer userId) {
|
||||
public Integer addTypeName(String typeName, String encoding, Integer userId) {
|
||||
|
||||
//判断题库名是否存在
|
||||
LambdaQueryWrapper<QuestionBank> queryWrapper =new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(QuestionBank::getName,typeName);
|
||||
queryWrapper.eq(QuestionBank::getTypeName,typeName);
|
||||
QuestionBank findQuestionBank=questionBankMapper.selectOne(queryWrapper);
|
||||
if(findQuestionBank!=null){
|
||||
//存在返回-2
|
||||
|
@ -45,7 +46,7 @@ public class QuestionBankServiceImpl extends ServiceImpl<QuestionBankMapper, Que
|
|||
}
|
||||
|
||||
QuestionBank insert=new QuestionBank();
|
||||
insert.setName(typeName);
|
||||
insert.setTypeName(typeName);
|
||||
insert.setCompanyEncoding(encoding);
|
||||
insert.setCreateUser(userId);
|
||||
insert.setUpdateUser(userId);
|
||||
|
@ -57,12 +58,45 @@ public class QuestionBankServiceImpl extends ServiceImpl<QuestionBankMapper, Que
|
|||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteTypeName(Integer typeNameId, Integer encoding, Integer userId) {
|
||||
public Integer deleteType(Integer typeId) {
|
||||
|
||||
LambdaQueryWrapper<QuestionBank> queryWrapper=new LambdaQueryWrapper<>();
|
||||
|
||||
queryWrapper.eq(QuestionBank::getId,typeNameId).eq(QuestionBank::getCompanyEncoding,encoding);
|
||||
queryWrapper.eq(QuestionBank::getId,typeId);
|
||||
|
||||
Integer row= questionBankMapper.deleteById(typeId);
|
||||
|
||||
Integer row= questionBankMapper.deleteById(typeNameId);
|
||||
return row;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer changeType(Integer typeId, String typeName, Integer userId) {
|
||||
//修改的题库名是否重名
|
||||
LambdaQueryWrapper<QuestionBank> queryWrapper =new LambdaQueryWrapper<>();
|
||||
|
||||
queryWrapper.eq(QuestionBank::getTypeName,typeName);
|
||||
|
||||
QuestionBank findBank=questionBankMapper.selectOne(queryWrapper);
|
||||
|
||||
if(findBank!=null){
|
||||
// 若重名,返回-2表示重名
|
||||
return -2;
|
||||
}
|
||||
//不重名,更新到数据库中
|
||||
//更新字段名:typeName,updateUser,updateTime
|
||||
LambdaQueryWrapper<QuestionBank> updateBankQueryWrapper=new LambdaQueryWrapper<>();
|
||||
|
||||
updateBankQueryWrapper.eq(QuestionBank::getId,typeId);
|
||||
|
||||
QuestionBank updateQuestionBank=questionBankMapper.selectOne(updateBankQueryWrapper);
|
||||
|
||||
updateQuestionBank.setUpdateUser(userId);
|
||||
|
||||
updateQuestionBank.setUpdateTime(TimeUtil.getTime());
|
||||
|
||||
updateQuestionBank.setTypeName(typeName);
|
||||
|
||||
return questionBankMapper.updateById(updateQuestionBank);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
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.Question;
|
||||
import com.yzdx.AiInterviewer.entity.QuestionBank;
|
||||
import com.yzdx.AiInterviewer.entity.User;
|
||||
import com.yzdx.AiInterviewer.entity.dto.QuestionDto;
|
||||
import com.yzdx.AiInterviewer.mapper.QuestionBankMapper;
|
||||
import com.yzdx.AiInterviewer.mapper.QuestionMapper;
|
||||
import com.yzdx.AiInterviewer.mapper.UserMapper;
|
||||
import com.yzdx.AiInterviewer.service.QuestionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> implements QuestionService {
|
||||
|
||||
@Autowired
|
||||
private QuestionMapper questionMapper;
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
@Autowired
|
||||
private QuestionBankMapper questionBankMapper;
|
||||
|
||||
@Override
|
||||
public List<QuestionDto> getQuestionList(String encoding) {
|
||||
//根据公司编码寻找题目
|
||||
LambdaQueryWrapper<Question> queryWrapper=new LambdaQueryWrapper<>();
|
||||
|
||||
queryWrapper.eq(Question::getCompanyEncoding,encoding);
|
||||
|
||||
List<Question> questionList= questionMapper.selectList(queryWrapper);
|
||||
|
||||
List<QuestionDto> questionDtoList =new ArrayList<>();
|
||||
|
||||
QuestionDto questionDto=new QuestionDto();
|
||||
|
||||
QuestionBank findQuestionBank=new QuestionBank();
|
||||
|
||||
|
||||
for (Question question:questionList) {
|
||||
questionDto.setId(question.getId());
|
||||
questionDto.setTitle(question.getTitle());
|
||||
questionDto.setDetails(question.getDetails());
|
||||
questionDto.setPromote(question.getPromote());
|
||||
questionDto.setBankId(question.getBankId());
|
||||
questionDto.setCompanyEncoding(question.getCompanyEncoding());
|
||||
questionDto.setCreateTime(question.getCreateTime());
|
||||
questionDto.setUpdateTime(question.getUpdateTime());
|
||||
LambdaQueryWrapper<User> userLambdaQueryWrapper =new LambdaQueryWrapper<>();
|
||||
|
||||
userLambdaQueryWrapper.eq(User::getId,question.getCreateUser());
|
||||
|
||||
User findCreateUser= userMapper.selectOne(userLambdaQueryWrapper);
|
||||
|
||||
questionDto.setCreateUserName(findCreateUser.getUsername());
|
||||
|
||||
LambdaQueryWrapper<User> userLambdaQueryWrapper1 =new LambdaQueryWrapper<>();
|
||||
|
||||
userLambdaQueryWrapper.eq(User::getId,question.getUpdateUser());
|
||||
|
||||
User findUpdateUser= userMapper.selectOne(userLambdaQueryWrapper1);
|
||||
|
||||
questionDto.setUpdateUserName(findUpdateUser.getUsername());
|
||||
|
||||
LambdaQueryWrapper<QuestionBank> bankQueryWrapper=new LambdaQueryWrapper<>();
|
||||
|
||||
bankQueryWrapper.eq(QuestionBank::getId,question.getBankId());
|
||||
|
||||
findQuestionBank=questionBankMapper.selectOne(bankQueryWrapper);
|
||||
|
||||
questionDto.setTypeName(findQuestionBank.getTypeName());
|
||||
|
||||
questionDtoList.add(questionDto);
|
||||
}
|
||||
|
||||
return questionDtoList;
|
||||
}
|
||||
}
|
|
@ -38,12 +38,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|||
queryWrapper2.eq(Employee::getPhone,phone).eq(Employee::getCompanyEncoding,encoding);
|
||||
Employee findEmployee=employeeMapper.selectOne(queryWrapper2);
|
||||
|
||||
if(findEmployee==null){
|
||||
if(findEmployee==null ||findEmployee.getStatus()==0){
|
||||
|
||||
return R.error("输入的账号或密码错误");
|
||||
}
|
||||
|
||||
|
||||
|
||||
LambdaQueryWrapper<User> queryWrapper=new LambdaQueryWrapper();
|
||||
|
||||
queryWrapper.eq(User::getPhone,phone);
|
||||
|
|
Loading…
Reference in New Issue