商城模块树形分类及其商品列表完成

This commit is contained in:
hupeng committed 2019-09-08 17:51:46 +08:00
1 parent 2bbbb35eac
commit 808d9c36cf
2 files changed
+23 -2

No files matched your search

@@ -6,13 +6,16 @@ import com.ruoyi.app.modular.shop.service.dto.CateDTO;
import com.ruoyi.app.modular.shop.service.dto.GoodsDTO;
import com.ruoyi.app.modular.shop.service.impl.CateServiceImpl;
import com.ruoyi.app.modular.shop.service.impl.GoodsServiceImpl;
import com.ruoyi.app.modular.shop.service.mapper.GoodsMapper;
import com.ruoyi.app.modular.shop.service.vo.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
@@ -32,8 +35,10 @@ public class MallController {
private final CateServiceImpl cateService;
private final GoodsServiceImpl goodsService;
private final UserOperator userOperator;
private final GoodsMapper goodsMapper;
@GetMapping("/shop/mall-lists")
@ApiOperation(value = "商品分类模块列表",notes = "商品分类模块列表")
public R lists(@Validated @RequestBody PageVO pageVO){
int userId = userOperator.getUser().getId();
List<CateDTO> goodsCates = cateService.getList();
@@ -42,12 +47,29 @@ public class MallController {
List<GoodsDTO> newGoods = goodsService.getList(0,pageVO.getPage(),
pageVO.getLimit(),userId,"",2);
goodsService.collectGoods(pageVO.getPage(),pageVO.getLimit(),userId);
List<GoodsDTO> collectGoods = goodsMapper.toDto(goodsService.collectGoods(pageVO.getPage(),pageVO.getLimit(),userId));
Map<String,Object> map = new HashMap<>();
map.put("goodsCates",goodsCates);
map.put("recommedGoods",recommedGoods);
map.put("newGoods",newGoods);
map.put("collectGoods",collectGoods);
return R.success(map);
}
@GetMapping("/shop/mall-goods-list")
@ApiOperation(value = "获取商品列表",notes = "获取商品列表")
public R goodsList(@RequestParam(value = "page",defaultValue = "0") int page,
@RequestParam(value = "limit",defaultValue = "10") int limit,
@RequestParam(value = "cat_id",defaultValue = "0") int catId,
@RequestParam(value = "keywords",defaultValue = "") String keywords){
int userId = userOperator.getUser().getId();
List<GoodsDTO> goods = goodsService.getList(catId,page,
limit,userId,keywords,0);
Map<String,Object> map = new HashMap<>();
map.put("list",goods);
return R.success(map);
}
}
@@ -97,7 +97,6 @@ public class GoodsServiceImpl extends ServiceImpl<StoreGoodsMapper, StoreGoods>
@Override
public List<StoreGoods> collectGoods(int page,int limit,int userId) {
System.out.println("userId"+userId);
Page<StoreGoods> pageModel = new Page<>(page, limit);
List<StoreGoods> list = baseMapper.collectGoods(pageModel,userId);
//System.out.println(list);