<?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="org.durcframework.autocode.dao.TemplateConfigDao">

	<resultMap id="queryResultMap" type="org.durcframework.autocode.entity.TemplateConfig">
		<result column="tc_id" property="tcId" jdbcType="INTEGER" />
		<result column="name" property="name" jdbcType="VARCHAR" />
		<result column="save_path" property="savePath" jdbcType="VARCHAR" />
		<result column="file_name" property="fileName" jdbcType="VARCHAR" />
		<result column="content" property="content" jdbcType="VARCHAR" />
		<result column="back_user" property="backUser" jdbcType="VARCHAR" />
	</resultMap>

	<select id="find" parameterType="org.durcframework.core.expression.ExpressionQuery"
		resultMap="queryResultMap">
		SELECT *
		FROM `template_config` t
		<include refid="expressionBlock.where" />
		<if test="sortname == null">
			ORDER BY `name`
		</if>
		<if test="sortname != null">
			ORDER BY ${order}
		</if>
		<if test="!isQueryAll">
			LIMIT
			#{firstResult,jdbcType=INTEGER},#{pageSize,jdbcType=INTEGER}
		</if>
	</select>

	<select id="findTotalCount" parameterType="org.durcframework.core.expression.ExpressionQuery"
		resultType="java.lang.Integer">
		SELECT count(*) FROM `template_config` t
		<include refid="expressionBlock.where" />
	</select>
	
	<insert id="save" parameterType="org.durcframework.autocode.entity.TemplateConfig" keyProperty="tcId" keyColumn="tc_id" useGeneratedKeys="true">
		INSERT INTO `template_config`
            (
             `name`,
             `save_path`,
             `file_name`,
             `content`,
             `back_user`,
             `suffix`)
		VALUES (
        #{name,jdbcType=VARCHAR},
        #{savePath,jdbcType=VARCHAR},
        #{fileName,jdbcType=VARCHAR},
        #{content,jdbcType=VARCHAR},
        #{backUser,jdbcType=VARCHAR},
        #{suffix,jdbcType=VARCHAR}
        )
	</insert>
	
	<update id="update" parameterType="org.durcframework.autocode.entity.TemplateConfig">
		UPDATE `template_config`
		SET 
		  `name` = #{name,jdbcType=VARCHAR},
		  `save_path` =  #{savePath,jdbcType=VARCHAR},
		  `file_name` =  #{fileName,jdbcType=VARCHAR},
		  `content` = #{content,jdbcType=VARCHAR},
		  `back_user` = #{backUser,jdbcType=VARCHAR},
		  `suffix` = #{suffix,jdbcType=VARCHAR}
		WHERE `tc_id` = #{tcId,jdbcType=INTEGER}
	</update>
	
	
	<select id="get" resultMap="queryResultMap" parameterType="java.io.Serializable">
		SELECT *
		FROM `template_config`
		WHERE tc_id = #{tcId,jdbcType=INTEGER}
	</select>
	
	<delete id="del" parameterType="org.durcframework.autocode.entity.TemplateConfig">
		DELETE FROM `template_config`
		WHERE tc_id = #{tcId,jdbcType=INTEGER}
	</delete>
	
</mapper>