| | |
| | | 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.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; |
| | |
| | | |
| | | @Autowired |
| | | private KeywordService keywordService; |
| | | @Autowired |
| | | private QuestionService questionService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveOrderWithKeywords(OrderDto orderDto,String order_id) { |
| | | |
| | | public boolean saveOrderWithKeywords(OrderDto orderDto, String order_id) { |
| | | |
| | | // 如果有关键词,则保存关键词 |
| | | if (StringUtils.hasText(orderDto.getKeywords())) { |
| | |
| | | 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; |
| | | } |
| | | } |