| | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.linghu.config.FinalStatus; |
| | | import com.linghu.listener.QuestionExcelListener; |
| | | import com.linghu.mapper.KeywordMapper; |
| | | import com.linghu.mapper.ReferenceMapper; |
| | |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | |
| | | Question question = new Question(); |
| | | question.setKeyword_id(keywordDto.getKeyword_id()); |
| | | question.setQuestion(q.trim()); |
| | | question.setStatus("pending"); |
| | | question.setStatus(FinalStatus.PENDING.getValue()); |
| | | |
| | | return question; |
| | | }).collect(Collectors.toList()); |
| | |
| | | LambdaQueryWrapper<Question> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Question::getQuestion_id, questions.getQuestion_id()); |
| | | Question keyword = this.getOne(queryWrapper); |
| | | if ("submitted".equals(keyword.getStatus()) ) { |
| | | if (FinalStatus.SUBMITTED.getValue().equals(keyword.getStatus()) ) { |
| | | return ResponseResult.error("该关键词在采集中"); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public ResponseResult<Void> batchDeleteQuestion(List<Integer> questionIds) { |
| | | // 新增判断:如果集合为空,直接返回错误 |
| | | if (CollectionUtils.isEmpty(questionIds)) { |
| | | return ResponseResult.error("删除失败,至少选择一个提问词"); |
| | | } |
| | | // 2. 批量查询所有提问词 |
| | | List<Question> questions = this.listByIds(questionIds); |
| | | // 3. 校验所有提问词关联的关键词是否处于采集中 |
| | |
| | | return ResponseResult.error("提问词关联的关键词不存在,ID:" + question.getKeyword_id()); |
| | | } |
| | | // 核心校验:若有任何关键词在采集中,禁止删除 |
| | | if ("submitted".equals(keyword.getStatus())) { |
| | | if (FinalStatus.PENDING.getValue().equals(keyword.getStatus())) { |
| | | return ResponseResult.error("该关键词在采集中,无法删除"); |
| | | } |
| | | } |
| | |
| | | |
| | | @Override |
| | | public ResponseResult<List<Question>> updateQuestion(KeywordDto keywordDto) { |
| | | if ("submitted".equals(keywordDto.getStatus()) ) { |
| | | if (FinalStatus.SUBMITTED.getValue().equals(keywordDto.getStatus()) ) { |
| | | return ResponseResult.error("该关键词在采集中"); |
| | | } |
| | | this.updateBatchById(keywordDto.getQuestionList()); |