| | |
| | | package com.linghu.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.linghu.model.dto.KeywordDto; |
| | | import com.linghu.model.dto.OrderDto; |
| | | import com.linghu.model.entity.Keyword; |
| | | import com.linghu.model.entity.Order; |
| | | import com.linghu.model.entity.Orders; |
| | | import com.linghu.model.entity.Question; |
| | | import com.linghu.service.KeywordService; |
| | | import com.linghu.service.OrderService; |
| | | import com.linghu.mapper.OrderMapper; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import com.linghu.service.QuestionService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | * @createDate 2025-07-04 20:17:33 |
| | | */ |
| | | @Service |
| | | public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> |
| | | public class OrderServiceImpl extends ServiceImpl<OrderMapper, Orders> |
| | | implements OrderService { |
| | | |
| | | @Autowired |
| | | private KeywordService keywordService; |
| | | @Autowired |
| | | private QuestionService questionService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveOrderWithKeywords(OrderDto orderDto) { |
| | | // 保存订单 |
| | | if (!this.save(orderDto)) { |
| | | return false; |
| | | } |
| | | public boolean saveOrderWithKeywords(OrderDto orderDto, String order_id) { |
| | | |
| | | // 如果有关键词,则保存关键词 |
| | | if (StringUtils.hasText(orderDto.getKeywords())) { |
| | |
| | | for (String keywordName : keywordArray) { |
| | | if (StringUtils.hasText(keywordName)) { |
| | | Keyword keyword = new Keyword(); |
| | | keyword.setOrder_id(orderDto.getOrder_id()); |
| | | keyword.setOrder_id(order_id); |
| | | keyword.setKeyword_name(keywordName.trim()); |
| | | keyword.setStatus("notSubmitted"); |
| | | // keyword.setNum(1); // 默认采集轮数为1 |
| | | keywordService.save(keyword); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | return true; |
| | |
| | | |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public List<KeywordDto> getKeywordListByOrderId(String orderId) { |
| | | List<Keyword> keywords = keywordService.lambdaQuery() |
| | | .eq(Keyword::getOrder_id, orderId) |
| | | .list(); |
| | | |
| | | // 遍历关键词,获取每个关键词对应的提问词 |
| | | List<KeywordDto> keywordDtos = new ArrayList<>(); |
| | | for (Keyword keyword : keywords) { |
| | | KeywordDto dto = new KeywordDto(); |
| | | BeanUtils.copyProperties(keyword, dto); |
| | | |
| | | // 查询该关键词下的所有提问词 |
| | | List<Question> questions = questionService.lambdaQuery() |
| | | .eq(Question::getKeyword_id, keyword.getKeyword_id()) |
| | | .list(); |
| | | dto.setQuestionList(questions); |
| | | keywordDtos.add(dto); |
| | | } |
| | | return keywordDtos; |
| | | } |
| | | } |