【mybatis】count 计数查询 + List的IN查询

mybatis中conut计数的sql怎么在mapper中写?

Mapper.java类这么写

@Mapper
public interface GoodsBindConfigMappingMapper {

    public int checkGoodsBindConfig(BindConfigBean bindConfigBean);
}

 

mapper.xml这么写

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pisen.cloud.luna.ms.goods.base.mapper.GoodsBindConfigMappingMapper">



    <select id="checkGoodsBindConfig" resultType="java.lang.Integer" parameterType="com.pisen.cloud.luna.ms.goods.api.beans.BindConfigBean">
        SELECT COUNT(*) FROM goods_bind_config_mapping
        WHERE

        good_config_flag = #{goodConfigFlag}

        AND
        good_type_uid IN
        <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
            #{item}
        </foreach>

    </select>


</mapper>

 

附录:

实体类如下:

public class BindConfigBean {

    private String goodsConfigUid;

    private Integer goodConfigFlag;// 1 话术  2 质保  3 保质期  4 扫码率  5  预约

    private List<String> goodsList;//商品分类OR商品uid list

   //get-set方法
}

 

posted @ 2018-06-05 08:59  Angel挤一挤  阅读(7707)  评论(0编辑  收藏  举报