<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hswebframework.web.dao.form.DynamicFormColumnDao">
    <resultMap id="DynamicFormColumnResultMap" type="org.hswebframework.web.entity.form.DynamicFormColumnEntity">
        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
        <result property="formId" column="form_id" javaType="String" jdbcType="VARCHAR"/>
        <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
        <result property="columnName" column="column_name" javaType="String" jdbcType="VARCHAR"/>
        <result property="describe" column="describe" javaType="String" jdbcType="VARCHAR"/>
        <result property="alias" column="alias" javaType="String" jdbcType="VARCHAR"/>
        <result property="javaType" column="java_type" javaType="String" jdbcType="VARCHAR"/>
        <result property="jdbcType" column="jdbc_type" javaType="String" jdbcType="VARCHAR"/>
        <result property="dataType" column="data_type" javaType="String" jdbcType="VARCHAR"/>
        <result property="length" column="length" javaType="Integer" jdbcType="DECIMAL"/>
        <result property="precision" column="precision" javaType="Integer" jdbcType="DECIMAL"/>
        <result property="scale" column="scale" javaType="Integer" jdbcType="DECIMAL"/>
        <result property="dictConfig" column="dict_config" javaType="String" jdbcType="CLOB"/>
        <result property="sortIndex" column="sort_index" javaType="Long" jdbcType="DECIMAL"/>
        <result property="properties" column="properties" javaType="java.util.Map" jdbcType="CLOB"/>
        <result property="validator" column="validator" javaType="java.util.List" jdbcType="CLOB"/>
    </resultMap>

    <!--用于动态生成sql所需的配置-->
    <sql id="config">
        <bind name="resultMapId" value="'DynamicFormColumnResultMap'"/>
        <bind name="tableName" value="'s_dyn_form_column'"/>
    </sql>

    <insert id="insert" parameterType="org.hswebframework.web.entity.form.DynamicFormColumnEntity">
        <include refid="config"/>
        <include refid="BasicMapper.buildInsertSql"/>
    </insert>

    <delete id="deleteByPk" parameterType="String">
        delete from s_dyn_form_column where u_id =#{id}
    </delete>

    <delete id="delete" parameterType="org.hswebframework.web.commons.entity.Entity">
        <include refid="config"/>
        <include refid="BasicMapper.buildDeleteSql"/>
    </delete>

    <update id="update" parameterType="org.hswebframework.web.commons.entity.Entity">
        <include refid="config"/>
        <include refid="BasicMapper.buildUpdateSql"/>
    </update>

    <select id="query" parameterType="org.hswebframework.web.commons.entity.Entity" resultMap="DynamicFormColumnResultMap">
        <include refid="config"/>
        <include refid="BasicMapper.buildSelectSql"/>
    </select>

    <select id="count" parameterType="org.hswebframework.web.commons.entity.Entity" resultType="int">
        <include refid="config"/>
        <include refid="BasicMapper.buildTotalSql"/>
    </select>
</mapper>
