<?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.cclotus.cms.mapper.CmsPostMetaMapper">

    <resultMap id="CmsPostMeta" type="com.cclotus.cms.domain.CmsPostMeta">
        <result property="metaId" column="meta_id"/>
        <result property="postId" column="post_id"/>
        <result property="metaKey" column="meta_key"/>
        <result property="metaValue" column="meta_value"/>
    </resultMap>

    <select id="selectPostMetaList" resultType="Int">
        select post_id
        from
        (select
        post_id,
        count(post_id) as `count`
        from cms_post_meta
        where (meta_key, meta_value) in
        <foreach collection="meta" item="value" index="key" open="(" close=")" separator=",">
            (#{key},#{value})
        </foreach>
        GROUP BY post_id
        ) as stat
        where stat.`count`= #{size}
    </select>


</mapper>
