<?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.ym.mec.biz.dal.dao.PlatformServeDetailDao">
    <resultMap id="BaseResultMap" type="com.ym.mec.biz.dal.entity.PlatformServeDetail">
        <id column="id_" jdbcType="INTEGER" property="id" />
        <result column="serve_id_" jdbcType="INTEGER" property="serveId" />
        <result column="mode_" jdbcType="VARCHAR" property="mode" />
        <result column="student_up_limit_" jdbcType="INTEGER" property="studentUpLimit" />
        <result column="original_price_" jdbcType="DECIMAL" property="originalPrice" />
    </resultMap>
    <sql id="Base_Column_List">
        id_, serve_id_, mode_, student_up_limit_, original_price_
    </sql>

    <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.PlatformServeDetail"
            useGeneratedKeys="true">
        insert into platform_serve_detail (serve_id_, mode_, student_up_limit_,
                                           original_price_)
        values (#{serveId,jdbcType=VARCHAR}, #{mode,jdbcType=VARCHAR}, #{studentUpLimit,jdbcType=INTEGER},
                #{originalPrice,jdbcType=DECIMAL})
    </insert>

    <delete id="deleteByServeId" parameterType="integer">
        delete
        from platform_serve_detail
        where serve_id_ = #{serveId,jdbcType=INTEGER}
    </delete>

    <resultMap id="PlatformServeModeVoResult" type="com.ym.mec.biz.dal.vo.PlatformServeModeVo">
        <result column="mode_" jdbcType="VARCHAR" property="mode"/>
        <collection property="list" ofType="com.ym.mec.biz.dal.vo.PlatformServeModeVo$PlatformServeModeDetailVo">
            <result column="id_" jdbcType="INTEGER" property="id"/>
            <result column="student_up_limit_" jdbcType="INTEGER" property="studentUpLimit"/>
            <result column="original_price_" jdbcType="DECIMAL" property="originalPrice"/>
        </collection>
    </resultMap>

    <select id="queryDetailById" parameterType="integer" resultMap="PlatformServeModeVoResult">
        select
        <include refid="Base_Column_List"/>
        from platform_serve_detail
        where serve_id_ = #{serveId,jdbcType=INTEGER}
    </select>

</mapper>