|
|
@@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.tzld.videoVector.dao.mapper.pgVector.VideoArticleMatchResultMapper;
|
|
|
import com.tzld.videoVector.dao.mapper.pgVector.ext.VideoArticleMatchResultMapperExt;
|
|
|
+import com.tzld.videoVector.model.param.VideoArticleMatchBySourceParam;
|
|
|
import com.tzld.videoVector.model.param.VideoArticleMatchQueryParam;
|
|
|
import com.tzld.videoVector.model.po.pgVector.VideoArticleMatchResult;
|
|
|
import com.tzld.videoVector.model.po.pgVector.VideoArticleMatchResultExample;
|
|
|
@@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -69,4 +71,25 @@ public class VideoArticleMatchServiceImpl implements VideoArticleMatchService {
|
|
|
return PageResult.of(list, list.size(), 1, list.size());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<VideoArticleMatchResult> queryBySourceId(VideoArticleMatchBySourceParam param) {
|
|
|
+ // 找到包含该 sourceId 的最大 dt
|
|
|
+ String dt = videoArticleMatchResultMapperExt.selectMaxDtBySourceId(param.getAccount(), param.getSourceId());
|
|
|
+ if (!StringUtils.hasText(dt)) {
|
|
|
+ log.info("未找到 sourceId={} 的匹配记录,返回空结果", param.getSourceId());
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ log.info("sourceId={} 最大 dt={}", param.getSourceId(), dt);
|
|
|
+
|
|
|
+ VideoArticleMatchResultExample example = new VideoArticleMatchResultExample();
|
|
|
+ VideoArticleMatchResultExample.Criteria criteria = example.createCriteria();
|
|
|
+ criteria.andDtEqualTo(dt).andChannelLevel3EqualTo(param.getAccount()).andMatchedArticleIdEqualTo(param.getSourceId());
|
|
|
+ example.setOrderByClause("match_score DESC");
|
|
|
+ PageHelper.startPage(1, param.getTopN());
|
|
|
+ List<VideoArticleMatchResult> list = videoArticleMatchResultMapper.selectByExample(example);
|
|
|
+
|
|
|
+ log.info("sourceId={} dt={} 返回 {} 条记录 (topN={})", param.getSourceId(), dt, list.size(), param.getTopN());
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|