| | |
| | | package com.linghu.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.linghu.model.common.ResponseResult; |
| | | import com.linghu.model.entity.Keyword; |
| | | import com.linghu.model.vo.*; |
| | | import com.linghu.model.vo.KeywordStaticsListVO; |
| | | import com.linghu.service.KeywordService; |
| | | import com.linghu.mapper.KeywordMapper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author xy |
| | |
| | | * @createDate 2025-07-04 20:17:33 |
| | | */ |
| | | @Service |
| | | public class KeywordServiceImpl extends ServiceImpl<KeywordMapper, Keyword> |
| | | implements KeywordService{ |
| | | public class KeywordServiceImpl extends ServiceImpl<KeywordMapper, Keyword> implements KeywordService{ |
| | | |
| | | @Override |
| | | public ResponseResult<KeywordStaticsListVO> statics(Integer keywordId, Integer questionId) { |
| | | KeywordStaticsListVO vo = new KeywordStaticsListVO(); |
| | | //1.关键词是否存在 |
| | | Keyword keyword = this.getById(keywordId); |
| | | if (keyword == null) { |
| | | return ResponseResult.error("关键词不存在"); |
| | | } |
| | | if (!"completed".equals(keyword.getStatus())){ |
| | | return ResponseResult.error("关键词采集未完成"); |
| | | } |
| | | List<KeywordStaticsVO> statics = this.getBaseMapper().statics(keywordId,questionId,keyword.getNum()); |
| | | vo.setNowRecord(statics); |
| | | if (keyword.getNum()!=0){ |
| | | statics = this.getBaseMapper().statics(keywordId,questionId,keyword.getNum()-1); |
| | | vo.setBeforeRecord(statics); |
| | | } |
| | | return ResponseResult.success(vo); |
| | | } |
| | | |
| | | @Override |
| | | public ResponseResult<List<PlatformProportionVO>> getResultByTypeId(Integer keywordId, Integer questionId, Integer typeId) { |
| | | //1.关键词是否存在 |
| | | Keyword keyword = this.getById(keywordId); |
| | | if (keyword == null) { |
| | | return ResponseResult.error("关键词不存在"); |
| | | } |
| | | if (!"completed".equals(keyword.getStatus())){ |
| | | return ResponseResult.error("关键词采集未完成"); |
| | | } |
| | | List<PlatformProportionVO> result = this.getBaseMapper().getResultByTypeId(keywordId, questionId, keyword.getNum(), typeId); |
| | | return ResponseResult.success(result); |
| | | } |
| | | |
| | | @Override |
| | | public ResponseResult<List<ResultListVO>> getResultByPlatformId(Integer keywordId, Integer questionId, Integer platformId) { |
| | | //1.关键词是否存在 |
| | | Keyword keyword = this.getById(keywordId); |
| | | if (keyword == null) { |
| | | return ResponseResult.error("关键词不存在"); |
| | | } |
| | | if (!"completed".equals(keyword.getStatus())){ |
| | | return ResponseResult.error("关键词采集未完成"); |
| | | } |
| | | |
| | | List<ResultListVO> result = this.getBaseMapper().getResultByPlatformId(keywordId, questionId, keyword.getNum(), platformId); |
| | | return ResponseResult.success(result); |
| | | } |
| | | |
| | | |
| | | } |
| | | |