<?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.group.dao.impl.TempletRelevanceDaoImpl">
    <resultMap id="BaseResultMap" type="com.pcloud.book.group.entity.TempletRelevance">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="templet_id" property="templetId" jdbcType="BIGINT"/>
        <result column="large_templet" property="largeTemplet" jdbcType="INTEGER"/>
    </resultMap>

    <sql id="Base_Column_List">
        id, templet_id, large_templet
    </sql>

    <insert id="insert" parameterType="com.pcloud.book.group.entity.TempletRelevance" useGeneratedKeys="true"
            keyProperty="id">
        insert into templet_relevance
        <trim prefix="(" suffix=")" suffixOverrides=",">
            templet_id,
            large_templet
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{templetId,jdbcType=BIGINT},
            #{largeTemplet,jdbcType=INTEGER}
        </trim>
    </insert>

    <!--根据模板id查询大类id-->
    <select id="getByTempletId" parameterType="Long" resultMap="BaseResultMap">
        select <include refid="Base_Column_List"/> from templet_relevance
        where templet_id=#{templetId} order by id desc limit 1
    </select>
</mapper>