<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.personalstage.dao.impl.ReplaceCodeDaoImpl">

    <resultMap  id="BaseResultMap" type="com.pcloud.book.personalstage.entity.ReplaceCode">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="replaceCode" column="replace_code" jdbcType="VARCHAR"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        id, replace_code, name
    </sql>

    <select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List"/>
        from replace_code
        where id = #{id,jdbcType=BIGINT}
    </select>

    <delete id="deleteById" parameterType="long">
        delete from replace_code
        where id = #{id,jdbcType=BIGINT}
    </delete>

    <insert id="insert" parameterType="com.pcloud.book.personalstage.entity.ReplaceCode" useGeneratedKeys="true" keyProperty="id">
        insert into replace_code
        <trim prefix="(" suffix=")" suffixOverrides=",">
            replace_code,
            name
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{replaceCode,jdbcType=VARCHAR},
            #{name,jdbcType=VARCHAR}
        </trim>
    </insert>

    <select id="getAll" resultMap="BaseResultMap">
        select <include refid="Base_Column_List"/>
        from replace_code
    </select>

</mapper>