<?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.qs.mp.admin.mapper.CdKeyMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.qs.mp.admin.domain.CdKey">
        <id column="key_id" property="keyId" />
        <result column="group_id" property="groupId" />
        <result column="ref_id" property="refId" />
        <result column="type" property="type" />
        <result column="pic_url" property="picUrl" />
        <result column="status" property="status" />
        <result column="cd_key" property="cdKey" />
        <result column="create_time" property="createTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        key_id, group_id, ref_id, type, pic_url, status, cd_key, create_time
    </sql>
    <select id="listCdKeyVO" resultType="com.qs.mp.admin.domain.vo.CdKeyGroupListVO">
        select t2.site_name,t3.title,t1.cd_key,t3.pic_url
        from mp_cd_key t1
        left join mp_cd_key_group t2 on t1.group_id = t2.group_id
        left join mp_cd_key_group_goods t3 on t1.group_id = t3.group_id
        ${ew.customSqlSegment}
    </select>
    <select id="listCdKeyExchangeVO" resultType="com.qs.mp.admin.domain.vo.CdKeyExchangeVO">
        select t1.*
        from mp_cd_key t1 left join mp_cd_key_exchange t2 on t1.key_id = t2.key_id
            ${ew.customSqlSegment}
    </select>
    <select id="listExportVO" resultType="com.qs.mp.admin.domain.vo.CdKeyVO">
        select t1.*,t2.title
        from mp_cd_key t1 left join mp_cd_key_group t2 on t1.group_id = t2.group_id
            ${ew.customSqlSegment}
    </select>


</mapper>