feat(手机端): 一级分类商品列表

添加一级分类商品列表接口
master
hequan_waynaqua 4 years ago
parent ae01f50b73
commit 0e4616054f

@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.common.core.domain.shop.Goods; import com.wayn.common.core.domain.shop.Goods;
import java.util.List;
/** /**
* <p> * <p>
* Mapper * Mapper
@ -16,4 +18,6 @@ import com.wayn.common.core.domain.shop.Goods;
public interface GoodsMapper extends BaseMapper<Goods> { public interface GoodsMapper extends BaseMapper<Goods> {
IPage<Goods> selectGoodsListPage(Page<Goods> page,Goods goods); IPage<Goods> selectGoodsListPage(Page<Goods> page,Goods goods);
IPage<Goods> selectGoodsListPageByl2CateId(Page<Goods> page, List<Long> cateList);
} }

@ -7,6 +7,7 @@ import com.wayn.common.core.domain.shop.Goods;
import com.wayn.common.core.domain.vo.GoodsSaveRelatedVO; import com.wayn.common.core.domain.vo.GoodsSaveRelatedVO;
import com.wayn.common.util.R; import com.wayn.common.util.R;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -67,4 +68,12 @@ public interface IGoodsService extends IService<Goods> {
* @return R * @return R
*/ */
R updateGoodsRelated(GoodsSaveRelatedVO goodsSaveRelatedVO); R updateGoodsRelated(GoodsSaveRelatedVO goodsSaveRelatedVO);
/**
* Id
* @param page
* @param l2cateList Id
* @return r
*/
R selectListPageByCateIds(Page<Goods> page, List<Long> l2cateList);
} }

@ -174,4 +174,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
iGoodsProductService.updateBatchById(Arrays.asList(products)); iGoodsProductService.updateBatchById(Arrays.asList(products));
return R.success(); return R.success();
} }
@Override
public R selectListPageByCateIds(Page<Goods> page, List<Long> l2cateList) {
return R.success().add("data", goodsMapper.selectGoodsListPageByl2CateId(page, l2cateList).getRecords());
}
} }

@ -56,4 +56,18 @@
order by create_time desc order by create_time desc
</where> </where>
</select> </select>
<select id="selectGoodsListPageByl2CateId" resultMap="ShopGoodsResult">
<include refid="selectGoodsVo"/>
<where>
del_flag = 0
<if test="cateList != null and cateList.size() > 0" >
and category_id in
<foreach collection="cateList" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</if>
order by create_time desc
</where>
</select>
</mapper> </mapper>

@ -1,8 +1,13 @@
package com.wayn.mobile.api.controller; package com.wayn.mobile.api.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.common.base.BaseController;
import com.wayn.common.core.domain.shop.Category; import com.wayn.common.core.domain.shop.Category;
import com.wayn.common.core.domain.shop.Goods;
import com.wayn.common.core.domain.vo.VanTreeSelectVo; import com.wayn.common.core.domain.vo.VanTreeSelectVo;
import com.wayn.common.core.service.shop.ICategoryService; import com.wayn.common.core.service.shop.ICategoryService;
import com.wayn.common.core.service.shop.IGoodsService;
import com.wayn.common.util.R; import com.wayn.common.util.R;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -12,14 +17,18 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
@RestController @RestController
@RequestMapping("category") @RequestMapping("category")
public class CategoryController { public class CategoryController extends BaseController {
@Autowired @Autowired
private ICategoryService iCategoryService; private ICategoryService iCategoryService;
@Autowired
private IGoodsService iGoodsService;
@GetMapping("index") @GetMapping("index")
public R index(@RequestParam(required = false) Long id) { public R index(@RequestParam(required = false) Long id) {
R success = R.success(); R success = R.success();
@ -48,4 +57,14 @@ public class CategoryController {
success.add("subCategoryList", subCategoryList); success.add("subCategoryList", subCategoryList);
return success; return success;
} }
@GetMapping("goods")
public R listGoodsByFirstCate(@RequestParam(defaultValue = "0") Long cateId) {
Page<Goods> page = getPage();
List<Category> categoryList = iCategoryService.list(new QueryWrapper<Category>().select("id").eq("pid", cateId));
List<Long> cateList = categoryList.stream().map(Category::getId).collect(Collectors.toList());
return iGoodsService.selectListPageByCateIds(page, cateList);
}
} }

Loading…
Cancel
Save