| | |
| | | import com.linghu.listener.QuestionExcelListener; |
| | | import com.linghu.model.common.ResponseResult; |
| | | import com.linghu.model.dto.KeywordDto; |
| | | import com.linghu.model.entity.Keyword; |
| | | import com.linghu.model.entity.Question; |
| | | import com.linghu.model.excel.KeywordExcel; |
| | | import com.linghu.model.excel.QuestionExcel; |
| | | import com.linghu.service.KeywordService; |
| | | import com.linghu.service.QuestionService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | |
| | | @Autowired |
| | | private QuestionService questionService; |
| | | @Autowired |
| | | private KeywordService keywordService; |
| | | |
| | | @PostMapping |
| | | @ApiOperation(value = "添加提问词") |
| | |
| | | public ResponseResult<List<Question>> update(@RequestBody KeywordDto keywordDto) { |
| | | //查询question的状态 |
| | | //遍历 |
| | | for (Question q : keywordDto.getQuestionList()) { |
| | | if ("success".equals(q.getStatus())) { |
| | | return ResponseResult.error("该提问词已采集"); |
| | | |
| | | if ("submitted".equals(keywordDto.getStatus()) ) { |
| | | return ResponseResult.error("该关键词在采集中"); |
| | | } |
| | | } |
| | | |
| | | questionService.updateBatchById(keywordDto.getQuestionList()); |
| | | |
| | | // if (!"notSubmitted".equals(keywordDto.getStatus() )){ |
| | |
| | | @PutMapping("/update") |
| | | @ApiOperation(value = "修改单个提问词") |
| | | public ResponseResult<Void> update(@RequestBody Question questions) { |
| | | boolean success = questionService.updateById(questions); |
| | | |
| | | LambdaQueryWrapper<Question> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Question::getQuestion_id, questions.getQuestion_id()); |
| | | Question keyword = questionService.getOne(queryWrapper); |
| | | if ("submitted".equals(keyword.getStatus()) ) { |
| | | return ResponseResult.error("该关键词在采集中"); |
| | | } |
| | | |
| | | boolean success = questionService.updateById(questions); |
| | | if (success) { |
| | | return ResponseResult.success(); |
| | | } |
| | |
| | | @Transactional |
| | | @ApiOperation(value = "批量删除提问词") |
| | | public ResponseResult<Void> batchDelete(@RequestBody List<Integer> questionIds) { |
| | | System.out.println(questionIds.toString()); |
| | | |
| | | LambdaQueryWrapper<Question> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Question::getQuestion_id, questionIds); |
| | | List<Question> questions = questionService.list(queryWrapper); |
| | | Question question = questions.get(0); |
| | | Keyword keyword = keywordService.getById(question.getKeyword_id()); |
| | | |
| | | |
| | | if ("submitted".equals(keyword.getStatus()) ) { |
| | | return ResponseResult.error("该关键词在采集中"); |
| | | } |
| | | System.out.println(questionIds.toString()); |
| | | questionService.removeByIds(questionIds); |
| | | return ResponseResult.success(); |
| | | } |