MagicTemplateConfigInfoMapper.xml 3.12 KB
<?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="cn.com.glsx.entmicro.mapper.MagicTemplateConfigInfoMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.entmicro.entity.magic.MagicTemplateConfigInfo">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="field_name" jdbcType="VARCHAR" property="fieldName"/>
        <result column="field_type" jdbcType="INTEGER" property="fieldType"/>
        <result column="field_comment" jdbcType="VARCHAR" property="fieldComment"/>
        <result column="field_length" jdbcType="INTEGER" property="fieldLength"/>
        <result column="field_primary" jdbcType="INTEGER" property="fieldPrimary"/>
        <result column="config_id" jdbcType="INTEGER" property="configId"/>
        <result column="cloumn_name" jdbcType="VARCHAR" property="cloumnName"/>
        <result column="cloumn_index" jdbcType="INTEGER" property="cloumnIndex"/>
        <result column="cloumn_regular" jdbcType="VARCHAR" property="cloumnRegular"/>
        <result column="cloumn_error_prompt" jdbcType="VARCHAR" property="cloumnErrorPrompt"/>
        <result column="field_base" jdbcType="INTEGER" property="fieldBase"/>
        <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
        <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
        <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
        <result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
        <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        id, field_name, field_type, field_comment, field_length, field_primary, config_id,
        cloumn_name, cloumn_index, cloumn_regular, cloumn_error_prompt, field_base, del_flag, created_by,
        created_time, updated_by, updated_time
    </sql>
    <select id="findByConfigId" resultMap="BaseResultMap">
        select * from magic_template_config_info where config_id=#{id}
    </select>


    <update id="createTable">
        CREATE TABLE IF NOT EXISTS ${tableConfig.magicTemplateConfig.tableName} (
        <foreach collection="tableConfig.magicTemplateConfigInfoList" item="conf" separator=",">
            <choose>
                <when test="conf.fieldPrimary==0">
                    ${conf.cloumnName} ${conf.fieldTypeName}<if test="conf.fieldType != 6  and conf.fieldLength != null">(${conf.fieldLength})</if>
                    COMMENT #{conf.fieldComment}
                </when>
                <when test="conf.fieldPrimary==1">
                    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT #{conf.fieldComment},
                    PRIMARY KEY (`id`)
                </when>
            </choose>
        </foreach>
        )
    </update>
    <select id="tableNameExists" resultType="java.lang.Integer">
        SELECT COUNT(1) FROM information_schema.TABLES WHERE table_name = #{tableName}
    </select>
</mapper>