<?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.liquidnet.service.sweet.mapper.SweetManualArtistsFiveMapper">

    <resultMap id="getManualListResult" type="com.liquidnet.service.sweet.dto.SweetManualArtistListFiveDto">
        <result column="manual_relation_id" property="manualRelationId"/>
        <result column="artists_id" property="artistId"/>
        <result column="name" property="name"/>
        <result column="pinyin" property="pinyin"/>
        <result column="describes" property="describes"/>
        <result column="pic_url" property="picUrl"/>
        <result column="stage_id" property="stageId"/>
        <result column="title" property="title"/>
        <result column="performance_start" property="performanceStart"/>
        <result column="performance_end" property="performanceEnd"/>
        <result column="signature_start" property="signatureStart"/>
        <result column="signature_end" property="signatureEnd"/>
    </resultMap>

    <resultMap id="getStageNameListResult" type="com.liquidnet.service.sweet.dto.SweetManualArtistStageListFiveDto">
        <result column="title" property="title"/>
    </resultMap>

    <select id="getManualList" parameterType="java.util.Map" resultMap="getManualListResult">
        select manual_relation_id,
        sa.`artists_id`,
        sa.`name`,
        sa.pinyin,
        sa.describes,
        sa.pic_url,
        ss.stage_id,
        ss.title,
        performance_start,
        performance_end,
        signature_start,
        signature_end
        from sweet_manual_artists_Five as sma
        left join sweet_artists as sa on sa.artists_id = sma.artists_id
        left join sweet_stage as ss on ss.stage_id = sma.stage_id
        <where>
            sma.status = 1 and manual_id = #{manualId}
        </where>
        ORDER BY sma.updated_at DESC
    </select>

    <select id="getManualDetails" parameterType="java.util.Map" resultMap="getManualListResult">
        select manual_relation_id,
               sa.`name`,
               sa.`artists_id`,
               ss.title,
               ss.stage_id,
               performance_start,
               performance_end,
               signature_start,
               signature_end
        from sweet_manual_artists_Five as sma
                 left join sweet_artists as sa on sa.artists_id = sma.artists_id
                 left join sweet_stage as ss on ss.stage_id = sma.stage_id
        where manual_relation_id = #{manualRelationId}
    </select>

    <select id="getStageNameList" parameterType="java.util.Map" resultMap="getStageNameListResult">
        select ss.title
        from sweet_manual_artists_Five as sma
                 left join sweet_artists as sa on sa.artists_id = sma.artists_id
                 left join sweet_stage as ss on ss.stage_id = sma.stage_id
        where sma.status = 1
          and manual_id = #{manualId}
        group by ss.title;

    </select>

</mapper>
