条件查询goods列表

This commit is contained in:
donqi 2022-06-08 13:58:41 +08:00
parent 8dfb3f0002
commit d819f4fb0c
3 changed files with 25 additions and 3 deletions

View File

@ -46,7 +46,7 @@ public class GoodsController extends BaseController {
// @RequiresPermissions("goods:goods:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(Goods goods) {
public TableDataInfo list(@RequestBody Goods goods) {
startPage();
List<Goods> list = goodsService.selectGoodsList(goods);
list.forEach(one->{

View File

@ -48,6 +48,9 @@ public class Goods extends BaseEntity {
@Excel(name = "状态", readConverterExp = "0=上架,1=下架,2删除")
private Integer status;
@Excel(name = "区域Id", cellType = Excel.ColumnType.NUMERIC)
private Long areaId;
private List<GoodsArea> goodsAreaList;
private Map<Integer, List<GoodsImgs>> goodsImgsMap;

View File

@ -26,6 +26,12 @@
dept_goods_category_id, goods_img_url, goods_video_url, status, create_by, create_time, remark
FROM goods
</sql>
<sql id="selectGoodsWithArea">
SELECT DISTINCT g.goods_id, goods_code, dept_id, goods_name, goods_sort, worker_id,
dept_goods_category_id, goods_img_url, goods_video_url, status, create_by, create_time, remark
FROM goods g
LEFT JOIN goods_area ga ON g.goods_id = ga.goods_id
</sql>
<update id="updateGoods" parameterType="com.ghy.goods.domain.Goods">
UPDATE goods
@ -80,7 +86,7 @@
</insert>
<select id="selectGoodsList" parameterType="com.ghy.goods.domain.Goods" resultMap="GoodsResult">
<include refid="selectGoods" />
<include refid="selectGoodsWithArea" />
<where>
<if test="goodsCode != null and goodsCode != ''">
AND goods_code like concat('%', #{goodsCode}, '%')
@ -88,7 +94,20 @@
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">
AND dept_goods_category_id = #{deptGoodsCategoryId}
</if>
<if test="areaId != null and areaId != ''">
AND country_area_id = #{areaId}
</if>
<if test="goodsName != null and goodsName != ''">
AND goods_name like concat('%', #{goodsName}, '%')
</if>
</where>
/* 默认生成时间排序 */
order by create_time
<trim suffixOverrides=",">
<if test="params.createTimeSort != null and params.createTimeSort != ''">
${params.createTimeSort}
</if>
</trim>
</select>
<select id="selectById" parameterType="long" resultMap="GoodsResult">
@ -137,4 +156,4 @@
#{ids}
</foreach>
</select>
</mapper>
</mapper>