新增商城端-热门商品接口
This commit is contained in:
parent
87d81b0547
commit
d0626c36b5
|
|
@ -17,10 +17,7 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
|
@ -64,6 +61,32 @@ public class GoodsController extends BaseController {
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/hot/list")
|
||||||
|
@ResponseBody
|
||||||
|
public TableDataInfo hotList(Goods goods) {
|
||||||
|
DeptGoodsCategory deptGoodsCategory = new DeptGoodsCategory();
|
||||||
|
deptGoodsCategory.setDeptId(goods.getDeptId());
|
||||||
|
deptGoodsCategory.setIsHot(1);
|
||||||
|
deptGoodsCategory.setLevel(2);
|
||||||
|
List<DeptGoodsCategory> categoryList = deptGoodsCategoryService.list(deptGoodsCategory);
|
||||||
|
Collection<Long> ids = new ArrayList<>();
|
||||||
|
categoryList.forEach(category->{
|
||||||
|
ids.add(category.getGoodsCategoryId());
|
||||||
|
});
|
||||||
|
|
||||||
|
startPage();
|
||||||
|
List<Goods> list = goodsService.selectByCategoryIds(ids);
|
||||||
|
list.forEach(one->{
|
||||||
|
// 补全商品
|
||||||
|
List<GoodsArea> goodsAreas = goodsAreaService.selectByGoodsId(one.getGoodsId());
|
||||||
|
one.setGoodsAreaList(goodsAreas);
|
||||||
|
|
||||||
|
// 补全商品类别
|
||||||
|
List<GoodsStandard> goodsStandards = goodsStandardService.selectByGoodsId(one.getGoodsId());
|
||||||
|
one.setGoodsStandardList(goodsStandards);
|
||||||
|
});
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/addGoods")
|
@PostMapping("/addGoods")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
|
|
||||||
|
|
@ -88,4 +88,12 @@ public interface GoodsMapper {
|
||||||
* @param ids 商品ID
|
* @param ids 商品ID
|
||||||
*/
|
*/
|
||||||
List<Goods> selectByIds(Collection<Long> ids);
|
List<Goods> selectByIds(Collection<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用类目ID批量查询
|
||||||
|
*
|
||||||
|
* @param ids 第三级类目ID
|
||||||
|
*/
|
||||||
|
List<Goods> selectByCategoryIds(Collection<Long> ids);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,4 +85,12 @@ public interface GoodsService {
|
||||||
* @param ids 商品ID
|
* @param ids 商品ID
|
||||||
*/
|
*/
|
||||||
List<Goods> selectByIds(Collection<Long> ids);
|
List<Goods> selectByIds(Collection<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用第三级类目ID批量查询
|
||||||
|
*
|
||||||
|
* @param ids 类目ID
|
||||||
|
*/
|
||||||
|
List<Goods> selectByCategoryIds(Collection<Long> ids);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,11 @@ public class GoodsServiceImpl implements GoodsService {
|
||||||
return goodsMapper.selectByIds(ids);
|
return goodsMapper.selectByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Goods> selectByCategoryIds(Collection<Long> ids) {
|
||||||
|
return goodsMapper.selectByCategoryIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public int countUserGoodsById(Goods goods) {
|
public int countUserGoodsById(Goods goods) {
|
||||||
//TODO 校验商品是否上架
|
//TODO 校验商品是否上架
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,12 @@
|
||||||
<if test="status != null and status != ''">
|
<if test="status != null and status != ''">
|
||||||
AND gc.status = #{status}
|
AND gc.status = #{status}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="level != null">
|
||||||
|
AND gc.level = #{level}
|
||||||
|
</if>
|
||||||
|
<if test="isHot != null">
|
||||||
|
AND dgc.is_hot = #{isHot}
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,9 @@
|
||||||
<if test="goodsCode != null and goodsCode != ''">
|
<if test="goodsCode != null and goodsCode != ''">
|
||||||
AND goods_code like concat('%', #{goodsCode}, '%')
|
AND goods_code like concat('%', #{goodsCode}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">
|
||||||
|
AND dept_goods_category_id = #{deptGoodsCategoryId}
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
@ -126,4 +129,12 @@
|
||||||
#{ids}
|
#{ids}
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByCategoryIds" resultMap="GoodsResult">
|
||||||
|
<include refid="selectGoods"/>
|
||||||
|
where dept_goods_category_id IN
|
||||||
|
<foreach collection="collection" item="ids" open="(" separator="," close=")">
|
||||||
|
#{ids}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue