修改首页接口数据
This commit is contained in:
@ -14,11 +14,15 @@ import co.yixiang.api.ApiResult;
|
|||||||
import co.yixiang.api.YshopException;
|
import co.yixiang.api.YshopException;
|
||||||
import co.yixiang.constant.ShopConstants;
|
import co.yixiang.constant.ShopConstants;
|
||||||
import co.yixiang.enums.ProductEnum;
|
import co.yixiang.enums.ProductEnum;
|
||||||
|
import co.yixiang.modules.activity.service.YxStoreCombinationService;
|
||||||
|
import co.yixiang.modules.activity.service.YxStoreSeckillService;
|
||||||
|
import co.yixiang.modules.activity.vo.YxStoreSeckillQueryVo;
|
||||||
import co.yixiang.modules.product.service.YxStoreProductService;
|
import co.yixiang.modules.product.service.YxStoreProductService;
|
||||||
import co.yixiang.modules.product.vo.YxSystemStoreQueryVo;
|
import co.yixiang.modules.product.vo.YxSystemStoreQueryVo;
|
||||||
import co.yixiang.modules.shop.param.YxSystemStoreQueryParam;
|
import co.yixiang.modules.shop.param.YxSystemStoreQueryParam;
|
||||||
import co.yixiang.modules.shop.service.YxSystemGroupDataService;
|
import co.yixiang.modules.shop.service.YxSystemGroupDataService;
|
||||||
import co.yixiang.modules.shop.service.YxSystemStoreService;
|
import co.yixiang.modules.shop.service.YxSystemStoreService;
|
||||||
|
import co.yixiang.modules.shop.vo.IndexVo;
|
||||||
import co.yixiang.utils.FileUtil;
|
import co.yixiang.utils.FileUtil;
|
||||||
import co.yixiang.utils.RedisUtil;
|
import co.yixiang.utils.RedisUtil;
|
||||||
import co.yixiang.utils.ShopKeyUtils;
|
import co.yixiang.utils.ShopKeyUtils;
|
||||||
@ -54,35 +58,26 @@ public class IndexController {
|
|||||||
private final YxSystemGroupDataService systemGroupDataService;
|
private final YxSystemGroupDataService systemGroupDataService;
|
||||||
private final YxStoreProductService storeProductService;
|
private final YxStoreProductService storeProductService;
|
||||||
private final YxSystemStoreService systemStoreService;
|
private final YxSystemStoreService systemStoreService;
|
||||||
|
private final YxStoreCombinationService storeCombinationService;
|
||||||
|
private final YxStoreSeckillService storeSeckillService;
|
||||||
|
|
||||||
@Cacheable(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY)
|
@Cacheable(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY)
|
||||||
@GetMapping("/index")
|
@GetMapping("/index")
|
||||||
@ApiOperation(value = "首页数据",notes = "首页数据")
|
@ApiOperation(value = "首页数据",notes = "首页数据")
|
||||||
public ApiResult<Map<String,Object>> index(){
|
public ApiResult<IndexVo> index(){
|
||||||
|
IndexVo indexVo = IndexVo.builder()
|
||||||
Map<String,Object> map = new LinkedHashMap<>();
|
.banner(systemGroupDataService.getDatas(ShopConstants.YSHOP_HOME_BANNER))
|
||||||
//banner
|
.bastList(storeProductService.getList(1,6, ProductEnum.TYPE_1.getValue()))
|
||||||
map.put("banner",systemGroupDataService.getDatas(ShopConstants.YSHOP_HOME_BANNER));
|
.benefit(storeProductService.getList(1,10,ProductEnum.TYPE_4.getValue()))
|
||||||
//首页按钮
|
.combinationList(storeCombinationService.getList(1,4))
|
||||||
map.put("menus",systemGroupDataService.getDatas(ShopConstants.YSHOP_HOME_MENUS));
|
.firstList(storeProductService.getList(1,6,ProductEnum.TYPE_3.getValue()))
|
||||||
|
.likeInfo(storeProductService.getList(1,3,ProductEnum.TYPE_2.getValue()))
|
||||||
|
.mapKey(RedisUtil.get(ShopKeyUtils.getTengXunMapKey()))
|
||||||
//精品推荐
|
.menus(systemGroupDataService.getDatas(ShopConstants.YSHOP_HOME_MENUS))
|
||||||
map.put("bastList",storeProductService.getList(1,6, ProductEnum.TYPE_1.getValue()));
|
.roll(systemGroupDataService.getDatas(ShopConstants.YSHOP_HOME_ROLL_NEWS))
|
||||||
//首发新品
|
.seckillList(storeSeckillService.getList(1, 4))
|
||||||
map.put("firstList",storeProductService.getList(1,6,ProductEnum.TYPE_3.getValue()));
|
.build();
|
||||||
//猜你喜欢
|
return ApiResult.ok(indexVo);
|
||||||
map.put("benefit",storeProductService.getList(1,10,ProductEnum.TYPE_4.getValue()));
|
|
||||||
//热门榜单
|
|
||||||
map.put("likeInfo",storeProductService.getList(1,3,ProductEnum.TYPE_2.getValue()));
|
|
||||||
|
|
||||||
//滚动
|
|
||||||
map.put("roll",systemGroupDataService.getDatas(ShopConstants.YSHOP_HOME_ROLL_NEWS));
|
|
||||||
|
|
||||||
map.put("mapKey",RedisUtil.get(ShopKeyUtils.getTengXunMapKey()));
|
|
||||||
|
|
||||||
return ApiResult.ok(map);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/search/keyword")
|
@GetMapping("/search/keyword")
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
package co.yixiang.modules.shop.vo;
|
||||||
|
|
||||||
|
import co.yixiang.modules.activity.vo.YxStoreCombinationQueryVo;
|
||||||
|
import co.yixiang.modules.activity.vo.YxStoreSeckillQueryVo;
|
||||||
|
import co.yixiang.modules.product.vo.YxStoreProductQueryVo;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@ApiModel("首页数据")
|
||||||
|
public class IndexVo {
|
||||||
|
|
||||||
|
@ApiModelProperty("banner")
|
||||||
|
private List<JSONObject> banner;
|
||||||
|
//首页按钮
|
||||||
|
@ApiModelProperty("首页按钮")
|
||||||
|
private List<JSONObject> menus;
|
||||||
|
//精品推荐->拼团
|
||||||
|
@ApiModelProperty("精品推荐")
|
||||||
|
private List<YxStoreProductQueryVo> bastList;
|
||||||
|
//首发新品->秒杀
|
||||||
|
@ApiModelProperty("首发新品")
|
||||||
|
private List<YxStoreProductQueryVo> firstList;
|
||||||
|
//猜你喜欢
|
||||||
|
@ApiModelProperty("猜你喜欢")
|
||||||
|
private List<YxStoreProductQueryVo> benefit;
|
||||||
|
//热门榜单
|
||||||
|
@ApiModelProperty("热门榜单")
|
||||||
|
private List<YxStoreProductQueryVo> likeInfo;
|
||||||
|
//滚动
|
||||||
|
@ApiModelProperty("滚动")
|
||||||
|
private List<JSONObject> roll;
|
||||||
|
//地图key
|
||||||
|
@ApiModelProperty("地图key")
|
||||||
|
private String mapKey;
|
||||||
|
//精品推荐->拼团
|
||||||
|
@ApiModelProperty("精品推荐->拼团")
|
||||||
|
private List<YxStoreCombinationQueryVo> combinationList;
|
||||||
|
//首发新品->秒杀
|
||||||
|
@ApiModelProperty("首发新品->秒杀")
|
||||||
|
private List<YxStoreSeckillQueryVo> seckillList;
|
||||||
|
|
||||||
|
}
|
@ -58,6 +58,13 @@ public interface YxStoreSeckillService extends BaseService<YxStoreSeckill>{
|
|||||||
*/
|
*/
|
||||||
List<YxStoreSeckillQueryVo> getList(int page, int limit, int time);
|
List<YxStoreSeckillQueryVo> getList(int page, int limit, int time);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 秒杀产品列表(首页用)
|
||||||
|
* @param page page
|
||||||
|
* @param limit limit
|
||||||
|
* @return list
|
||||||
|
*/
|
||||||
|
List<YxStoreSeckillQueryVo> getList(int page, int limit);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询数据分页
|
* 查询数据分页
|
||||||
|
@ -182,7 +182,32 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
|
|||||||
});
|
});
|
||||||
return yxStoreSeckillQueryVos;
|
return yxStoreSeckillQueryVos;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 秒杀产品列表(首页用)
|
||||||
|
* @param page page
|
||||||
|
* @param limit limit
|
||||||
|
* @return list
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<YxStoreSeckillQueryVo> getList(int page, int limit) {
|
||||||
|
Date nowTime = new Date();
|
||||||
|
Page<YxStoreSeckill> pageModel = new Page<>(page, limit);
|
||||||
|
QueryWrapper<YxStoreSeckill> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.lambda().eq(YxStoreSeckill::getStatus, ShopCommonEnum.IS_STATUS_1.getValue())
|
||||||
|
.eq(YxStoreSeckill::getIsHot,1)
|
||||||
|
.le(YxStoreSeckill::getStartTime,nowTime)
|
||||||
|
.ge(YxStoreSeckill::getStopTime,nowTime)
|
||||||
|
.orderByDesc(YxStoreSeckill::getSort);
|
||||||
|
List<YxStoreSeckillQueryVo> yxStoreSeckillQueryVos = generator.convert
|
||||||
|
(yxStoreSeckillMapper.selectPage(pageModel,wrapper).getRecords(),
|
||||||
|
YxStoreSeckillQueryVo.class);
|
||||||
|
yxStoreSeckillQueryVos.forEach(item->{
|
||||||
|
Integer sum = item.getSales() + item.getStock();
|
||||||
|
item.setPercent(NumberUtil.round(NumberUtil.mul(NumberUtil.div(item.getSales(),sum),
|
||||||
|
100),0).intValue());
|
||||||
|
});
|
||||||
|
return yxStoreSeckillQueryVos;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
//@Cacheable
|
//@Cacheable
|
||||||
public Map<String, Object> queryAll(YxStoreSeckillQueryCriteria criteria, Pageable pageable) {
|
public Map<String, Object> queryAll(YxStoreSeckillQueryCriteria criteria, Pageable pageable) {
|
||||||
|
Reference in New Issue
Block a user