All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mapper.generator.GenTableDAO.xml Maven / Gradle / Ivy

There is a newer version: 1.1.2.RELEASE
Show newest version
<?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="com.beli.gen.dao.GenTableDAO">

	<!-- 可根据自己的需求,是否要使用 -->
    <resultMap type="com.beli.gen.po.GenTablePO" id="genTableMap">
        <result property="id" column="table_id"/>
        <result property="tableName" column="table_name"/>
        <result property="tableComment" column="table_comment"/>
        <result property="className" column="class_name"/>
        <result property="tplCategory" column="tpl_category"/>
        <result property="packageName" column="package_name"/>
        <result property="moduleName" column="module_name"/>
        <result property="businessName" column="business_name"/>
        <result property="functionName" column="function_name"/>
        <result property="functionAuthor" column="function_author"/>
        <result property="genType" column="gen_type"/>
        <result property="needApi" column="need_api"/>
        <result property="needRunSql" column="need_run_sql"/>
        <result property="genPath" column="gen_path"/>
        <result property="genVuePath" column="gen_vue_path"/>
        <result property="options" column="options"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>
    <select id="selectDbTableList" resultType="map">
        <choose>
            <when test="databaseType != null and databaseType == 'oracle'">
                select a.TABLE_NAME as tableName , a.TABLESPACE_NAME as engine ,a.LAST_ANALYZED as CREATETIME, b.COMMENTS as TABLECOMMENT
                from user_tables a,user_tab_comments b
                WHERE a.TABLE_NAME=b.TABLE_NAME  and a.TABLE_NAME = #{tableName}
            </when>
            <otherwise>
                select table_name  as tableName , table_comment as tableComment,engine , date_format(create_time, '%Y-%m-%d %H:%m:%S') as createTime,
                date_format(update_time, '%Y-%m-%d %H:%m:%S') as updateTime from information_schema.tables
                where table_schema = (select database())
                AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%' AND table_name NOT LIKE 'act_%'
                AND table_name NOT IN (select table_name from gen_table)
                <if test="tableName != null and tableName != ''">
                    AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
                </if>
                <if test="tableComment != null and tableComment != ''">
                    AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
                </if>
                <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
                    AND date_format(create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
                </if>
                <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
                    AND date_format(create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
                </if>
            </otherwise>
        </choose>
    </select>

    <select id="queryTotal" resultType="int">
        <choose>
            <when test="databaseType == 'oracle'">
                select count(*)
                from user_tables a,user_tab_comments b
                WHERE a.TABLE_NAME=b.TABLE_NAME
                <if test="tableName != null and tableName.trim() != ''">
                    and a.TABLE_NAME like concat('%', #{tableName}, '%')
                </if>
                <if test="tableComment != null and tableComment != ''">
                    AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
                </if>
                <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
                    AND date_format(create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
                </if>
                <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
                    AND date_format(create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
                </if>
            </when>
            <otherwise>
                select count(*) from information_schema.tables where table_schema = (select database())
                AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%' AND table_name NOT LIKE 'act_%'
                AND table_name NOT IN (select table_name from gen_table)
                <if test="tableName != null and tableName.trim() != ''">
                    and table_name like concat('%', #{tableName}, '%')
                </if>
                <if test="tableComment != null and tableComment != ''">
                    AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
                </if>
                <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
                    AND date_format(create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
                </if>
                <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
                    AND date_format(create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
                </if>
            </otherwise>
        </choose>
    </select>

    <select id="selectDbTableListByNames" resultType="map">
        select table_name  as tableName , table_comment as tableComment,engine , date_format(create_time, '%Y-%m-%d %H:%m:%S') as createTime,
        date_format(update_time, '%Y-%m-%d %H:%m:%S') as updateTime
        from information_schema.tables
        where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_name NOT LIKE 'act_%' and table_schema = (select database())
        and table_name in
        <foreach collection="array" item="name" open="(" separator="," close=")">
            #{name}
        </foreach>
    </select>

    <insert id="insertGenTable" parameterType="com.beli.gen.bo.GenTableBO" useGeneratedKeys="true" keyProperty="id">
        insert into gen_table (
        <if test="tableName != null">table_name,</if>
        <if test="tableComment != null and tableComment != ''">table_comment,</if>
        <if test="className != null and className != ''">class_name,</if>
        <if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
        <if test="packageName != null and packageName != ''">package_name,</if>
        <if test="moduleName != null and moduleName != ''">module_name,</if>
        <if test="businessName != null and businessName != ''">business_name,</if>
        <if test="functionName != null and functionName != ''">function_name,</if>
        <if test="functionAuthor != null and functionAuthor != ''">function_author,</if>
        <if test="genType != null and genType != ''">gen_type,</if>
        <if test="genPath != null and genPath != ''">gen_path,</if>
        <if test="needApi != null and needApi != ''">need_api,</if>
        <if test="needRunSql != null">need_run_sql,</if>
        <if test="genVuePath != null and genVuePath != ''">gen_vue_path,</if>
        <if test="remark != null and remark != ''">remark,</if>
        <if test="createBy != null and createBy != ''">create_by,</if>
        create_time
        )values(
        <if test="tableName != null">#{tableName},</if>
        <if test="tableComment != null and tableComment != ''">#{tableComment},</if>
        <if test="className != null and className != ''">#{className},</if>
        <if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
        <if test="packageName != null and packageName != ''">#{packageName},</if>
        <if test="moduleName != null and moduleName != ''">#{moduleName},</if>
        <if test="businessName != null and businessName != ''">#{businessName},</if>
        <if test="functionName != null and functionName != ''">#{functionName},</if>
        <if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if>
        <if test="genType != null and genType != ''">#{genType},</if>
        <if test="genPath != null and genPath != ''">#{genPath},</if>
        <if test="needApi != null and needApi != ''">#{needApi},</if>
        <if test="needRunSql != null">#{needRunSql},</if>
        <if test="genVuePath != null and genVuePath != ''">#{genVuePath},</if>
        <if test="remark != null and remark != ''">#{remark},</if>
        <if test="createBy != null and createBy != ''">#{createBy},</if>
        sysdate()
        )
    </insert>

    <update id="updateGenTable" parameterType="com.beli.gen.bo.GenTableBO">
        update gen_table
        <set>
            <if test="tableName != null">table_name = #{tableName},</if>
            <if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
            <if test="className != null and className != ''">class_name = #{className},</if>
            <if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
            <if test="genType != null and genType != ''">gen_type = #{genType},</if>
            <if test="genPath != null and genPath != ''">gen_path = #{genPath},</if>
            need_api =#{needApi},need_run_sql=#{needRunSql},
            <if test="genVuePath != null and genVuePath != ''">gen_vue_path = #{genVuePath},</if>
            <if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if>
            <if test="packageName != null and packageName != ''">package_name = #{packageName},</if>
            <if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if>
            <if test="businessName != null and businessName != ''">business_name = #{businessName},</if>
            <if test="functionName != null and functionName != ''">function_name = #{functionName},</if>
            <if test="options != null and options != ''">options = #{options},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>
            update_time = sysdate()
        </set>
        where table_id = #{id}
    </update>


    <select id="selectTableByName" parameterType="String" resultMap="genTableMap">
		select table_name, table_comment, create_time, update_time from information_schema.tables
		where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
		and table_name = #{tableName}
	</select>


</mapper>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy