2023-10-20 05:15:23 +00:00
|
|
|
package com.yzdx.AiInterviewer.controller;
|
|
|
|
|
|
|
|
import com.yzdx.AiInterviewer.comment.R;
|
|
|
|
import com.yzdx.AiInterviewer.entity.QuestionBank;
|
2023-10-22 01:10:10 +00:00
|
|
|
import com.yzdx.AiInterviewer.entity.dto.QuestionDto;
|
2023-10-20 05:15:23 +00:00
|
|
|
import com.yzdx.AiInterviewer.service.QuestionBankService;
|
2023-10-22 01:10:10 +00:00
|
|
|
import com.yzdx.AiInterviewer.service.QuestionService;
|
|
|
|
import io.swagger.annotations.ApiParam;
|
2023-10-20 05:15:23 +00:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/question")
|
|
|
|
public class QuestionController {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private QuestionBankService questionBankService;
|
|
|
|
|
2023-10-22 01:10:10 +00:00
|
|
|
@Autowired
|
|
|
|
private QuestionService questionService;
|
|
|
|
|
2023-10-20 05:15:23 +00:00
|
|
|
/**
|
|
|
|
* 获取题库列表
|
|
|
|
* @param encoding 公司编码
|
|
|
|
* @return 返回的该公司下的公司题库
|
|
|
|
* */
|
|
|
|
@GetMapping("/get_typeList")
|
2023-10-22 01:10:10 +00:00
|
|
|
public R getTypeListByEncoding(@RequestParam @ApiParam("传入前端存入的encoding数据") String encoding){
|
2023-10-20 05:15:23 +00:00
|
|
|
|
|
|
|
List<QuestionBank> typeList = questionBankService.getTypeList(encoding);
|
|
|
|
|
|
|
|
return R.success(typeList);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param addInfo typeName,encoding,userId
|
|
|
|
* @return R
|
|
|
|
* */
|
|
|
|
@PostMapping("/add_typeName")
|
2023-10-22 01:10:10 +00:00
|
|
|
public R addTypeName(@RequestBody @ApiParam("addInfo:typeName,encoding,userId") Map<String ,Object> addInfo){
|
2023-10-20 05:15:23 +00:00
|
|
|
|
2023-10-22 01:10:10 +00:00
|
|
|
if(addInfo.size()==0||addInfo.get("typeName")==null){
|
2023-10-20 05:15:23 +00:00
|
|
|
return R.error("添加失败,请检查输入");
|
|
|
|
}
|
|
|
|
String typeName=(String)addInfo.get("typeName");
|
2023-10-22 01:10:10 +00:00
|
|
|
String encoding= (String)addInfo.get("encoding");
|
2023-10-20 05:15:23 +00:00
|
|
|
Integer userId=(Integer)addInfo.get("userId");
|
|
|
|
|
|
|
|
Integer row=questionBankService.addTypeName(typeName,encoding,userId);
|
|
|
|
|
|
|
|
if(row==0){
|
|
|
|
return R.error("添加失败,请联系管理员");
|
|
|
|
}
|
|
|
|
if (row==-2){
|
|
|
|
return R.error("该题库类型已存在!");
|
|
|
|
}
|
|
|
|
return R.success("添加成功");
|
|
|
|
}
|
|
|
|
|
2023-10-22 01:10:10 +00:00
|
|
|
/**
|
|
|
|
* 根据题库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);
|
|
|
|
}
|
2023-10-20 05:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-22 01:10:10 +00:00
|
|
|
|