master:前端推广营销功能完善;

pull/1121/head
liujiang 2025-05-24 14:27:12 +08:00
parent 47e4d57d58
commit f9bf389b99
19 changed files with 284 additions and 45 deletions

View File

@ -4,20 +4,25 @@ import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.common.core.controller.XktBaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.Page;
import com.ruoyi.web.controller.xkt.vo.advertRound.app.category.APPCateVO;
import com.ruoyi.web.controller.xkt.vo.advertRound.app.index.APPIndexHotSaleRightFixVO;
import com.ruoyi.web.controller.xkt.vo.advertRound.app.index.APPIndexMidBrandVO;
import com.ruoyi.web.controller.xkt.vo.advertRound.app.category.APPCateVO;
import com.ruoyi.web.controller.xkt.vo.advertRound.app.own.APPOwnGuessLikeVO;
import com.ruoyi.web.controller.xkt.vo.advertRound.pc.PCDownloadVO;
import com.ruoyi.web.controller.xkt.vo.advertRound.pc.PCUserCenterVO;
import com.ruoyi.web.controller.xkt.vo.advertRound.pc.index.*;
import com.ruoyi.web.controller.xkt.vo.advertRound.pc.newArrival.*;
import com.ruoyi.web.controller.xkt.vo.advertRound.pc.newProd.*;
import com.ruoyi.web.controller.xkt.vo.advertRound.pc.store.PCStoreMidBannerVO;
import com.ruoyi.web.controller.xkt.vo.advertRound.pc.store.PCStoreTopBannerVO;
import com.ruoyi.web.controller.xkt.vo.advertRound.picSearch.PicSearchAdvertVO;
import com.ruoyi.web.controller.xkt.website.IndexSearchVO;
import com.ruoyi.xkt.dto.advertRound.app.index.*;
import com.ruoyi.xkt.dto.advertRound.app.index.APPIndexHotSaleDTO;
import com.ruoyi.xkt.dto.advertRound.app.index.APPIndexNewProdDTO;
import com.ruoyi.xkt.dto.advertRound.app.index.APPIndexPopularSaleDTO;
import com.ruoyi.xkt.dto.advertRound.app.index.APPSearchDTO;
import com.ruoyi.xkt.dto.advertRound.pc.PCSearchDTO;
import com.ruoyi.xkt.dto.advertRound.pc.index.PCIndexRecommendDTO;
import com.ruoyi.xkt.dto.advertRound.pc.newProd.PCNewRecommendDTO;
import com.ruoyi.xkt.dto.es.ESProductDTO;
import com.ruoyi.xkt.dto.website.IndexSearchDTO;
import com.ruoyi.xkt.service.IWebsiteService;
@ -54,18 +59,23 @@ public class WebsiteController extends XktBaseController {
return R.ok(websiteService.search(BeanUtil.toBean(searchVO, IndexSearchDTO.class)));
}
// PC 首页 新品馆 列表
// TODO APP 首页 热卖精选、人气爆品、新品榜 PC 首页 新品馆 列表
// TODO APP 首页 热卖精选、人气爆品、新品榜 PC 首页 新品馆 列表
@ApiOperation(value = "PC 首页 为你推荐", httpMethod = "POST", response = R.class)
@PostMapping("/pc/index/recommend")
public R<Page<PCIndexRecommendDTO>> pcIndexRecommendPage(@Validated @RequestBody IndexSearchVO searchVO) throws IOException {
return R.ok(websiteService.pcIndexRecommendPage(BeanUtil.toBean(searchVO, IndexSearchDTO.class)));
}
@ApiOperation(value = "PC 新品馆 为你推荐", httpMethod = "POST", response = R.class)
@PostMapping("/pc/new-prod/recommend")
public R<Page<PCNewRecommendDTO>> pcNewProdRecommendPage(@Validated @RequestBody IndexSearchVO searchVO) throws IOException {
return R.ok(websiteService.pcNewProdRecommendPage(BeanUtil.toBean(searchVO, IndexSearchDTO.class)));
}
@ApiOperation(value = "PC 搜索结果", httpMethod = "POST", response = R.class)
@PostMapping("/pc/search")
public R<Page<PCSearchDTO>> psSearchPage(@Validated @RequestBody IndexSearchVO searchVO) throws IOException {
return R.ok(websiteService.psSearchPage(BeanUtil.toBean(searchVO, IndexSearchDTO.class)));
}
@ApiOperation(value = "APP 首页 精选热卖列表", httpMethod = "POST", response = R.class)
@PostMapping("/app/index/hot-sale")
@ -92,8 +102,6 @@ public class WebsiteController extends XktBaseController {
}
@ApiOperation(value = "PC 首页 顶部横向轮播图", httpMethod = "GET", response = R.class)
@GetMapping("/pc/index/top/left")
public R<List<PCIndexTopLeftBannerVO>> getPcIndexTopLeftBanner() {

View File

@ -1,4 +1,4 @@
package com.ruoyi.web.controller.xkt.vo.advertRound.pc.newArrival;
package com.ruoyi.web.controller.xkt.vo.advertRound.pc.newProd;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;

View File

@ -1,4 +1,4 @@
package com.ruoyi.web.controller.xkt.vo.advertRound.pc.newArrival;
package com.ruoyi.web.controller.xkt.vo.advertRound.pc.newProd;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;

View File

@ -1,4 +1,4 @@
package com.ruoyi.web.controller.xkt.vo.advertRound.pc.newArrival;
package com.ruoyi.web.controller.xkt.vo.advertRound.pc.newProd;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;

View File

@ -1,4 +1,4 @@
package com.ruoyi.web.controller.xkt.vo.advertRound.pc.newArrival;
package com.ruoyi.web.controller.xkt.vo.advertRound.pc.newProd;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;

View File

@ -1,4 +1,4 @@
package com.ruoyi.web.controller.xkt.vo.advertRound.pc.newArrival;
package com.ruoyi.web.controller.xkt.vo.advertRound.pc.newProd;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;

View File

@ -1,4 +1,4 @@
package com.ruoyi.web.controller.xkt.vo.advertRound.pc.newArrival;
package com.ruoyi.web.controller.xkt.vo.advertRound.pc.newProd;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;

View File

@ -142,6 +142,14 @@ public class CacheConstants {
* PC
*/
public static final String PC_DOWNLOAD = "pc_download";
/**
* PC
*/
public static final String PC_INDEX_RECOMMEND = "pc_index_recommend";
/**
* PC
*/
public static final String PC_NEW_RECOMMEND = "pc_new_recommend";
/**

View File

@ -63,8 +63,10 @@ public class SysLoginService
*/
public String login(String username, String password, String code, String uuid)
{
// 验证码校验
validateCaptcha(username, code, uuid);
// validateCaptcha(username, code, uuid);
// 登录前置校验
loginPreCheck(username, password);
// 用户验证

View File

@ -0,0 +1,39 @@
package com.ruoyi.xkt.dto.advertRound.pc;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@ApiModel("PC 搜索 ")
@Data
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PCSearchDTO {
@ApiModelProperty(value = "档口ID")
private String storeId;
@ApiModelProperty(value = "档口名称")
private String storeName;
@ApiModelProperty(value = "档口商品ID")
private String storeProdId;
@ApiModelProperty(value = "货号")
private String prodArtNum;
@ApiModelProperty(value = "主图")
private String mainPic;
@ApiModelProperty(value = "单价")
private String prodPrice;
@ApiModelProperty(value = "是否广告")
private Boolean advert;
@ApiModelProperty(value = "标签")
private List<String> tags;
}

View File

@ -1,4 +1,4 @@
package com.ruoyi.xkt.dto.advertRound.pc.newArrival;
package com.ruoyi.xkt.dto.advertRound.pc.newProd;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;

View File

@ -1,4 +1,4 @@
package com.ruoyi.xkt.dto.advertRound.pc.newArrival;
package com.ruoyi.xkt.dto.advertRound.pc.newProd;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;

View File

@ -1,4 +1,4 @@
package com.ruoyi.xkt.dto.advertRound.pc.newArrival;
package com.ruoyi.xkt.dto.advertRound.pc.newProd;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;

View File

@ -1,4 +1,4 @@
package com.ruoyi.xkt.dto.advertRound.pc.newArrival;
package com.ruoyi.xkt.dto.advertRound.pc.newProd;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;

View File

@ -0,0 +1,39 @@
package com.ruoyi.xkt.dto.advertRound.pc.newProd;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@ApiModel("PC 新品馆 为你推荐")
@Data
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PCNewRecommendDTO {
@ApiModelProperty(value = "档口ID")
private String storeId;
@ApiModelProperty(value = "档口名称")
private String storeName;
@ApiModelProperty(value = "档口商品ID")
private String storeProdId;
@ApiModelProperty(value = "货号")
private String prodArtNum;
@ApiModelProperty(value = "主图")
private String mainPic;
@ApiModelProperty(value = "单价")
private String prodPrice;
@ApiModelProperty(value = "是否广告")
private Boolean advert;
@ApiModelProperty(value = "标签")
private List<String> tags;
}

View File

@ -1,4 +1,4 @@
package com.ruoyi.xkt.dto.advertRound.pc.newArrival;
package com.ruoyi.xkt.dto.advertRound.pc.newProd;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;

View File

@ -1,4 +1,4 @@
package com.ruoyi.xkt.dto.advertRound.pc.newArrival;
package com.ruoyi.xkt.dto.advertRound.pc.newProd;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;

View File

@ -5,9 +5,10 @@ import com.ruoyi.xkt.dto.advertRound.app.category.APPCateDTO;
import com.ruoyi.xkt.dto.advertRound.app.index.*;
import com.ruoyi.xkt.dto.advertRound.app.own.APPOwnGuessLikeDTO;
import com.ruoyi.xkt.dto.advertRound.pc.PCDownloadDTO;
import com.ruoyi.xkt.dto.advertRound.pc.PCSearchDTO;
import com.ruoyi.xkt.dto.advertRound.pc.PCUserCenterDTO;
import com.ruoyi.xkt.dto.advertRound.pc.index.*;
import com.ruoyi.xkt.dto.advertRound.pc.newArrival.*;
import com.ruoyi.xkt.dto.advertRound.pc.newProd.*;
import com.ruoyi.xkt.dto.advertRound.pc.store.PCStoreMidBannerDTO;
import com.ruoyi.xkt.dto.advertRound.pc.store.PCStoreTopBannerDTO;
import com.ruoyi.xkt.dto.advertRound.picSearch.PicSearchAdvertDTO;
@ -238,6 +239,22 @@ public interface IWebsiteService {
* @param searchDTO
* @return List<PCIndexRecommendProdDTO>
*/
Page<PCIndexRecommendDTO> pcIndexRecommendPage(IndexSearchDTO searchDTO);
Page<PCIndexRecommendDTO> pcIndexRecommendPage(IndexSearchDTO searchDTO) throws IOException;
/**
* PC
*
* @param searchDTO
* @return Page<PCNewRecommendDTO>
*/
Page<PCNewRecommendDTO> pcNewProdRecommendPage(IndexSearchDTO searchDTO) throws IOException;
/**
* PC
*
* @param searchDTO
* @return Page<PCSearchDTO>
*/
Page<PCSearchDTO> psSearchPage(IndexSearchDTO searchDTO) throws IOException;
}

View File

@ -18,9 +18,10 @@ import com.ruoyi.xkt.dto.advertRound.app.category.APPCateDTO;
import com.ruoyi.xkt.dto.advertRound.app.index.*;
import com.ruoyi.xkt.dto.advertRound.app.own.APPOwnGuessLikeDTO;
import com.ruoyi.xkt.dto.advertRound.pc.PCDownloadDTO;
import com.ruoyi.xkt.dto.advertRound.pc.PCSearchDTO;
import com.ruoyi.xkt.dto.advertRound.pc.PCUserCenterDTO;
import com.ruoyi.xkt.dto.advertRound.pc.index.*;
import com.ruoyi.xkt.dto.advertRound.pc.newArrival.*;
import com.ruoyi.xkt.dto.advertRound.pc.newProd.*;
import com.ruoyi.xkt.dto.advertRound.pc.store.PCStoreMidBannerDTO;
import com.ruoyi.xkt.dto.advertRound.pc.store.PCStoreTopBannerDTO;
import com.ruoyi.xkt.dto.advertRound.picSearch.PicSearchAdvertDTO;
@ -285,32 +286,134 @@ public class WebsiteServiceImpl implements IWebsiteService {
*/
@Override
@Transactional(readOnly = true)
public Page<PCIndexRecommendDTO> pcIndexRecommendPage(IndexSearchDTO searchDTO) {
return null;
public Page<PCIndexRecommendDTO> pcIndexRecommendPage(IndexSearchDTO searchDTO) throws IOException {
Page<ESProductDTO> page = this.search(searchDTO);
// 筛选出真实的数据
List<PCIndexRecommendDTO> realDataList = page.getList().stream()
.map(esProduct -> BeanUtil.toBean(esProduct, PCIndexRecommendDTO.class).setAdvert(Boolean.FALSE)).collect(Collectors.toList());
// APP 只有第一页 有数据 其它页暂时没有广告
if (searchDTO.getPageNum() > 1) {
return new Page<>(page.getPageNum(), page.getPageSize(), page.getPages(), page.getTotal(), realDataList);
}
// 从redis中获取数据
List<PCIndexRecommendDTO> redisList = this.redisCache.getCacheObject(CacheConstants.PC_ADVERT + CacheConstants.PC_INDEX_RECOMMEND);
if (CollectionUtils.isNotEmpty(redisList)) {
// 推广数据排在最前面,其次才是真实的数据
CollectionUtils.addAll(redisList, realDataList);
// 添加广告的数据PC的规则是将所有的广告数据全部放到最前面展示不用给广告打标
return new Page<>(page.getPageNum(), page.getPageSize(), page.getPages(), page.getTotal(), redisList);
} else {
// 从数据库查首页 推荐商品 推广(精准搜索是否存在推广,不存在从已过期的数据中拉数据来凑数)
List<AdvertRound> advertRoundList = this.advertRoundMapper.selectList(new LambdaQueryWrapper<AdvertRound>()
.isNotNull(AdvertRound::getStoreId).eq(AdvertRound::getDelFlag, Constants.UNDELETED)
.eq(AdvertRound::getTypeId, AdType.PC_HOME_PRODUCT_LIST.getValue())
.eq(AdvertRound::getLaunchStatus, AdLaunchStatus.LAUNCHING.getValue()));
if (CollectionUtils.isNotEmpty(advertRoundList)) {
List<StoreProdPriceAndMainPicAndTagDTO> attrList = storeProdMapper.selectPriceAndMainPicAndTagList(advertRoundList.stream()
.map(x -> x.getProdIdStr().split(",")).flatMap(Arrays::stream).map(Long::valueOf).collect(Collectors.toList()));
attrList = attrList.stream().peek(x -> x.setTags(StringUtils.isNotBlank(x.getTagStr()) ? Arrays.asList(x.getTagStr().split(",")) : null)).collect(Collectors.toList());
Map<Long, StoreProdPriceAndMainPicAndTagDTO> attrMap = attrList.stream().collect(Collectors.toMap(StoreProdPriceAndMainPicAndTagDTO::getStoreProdId, x -> x));
List<PCIndexRecommendDTO> indexRecommendList = new ArrayList<>();
advertRoundList.stream().forEach(x -> {
// 这里是一个档口上传多个档口商品所以需要对prodIdStr的逗号进行分割
List<Long> prodIdList = Arrays.asList(x.getProdIdStr().split(",")).stream().map(Long::parseLong).collect(Collectors.toList());
prodIdList.forEach(storeProdId -> {
StoreProdPriceAndMainPicAndTagDTO attrDto = attrMap.get(storeProdId);
indexRecommendList.add(new PCIndexRecommendDTO().setAdvert(Boolean.TRUE).setStoreId(x.getStoreId().toString())
.setStoreProdId(storeProdId.toString()).setTags(ObjectUtils.isNotEmpty(attrDto) ? attrDto.getTags() : null)
.setStoreName(ObjectUtils.isNotEmpty(attrDto) ? attrDto.getStoreName() : "")
.setProdPrice(ObjectUtils.isNotEmpty(attrDto) ? attrDto.getMinPrice().toString() : null)
.setProdArtNum(ObjectUtils.isNotEmpty(attrDto) ? attrDto.getProdArtNum() : "")
.setMainPic(ObjectUtils.isNotEmpty(attrDto) ? attrDto.getMainPicUrl() : ""));
});
});
// 将indexRecommendList 顺序打乱,不然一个档口的数据在同一地方展示
Collections.shuffle(indexRecommendList);
// 放到redis中 有效期1天
this.redisCache.setCacheObject(CacheConstants.PC_ADVERT + CacheConstants.PC_INDEX_RECOMMEND, indexRecommendList, 1, TimeUnit.DAYS);
CollectionUtils.addAll(indexRecommendList, realDataList);
// 添加了广告的数据
return new Page<>(page.getPageNum(), page.getPageSize(), page.getPages(), page.getTotal(), indexRecommendList);
}
}
return new Page<>(page.getPageNum(), page.getPageSize(), page.getPages(), page.getTotal(), realDataList);
}
/**
* 广
* PC
*
* @param dataList
* @param adverts 广
* @param positions 广
* @param <T>
* @return
* @param searchDTO
* @return Page<PCNewRecommendDTO>
*/
public static <T> List<T> insertAdvertsIntoList(List<T> dataList, List<T> adverts, Set<Integer> positions) {
List<T> mergedList = new ArrayList<>();
int dataIndex = 0;
int advertIndex = 0;
for (int i = 0; i < dataList.size() + positions.size(); i++) {
if (positions.contains(i) && advertIndex < adverts.size()) {
mergedList.add(adverts.get(advertIndex++));
} else if (dataIndex < dataList.size()) {
mergedList.add(dataList.get(dataIndex++));
@Override
public Page<PCNewRecommendDTO> pcNewProdRecommendPage(IndexSearchDTO searchDTO) throws IOException {
Page<ESProductDTO> page = this.search(searchDTO);
// 筛选出真实的数据
List<PCNewRecommendDTO> realDataList = page.getList().stream()
.map(esProduct -> BeanUtil.toBean(esProduct, PCNewRecommendDTO.class).setAdvert(Boolean.FALSE)).collect(Collectors.toList());
// APP 只有第一页 有数据 其它页暂时没有广告
if (searchDTO.getPageNum() > 1) {
return new Page<>(page.getPageNum(), page.getPageSize(), page.getPages(), page.getTotal(), realDataList);
}
// 从redis中获取数据
List<PCNewRecommendDTO> redisList = this.redisCache.getCacheObject(CacheConstants.PC_ADVERT + CacheConstants.PC_NEW_RECOMMEND);
if (CollectionUtils.isNotEmpty(redisList)) {
// 推广数据排在最前面,其次才是真实的数据
CollectionUtils.addAll(redisList, realDataList);
// 添加广告的数据PC的规则是将所有的广告数据全部放到最前面展示不用给广告打标
return new Page<>(page.getPageNum(), page.getPageSize(), page.getPages(), page.getTotal(), redisList);
} else {
// 从数据库查新品馆 推荐商品 推广(精准搜索是否存在推广,不存在从已过期的数据中拉数据来凑数)
List<AdvertRound> advertRoundList = this.advertRoundMapper.selectList(new LambdaQueryWrapper<AdvertRound>()
.isNotNull(AdvertRound::getStoreId).eq(AdvertRound::getDelFlag, Constants.UNDELETED)
.eq(AdvertRound::getTypeId, AdType.PC_NEW_PROD_PRODUCT_LIST.getValue())
.eq(AdvertRound::getLaunchStatus, AdLaunchStatus.LAUNCHING.getValue()));
if (CollectionUtils.isNotEmpty(advertRoundList)) {
List<StoreProdPriceAndMainPicAndTagDTO> attrList = storeProdMapper.selectPriceAndMainPicAndTagList(advertRoundList.stream()
.map(x -> x.getProdIdStr().split(",")).flatMap(Arrays::stream).map(Long::valueOf).collect(Collectors.toList()));
attrList = attrList.stream().peek(x -> x.setTags(StringUtils.isNotBlank(x.getTagStr()) ? Arrays.asList(x.getTagStr().split(",")) : null)).collect(Collectors.toList());
Map<Long, StoreProdPriceAndMainPicAndTagDTO> attrMap = attrList.stream().collect(Collectors.toMap(StoreProdPriceAndMainPicAndTagDTO::getStoreProdId, x -> x));
List<PCNewRecommendDTO> newRecommendList = new ArrayList<>();
advertRoundList.stream().forEach(x -> {
// 这里是一个档口上传多个档口商品所以需要对prodIdStr的逗号进行分割
List<Long> prodIdList = Arrays.asList(x.getProdIdStr().split(",")).stream().map(Long::parseLong).collect(Collectors.toList());
prodIdList.forEach(storeProdId -> {
StoreProdPriceAndMainPicAndTagDTO attrDto = attrMap.get(storeProdId);
newRecommendList.add(new PCNewRecommendDTO().setAdvert(Boolean.TRUE).setStoreId(x.getStoreId().toString())
.setStoreProdId(storeProdId.toString()).setTags(ObjectUtils.isNotEmpty(attrDto) ? attrDto.getTags() : null)
.setStoreName(ObjectUtils.isNotEmpty(attrDto) ? attrDto.getStoreName() : "")
.setProdPrice(ObjectUtils.isNotEmpty(attrDto) ? attrDto.getMinPrice().toString() : null)
.setProdArtNum(ObjectUtils.isNotEmpty(attrDto) ? attrDto.getProdArtNum() : "")
.setMainPic(ObjectUtils.isNotEmpty(attrDto) ? attrDto.getMainPicUrl() : ""));
});
});
// newRecommendList 顺序打乱,不然一个档口的数据在同一地方展示
Collections.shuffle(newRecommendList);
// 放到redis中 有效期1天
this.redisCache.setCacheObject(CacheConstants.PC_ADVERT + CacheConstants.PC_NEW_RECOMMEND, newRecommendList, 1, TimeUnit.DAYS);
CollectionUtils.addAll(newRecommendList, realDataList);
// 添加了广告的数据
return new Page<>(page.getPageNum(), page.getPageSize(), page.getPages(), page.getTotal(), newRecommendList);
}
}
return mergedList;
return new Page<>(page.getPageNum(), page.getPageSize(), page.getPages(), page.getTotal(), realDataList);
}
/**
* PC
*
* @param searchDTO
* @return Page<PCSearchDTO>
*/
@Override
@Transactional(readOnly = true)
public Page<PCSearchDTO> psSearchPage(IndexSearchDTO searchDTO) throws IOException {
Page<ESProductDTO> page = this.search(searchDTO);
// 筛选出真实的数据
List<PCSearchDTO> realDataList = page.getList().stream()
.map(esProduct -> BeanUtil.toBean(esProduct, PCSearchDTO.class).setAdvert(Boolean.FALSE)).collect(Collectors.toList());
// 暂时没有广告
return new Page<>(page.getPageNum(), page.getPageSize(), page.getPages(), page.getTotal(), realDataList);
}
@ -1883,6 +1986,29 @@ public class WebsiteServiceImpl implements IWebsiteService {
return firstChar - 'A' + 1;
}
/**
* 广
*
* @param dataList
* @param adverts 广
* @param positions 广
* @param <T>
* @return
*/
public static <T> List<T> insertAdvertsIntoList(List<T> dataList, List<T> adverts, Set<Integer> positions) {
List<T> mergedList = new ArrayList<>();
int dataIndex = 0;
int advertIndex = 0;
for (int i = 0; i < dataList.size() + positions.size(); i++) {
if (positions.contains(i) && advertIndex < adverts.size()) {
mergedList.add(adverts.get(advertIndex++));
} else if (dataIndex < dataList.size()) {
mergedList.add(dataList.get(dataIndex++));
}
}
return mergedList;
}
private static FieldValue newFieldValue(String value) {
return FieldValue.of(value);
}