Commit 5db4a0a8 by yangyang

题库删除、修改提交

parent fb4831ec
...@@ -7,9 +7,7 @@ import com.exam.serviceimpl.AnswerServiceImpl; ...@@ -7,9 +7,7 @@ import com.exam.serviceimpl.AnswerServiceImpl;
import com.exam.util.ApiResultHandler; import com.exam.util.ApiResultHandler;
import com.exam.vo.AnswerVO; import com.exam.vo.AnswerVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
...@@ -25,4 +23,24 @@ public class AnswerController { ...@@ -25,4 +23,24 @@ public class AnswerController {
return ApiResultHandler.buildApiResult(200,"查询所有题库",answerVOIPage); return ApiResultHandler.buildApiResult(200,"查询所有题库",answerVOIPage);
} }
@GetMapping("/deleteAnswers/{questionid}/{tablename}/{subject}")
public ApiResult deleteQuestion(@PathVariable("questionid") String questionid, @PathVariable("tablename") String tablename, @PathVariable("subject") String subject){
int res = answerService.deleteQuestion(questionid,tablename,subject);
if (res == 0) {
return ApiResultHandler.buildApiResult(400,"删除失败",res);
} else {
return ApiResultHandler.buildApiResult(200,"删除成功",res);
}
}
@PostMapping("/updateAnswers")
public ApiResult updateAnswers(@RequestBody AnswerVO answerVO){
int res = answerService.updateAnswers(answerVO);
if (res == 0) {
return ApiResultHandler.buildApiResult(400,"修改失败",res);
} else {
return ApiResultHandler.buildApiResult(200,"修改成功",res);
}
}
} }
...@@ -3,9 +3,7 @@ package com.exam.mapper; ...@@ -3,9 +3,7 @@ package com.exam.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.exam.vo.AnswerVO; import com.exam.vo.AnswerVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@Mapper @Mapper
...@@ -20,4 +18,17 @@ public interface AnswerMapper { ...@@ -20,4 +18,17 @@ public interface AnswerMapper {
+ "</if>" + + "</if>" +
"</script>") "</script>")
IPage<AnswerVO> findAll(Page page,@Param("question") String question); IPage<AnswerVO> findAll(Page page,@Param("question") String question);
@Delete("delete from ${tablename} where questionid = #{questionid}")
int deleteQuestion(@Param("questionid") String questionid,@Param("tablename") String tablename);
@Delete("delete from paper_manage where questionid = #{questionid} and questionType = #{questionType} and paperid = (select paperid from exam_manage where type = #{subject})")
int deletePaperManage(@Param("questionid") String questionid,@Param("questionType") String questionType,@Param("subject") String subject);
@Update("update multi_question set question = #{question},answerA = #{answerA},answerB = #{answerB},answerC = #{answerC},answerD = #{answerD},rightAnswer = #{rightAnswer},analysis = #{analysis} where questionid = #{questionid}")
int updateMultiQuestionByQuestionid(AnswerVO answerVO);
@Update("update judge_question set question = #{question},answer = #{rightAnswer},analysis = #{analysis} where questionid = #{questionid}")
int updatejudgeQuestionByQuestionid(AnswerVO answerVO);
} }
...@@ -7,4 +7,8 @@ import com.exam.vo.AnswerVO; ...@@ -7,4 +7,8 @@ import com.exam.vo.AnswerVO;
public interface AnswerService { public interface AnswerService {
IPage<AnswerVO> findAll(Page<AnswerVO> page,String question); IPage<AnswerVO> findAll(Page<AnswerVO> page,String question);
int deleteQuestion(String questionid,String tablename,String subject);
int updateAnswers(AnswerVO answerVO);
} }
...@@ -18,4 +18,35 @@ public class AnswerServiceImpl implements AnswerService { ...@@ -18,4 +18,35 @@ public class AnswerServiceImpl implements AnswerService {
public IPage<AnswerVO> findAll(Page<AnswerVO> page,String question) { public IPage<AnswerVO> findAll(Page<AnswerVO> page,String question) {
return answerMapper.findAll(page,question); return answerMapper.findAll(page,question);
} }
@Override
public int deleteQuestion(String questionid, String tablename, String subject) {
int flag = answerMapper.deleteQuestion(questionid,tablename);
if(flag>0){
answerMapper.deletePaperManage(questionid,getQuestionType(tablename),subject);
return 1;
}
return 0;
}
@Override
public int updateAnswers(AnswerVO answerVO) {
int update = 0 ;
if("multi_question".equals(answerVO.getTablename())){
update = answerMapper.updateMultiQuestionByQuestionid(answerVO);
}else if("judge_question".equals(answerVO.getTablename())){
update = answerMapper.updatejudgeQuestionByQuestionid(answerVO);
}
return update;
}
public String getQuestionType(String tablename){
String questionType = "";
if("multi_question".equals(tablename)){
questionType = "1";
}else if("judge_question".equals(tablename)){
questionType = "3";
}
return questionType;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment