微信小程序主页完成
This commit is contained in:
@@ -28,11 +28,6 @@
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.atguigu</groupId>-->
|
||||
<!-- <artifactId>service-product-api</artifactId>-->
|
||||
<!-- <version>1.0-SNAPSHOT</version>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.atguigu.ssyx.search.controller;
|
||||
|
||||
import com.atguigu.ssyx.common.result.Result;
|
||||
import com.atguigu.ssyx.model.search.SkuEs;
|
||||
import com.atguigu.ssyx.search.service.SkuService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -9,6 +10,8 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ClassName: SkuApiController
|
||||
* Package: com.atguigu.ssyx.search.controller
|
||||
@@ -36,4 +39,10 @@ public class SkuApiController {
|
||||
skuService.lowerSku(skuId);
|
||||
return Result.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取爆品商品")
|
||||
@GetMapping("inner/findHotSkuList")
|
||||
public List<SkuEs> findHotSkuList() {
|
||||
return skuService.findHotSkuList();
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,14 @@
|
||||
package com.atguigu.ssyx.search.repository;
|
||||
|
||||
|
||||
import com.atguigu.ssyx.model.search.SkuEs;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||
|
||||
import java.net.ContentHandler;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ClassName: SkuRepository
|
||||
* Package: com.atguigu.ssyx.search.repository
|
||||
@@ -11,4 +17,7 @@ import org.springframework.data.elasticsearch.repository.ElasticsearchRepository
|
||||
* @Create 2023/9/16 17:24
|
||||
*/
|
||||
public interface SkuRepository extends ElasticsearchRepository<SkuEs, Long> {
|
||||
//获取爆款商品
|
||||
Page<SkuEs> findByOrderByHotScoreDesc(Pageable pageable);
|
||||
|
||||
}
|
||||
|
@@ -1,7 +1,10 @@
|
||||
package com.atguigu.ssyx.search.service;
|
||||
|
||||
import com.atguigu.ssyx.model.search.SkuEs;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ClassName: SkuService
|
||||
* Package: com.atguigu.ssyx.search.service
|
||||
@@ -26,4 +29,11 @@ public interface SkuService {
|
||||
*/
|
||||
|
||||
void lowerSku(Long skuId);
|
||||
|
||||
/**
|
||||
* 获取爆品商品
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<SkuEs> findHotSkuList();
|
||||
}
|
||||
|
@@ -10,8 +10,12 @@ import com.atguigu.ssyx.search.repository.SkuRepository;
|
||||
import com.atguigu.ssyx.search.service.SkuService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -29,7 +33,7 @@ public class SkuServiceImpl implements SkuService {
|
||||
private ProductFeignClient productFeignClient;
|
||||
|
||||
@Autowired
|
||||
private SkuRepository skuEsRepository;
|
||||
private SkuRepository skuRepository;
|
||||
|
||||
/**
|
||||
* 上架商品列表
|
||||
@@ -60,9 +64,8 @@ public class SkuServiceImpl implements SkuService {
|
||||
|
||||
if (Objects.equals(skuInfo.getSkuType(), SkuType.COMMON.getCode())) {
|
||||
skuEs.setSkuType(0);
|
||||
skuEs.setPrice(skuInfo
|
||||
.getPrice()
|
||||
.doubleValue());
|
||||
skuEs.setPrice(skuInfo.getPrice()
|
||||
.doubleValue());
|
||||
skuEs.setStock(skuInfo.getStock());
|
||||
skuEs.setSale(skuInfo.getSale());
|
||||
skuEs.setPerLimit(skuInfo.getPerLimit());
|
||||
@@ -70,18 +73,26 @@ public class SkuServiceImpl implements SkuService {
|
||||
//TODO 待完善-秒杀商品
|
||||
|
||||
}
|
||||
SkuEs save = skuEsRepository.save(skuEs);
|
||||
SkuEs save = skuRepository.save(skuEs);
|
||||
log.info("upperSku:" + JSON.toJSONString(save));
|
||||
}
|
||||
|
||||
/**
|
||||
* a下架商品列表
|
||||
* 下架商品列表
|
||||
*
|
||||
* @param skuId
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void lowerSku(Long skuId) {
|
||||
skuEsRepository.deleteById(skuId);
|
||||
skuRepository.deleteById(skuId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SkuEs> findHotSkuList() {
|
||||
Pageable pageable = PageRequest.of(0, 10);
|
||||
Page<SkuEs> page = skuRepository.findByOrderByHotScoreDesc(pageable);
|
||||
List<SkuEs> skuEsList = page.getContent();
|
||||
return skuEsList;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user