|
@@ -0,0 +1,41 @@
|
|
|
+package com.tzld.longarticle.recommend.server.service.recommend.filter.strategy;
|
|
|
+
|
|
|
+import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
|
|
|
+import com.tzld.longarticle.recommend.server.model.dto.Content;
|
|
|
+import com.tzld.longarticle.recommend.server.model.entity.aigc.PublishContent;
|
|
|
+import com.tzld.longarticle.recommend.server.service.recommend.filter.FilterParam;
|
|
|
+import com.tzld.longarticle.recommend.server.service.recommend.filter.FilterResult;
|
|
|
+import com.tzld.longarticle.recommend.server.service.recommend.filter.FilterStrategy;
|
|
|
+import com.tzld.longarticle.recommend.server.util.DateUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Component
|
|
|
+@Slf4j
|
|
|
+public class TodayPublishStrategy implements FilterStrategy {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AigcBaseMapper aigcBaseMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public FilterResult filter(FilterParam param) {
|
|
|
+ FilterResult filterResult = new FilterResult();
|
|
|
+ List<String> result = new ArrayList<>(param.getContents().size());
|
|
|
+ Long todayStart = DateUtils.getTodayStart();
|
|
|
+ List<PublishContent> todayPublishContentList = aigcBaseMapper.getTodayPublishContentList(param.getAccountId(), todayStart);
|
|
|
+ List<String> todayPublishContentIdList = todayPublishContentList.stream().map(PublishContent::getId).collect(Collectors.toList());
|
|
|
+ for (Content content : param.getContents()) {
|
|
|
+ if (!todayPublishContentIdList.contains(content.getId())) {
|
|
|
+ result.add(content.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ filterResult.setContentIds(result);
|
|
|
+ return filterResult;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|